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

#include <KoPathToolHandle.h>

+ Inheritance diagram for PointHandle:

Public Member Functions

KoPathPointactivePoint () const
 
KoPathPoint::PointType activePointType () const
 
QRectF boundingRect () const override
 
bool check (const QList< KoPathShape * > &selectedShapes) override
 
KoInteractionStrategyhandleMousePress (KoPointerEvent *event) override
 
void paint (QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness) override
 
 PointHandle (KoPathTool *tool, KoPathPoint *activePoint, KoPathPoint::PointType activePointType)
 
void trySelectHandle () override
 
- Public Member Functions inherited from KoPathToolHandle
 KoPathToolHandle (KoPathTool *tool)
 
virtual ~KoPathToolHandle ()
 

Private Attributes

KoPathPointm_activePoint
 
KoPathPoint::PointType m_activePointType
 
QRectF m_oldRepaintedRect
 

Additional Inherited Members

- Protected Attributes inherited from KoPathToolHandle
KoPathToolm_tool
 

Detailed Description

Definition at line 45 of file KoPathToolHandle.h.

Constructor & Destructor Documentation

◆ PointHandle()

PointHandle::PointHandle ( KoPathTool * tool,
KoPathPoint * activePoint,
KoPathPoint::PointType activePointType )

Definition at line 36 of file KoPathToolHandle.cpp.

37 : KoPathToolHandle(tool)
40{
41}
KoPathToolHandle(KoPathTool *tool)
KoPathPoint::PointType m_activePointType
KoPathPoint * activePoint() const
KoPathPoint * m_activePoint
KoPathPoint::PointType activePointType() const

Member Function Documentation

◆ activePoint()

KoPathPoint * PointHandle::activePoint ( ) const

Definition at line 141 of file KoPathToolHandle.cpp.

142{
143 return m_activePoint;
144}

References m_activePoint.

◆ activePointType()

KoPathPoint::PointType PointHandle::activePointType ( ) const

Definition at line 146 of file KoPathToolHandle.cpp.

147{
148 return m_activePointType;
149}

References m_activePointType.

◆ boundingRect()

QRectF PointHandle::boundingRect ( ) const
overridevirtual

Implements KoPathToolHandle.

Definition at line 75 of file KoPathToolHandle.cpp.

76{
77 bool active = false;
78 KoPathToolSelection * selection = dynamic_cast<KoPathToolSelection*>(m_tool->selection());
79 if (selection && selection->contains(m_activePoint))
80 active = true;
81 return m_activePoint->boundingRect(!active);
82}
QRectF boundingRect(bool active=true) const
Get the bounding rect of the point.
KoPathTool * m_tool
Handle the selection of points.
bool contains(KoPathPoint *point)
Check if a point is in the selection.
KoToolSelection * selection() override

References KoPathPoint::boundingRect(), KoPathToolSelection::contains(), m_activePoint, KoPathToolHandle::m_tool, and KoPathTool::selection().

◆ check()

bool PointHandle::check ( const QList< KoPathShape * > & selectedShapes)
overridevirtual

Implements KoPathToolHandle.

Definition at line 133 of file KoPathToolHandle.cpp.

134{
135 if (selectedShapes.contains(m_activePoint->parent())) {
137 }
138 return false;
139}
QPair< int, int > KoPathPointIndex
Definition KoPathShape.h:28
KoPathShape * parent() const
Get the path shape the point belongs to.
KoPathPointIndex pathPointIndex(const KoPathPoint *point) const
Returns the path point index of a given path point.

References m_activePoint, KoPathPoint::parent(), and KoPathShape::pathPointIndex().

◆ handleMousePress()

KoInteractionStrategy * PointHandle::handleMousePress ( KoPointerEvent * event)
overridevirtual

Implements KoPathToolHandle.

Definition at line 84 of file KoPathToolHandle.cpp.

