23 , m_lastMousePos(clicked)
31 const QPointF padding(shapePadding+2, shapePadding+2);
32 const QPointF margin(shapeMargin+2, shapeMargin+2);
34 qreal minDistance = std::numeric_limits<qreal>::max();
36 bool isPadding =
false;
41 const QRectF marginRect(mp - margin, mp + margin);
43 Q_FOREACH(
KoPathSegment segment, path->segmentsAt(marginRect)) {
45 const QPointF nearestP = segment.
pointAt(nearestT);
58 const QRectF paddingRect(mp - padding, mp + padding);
60 qDebug() <<
"segments" << path->segmentsAt(paddingRect).size() << paddingRect;
61 Q_FOREACH(
KoPathSegment segment, path->segmentsAt(paddingRect)) {
63 const QPointF nearestP = segment.
pointAt(nearestT);
84 if (!shape)
return std::nullopt;
86 if (textAreas.isEmpty())
return std::nullopt;
88 const QPointF grab(grabSensitivityInPts, grabSensitivityInPts);
89 const QRectF grabRect(mousePos-grab, mousePos+grab);
106 if (!referenceShape)
return QLineF();
107 const bool hit = referenceShape->
hitTest(mousePos);
108 if ((!hit && isPadding) || (hit && !isPadding))
return QLineF();
113 qreal minDistance = std::numeric_limits<qreal>::max();
117 const QPointF nearestP = segment.
pointAt(nearestT);
124 if (l.length() < 0) {
134 previous.setProperty(propId, QVariant::fromValue(
length));
153 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(KisHandlePalette palette=KisHandlePalette())
virtual KisHandlePalette handlePaletteForDisplayColorSpace() const =0
handlePaletteForDisplayColorSpace
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()
void inheritFrom(const KoSvgTextProperties &parentProperties, bool resolve=false, bool onlyFontAndLineHeight=false)
QVariant propertyOrDefault(PropertyId id) const
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
~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 paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override
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)