Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgTextOnPathDecorationHelper Class Reference

The SvgTextOnPathDecorationHelper class. More...

#include <SvgTextOnPathDecorationHelper.h>

Classes

struct  Private
 

Public Member Functions

QRectF decorationRect (const QTransform documentToView) const
 decorationRect
 
bool hitTest (QPointF mouseInPts, const QTransform viewToDocument)
 hitTest
 
void paint (QPainter *painter, const KoViewConverter &converter)
 paint Paint the handles for the text path.
 
void setDecorationThickness (qreal thickness)
 
void setHandleRadius (qreal radius)
 
void setPos (int pos)
 setPos the the position of the cursor, where the text path is sought. A single text shape can have multiple paths, and this is how they are distinguished.
 
void setShape (KoSvgTextShape *shape)
 setShape Set the shape for which to draw the text path.
 
void setStrategyActive (bool isActive)
 
 SvgTextOnPathDecorationHelper ()
 
 ~SvgTextOnPathDecorationHelper ()
 

Private Attributes

QScopedPointer< Privated
 

Detailed Description

The SvgTextOnPathDecorationHelper class.

Definition at line 18 of file SvgTextOnPathDecorationHelper.h.

Constructor & Destructor Documentation

◆ SvgTextOnPathDecorationHelper()

SvgTextOnPathDecorationHelper::SvgTextOnPathDecorationHelper ( )

Definition at line 45 of file SvgTextOnPathDecorationHelper.cpp.

45 : d(new Private)
46{
47
48}

◆ ~SvgTextOnPathDecorationHelper()

SvgTextOnPathDecorationHelper::~SvgTextOnPathDecorationHelper ( )

Definition at line 50 of file SvgTextOnPathDecorationHelper.cpp.

51{
52
53}

Member Function Documentation

◆ decorationRect()

QRectF SvgTextOnPathDecorationHelper::decorationRect ( const QTransform documentToView) const

decorationRect

Parameters
documentToView– document to view transform.
Returns
the decoration rect.

Definition at line 115 of file SvgTextOnPathDecorationHelper.cpp.

116{
117 QRectF r;
118 if (!d->shape) return r;
119 KoSvgTextNodeIndex index = d->shape->topLevelNodeForPos(d->pos);
120 if (!(index.textPath() && index.textPathInfo())) return r;
121 QPointF handleInPts = documentToView.inverted().map(QPointF(d->handleRadius, d->handleRadius));
122
123 QLineF line = d->getLineAnchorTextNode(index, handleInPts.x()*3);
124
125 line = QTransform(d->shape->absoluteTransformation()*documentToView).map(line);
126 r |= QRectF(line.p1()-QPointF(d->decorationThickness, d->decorationThickness)
127 , line.p2()+QPointF(d->decorationThickness, d->decorationThickness));
128
129 QPointF handle(d->handleRadius, d->handleRadius);
130 r |= QRectF(line.p2() - handle, line.p2() + handle);
131
132 //qDebug() << "decor rect" << r << line.p2();
133 return r;
134}
The KoSvgTextNodeIndex class.
KoShape * textPath()
textPath
KoSvgText::TextOnPathInfo * textPathInfo()
textPathInfo the text path info for this node as a pointer.

References d, KoSvgTextNodeIndex::textPath(), and KoSvgTextNodeIndex::textPathInfo().

◆ hitTest()

bool SvgTextOnPathDecorationHelper::hitTest ( QPointF mouseInPts,
const QTransform viewToDocument )

hitTest

Returns
whether the current position is over a handle.

Definition at line 75 of file SvgTextOnPathDecorationHelper.cpp.

76{
77 if (!d->shape) return false;
78 KoSvgTextNodeIndex index = d->shape->topLevelNodeForPos(d->pos);
79 if (!(index.textPath() && index.textPathInfo())) return false;
80 QPointF handleInPts = viewToDocument.map(QPointF(d->handleRadius, d->handleRadius));
81
82 QLineF line = d->getLineAnchorTextNode(index, handleInPts.x()*2);
83 line = d->shape->absoluteTransformation().map(line);
84 bool hit = (QLineF(line.p2(), mouseInPts).length() <= handleInPts.x()*2);
85 d->isHovered = hit;
86 return hit;
87}