85{
86 if ((event->button() & Qt::LeftButton) == 0)
87 return 0;
88 if ((event->modifiers() & Qt::ControlModifier) == 0) { // no shift pressed.
89 KoPathToolSelection * selection = dynamic_cast<KoPathToolSelection*>(m_tool->selection());
91
92 // control select adds/removes points to/from the selection
93 if (event->modifiers() & Qt::ShiftModifier) {
94 if (selection->contains(m_activePoint)) {
95 selection->remove(m_activePoint);
96 } else {
97 selection->add(m_activePoint, false);
98 }
99 } else {
100 // no control modifier, so clear selection and select active point
101 if (!selection->contains(m_activePoint)) {
102 selection->add(m_activePoint, true);
103 }
104 }
105 // TODO remove canvas from call ?
107 QPointF movedPointPosition = m_activePoint->parent()->shapeToDocument(m_activePoint->point());
108 return new KoPathPointMoveStrategy(m_tool, event->point, movedPointPosition);
109 } else {
110 KoPathShape * pathShape = m_activePoint->parent();
111 KoPathPointData pd(pathShape, pathShape->pathPointIndex(m_activePoint));
113 }
114 } else {
115 KoPathPoint::PointProperties props = m_activePoint->properties();
117 return 0;
118
120 // cycle the smooth->symmetric->unsmooth state of the path point
121 if (props & KoPathPoint::IsSmooth)
123 else if (props & KoPathPoint::IsSymmetric)
125
126 QList<KoPathPointData> pointData;
128 m_tool->canvas()->addCommand(new KoPathPointTypeCommand(pointData, pointType));
129 }
130 return 0;
131}
virtual void addCommand(KUndo2Command *command)=0
Strategy for moving points of a path shape.
Describe a KoPathPoint by a KoPathShape and its indices.
Strategy for moving points of a path shape.
The undo / redo command for changing the path point type.
PointType
The type of the point.
PointProperties properties
QPointF point
@ IsSmooth
it is smooth, both control points on a line through the point
Definition KoPathPoint.h:41
@ IsSymmetric
it is symmetric, like smooth but control points have same distance to point
Definition KoPathPoint.h:42
@ Node
the node point
Definition KoPathPoint.h:49
bool activeControlPoint1
bool activeControlPoint2
The position of a path point within a path shape.
Definition KoPathShape.h:63
void add(KoPathPoint *point, bool clear)
Add a point to the selection.
void remove(KoPathPoint *point)
Remove a point form the selection.
Qt::MouseButton button() const
return button pressed (see QMouseEvent::button());
Qt::KeyboardModifiers modifiers() const
QPointF point
The point in document coordinates.
QPointF shapeToDocument(const QPointF &point) const
Transforms point from shape coordinates to document coordinates.
Definition KoShape.cpp:1201
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References KoPathPoint::activeControlPoint1, KoPathPoint::activeControlPoint2, KoPathToolSelection::add(), KoCanvasBase::addCommand(), KoPointerEvent::button(), KoToolBase::canvas(), KoPathToolSelection::contains(), KoPathPointTypeCommand::Corner, KoPathPoint::IsSmooth, KoPathPoint::IsSymmetric, KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, m_activePoint, m_activePointType, KoPathToolHandle::m_tool, KoPointerEvent::modifiers(), KoPathPoint::Node, KoPathPoint::parent(), KoPathShape::pathPointIndex(), KoPathPoint::point, KoPointerEvent::point, KoPathPoint::properties, KoPathToolSelection::remove(), KoPathTool::selection(), KoShape::shapeToDocument(), KoPathPointTypeCommand::Smooth, and KoPathPointTypeCommand::Symmetric.

◆ paint()

void PointHandle::paint ( QPainter & painter,
const KoViewConverter & converter,
qreal handleRadius,
int decorationThickness )
overridevirtual

Implements KoPathToolHandle.

Definition at line 43 of file KoPathToolHandle.cpp.

44{
45 KoPathToolSelection * selection = dynamic_cast<KoPathToolSelection*>(m_tool->selection());
46
47 KoPathPoint::PointTypes allPaintedTypes = KoPathPoint::Node;
48 if (selection && selection->contains(m_activePoint)) {
49 allPaintedTypes = KoPathPoint::All;
50 }
51
52
53 KisHandlePainterHelper helper = KoShape::createHandlePainterHelperView(&painter, m_activePoint->parent(), converter, handleRadius, decorationThickness);
54
55
56 if (allPaintedTypes != m_activePointType) {
57 KoPathPoint::PointTypes nonHighlightedType = allPaintedTypes & ~m_activePointType;
58 KoPathPoint::PointTypes nonNodeType = nonHighlightedType & ~KoPathPoint::Node;
59
60 if (nonNodeType != KoPathPoint::None) {
62 m_activePoint->paint(helper, nonHighlightedType);
63 }
64
65 if (nonHighlightedType & KoPathPoint::Node) {
68 }
69 }
70
73}
The KisHandlePainterHelper class is a special helper for painting handles around objects....
void setHandleStyle(const KisHandleStyle &style)
static KisHandleStyle & highlightedPrimaryHandles()
static KisHandleStyle & selectedPrimaryHandles()
static KisHandleStyle & partiallyHighlightedPrimaryHandles()
A KoPathPoint represents a point in a path.
void paint(KisHandlePainterHelper &handlesHelper, PointTypes types, bool active=true)
static KisHandlePainterHelper createHandlePainterHelperView(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
Definition KoShape.cpp:1177
Definition Node.h:24

References KoPathPoint::All, KoPathToolSelection::contains(), KoShape::createHandlePainterHelperView(), KisHandleStyle::highlightedPrimaryHandles(), m_activePoint, m_activePointType, KoPathToolHandle::m_tool, KoPathPoint::Node, KoPathPoint::None, KoPathPoint::paint(), KoPathPoint::parent(), KisHandleStyle::partiallyHighlightedPrimaryHandles(), KisHandleStyle::selectedPrimaryHandles(), KoPathTool::selection(), and KisHandlePainterHelper::setHandleStyle().

◆ trySelectHandle()

void PointHandle::trySelectHandle ( )
overridevirtual

Reimplemented from KoPathToolHandle.

Definition at line 151 of file KoPathToolHandle.cpp.

152{
153 KoPathToolSelection * selection = dynamic_cast<KoPathToolSelection*>(m_tool->selection());
155
157 selection->clear();
158 selection->add(m_activePoint, false);
159 }
160}
void clear()
Clear the selection.
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References KoPathToolSelection::add(), KoPathToolSelection::clear(), KoPathToolSelection::contains(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_activePoint, m_activePointType, KoPathToolHandle::m_tool, KoPathPoint::Node, and KoPathTool::selection().

Member Data Documentation

◆ m_activePoint

KoPathPoint* PointHandle::m_activePoint
private

Definition at line 57 of file KoPathToolHandle.h.

◆ m_activePointType

KoPathPoint::PointType PointHandle::m_activePointType
private

Definition at line 58 of file KoPathToolHandle.h.

◆ m_oldRepaintedRect

QRectF PointHandle::m_oldRepaintedRect
mutableprivate

Definition at line 59 of file KoPathToolHandle.h.


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