[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [Calligra] 2431bf7: add perspective value to KisPaintInformation
From: Geoffry Song <goffrie () gmail ! com>
Date: 2010-12-31 23:27:33
Message-ID: 20101231232733.F3A83A6090 () git ! kde ! org
[Download RAW message or body]
commit 2431bf7e0a12c1958f1bb26ce657d6ff84b29661
branch master
Author: Geoffry Song <goffrie@gmail.com>
Date: Wed Dec 29 14:41:44 2010 -0500
add perspective value to KisPaintInformation
diff --git a/krita/image/brushengine/kis_paint_information.cc \
b/krita/image/brushengine/kis_paint_information.cc index 7979679..44c7a96 100644
--- a/krita/image/brushengine/kis_paint_information.cc
+++ b/krita/image/brushengine/kis_paint_information.cc
@@ -30,6 +30,7 @@ struct KisPaintInformation::Private {
qreal angle;
qreal rotation;
qreal tangentialPressure;
+ qreal perspective;
int time;
};
@@ -38,6 +39,7 @@ KisPaintInformation::KisPaintInformation(const QPointF & pos_, \
qreal pressure_, const KisVector2D& movement_,
qreal rotation_,
qreal tangentialPressure_,
+ qreal perspective_,
int time)
: d(new Private)
{
@@ -48,6 +50,7 @@ KisPaintInformation::KisPaintInformation(const QPointF & pos_, \
qreal pressure_, d->movement = movement_;
d->rotation = rotation_;
d->tangentialPressure = tangentialPressure_;
+ d->perspective = perspective_;
d->angle = atan2(movement_.y(), movement_.x());
d->time = time;
}
@@ -78,6 +81,7 @@ void KisPaintInformation::toXML(QDomDocument&, QDomElement& e) \
const
e.setAttribute("movementY", QString::number(movement().y(), 'g', 15));
e.setAttribute("rotation", QString::number(rotation(), 'g', 15));
e.setAttribute("tangentialPressure", QString::number(tangentialPressure(), 'g', \
15)); + e.setAttribute("perspective", QString::number(perspective(), 'g', 15));
e.setAttribute("time", d->time);
}
@@ -88,6 +92,7 @@ KisPaintInformation KisPaintInformation::fromXML(const QDomElement& \
e) qreal pressure = qreal(e.attribute("pressure", "0.0").toDouble());
qreal rotation = qreal(e.attribute("rotation", "0.0").toDouble());
qreal tangentialPressure = qreal(e.attribute("tangentialPressure", \
"0.0").toDouble()); + qreal perspective = qreal(e.attribute("perspective", \
"0.0").toDouble()); qreal xTilt = qreal(e.attribute("xTilt", "0.0").toDouble());
qreal yTilt = qreal(e.attribute("yTilt", "0.0").toDouble());
qreal movementX = qreal(e.attribute("movementX", "0.0").toDouble());
@@ -95,7 +100,7 @@ KisPaintInformation KisPaintInformation::fromXML(const \
QDomElement& e) int time = e.attribute("time", "0").toInt();
return KisPaintInformation(QPointF(pointX, pointY), pressure, xTilt, yTilt, \
KisVector2D(movementX, movementY),
- rotation, tangentialPressure, time);
+ rotation, tangentialPressure, perspective, time);
}
const QPointF& KisPaintInformation::pos() const
@@ -148,6 +153,11 @@ qreal KisPaintInformation::tangentialPressure() const
return d->tangentialPressure;
}
+qreal KisPaintInformation::perspective() const
+{
+ return d->perspective;
+}
+
int KisPaintInformation::currentTime() const
{
return d->time;
@@ -165,6 +175,7 @@ QDebug operator<<(QDebug dbg, const KisPaintInformation &info)
dbg.nospace() << ", Movement: " << toQPointF(info.movement());
dbg.nospace() << ", Rotation: " << info.rotation();
dbg.nospace() << ", Tangential Pressure: " << info.tangentialPressure();
+ dbg.nospace() << ", Perspective: " << info.perspective();
dbg.nospace() << ", Angle: " << info.angle();
dbg.nospace() << ", Time: " << info.currentTime();
#endif
@@ -178,6 +189,7 @@ KisPaintInformation KisPaintInformation::mix(const QPointF& p, \
qreal t, const Ki qreal yTilt = (1 - t) * pi1.yTilt() + t * pi2.yTilt();
qreal rotation = (1 - t) * pi1.rotation() + t * pi2.rotation();
qreal tangentialPressure = (1 - t) * pi1.tangentialPressure() + t * \
pi2.tangentialPressure(); + qreal perspective = (1 - t) * pi1.perspective() + t * \
pi2.perspective(); int time = (1 - t) * pi1.currentTime() + t * pi2.currentTime();
- return KisPaintInformation(p, pressure, xTilt, yTilt, movement, rotation, \
tangentialPressure, time); + return KisPaintInformation(p, pressure, xTilt, yTilt, \
movement, rotation, tangentialPressure, perspective, time); }
diff --git a/krita/image/brushengine/kis_paint_information.h \
b/krita/image/brushengine/kis_paint_information.h index 4453529..78c64b4 100644
--- a/krita/image/brushengine/kis_paint_information.h
+++ b/krita/image/brushengine/kis_paint_information.h
@@ -50,6 +50,7 @@ class QDomElement;
* @param movement: current position minus the last position of the call to paintAt
* @param rotation
* @param tangentialPressure
+ * @param perspective
**/
class KRITAIMAGE_EXPORT KisPaintInformation
{
@@ -67,6 +68,7 @@ public:
const KisVector2D& movement = nullKisVector2D(),
qreal rotation = 0.0,
qreal tangentialPressure = 0.0,
+ qreal perspective = 1.0,
int time = 0);
KisPaintInformation(const KisPaintInformation& rhs);
@@ -102,6 +104,9 @@ public:
/// tangential pressure (i.e., rate for an airbrush device)
qreal tangentialPressure() const;
+
+ /// reciprocal of distance on the perspective grid
+ qreal perspective() const;
/// Number of ms since the beginning of the stroke
int currentTime() const;
diff --git a/krita/plugins/paintops/libpaintop/tests/kis_sensors_test.cpp \
b/krita/plugins/paintops/libpaintop/tests/kis_sensors_test.cpp index 5937b36..13ffeed \
100644
--- a/krita/plugins/paintops/libpaintop/tests/kis_sensors_test.cpp
+++ b/krita/plugins/paintops/libpaintop/tests/kis_sensors_test.cpp
@@ -23,14 +23,14 @@
KisSensorsTest::KisSensorsTest()
{
- paintInformations.append(KisPaintInformation(QPointF(0,0), 0, 0, 0, \
KisVector2D(0,1), 0.0, 0.0 ));
- paintInformations.append(KisPaintInformation(QPointF(0,1), 0, 0, 0, \
KisVector2D(1,1), 0.0, 0.0 ));
- paintInformations.append(KisPaintInformation(QPointF(1,2), 0, 0, 0, \
KisVector2D(1,0), 0.0, 0.0 ));
- paintInformations.append(KisPaintInformation(QPointF(2,2), 0, 0, 0, \
KisVector2D(1,-1), 0.0, 0.0 ));
- paintInformations.append(KisPaintInformation(QPointF(3,1), 0, 0, 0, \
KisVector2D(0,-1), 0.0, 0.0 ));
- paintInformations.append(KisPaintInformation(QPointF(3,0), 0, 0, 0, \
KisVector2D(-1,-1), 0.0, 0.0 ));
- paintInformations.append(KisPaintInformation(QPointF(2,-1), 0, 0, 0, \
KisVector2D(-1,0), 0.0, 0.0 ));
- paintInformations.append(KisPaintInformation(QPointF(1,-1), 0, 0, 0, \
KisVector2D(-1,1), 0.0, 0.0 )); + \
paintInformations.append(KisPaintInformation(QPointF(0,0), 0, 0, 0, KisVector2D(0,1), \
0.0, 0.0, 1.0 )); + paintInformations.append(KisPaintInformation(QPointF(0,1), 0, \
0, 0, KisVector2D(1,1), 0.0, 0.0, 1.0 )); + \
paintInformations.append(KisPaintInformation(QPointF(1,2), 0, 0, 0, KisVector2D(1,0), \
0.0, 0.0, 1.0 )); + paintInformations.append(KisPaintInformation(QPointF(2,2), 0, \
0, 0, KisVector2D(1,-1), 0.0, 0.0, 1.0 )); + \
paintInformations.append(KisPaintInformation(QPointF(3,1), 0, 0, 0, \
KisVector2D(0,-1), 0.0, 0.0, 1.0 )); + \
paintInformations.append(KisPaintInformation(QPointF(3,0), 0, 0, 0, \
KisVector2D(-1,-1), 0.0, 0.0, 1.0 )); + \
paintInformations.append(KisPaintInformation(QPointF(2,-1), 0, 0, 0, \
KisVector2D(-1,0), 0.0, 0.0, 1.0 )); + \
paintInformations.append(KisPaintInformation(QPointF(1,-1), 0, 0, 0, \
KisVector2D(-1,1), 0.0, 0.0, 1.0 )); }
void KisSensorsTest::testDrawingAngle()
diff --git a/krita/ui/tool/kis_tool_freehand.cc b/krita/ui/tool/kis_tool_freehand.cc
index bb50e6d..702c6dc 100644
--- a/krita/ui/tool/kis_tool_freehand.cc
+++ b/krita/ui/tool/kis_tool_freehand.cc
@@ -144,7 +144,7 @@ void KisToolFreehand::mousePressEvent(KoPointerEvent *e)
bool ignoreEvent = \
currentPaintOpPreset()->settings()->mousePressEvent(KisPaintInformation(convertToPixelCoord(e->point),
\
pressureToCurve(e->pressure()), e->xTilt(), e->yTilt(),
KisVector2D::Zero(),
- e->rotation(), \
e->tangentialPressure(), m_strokeTimeMeasure.elapsed()),e->modifiers()); + \
e->rotation(), e->tangentialPressure(), 1.0, \
m_strokeTimeMeasure.elapsed()),e->modifiers()); if (!ignoreEvent){
e->accept();
return;
@@ -168,7 +168,7 @@ void KisToolFreehand::mousePressEvent(KoPointerEvent *e)
m_previousPaintInformation = \
KisPaintInformation(convertToPixelCoord(adjustPosition(e->point, \
e->point)),
\
pressureToCurve(e->pressure()), e->xTilt(), e->yTilt(),
KisVector2D::Zero(),
- e->rotation(), \
e->tangentialPressure(), m_strokeTimeMeasure.elapsed()); + \
e->rotation(), e->tangentialPressure(), 1.0, m_strokeTimeMeasure.elapsed()); \
m_strokeBegin = e->point;
e->accept();
@@ -218,7 +218,7 @@ void KisToolFreehand::mouseMoveEvent(KoPointerEvent *e)
KisPaintInformation info =
KisPaintInformation(pos, pressureToCurve(e->pressure()),
e->xTilt(), e->yTilt(), toKisVector2D(dragVec),
- e->rotation(), e->tangentialPressure(),
+ e->rotation(), e->tangentialPressure(), 1.0,
m_strokeTimeMeasure.elapsed());
if (m_smooth) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic