29 , m_previewColor(0, 255, 0, 128)
30 , m_displayRenderer(canvas->displayRendererInterface())
69 QString message = i18n(
"This tool cannot paint on clone layers. Please select a paint or vector layer or mask.");
75 QString message = i18n(
"The MyPaint Brush Engine is not available for this colorspace");
90 m_path = QPainterPath(position);
91 m_path.setFillRule(Qt::WindingFill);
92 m_path.addEllipse(position, radius, radius);
114 update(segment.boundingRect());
175 QPointF offset = actualWidgetPosition - lastWidgetPosition;
179 QRect screenRect = QGuiApplication::primaryScreen()->availableVirtualGeometry();
186 const qreal effectiveMaxDragSize = 0.5 * screenRect.width();
187 const qreal effectiveMaxBrushSize = qMin(maxBrushSize, effectiveMaxDragSize / scaleX);
189 const qreal scaleCoeff = effectiveMaxBrushSize / effectiveMaxDragSize;
190 const qreal sizeDiff = scaleCoeff * offset.x() ;
192 if (qAbs(sizeDiff) > 0.01) {
198 newSize = qMax(qRound(newSize), 1);
201 newSize = qBound(0.01, newSize, maxBrushSize);
203 settings->setPaintOpSize(newSize);
231 if (strokeSegmentRect.isValid()) {
249 if (segmentRect.isValid() && outlineRect.isValid()) {
251 }
else if (segmentRect.isValid()) {
253 }
else if (outlineRect.isValid()) {
262 Q_UNUSED(documentPos);
272 QPainterPath outline;
355 const QPointF &
p1 = radius1 < radius2 ? point2 : point1;
356 const QPointF &
p2 = radius1 < radius2 ? point1 : point2;
357 const qreal &
r1 = radius1 < radius2 ? radius2 : radius1;
358 const qreal &
r2 = radius1 < radius2 ? radius1 : radius2;
359 const QPointF deltaP1P2 =
p2 -
p1;
360 const qreal deltaR1R2 =
r1 -
r2;
361 QPointF tangentPointP11, tangentPointP12, tangentPointP21, tangentPointP22;
365 const qreal deltaP1P2Length = std::sqrt(deltaP1P2.x() * deltaP1P2.x() + deltaP1P2.y() * deltaP1P2.y());
366 const QPointF deltaP1P2Normalized = deltaP1P2 / deltaP1P2Length;
367 tangentPointP11 =
p1 + QPointF(deltaP1P2Normalized.y(), -deltaP1P2Normalized.x()) *
r1;
368 tangentPointP12 =
p1 + QPointF(-deltaP1P2Normalized.y(), deltaP1P2Normalized.x()) *
r1;
369 tangentPointP21 =
p2 + QPointF(deltaP1P2Normalized.y(), -deltaP1P2Normalized.x()) *
r2;
370 tangentPointP22 =
p2 + QPointF(-deltaP1P2Normalized.y(), deltaP1P2Normalized.x()) *
r2;
373 const QPointF tangentIntersectionPoint(
374 (
p2.x() *
r1 -
p1.x() *
r2) / deltaR1R2,
375 (
p2.y() *
r1 -
p1.y() *
r2) / deltaR1R2
377 auto f = [](qreal t1, qreal t2, qreal t3, qreal t4, qreal
sign) -> qreal
379 return (t1 +
sign * t2) / t3 + t4;
382 const qreal r1Squared =
r1 *
r1;
383 const QPointF deltaP1TangentIntersectionPoint = tangentIntersectionPoint -
p1;
384 const qreal deltaP1TangentIntersectionPointLengthSquared =
385 deltaP1TangentIntersectionPoint.x() * deltaP1TangentIntersectionPoint.x() +
386 deltaP1TangentIntersectionPoint.y() * deltaP1TangentIntersectionPoint.y();
387 const QPointF t11 = r1Squared * deltaP1TangentIntersectionPoint;
388 const QPointF t12 =
r1 * deltaP1TangentIntersectionPoint * std::sqrt(deltaP1TangentIntersectionPointLengthSquared - r1Squared);
389 tangentPointP11 = QPointF(
390 f(t11.x(), t12.y(), deltaP1TangentIntersectionPointLengthSquared,
p1.x(), 1.0),
391 f(t11.y(), t12.x(), deltaP1TangentIntersectionPointLengthSquared,
p1.y(), -1.0)
393 tangentPointP12 = QPointF(
394 f(t11.x(), t12.y(), deltaP1TangentIntersectionPointLengthSquared,
p1.x(), -1.0),
395 f(t11.y(), t12.x(), deltaP1TangentIntersectionPointLengthSquared,
p1.y(), 1.0)
399 const qreal r2Squared =
r2 *
r2;
400 const QPointF deltaP2TangentIntersectionPoint = tangentIntersectionPoint -
p2;
401 const qreal deltaP2TangentIntersectionPointLengthSquared =
402 deltaP2TangentIntersectionPoint.x() * deltaP2TangentIntersectionPoint.x() +
403 deltaP2TangentIntersectionPoint.y() * deltaP2TangentIntersectionPoint.y();
404 const QPointF t11 = r2Squared * deltaP2TangentIntersectionPoint;
405 const QPointF t12 =
r2 * deltaP2TangentIntersectionPoint * std::sqrt(deltaP2TangentIntersectionPointLengthSquared - r2Squared);
406 tangentPointP21 = QPointF(
407 f(t11.x(), t12.y(), deltaP2TangentIntersectionPointLengthSquared,
p2.x(), 1.0),
408 f(t11.y(), t12.x(), deltaP2TangentIntersectionPointLengthSquared,
p2.y(), -1.0)
410 tangentPointP22 = QPointF(
411 f(t11.x(), t12.y(), deltaP2TangentIntersectionPointLengthSquared,
p2.x(), -1.0),
412 f(t11.y(), t12.x(), deltaP2TangentIntersectionPointLengthSquared,
p2.y(), 1.0)
418 path.setFillRule(Qt::WindingFill);
419 path.moveTo(tangentPointP11);
420 path.lineTo(tangentPointP21);
421 path.lineTo(tangentPointP22);
422 path.lineTo(tangentPointP12);
424 path.addEllipse(point2, radius2, radius2);
KisCoordinatesConverter * coordinatesConverter
void updateCanvas(const QRectF &rc) override
KisViewManager * viewManager() const
static KisConfigNotifier * instance()
QString pressureTabletCurve(bool defaultValue=false) const
CursorStyle newCursorStyle(bool defaultValue=false) const
OutlineStyle newOutlineStyle(bool defaultValue=false) const
bool forceAlwaysFullSizedOutline(bool defaultValue=false) const
bool showOutlineWhilePainting(bool defaultValue=false) const
void imageScale(qreal *scaleX, qreal *scaleY) const
static QCursor pixelBlackCursor()
static QCursor blankCursor()
static QCursor crossCursor()
static QCursor triangleRightHandedCursor()
static QCursor arrowCursor()
static QCursor triangleLeftHandedCursor()
static QCursor roundCursor()
static QCursor pixelWhiteCursor()
int maxBrushSize(bool defaultValue=false) const
void showFloatingMessage(const QString &message, const QIcon &icon, int timeout=4500, KisFloatingMessage::Priority priority=KisFloatingMessage::Medium, int alignment=Qt::AlignCenter|Qt::TextWordWrap)
shows a floating message in the top right corner of the canvas
virtual QColor convertColorToDisplayColorSpace(const KoColor color) const =0
convertColorToDisplayColorSpace
QPointF point
The point in document coordinates.
static bool qFuzzyIsNull(half h)
#define KIS_ASSERT_RECOVER_RETURN(cond)
T kisGrowRect(const T &rect, U offset)
@ CURSOR_STYLE_SMALL_ROUND
@ CURSOR_STYLE_TRIANGLE_RIGHTHANDED
@ CURSOR_STYLE_WHITE_PIXEL
@ CURSOR_STYLE_BLACK_PIXEL
@ CURSOR_STYLE_TRIANGLE_LEFTHANDED
#define koIcon(name)
Use these macros for icons without any issues.
const QVector< qreal > floatTransfer(int size=256) const
static qreal interpolateLinear(qreal normalizedValue, const QVector< qreal > &transfer)
static KoColorSpaceRegistry * instance()