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

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

#include <KoPathPointMoveStrategy.h>

+ Inheritance diagram for KoPathPointMoveStrategy:

Public Member Functions

KUndo2CommandcreateCommand () override
 
void finishInteraction (Qt::KeyboardModifiers modifiers) override
 
void handleMouseMove (const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override
 
 KoPathPointMoveStrategy (KoPathTool *tool, const QPointF &mousePosition, const QPointF &pointPosition)
 
 ~KoPathPointMoveStrategy () 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_move
 the accumulated point move amount
 
QPointF m_startMousePosition
 
QPointF m_startPointPosition
 
KoPathToolm_tool
 pointer to the path 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.

Definition at line 21 of file KoPathPointMoveStrategy.h.

Constructor & Destructor Documentation

◆ KoPathPointMoveStrategy()

KoPathPointMoveStrategy::KoPathPointMoveStrategy ( KoPathTool * tool,
const QPointF & mousePosition,
const QPointF & pointPosition )

Definition at line 20 of file KoPathPointMoveStrategy.cpp.

◆ ~KoPathPointMoveStrategy()

KoPathPointMoveStrategy::~KoPathPointMoveStrategy ( )
override

Definition at line 28 of file KoPathPointMoveStrategy.cpp.

29{
30}

Member Function Documentation

◆ createCommand()

KUndo2Command * KoPathPointMoveStrategy::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 59 of file KoPathPointMoveStrategy.cpp.

60{
63 }
64 return nullptr;
65}
QScopedPointer< KUndo2Command > m_intermediateCommand

References m_intermediateCommand.

◆ finishInteraction()

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

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

Implements KoInteractionStrategy.

Definition at line 54 of file KoPathPointMoveStrategy.cpp.

55{
56 Q_UNUSED(modifiers);
57}

◆ handleMouseMove()

void KoPathPointMoveStrategy::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 32 of file KoPathPointMoveStrategy.cpp.

33{
34 QPointF deltaMovement = mouseLocation - m_startMousePosition;
35 QPointF newPosition = m_tool->canvas()->snapGuide()->snap(m_startPointPosition + deltaMovement, modifiers);
36 QPointF move = newPosition - m_startPointPosition;
37
38 if (modifiers & Qt::ShiftModifier) {
39 // Limit change to one direction only
40 move = snapToClosestAxis(move);
41 }
42
43 KoPathToolSelection * selection = dynamic_cast<KoPathToolSelection*>(m_tool->selection());
44 if (! selection)
45 return;
46
48 new KoPathPointMoveCommand(selection->selectedPointsData(), move - m_move),
50
51 m_move = move;
52}
KoSnapGuide * snapGuide
The undo / redo command for path point moving.
QPointF m_move
the accumulated point move amount
Handle the selection of points.
QList< KoPathPointData > selectedPointsData() const
Get the point data of all selected points.
KoToolSelection * selection() override
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.
PointType snapToClosestAxis(PointType P)
Definition kis_global.h:199
void redoAndMergeIntoAccumulatingCommand(KUndo2Command *cmd, QScopedPointer< KUndo2Command > &accumulatingCommand)

References KoToolBase::canvas(), m_intermediateCommand, m_move, m_startMousePosition, m_startPointPosition, m_tool, KisCommandUtils::redoAndMergeIntoAccumulatingCommand(), KoPathToolSelection::selectedPointsData(), KoPathTool::selection(), KoSnapGuide::snap(), KoCanvasBase::snapGuide, and snapToClosestAxis().

Member Data Documentation

◆ m_intermediateCommand

QScopedPointer<KUndo2Command> KoPathPointMoveStrategy::m_intermediateCommand
private

Definition at line 37 of file KoPathPointMoveStrategy.h.

◆ m_move

QPointF KoPathPointMoveStrategy::m_move
private

the accumulated point move amount

Definition at line 34 of file KoPathPointMoveStrategy.h.

◆ m_startMousePosition

QPointF KoPathPointMoveStrategy::m_startMousePosition
private

Definition at line 31 of file KoPathPointMoveStrategy.h.

◆ m_startPointPosition

QPointF KoPathPointMoveStrategy::m_startPointPosition
private

Definition at line 32 of file KoPathPointMoveStrategy.h.

◆ m_tool

KoPathTool* KoPathPointMoveStrategy::m_tool
private

pointer to the path tool

Definition at line 36 of file KoPathPointMoveStrategy.h.


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