22 , m_lastMousePos(clicked)
30 const QPointF padding(shapePadding+2, shapePadding+2);
31 const QPointF margin(shapeMargin+2, shapeMargin+2);
33 qreal minDistance = std::numeric_limits<qreal>::max();
35 bool isPadding =
false;
40 const QRectF marginRect(mp - margin, mp + margin);
42 Q_FOREACH(
KoPathSegment segment, path->segmentsAt(marginRect)) {
44 const QPointF nearestP = segment.
pointAt(nearestT);
57 const QRectF paddingRect(mp - padding, mp + padding);
59 qDebug() <<
"segments" << path->segmentsAt(paddingRect).size() << paddingRect;
60 Q_FOREACH(
KoPathSegment segment, path->segmentsAt(paddingRect)) {
62 const QPointF nearestP = segment.
pointAt(nearestT);
83 if (!shape)
return std::nullopt;
85 if (textAreas.isEmpty())
return std::nullopt;
87 const QPointF grab(grabSensitivityInPts, grabSensitivityInPts);
88 const QRectF grabRect(mousePos-grab, mousePos+grab);
105 if (!referenceShape)
return QLineF();
106 const bool hit = referenceShape->
hitTest(mousePos);
107 if ((!hit && isPadding) || (hit && !isPadding))
return QLineF();
112 qreal minDistance = std::numeric_limits<qreal>::max();
116 const QPointF nearestP = segment.
pointAt(nearestT);
123 if (l.length() < 0) {
133 previous.setProperty(propId, QVariant::fromValue(
length));
151 Q_FOREACH(QPainterPath area, areas) {
qreal length(const QPointF &vec)
float value(const T *src, size_t ch)
qreal distance(const QPointF &p1, const QPointF &p2)
QLineF getLine(QPointF mousePos, KoPathShape *referenceShape, bool isPadding)
KoSvgTextProperties getProperties(bool isPadding, QLineF line, KoSvgTextProperties previous=KoSvgTextProperties())
The KisHandlePainterHelper class is a special helper for painting handles around objects....
void drawPath(const QPainterPath &path)
void drawConnectionLine(const QLineF &line)
void setHandleStyle(const KisHandleStyle &style)
static KisHandleStyle & selectedPrimaryHandles()
uint decorationThickness() const
uint handleRadius() const
Convenience function to get the global handle radius.
A KoPathSegment consist of two neighboring KoPathPoints.
QPointF pointAt(qreal t) const
Returns point at given t.
QPointF angleVectorAtParam(qreal t)
angleVectorAtParam Calculates the angle vector at t.
qreal nearestPoint(const QPointF &point) const
bool isValid() const
Returns if segment is valid, e.g. has two valid points.
The position of a path point within a path shape.
KoPathSegment segmentAtPoint(const QPointF &point, const QRectF &grabRoi) const
bool hitTest(const QPointF &position) const override
reimplemented
QRectF outlineRect() const override
reimplemented
QList< KoPathSegment > segmentsAt(const QRectF &rect) const
Returns the list of path segments within the given rectangle.
static KoPathShape * createShapeFromPainterPath(const QPainterPath &path)
Creates path shape from given QPainterPath.
QPointF documentToShape(const QPointF &point) const
Transforms point from document coordinates to shape coordinates.
QTransform absoluteTransformation() const
void setTransformation(const QTransform &matrix)
static KisHandlePainterHelper createHandlePainterHelperView(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
static const KoSvgTextProperties & defaultProperties()
QVariant propertyOrDefault(PropertyId id) const
void inheritFrom(const KoSvgTextProperties &parentProperties, bool resolve=false)
QList< QPainterPath > textWrappingAreas() const
textWrappingAreas The text wrapping areas are computed from shapesInside() and shapesSubtract(),...
QList< KoShape * > shapesInside
QList< KoShape * > shapesSubtract
static QList< QPainterPath > generateTextAreas(const QList< KoShape * > shapesInside, const QList< KoShape * > shapesSubtract, const KoSvgTextProperties &props)
generateTextAreas Generates text areas with the given shapes and properties. This is used to paint pr...
KoSvgTextProperties textProperties() const
KUndo2Command * createCommand() override
void paint(QPainter &painter, const KoViewConverter &converter) override
~SvgChangeTextPaddingMarginStrategy()
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override
static std::optional< QPointF > hitTest(KoSvgTextShape *shape, const QPointF &mousePos, const qreal grabSensitivityInPts)
hitTest Tests whether the current mouse position is over a text wrapping area, and if so,...
KoPathShape * m_referenceShape
SvgChangeTextPaddingMarginStrategy(SvgTextTool *tool, KoSvgTextShape *shape, const QPointF &clicked)
void finishInteraction(Qt::KeyboardModifiers modifiers) override
The SvgTextMergePropertiesRangeCommand class This sets properties on a specific range in a single tex...
qreal kisDistance(const QPointF &pt1, const QPointF &pt2)