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

#include <KoPathTool.h>

+ Inheritance diagram for KoPathTool:

Classes

struct  PathSegment
 

Public Slots

void canvasResourceChanged (int key, const QVariant &res) override
 
- Public Slots inherited from KoToolBase
virtual void canvasResourceChanged (int key, const QVariant &res)
 
virtual void documentResourceChanged (int key, const QVariant &res)
 
virtual void requestRedoDuringStroke ()
 
void setStatusText (const QString &statusText)
 
void updateOptionsWidgetIcons ()
 

Signals

void singleShapeChanged (KoPathShape *path)
 
void typeChanged (int types)
 
- Signals inherited from KoToolBase
void activateTool (const QString &id)
 
void cursorChanged (const QCursor &cursor)
 
void selectionChanged (bool hasSelection)
 
void statusTextChanged (const QString &statusText)
 
void textModeChanged (bool inTextMode)
 

Public Member Functions

void activate (const QSet< KoShape * > &shapes) override
 
void deactivate () override
 
QRectF decorationsRect () const override
 
void deleteSelection () override
 
void deselect () override
 deselect the tool should clear the selection if it has one.
 
void explicitUserStrokeEndRequest () override
 explicitUserStrokeEndRequest is called by the input manager when the user presses the Enter key or any equivalent key. This callback comes before requestStrokeEnd(), which comes from a different source.
 
void keyPressEvent (QKeyEvent *event) override
 
void keyReleaseEvent (QKeyEvent *event) override
 
 KoPathTool (KoCanvasBase *canvas)
 
void mouseDoubleClickEvent (KoPointerEvent *event) override
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mousePressEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
void notifyPathPointsChanged (KoPathShape *shape)
 
void paint (QPainter &painter, const KoViewConverter &converter) override
 
QMenu * popupActionsMenu () override
 
void repaintDecorations () override
 
void requestStrokeCancellation () override
 
void requestStrokeEnd () override
 
void requestUndoDuringStroke () override
 
bool selectAll () override
 selectAll select all data the tool can select.
 
KoToolSelectionselection () override
 
 ~KoPathTool () override
 
- Public Member Functions inherited from KoToolBase
QAction * action (const QString &name) const
 
KoCanvasBasecanvas () const
 Returns the canvas the tool is working on.
 
virtual void copy () const
 
QCursor cursor () const
 return the last emitted cursor
 
virtual void customMoveEvent (KoPointerEvent *event)
 
virtual void customPressEvent (KoPointerEvent *event)
 
virtual void customReleaseEvent (KoPointerEvent *event)
 
virtual void cut ()
 
int decorationThickness () const
 decorationThickness The minimum thickness for tool decoration lines, this is derived from the screen magnification, thus the HiDPI settings. Note: to use this effectively, also set the pen to isCosmetic(true);
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event, const QPointF &point)
 
virtual void dropEvent (QDropEvent *event, const QPointF &point)
 
KoToolFactoryBasefactory () const
 
virtual void focusInEvent (QFocusEvent *event)
 
virtual void focusOutEvent (QFocusEvent *event)
 
virtual bool hasSelection ()
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
bool isInTextMode () const
 
bool isOpacityPresetMode () const
 
 KoToolBase (KoCanvasBase *canvas)
 
bool maskSyntheticEvents () const
 
virtual void mouseTripleClickEvent (KoPointerEvent *event)
 
QList< QPointer< QWidget > > optionWidgets ()
 
virtual bool paste ()
 
virtual KisPopupWidgetInterfacepopupWidget ()
 
Q_INVOKABLE QString toolId () const
 
virtual bool wantsAutoScroll () const
 
 ~KoToolBase () override
 

Protected Member Functions

QList< QPointer< QWidget > > createOptionWidgets () override
 reimplemented
 
- Protected Member Functions inherited from KoToolBase
virtual QWidget * createOptionWidget ()
 
int grabSensitivity () const
 Convenience function to get the current grab sensitivity.
 
qreal handleDocRadius () const
 
QRectF handleGrabRect (const QPointF &position) const
 
QRectF handlePaintRect (const QPointF &position) const
 
int handleRadius () const
 Convenience function to get the current handle radius.
 
bool isActivated () const
 
 KoToolBase (KoToolBasePrivate &dd)
 
KoPointerEventlastDeliveredPointerEvent () const
 
void setAbstractResource (KoAbstractCanvasResourceInterfaceSP abstractResource)
 
void setConverter (KoDerivedResourceConverterSP converter)
 
void setIsOpacityPresetMode (bool value)
 
void setMaskSyntheticEvents (bool value)
 
void setTextMode (bool value)
 
QHash< int, KoAbstractCanvasResourceInterfaceSPtoolAbstractResources ()
 
QHash< int, KoDerivedResourceConverterSPtoolConverters ()
 
void useCursor (const QCursor &cursor)
 

Protected Attributes

KoPathToolSelection m_pointSelection
 the point selection
 
QCursor m_selectCursor
 
- Protected Attributes inherited from KoToolBase
KoToolBasePrivated_ptr
 

Private Slots

void breakAtPoint ()
 
void breakAtSegment ()
 
void breakAtSelection ()
 
void convertToPath ()
 
void insertPoints ()
 
void joinPoints ()
 
void mergePoints ()
 
void pointSelectionChanged ()
 
void pointToCurve ()
 
void pointToLine ()
 
void pointTypeChanged (KoPathPointTypeCommand::PointType type)
 
void pointTypeChangedCorner ()
 
void pointTypeChangedSmooth ()
 
void pointTypeChangedSymmetric ()
 
void removePoints ()
 
void segmentToCurve ()
 
void segmentToLine ()
 
void slotSelectionChanged ()
 
void updateActions ()
 

Private Member Functions

void clearActivePointSelectionReferences ()
 
KUndo2CommandcreatePointToCurveCommand (const QList< KoPathPointData > &points)
 
void initializeWithShapes (const QList< KoShape * > shapes)
 
void mergePointsImpl (bool doJoin)
 
PathSegmentsegmentAtPoint (const QPointF &point)
 
void updateOptionsWidget ()
 

Private Attributes

QAction * m_actionAddPoint
 
QAction * m_actionBreakPoint
 
QAction * m_actionBreakSegment
 
QAction * m_actionBreakSelection
 
QAction * m_actionConvertToPath
 
QAction * m_actionCurvePoint
 
QAction * m_actionCurveSegment
 
QAction * m_actionJoinSegment
 
QAction * m_actionLinePoint
 
QAction * m_actionLineSegment
 
QAction * m_actionMergePoints
 
QAction * m_actionPathPointCorner
 
QAction * m_actionPathPointSmooth
 
QAction * m_actionPathPointSymmetric
 
QAction * m_actionRemovePoint
 
QScopedPointer< KoPathToolHandlem_activeHandle
 the currently active handle
 
QScopedPointer< PathSegmentm_activeSegment
 
KisSignalAutoConnectionsStore m_canvasConnections
 
QScopedPointer< QMenu > m_contextMenu
 
QScopedPointer< KoInteractionStrategym_currentStrategy
 the rubber selection strategy
 
QPointF m_lastPoint
 needed for interaction strategy
 
QCursor m_moveCursor
 
KoShapeFillResourceConnector m_shapeFillResourceConnector
 
QScopedPointer< KoSvgTextShapeOutlineHelperm_textOutlineHelper
 

Friends

class TestPathTool
 

Detailed Description

The tool for editing a KoPathShape or a KoParameterShape. See KoCreatePathTool for code handling the initial path creation.

Definition at line 36 of file KoPathTool.h.

Constructor & Destructor Documentation

◆ KoPathTool()

KoPathTool::KoPathTool ( KoCanvasBase * canvas)
explicit

Definition at line 87 of file KoPathTool.cpp.

89 , m_pointSelection(this)
91{
92 m_actionPathPointCorner = action("pathpoint-corner");
93 m_actionPathPointSmooth = action("pathpoint-smooth");
94 m_actionPathPointSymmetric = action("pathpoint-symmetric");
95 m_actionCurvePoint = action("pathpoint-curve");
96 m_actionLinePoint = action("pathpoint-line");
97 m_actionLineSegment = action("pathsegment-line");
98 m_actionCurveSegment = action("pathsegment-curve");
99 m_actionAddPoint = action("pathpoint-insert");
100 m_actionRemovePoint = action("pathpoint-remove");
101 m_actionBreakPoint = action("path-break-point");
102 m_actionBreakSegment = action("path-break-segment");
103 m_actionBreakSelection = action("path-break-selection");
104 m_actionJoinSegment = action("pathpoint-join");
105 m_actionMergePoints = action("pathpoint-merge");
106 m_actionConvertToPath = action("convert-to-path");
107
108 m_contextMenu.reset(new QMenu());
109 m_textOutlineHelper->setDrawBoundingRect(true);
110 m_textOutlineHelper->setDrawShapeOutlines(false);
111
112 m_selectCursor = QCursor(QIcon(":/cursor-needle.svg").pixmap(32), 0, 0);
113 m_moveCursor = QCursor(QIcon(":/cursor-needle-move.svg").pixmap(32), 0, 0);
114
115 connect(&m_pointSelection, SIGNAL(selectionChanged()), SLOT(repaintDecorations()));
116}
QAction * m_actionJoinSegment
Definition KoPathTool.h:139
QCursor m_selectCursor
Definition KoPathTool.h:115
QAction * m_actionCurvePoint
Definition KoPathTool.h:130
QAction * m_actionLinePoint
Definition KoPathTool.h:131
QAction * m_actionRemovePoint
Definition KoPathTool.h:135
KoPathToolSelection m_pointSelection
the point selection
Definition KoPathTool.h:114
QAction * m_actionLineSegment
Definition KoPathTool.h:132
QScopedPointer< QMenu > m_contextMenu
Definition KoPathTool.h:143
QAction * m_actionPathPointSymmetric
Definition KoPathTool.h:129
QScopedPointer< KoSvgTextShapeOutlineHelper > m_textOutlineHelper
Definition KoPathTool.h:144
QAction * m_actionBreakSegment
Definition KoPathTool.h:137
QAction * m_actionAddPoint
Definition KoPathTool.h:134
QAction * m_actionPathPointSmooth
Definition KoPathTool.h:128
QAction * m_actionCurveSegment
Definition KoPathTool.h:133
QCursor m_moveCursor
Definition KoPathTool.h:142
QAction * m_actionMergePoints
Definition KoPathTool.h:140
QAction * m_actionBreakPoint
Definition KoPathTool.h:136
QAction * m_actionConvertToPath
Definition KoPathTool.h:141
void repaintDecorations() override
QAction * m_actionPathPointCorner
Definition KoPathTool.h:127
QAction * m_actionBreakSelection
Definition KoPathTool.h:138
The KoSvgTextShapeOutlineHelper class helper class that draws the text outlines and contour mode butt...
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
void selectionChanged(bool hasSelection)
QAction * action(const QString &name) const

