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

Strategy for changing control points of parametric shapes. More...

#include <KoParameterChangeStrategy.h>

+ Inheritance diagram for KoParameterChangeStrategy:

Public Member Functions

KUndo2CommandcreateCommand () override
 
void finishInteraction (Qt::KeyboardModifiers modifiers) override
 
void handleMouseMove (const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override
 
 KoParameterChangeStrategy (KoToolBase *tool, KoParameterShape *parameterShape, int handleId)
 
 ~KoParameterChangeStrategy () 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.
 

Protected Member Functions

 KoParameterChangeStrategy (KoParameterChangeStrategyPrivate &)
 constructor
 
- 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
 

Additional Inherited Members

- Protected Attributes inherited from KoInteractionStrategy
KoInteractionStrategyPrivated_ptr
 

Detailed Description

Strategy for changing control points of parametric shapes.

Definition at line 18 of file KoParameterChangeStrategy.h.

Constructor & Destructor Documentation

◆ KoParameterChangeStrategy() [1/2]

KoParameterChangeStrategy::KoParameterChangeStrategy ( KoToolBase * tool,
KoParameterShape * parameterShape,
int handleId )

Constructs a strategy for changing control points of parametric shapes.

Parameters
toolthe tool the strategy belongs to
parameterShapethe parametric shapes the strategy is working on
handleIdthe id of the handle to modify

Definition at line 16 of file KoParameterChangeStrategy.cpp.

17 : KoInteractionStrategy(*(new KoParameterChangeStrategyPrivate(tool, parameterShape, handleId)))
18{
20 d->tool->canvas()->snapGuide()->setIgnoredShapes({parameterShape});
21}
KoInteractionStrategy(KoToolBase *parent)
constructor
Strategy for changing control points of parametric shapes.

◆ ~KoParameterChangeStrategy()

KoParameterChangeStrategy::~KoParameterChangeStrategy ( )
override

Definition at line 29 of file KoParameterChangeStrategy.cpp.

30{
31}

◆ KoParameterChangeStrategy() [2/2]

KoParameterChangeStrategy::KoParameterChangeStrategy ( KoParameterChangeStrategyPrivate & dd)
protected

constructor

Definition at line 23 of file KoParameterChangeStrategy.cpp.

25{
26
27}

Member Function Documentation

◆ createCommand()

KUndo2Command * KoParameterChangeStrategy::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 44 of file KoParameterChangeStrategy.cpp.

45{
47
48 d->tool->canvas()->snapGuide()->reset();
49
51 // check if handle position changed
52 if (d->startPoint != QPointF(0, 0) && d->startPoint != d->releasePoint) {
53 cmd = new KoParameterHandleMoveCommand(d->parameterShape, d->handleId, d->startPoint, d->releasePoint, d->lastModifierUsed);
54 }
55 return cmd;
56}
The undo / redo command for changing a parameter.

◆ finishInteraction()

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

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

Implements KoInteractionStrategy.

Definition at line 58 of file KoParameterChangeStrategy.cpp.

59{
60}

◆ handleMouseMove()

void KoParameterChangeStrategy::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 33 of file KoParameterChangeStrategy.cpp.

34{
36
37 const QPointF snappedPosition = d->tool->canvas()->snapGuide()->snap(mouseLocation, modifiers);
38
39 d->parameterShape->moveHandle(d->handleId, snappedPosition, modifiers);
40 d->lastModifierUsed = modifiers;
41 d->releasePoint = snappedPosition;
42}

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