64 QPainterPath baseGuidePath;
65 QPainterPath mouseGuidePath;
67 gc.setTransform(initialTransform);
90 double deltaX =
p2.x() -
p1.x();
91 double deltaY =
p2.y() -
p1.y();
96 QColor color = canvasAssistantColor;
97 QGradient fade = QLinearGradient(
98 QPointF(
p1.x() - deltaY,
p1.y() + deltaX),
99 QPointF(
p1.x() + deltaY,
p1.y() - deltaX));
101 color.setAlphaF(0.0);
102 fade.setColorAt(0.42, canvasAssistantColor);
103 fade.setColorAt(0.5, color);
104 fade.setColorAt(0.58, canvasAssistantColor);
105 const QPen pen = gc.pen();
106 const QBrush new_brush = QBrush(fade);
108 const QPen new_pen = QPen(new_brush, width, pen.style());
112 double halfHandleDist = handleDistance / 2.0;
114 double avgX = deltaX / 2.0 +
p1.x();
115 double avgY = deltaY / 2.0 +
p1.y();
119 double dirX = -deltaY / handleDistance;
120 double dirY = deltaX / handleDistance;
122 int resolution = halfHandleDist / 3;
124 if(assistantVisible) {
126 for(
int i = -resolution; i < resolution; i++) {
129 baseGuidePath.moveTo(QPointF(
p1.x() - deltaX*2,
p1.y() - deltaY*2));
130 baseGuidePath.lineTo(QPointF(
p2.x() + deltaX*2,
p2.y() + deltaY*2));
134 double mult = 1.0 / i;
136 double centerDist = halfHandleDist * (1 -
pow2(mult)) / (2*mult);
139 double circleCenterX = centerDist * dirX + avgX;
140 double circleCenterY = centerDist * dirY + avgY;
142 double radius = halfHandleDist * (1 +
pow2(mult)) / (2*mult);
144 baseGuidePath.addEllipse(QPointF(circleCenterX, circleCenterY), radius, radius);
147 gc.drawPath(baseGuidePath);
154 QPointF screenP1 = initialTransform.map(*
handles()[0]);
155 QPointF screenP2 = initialTransform.map(*
handles()[1]);
162 QLineF circle =
identifyCircle(initialTransform.inverted().map(mousePos));
163 double radius = circle.length();
164 mouseGuidePath.addEllipse(circle.p1(), radius, radius);
167 gc.drawPath(mouseGuidePath);
203 double deltaX =
p2.x() -
p1.x();
204 double deltaY =
p2.y() -
p1.y();
207 double halfHandleDist = handleDistance / 2.0;
209 double avgX = deltaX / 2.0 +
p1.x();
210 double avgY = deltaY / 2.0 +
p1.y();
212 double dirX = -deltaY / handleDistance;
213 double dirY = deltaX / handleDistance;
215 double betaX = thirdPoint.x() - avgX;
216 double betaY = thirdPoint.y() - avgY;
221 (2 * dirX * betaX + 2 * dirY * betaY);
223 double circleCenterX = centerDist*dirX + avgX;
224 double circleCenterY = centerDist*dirY + avgY;
225 return QLineF(QPointF(circleCenterX, circleCenterY), thirdPoint);
259 const QPointF delta =
p2 -
p1;
261 const qreal halfHandleDist = handleDistance / 2.0;
263 if (!std::isfinite(halfHandleDist) || halfHandleDist <= 0.0) {
267 const QPointF midpoint = (
p1 +
p2) * 0.5;
268 const QPointF normal(-delta.y() / handleDistance, delta.x() / handleDistance);
269 const qreal depth = QPointF::dotProduct(point - midpoint, normal) / halfHandleDist;
271 if (!std::isfinite(depth)) {
276 *signedDepth = depth;
void drawCache(QPainter &gc, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *displayRenderInterface, bool assistantVisible=true) override
performance layer where the graphics can be drawn from a cache instead of generated every render upda...
void drawAssistant(QPainter &gc, const QRectF &updateRect, const KisCoordinatesConverter *converter, const KoColorDisplayRendererInterface *displayRenderInterface, bool cached=true, KisCanvas2 *canvas=0, bool assistantVisible=true, bool previewVisible=true) override