References KoToolBase::action(), m_actionAddPoint, m_actionBreakPoint, m_actionBreakSegment, m_actionBreakSelection, m_actionConvertToPath, m_actionCurvePoint, m_actionCurveSegment, m_actionJoinSegment, m_actionLinePoint, m_actionLineSegment, m_actionMergePoints, m_actionPathPointCorner, m_actionPathPointSmooth, m_actionPathPointSymmetric, m_actionRemovePoint, m_contextMenu, m_moveCursor, m_pointSelection, m_selectCursor, m_textOutlineHelper, repaintDecorations(), and KoToolBase::selectionChanged().

◆ ~KoPathTool()

KoPathTool::~KoPathTool ( )
override

Definition at line 118 of file KoPathTool.cpp.

119{
120}

Member Function Documentation

◆ activate()

void KoPathTool::activate ( const QSet< KoShape * > & shapes)
overridevirtual

This method is called when this tool instance is activated. For any main window there is only one tool active at a time, which then gets all user input. Switching between tools will call deactivate on one and activate on the new tool allowing the tool to flush items (like a selection) when it is not in use.

Parameters
shapesthe set of shapes that are selected or suggested for editing by a selected shape for the tool to work on. Not all shapes will be meant for this tool.
See also
deactivate()

Reimplemented from KoToolBase.

Definition at line 863 of file KoPathTool.cpp.

864{
865 KoToolBase::activate(shapes);
866
867 Q_D(KoToolBase);
868
869 d->canvas->snapGuide()->reset();
870
872 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()));
873 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionContentChanged()), this, SLOT(updateActions()));
874
875 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(repaintDecorations()));
876 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionContentChanged()), this, SLOT(repaintDecorations()));
878 initializeWithShapes(QList<KoShape*>(shapes.begin(), shapes.end()));
879 connect(m_actionCurvePoint, SIGNAL(triggered()), this, SLOT(pointToCurve()), Qt::UniqueConnection);
880 connect(m_actionLinePoint, SIGNAL(triggered()), this, SLOT(pointToLine()), Qt::UniqueConnection);
881 connect(m_actionLineSegment, SIGNAL(triggered()), this, SLOT(segmentToLine()), Qt::UniqueConnection);
882 connect(m_actionCurveSegment, SIGNAL(triggered()), this, SLOT(segmentToCurve()), Qt::UniqueConnection);
883 connect(m_actionAddPoint, SIGNAL(triggered()), this, SLOT(insertPoints()), Qt::UniqueConnection);
884 connect(m_actionRemovePoint, SIGNAL(triggered()), this, SLOT(removePoints()), Qt::UniqueConnection);
885 connect(m_actionBreakPoint, SIGNAL(triggered()), this, SLOT(breakAtPoint()), Qt::UniqueConnection);
886 connect(m_actionBreakSegment, SIGNAL(triggered()), this, SLOT(breakAtSegment()), Qt::UniqueConnection);
887 connect(m_actionBreakSelection, SIGNAL(triggered()), this, SLOT(breakAtSelection()), Qt::UniqueConnection);
888 connect(m_actionJoinSegment, SIGNAL(triggered()), this, SLOT(joinPoints()), Qt::UniqueConnection);
889 connect(m_actionMergePoints, SIGNAL(triggered()), this, SLOT(mergePoints()), Qt::UniqueConnection);
890 connect(m_actionConvertToPath, SIGNAL(triggered()), this, SLOT(convertToPath()), Qt::UniqueConnection);
891 connect(m_actionPathPointCorner, SIGNAL(triggered()), this, SLOT(pointTypeChangedCorner()), Qt::UniqueConnection);
892 connect(m_actionPathPointSmooth, SIGNAL(triggered()), this, SLOT(pointTypeChangedSmooth()), Qt::UniqueConnection);
893 connect(m_actionPathPointSymmetric, SIGNAL(triggered()), this, SLOT(pointTypeChangedSymmetric()), Qt::UniqueConnection);
894 connect(&m_pointSelection, SIGNAL(selectionChanged()), this, SLOT(pointSelectionChanged()), Qt::UniqueConnection);
895
896}
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
void updateActions()
void pointTypeChangedSmooth()
void breakAtSelection()
void segmentToCurve()
void breakAtPoint()
void pointToLine()
void convertToPath()
void joinPoints()
KisSignalAutoConnectionsStore m_canvasConnections
Definition KoPathTool.h:145
void pointSelectionChanged()
void segmentToLine()
void pointToCurve()
void pointTypeChangedCorner()
void slotSelectionChanged()
void breakAtSegment()
void pointTypeChangedSymmetric()
void removePoints()
void initializeWithShapes(const QList< KoShape * > shapes)
void mergePoints()
KoShapeFillResourceConnector m_shapeFillResourceConnector
Definition KoPathTool.h:146
void insertPoints()
void useCursor(const QCursor &cursor)
virtual void activate(const QSet< KoShape * > &shapes)

References KoToolBase::activate(), KisSignalAutoConnectionsStore::addConnection(), breakAtPoint(), breakAtSegment(), breakAtSelection(), KoShapeFillResourceConnector::connectToCanvas(), convertToPath(), initializeWithShapes(), insertPoints(), joinPoints(), m_actionAddPoint, m_actionBreakPoint, m_actionBreakSegment, m_actionBreakSelection, m_actionConvertToPath, m_actionCurvePoint, m_actionCurveSegment, m_actionJoinSegment, m_actionLinePoint, m_actionLineSegment, m_actionMergePoints, m_actionPathPointCorner, m_actionPathPointSmooth, m_actionPathPointSymmetric, m_actionRemovePoint, m_canvasConnections, m_pointSelection, m_selectCursor, m_shapeFillResourceConnector, mergePoints(), pointSelectionChanged(), pointToCurve(), pointToLine(), pointTypeChangedCorner(), pointTypeChangedSmooth(), pointTypeChangedSymmetric(), removePoints(), repaintDecorations(), segmentToCurve(), segmentToLine(), KoToolBase::selectionChanged(), slotSelectionChanged(), updateActions(), and KoToolBase::useCursor().

◆ breakAtPoint

void KoPathTool::breakAtPoint ( )
privateslot

Definition at line 407 of file KoPathTool.cpp.

408{
409 Q_D(KoToolBase);
412 }
413}
Command to break a subpath at points.
bool hasSelection() override
reimplemented from KoToolSelection
QList< KoPathPointData > selectedPointsData() const
Get the point data of all selected points.

References KoPathToolSelection::hasSelection(), m_pointSelection, and KoPathToolSelection::selectedPointsData().

◆ breakAtSegment

void KoPathTool::breakAtSegment ( )
privateslot

Definition at line 429 of file KoPathTool.cpp.

430{
431 Q_D(KoToolBase);
432 // only try to break a segment when 2 points of the same object are selected
433 if (m_pointSelection.objectCount() == 1 && m_pointSelection.size() == 2) {
435 if (segments.size() == 1) {
436 d->canvas->addCommand(new KoPathSegmentBreakCommand(segments.at(0)));
437 }
438 }
439}
The undo / redo command for breaking a subpath by removing the segment.
int objectCount() const
Get the number of path objects in the selection.
int size() const
Get the number of path points in the selection.
QList< KoPathPointData > selectedSegmentsData() const
Get the point data of all selected segments.

References m_pointSelection, KoPathToolSelection::objectCount(), KoPathToolSelection::selectedSegmentsData(), and KoPathToolSelection::size().

◆ breakAtSelection

void KoPathTool::breakAtSelection ( )
privateslot

◆ canvasResourceChanged

void KoPathTool::canvasResourceChanged ( int key,
const QVariant & res )
overrideslot

Definition at line 1097 of file KoPathTool.cpp.

1098{
1101 }
1102}
@ DecorationThickness
Integer, the thickness of single px decorations, will be adjusted by HiDPI settings....
@ HandleRadius
The handle radius used for drawing handles of any kind.

References KoCanvasResource::DecorationThickness, KoCanvasResource::HandleRadius, and repaintDecorations().

◆ clearActivePointSelectionReferences()

void KoPathTool::clearActivePointSelectionReferences ( )
private

Definition at line 918 of file KoPathTool.cpp.

919{
920 m_activeHandle.reset();
921 m_activeSegment.reset();
923}
void clear()
Clear the selection.
QScopedPointer< PathSegment > m_activeSegment
Definition KoPathTool.h:120
QScopedPointer< KoPathToolHandle > m_activeHandle
the currently active handle
Definition KoPathTool.h:118

References KoPathToolSelection::clear(), m_activeHandle, m_activeSegment, and m_pointSelection.