References d, KoSvgTextNodeIndex::textPath(), and KoSvgTextNodeIndex::textPathInfo().

◆ paint()

void SvgTextOnPathDecorationHelper::paint ( QPainter * painter,
const KoViewConverter & converter )

paint Paint the handles for the text path.

Definition at line 89 of file SvgTextOnPathDecorationHelper.cpp.

90{
91 if (!d->shape) return;
92 KoSvgTextNodeIndex index = d->shape->topLevelNodeForPos(d->pos);
93 if (!(index.textPath() && index.textPathInfo())) return;
94
95 QPointF handleInPts = converter.viewToDocument().map(QPointF(d->handleRadius, d->handleRadius));
96 QLineF line = d->getLineAnchorTextNode(index, handleInPts.x()*3);
97 p->save();
99 KoShape::createHandlePainterHelperView(p, d->shape, converter, d->handleRadius, d->decorationThickness);
100
101 if (d->isActive) {
103 } else if (d->isHovered) {
105 } else {
107 }
108
109 helper.drawConnectionLine(line);
110 helper.drawHandleCircle(line.p2());
111 //qDebug() << line.p2();
112 p->restore();
113}
const Params2D p
The KisHandlePainterHelper class is a special helper for painting handles around objects....
void drawConnectionLine(const QLineF &line)
void setHandleStyle(const KisHandleStyle &style)
void drawHandleCircle(const QPointF &center, qreal radius)
static KisHandleStyle & highlightedPrimaryHandles()
static KisHandleStyle & selectedPrimaryHandles()
static KisHandleStyle & primarySelection()
static KisHandlePainterHelper createHandlePainterHelperView(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
Definition KoShape.cpp:982
virtual QPointF viewToDocument(const QPointF &viewPoint) const

References KoShape::createHandlePainterHelperView(), d, KisHandlePainterHelper::drawConnectionLine(), KisHandlePainterHelper::drawHandleCircle(), KisHandleStyle::highlightedPrimaryHandles(), p, KisHandleStyle::primarySelection(), KisHandleStyle::selectedPrimaryHandles(), KisHandlePainterHelper::setHandleStyle(), KoSvgTextNodeIndex::textPath(), KoSvgTextNodeIndex::textPathInfo(), and KoViewConverter::viewToDocument().

◆ setDecorationThickness()

void SvgTextOnPathDecorationHelper::setDecorationThickness ( qreal thickness)

Definition at line 70 of file SvgTextOnPathDecorationHelper.cpp.

71{
72 d->decorationThickness = thickness;
73}

References d.

◆ setHandleRadius()

void SvgTextOnPathDecorationHelper::setHandleRadius ( qreal radius)

Definition at line 65 of file SvgTextOnPathDecorationHelper.cpp.

66{
67 d->handleRadius = radius;
68}

References d.

◆ setPos()

void SvgTextOnPathDecorationHelper::setPos ( int pos)

setPos the the position of the cursor, where the text path is sought. A single text shape can have multiple paths, and this is how they are distinguished.

Parameters
pos– a text cursor position.

Definition at line 55 of file SvgTextOnPathDecorationHelper.cpp.

56{
57 d->pos = pos;
58}

References d.

◆ setShape()

void SvgTextOnPathDecorationHelper::setShape ( KoSvgTextShape * shape)

setShape Set the shape for which to draw the text path.

Parameters
shape– text shape.

Definition at line 60 of file SvgTextOnPathDecorationHelper.cpp.

61{
62 d->shape = shape;
63}

References d.

◆ setStrategyActive()

void SvgTextOnPathDecorationHelper::setStrategyActive ( bool isActive)

Definition at line 136 of file SvgTextOnPathDecorationHelper.cpp.

137{
138 d->isActive = isActive;
139}

References d.

Member Data Documentation

◆ d

QScopedPointer<Private> SvgTextOnPathDecorationHelper::d
private

Definition at line 67 of file SvgTextOnPathDecorationHelper.h.


The documentation for this class was generated from the following files: