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

#include <kis_tool_transform.h>

+ Inheritance diagram for KisToolTransform:

Public Types

enum  TransformToolMode {
  FreeTransformMode , WarpTransformMode , CageTransformMode , LiquifyTransformMode ,
  PerspectiveTransformMode , MeshTransformMode
}
 
enum  WarpType { RigidWarpType , AffineWarpType , SimilitudeWarpType }
 
- Public Types inherited from KisTool
enum  { FLAG_USES_CUSTOM_PRESET =0x01 , FLAG_USES_CUSTOM_COMPOSITEOP =0x02 , FLAG_USES_CUSTOM_SIZE =0x04 }
 
enum  AlternateAction {
  ChangeSize = AlternateChangeSize , ChangeSizeSnap = AlternateChangeSizeSnap , SampleFgNode = AlternateSampleFgNode , SampleBgNode = AlternateSampleBgNode ,
  SampleFgImage = AlternateSampleFgImage , SampleBgImage = AlternateSampleBgImage , Secondary = AlternateSecondary , Third = AlternateThird ,
  Fourth = AlternateFourth , Fifth = AlternateFifth , NONE = 10000
}
 
enum  NodePaintAbility {
  VECTOR , CLONE , PAINT , UNPAINTABLE ,
  MYPAINTBRUSH_UNPAINTABLE
}
 
enum  ToolAction {
  Primary , AlternateChangeSize , AlternateChangeSizeSnap , AlternateSampleFgNode ,
  AlternateSampleBgNode , AlternateSampleFgImage , AlternateSampleBgImage , AlternateSecondary ,
  AlternateThird , AlternateFourth , AlternateFifth , Alternate_NONE = 10000
}
 

Public Slots

void activate (const QSet< KoShape * > &shapes) override
 
void applyTransform ()
 
void canvasUpdateRequested ()
 
void convexHullCalculationRequested ()
 
void cursorOutlineUpdateRequested (const QPointF &imagePos)
 
void deactivate () override
 
void imageTooBigRequested (bool value)
 
void requestImageRecalculation ()
 
void requestRedoDuringStroke () override
 
void requestStrokeCancellation () override
 
void requestStrokeEnd () override
 
void requestUndoDuringStroke () override
 
void resetRotationCenterButtonsRequested ()
 
void setRotateX (double rotation)
 
void setRotateY (double rotation)
 
void setRotateZ (double rotation)
 
void setScaleX (double scaleX)
 
void setScaleY (double scaleY)
 
void setShearX (double shearX)
 
void setShearY (double shearY)
 
void setTransformMode (KisToolTransform::TransformToolMode newMode)
 
void setTranslateX (double translateX)
 
void setTranslateY (double translateY)
 
void setWarpFlexibility (double flexibility)
 
void setWarpPointDensity (int density)
 
void setWarpType (WarpType type)
 
void slotConvexHullCalculated (QPolygon hull, void *strokeStrategyCookie)
 
void updateOptionWidget ()
 
- Public Slots inherited from KisTool
void activate (const QSet< KoShape * > &shapes) override
 
void canvasResourceChanged (int key, const QVariant &res) override
 
void deactivate () override
 
virtual void updateSettingsViews ()
 
- Public Slots inherited from KoToolBase
virtual void activate (const QSet< KoShape * > &shapes)
 
virtual void canvasResourceChanged (int key, const QVariant &res)
 
virtual void deactivate ()
 
virtual void documentResourceChanged (int key, const QVariant &res)
 
virtual void repaintDecorations ()
 
virtual void requestRedoDuringStroke ()
 
virtual void requestStrokeCancellation ()
 
virtual void requestStrokeEnd ()
 
virtual void requestUndoDuringStroke ()
 
void setStatusText (const QString &statusText)
 
void updateOptionsWidgetIcons ()
 

Signals

void freeTransformChanged ()
 
void transformModeChanged ()
 
void warpTransformChanged ()
 
- Signals inherited from KisTool
void isActiveChanged (bool isActivated)
 
- 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 activateAlternateAction (AlternateAction action) override
 
void activatePrimaryAction () override
 
void beginActionImpl (KoPointerEvent *event, bool usePrimaryAction, KisTool::AlternateAction action)
 
void beginAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void beginPrimaryAction (KoPointerEvent *event) override
 
void continueActionImpl (KoPointerEvent *event, bool usePrimaryAction, KisTool::AlternateAction action)
 
void continueAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void continuePrimaryAction (KoPointerEvent *event) override
 
QWidget * createOptionWidget () override
 
void deactivateAlternateAction (AlternateAction action) override
 
void deactivatePrimaryAction () override
 
void endActionImpl (KoPointerEvent *event, bool usePrimaryAction, KisTool::AlternateAction action)
 
void endAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void endPrimaryAction (KoPointerEvent *event) override
 
 KisToolTransform (KoCanvasBase *canvas)
 
void mouseMoveEvent (KoPointerEvent *e) override
 
void mousePressEvent (KoPointerEvent *e) override
 
void mouseReleaseEvent (KoPointerEvent *e) override
 
void newActivationWithExternalSource (KisPaintDeviceSP externalSource) override
 newActivationWithExternalSource Makes sure that the tool is active and starts a new stroke, which will be able to access the pixels from the specified external source.
 
void paint (QPainter &gc, const KoViewConverter &converter) override
 
QMenu * popupActionsMenu () override
 
double rotateX () const
 
double rotateY () const
 
double rotateZ () const
 
double scaleX () const
 
double scaleY () const
 
double shearX () const
 
double shearY () const
 
TransformToolMode transformMode () const
 
double translateX () const
 
double translateY () const
 
bool wantsAutoScroll () const override
 wantsAutoScroll reimplemented from KoToolBase there's an issue where autoscrolling with this tool never makes the stroke end, so we return false here so that users don't get stuck with the tool. See bug 362659
 
double warpFlexibility () const
 
int warpPointDensity () const
 
WarpType warpType () const
 
 ~KisToolTransform () override
 
- Public Member Functions inherited from KisTool
virtual bool alternateActionSupportsHiResEvents (AlternateAction action) const
 
virtual void beginAlternateDoubleClickAction (KoPointerEvent *event, AlternateAction action)
 
virtual void beginPrimaryDoubleClickAction (KoPointerEvent *event)
 
void deleteSelection () override
 
virtual int flags () const
 
bool isActive () const
 
 KisTool (KoCanvasBase *canvas, const QCursor &cursor)
 
void mouseDoubleClickEvent (KoPointerEvent *event) override
 
void mouseTripleClickEvent (KoPointerEvent *event) override
 
KisTool::NodePaintAbility nodePaintAbility ()
 
virtual bool primaryActionSupportsHiResEvents () const
 
virtual bool supportsPaintingAssistants () const
 
 ~KisTool () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- 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 ()
 
virtual QRectF decorationsRect () const
 
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 deselect ()
 deselect the tool should clear the selection if it has one.
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event, const QPointF &point)
 
virtual void dropEvent (QDropEvent *event, const QPointF &point)
 
virtual void explicitUserStrokeEndRequest ()
 explicitUserStrokeEndRequest is called by the input manager when the user presses Enter key or any equivalent. This callback comes before requestStrokeEnd(), which comes from a different source.
 
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
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
 KoToolBase (KoCanvasBase *canvas)
 
bool maskSyntheticEvents () const
 
QList< QPointer< QWidget > > optionWidgets ()
 
virtual bool paste ()
 
virtual KisPopupWidgetInterfacepopupWidget ()
 
virtual bool selectAll ()
 selectAll select all data the tool can select.
 
virtual KoToolSelectionselection ()
 
Q_INVOKABLE QString toolId () const
 
 ~KoToolBase () override
 

Protected Slots

void resetCursorStyle () override
 
void slotGlobalConfigChanged ()
 
- Protected Slots inherited from KisTool
virtual void resetCursorStyle ()
 

Properties

double rotateX
 
double rotateY
 
double rotateZ
 
double scaleX
 
double scaleY
 
double shearX
 
double shearY
 
TransformToolMode transformMode
 
double translateX
 
double translateY
 
double warpFlexibility
 
int warpPointDensity
 
WarpType warpType
 
- Properties inherited from KisTool
bool isActive
 

Private Slots

void slotApplyTransform ()
 
void slotCancelTransform ()
 
void slotEditingFinished ()
 
void slotMoveDiscreteDown ()
 
void slotMoveDiscreteDownMore ()
 
void slotMoveDiscreteLeft ()
 
void slotMoveDiscreteLeftMore ()
 
void slotMoveDiscreteRight ()
 
void slotMoveDiscreteRightMore ()
 
void slotMoveDiscreteUp ()
 
void slotMoveDiscreteUpMore ()
 
void slotPreviewDeviceGenerated (KisPaintDeviceSP device)
 
void slotResetTransform (ToolTransformArgs::TransformMode mode)
 
void slotRestartAndContinueTransform ()
 
void slotRestartTransform ()
 
void slotTrackerChangedConfig (KisToolChangesTrackerDataSP status)
 
void slotTransactionGenerated (TransformTransactionProperties transaction, ToolTransformArgs args, void *strokeStrategyCookie)
 
void slotUiChangedConfig (bool needsPreviewRecalculation)
 
void slotUpdateToCageType ()
 
void slotUpdateToFreeTransformType ()
 
void slotUpdateToLiquifyType ()
 
void slotUpdateToMeshType ()
 
void slotUpdateToPerspectiveType ()
 
void slotUpdateToWarpType ()
 

Private Member Functions

void cancelStroke ()
 
void commitChanges ()
 
KisTransformStrategyBasecurrentStrategy () const
 
void endStroke ()
 
void initGuiAfterTransformMode ()
 
void initThumbnailImage (KisPaintDeviceSP previewDevice)
 
void initTransformMode (ToolTransformArgs::TransformMode mode)
 
void outlineChanged ()
 
void setFunctionalCursor ()
 
void setTransformFunction (QPointF mousePos, Qt::KeyboardModifiers modifiers)
 
void startStroke (ToolTransformArgs::TransformMode mode, bool forceReset)
 
void updateApplyResetAvailability ()
 

Private Attributes

KisActionapplyTransformation {0}
 
KisActioncageAction {0}
 
KisActionfreeTransformAction {0}
 
KisActionkeepAspectRatioAction {0}
 
KisActionliquifyAction {0}
 
KisSignalAutoConnectionsStore m_actionConnections
 
bool m_actuallyMoveWhileSelected {false}
 
KisAsynchronousStrokeUpdateHelper m_asyncUpdateHelper
 
QScopedPointer< KisCageTransformStrategym_cageStrategy
 
QPointer< KisCanvas2m_canvas
 
KisToolChangesTracker m_changesTracker
 
QScopedPointer< QMenu > m_contextMenu
 
ToolTransformArgs m_currentArgs
 
bool m_currentlyUsingOverlayPreviewStyle {false}
 
QPainterPath m_cursorOutline
 
KisPaintDeviceSP m_externalSourceForNextActivation
 
bool m_forceLodMode {false}
 
QScopedPointer< KisFreeTransformStrategym_freeStrategy
 
QScopedPointer< KisLiquifyTransformStrategym_liquifyStrategy
 
QScopedPointer< KisMeshTransformStrategym_meshStrategy
 
KisToolTransformConfigWidgetm_optionsWidget {0}
 
QScopedPointer< KisPerspectiveTransformStrategym_perspectiveStrategy
 
bool m_preferOverlayPreviewStyle {false}
 
QRectF m_refRect
 
KisPaintDeviceSP m_selectedPortionCache
 
QPainterPath m_selectionPath
 
KisStrokeId m_strokeId
 
voidm_strokeStrategyCookie {0}
 
TransformTransactionProperties m_transaction
 
QScopedPointer< KisWarpTransformStrategym_warpStrategy
 
KisActionmeshAction {0}
 
KisActionmirrorHorizontalAction {0}
 
KisActionmirrorVerticalAction {0}
 
KisActionperspectiveAction {0}
 
KisActionresetTransformation {0}
 
KisActionrotateNinetyCCWAction {0}
 
KisActionrotateNinetyCWAction {0}
 
KisActionwarpAction {0}
 actions for the context click menu
 

Additional Inherited Members

- Static Public Member Functions inherited from KisTool
static AlternateAction actionToAlternateAction (ToolAction action)
 
- Public Attributes inherited from KisTool
KoColor currentBgColor
 
float currentExposure {1.0}
 
KoColor currentFgColor
 
KisFilterConfigurationSP currentGenerator
 
KoAbstractGradientSP currentGradient
 
KoPatternSP currentPattern
 
QCursor cursor
 
bool m_isActive {false}
 
ToolMode m_mode {HOVER_MODE}
 
QWidget * optionWidget {0}
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Protected Types inherited from KisTool
enum  ToolMode : int {
  HOVER_MODE , PAINT_MODE , SECONDARY_PAINT_MODE , MIRROR_AXIS_SETUP_MODE ,
  GESTURE_MODE , PAN_MODE , OTHER , OTHER_1
}
 
- Protected Member Functions inherited from KisTool
bool blockUntilOperationsFinished ()
 
void blockUntilOperationsFinishedForced ()
 
QPointF convertDocumentToWidget (const QPointF &pt)
 
QPoint convertToImagePixelCoordFloored (KoPointerEvent *e)
 
QPointF convertToPixelCoord (const QPointF &pt)
 
QPointF convertToPixelCoord (KoPointerEvent *e)
 
QPointF convertToPixelCoordAndAlignOnWidget (const QPointF &pt)
 
QPointF convertToPixelCoordAndSnap (const QPointF &pt, const QPointF &offset=QPointF())
 
QPointF convertToPixelCoordAndSnap (KoPointerEvent *e, const QPointF &offset=QPointF(), bool useModifiers=true)
 
QRectF convertToPt (const QRectF &rect)
 
qreal convertToPt (qreal value)
 
KoColor currentBgColor ()
 
KoColor currentFgColor ()
 
KisFilterConfigurationSP currentGenerator ()
 
KoAbstractGradientSP currentGradient ()
 
KisImageWSP currentImage ()
 
KisNodeSP currentNode () const
 
KisPaintOpPresetSP currentPaintOpPreset ()
 
KoPatternSP currentPattern ()
 
QCursor cursor () const
 
KisImageWSP image () const
 
virtual bool listeningToModifiers ()
 
virtual void listenToModifiers (bool listen)
 
virtual ToolMode mode () const
 
bool nodeEditable ()
 Checks checks if the current node is editable.
 
bool overrideCursorIfNotEditable ()
 Override the cursor appropriately if current node is not editable.
 
void paintToolOutline (QPainter *painter, const KisOptimizedBrushOutline &path)
 
KisOptimizedBrushOutline pixelToView (const KisOptimizedBrushOutline &path) const
 
QPainterPath pixelToView (const QPainterPath &pixelPath) const
 Convert a pixel path into a view path.
 
QPointF pixelToView (const QPoint &pixelCoord) const
 
QPointF pixelToView (const QPointF &pixelCoord) const
 Convert a floating point pixel coordinate into a view coordinate.
 
QPolygonF pixelToView (const QPolygonF &pixelPolygon) const
 Convert a pixel polygon into a view path.
 
QRectF pixelToView (const QRectF &pixelRect) const
 Convert a pixel rectangle into a view rectangle.
 
KisNodeList selectedNodes () const
 
bool selectionEditable ()
 Checks checks if the selection is editable, only applies to local selection as global selection is always editable.
 
void setCursor (const QCursor &cursor)
 
virtual void setMode (ToolMode mode)
 
void updateCanvasPixelRect (const QRectF &pixelRect)
 Update the canvas for the given rectangle in image pixel coordinates.
 
void updateCanvasViewRect (const QRectF &viewRect)
 Update the canvas for the given rectangle in view coordinates.
 
QPointF viewToPixel (const QPointF &viewCoord) const
 
QPointF widgetCenterInWidgetPixels ()
 
- Protected Member Functions inherited from KoToolBase
virtual QList< QPointer< QWidget > > createOptionWidgets ()
 
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 inherited from KoToolBase
KoToolBasePrivated_ptr
 

Detailed Description

Transform tool This tool offers several modes.

  • Free Transform mode allows the user to translate, scale, shear, rotate and apply a perspective transformation to a selection or the whole canvas.
  • Warp mode allows the user to warp the selection of the canvas by grabbing and moving control points placed on the image. The user can either work with default control points, like a grid whose density can be modified, or place the control points manually. The modifications made on the selected pixels are applied only when the user clicks the Apply button : the semi-transparent image displayed until the user click that button is only a preview.
  • Cage transform is similar to warp transform with control points exactly placed on the outer boundary. The user draws a boundary polygon, the vertices of which become control points.
  • Perspective transform applies a two-point perspective transformation. The user can manipulate the corners of the selection. If the vanishing points of the resulting quadrilateral are on screen, the user can manipulate those as well.
  • Liquify transform transforms the selection by painting motions, as if the user was finger painting.

Definition at line 78 of file kis_tool_transform.h.

Member Enumeration Documentation

◆ TransformToolMode

Enumerator
FreeTransformMode 
WarpTransformMode 
CageTransformMode 
LiquifyTransformMode 
PerspectiveTransformMode 
MeshTransformMode 

Definition at line 105 of file kis_tool_transform.h.

◆ WarpType

Enumerator
RigidWarpType 
AffineWarpType 
SimilitudeWarpType 

Definition at line 115 of file kis_tool_transform.h.

Constructor & Destructor Documentation

◆ KisToolTransform()

KisToolTransform::KisToolTransform ( KoCanvasBase * canvas)

Definition at line 83 of file kis_tool_transform.cc.

87 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
88 dynamic_cast<KisCanvas2*>(canvas)->snapGuide(),
92 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
93 dynamic_cast<KisCanvas2*>(canvas)->snapGuide(),
97 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
101 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
102 dynamic_cast<KisCanvas2*>(canvas)->snapGuide(),
106 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
107 dynamic_cast<KisCanvas2*>(canvas)->snapGuide(),
111 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
112 dynamic_cast<KisCanvas2*>(canvas)->snapGuide(),
114{
115 m_canvas = dynamic_cast<KisCanvas2*>(canvas);
116 Q_ASSERT(m_canvas);
117
118 setObjectName("tool_transform");
119 m_optionsWidget = 0;
120
121 warpAction = new KisAction(i18nc("Warp Transform Tab Label", "Warp"));
122 liquifyAction = new KisAction(i18nc("Liquify Transform Tab Label", "Liquify"));
123 meshAction = new KisAction(i18nc("Mesh Transform Tab Label", "Mesh"));
124 cageAction = new KisAction(i18nc("Cage Transform Tab Label", "Cage"));
125 freeTransformAction = new KisAction(i18nc("Free Transform Tab Label", "Free"));
126 perspectiveAction = new KisAction(i18nc("Perspective Transform Tab Label", "Perspective"));
127
128 // extra actions for free transform that are in the tool options
129 mirrorHorizontalAction = new KisAction(i18n("Mirror Horizontal"));
130 mirrorVerticalAction = new KisAction(i18n("Mirror Vertical"));
131 rotateNinetyCWAction = new KisAction(i18n("Rotate 90 degrees Clockwise"));
132 rotateNinetyCCWAction = new KisAction(i18n("Rotate 90 degrees CounterClockwise"));
133
134 keepAspectRatioAction = new KisAction(i18n("Keep Aspect Ratio"));
135 keepAspectRatioAction->setCheckable(true);
136 keepAspectRatioAction->setChecked(false);
137
138 applyTransformation = new KisAction(i18n("Apply"));
139 resetTransformation = new KisAction(i18n("Reset"));
140
141 m_contextMenu.reset(new QMenu());
142
143 connect(m_warpStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
145 connect(m_cageStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
147 connect(m_liquifyStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
148 connect(m_liquifyStrategy.data(), SIGNAL(requestCursorOutlineUpdate(QPointF)), SLOT(cursorOutlineUpdateRequested(QPointF)));
149 connect(m_liquifyStrategy.data(), SIGNAL(requestUpdateOptionWidget()), SLOT(updateOptionWidget()));
151 connect(m_freeStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
152 connect(m_freeStrategy.data(), SIGNAL(requestResetRotationCenterButtons()), SLOT(resetRotationCenterButtonsRequested()));
153 connect(m_freeStrategy.data(), SIGNAL(requestShowImageTooBig(bool)), SLOT(imageTooBigRequested(bool)));
155 connect(m_freeStrategy.data(), SIGNAL(requestConvexHullCalculation()), SLOT(convexHullCalculationRequested()));
156 connect(m_perspectiveStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
157 connect(m_perspectiveStrategy.data(), SIGNAL(requestShowImageTooBig(bool)), SLOT(imageTooBigRequested(bool)));
159 connect(m_meshStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
161
162 connect(&m_changesTracker, SIGNAL(sigConfigChanged(KisToolChangesTrackerDataSP)),
164
165 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(slotGlobalConfigChanged()));
166}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static KisConfigNotifier * instance()
static QCursor rotateCursor()
KisAction * perspectiveAction
KisAction * resetTransformation
KisAction * applyTransformation
KisToolTransformConfigWidget * m_optionsWidget
KisToolChangesTracker m_changesTracker
KisAction * keepAspectRatioAction
QScopedPointer< KisMeshTransformStrategy > m_meshStrategy
void slotTrackerChangedConfig(KisToolChangesTrackerDataSP status)
QScopedPointer< KisFreeTransformStrategy > m_freeStrategy
void cursorOutlineUpdateRequested(const QPointF &imagePos)
void imageTooBigRequested(bool value)
ToolTransformArgs m_currentArgs
QPointer< KisCanvas2 > m_canvas
QScopedPointer< KisCageTransformStrategy > m_cageStrategy
QScopedPointer< QMenu > m_contextMenu
KisAction * mirrorVerticalAction
QScopedPointer< KisPerspectiveTransformStrategy > m_perspectiveStrategy
KisAction * mirrorHorizontalAction
KisAction * rotateNinetyCWAction
TransformTransactionProperties m_transaction
KisAction * warpAction
actions for the context click menu
void resetRotationCenterButtonsRequested()
KisAction * freeTransformAction
KisAction * rotateNinetyCCWAction
QScopedPointer< KisWarpTransformStrategy > m_warpStrategy
QScopedPointer< KisLiquifyTransformStrategy > m_liquifyStrategy
QPointer< KoCanvasResourceProvider > resourceManager
KisTool(KoCanvasBase *canvas, const QCursor &cursor)
Definition kis_tool.cc:78
KisCanvas2 * canvas

References applyTransformation, cageAction, Private::canvas, canvasUpdateRequested(), connect(), convexHullCalculationRequested(), cursorOutlineUpdateRequested(), freeTransformAction, imageTooBigRequested(), KisConfigNotifier::instance(), keepAspectRatioAction, liquifyAction, m_cageStrategy, m_canvas, m_changesTracker, m_contextMenu, m_freeStrategy, m_liquifyStrategy, m_meshStrategy, m_optionsWidget, m_perspectiveStrategy, m_warpStrategy, meshAction, mirrorHorizontalAction, mirrorVerticalAction, perspectiveAction, requestImageRecalculation(), resetRotationCenterButtonsRequested(), resetTransformation, rotateNinetyCCWAction, rotateNinetyCWAction, slotGlobalConfigChanged(), slotTrackerChangedConfig(), updateOptionWidget(), and warpAction.

◆ ~KisToolTransform()

Member Function Documentation

◆ activate

void KisToolTransform::activate ( const QSet< KoShape * > & shapes)
overrideslot

we cannot initialize the setting in the constructor, because factory() is not yet initialized, so we cannot get toolId()

Definition at line 804 of file kis_tool_transform.cc.

805{
806 KisTool::activate(shapes);
807
811
812 m_actionConnections.addConnection(action("movetool-move-up"), SIGNAL(triggered(bool)),
813 this, SLOT(slotMoveDiscreteUp()));
814 m_actionConnections.addConnection(action("movetool-move-up-more"), SIGNAL(triggered(bool)),
815 this, SLOT(slotMoveDiscreteUpMore()));
816 m_actionConnections.addConnection(action("movetool-move-down"), SIGNAL(triggered(bool)),
817 this, SLOT(slotMoveDiscreteDown()));
818 m_actionConnections.addConnection(action("movetool-move-down-more"), SIGNAL(triggered(bool)),
819 this, SLOT(slotMoveDiscreteDownMore()));
820 m_actionConnections.addConnection(action("movetool-move-left"), SIGNAL(triggered(bool)),
821 this, SLOT(slotMoveDiscreteLeft()));
822 m_actionConnections.addConnection(action("movetool-move-left-more"), SIGNAL(triggered(bool)),
823 this, SLOT(slotMoveDiscreteLeftMore()));
824 m_actionConnections.addConnection(action("movetool-move-right"), SIGNAL(triggered(bool)),
825 this, SLOT(slotMoveDiscreteRight()));
826 m_actionConnections.addConnection(action("movetool-move-right-more"), SIGNAL(triggered(bool)),
827 this, SLOT(slotMoveDiscreteRightMore()));
828
829 if (currentNode()) {
831 }
832
834}
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
void startStroke(ToolTransformArgs::TransformMode mode, bool forceReset)
KisSignalAutoConnectionsStore m_actionConnections
QAction * action(const QString &name) const
QList< KisNodeSP > KisNodeList
Definition kis_types.h:264
KisNodeSP currentNode() const
Definition kis_tool.cc:370
void activate(const QSet< KoShape * > &shapes) override
Definition kis_tool.cc:93

References KoToolBase::action(), KisTool::activate(), KisSignalAutoConnectionsStore::addConnection(), KisTool::currentNode(), ToolTransformArgs::FREE_TRANSFORM, m_actionConnections, m_currentArgs, m_transaction, slotGlobalConfigChanged(), slotMoveDiscreteDown(), slotMoveDiscreteDownMore(), slotMoveDiscreteLeft(), slotMoveDiscreteLeftMore(), slotMoveDiscreteRight(), slotMoveDiscreteRightMore(), slotMoveDiscreteUp(), slotMoveDiscreteUpMore(), and startStroke().

◆ activateAlternateAction()

void KisToolTransform::activateAlternateAction ( AlternateAction action)
overridevirtual

Reimplemented from KisTool.

Definition at line 480 of file kis_tool_transform.cc.

481{
484}
KisTransformStrategyBase * currentStrategy() const
virtual void activateAlternateAction(KisTool::AlternateAction action)

References KoToolBase::action(), KisTransformStrategyBase::activateAlternateAction(), currentStrategy(), and setFunctionalCursor().

◆ activatePrimaryAction()

void KisToolTransform::activatePrimaryAction ( )
overridevirtual

Called by KisToolProxy when the primary action of the tool is going to be started now, that is when all the modifiers are pressed and the only thing left is just to press the mouse button. On coming of this callback the tool is supposed to prepare the cursor and/or the outline to show the user shat is going to happen next

Reimplemented from KisTool.

Definition at line 469 of file kis_tool_transform.cc.

References KisTransformStrategyBase::activatePrimaryAction(), currentStrategy(), and setFunctionalCursor().

◆ applyTransform

void KisToolTransform::applyTransform ( )
slot

Definition at line 538 of file kis_tool_transform.cc.

539{
541}

References slotApplyTransform().

◆ beginActionImpl()

void KisToolTransform::beginActionImpl ( KoPointerEvent * event,
bool usePrimaryAction,
KisTool::AlternateAction action )

Definition at line 346 of file kis_tool_transform.cc.

347{
348 if (!nodeEditable()) {
349 event->ignore();
350 return;
351 }
352
353 if (!m_strokeId) {
355 } else if (!m_transaction.rootNodes().isEmpty()) {
356 bool result = false;
357
358 if (usePrimaryAction) {
359 result = currentStrategy()->beginPrimaryAction(event);
360 } else {
361 result = currentStrategy()->beginAlternateAction(event, action);
362 }
363
364 if (result) {
366 }
367 }
368
370
372}
virtual bool beginAlternateAction(KoPointerEvent *event, KisTool::AlternateAction action)
virtual bool beginPrimaryAction(KoPointerEvent *event)=0
TransformMode mode() const
bool nodeEditable()
Checks checks if the current node is editable.
Definition kis_tool.cc:651
@ PAINT_MODE
Definition kis_tool.h:300
@ ChangeSize
Definition kis_tool.h:135
virtual void setMode(ToolMode mode)
Definition kis_tool.cc:403

References KoToolBase::action(), KisTransformStrategyBase::beginAlternateAction(), KisTransformStrategyBase::beginPrimaryAction(), KisTool::ChangeSize, currentStrategy(), m_actuallyMoveWhileSelected, m_currentArgs, m_strokeId, m_transaction, ToolTransformArgs::mode(), KisTool::nodeEditable(), outlineChanged(), KisTool::PAINT_MODE, TransformTransactionProperties::rootNodes(), KisTool::setMode(), and startStroke().

◆ beginAlternateAction()

void KisToolTransform::beginAlternateAction ( KoPointerEvent * event,
AlternateAction action )
overridevirtual

Reimplemented from KisTool.

Definition at line 491 of file kis_tool_transform.cc.

492{
493 beginActionImpl(event, false, action);
494}
void beginActionImpl(KoPointerEvent *event, bool usePrimaryAction, KisTool::AlternateAction action)

References KoToolBase::action(), and beginActionImpl().

◆ beginPrimaryAction()

void KisToolTransform::beginPrimaryAction ( KoPointerEvent * event)
overridevirtual

Called by KisToolProxy when a primary action for the tool is started. The event stores the original event that started the stroke. The event is accepted by default. If the tool decides to ignore this particular action (e.g. when the node is not editable), it should call event->ignore(). Then no further continuePrimaryAction() or endPrimaryAction() will be called until the next user action.

Reimplemented from KisTool.

Definition at line 454 of file kis_tool_transform.cc.

455{
456 beginActionImpl(event, true, KisTool::NONE);
457}

References beginActionImpl(), and KisTool::NONE.

◆ cancelStroke()

void KisToolTransform::cancelStroke ( )
private

◆ canvasUpdateRequested

void KisToolTransform::canvasUpdateRequested ( )
slot

Definition at line 193 of file kis_tool_transform.cc.

194{
195 m_canvas->updateCanvas();
196}

References m_canvas.

◆ commitChanges()

void KisToolTransform::commitChanges ( )
private

Definition at line 1113 of file kis_tool_transform.cc.

1114{
1115 if (!m_strokeId || m_transaction.rootNodes().isEmpty()) return;
1116
1118}
void commitConfig(KisToolChangesTrackerDataSP state)
KisToolChangesTrackerData * clone() const override
QSharedPointer< T > toQShared(T *ptr)

References ToolTransformArgs::clone(), KisToolChangesTracker::commitConfig(), m_changesTracker, m_currentArgs, m_strokeId, m_transaction, TransformTransactionProperties::rootNodes(), and toQShared().

◆ continueActionImpl()

void KisToolTransform::continueActionImpl ( KoPointerEvent * event,
bool usePrimaryAction,
KisTool::AlternateAction action )

Definition at line 374 of file kis_tool_transform.cc.

375{
376 if (mode() != KisTool::PAINT_MODE) return;
377 if (m_transaction.rootNodes().isEmpty()) return;
378
380
381 if (usePrimaryAction) {
383 } else {
385 }
386
389}
virtual void continuePrimaryAction(KoPointerEvent *event)=0
virtual void continueAlternateAction(KoPointerEvent *event, KisTool::AlternateAction action)
virtual ToolMode mode() const
Definition kis_tool.cc:407

References KoToolBase::action(), KisTransformStrategyBase::continueAlternateAction(), KisTransformStrategyBase::continuePrimaryAction(), currentStrategy(), m_actuallyMoveWhileSelected, m_transaction, KisTool::mode(), outlineChanged(), KisTool::PAINT_MODE, TransformTransactionProperties::rootNodes(), and updateOptionWidget().

◆ continueAlternateAction()

void KisToolTransform::continueAlternateAction ( KoPointerEvent * event,
AlternateAction action )
overridevirtual

Reimplemented from KisTool.

Definition at line 496 of file kis_tool_transform.cc.

497{
498 continueActionImpl(event, false, action);
499}
void continueActionImpl(KoPointerEvent *event, bool usePrimaryAction, KisTool::AlternateAction action)

References KoToolBase::action(), and continueActionImpl().

◆ continuePrimaryAction()

void KisToolTransform::continuePrimaryAction ( KoPointerEvent * event)
overridevirtual

Called by KisToolProxy when the primary action is in progress of pointer movement. If the tool has ignored the event in beginPrimaryAction(), this method will not be called.

Reimplemented from KisTool.

Definition at line 459 of file kis_tool_transform.cc.

460{
461 continueActionImpl(event, true, KisTool::NONE);
462}

References continueActionImpl(), and KisTool::NONE.

◆ convexHullCalculationRequested

void KisToolTransform::convexHullCalculationRequested ( )
slot

Free transform strategy issues the recalculation request every time the user performs a bounds rotation action, so we should skip actual recalculation, when it is not necessary anymore

Definition at line 222 of file kis_tool_transform.cc.

References KisImage::addJob(), TransformTransactionProperties::convexHullHasBeenRequested(), KisTool::image(), m_currentlyUsingOverlayPreviewStyle, m_strokeId, m_transaction, TransformTransactionProperties::rootNodes(), and TransformTransactionProperties::setConvexHullHasBeenRequested().

◆ createOptionWidget()

QWidget * KisToolTransform::createOptionWidget ( )
overridevirtual

Reimplement this if your tool actually has an option widget. Sets the option widget to 0 by default.

Reimplemented from KisTool.

Definition at line 1131 of file kis_tool_transform.cc.

1132{
1133 if (!m_canvas) return 0;
1134
1136 Q_CHECK_PTR(m_optionsWidget);
1137 m_optionsWidget->setObjectName(toolId() + " option widget");
1138
1139 // See https://bugs.kde.org/show_bug.cgi?id=316896
1140 QWidget *specialSpacer = new QWidget(m_optionsWidget);
1141 specialSpacer->setObjectName("SpecialSpacer");
1142 specialSpacer->setFixedSize(0, 0);
1143 m_optionsWidget->layout()->addWidget(specialSpacer);
1144
1145
1146 connect(m_optionsWidget, SIGNAL(sigConfigChanged(bool)),
1147 this, SLOT(slotUiChangedConfig(bool)));
1148
1149 connect(m_optionsWidget, SIGNAL(sigApplyTransform()),
1150 this, SLOT(slotApplyTransform()));
1151
1152 connect(m_optionsWidget, SIGNAL(sigResetTransform(ToolTransformArgs::TransformMode)),
1154
1155 connect(m_optionsWidget, SIGNAL(sigCancelTransform()),
1156 this, SLOT(slotCancelTransform()));
1157
1158 connect(m_optionsWidget, SIGNAL(sigRestartTransform()),
1159 this, SLOT(slotRestartTransform()));
1160
1161 connect(m_optionsWidget, SIGNAL(sigUpdateGlobalConfig()),
1162 this, SLOT(slotGlobalConfigChanged()));
1163
1164 connect(m_optionsWidget, SIGNAL(sigRestartAndContinueTransform()),
1165 this, SLOT(slotRestartAndContinueTransform()));
1166
1167 connect(m_optionsWidget, SIGNAL(sigEditingFinished()),
1168 this, SLOT(slotEditingFinished()));
1169
1170
1171 connect(mirrorHorizontalAction, SIGNAL(triggered(bool)), m_optionsWidget, SLOT(slotFlipX()));
1172 connect(mirrorVerticalAction, SIGNAL(triggered(bool)), m_optionsWidget, SLOT(slotFlipY()));
1173 connect(rotateNinetyCWAction, SIGNAL(triggered(bool)), m_optionsWidget, SLOT(slotRotateCW()));
1174 connect(rotateNinetyCCWAction, SIGNAL(triggered(bool)), m_optionsWidget, SLOT(slotRotateCCW()));
1175
1176 connect(keepAspectRatioAction, SIGNAL(triggered(bool)), m_optionsWidget, SLOT(slotSetKeepAspectRatio(bool)));
1177
1178
1179 connect(warpAction, SIGNAL(triggered(bool)), this, SLOT(slotUpdateToWarpType()));
1180 connect(perspectiveAction, SIGNAL(triggered(bool)), this, SLOT(slotUpdateToPerspectiveType()));
1181 connect(freeTransformAction, SIGNAL(triggered(bool)), this, SLOT(slotUpdateToFreeTransformType()));
1182 connect(liquifyAction, SIGNAL(triggered(bool)), this, SLOT(slotUpdateToLiquifyType()));
1183 connect(meshAction, SIGNAL(triggered(bool)), this, SLOT(slotUpdateToMeshType()));
1184 connect(cageAction, SIGNAL(triggered(bool)), this, SLOT(slotUpdateToCageType()));
1185
1186 connect(applyTransformation, SIGNAL(triggered(bool)), this, SLOT(slotApplyTransform()));
1187 connect(resetTransformation, SIGNAL(triggered(bool)), this, SLOT(slotCancelTransform()));
1188
1189
1191
1192 return m_optionsWidget;
1193}
void slotUiChangedConfig(bool needsPreviewRecalculation)
void slotResetTransform(ToolTransformArgs::TransformMode mode)
Q_INVOKABLE QString toolId() const

References applyTransformation, cageAction, connect(), freeTransformAction, keepAspectRatioAction, liquifyAction, m_canvas, m_optionsWidget, m_transaction, meshAction, mirrorHorizontalAction, mirrorVerticalAction, perspectiveAction, resetTransformation, rotateNinetyCCWAction, rotateNinetyCWAction, slotApplyTransform(), slotCancelTransform(), slotEditingFinished(), slotGlobalConfigChanged(), slotResetTransform(), slotRestartAndContinueTransform(), slotRestartTransform(), slotUiChangedConfig(), slotUpdateToCageType(), slotUpdateToFreeTransformType(), slotUpdateToLiquifyType(), slotUpdateToMeshType(), slotUpdateToPerspectiveType(), slotUpdateToWarpType(), KoToolBase::toolId(), updateOptionWidget(), and warpAction.

◆ currentStrategy()

KisTransformStrategyBase * KisToolTransform::currentStrategy ( ) const
private

◆ cursorOutlineUpdateRequested

void KisToolTransform::cursorOutlineUpdateRequested ( const QPointF & imagePos)
slot

Definition at line 321 of file kis_tool_transform.cc.

322{
323 QRect canvasUpdateRect;
324
325 if (!m_cursorOutline.isEmpty()) {
326 canvasUpdateRect = m_canvas->coordinatesConverter()->
327 imageToDocument(m_cursorOutline.boundingRect()).toAlignedRect();
328 }
329
331 getCursorOutline().translated(imagePos);
332
333 if (!m_cursorOutline.isEmpty()) {
334 canvasUpdateRect |=
335 m_canvas->coordinatesConverter()->
336 imageToDocument(m_cursorOutline.boundingRect()).toAlignedRect();
337 }
338
339 if (!canvasUpdateRect.isEmpty()) {
340 // grow rect a bit to follow interpolation fuzziness
341 canvasUpdateRect = kisGrowRect(canvasUpdateRect, 2);
342 m_canvas->updateCanvas(canvasUpdateRect);
343 }
344}
QPainterPath m_cursorOutline
T kisGrowRect(const T &rect, U offset)
Definition kis_global.h:186

References currentStrategy(), kisGrowRect(), m_canvas, and m_cursorOutline.

◆ deactivate

void KisToolTransform::deactivate ( )
overrideslot

◆ deactivateAlternateAction()

void KisToolTransform::deactivateAlternateAction ( AlternateAction action)
overridevirtual

Reimplemented from KisTool.

Definition at line 486 of file kis_tool_transform.cc.

487{
489}
virtual void deactivateAlternateAction(KisTool::AlternateAction action)

References KoToolBase::action(), currentStrategy(), and KisTransformStrategyBase::deactivateAlternateAction().

◆ deactivatePrimaryAction()

void KisToolTransform::deactivatePrimaryAction ( )
overridevirtual

Called by KisToolProxy when the primary is no longer possible to be started now, e.g. when its modifiers and released. The tool is supposed to revert all the preparations it has done in activatePrimaryAction().

Reimplemented from KisTool.

Definition at line 475 of file kis_tool_transform.cc.

References currentStrategy(), and KisTransformStrategyBase::deactivatePrimaryAction().

◆ endActionImpl()

void KisToolTransform::endActionImpl ( KoPointerEvent * event,
bool usePrimaryAction,
KisTool::AlternateAction action )

Definition at line 391 of file kis_tool_transform.cc.

392{
393 if (mode() != KisTool::PAINT_MODE) return;
394
396
398 currentStrategy()->acceptsClicks()) {
399
400 bool result = false;
401
402 if (usePrimaryAction) {
403 result = currentStrategy()->endPrimaryAction(event);
404 } else {
405 result = currentStrategy()->endAlternateAction(event, action);
406 }
407
408 if (result) {
410 }
411
413 }
414
417}
virtual bool endPrimaryAction(KoPointerEvent *event)=0
virtual bool endAlternateAction(KoPointerEvent *event, KisTool::AlternateAction action)
@ HOVER_MODE
Definition kis_tool.h:299

References KoToolBase::action(), commitChanges(), currentStrategy(), KisTransformStrategyBase::endAlternateAction(), KisTransformStrategyBase::endPrimaryAction(), KisTool::HOVER_MODE, m_actuallyMoveWhileSelected, KisTool::mode(), outlineChanged(), KisTool::PAINT_MODE, KisTool::setMode(), updateApplyResetAvailability(), and updateOptionWidget().

◆ endAlternateAction()

void KisToolTransform::endAlternateAction ( KoPointerEvent * event,
AlternateAction action )
overridevirtual

Reimplemented from KisTool.

Definition at line 501 of file kis_tool_transform.cc.

502{
503 endActionImpl(event, false, action);
504}
void endActionImpl(KoPointerEvent *event, bool usePrimaryAction, KisTool::AlternateAction action)

References KoToolBase::action(), and endActionImpl().

◆ endPrimaryAction()

void KisToolTransform::endPrimaryAction ( KoPointerEvent * event)
overridevirtual

Called by KisToolProxy when the primary action is being finished, that is while mouseRelease or tabletRelease event. If the tool has ignored the event in beginPrimaryAction(), this method will not be called.

Reimplemented from KisTool.

Definition at line 464 of file kis_tool_transform.cc.

465{
466 endActionImpl(event, true, KisTool::NONE);
467}

References endActionImpl(), and KisTool::NONE.

◆ endStroke()

void KisToolTransform::endStroke ( )
private

Definition at line 1011 of file kis_tool_transform.cc.

References KisImage::addJob(), KisImage::endStroke(), KisAsynchronousStrokeUpdateHelper::endUpdateStream(), KisTool::image(), KisAsynchronousStrokeUpdateHelper::isActive(), ToolTransformArgs::isUnchanging(), m_asyncUpdateHelper, m_changesTracker, m_currentArgs, m_currentlyUsingOverlayPreviewStyle, m_strokeId, m_strokeStrategyCookie, m_transaction, outlineChanged(), KisToolChangesTracker::reset(), and TransformTransactionProperties::rootNodes().

◆ freeTransformChanged

void KisToolTransform::freeTransformChanged ( )
signal

◆ imageTooBigRequested

void KisToolTransform::imageTooBigRequested ( bool value)
slot

Definition at line 216 of file kis_tool_transform.cc.

217{
218 if (!m_optionsWidget) return;
220}
float value(const T *src, size_t ch)

References m_optionsWidget, KisToolTransformConfigWidget::setTooBigLabelVisible(), and value().

◆ initGuiAfterTransformMode()

◆ initThumbnailImage()

void KisToolTransform::initThumbnailImage ( KisPaintDeviceSP previewDevice)
private

Definition at line 746 of file kis_tool_transform.cc.

747{
748 QImage origImg;
749 m_selectedPortionCache = previewDevice;
750
751 QTransform thumbToImageTransform;
752
753 const int maxSize = 2000;
754
755 QRect srcRect(m_transaction.originalRect().toAlignedRect());
756 int x, y, w, h;
757 srcRect.getRect(&x, &y, &w, &h);
758
760 if (w > maxSize || h > maxSize) {
761 qreal scale = qreal(maxSize) / (w > h ? w : h);
762 QTransform scaleTransform = QTransform::fromScale(scale, scale);
763
764 QRect thumbRect = scaleTransform.mapRect(m_transaction.originalRect()).toAlignedRect();
765
766 origImg = m_selectedPortionCache->
767 createThumbnail(thumbRect.width(),
768 thumbRect.height(),
769 srcRect, 1,
772 thumbToImageTransform = scaleTransform.inverted();
773
774 } else {
775 origImg = m_selectedPortionCache->convertToQImage(0, x, y, w, h,
778 thumbToImageTransform = QTransform();
779 }
780 }
781
782 // init both strokes since the thumbnail is initialized only once
783 // during the stroke
784 m_freeStrategy->setThumbnailImage(origImg, thumbToImageTransform);
785 m_perspectiveStrategy->setThumbnailImage(origImg, thumbToImageTransform);
786 m_warpStrategy->setThumbnailImage(origImg, thumbToImageTransform);
787 m_cageStrategy->setThumbnailImage(origImg, thumbToImageTransform);
788 m_liquifyStrategy->setThumbnailImage(origImg, thumbToImageTransform);
789 m_meshStrategy->setThumbnailImage(origImg, thumbToImageTransform);
790}
QImage convertToQImage(const KoColorProfile *dstProfile, qint32 x, qint32 y, qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags()) const
KisPaintDeviceSP m_selectedPortionCache

References KisPaintDevice::convertToQImage(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), m_cageStrategy, m_freeStrategy, m_liquifyStrategy, m_meshStrategy, m_perspectiveStrategy, m_selectedPortionCache, m_transaction, m_warpStrategy, and TransformTransactionProperties::originalRect().

◆ initTransformMode()

void KisToolTransform::initTransformMode ( ToolTransformArgs::TransformMode mode)
private

Definition at line 731 of file kis_tool_transform.cc.

732{
735}
static ToolTransformArgs resetArgsForMode(ToolTransformArgs::TransformMode mode, const QString &filterId, const TransformTransactionProperties &transaction, KisPaintDeviceSP externalSource)
QString filterId() const
KisPaintDeviceSP externalSource() const

References ToolTransformArgs::externalSource(), ToolTransformArgs::filterId(), initGuiAfterTransformMode(), m_currentArgs, m_transaction, KisTool::mode(), and KisTransformUtils::resetArgsForMode().

◆ mouseMoveEvent()

void KisToolTransform::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

Reimplemented from KisTool.

Definition at line 519 of file kis_tool_transform.cc.

520{
521 QPointF mousePos = m_canvas->coordinatesConverter()->documentToImage(event->point);
522
524
525 if (this->mode() != KisTool::PAINT_MODE) {
529 return;
530 }
531}
virtual void hoverActionCommon(KoPointerEvent *event)=0
QPointF point
The point in document coordinates.
void mouseMoveEvent(KoPointerEvent *event) override
Definition kis_tool.cc:520

References currentStrategy(), cursorOutlineUpdateRequested(), KisTransformStrategyBase::hoverActionCommon(), m_canvas, KisTool::mode(), KisTool::mouseMoveEvent(), KisTool::PAINT_MODE, KoPointerEvent::point, and setFunctionalCursor().

◆ mousePressEvent()

void KisToolTransform::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

Reimplemented from KisTool.

Definition at line 506 of file kis_tool_transform.cc.

507{
508 // When using touch drawing, we only ever receive move events after the
509 // finger has pressed down. This confuses the strategies greatly, since they
510 // expect to receive a hover to tell which anchor the user wants to
511 // manipulate or similar. So in this case, we send an artificial hover.
512 if (event->isTouchEvent() && this->mode() != KisTool::PAINT_MODE) {
515 }
517}
bool isTouchEvent() const
void mousePressEvent(KoPointerEvent *event) override
Definition kis_tool.cc:510

References currentStrategy(), KisTransformStrategyBase::hoverActionCommon(), KoPointerEvent::isTouchEvent(), KisTool::mousePressEvent(), KisTool::PAINT_MODE, and setFunctionalCursor().

◆ mouseReleaseEvent()

void KisToolTransform::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

Reimplemented from KisTool.

Definition at line 533 of file kis_tool_transform.cc.

534{
536}
void mouseReleaseEvent(KoPointerEvent *event) override
Definition kis_tool.cc:515

References KisTool::mouseReleaseEvent().

◆ newActivationWithExternalSource()

void KisToolTransform::newActivationWithExternalSource ( KisPaintDeviceSP externalSource)
overridevirtual

newActivationWithExternalSource Makes sure that the tool is active and starts a new stroke, which will be able to access the pixels from the specified external source.

This is currently implemented by the Transform tool to paste an image into the current layer and transform it.

Reimplemented from KisTool.

Definition at line 792 of file kis_tool_transform.cc.

793{
794 m_externalSourceForNextActivation = externalSource;
795 if (isActive()) {
796 QSet<KoShape*> dummy;
797 deactivate();
798 activate(dummy);
799 } else {
800 KoToolManager::instance()->switchToolRequested("KisToolTransform");
801 }
802}
void deactivate() override
KisPaintDeviceSP m_externalSourceForNextActivation
void activate(const QSet< KoShape * > &shapes) override
void switchToolRequested(const QString &id)
static KoToolManager * instance()
Return the toolmanager singleton.
bool isActive
Definition kis_tool.h:44

References activate(), deactivate(), KoToolManager::instance(), KisTool::isActive, m_externalSourceForNextActivation, and KoToolManager::switchToolRequested().

◆ outlineChanged()

void KisToolTransform::outlineChanged ( )
private

Definition at line 187 of file kis_tool_transform.cc.

188{
189 Q_EMIT freeTransformChanged();
190 m_canvas->updateCanvas();
191}
void freeTransformChanged()

References freeTransformChanged(), and m_canvas.

◆ paint()

void KisToolTransform::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 282 of file kis_tool_transform.cc.

283{
284 Q_UNUSED(converter);
285
286 if (!m_strokeId || m_transaction.rootNodes().isEmpty()) return;
287
288 QRectF newRefRect = KisTransformUtils::imageToFlake(m_canvas->coordinatesConverter(), QRectF(0.0,0.0,1.0,1.0));
289 if (m_refRect != newRefRect) {
290 m_refRect = newRefRect;
292 }
294 currentStrategy()->paint(gc);
295
296
297 if (!m_cursorOutline.isEmpty()) {
298 QPainterPath mappedOutline =
300 m_canvas->coordinatesConverter()).map(m_cursorOutline);
301 paintToolOutline(&gc, mappedOutline);
302 }
303}
virtual void paint(QPainter &gc)=0
virtual void setDecorationThickness(int thickness)
static T imageToFlake(const KisCoordinatesConverter *converter, T object)
static QTransform imageToFlakeTransform(const KisCoordinatesConverter *converter)
int decorationThickness() const
decorationThickness The minimum thickness for tool decoration lines, this is derived from the screen ...
void paintToolOutline(QPainter *painter, const KisOptimizedBrushOutline &path)
Definition kis_tool.cc:589

References currentStrategy(), KoToolBase::decorationThickness(), KisTransformStrategyBase::externalConfigChanged(), KisTransformUtils::imageToFlake(), KisTransformUtils::imageToFlakeTransform(), m_canvas, m_cursorOutline, m_refRect, m_strokeId, m_transaction, KisTransformStrategyBase::paint(), KisTool::paintToolOutline(), TransformTransactionProperties::rootNodes(), and KisTransformStrategyBase::setDecorationThickness().

◆ popupActionsMenu()

QMenu * KisToolTransform::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 419 of file kis_tool_transform.cc.

420{
421 if (m_contextMenu) {
422 m_contextMenu->clear();
423
424 m_contextMenu->addSection(i18n("Transform Tool Actions"));
425 // add a quick switch to different transform types
428 m_contextMenu->addAction(warpAction);
429 m_contextMenu->addAction(cageAction);
430 m_contextMenu->addAction(liquifyAction);
431 m_contextMenu->addAction(meshAction);
432
433 // extra options if free transform is selected
435 m_contextMenu->addSeparator();
440
441 m_contextMenu->addSeparator();
444 }
445
446 m_contextMenu->addSeparator();
449 }
450
451 return m_contextMenu.data();
452}
TransformToolMode transformMode

References applyTransformation, cageAction, freeTransformAction, FreeTransformMode, ToolTransformArgs::keepAspectRatio(), keepAspectRatioAction, liquifyAction, m_contextMenu, m_currentArgs, meshAction, mirrorHorizontalAction, mirrorVerticalAction, perspectiveAction, resetTransformation, rotateNinetyCCWAction, rotateNinetyCWAction, transformMode, and warpAction.

◆ requestImageRecalculation

◆ requestRedoDuringStroke

void KisToolTransform::requestRedoDuringStroke ( )
overrideslot

◆ requestStrokeCancellation

void KisToolTransform::requestStrokeCancellation ( )
overrideslot

◆ requestStrokeEnd

void KisToolTransform::requestStrokeEnd ( )
overrideslot

Definition at line 864 of file kis_tool_transform.cc.

865{
866 endStroke();
867}

References endStroke().

◆ requestUndoDuringStroke

void KisToolTransform::requestUndoDuringStroke ( )
overrideslot

◆ resetCursorStyle

void KisToolTransform::resetCursorStyle ( )
overrideprotectedslot

Definition at line 198 of file kis_tool_transform.cc.

199{
201}

References setFunctionalCursor().

◆ resetRotationCenterButtonsRequested

void KisToolTransform::resetRotationCenterButtonsRequested ( )
slot

◆ rotateX()

double KisToolTransform::rotateX ( ) const

Definition at line 584 of file kis_tool_transform.cc.

585{
586 return m_currentArgs.aX();
587}

References ToolTransformArgs::aX(), and m_currentArgs.

◆ rotateY()

double KisToolTransform::rotateY ( ) const

Definition at line 589 of file kis_tool_transform.cc.

590{
591 return m_currentArgs.aY();
592}

References ToolTransformArgs::aY(), and m_currentArgs.

◆ rotateZ()

double KisToolTransform::rotateZ ( ) const

Definition at line 594 of file kis_tool_transform.cc.

595{
596 return m_currentArgs.aZ();
597}

References ToolTransformArgs::aZ(), and m_currentArgs.

◆ scaleX()

double KisToolTransform::scaleX ( ) const

Definition at line 599 of file kis_tool_transform.cc.

600{
601 return m_currentArgs.scaleX();
602}

References m_currentArgs, and ToolTransformArgs::scaleX().

◆ scaleY()

double KisToolTransform::scaleY ( ) const

Definition at line 604 of file kis_tool_transform.cc.

605{
606 return m_currentArgs.scaleY();
607}

References m_currentArgs, and ToolTransformArgs::scaleY().

◆ setFunctionalCursor()

void KisToolTransform::setFunctionalCursor ( )
private

Definition at line 305 of file kis_tool_transform.cc.

306{
308 return;
309 }
310
311 if (!m_strokeId) {
313 } else if (m_strokeId && m_transaction.rootNodes().isEmpty()) {
314 // we are in the middle of stroke initialization
316 } else {
317 useCursor(currentStrategy()->getCurrentCursor());
318 }
319}
static QCursor waitCursor()
Definition kis_cursor.cc:54
static QCursor pointingHandCursor()
void useCursor(const QCursor &cursor)
bool overrideCursorIfNotEditable()
Override the cursor appropriately if current node is not editable.
Definition kis_tool.cc:618

References currentStrategy(), m_strokeId, m_transaction, KisTool::overrideCursorIfNotEditable(), KisCursor::pointingHandCursor(), TransformTransactionProperties::rootNodes(), KoToolBase::useCursor(), and KisCursor::waitCursor().

◆ setRotateX

void KisToolTransform::setRotateX ( double rotation)
slot

Definition at line 689 of file kis_tool_transform.cc.

690{
691 m_currentArgs.setAX( rotation );
692}

References m_currentArgs, and ToolTransformArgs::setAX().

◆ setRotateY

void KisToolTransform::setRotateY ( double rotation)
slot

Definition at line 694 of file kis_tool_transform.cc.

695{
696 m_currentArgs.setAY( rotation );
697}

References m_currentArgs, and ToolTransformArgs::setAY().

◆ setRotateZ

void KisToolTransform::setRotateZ ( double rotation)
slot

Definition at line 699 of file kis_tool_transform.cc.

700{
701 m_currentArgs.setAZ( rotation );
702}

References m_currentArgs, and ToolTransformArgs::setAZ().

◆ setScaleX

void KisToolTransform::setScaleX ( double scaleX)
slot

◆ setScaleY

void KisToolTransform::setScaleY ( double scaleY)
slot

◆ setShearX

void KisToolTransform::setShearX ( double shearX)
slot

◆ setShearY

void KisToolTransform::setShearY ( double shearY)
slot

◆ setTransformFunction()

void KisToolTransform::setTransformFunction ( QPointF mousePos,
Qt::KeyboardModifiers modifiers )
private

◆ setTransformMode

void KisToolTransform::setTransformMode ( KisToolTransform::TransformToolMode newMode)
slot

Definition at line 643 of file kis_tool_transform.cc.

644{
646
647 switch (newMode) {
650 break;
653 break;
656 break;
659 break;
662 break;
665 break;
666 default:
667 KIS_ASSERT_RECOVER_NOOP(0 && "unexpected transform mode");
668 }
669
670 if( mode != m_currentArgs.mode() ) {
671 if( newMode == FreeTransformMode ) {
673 } else if( newMode == WarpTransformMode ) {
675 } else if( newMode == CageTransformMode ) {
677 } else if( newMode == LiquifyTransformMode ) {
679 } else if( newMode == PerspectiveTransformMode ) {
681 } else if( newMode == MeshTransformMode ) {
683 }
684
685 Q_EMIT transformModeChanged();
686 }
687}
void transformModeChanged()
#define KIS_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:97

References ToolTransformArgs::CAGE, CageTransformMode, ToolTransformArgs::FREE_TRANSFORM, FreeTransformMode, KIS_ASSERT_RECOVER_NOOP, ToolTransformArgs::LIQUIFY, LiquifyTransformMode, m_currentArgs, m_optionsWidget, ToolTransformArgs::MESH, MeshTransformMode, KisTool::mode(), ToolTransformArgs::mode(), ToolTransformArgs::PERSPECTIVE_4POINT, PerspectiveTransformMode, KisToolTransformConfigWidget::slotSetCageModeButtonClicked(), KisToolTransformConfigWidget::slotSetFreeTransformModeButtonClicked(), KisToolTransformConfigWidget::slotSetLiquifyModeButtonClicked(), KisToolTransformConfigWidget::slotSetMeshModeButtonClicked(), KisToolTransformConfigWidget::slotSetPerspectiveModeButtonClicked(), KisToolTransformConfigWidget::slotSetWarpModeButtonClicked(), transformModeChanged(), ToolTransformArgs::WARP, and WarpTransformMode.

◆ setTranslateX

◆ setTranslateY

◆ setWarpFlexibility

void KisToolTransform::setWarpFlexibility ( double flexibility)
slot

Definition at line 721 of file kis_tool_transform.cc.

722{
723 m_currentArgs.setAlpha( flexibility );
724}
void setAlpha(double alpha)

References m_currentArgs, and ToolTransformArgs::setAlpha().

◆ setWarpPointDensity

void KisToolTransform::setWarpPointDensity ( int density)
slot

◆ setWarpType

◆ shearX()

double KisToolTransform::shearX ( ) const

Definition at line 609 of file kis_tool_transform.cc.

610{
611 return m_currentArgs.shearX();
612}

References m_currentArgs, and ToolTransformArgs::shearX().

◆ shearY()

double KisToolTransform::shearY ( ) const

Definition at line 614 of file kis_tool_transform.cc.

615{
616 return m_currentArgs.shearY();
617}

References m_currentArgs, and ToolTransformArgs::shearY().

◆ slotApplyTransform

void KisToolTransform::slotApplyTransform ( )
privateslot

Definition at line 1232 of file kis_tool_transform.cc.

1233{
1234 KisCursorOverrideLock cursorLock(KisCursor::waitCursor());
1235 endStroke();
1236}

References endStroke(), and KisCursor::waitCursor().

◆ slotCancelTransform

void KisToolTransform::slotCancelTransform ( )
privateslot

◆ slotConvexHullCalculated

void KisToolTransform::slotConvexHullCalculated ( QPolygon hull,
void * strokeStrategyCookie )
slot

Only use the convex hull if it matches the original bounding rect. When we skip setConvexHull() call, nothing serious happens, except that rotatted bounds are rotated around the entire clip rect, not actual clip's data.

Definition at line 244 of file kis_tool_transform.cc.

245{
246 if (!m_strokeId || strokeStrategyCookie != m_strokeStrategyCookie) return;
247 QPolygonF hullF = hull;
254 if (hullF.boundingRect() == m_transaction.originalRect()) {
258 } else {
259 warnTools << "WARNING: KisToolTransform: calculated convex hull's bounds "
260 "differ from the bounding rect of the source clip. It shouldn't "
261 "have happened";
262 }
263}
#define warnTools
Definition kis_debug.h:90

References canvasUpdateRequested(), currentStrategy(), KisTransformStrategyBase::externalConfigChanged(), m_strokeId, m_strokeStrategyCookie, m_transaction, TransformTransactionProperties::originalRect(), TransformTransactionProperties::setConvexHull(), and warnTools.

◆ slotEditingFinished

void KisToolTransform::slotEditingFinished ( )
privateslot

Definition at line 1321 of file kis_tool_transform.cc.

1322{
1323 commitChanges();
1324}

References commitChanges().

◆ slotGlobalConfigChanged

void KisToolTransform::slotGlobalConfigChanged ( )
protectedslot

Definition at line 203 of file kis_tool_transform.cc.

204{
205 KConfigGroup group = KSharedConfig::openConfig()->group(toolId());
206 m_preferOverlayPreviewStyle = group.readEntry("useOverlayPreviewStyle", false);
207 m_forceLodMode = group.readEntry("forceLodMode", true);
208}

References m_forceLodMode, m_preferOverlayPreviewStyle, and KoToolBase::toolId().

◆ slotMoveDiscreteDown

void KisToolTransform::slotMoveDiscreteDown ( )
privateslot

Definition at line 1336 of file kis_tool_transform.cc.

1337{
1339}
void setTranslateY(double translateY)

References setTranslateY(), and translateY.

◆ slotMoveDiscreteDownMore

void KisToolTransform::slotMoveDiscreteDownMore ( )
privateslot

Definition at line 1341 of file kis_tool_transform.cc.

1342{
1343 setTranslateY(translateY()+10.0);
1344}

References setTranslateY(), and translateY.

◆ slotMoveDiscreteLeft

void KisToolTransform::slotMoveDiscreteLeft ( )
privateslot

Definition at line 1346 of file kis_tool_transform.cc.

1347{
1349}
void setTranslateX(double translateX)

References setTranslateX(), and translateX.

◆ slotMoveDiscreteLeftMore

void KisToolTransform::slotMoveDiscreteLeftMore ( )
privateslot

Definition at line 1351 of file kis_tool_transform.cc.

1352{
1353 setTranslateX(translateX()-10.0);
1354}

References setTranslateX(), and translateX.

◆ slotMoveDiscreteRight

void KisToolTransform::slotMoveDiscreteRight ( )
privateslot

Definition at line 1356 of file kis_tool_transform.cc.

1357{
1359}

References setTranslateX(), and translateX.

◆ slotMoveDiscreteRightMore

void KisToolTransform::slotMoveDiscreteRightMore ( )
privateslot

Definition at line 1361 of file kis_tool_transform.cc.

1362{
1363 setTranslateX(translateX()+10.0);
1364}

References setTranslateX(), and translateX.

◆ slotMoveDiscreteUp

void KisToolTransform::slotMoveDiscreteUp ( )
privateslot

Definition at line 1326 of file kis_tool_transform.cc.

1327{
1329}

References setTranslateY(), and translateY.

◆ slotMoveDiscreteUpMore

void KisToolTransform::slotMoveDiscreteUpMore ( )
privateslot

Definition at line 1331 of file kis_tool_transform.cc.

1332{
1333 setTranslateY(translateY()-10.0);
1334}

References setTranslateY(), and translateY.

◆ slotPreviewDeviceGenerated

void KisToolTransform::slotPreviewDeviceGenerated ( KisPaintDeviceSP device)
privateslot

Definition at line 1079 of file kis_tool_transform.cc.

1080{
1081 if (device && device->exactBounds().isEmpty()) {
1082 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
1083 KIS_SAFE_ASSERT_RECOVER(kisCanvas) { cancelStroke(); return; }
1084 kisCanvas->viewManager()->
1085 showFloatingMessage(
1086 i18nc("floating message in transformation tool",
1087 "Cannot transform empty layer "),
1088 QIcon(), 1000, KisFloatingMessage::Medium);
1089
1090 cancelStroke();
1091 } else {
1092 initThumbnailImage(device);
1094 }
1095}
KisViewManager * viewManager() const
QRect exactBounds() const
void initThumbnailImage(KisPaintDeviceSP previewDevice)
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126

References cancelStroke(), Private::canvas, KisPaintDevice::exactBounds(), initGuiAfterTransformMode(), initThumbnailImage(), KIS_SAFE_ASSERT_RECOVER, KisFloatingMessage::Medium, and KisCanvas2::viewManager().

◆ slotResetTransform

void KisToolTransform::slotResetTransform ( ToolTransformArgs::TransformMode mode)
privateslot

Our reset transform button can be used for two purposes:

1) Reset current transform to the initial one, which was loaded from the previous user action.

2) Reset transform frame to infinity when the frame is unchanged

Definition at line 1238 of file kis_tool_transform.cc.

1239{
1241 const ToolTransformArgs::TransformMode previousMode = config->mode();
1242 config->setMode(mode);
1243
1245 config->setWarpCalculation(KisWarpTransformWorker::WarpCalculation::GRID);
1246 }
1247
1248 if (!m_strokeId || m_transaction.rootNodes().isEmpty()) return;
1249
1252
1262 const bool transformDiffers = !m_currentArgs.continuedTransform()->isSameMode(m_currentArgs);
1263
1264 if (transformDiffers &&
1265 m_currentArgs.continuedTransform()->mode() == savedMode) {
1266
1270
1271 } else {
1272 cancelStroke();
1273 startStroke(savedMode, true);
1274
1276 }
1277 } else {
1283
1284 } else {
1285 cancelStroke();
1287
1288 }
1289 }
1290}
void initTransformMode(ToolTransformArgs::TransformMode mode)
static bool shouldRestartStrokeOnModeChange(ToolTransformArgs::TransformMode oldMode, ToolTransformArgs::TransformMode newMode, KisNodeList processedNodes)
void setWarpCalculation(KisWarpTransformWorker::WarpCalculation warpCalc)
void setMode(TransformMode mode)
bool isSameMode(const ToolTransformArgs &other) const
const ToolTransformArgs * continuedTransform() const

References cancelStroke(), ToolTransformArgs::continuedTransform(), TransformTransactionProperties::currentConfig(), initGuiAfterTransformMode(), initTransformMode(), ToolTransformArgs::isSameMode(), KIS_ASSERT_RECOVER_NOOP, m_currentArgs, m_strokeId, m_transaction, KisTool::mode(), ToolTransformArgs::mode(), ToolTransformArgs::restoreContinuedState(), TransformTransactionProperties::rootNodes(), ToolTransformArgs::setMode(), ToolTransformArgs::setWarpCalculation(), KisTransformUtils::shouldRestartStrokeOnModeChange(), slotEditingFinished(), startStroke(), TransformTransactionProperties::transformedNodes(), and ToolTransformArgs::WARP.

◆ slotRestartAndContinueTransform

void KisToolTransform::slotRestartAndContinueTransform ( )
privateslot

Definition at line 1309 of file kis_tool_transform.cc.

1310{
1311 if (!m_strokeId || m_transaction.rootNodes().isEmpty()) return;
1312
1313 KisNodeSP root = m_transaction.rootNodes()[0];
1314 KIS_ASSERT_RECOVER_RETURN(root); // the stroke is guaranteed to be started by an 'if' above
1315
1317 endStroke();
1318 startStroke(savedArgs.mode(), false);
1319}
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75

References endStroke(), KIS_ASSERT_RECOVER_RETURN, m_currentArgs, m_strokeId, m_transaction, ToolTransformArgs::mode(), TransformTransactionProperties::rootNodes(), and startStroke().

◆ slotRestartTransform

void KisToolTransform::slotRestartTransform ( )
privateslot

Definition at line 1297 of file kis_tool_transform.cc.

1298{
1299 if (!m_strokeId || m_transaction.rootNodes().isEmpty()) return;
1300
1301 KisNodeSP root = m_transaction.rootNodes()[0];
1302 KIS_ASSERT_RECOVER_RETURN(root); // the stroke is guaranteed to be started by an 'if' above
1303
1305 cancelStroke();
1306 startStroke(savedArgs.mode(), true);
1307}

References cancelStroke(), KIS_ASSERT_RECOVER_RETURN, m_currentArgs, m_strokeId, m_transaction, ToolTransformArgs::mode(), TransformTransactionProperties::rootNodes(), and startStroke().

◆ slotTrackerChangedConfig

void KisToolTransform::slotTrackerChangedConfig ( KisToolChangesTrackerDataSP status)
privateslot

Definition at line 1120 of file kis_tool_transform.cc.

1121{
1122 const ToolTransformArgs *newArgs = dynamic_cast<const ToolTransformArgs*>(status.data());
1124
1125 *m_transaction.currentConfig() = *newArgs;
1126
1127 slotUiChangedConfig(true);
1129}
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References TransformTransactionProperties::currentConfig(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_transaction, slotUiChangedConfig(), and updateOptionWidget().

◆ slotTransactionGenerated

void KisToolTransform::slotTransactionGenerated ( TransformTransactionProperties transaction,
ToolTransformArgs args,
void * strokeStrategyCookie )
privateslot

Definition at line 1036 of file kis_tool_transform.cc.

1037{
1038 if (!m_strokeId || strokeStrategyCookie != m_strokeStrategyCookie) return;
1039
1040 if (transaction.transformedNodes().isEmpty() ||
1041 transaction.originalRect().isEmpty()) {
1042
1043 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
1044 KIS_ASSERT(kisCanvas);
1045 kisCanvas->viewManager()->
1046 showFloatingMessage(
1047 i18nc("floating message in transformation tool",
1048 "Cannot transform empty layer "),
1049 QIcon(), 1000, KisFloatingMessage::Medium);
1050
1051 cancelStroke();
1052 return;
1053 }
1054
1055 m_transaction = transaction;
1056 m_currentArgs = args;
1058
1061 }
1062
1064 commitChanges();
1065
1067
1069 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
1070 KIS_ASSERT(kisCanvas);
1071 kisCanvas->viewManager()->
1072 showFloatingMessage(
1073 i18nc("floating message in transformation tool",
1074 "Invisible sublayers will also be transformed. Lock layers if you do not want them to be transformed "),
1075 QIcon(), 4000, KisFloatingMessage::Low);
1076 }
1077}
void setCurrentConfigLocation(ToolTransformArgs *config)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
#define KIS_ASSERT(cond)
Definition kis_assert.h:33

References cancelStroke(), Private::canvas, commitChanges(), TransformTransactionProperties::hasInvisibleNodes(), initGuiAfterTransformMode(), KisToolChangesTracker::isEmpty(), KIS_ASSERT, KIS_SAFE_ASSERT_RECOVER_NOOP, KisFloatingMessage::Low, m_asyncUpdateHelper, m_changesTracker, m_currentArgs, m_currentlyUsingOverlayPreviewStyle, m_strokeId, m_strokeStrategyCookie, m_transaction, KisFloatingMessage::Medium, TransformTransactionProperties::originalRect(), TransformTransactionProperties::setCurrentConfigLocation(), KisAsynchronousStrokeUpdateHelper::startUpdateStreamLowLevel(), TransformTransactionProperties::transformedNodes(), and KisCanvas2::viewManager().

◆ slotUiChangedConfig

void KisToolTransform::slotUiChangedConfig ( bool needsPreviewRecalculation)
privateslot

◆ slotUpdateToCageType

void KisToolTransform::slotUpdateToCageType ( )
privateslot

Definition at line 1391 of file kis_tool_transform.cc.

1392{
1394}
void setTransformMode(KisToolTransform::TransformToolMode newMode)

References CageTransformMode, and setTransformMode().

◆ slotUpdateToFreeTransformType

void KisToolTransform::slotUpdateToFreeTransformType ( )
privateslot

◆ slotUpdateToLiquifyType

void KisToolTransform::slotUpdateToLiquifyType ( )
privateslot

◆ slotUpdateToMeshType

void KisToolTransform::slotUpdateToMeshType ( )
privateslot

◆ slotUpdateToPerspectiveType

void KisToolTransform::slotUpdateToPerspectiveType ( )
privateslot

◆ slotUpdateToWarpType

void KisToolTransform::slotUpdateToWarpType ( )
privateslot

◆ startStroke()

void KisToolTransform::startStroke ( ToolTransformArgs::TransformMode mode,
bool forceReset )
private

When working with transform mask, selections are not taken into account.

Definition at line 889 of file kis_tool_transform.cc.

890{
891 Q_ASSERT(!m_strokeId);
892
895
896 // set up and null checks before we do anything
897 KisResourcesSnapshotSP resources =
898 new KisResourcesSnapshot(image(), currentNode(), this->canvas()->resourceManager(), 0, selectedNodes(), 0);
899 KisNodeList rootNodes = resources->selectedNodes();
900 //Filter out any nodes that might be children of other selected nodes so they aren't used twice
903
906
907 Q_FOREACH (KisNodeSP currentNode, resources->selectedNodes()) {
908 if (!currentNode || !currentNode->isEditable()) return;
909
910 // some layer types cannot be transformed. Give a message and return if a user tries it
911 if (currentNode->inherits("KisColorizeMask") ||
912 currentNode->inherits("KisFileLayer") ||
913 currentNode->inherits("KisCloneLayer")) {
914
915 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
916 KIS_ASSERT(kisCanvas);
917
918 if(currentNode->inherits("KisColorizeMask")){
919 kisCanvas->viewManager()->
920 showFloatingMessage(
921 i18nc("floating message in transformation tool",
922 "Layer type cannot use the transform tool"),
923 koIcon("object-locked"), 4000, KisFloatingMessage::High);
924 }
925 else{
926 kisCanvas->viewManager()->
927 showFloatingMessage(
928 i18nc("floating message in transformation tool",
929 "Layer type cannot use the transform tool. Use transform mask instead."),
930 koIcon("object-locked"), 4000, KisFloatingMessage::High);
931 }
932 return;
933 }
934
935 KisNodeSP impossibleMask =
937 [currentNode] (KisNodeSP node) {
938 // we can process transform masks of the first level
939 if (node == currentNode || node->parent() == currentNode) return false;
940
941 return node->inherits("KisTransformMask") && node->visible(true);
942 });
943
944 if (impossibleMask) {
945 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
946 kisCanvas->viewManager()->
947 showFloatingMessage(
948 i18nc("floating message in transformation tool",
949 "Layer has children with transform masks. Please disable them before doing transformation."),
950 koIcon("object-locked"), 8000, KisFloatingMessage::High);
951 return;
952 }
953
958 if (selection && dynamic_cast<KisTransformMask*>(currentNode.data())) {
959 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
960 kisCanvas->viewManager()->
961 showFloatingMessage(
962 i18nc("floating message in transformation tool",
963 "Selections are not used when editing transform masks "),
964 QIcon(), 4000, KisFloatingMessage::Low);
965
966 selection = 0;
967 }
968 }
969 // Overlay preview is never used when transforming an externally provided image
971
972 KisStrokeStrategy *strategy = 0;
973
975 TransformStrokeStrategy *transformStrategy = new TransformStrokeStrategy(mode, m_currentArgs.filterId(), forceReset, rootNodes, selection, image().data(), image().data());
976 connect(transformStrategy, SIGNAL(sigPreviewDeviceReady(KisPaintDeviceSP)), SLOT(slotPreviewDeviceGenerated(KisPaintDeviceSP)));
977 connect(transformStrategy, SIGNAL(sigTransactionGenerated(TransformTransactionProperties, ToolTransformArgs, void*)), SLOT(slotTransactionGenerated(TransformTransactionProperties, ToolTransformArgs, void*)));
978 connect(transformStrategy, SIGNAL(sigConvexHullCalculated(QPolygon, void*)), SLOT(slotConvexHullCalculated(QPolygon, void*)));
979 strategy = transformStrategy;
980
981 // save unique identifier of the stroke so we could
982 // recognize it when sigTransactionGenerated() is
983 // received (theoretically, the user can start two
984 // strokes at the same time, if he is quick enough)
985 m_strokeStrategyCookie = transformStrategy;
986
987 } else {
988 InplaceTransformStrokeStrategy *transformStrategy = new InplaceTransformStrokeStrategy(mode, m_currentArgs.filterId(), forceReset, rootNodes, selection, externalSource, image().data(), image().data(), image()->root(), m_forceLodMode);
989 connect(transformStrategy, SIGNAL(sigTransactionGenerated(TransformTransactionProperties, ToolTransformArgs, void*)), SLOT(slotTransactionGenerated(TransformTransactionProperties, ToolTransformArgs, void*)));
990 connect(transformStrategy, SIGNAL(sigConvexHullCalculated(QPolygon, void*)), SLOT(slotConvexHullCalculated(QPolygon, void*)));
991 strategy = transformStrategy;
992
993 // save unique identifier of the stroke so we could
994 // recognize it when sigTransactionGenerated() is
995 // received (theoretically, the user can start two
996 // strokes at the same time, if he is quick enough)
997 m_strokeStrategyCookie = transformStrategy;
998 }
999
1000 m_strokeId = image()->startStroke(strategy);
1001
1004 }
1005
1007
1009}
void initUpdateStreamLowLevel(KisStrokesFacade *strokesFacade, KisStrokeId strokeId)
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override
The KisResourcesSnapshot class takes a snapshot of the various resources like colors and settings use...
KisNodeList selectedNodes() const
KisSelectionSP activeSelection() const
void slotConvexHullCalculated(QPolygon hull, void *strokeStrategyCookie)
void slotPreviewDeviceGenerated(KisPaintDeviceSP device)
void slotTransactionGenerated(TransformTransactionProperties transaction, ToolTransformArgs args, void *strokeStrategyCookie)
virtual KoToolSelection * selection()
#define koIcon(name)
Use these macros for icons without any issues.
Definition kis_icon.h:25
KisNodeSP recursiveFindNode(KisNodeSP node, std::function< bool(KisNodeSP)> func)
void filterMergeableNodes(KisNodeList &nodes, bool allowMasks)
bool isEditable(bool checkVisibility=true) const
virtual bool visible(bool recursive=false) const
KisNodeWSP parent
Definition kis_node.cpp:86
KisNodeList selectedNodes() const
Definition kis_tool.cc:376

References KisResourcesSnapshot::activeSelection(), Private::canvas, KisSharedPtr< T >::clear(), connect(), KisTool::currentNode(), KisSharedPtr< T >::data(), ToolTransformArgs::filterId(), KisLayerUtils::filterMergeableNodes(), KisFloatingMessage::High, KisTool::image(), KisAsynchronousStrokeUpdateHelper::initUpdateStreamLowLevel(), KisBaseNode::isEditable(), KisToolChangesTracker::isEmpty(), KIS_ASSERT, KIS_SAFE_ASSERT_RECOVER_NOOP, koIcon, KisFloatingMessage::Low, m_asyncUpdateHelper, m_changesTracker, m_currentArgs, m_currentlyUsingOverlayPreviewStyle, m_externalSourceForNextActivation, m_forceLodMode, m_preferOverlayPreviewStyle, m_strokeId, m_strokeStrategyCookie, m_transaction, KisTool::mode(), KisNode::parent, KisLayerUtils::recursiveFindNode(), KisResourcesSnapshot::selectedNodes(), KisTool::selectedNodes(), KoToolBase::selection(), slotConvexHullCalculated(), slotPreviewDeviceGenerated(), slotTransactionGenerated(), KisImage::startStroke(), KisCanvas2::viewManager(), and KisBaseNode::visible().

◆ transformMode()

◆ transformModeChanged

void KisToolTransform::transformModeChanged ( )
signal

◆ translateX()

double KisToolTransform::translateX ( ) const

Definition at line 574 of file kis_tool_transform.cc.

575{
576 return m_currentArgs.transformedCenter().x();
577}
QPointF transformedCenter() const

References m_currentArgs, and ToolTransformArgs::transformedCenter().

◆ translateY()

double KisToolTransform::translateY ( ) const

Definition at line 579 of file kis_tool_transform.cc.

580{
581 return m_currentArgs.transformedCenter().y();
582}

References m_currentArgs, and ToolTransformArgs::transformedCenter().

◆ updateApplyResetAvailability()

void KisToolTransform::updateApplyResetAvailability ( )
private

◆ updateOptionWidget

void KisToolTransform::updateOptionWidget ( )
slot

Definition at line 1195 of file kis_tool_transform.cc.

1196{
1197 if (!m_optionsWidget) return;
1198
1199 if (!currentNode()) {
1200 m_optionsWidget->setEnabled(false);
1201 return;
1202 }
1203 else {
1204 m_optionsWidget->setEnabled(true);
1206 }
1207}
void updateConfig(const ToolTransformArgs &config)

References KisTool::currentNode(), m_currentArgs, m_optionsWidget, and KisToolTransformConfigWidget::updateConfig().

◆ wantsAutoScroll()

bool KisToolTransform::wantsAutoScroll ( ) const
inlineoverridevirtual

wantsAutoScroll reimplemented from KoToolBase there's an issue where autoscrolling with this tool never makes the stroke end, so we return false here so that users don't get stuck with the tool. See bug 362659

Returns
false

Reimplemented from KoToolBase.

Definition at line 133 of file kis_tool_transform.h.

133 {
134 return false;
135 }

◆ warpFlexibility()

double KisToolTransform::warpFlexibility ( ) const

Definition at line 633 of file kis_tool_transform.cc.

634{
635 return m_currentArgs.alpha();
636}

References ToolTransformArgs::alpha(), and m_currentArgs.

◆ warpPointDensity()

int KisToolTransform::warpPointDensity ( ) const

Definition at line 638 of file kis_tool_transform.cc.

639{
640 return m_currentArgs.numPoints();
641}

References m_currentArgs, and ToolTransformArgs::numPoints().

◆ warpTransformChanged

void KisToolTransform::warpTransformChanged ( )
signal

◆ warpType()

Member Data Documentation

◆ applyTransformation

KisAction* KisToolTransform::applyTransformation {0}
private

Definition at line 290 of file kis_tool_transform.h.

290{0};

◆ cageAction

KisAction* KisToolTransform::cageAction {0}
private

Definition at line 287 of file kis_tool_transform.h.

287{0};

◆ freeTransformAction

KisAction* KisToolTransform::freeTransformAction {0}
private

Definition at line 288 of file kis_tool_transform.h.

288{0};

◆ keepAspectRatioAction

KisAction* KisToolTransform::keepAspectRatioAction {0}
private

Definition at line 298 of file kis_tool_transform.h.

298{0};

◆ liquifyAction

KisAction* KisToolTransform::liquifyAction {0}
private

Definition at line 286 of file kis_tool_transform.h.

286{0};

◆ m_actionConnections

KisSignalAutoConnectionsStore KisToolTransform::m_actionConnections
private

Definition at line 280 of file kis_tool_transform.h.

◆ m_actuallyMoveWhileSelected

bool KisToolTransform::m_actuallyMoveWhileSelected {false}
private

Definition at line 263 of file kis_tool_transform.h.

263{false}; // true <=> selection has been moved while clicked

◆ m_asyncUpdateHelper

KisAsynchronousStrokeUpdateHelper KisToolTransform::m_asyncUpdateHelper
private

Definition at line 320 of file kis_tool_transform.h.

◆ m_cageStrategy

QScopedPointer<KisCageTransformStrategy> KisToolTransform::m_cageStrategy
private

Definition at line 311 of file kis_tool_transform.h.

◆ m_canvas

QPointer<KisCanvas2> KisToolTransform::m_canvas
private

Definition at line 276 of file kis_tool_transform.h.

◆ m_changesTracker

KisToolChangesTracker KisToolTransform::m_changesTracker
private

Definition at line 279 of file kis_tool_transform.h.

◆ m_contextMenu

QScopedPointer<QMenu> KisToolTransform::m_contextMenu
private

Definition at line 235 of file kis_tool_transform.h.

◆ m_currentArgs

ToolTransformArgs KisToolTransform::m_currentArgs
private

Definition at line 257 of file kis_tool_transform.h.

◆ m_currentlyUsingOverlayPreviewStyle

bool KisToolTransform::m_currentlyUsingOverlayPreviewStyle {false}
private

Definition at line 268 of file kis_tool_transform.h.

268{false};

◆ m_cursorOutline

QPainterPath KisToolTransform::m_cursorOutline
private

Definition at line 318 of file kis_tool_transform.h.

◆ m_externalSourceForNextActivation

KisPaintDeviceSP KisToolTransform::m_externalSourceForNextActivation
private

Definition at line 261 of file kis_tool_transform.h.

◆ m_forceLodMode

bool KisToolTransform::m_forceLodMode {false}
private

Definition at line 270 of file kis_tool_transform.h.

270{false};

◆ m_freeStrategy

QScopedPointer<KisFreeTransformStrategy> KisToolTransform::m_freeStrategy
private

Definition at line 314 of file kis_tool_transform.h.

◆ m_liquifyStrategy

QScopedPointer<KisLiquifyTransformStrategy> KisToolTransform::m_liquifyStrategy
private

Definition at line 312 of file kis_tool_transform.h.

◆ m_meshStrategy

QScopedPointer<KisMeshTransformStrategy> KisToolTransform::m_meshStrategy
private

Definition at line 313 of file kis_tool_transform.h.

◆ m_optionsWidget

KisToolTransformConfigWidget* KisToolTransform::m_optionsWidget {0}
private

Definition at line 275 of file kis_tool_transform.h.

275{0};

◆ m_perspectiveStrategy

QScopedPointer<KisPerspectiveTransformStrategy> KisToolTransform::m_perspectiveStrategy
private

Definition at line 315 of file kis_tool_transform.h.

◆ m_preferOverlayPreviewStyle

bool KisToolTransform::m_preferOverlayPreviewStyle {false}
private

Definition at line 269 of file kis_tool_transform.h.

269{false};

◆ m_refRect

QRectF KisToolTransform::m_refRect
private

This artificial rect is used to store the image to flake transformation. We check against this rect to get to know whether zoom has changed.

Definition at line 308 of file kis_tool_transform.h.

◆ m_selectedPortionCache

KisPaintDeviceSP KisToolTransform::m_selectedPortionCache
private

Definition at line 265 of file kis_tool_transform.h.

◆ m_selectionPath

QPainterPath KisToolTransform::m_selectionPath
private

Definition at line 273 of file kis_tool_transform.h.

◆ m_strokeId

KisStrokeId KisToolTransform::m_strokeId
private

Definition at line 266 of file kis_tool_transform.h.

◆ m_strokeStrategyCookie

void* KisToolTransform::m_strokeStrategyCookie {0}
private

Definition at line 267 of file kis_tool_transform.h.

267{0};

◆ m_transaction

TransformTransactionProperties KisToolTransform::m_transaction
private

Definition at line 278 of file kis_tool_transform.h.

◆ m_warpStrategy

QScopedPointer<KisWarpTransformStrategy> KisToolTransform::m_warpStrategy
private

Definition at line 310 of file kis_tool_transform.h.

◆ meshAction

KisAction* KisToolTransform::meshAction {0}
private

Definition at line 285 of file kis_tool_transform.h.

285{0};

◆ mirrorHorizontalAction

KisAction* KisToolTransform::mirrorHorizontalAction {0}
private

Definition at line 294 of file kis_tool_transform.h.

294{0};

◆ mirrorVerticalAction

KisAction* KisToolTransform::mirrorVerticalAction {0}
private

Definition at line 295 of file kis_tool_transform.h.

295{0};

◆ perspectiveAction

KisAction* KisToolTransform::perspectiveAction {0}
private

Definition at line 289 of file kis_tool_transform.h.

289{0};

◆ resetTransformation

KisAction* KisToolTransform::resetTransformation {0}
private

Definition at line 291 of file kis_tool_transform.h.

291{0};

◆ rotateNinetyCCWAction

KisAction* KisToolTransform::rotateNinetyCCWAction {0}
private

Definition at line 297 of file kis_tool_transform.h.

297{0};

◆ rotateNinetyCWAction

KisAction* KisToolTransform::rotateNinetyCWAction {0}
private

Definition at line 296 of file kis_tool_transform.h.

296{0};

◆ warpAction

KisAction* KisToolTransform::warpAction {0}
private

actions for the context click menu

Definition at line 284 of file kis_tool_transform.h.

284{0};

Property Documentation

◆ rotateX

double KisToolTransform::rotateX
readwrite

Definition at line 88 of file kis_tool_transform.h.

◆ rotateY

double KisToolTransform::rotateY
readwrite

Definition at line 89 of file kis_tool_transform.h.

◆ rotateZ

double KisToolTransform::rotateZ
readwrite

Definition at line 90 of file kis_tool_transform.h.

◆ scaleX

double KisToolTransform::scaleX
readwrite

Definition at line 92 of file kis_tool_transform.h.

◆ scaleY

double KisToolTransform::scaleY
readwrite

Definition at line 93 of file kis_tool_transform.h.

◆ shearX

double KisToolTransform::shearX
readwrite

Definition at line 95 of file kis_tool_transform.h.

◆ shearY

double KisToolTransform::shearY
readwrite

Definition at line 96 of file kis_tool_transform.h.

◆ transformMode

TransformToolMode KisToolTransform::transformMode
readwrite

Definition at line 83 of file kis_tool_transform.h.

◆ translateX

double KisToolTransform::translateX
readwrite

Definition at line 85 of file kis_tool_transform.h.

◆ translateY

double KisToolTransform::translateY
readwrite

Definition at line 86 of file kis_tool_transform.h.

◆ warpFlexibility

double KisToolTransform::warpFlexibility
readwrite

Definition at line 99 of file kis_tool_transform.h.

◆ warpPointDensity

int KisToolTransform::warpPointDensity
readwrite

Definition at line 100 of file kis_tool_transform.h.

◆ warpType

WarpType KisToolTransform::warpType
readwrite

Definition at line 98 of file kis_tool_transform.h.


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