◆ convertToPath

void KoPathTool::convertToPath ( )
privateslot

Definition at line 288 of file KoPathTool.cpp.

289{
290 Q_D(KoToolBase);
291
293
294 QList<KoParameterShape*> parameterShapes;
295
296 Q_FOREACH (KoShape *shape, m_pointSelection.selectedShapes()) {
297 KoParameterShape * parametric = dynamic_cast<KoParameterShape*>(shape);
298 if (parametric && parametric->isParametricShape()) {
299 parameterShapes.append(parametric);
300 }
301 }
302
303 if (!parameterShapes.isEmpty()) {
304 d->canvas->addCommand(new KoParameterToPathCommand(parameterShapes));
305 }
306
307 QList<KoSvgTextShape*> textShapes;
308 Q_FOREACH (KoShape *shape, selection->selectedEditableShapes()) {
309 if (KoSvgTextShape *text = dynamic_cast<KoSvgTextShape*>(shape)) {
310 textShapes.append(text);
311 }
312 }
313
314 if (!textShapes.isEmpty()) {
315 KUndo2Command *cmd = new KUndo2Command(kundo2_i18n("Convert to Path")); // TODO: reuse the text from KoParameterToPathCommand
316 const QList<KoShape*> oldSelectedShapes = implicitCastList<KoShape*>(textShapes);
317
318
319 new KoKeepShapesSelectedCommand(oldSelectedShapes, {}, canvas()->selectedShapesProxy(),
321
322 QList<KoShape*> newSelectedShapes;
323 Q_FOREACH (KoSvgTextShape *shape, textShapes) {
324 KoShape *outlineShape = shape->textOutline();
325
326 KoShapeContainer *parent = shape->parent();
327 canvas()->shapeController()->addShapeDirect(outlineShape, parent, cmd);
328
329 newSelectedShapes << outlineShape;
330 }
331
332 canvas()->shapeController()->removeShapes(oldSelectedShapes, cmd);
333
334 new KoKeepShapesSelectedCommand({}, newSelectedShapes, canvas()->selectedShapesProxy(),
336
337 canvas()->addCommand(cmd);
338 }
339
341}
QPointer< KoShapeController > shapeController
virtual void addCommand(KUndo2Command *command)=0
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
bool isParametricShape() const
Check if object is a parametric shape.
The undo / redo command for changing a KoParameterShape into a KoPathShape.
QList< KoPathShape * > selectedShapes() const
Returns list of selected shapes.
void updateOptionsWidget()
KoToolSelection * selection() override
virtual KoSelection * selection()=0
KoShapeContainer * parent() const
Definition KoShape.cpp:857
KoShape * textOutline() const
textOutline This turns the text object into non-text KoShape(s) to the best of its abilities.
KUndo2MagicString kundo2_i18n(const char *text)
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327

References KoCanvasBase::addCommand(), KoToolBase::canvas(), KisCommandUtils::FlipFlopCommand::FINALIZING, KisCommandUtils::FlipFlopCommand::INITIALIZING, KoParameterShape::isParametricShape(), kundo2_i18n(), m_pointSelection, KoShape::parent(), KoPathToolSelection::selectedShapes(), KoCanvasBase::selectedShapesProxy(), selection(), KoSelectedShapesProxy::selection(), KoCanvasBase::shapeController, KoSvgTextShape::textOutline(), and updateOptionsWidget().

◆ createOptionWidgets()

QList< QPointer< QWidget > > KoPathTool::createOptionWidgets ( )
overrideprotectedvirtual

reimplemented

Reimplemented from KoToolBase.

Definition at line 122 of file KoPathTool.cpp.

123{
125
126 PathToolOptionWidget * toolOptions = new PathToolOptionWidget(this);
127 connect(this, SIGNAL(typeChanged(int)), toolOptions, SLOT(setSelectionType(int)));
128 connect(this, SIGNAL(singleShapeChanged(KoPathShape*)), toolOptions, SLOT(setCurrentShape(KoPathShape*)));
129 connect(toolOptions, SIGNAL(sigRequestUpdateActions()), this, SLOT(updateActions()));
131 toolOptions->setWindowTitle(i18n("Edit Shape"));
132 list.append(toolOptions);
133
134 return list;
135}
The position of a path point within a path shape.
Definition KoPathShape.h:63
void singleShapeChanged(KoPathShape *path)
void typeChanged(int types)

References singleShapeChanged(), typeChanged(), updateActions(), and updateOptionsWidget().

◆ createPointToCurveCommand()

KUndo2Command * KoPathTool::createPointToCurveCommand ( const QList< KoPathPointData > & points)
private

Definition at line 247 of file KoPathTool.cpp.

248{
249 KUndo2Command *command = 0;
250 QList<KoPathPointData> pointToChange;
251
252 QList<KoPathPointData>::const_iterator it(points.constBegin());
253 for (; it != points.constEnd(); ++it) {
254 KoPathPoint *point = it->pathShape->pointByIndex(it->pointIndex);
255 if (point && (! point->activeControlPoint1() || ! point->activeControlPoint2()))
256 pointToChange.append(*it);
257 }
258
259 if (!pointToChange.isEmpty()) {
260 command = new KoPathPointTypeCommand(pointToChange, KoPathPointTypeCommand::Curve);
261 }
262
263 return command;
264}
The undo / redo command for changing the path point type.
A KoPathPoint represents a point in a path.
bool activeControlPoint1
bool activeControlPoint2

References KoPathPoint::activeControlPoint1, KoPathPoint::activeControlPoint2, and KoPathPointTypeCommand::Curve.

◆ deactivate()

void KoPathTool::deactivate ( )
overridevirtual

This method is called whenever this tool is no longer the active tool

See also
activate()

Reimplemented from KoToolBase.

Definition at line 1064 of file KoPathTool.cpp.

1065{
1066 Q_D(KoToolBase);
1067
1072 m_activeHandle.reset();
1073 m_activeSegment.reset();
1074 m_currentStrategy.reset();
1075 d->canvas->snapGuide()->reset();
1076
1077 disconnect(m_actionCurvePoint, 0, this, 0);
1078 disconnect(m_actionLinePoint, 0, this, 0);
1079 disconnect(m_actionLineSegment, 0, this, 0);
1080 disconnect(m_actionCurveSegment, 0, this, 0);
1081 disconnect(m_actionAddPoint, 0, this, 0);
1082 disconnect(m_actionRemovePoint, 0, this, 0);
1083 disconnect(m_actionBreakPoint, 0, this, 0);
1084 disconnect(m_actionBreakSegment, 0, this, 0);
1085 disconnect(m_actionBreakSelection, 0, this, 0);
1086 disconnect(m_actionJoinSegment, 0, this, 0);
1087 disconnect(m_actionMergePoints, 0, this, 0);
1088 disconnect(m_actionConvertToPath, 0, this, 0);
1089 disconnect(m_actionPathPointCorner, 0, this, 0);
1090 disconnect(m_actionPathPointSmooth, 0, this, 0);
1091 disconnect(m_actionPathPointSymmetric, 0, this, 0);
1092 disconnect(&m_pointSelection, 0, this, 0);
1093
1095}
void setSelectedShapes(const QList< KoPathShape * > shapes)
Sets list of selected shapes.
QScopedPointer< KoInteractionStrategy > m_currentStrategy
the rubber selection strategy
Definition KoPathTool.h:125
virtual void deactivate()

References KoPathToolSelection::clear(), KisSignalAutoConnectionsStore::clear(), KoToolBase::deactivate(), KoShapeFillResourceConnector::disconnect(), m_actionAddPoint, m_actionBreakPoint, m_actionBreakSegment, m_actionBreakSelection, m_actionConvertToPath, m_actionCurvePoint, m_actionCurveSegment, m_actionJoinSegment, m_actionLinePoint, m_actionLineSegment, m_actionMergePoints, m_actionPathPointCorner, m_actionPathPointSmooth, m_actionPathPointSymmetric, m_actionRemovePoint, m_activeHandle, m_activeSegment, m_canvasConnections, m_currentStrategy, m_pointSelection, m_shapeFillResourceConnector, and KoPathToolSelection::setSelectedShapes().

◆ decorationsRect()

QRectF KoPathTool::decorationsRect ( ) const
overridevirtual

Reimplemented from KoToolBase.

Definition at line 517 of file KoPathTool.cpp.

518{
520
521 QRectF newDecorationsRect;
522
523 Q_FOREACH (KoShape *shape, m_pointSelection.selectedShapes()) {
524 newDecorationsRect |= kisGrowRect(shape->boundingRect(), handleDocRadius());
525 }
526
527 Q_FOREACH(const KoPathPoint *point, m_pointSelection.selectedPoints()) {
528 newDecorationsRect |= kisGrowRect(point->boundingRect(false), handleDocRadius());
529 }
530
531 if (m_activeHandle) {
532 newDecorationsRect |= kisGrowRect(m_activeHandle->boundingRect(), handleDocRadius());
533 }
534
535 if (m_activeSegment) {
536 KoPathPointIndex index = m_activeSegment->path->pathPointIndex(m_activeSegment->segmentStart);
537 KoPathSegment segment = m_activeSegment->path->segmentByIndex(index);
538
539 QRectF rect = segment.boundingRect();
540 rect = m_activeSegment->path->shapeToDocument(rect);
541
542 newDecorationsRect |= kisGrowRect(rect, handleDocRadius());
543 }
544
545 newDecorationsRect |= m_textOutlineHelper->decorationRect();
546
547 return newDecorationsRect;
548}
QPair< int, int > KoPathPointIndex
Definition KoPathShape.h:28
QRectF boundingRect(bool active=true) const
Get the bounding rect of the point.
A KoPathSegment consist of two neighboring KoPathPoints.
QRectF boundingRect() const
Returns the axis aligned tight bounding rect.
Handle the selection of points.
const QSet< KoPathPoint * > & selectedPoints() const
Get all selected points.
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:300
qreal handleDocRadius() const
T kisGrowRect(const T &rect, U offset)
Definition kis_global.h:186
bool update(QSpinBox *spinBox)

References KoPathSegment::boundingRect(), KoShape::boundingRect(), KoPathPoint::boundingRect(), KoToolBase::handleDocRadius(), kisGrowRect(), m_activeHandle, m_activeSegment, m_pointSelection, m_textOutlineHelper, KoPathToolSelection::selectedPoints(), and KoPathToolSelection::selectedShapes().

◆ deleteSelection()

void KoPathTool::deleteSelection ( )
overridevirtual

Delete the tools selection. The default implementation is empty to aid tools that don't have any selection.

See also
selection()

Reimplemented from KoToolBase.

Definition at line 1183 of file KoPathTool.cpp.

1184{
1185 removePoints();
1186}

References removePoints().

◆ deselect()

void KoPathTool::deselect ( )
overridevirtual

deselect the tool should clear the selection if it has one.

Reimplemented from KoToolBase.

Definition at line 1220 of file KoPathTool.cpp.

1221{
1224}
void clearActivePointSelectionReferences()

References clearActivePointSelectionReferences(), and repaintDecorations().

◆ explicitUserStrokeEndRequest()

void KoPathTool::explicitUserStrokeEndRequest ( )
overridevirtual

explicitUserStrokeEndRequest is called by the input manager when the user presses the Enter key or any equivalent key. This callback comes before requestStrokeEnd(), which comes from a different source.

Reimplemented from KoToolBase.

Definition at line 1208 of file KoPathTool.cpp.

1209{
1210 KoToolManager::instance()->switchToolRequested("InteractionTool");
1211}
void switchToolRequested(const QString &id)
static KoToolManager * instance()
Return the toolmanager singleton.

References KoToolManager::instance(), and KoToolManager::switchToolRequested().

◆ initializeWithShapes()

void KoPathTool::initializeWithShapes ( const QList< KoShape * > shapes)
private

Definition at line 925 of file KoPathTool.cpp.

926{
927 QList<KoPathShape*> selectedShapes;
928 Q_FOREACH (KoShape *shape, shapes) {
929 KoPathShape *pathShape = dynamic_cast<KoPathShape*>(shape);
930
931 if (pathShape && pathShape->isShapeEditable()) {
932 selectedShapes.append(pathShape);
933 }
934 }
935
936 if (selectedShapes != m_pointSelection.selectedShapes()) {
938 m_pointSelection.setSelectedShapes(selectedShapes);
940 }
941
944}
virtual bool isShapeEditable(bool recursive=true) const
checks recursively if the shape or one of its parents is not visible or locked
Definition KoShape.cpp:965

References clearActivePointSelectionReferences(), KoShape::isShapeEditable(), m_pointSelection, repaintDecorations(), KoPathToolSelection::selectedShapes(), KoPathToolSelection::setSelectedShapes(), updateActions(), and updateOptionsWidget().

◆ insertPoints

void KoPathTool::insertPoints ( )
privateslot

Definition at line 177 of file KoPathTool.cpp.

178{
179 Q_D(KoToolBase);
181 if (segments.size() == 1) {
182 qreal positionInSegment = 0.5;
183 if (m_activeSegment && m_activeSegment->isValid()) {
184 positionInSegment = m_activeSegment->positionOnSegment;
185 }
186
187 KoPathPointInsertCommand *cmd = new KoPathPointInsertCommand(segments, positionInSegment);
188 d->canvas->addCommand(cmd);
189
190 // TODO: this construction is dangerous. The canvas can remove the command right after
191 // it has been added to it!
193 foreach (KoPathPoint * p, cmd->insertedPoints()) {
194 m_pointSelection.add(p, false);
195 }
196 }
197}
const Params2D p
The undo / redo command for inserting path points.
QList< KoPathPoint * > insertedPoints() const
Returns list of inserted points.
void add(KoPathPoint *point, bool clear)
Add a point to the selection.

References KoPathToolSelection::add(), KoPathToolSelection::clear(), KoPathPointInsertCommand::insertedPoints(), m_activeSegment, m_pointSelection, p, and KoPathToolSelection::selectedSegmentsData().

◆ joinPoints

void KoPathTool::joinPoints ( )
privateslot

Definition at line 397 of file KoPathTool.cpp.

398{
399 mergePointsImpl(true);
400}
void mergePointsImpl(bool doJoin)

References mergePointsImpl().

◆ keyPressEvent()

void KoPathTool::keyPressEvent ( QKeyEvent * event)
overridevirtual

Called when a key is pressed. Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this key press

Reimplemented from KoToolBase.

Definition at line 754 of file KoPathTool.cpp.

755{
756 if (m_currentStrategy) {
757 switch (event->key()) {
758 case Qt::Key_Control:
759 case Qt::Key_Alt:
760 case Qt::Key_Shift:
761 case Qt::Key_Meta:
762 if (! event->isAutoRepeat()) {
763 m_currentStrategy->handleMouseMove(m_lastPoint, event->modifiers());
764 }
765 break;
766 case Qt::Key_Escape:
767 m_currentStrategy->cancelInteraction();
768 m_currentStrategy.reset();
769 break;
770 default:
771 event->ignore();
772 return;
773 }
774 } else {
775 switch (event->key()) {
776#ifndef NDEBUG
777// case Qt::Key_D:
778// if (m_pointSelection.objectCount() == 1) {
779// QList<KoPathPointData> selectedPoints = m_pointSelection.selectedPointsData();
780// KoPathShapePrivate *p = static_cast<KoPathShapePrivate*>(selectedPoints[0].pathShape->priv());
781// p->debugPath();
782// }
783// break;
784#endif
785 default:
786 event->ignore();
787 return;
788 }
789 }
790 event->accept();
791}
QPointF m_lastPoint
needed for interaction strategy
Definition KoPathTool.h:119

References m_currentStrategy, and m_lastPoint.

◆ keyReleaseEvent()

void KoPathTool::keyReleaseEvent ( QKeyEvent * event)
overridevirtual

Called when a key is released Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this key release

Reimplemented from KoToolBase.

Definition at line 793 of file KoPathTool.cpp.

794{
795 if (m_currentStrategy) {
796 switch (event->key()) {
797 case Qt::Key_Control:
798 case Qt::Key_Alt:
799 case Qt::Key_Shift:
800 case Qt::Key_Meta:
801 if (! event->isAutoRepeat()) {
802 m_currentStrategy->handleMouseMove(m_lastPoint, Qt::NoModifier);
803 }
804 break;
805 default:
806 break;
807 }
808 }
809 event->accept();
810}

References m_currentStrategy, and m_lastPoint.

◆ mergePoints

void KoPathTool::mergePoints ( )
privateslot

Definition at line 402 of file KoPathTool.cpp.

403{
404 mergePointsImpl(false);
405}

References mergePointsImpl().

◆ mergePointsImpl()

void KoPathTool::mergePointsImpl ( bool doJoin)
private

Definition at line 368 of file KoPathTool.cpp.

369{
370 Q_D(KoToolBase);
371
372 if (m_pointSelection.size() != 2)
373 return;
374
376 if (pointData.size() != 2) return;
377
378 const KoPathPointData & pd1 = pointData.at(0);
379 const KoPathPointData & pd2 = pointData.at(1);
380
381 if (!checkCanJoinToPoints(pd1, pd2)) {
382 return;
383 }
384
386
387 KUndo2Command *cmd = 0;
388
389 if (doJoin) {
390 cmd = new KoMultiPathPointJoinCommand(pd1, pd2, d->canvas->shapeController()->documentBase(), d->canvas->shapeManager()->selection());
391 } else {
392 cmd = new KoMultiPathPointMergeCommand(pd1, pd2, d->canvas->shapeController()->documentBase(), d->canvas->shapeManager()->selection());
393 }
394 d->canvas->addCommand(cmd);
395}
Describe a KoPathPoint by a KoPathShape and its indices.

References clearActivePointSelectionReferences(), m_pointSelection, KoPathToolSelection::selectedPointsData(), and KoPathToolSelection::size().

◆ mouseDoubleClickEvent()

void KoPathTool::mouseDoubleClickEvent ( KoPointerEvent * event)
overridevirtual

Called when (one of) the mouse or stylus buttons is double clicked. Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this mouse or stylus press

Reimplemented from KoToolBase.

Definition at line 812 of file KoPathTool.cpp.

813{
814 Q_D(KoToolBase);
815 // check if we are doing something else at the moment
816 if (m_currentStrategy) return;
817
818 if (!m_activeHandle && m_activeSegment && m_activeSegment->isValid()) {
819 QList<KoPathPointData> segments;
820 segments.append(
822 m_activeSegment->path->pathPointIndex(m_activeSegment->segmentStart)));
823
824 KoPathPointInsertCommand *cmd = new KoPathPointInsertCommand(segments, m_activeSegment->positionOnSegment);
825 d->canvas->addCommand(cmd);
826
828 foreach (KoPathPoint * p, cmd->insertedPoints()) {
829 m_pointSelection.add(p, false);
830 }
832 } else if (!m_activeHandle && !m_activeSegment) {
834 }
835}
void explicitUserStrokeEndRequest() override
explicitUserStrokeEndRequest is called by the input manager when the user presses the Enter key or an...

References KoPathToolSelection::add(), KoPathToolSelection::clear(), explicitUserStrokeEndRequest(), KoPathPointInsertCommand::insertedPoints(), m_activeHandle, m_activeSegment, m_currentStrategy, m_pointSelection, p, and updateActions().

◆ mouseMoveEvent()

void KoPathTool::mouseMoveEvent ( KoPointerEvent * event)
overridevirtual

Called when the mouse or stylus moved over the canvas. Implementors should call event->ignore() if they do not actually use the event.

Parameters
eventstate and reason of this mouse or stylus move

Implements KoToolBase.

Definition at line 610 of file KoPathTool.cpp.

611{
612 if (event->button() & Qt::RightButton)
613 return;
614
615 if (m_currentStrategy) {
616 m_lastPoint = event->point;
617 m_currentStrategy->handleMouseMove(event->point, event->modifiers());
618
620
621 return;
622 }
623
624 if (m_activeSegment) {
625 m_activeSegment.reset();
627 }
628
629 Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
630 QRectF roi = shape->documentToShape(handleGrabRect(event->point));
631 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
632 if (parameterShape && parameterShape->isParametricShape()) {
633 int handleId = parameterShape->handleIdAt(roi);
634 if (handleId != -1) {
636 Q_EMIT statusTextChanged(i18n("Drag to move handle."));
637
638 m_activeHandle.reset(new ParameterHandle(this, parameterShape, handleId));
640 return;
641 }
642 } else {
643 QList<KoPathPoint*> points = shape->pointsAt(roi, true);
644 if (! points.empty()) {
645 // find the nearest control point from all points within the roi
646 KoPathPoint * bestPoint = 0;
648 qreal minDistance = HUGE_VAL;
649 Q_FOREACH (KoPathPoint *p, points) {
650 // the node point must be hit if the point is not selected yet
651 if (! m_pointSelection.contains(p) && ! roi.contains(p->point()))
652 continue;
653
654 // check for the control points first as otherwise it is no longer
655 // possible to change the control points when they are the same as the point
656 if (p->activeControlPoint1() && roi.contains(p->controlPoint1())) {
657 qreal dist = squaredDistance(roi.center(), p->controlPoint1());
658 if (dist < minDistance) {
659 bestPoint = p;
660 bestPointType = KoPathPoint::ControlPoint1;
661 minDistance = dist;
662 }
663 }
664
665 if (p->activeControlPoint2() && roi.contains(p->controlPoint2())) {
666 qreal dist = squaredDistance(roi.center(), p->controlPoint2());
667 if (dist < minDistance) {
668 bestPoint = p;
669 bestPointType = KoPathPoint::ControlPoint2;
670 minDistance = dist;
671 }
672 }
673
674 // check the node point at last
675 qreal dist = squaredDistance(roi.center(), p->point());
676 if (dist < minDistance) {
677 bestPoint = p;
678 bestPointType = KoPathPoint::Node;
679 minDistance = dist;
680 }
681 }
682
683 if (! bestPoint) {
685 return;
686 }
687
689 if (bestPointType == KoPathPoint::Node)
690 Q_EMIT statusTextChanged(i18n("Drag to move point. Shift click to change point type."));
691 else
692 Q_EMIT statusTextChanged(i18n("Drag to move control point."));
693
694 PointHandle *prev = dynamic_cast<PointHandle*>(m_activeHandle.data());
695 if (prev && prev->activePoint() == bestPoint && prev->activePointType() == bestPointType)
696 return; // no change;
697
698 m_activeHandle.reset(new PointHandle(this, bestPoint, bestPointType));
700 return;
701 }
702 }
703 }
704
706
707 if (m_activeHandle) {
708 m_activeHandle.reset();
710 }
711
712 PathSegment *hoveredSegment = segmentAtPoint(event->point);
713 if(hoveredSegment) {
714 useCursor(Qt::PointingHandCursor);
715 Q_EMIT statusTextChanged(i18n("Drag to change curve directly. Double click to insert new path point."));
716 m_activeSegment.reset(hoveredSegment);
718 } else {
719 uint selectedPointCount = m_pointSelection.size();
720 if (selectedPointCount == 0)
721 Q_EMIT statusTextChanged(QString());
722 else {
723 if (!m_actionBreakSelection->shortcut().isEmpty()) {
724 if (selectedPointCount == 1)
725 Q_EMIT statusTextChanged(i18nc("%1 is a shortcut to be pressed", "Press %1 to break path at selected point.", m_actionBreakSelection->shortcut().toString()));
726 else
727 Q_EMIT statusTextChanged(i18nc("%1 is a shortcut to be pressed", "Press %1 to break path at selected segments.", m_actionBreakSelection->shortcut().toString()));
728 } else {
729 Q_EMIT statusTextChanged(QString());
730 }
731 }
732 }
733}
unsigned int uint
qreal squaredDistance(const QPointF &p1, const QPointF &p2)
int handleIdAt(const QRectF &rect) const
Get the id of the handle within the given rect.
PointType
the type for identifying part of a KoPathPoint
Definition KoPathPoint.h:47
@ ControlPoint2
the second control point
Definition KoPathPoint.h:51
@ ControlPoint1
the first control point
Definition KoPathPoint.h:50
@ Node
the node point
Definition KoPathPoint.h:49
QList< KoPathPoint * > pointsAt(const QRectF &rect, const bool useControlPoints=false) const
Returns the path points within the given rectangle.
bool contains(KoPathPoint *point)
Check if a point is in the selection.
PathSegment * segmentAtPoint(const QPointF &point)
Qt::MouseButton button() const
return button pressed (see QMouseEvent::button());
Qt::KeyboardModifiers modifiers() const
QPointF point
The point in document coordinates.
QPointF documentToShape(const QPointF &point) const
Transforms point from document coordinates to shape coordinates.
Definition KoShape.cpp:1011
void statusTextChanged(const QString &statusText)
QRectF handleGrabRect(const QPointF &position) const
KoPathPoint * activePoint() const
KoPathPoint::PointType activePointType() const

References PointHandle::activePoint(), PointHandle::activePointType(), KoPointerEvent::button(), KoPathToolSelection::contains(), KoPathPoint::ControlPoint1, KoPathPoint::ControlPoint2, KoShape::documentToShape(), KoToolBase::handleGrabRect(), KoParameterShape::handleIdAt(), KoParameterShape::isParametricShape(), m_actionBreakSelection, m_activeHandle, m_activeSegment, m_currentStrategy, m_lastPoint, m_moveCursor, m_pointSelection, m_selectCursor, KoPointerEvent::modifiers(), KoPathPoint::Node, p, KoPointerEvent::point, KoPathShape::pointsAt(), repaintDecorations(), segmentAtPoint(), KoPathToolSelection::selectedShapes(), KoPathToolSelection::size(), squaredDistance(), KoToolBase::statusTextChanged(), and KoToolBase::useCursor().

◆ mousePressEvent()

void KoPathTool::mousePressEvent ( KoPointerEvent * event)
overridevirtual

Called when (one of) the mouse or stylus buttons is pressed. Implementors should call event->ignore() if they do not actually use the event.

Parameters
eventstate and reason of this mouse or stylus press

Implements KoToolBase.

Definition at line 556 of file KoPathTool.cpp.

557{
558 // When using touch drawing, we only ever receive move events after the
559 // finger has pressed down. We have to issue an artificial move here so that
560 // the tool's state is updated properly to handle the press.
561 if (event->isTouchEvent()) {
562 mouseMoveEvent(event);
563 }
564
565 if (KoSvgTextShape *shape = m_textOutlineHelper->contourModeButtonHovered(event->point)) {
566 m_textOutlineHelper->toggleTextContourMode(shape);
567 event->accept();
568 }
569 // we are moving if we hit a point and use the left mouse button
570 if (m_activeHandle) {
571 m_currentStrategy.reset(m_activeHandle->handleMousePress(event));
572 } else {
573
574 if (event->button() & Qt::LeftButton) {
575
576 // check if we hit a path segment
577 if (m_activeSegment && m_activeSegment->isValid()) {
578
579 KoPathShape *shape = m_activeSegment->path;
580 KoPathPointIndex index = shape->pathPointIndex(m_activeSegment->segmentStart);
581 KoPathSegment segment = shape->segmentByIndex(index);
582
583 m_pointSelection.add(segment.first(), !(event->modifiers() & Qt::ShiftModifier));
584 m_pointSelection.add(segment.second(), false);
585
586 KoPathPointData data(shape, index);
587 m_currentStrategy.reset(new KoPathSegmentChangeStrategy(this, event->point, data, m_activeSegment->positionOnSegment));
588 } else {
589
590 KoShapeManager *shapeManager = canvas()->shapeManager();
591 KoSelection *selection = shapeManager->selection();
592 KoShape *shape = shapeManager->shapeAt(event->point, KoFlake::ShapeOnTop);
593
594 if (shape && !selection->isSelected(shape)) {
595
596 if (!(event->modifiers() & Qt::ShiftModifier)) {
597 selection->deselectAll();
598 }
599
600 selection->select(shape);
601 } else {
604 }
605 }
606 }
607 }
608}
virtual KoShapeManager * shapeManager() const =0
Strategy to rubber select points of a path shape.
Strategy for deforming a segment of a path shape.
KoPathPoint * first
KoPathPoint * second
KoPathSegment segmentByIndex(const KoPathPointIndex &pointIndex) const
Returns the segment specified by a path point index.
KoPathPointIndex pathPointIndex(const KoPathPoint *point) const
Returns the path point index of a given path point.
void mouseMoveEvent(KoPointerEvent *event) override
bool isTouchEvent() const
KoShape * shapeAt(const QPointF &position, KoFlake::ShapeSelection selection=KoFlake::ShapeOnTop, bool omitHiddenShapes=true)
KoSelection * selection
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
@ ShapeOnTop
return the shape highest z-ordering, regardless of selection.
Definition KoFlake.h:74

References KoPathToolSelection::add(), KoPointerEvent::button(), KoToolBase::canvas(), KoPathSegment::first, KoPointerEvent::isTouchEvent(), KIS_ASSERT_RECOVER_RETURN, m_activeHandle, m_activeSegment, m_currentStrategy, m_pointSelection, m_textOutlineHelper, KoPointerEvent::modifiers(), mouseMoveEvent(), KoPathShape::pathPointIndex(), KoPointerEvent::point, KoPathSegment::second, KoPathShape::segmentByIndex(), KoShapeManager::selection, selection(), KoShapeManager::shapeAt(), KoCanvasBase::shapeManager(), and KoFlake::ShapeOnTop.

◆ mouseReleaseEvent()

void KoPathTool::mouseReleaseEvent ( KoPointerEvent * event)
overridevirtual

Called when (one of) the mouse or stylus buttons is released. Implementors should call event->ignore() if they do not actually use the event.

Parameters
eventstate and reason of this mouse or stylus release

Implements KoToolBase.

Definition at line 735 of file KoPathTool.cpp.

736{
737 Q_D(KoToolBase);
738 if (m_currentStrategy) {
739 const bool hadNoSelection = !m_pointSelection.hasSelection();
740 m_currentStrategy->finishInteraction(event->modifiers());
741 KUndo2Command *command = m_currentStrategy->createCommand();
742 if (command)
743 d->canvas->addCommand(command);
744 if (hadNoSelection && dynamic_cast<KoPathPointRubberSelectStrategy*>(m_currentStrategy.data())
746 // the click didn't do anything at all. Allow it to be used by others.
747 event->ignore();
748 }
749 m_currentStrategy.reset();
751 }
752}

References KoPathToolSelection::hasSelection(), m_currentStrategy, m_pointSelection, KoPointerEvent::modifiers(), and repaintDecorations().

◆ notifyPathPointsChanged()

void KoPathTool::notifyPathPointsChanged ( KoPathShape * shape)

Definition at line 907 of file KoPathTool.cpp.

908{
909 Q_UNUSED(shape);
910
911 // active handle and selection might have already become invalid, so just
912 // delete them without dereferencing anything...
913
914 m_activeHandle.reset();
915 m_activeSegment.reset();
916}

References m_activeHandle, and m_activeSegment.

◆ paint()

void KoPathTool::paint ( QPainter & painter,
const KoViewConverter & converter )
overridevirtual

Called by the canvas to paint any decorations that the tool deems needed. The painter has the top left of the canvas as its origin.

Parameters
painterused for painting the shape
converterto convert between internal and view coordinates.

Implements KoToolBase.

Definition at line 441 of file KoPathTool.cpp.

442{
443 Q_D(KoToolBase);
444 m_textOutlineHelper->setDecorationThickness(decorationThickness());
445 m_textOutlineHelper->setHandleRadius(handleRadius());
446 m_textOutlineHelper->paint(&painter, converter);
447
449
450 Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
454
455 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
456 if (parameterShape && parameterShape->isParametricShape()) {
457 parameterShape->paintHandles(helper);
458 } else {
459 shape->paintPoints(helper);
460 }
461
462 if (!shape->stroke() || !shape->stroke()->isVisible()) {
464 helper.drawPath(shape->outline());
465 }
466 }
467
468 if (m_currentStrategy) {
469 painter.save();
470 m_currentStrategy->paint(painter, converter, canvas()->displayRendererInterface());
471 painter.restore();
472 }
473
475
476 if (m_activeHandle) {
479 } else {
480 m_activeHandle.reset();
481 }
482 } else if (m_activeSegment && m_activeSegment->isValid()) {
483
484 KoPathShape *shape = m_activeSegment->path;
485
486 // if the stroke is invisible, then we already painted the outline of the shape!
487 if (shape->stroke() && shape->stroke()->isVisible()) {
488 KoPathPointIndex index = shape->pathPointIndex(m_activeSegment->segmentStart);
489 KoPathSegment segment = shape->segmentByIndex(index).toCubic();
490
492
496
497 QPainterPath path;
498 path.moveTo(segment.first()->point());
499 path.cubicTo(segment.first()->controlPoint2(),
500 segment.second()->controlPoint1(),
501 segment.second()->point());
502
503 helper.drawPath(path);
504 }
505 }
506
507
508
509 if (m_currentStrategy) {
510 painter.save();
511 painter.setTransform(converter.documentToView(), true);
512 d->canvas->snapGuide()->paint(painter, converter, canvas()->displayRendererInterface());
513 painter.restore();
514 }
515}
The KisHandlePainterHelper class is a special helper for painting handles around objects....
void drawPath(const QPainterPath &path)
void setHandleStyle(const KisHandleStyle &style)
static KisHandleStyle & secondarySelection(KisHandlePalette palette=KisHandlePalette())
static KisHandleStyle & primarySelection(KisHandlePalette palette=KisHandlePalette())
virtual KoColorDisplayRendererInterface * displayRendererInterface() const
displayRendererInterface The display renderer interface has a number of color conversion functions wh...
virtual KisHandlePalette handlePaletteForDisplayColorSpace() const =0
handlePaletteForDisplayColorSpace
void paintHandles(KisHandlePainterHelper &handlesHelper)
Paint the handles.
QPointF point
QPointF controlPoint1
QPointF controlPoint2
bool isValid() const
Returns if segment is valid, e.g. has two valid points.
KoPathSegment toCubic() const
Returns cubic bezier curve segment of this segment.
QPainterPath outline() const override
reimplemented
virtual void paintPoints(KisHandlePainterHelper &handlesHelper)
void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, KoColorDisplayRendererInterface *renderInterface)
Draw the selected points.
virtual KoShapeStrokeModelSP stroke() const
Definition KoShape.cpp:885
static KisHandlePainterHelper createHandlePainterHelperView(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
Definition KoShape.cpp:977
int handleRadius() const
Convenience function to get the current handle radius.
int decorationThickness() const
decorationThickness The minimum thickness for tool decoration lines, this is derived from the screen ...
virtual QPointF documentToView(const QPointF &documentPoint) const
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
rgba palette[MAX_PALETTE]
Definition palette.c:35

References KoToolBase::canvas(), KoPathPoint::controlPoint1, KoPathPoint::controlPoint2, KoShape::createHandlePainterHelperView(), KoToolBase::decorationThickness(), KoCanvasBase::displayRendererInterface(), KoViewConverter::documentToView(), KisHandlePainterHelper::drawPath(), KoPathSegment::first, KoColorDisplayRendererInterface::handlePaletteForDisplayColorSpace(), KoToolBase::handleRadius(), KoParameterShape::isParametricShape(), KoPathSegment::isValid(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_activeHandle, m_activeSegment, m_currentStrategy, m_pointSelection, m_textOutlineHelper, KoPathShape::outline(), KoPathToolSelection::paint(), KoParameterShape::paintHandles(), KoPathShape::paintPoints(), palette, KoPathShape::pathPointIndex(), KoPathPoint::point, KisHandleStyle::primarySelection(), KoPathSegment::second, KisHandleStyle::secondarySelection(), KoPathShape::segmentByIndex(), KoPathToolSelection::selectedShapes(), KisHandlePainterHelper::setHandleStyle(), KoShape::stroke(), and KoPathSegment::toCubic().

◆ pointSelectionChanged

void KoPathTool::pointSelectionChanged ( )
privateslot

◆ pointToCurve

void KoPathTool::pointToCurve ( )
privateslot

Definition at line 233 of file KoPathTool.cpp.

234{
235 Q_D(KoToolBase);
238
239 KUndo2Command *command = createPointToCurveCommand(selectedPoints);
240
241 if (command) {
242 d->canvas->addCommand(command);
243 }
244 }
245}
KUndo2Command * createPointToCurveCommand(const QList< KoPathPointData > &points)

References createPointToCurveCommand(), KoPathToolSelection::hasSelection(), m_pointSelection, and KoPathToolSelection::selectedPointsData().

◆ pointToLine

void KoPathTool::pointToLine ( )
privateslot

Definition at line 213 of file KoPathTool.cpp.

214{
215 Q_D(KoToolBase);
218 QList<KoPathPointData> pointToChange;
219
220 QList<KoPathPointData>::const_iterator it(selectedPoints.constBegin());
221 for (; it != selectedPoints.constEnd(); ++it) {
222 KoPathPoint *point = it->pathShape->pointByIndex(it->pointIndex);
223 if (point && (point->activeControlPoint1() || point->activeControlPoint2()))
224 pointToChange.append(*it);
225 }
226
227 if (! pointToChange.isEmpty()) {
228 d->canvas->addCommand(new KoPathPointTypeCommand(pointToChange, KoPathPointTypeCommand::Line));
229 }
230 }
231}

References KoPathPoint::activeControlPoint1, KoPathPoint::activeControlPoint2, KoPathToolSelection::hasSelection(), KoPathPointTypeCommand::Line, m_pointSelection, and KoPathToolSelection::selectedPointsData().

◆ pointTypeChanged

void KoPathTool::pointTypeChanged ( KoPathPointTypeCommand::PointType type)
privateslot

Definition at line 147 of file KoPathTool.cpp.

148{
149 Q_D(KoToolBase);
152
153 KUndo2Command *initialConversionCommand = createPointToCurveCommand(selectedPoints);
154
155 // conversion should happen before the c-tor
156 // of KoPathPointTypeCommand is executed!
157 if (initialConversionCommand) {
158 initialConversionCommand->redo();
159 }
160
161 KUndo2Command *command =
162 new KoPathPointTypeCommand(selectedPoints, type);
163
164 if (initialConversionCommand) {
165 using namespace KisCommandUtils;
167 parent->setText(command->text());
168 parent->addCommand(new SkipFirstRedoWrapper(initialConversionCommand));
169 parent->addCommand(command);
170 command = parent;
171 }
172
173 d->canvas->addCommand(command);
174 }
175}
KUndo2MagicString text() const
virtual void redo()

References createPointToCurveCommand(), KoPathToolSelection::hasSelection(), m_pointSelection, KUndo2Command::redo(), KoPathToolSelection::selectedPointsData(), and KUndo2Command::text().

◆ pointTypeChangedCorner

void KoPathTool::pointTypeChangedCorner ( )
privateslot

Definition at line 137 of file KoPathTool.cpp.

137 {
139}
void pointTypeChanged(KoPathPointTypeCommand::PointType type)

References KoPathPointTypeCommand::Corner, and pointTypeChanged().

◆ pointTypeChangedSmooth

void KoPathTool::pointTypeChangedSmooth ( )
privateslot

◆ pointTypeChangedSymmetric

void KoPathTool::pointTypeChangedSymmetric ( )
privateslot

◆ popupActionsMenu()

QMenu * KoPathTool::popupActionsMenu ( )
overridevirtual
Returns
a menu with context-aware actions for the current selection. If the returned value is null, no context menu is shown.

Reimplemented from KoToolBase.

Definition at line 1133 of file KoPathTool.cpp.

1134{
1135 if (m_activeHandle) {
1136 m_activeHandle->trySelectHandle();
1137 }
1138
1139 if (m_activeSegment && m_activeSegment->isValid()) {
1140 KoPathShape *shape = m_activeSegment->path;
1141 KoPathSegment segment = shape->segmentByIndex(shape->pathPointIndex(m_activeSegment->segmentStart));
1142
1143 m_pointSelection.add(segment.first(), true);
1144 m_pointSelection.add(segment.second(), false);
1145 }
1146
1147 if (m_contextMenu) {
1148 m_contextMenu->clear();
1149
1150 addActionsGroupIfEnabled(m_contextMenu.data(),
1154
1155 addActionsGroupIfEnabled(m_contextMenu.data(),
1158
1159 addActionsGroupIfEnabled(m_contextMenu.data(),
1162
1163 addActionsGroupIfEnabled(m_contextMenu.data(),
1166
1167 addActionsGroupIfEnabled(m_contextMenu.data(),
1170
1171 addActionsGroupIfEnabled(m_contextMenu.data(),
1174
1176
1177 m_contextMenu->addSeparator();
1178 }
1179
1180 return m_contextMenu.data();
1181}

References KoPathToolSelection::add(), KoPathSegment::first, m_actionAddPoint, m_actionBreakPoint, m_actionBreakSegment, m_actionConvertToPath, m_actionCurvePoint, m_actionCurveSegment, m_actionJoinSegment, m_actionLinePoint, m_actionLineSegment, m_actionMergePoints, m_actionPathPointCorner, m_actionPathPointSmooth, m_actionPathPointSymmetric, m_actionRemovePoint, m_activeHandle, m_activeSegment, m_contextMenu, m_pointSelection, KoPathShape::pathPointIndex(), KoPathSegment::second, and KoPathShape::segmentByIndex().

◆ removePoints

void KoPathTool::removePoints ( )
privateslot

Definition at line 199 of file KoPathTool.cpp.

200{
201 Q_D(KoToolBase);
202 if (m_pointSelection.size() > 0) {
204 PointHandle *pointHandle = dynamic_cast<PointHandle*>(m_activeHandle.data());
205 if (pointHandle && m_pointSelection.contains(pointHandle->activePoint())) {
206 m_activeHandle.reset();
207 }
209 d->canvas->addCommand(cmd);
210 }
211}
static KUndo2Command * createCommand(const QList< KoPathPointData > &pointDataList, KoShapeController *shapeController, KUndo2Command *parent=0)
Create command for removing points from path shapes.

References PointHandle::activePoint(), clearActivePointSelectionReferences(), KoPathToolSelection::contains(), KoPathPointRemoveCommand::createCommand(), m_activeHandle, m_pointSelection, KoPathToolSelection::selectedPointsData(), and KoPathToolSelection::size().

◆ repaintDecorations()

void KoPathTool::repaintDecorations ( )
overridevirtual

request a repaint of the decorations to be made. This triggers an update call on the canvas, but does not paint directly.

Reimplemented from KoToolBase.

Definition at line 550 of file KoPathTool.cpp.

551{
554}
virtual void repaintDecorations()

References KoToolBase::repaintDecorations(), and updateOptionsWidget().

◆ requestStrokeCancellation()

void KoPathTool::requestStrokeCancellation ( )
overridevirtual

Called when the user requests cancellation of the current stroke. If your tool supports cancelling, override this method and implement the desired effects there.

Reimplemented from KoToolBase.

Definition at line 1198 of file KoPathTool.cpp.

1199{
1201}

References explicitUserStrokeEndRequest().

◆ requestStrokeEnd()

void KoPathTool::requestStrokeEnd ( )
overridevirtual

Called when the image decided that the stroke should better be ended. If your tool supports long strokes, override this method and implement the desired effects there.

Reimplemented from KoToolBase.

Definition at line 1203 of file KoPathTool.cpp.

1204{
1205 // noop!
1206}

◆ requestUndoDuringStroke()

void KoPathTool::requestUndoDuringStroke ( )
overridevirtual

Called when the user requested undo while the stroke is active. If your tool supports undoing, override this method and implement the desired effects there.

NOTE: Default implementation forwards this request to requestStrokeCancellation() method, so that the stroke would be cancelled.

Default implementation just cancels the stroke

Reimplemented from KoToolBase.

Definition at line 1193 of file KoPathTool.cpp.

1194{
1195 // noop!
1196}

◆ segmentAtPoint()

KoPathTool::PathSegment * KoPathTool::segmentAtPoint ( const QPointF & point)
private

Definition at line 837 of file KoPathTool.cpp.

838{
839 // the max allowed distance from a segment
840 const QRectF grabRoi = handleGrabRect(point);
841 std::unique_ptr<PathSegment> segment(new PathSegment);
842
843 Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
844 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
845 if (parameterShape && parameterShape->isParametricShape())
846 continue;
847
848 const KoPathSegment s = shape->segmentAtPoint(point, grabRoi);
849 if (s.isValid()) {
850 segment->path = shape;
851 segment->segmentStart = s.first();
852 segment->positionOnSegment = s.nearestPoint(shape->documentToShape(point));
853 }
854 }
855
856 if (!segment->isValid()) {
857 segment.reset();
858 }
859
860 return segment.release();
861}
qreal nearestPoint(const QPointF &point) const
KoPathSegment segmentAtPoint(const QPointF &point, const QRectF &grabRoi) const

References KoShape::documentToShape(), KoPathSegment::first, KoToolBase::handleGrabRect(), KoParameterShape::isParametricShape(), KoPathSegment::isValid(), m_pointSelection, KoPathSegment::nearestPoint(), KoPathShape::segmentAtPoint(), and KoPathToolSelection::selectedShapes().

◆ segmentToCurve

void KoPathTool::segmentToCurve ( )
privateslot

Definition at line 277 of file KoPathTool.cpp.

278{
279 Q_D(KoToolBase);
280 if (m_pointSelection.size() > 1) {
282 if (segments.size() > 0) {
283 d->canvas->addCommand(new KoPathSegmentTypeCommand(segments, KoPathSegmentTypeCommand::Curve));
284 }
285 }
286}
The undo / redo command for changing segments to curves/lines.

References KoPathSegmentTypeCommand::Curve, m_pointSelection, KoPathToolSelection::selectedSegmentsData(), and KoPathToolSelection::size().

◆ segmentToLine

void KoPathTool::segmentToLine ( )
privateslot

◆ selectAll()

bool KoPathTool::selectAll ( )
overridevirtual

selectAll select all data the tool can select.

Returns
true if something happened, false if nothing happened.

Reimplemented from KoToolBase.

Definition at line 1213 of file KoPathTool.cpp.

1214{
1217 return true;
1218}

References m_pointSelection, repaintDecorations(), and KoPathToolSelection::selectAll().

◆ selection()

KoToolSelection * KoPathTool::selection ( )
overridevirtual

Returns the internal selection object of this tool. Each tool can have a selection which is private to that tool and the specified shape that it comes with. The default returns 0.

Reimplemented from KoToolBase.

Definition at line 1188 of file KoPathTool.cpp.

1189{
1190 return &m_pointSelection;
1191}

References m_pointSelection.

◆ singleShapeChanged

void KoPathTool::singleShapeChanged ( KoPathShape * path)
signal

◆ slotSelectionChanged

void KoPathTool::slotSelectionChanged ( )
privateslot

Definition at line 898 of file KoPathTool.cpp.

899{
900 Q_D(KoToolBase);
901 QList<KoShape*> shapes =
902 d->canvas->selectedShapesProxy()->selection()->selectedEditableShapesAndDelegates();
903
904 initializeWithShapes(shapes);
905}

References initializeWithShapes().

◆ typeChanged

void KoPathTool::typeChanged ( int types)
signal

◆ updateActions

void KoPathTool::updateActions ( )
privateslot

Definition at line 960 of file KoPathTool.cpp.

961{
963
964 bool canBreakAtPoint = false;
965
966 bool hasNonSmoothPoints = false;
967 bool hasNonSymmetricPoints = false;
968 bool hasNonSplitPoints = false;
969
970 bool hasNonLinePoints = false;
971 bool hasNonCurvePoints = false;
972
973 bool canJoinSubpaths = false;
974
975 if (!pointData.isEmpty()) {
976 Q_FOREACH (const KoPathPointData &pd, pointData) {
977 const int subpathIndex = pd.pointIndex.first;
978 const int pointIndex = pd.pointIndex.second;
979
980 canBreakAtPoint |= pd.pathShape->isClosedSubpath(subpathIndex) ||
981 (pointIndex > 0 && pointIndex < pd.pathShape->subpathPointCount(subpathIndex) - 1);
982
984
985 hasNonSmoothPoints |= !(point->properties() & KoPathPoint::IsSmooth);
986 hasNonSymmetricPoints |= !(point->properties() & KoPathPoint::IsSymmetric);
987 hasNonSplitPoints |=
990
991 hasNonLinePoints |= point->activeControlPoint1() || point->activeControlPoint2();
992 hasNonCurvePoints |= !point->activeControlPoint1() && !point->activeControlPoint2();
993 }
994
995 if (pointData.size() == 2) {
996 const KoPathPointData & pd1 = pointData.at(0);
997 const KoPathPointData & pd2 = pointData.at(1);
998
999 canJoinSubpaths = checkCanJoinToPoints(pd1, pd2);
1000 }
1001 }
1002
1003 m_actionPathPointCorner->setEnabled(hasNonSplitPoints);
1004 m_actionPathPointSmooth->setEnabled(hasNonSmoothPoints);
1005 m_actionPathPointSymmetric->setEnabled(hasNonSymmetricPoints);
1006
1007 m_actionRemovePoint->setEnabled(!pointData.isEmpty());
1008
1009 m_actionBreakPoint->setEnabled(canBreakAtPoint);
1010
1011 m_actionCurvePoint->setEnabled(hasNonCurvePoints);
1012 m_actionLinePoint->setEnabled(hasNonLinePoints);
1013
1014 m_actionJoinSegment->setEnabled(canJoinSubpaths);
1015 m_actionMergePoints->setEnabled(canJoinSubpaths);
1016
1018
1019
1020 bool canSplitAtSegment = false;
1021 bool canConvertSegmentToLine = false;
1022 bool canConvertSegmentToCurve= false;
1023
1024 if (!segments.isEmpty()) {
1025
1026 canSplitAtSegment = segments.size() == 1;
1027
1028 bool hasLines = false;
1029 bool hasCurves = false;
1030
1031 Q_FOREACH (const KoPathPointData &pd, segments) {
1033 hasLines |= segment.degree() == 1;
1034 hasCurves |= segment.degree() > 1;
1035 }
1036
1037 canConvertSegmentToLine = !segments.isEmpty() && hasCurves;
1038 canConvertSegmentToCurve= !segments.isEmpty() && hasLines;
1039 }
1040
1041 m_actionAddPoint->setEnabled(canSplitAtSegment);
1042
1043 m_actionLineSegment->setEnabled(canConvertSegmentToLine);
1044 m_actionCurveSegment->setEnabled(canConvertSegmentToCurve);
1045
1046 m_actionBreakSegment->setEnabled(canSplitAtSegment);
1047 m_actionBreakSelection->setEnabled(canSplitAtSegment | canBreakAtPoint);
1048
1050 bool haveConvertibleShapes = false;
1051 Q_FOREACH (KoShape *shape, selection->selectedEditableShapes()) {
1052 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
1053 KoSvgTextShape *textShape = dynamic_cast<KoSvgTextShape*>(shape);
1054 if (textShape ||
1055 (parameterShape && parameterShape->isParametricShape())) {
1056
1057 haveConvertibleShapes = true;
1058 break;
1059 }
1060 }
1061 m_actionConvertToPath->setEnabled(haveConvertibleShapes);
1062}
KoPathPointIndex pointIndex
position of the point in the path shape
KoPathShape * pathShape
path shape the path point belongs too
PointProperties properties
@ 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
int degree() const
Returns the degree of the segment: 1 = line, 2 = quadratic, 3 = cubic, -1 = invalid.
int subpathPointCount(int subpathIndex) const
Returns the number of points in a subpath.
bool isClosedSubpath(int subpathIndex) const
Checks if a subpath is closed.
KoPathPoint * pointByIndex(const KoPathPointIndex &pointIndex) const
Returns the path point specified by a path point index.

References KoPathPoint::activeControlPoint1, KoPathPoint::activeControlPoint2, KoToolBase::canvas(), KoPathSegment::degree(), KoPathShape::isClosedSubpath(), KoParameterShape::isParametricShape(), KoPathPoint::IsSmooth, KoPathPoint::IsSymmetric, m_actionAddPoint, m_actionBreakPoint, m_actionBreakSegment, m_actionBreakSelection, m_actionConvertToPath, m_actionCurvePoint, m_actionCurveSegment, m_actionJoinSegment, m_actionLinePoint, m_actionLineSegment, m_actionMergePoints, m_actionPathPointCorner, m_actionPathPointSmooth, m_actionPathPointSymmetric, m_actionRemovePoint, m_pointSelection, KoPathPointData::pathShape, KoPathShape::pointByIndex(), KoPathPointData::pointIndex, KoPathPoint::properties, KoPathShape::segmentByIndex(), KoPathToolSelection::selectedPointsData(), KoPathToolSelection::selectedSegmentsData(), KoCanvasBase::selectedShapesProxy(), selection(), KoSelectedShapesProxy::selection(), and KoPathShape::subpathPointCount().

◆ updateOptionsWidget()

void KoPathTool::updateOptionsWidget ( )
private

Definition at line 946 of file KoPathTool.cpp.

947{
948 PathToolOptionWidget::Types type;
950 Q_FOREACH (KoPathShape *shape, selectedShapes) {
951 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
952 type |= parameterShape && parameterShape->isParametricShape() ?
954 }
955
956 Q_EMIT singleShapeChanged(selectedShapes.size() == 1 ? selectedShapes.first() : 0);
957 Q_EMIT typeChanged(type);
958}

References KoParameterShape::isParametricShape(), m_pointSelection, PathToolOptionWidget::ParametricShape, PathToolOptionWidget::PlainPath, KoPathToolSelection::selectedShapes(), singleShapeChanged(), and typeChanged().

Friends And Related Symbol Documentation

◆ TestPathTool

friend class TestPathTool
friend

Definition at line 123 of file KoPathTool.h.

Member Data Documentation

◆ m_actionAddPoint

QAction* KoPathTool::m_actionAddPoint
private

Definition at line 134 of file KoPathTool.h.

◆ m_actionBreakPoint

QAction* KoPathTool::m_actionBreakPoint
private

Definition at line 136 of file KoPathTool.h.

◆ m_actionBreakSegment

QAction* KoPathTool::m_actionBreakSegment
private

Definition at line 137 of file KoPathTool.h.

◆ m_actionBreakSelection

QAction* KoPathTool::m_actionBreakSelection
private

Definition at line 138 of file KoPathTool.h.

◆ m_actionConvertToPath

QAction* KoPathTool::m_actionConvertToPath
private

Definition at line 141 of file KoPathTool.h.

◆ m_actionCurvePoint

QAction* KoPathTool::m_actionCurvePoint
private

Definition at line 130 of file KoPathTool.h.

◆ m_actionCurveSegment

QAction* KoPathTool::m_actionCurveSegment
private

Definition at line 133 of file KoPathTool.h.

◆ m_actionJoinSegment

QAction* KoPathTool::m_actionJoinSegment
private

Definition at line 139 of file KoPathTool.h.

◆ m_actionLinePoint

QAction* KoPathTool::m_actionLinePoint
private

Definition at line 131 of file KoPathTool.h.

◆ m_actionLineSegment

QAction* KoPathTool::m_actionLineSegment
private

Definition at line 132 of file KoPathTool.h.

◆ m_actionMergePoints

QAction* KoPathTool::m_actionMergePoints
private

Definition at line 140 of file KoPathTool.h.

◆ m_actionPathPointCorner

QAction* KoPathTool::m_actionPathPointCorner
private

Definition at line 127 of file KoPathTool.h.

◆ m_actionPathPointSmooth

QAction* KoPathTool::m_actionPathPointSmooth
private

Definition at line 128 of file KoPathTool.h.

◆ m_actionPathPointSymmetric

QAction* KoPathTool::m_actionPathPointSymmetric
private

Definition at line 129 of file KoPathTool.h.

◆ m_actionRemovePoint

QAction* KoPathTool::m_actionRemovePoint
private

Definition at line 135 of file KoPathTool.h.

◆ m_activeHandle

QScopedPointer<KoPathToolHandle> KoPathTool::m_activeHandle
private

the currently active handle

Definition at line 118 of file KoPathTool.h.

◆ m_activeSegment

QScopedPointer<PathSegment> KoPathTool::m_activeSegment
private

Definition at line 120 of file KoPathTool.h.

◆ m_canvasConnections

KisSignalAutoConnectionsStore KoPathTool::m_canvasConnections
private

Definition at line 145 of file KoPathTool.h.

◆ m_contextMenu

QScopedPointer<QMenu> KoPathTool::m_contextMenu
private

Definition at line 143 of file KoPathTool.h.

◆ m_currentStrategy

QScopedPointer<KoInteractionStrategy> KoPathTool::m_currentStrategy
private

the rubber selection strategy

Definition at line 125 of file KoPathTool.h.

◆ m_lastPoint

QPointF KoPathTool::m_lastPoint
private

needed for interaction strategy

Definition at line 119 of file KoPathTool.h.

◆ m_moveCursor

QCursor KoPathTool::m_moveCursor
private

Definition at line 142 of file KoPathTool.h.

◆ m_pointSelection

KoPathToolSelection KoPathTool::m_pointSelection
protected

the point selection

Definition at line 114 of file KoPathTool.h.

◆ m_selectCursor

QCursor KoPathTool::m_selectCursor
protected

Definition at line 115 of file KoPathTool.h.

◆ m_shapeFillResourceConnector

KoShapeFillResourceConnector KoPathTool::m_shapeFillResourceConnector
private

Definition at line 146 of file KoPathTool.h.

◆ m_textOutlineHelper

QScopedPointer<KoSvgTextShapeOutlineHelper> KoPathTool::m_textOutlineHelper
private

Definition at line 144 of file KoPathTool.h.


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