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

Strategy for moving points of a path shape. More...

#include <KoPathControlPointMoveStrategy.h>

+ Inheritance diagram for KoPathControlPointMoveStrategy:

Public Member Functions

KUndo2CommandcreateCommand () override
 
void finishInteraction (Qt::KeyboardModifiers modifiers) override
 
void handleMouseMove (const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override
 
 KoPathControlPointMoveStrategy (KoPathTool *tool, const KoPathPointData &point, KoPathPoint::PointType type, const QPointF &pos)
 
 ~KoPathControlPointMoveStrategy () override
 
- Public Member Functions inherited from KoInteractionStrategy
virtual void cancelInteraction ()
 
 KoInteractionStrategy (KoToolBase *parent)
 constructor
 
virtual void paint (QPainter &painter, const KoViewConverter &converter)
 
KoToolBasetool () const
 
virtual ~KoInteractionStrategy ()
 Destructor.
 

Private Attributes

QScopedPointer< KUndo2Commandm_intermediateCommand
 
QPointF m_lastPosition
 the last mouse position
 
QPointF m_move
 the accumulated point move amount
 
KoPathShapem_path
 
KoPathPointData m_pointData
 
KoPathPoint::PointType m_pointType
 
KoPathToolm_tool
 

Additional Inherited Members

- Protected Member Functions inherited from KoInteractionStrategy
uint decorationThickness () const
 
uint grabSensitivity () const
 Convenience function to get the global grab sensitivity.
 
uint handleRadius () const
 Convenience function to get the global handle radius.
 
 KoInteractionStrategy (KoInteractionStrategyPrivate &)
 constructor
 
- Protected Attributes inherited from KoInteractionStrategy
KoInteractionStrategyPrivated_ptr
 

Detailed Description

Strategy for moving points of a path shape.

/internal

Definition at line 22 of file KoPathControlPointMoveStrategy.h.

Constructor & Destructor Documentation

◆ KoPathControlPointMoveStrategy()

KoPathControlPointMoveStrategy::KoPathControlPointMoveStrategy ( KoPathTool * tool,
const KoPathPointData & point,
KoPathPoint::PointType type,
const QPointF & pos )

Definition at line 16 of file KoPathControlPointMoveStrategy.cpp.

18 , m_lastPosition(pos)
19 , m_move(0, 0)
20 , m_tool(tool)
21 , m_pointData(pointData)
22 , m_pointType(type)
23{
25}
KoInteractionStrategy(KoToolBase *parent)
constructor
QPointF m_lastPosition
the last mouse position
QPointF m_move
the accumulated point move amount
KoPathShape * pathShape
path shape the path point belongs too

References m_path, m_pointData, and KoPathPointData::pathShape.

◆ ~KoPathControlPointMoveStrategy()

KoPathControlPointMoveStrategy::~KoPathControlPointMoveStrategy ( )
override

Definition at line 27 of file KoPathControlPointMoveStrategy.cpp.

28{
29}

Member Function Documentation

◆ createCommand()

KUndo2Command * KoPathControlPointMoveStrategy::createCommand ( )
overridevirtual

For interactions that are undo-able this method should be implemented to return such a command. Implementations should return 0 otherwise.

Returns
a command, or 0.

Implements KoInteractionStrategy.

Definition at line 52 of file KoPathControlPointMoveStrategy.cpp.

References m_intermediateCommand.

◆ finishInteraction()

void KoPathControlPointMoveStrategy::finishInteraction ( Qt::KeyboardModifiers modifiers)
overridevirtual

Override to make final changes to the data on the end of an interaction.

Implements KoInteractionStrategy.

Definition at line 47 of file KoPathControlPointMoveStrategy.cpp.

48{
49 Q_UNUSED(modifiers);
50}

◆ handleMouseMove()

void KoPathControlPointMoveStrategy::handleMouseMove ( const QPointF & mouseLocation,
Qt::KeyboardModifiers modifiers )
overridevirtual

Extending classes should implement this method to update the selectedShapes based on the new mouse position.

Parameters
mouseLocationthe new location in pt
modifiersOR-ed set of keys pressed.

Implements KoInteractionStrategy.

Definition at line 31 of file KoPathControlPointMoveStrategy.cpp.

32{
33 QPointF docPoint = m_tool->canvas()->snapGuide()->snap(mouseLocation, modifiers);
34 QPointF localPos = m_path->documentToShape(docPoint);
35 QPointF move = localPos - m_path->documentToShape(m_lastPosition);
36 // as the last position can change when the top left is changed we have
37 // to save it in document pos and not in shape pos
38 m_lastPosition = docPoint;
39
40 m_move += move;
41
45}
KoSnapGuide * snapGuide
The undo / redo command for path point moving.
QPointF documentToShape(const QPointF &point) const
Transforms point from document coordinates to shape coordinates.
Definition KoShape.cpp:1211
QPointF snap(const QPointF &mousePosition, Qt::KeyboardModifiers modifiers)
snaps the mouse position, returns if mouse was snapped
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
void redoAndMergeIntoAccumulatingCommand(KUndo2Command *cmd, QScopedPointer< KUndo2Command > &accumulatingCommand)

References KoToolBase::canvas(), KoShape::documentToShape(), m_intermediateCommand, m_lastPosition, m_move, m_path, m_pointData, m_pointType, m_tool, KisCommandUtils::redoAndMergeIntoAccumulatingCommand(), KoSnapGuide::snap(), and KoCanvasBase::snapGuide.

Member Data Documentation

◆ m_intermediateCommand

QScopedPointer<KUndo2Command> KoPathControlPointMoveStrategy::m_intermediateCommand
private

Definition at line 42 of file KoPathControlPointMoveStrategy.h.

◆ m_lastPosition

QPointF KoPathControlPointMoveStrategy::m_lastPosition
private

the last mouse position

Definition at line 34 of file KoPathControlPointMoveStrategy.h.

◆ m_move

QPointF KoPathControlPointMoveStrategy::m_move
private

the accumulated point move amount

Definition at line 36 of file KoPathControlPointMoveStrategy.h.

◆ m_path

KoPathShape* KoPathControlPointMoveStrategy::m_path
private

Definition at line 40 of file KoPathControlPointMoveStrategy.h.

◆ m_pointData

KoPathPointData KoPathControlPointMoveStrategy::m_pointData
private

Definition at line 39 of file KoPathControlPointMoveStrategy.h.

◆ m_pointType

KoPathPoint::PointType KoPathControlPointMoveStrategy::m_pointType
private

Definition at line 41 of file KoPathControlPointMoveStrategy.h.

◆ m_tool

KoPathTool* KoPathControlPointMoveStrategy::m_tool
private

Definition at line 38 of file KoPathControlPointMoveStrategy.h.


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