Commit 7c22b7a5 authored by Cyrille Berger's avatar Cyrille Berger

make use of the sensor for size and darken options

svn path=/trunk/koffice/; revision=986468
parent 4ba9f5a6
......@@ -85,13 +85,14 @@ void KisComplexOp::paintAt(const KisPaintInformation& info)
Q_ASSERT(brush);
if (!brush) return;
KisPaintInformation adjustedInfo = settings->m_optionsWidget->m_sizeOption->apply(info);
if (! brush->canPaintFor(adjustedInfo))
if (! brush->canPaintFor(info))
return;
double scale = KisPaintOp::scaleForPressure(settings->m_optionsWidget->m_sizeOption->apply(info));
KisPaintDeviceSP device = painter()->device();
double pScale = KisPaintOp::scaleForPressure(adjustedInfo.pressure()); // TODO: why is there scale and pScale that seems to contains the same things ?
QPointF hotSpot = brush->hotSpot(pScale, pScale);
QPointF hotSpot = brush->hotSpot(scale, scale);
QPointF pt = info.pos() - hotSpot;
// Split the coordinates into integer plus fractional parts. The integer
......@@ -106,9 +107,7 @@ void KisComplexOp::paintAt(const KisPaintInformation& info)
splitCoordinate(pt.y(), &y, &yFraction);
quint8 origOpacity = settings->m_optionsWidget->m_opacityOption->apply(painter(), info);
KoColor origColor = settings->m_optionsWidget->m_darkenOption->apply(painter(), info.pressure());
double scale = KisPaintOp::scaleForPressure(adjustedInfo.pressure());
KoColor origColor = settings->m_optionsWidget->m_darkenOption->apply(painter(), info);
QRect dabRect = QRect(0, 0, brush->maskWidth(scale, 0.0), brush->maskHeight(scale, 0.0));
QRect dstRect = QRect(x, y, dabRect.width(), dabRect.height());
......@@ -127,7 +126,7 @@ void KisComplexOp::paintAt(const KisPaintInformation& info)
KisFixedPaintDeviceSP dab;
if (brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
dab = brush->image(device->colorSpace(), scale, 0.0, adjustedInfo, xFraction, yFraction);
dab = brush->image(device->colorSpace(), scale, 0.0, info, xFraction, yFraction);
} else {
dab = cachedDab();
KoColor color = painter()->paintColor();
......@@ -135,7 +134,7 @@ void KisComplexOp::paintAt(const KisPaintInformation& info)
brush->mask(dab, color, scale, scale, 0.0, info, xFraction, yFraction);
}
settings->m_optionsWidget->m_bidiOption->applyFixed(dab, device, painter(), sx, sy, sw, sh, adjustedInfo.pressure(), dstRect);
settings->m_optionsWidget->m_bidiOption->applyFixed(dab, device, painter(), sx, sy, sw, sh, scale, dstRect);
painter()->bltFixed(dstRect.x(), dstRect.y(), dab, sx, sy, sw, sh);
......@@ -143,17 +142,3 @@ void KisComplexOp::paintAt(const KisPaintInformation& info)
painter()->setPaintColor(origColor);
}
double KisComplexOp::paintLine(const KisPaintInformation &pi1,
const KisPaintInformation &pi2,
double savedDist)
{
KisPaintInformation adjustedInfo1(pi1);
KisPaintInformation adjustedInfo2(pi2);
if (!settings->m_optionsWidget->m_sizeOption->isChecked()) {
adjustedInfo1.setPressure(PRESSURE_DEFAULT);
adjustedInfo2.setPressure(PRESSURE_DEFAULT);
}
return KisPaintOp::paintLine(adjustedInfo1, adjustedInfo2, savedDist);
}
......@@ -48,9 +48,6 @@ public:
virtual ~KisComplexOp();
void paintAt(const KisPaintInformation& info);
virtual double paintLine(const KisPaintInformation &pi1,
const KisPaintInformation &pi2,
double savedDist = -1);
private:
......
......@@ -81,14 +81,14 @@ void KisBrushOp::paintAt(const KisPaintInformation& info)
Q_ASSERT(brush);
if (!brush) return;
KisPaintInformation adjustedInfo = settings->m_optionsWidget->m_sizeOption->apply(info);
if (!brush->canPaintFor(adjustedInfo))
if (!brush->canPaintFor(info))
return;
double scale = KisPaintOp::scaleForPressure(settings->m_optionsWidget->m_sizeOption->apply(info));
KisPaintDeviceSP device = painter()->device();
double pScale = KisPaintOp::scaleForPressure(adjustedInfo.pressure()); // TODO: why is there scale and pScale that seems to contains the same things ?
QPointF hotSpot = brush->hotSpot(pScale, pScale);
QPointF hotSpot = brush->hotSpot(scale, scale);
QPointF pt = info.pos() - hotSpot;
// Split the coordinates into integer plus fractional parts. The integer
......@@ -103,13 +103,11 @@ void KisBrushOp::paintAt(const KisPaintInformation& info)
splitCoordinate(pt.y(), &y, &yFraction);
quint8 origOpacity = settings->m_optionsWidget->m_opacityOption->apply(painter(), info);
KoColor origColor = settings->m_optionsWidget->m_darkenOption->apply(painter(), info.pressure());
double scale = KisPaintOp::scaleForPressure(adjustedInfo.pressure());
KoColor origColor = settings->m_optionsWidget->m_darkenOption->apply(painter(), info);
KisFixedPaintDeviceSP dab = cachedDab(device->colorSpace());
if (brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
dab = brush->image(device->colorSpace(), scale, 0.0, adjustedInfo, xFraction, yFraction);
dab = brush->image(device->colorSpace(), scale, 0.0, info, xFraction, yFraction);
} else {
KoColor color = painter()->paintColor();
color.convertTo(dab->colorSpace());
......
......@@ -102,13 +102,13 @@ void KisEraseOp::paintAt(const KisPaintInformation& info)
Q_ASSERT(brush);
if (!brush) return;
KisPaintInformation adjustedInfo = settings->m_optionsWidget->m_sizeOption->apply(info);
if (! brush->canPaintFor(adjustedInfo))
if (! brush->canPaintFor(info))
return;
double scale = KisPaintOp::scaleForPressure(settings->m_optionsWidget->m_sizeOption->apply(info));
KisPaintDeviceSP device = painter()->device();
double pScale = KisPaintOp::scaleForPressure(adjustedInfo.pressure()); // TODO: why is there scale and pScale that seems to contains the same things ?
QPointF hotSpot = brush->hotSpot(pScale, pScale);
QPointF hotSpot = brush->hotSpot(scale, scale);
QPointF pt = info.pos() - hotSpot;
qint32 x;
......@@ -123,8 +123,6 @@ void KisEraseOp::paintAt(const KisPaintInformation& info)
quint8 origOpacity = settings->m_optionsWidget->m_opacityOption->apply(painter(), info);
double scale = KisPaintOp::scaleForPressure(adjustedInfo.pressure());
QRect dabRect = QRect(0, 0, brush->maskWidth(scale, 0.0), brush->maskHeight(scale, 0.0));
QRect dstRect = QRect(x, y, dabRect.width(), dabRect.height());
......@@ -141,7 +139,7 @@ void KisEraseOp::paintAt(const KisPaintInformation& info)
qint32 sh = dstRect.height();
if (brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
dab = brush->image(device->colorSpace(), scale, 0.0, adjustedInfo, xFraction, yFraction);
dab = brush->image(device->colorSpace(), scale, 0.0, info, xFraction, yFraction);
} else {
dab = cachedDab();
KoColor color = painter()->paintColor();
......
......@@ -83,13 +83,13 @@ void KisPenOp::paintAt(const KisPaintInformation& info)
Q_ASSERT(brush);
if (!brush) return;
KisPaintInformation adjustedInfo = settings->m_optionsWidget->m_sizeOption->apply(info);
if (! brush->canPaintFor(adjustedInfo))
if (! brush->canPaintFor(info))
return;
double scale = KisPaintOp::scaleForPressure(settings->m_optionsWidget->m_sizeOption->apply(info));
KisPaintDeviceSP device = painter()->device();
double pScale = KisPaintOp::scaleForPressure(adjustedInfo.pressure()); // TODO: why is there scale and pScale that seems to contains the same things ?
QPointF hotSpot = brush->hotSpot(pScale, pScale);
QPointF hotSpot = brush->hotSpot(scale, scale);
QPointF pt = info.pos() - hotSpot;
// Split the coordinates into integer plus fractional parts. The integer
......@@ -99,9 +99,7 @@ void KisPenOp::paintAt(const KisPaintInformation& info)
qint32 y = qRound( pt.y() );
quint8 origOpacity = settings->m_optionsWidget->m_opacityOption->apply(painter(), info);
KoColor origColor = settings->m_optionsWidget->m_darkenOption->apply(painter(), info.pressure());
double scale = KisPaintOp::scaleForPressure(adjustedInfo.pressure());
KoColor origColor = settings->m_optionsWidget->m_darkenOption->apply(painter(), info);
KisFixedPaintDeviceSP dab = cachedDab();
......
......@@ -93,13 +93,13 @@ void KisSmudgeOp::paintAt(const KisPaintInformation& info)
Q_ASSERT(brush);
if (!brush) return;
KisPaintInformation adjustedInfo = settings->m_optionsWidget->m_sizeOption->apply(info);
if (! brush->canPaintFor(adjustedInfo))
if (! brush->canPaintFor(info))
return;
double scale = KisPaintOp::scaleForPressure(settings->m_optionsWidget->m_sizeOption->apply(info));
KisPaintDeviceSP device = painter()->device();
double pScale = KisPaintOp::scaleForPressure(adjustedInfo.pressure());
QPointF hotSpot = brush->hotSpot(pScale, pScale);
QPointF hotSpot = brush->hotSpot(scale, scale);
QPointF pt = info.pos() - hotSpot;
// Split the coordinates into integer plus fractional parts. The integer
......@@ -115,20 +115,18 @@ void KisSmudgeOp::paintAt(const KisPaintInformation& info)
KisFixedPaintDeviceSP dab = 0;
double scale = KisPaintOp::scaleForPressure(adjustedInfo.pressure());
QRect dabRect = QRect(0, 0, brush->maskWidth(scale, 0.0), brush->maskHeight(scale, 0.0));
QRect dstRect = QRect(x, y, dabRect.width(), dabRect.height());
if (dstRect.isNull() || dstRect.isEmpty() || !dstRect.isValid()) return;
if (brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
dab = brush->image(device->colorSpace(), pScale, 0.0, adjustedInfo, xFraction, yFraction);
dab = brush->image(device->colorSpace(), scale, 0.0, info, xFraction, yFraction);
dab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
} else {
dab = cachedDab();
KoColor color = painter()->paintColor();
dab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
brush->mask(dab, color, scale, pScale, 0.0, info, xFraction, yFraction);
brush->mask(dab, color, scale, scale, 0.0, info, xFraction, yFraction);
}
qint32 sw = dab->bounds().width();
......
......@@ -94,12 +94,12 @@ void KisFilterOp::paintAt(const KisPaintInformation& info)
KisBrushSP brush = m_brush;;
if (!brush) return;
KisPaintInformation adjustedInfo = settings->m_optionsWidget->m_sizeOption->apply(info);
if (! brush->canPaintFor(adjustedInfo))
if (! brush->canPaintFor(info))
return;
double pScale = KisPaintOp::scaleForPressure(adjustedInfo.pressure()); // TODO: why is there scale and pScale that seems to contains the same things ?
QPointF hotSpot = brush->hotSpot(pScale, pScale);
double scale = KisPaintOp::scaleForPressure(settings->m_optionsWidget->m_sizeOption->apply(info));
QPointF hotSpot = brush->hotSpot(scale, scale);
QPointF pt = info.pos() - hotSpot;
......@@ -114,8 +114,6 @@ void KisFilterOp::paintAt(const KisPaintInformation& info)
splitCoordinate(pt.x(), &x, &xFraction);
splitCoordinate(pt.y(), &y, &yFraction);
double scale = KisPaintOp::scaleForPressure(adjustedInfo.pressure());
qint32 maskWidth = brush->maskWidth(scale, 0.0);
qint32 maskHeight = brush->maskHeight(scale, 0.0);
......@@ -170,16 +168,3 @@ void KisFilterOp::paintAt(const KisPaintInformation& info)
painter()->bitBlt(dstRect.x(), dstRect.y(), m_tmpDevice, sx, sy, sw, sh);
}
double KisFilterOp::paintLine(const KisPaintInformation &pi1,
const KisPaintInformation &pi2,
double savedDist)
{
KisPaintInformation adjustedInfo1(pi1);
KisPaintInformation adjustedInfo2(pi2);
if (!settings->m_optionsWidget->m_sizeOption->isChecked()) {
adjustedInfo1.setPressure(PRESSURE_DEFAULT);
adjustedInfo2.setPressure(PRESSURE_DEFAULT);
}
return KisPaintOp::paintLine(adjustedInfo1, adjustedInfo2, savedDist);
}
......@@ -41,9 +41,6 @@ public:
virtual ~KisFilterOp();
void paintAt(const KisPaintInformation& info);
virtual double paintLine(const KisPaintInformation &pi1,
const KisPaintInformation &pi2,
double savedDist = -1);
private:
......
......@@ -28,7 +28,7 @@ KisPressureDarkenOption::KisPressureDarkenOption()
}
KoColor KisPressureDarkenOption::apply(KisPainter * painter, double pressure) const
KoColor KisPressureDarkenOption::apply(KisPainter * painter, const KisPaintInformation& info) const
{
if (!isChecked()) {
return painter->paintColor();
......@@ -38,12 +38,7 @@ KoColor KisPressureDarkenOption::apply(KisPainter * painter, double pressure) co
KoColor origColor = darkened;
// Darken docs aren't really clear about what exactly the amount param can have as value...
quint32 darkenAmount;
if (!customCurve()) {
darkenAmount = (qint32)(255 - 75 * pressure);
} else {
darkenAmount = (qint32)(255 - 75 * scaleToCurve(pressure));
}
quint32 darkenAmount = (qint32)(255 - 75 * computeValue(info));
KoColorTransformation* darkenTransformation = darkened.colorSpace()->createDarkenAdjustment(darkenAmount, false, 0.0);
darkenTransformation ->transform(painter->paintColor().data(), darkened.data(), 1);
painter->setPaintColor(darkened);
......
......@@ -36,7 +36,7 @@ public:
KisPressureDarkenOption();
KoColor apply(KisPainter * painter, double pressure) const;
KoColor apply(KisPainter * painter, const KisPaintInformation& info) const;
};
#endif
......@@ -29,16 +29,7 @@ KisPressureSizeOption::KisPressureSizeOption()
}
KisPaintInformation KisPressureSizeOption::apply(const KisPaintInformation & info) const
double KisPressureSizeOption::apply(const KisPaintInformation & info) const
{
KisPaintInformation adjustedInfo(info);
if (!isChecked()) {
adjustedInfo.setPressure(PRESSURE_DEFAULT);
} else {
if (customCurve()) {
adjustedInfo.setPressure(scaleToCurve(adjustedInfo.pressure()));
}
}
return adjustedInfo;
return computeValue(info);
}
......@@ -32,7 +32,7 @@ class PAINTOP_EXPORT KisPressureSizeOption : public KisCurveOption
{
public:
KisPressureSizeOption();
KisPaintInformation apply(const KisPaintInformation & info) const;
double apply(const KisPaintInformation & info) const;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment