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
 
void setNextActivationTransformMode (TransformToolMode mode)
 
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
 

Static Public Member Functions

static ToolTransformArgs::TransformMode toArgsMode (KisToolTransform::TransformToolMode toolMode)
 
- Static Public Member Functions inherited from KisTool
static AlternateAction actionToAlternateAction (ToolAction action)
 

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}
 
TransformToolMode nextActivationTransformMode {FreeTransformMode}
 
KisActionperspectiveAction {0}
 
KisActionresetTransformation {0}
 
KisActionrotateNinetyCCWAction {0}
 
KisActionrotateNinetyCWAction {0}
 
KisActionwarpAction {0}
 actions for the context click menu
 

Additional Inherited Members

- 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 84 of file kis_tool_transform.cc.

88 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
89 dynamic_cast<KisCanvas2*>(canvas)->snapGuide(),
93 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
94 dynamic_cast<KisCanvas2*>(canvas)->snapGuide(),
98 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
102 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
103 dynamic_cast<KisCanvas2*>(canvas)->snapGuide(),
107 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
108 dynamic_cast<KisCanvas2*>(canvas)->snapGuide(),
112 dynamic_cast<KisCanvas2*>(canvas)->coordinatesConverter(),
113 dynamic_cast<KisCanvas2*>(canvas)->snapGuide(),
115{
116 m_canvas = dynamic_cast<KisCanvas2*>(canvas);
117 Q_ASSERT(m_canvas);
118
119 setObjectName("tool_transform");
120 m_optionsWidget = 0;
121
122 warpAction = new KisAction(i18nc("Warp Transform Tab Label", "Warp"));
123 liquifyAction = new KisAction(i18nc("Liquify Transform Tab Label", "Liquify"));
124 meshAction = new KisAction(i18nc("Mesh Transform Tab Label", "Mesh"));
125 cageAction = new KisAction(i18nc("Cage Transform Tab Label", "Cage"));
126 freeTransformAction = new KisAction(i18nc("Free Transform Tab Label", "Free"));
127 perspectiveAction = new KisAction(i18nc("Perspective Transform Tab Label", "Perspective"));
128
129 // extra actions for free transform that are in the tool options
130 mirrorHorizontalAction = new KisAction(i18n("Mirror Horizontal"));
131 mirrorVerticalAction = new KisAction(i18n("Mirror Vertical"));
132 rotateNinetyCWAction = new KisAction(i18n("Rotate 90 degrees Clockwise"));
133 rotateNinetyCCWAction = new KisAction(i18n("Rotate 90 degrees CounterClockwise"));
134
135 keepAspectRatioAction = new KisAction(i18n("Keep Aspect Ratio"));
136 keepAspectRatioAction->setCheckable(true);
137 keepAspectRatioAction->setChecked(false);
138
139 applyTransformation = new KisAction(i18n("Apply"));
140 resetTransformation = new KisAction(i18n("Reset"));
141
142 m_contextMenu.reset(new QMenu());
143
144 connect(m_warpStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
145 connect(m_warpStrategy.data(), SIGNAL(requestImageRecalculation()), SLOT(requestImageRecalculation()));
146 connect(m_cageStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
147 connect(m_cageStrategy.data(), SIGNAL(requestImageRecalculation()), SLOT(requestImageRecalculation()));
148 connect(m_liquifyStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
149 connect(m_liquifyStrategy.data(), SIGNAL(requestCursorOutlineUpdate(QPointF)), SLOT(cursorOutlineUpdateRequested(QPointF)));
150 connect(m_liquifyStrategy.data(), SIGNAL(requestUpdateOptionWidget()), SLOT(updateOptionWidget()));
152 connect(m_freeStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
153 connect(m_freeStrategy.data(), SIGNAL(requestResetRotationCenterButtons()), SLOT(resetRotationCenterButtonsRequested()));
154 connect(m_freeStrategy.data(), SIGNAL(requestShowImageTooBig(bool)), SLOT(imageTooBigRequested(bool)));
155 connect(m_freeStrategy.data(), SIGNAL(requestImageRecalculation()), SLOT(requestImageRecalculation()));
156 connect(m_freeStrategy.data(), SIGNAL(requestConvexHullCalculation()), SLOT(convexHullCalculationRequested()));
157 connect(m_perspectiveStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
158 connect(m_perspectiveStrategy.data(), SIGNAL(requestShowImageTooBig(bool)), SLOT(imageTooBigRequested(bool)));
160 connect(m_meshStrategy.data(), SIGNAL(requestCanvasUpdate()), SLOT(canvasUpdateRequested()));
161 connect(m_meshStrategy.data(), SIGNAL(requestImageRecalculation()), SLOT(requestImageRecalculation()));
162
163 connect(&m_changesTracker, SIGNAL(sigConfigChanged(KisToolChangesTrackerDataSP)),
165
166 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(slotGlobalConfigChanged()));
167}
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(), 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 817 of file kis_tool_transform.cc.

818{
819 KisTool::activate(shapes);
820
824
825 m_actionConnections.addConnection(action("movetool-move-up"), SIGNAL(triggered(bool)),
826 this, SLOT(slotMoveDiscreteUp()));
827 m_actionConnections.addConnection(action("movetool-move-up-more"), SIGNAL(triggered(bool)),
828 this, SLOT(slotMoveDiscreteUpMore()));
829 m_actionConnections.addConnection(action("movetool-move-down"), SIGNAL(triggered(bool)),
830 this, SLOT(slotMoveDiscreteDown()));
831 m_actionConnections.addConnection(action("movetool-move-down-more"), SIGNAL(triggered(bool)),
832 this, SLOT(slotMoveDiscreteDownMore()));
833 m_actionConnections.addConnection(action("movetool-move-left"), SIGNAL(triggered(bool)),
834 this, SLOT(slotMoveDiscreteLeft()));
835 m_actionConnections.addConnection(action("movetool-move-left-more"), SIGNAL(triggered(bool)),
836 this, SLOT(slotMoveDiscreteLeftMore()));
837 m_actionConnections.addConnection(action("movetool-move-right"), SIGNAL(triggered(bool)),
838 this, SLOT(slotMoveDiscreteRight()));
839 m_actionConnections.addConnection(action("movetool-move-right-more"), SIGNAL(triggered(bool)),
840 this, SLOT(slotMoveDiscreteRightMore()));
841
842 if (currentNode()) {
844 }
845
848}
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
static ToolTransformArgs::TransformMode toArgsMode(KisToolTransform::TransformToolMode toolMode)
TransformToolMode nextActivationTransformMode
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(), FreeTransformMode, m_actionConnections, m_currentArgs, m_transaction, nextActivationTransformMode, slotGlobalConfigChanged(), slotMoveDiscreteDown(), slotMoveDiscreteDownMore(), slotMoveDiscreteLeft(), slotMoveDiscreteLeftMore(), slotMoveDiscreteRight(), slotMoveDiscreteRightMore(), slotMoveDiscreteUp(), slotMoveDiscreteUpMore(), startStroke(), and toArgsMode().

◆ activateAlternateAction()

void KisToolTransform::activateAlternateAction ( AlternateAction action)
overridevirtual

Reimplemented from KisTool.

Definition at line 481 of file kis_tool_transform.cc.

482{
485}
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 470 of file kis_tool_transform.cc.

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

◆ applyTransform

void KisToolTransform::applyTransform ( )
slot

Definition at line 539 of file kis_tool_transform.cc.

540{
542}

References slotApplyTransform().

◆ beginActionImpl()

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

Definition at line 347 of file kis_tool_transform.cc.

348{
349 if (!nodeEditable()) {
350 event->ignore();
351 return;
352 }
353
354 if (!m_strokeId) {
356 } else if (!m_transaction.rootNodes().isEmpty()) {
357 bool result = false;
358
359 if (usePrimaryAction) {
360 result = currentStrategy()->beginPrimaryAction(event);
361 } else {
362 result = currentStrategy()->beginAlternateAction(event, action);
363 }
364
365 if (result) {
367 }
368 }
369
371
373}
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 492 of file kis_tool_transform.cc.

493{
494 beginActionImpl(event, false, action);
495}
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 455 of file kis_tool_transform.cc.

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

References beginActionImpl(), and KisTool::NONE.

◆ cancelStroke()

void KisToolTransform::cancelStroke ( )
private

◆ canvasUpdateRequested

void KisToolTransform::canvasUpdateRequested ( )
slot

Definition at line 194 of file kis_tool_transform.cc.

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

References m_canvas.

◆ commitChanges()

void KisToolTransform::commitChanges ( )
private

Definition at line 1127 of file kis_tool_transform.cc.

1128{
1129 if (!m_strokeId || m_transaction.rootNodes().isEmpty()) return;
1130
1132}
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 375 of file kis_tool_transform.cc.

376{
377 if (mode() != KisTool::PAINT_MODE) return;
378 if (m_transaction.rootNodes().isEmpty()) return;
379
381
382 if (usePrimaryAction) {
384 } else {
386 }
387
390}
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 497 of file kis_tool_transform.cc.

498{
499 continueActionImpl(event, false, action);
500}
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 460 of file kis_tool_transform.cc.

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

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 223 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 1145 of file kis_tool_transform.cc.

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

References applyTransformation, cageAction, 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()

◆ cursorOutlineUpdateRequested

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

Definition at line 322 of file kis_tool_transform.cc.

323{
324 QRect canvasUpdateRect;
325
326 if (!m_cursorOutline.isEmpty()) {
327 canvasUpdateRect = m_canvas->coordinatesConverter()->
328 imageToDocument(m_cursorOutline.boundingRect()).toAlignedRect();
329 }
330
332 getCursorOutline().translated(imagePos);
333
334 if (!m_cursorOutline.isEmpty()) {
335 canvasUpdateRect |=
336 m_canvas->coordinatesConverter()->
337 imageToDocument(m_cursorOutline.boundingRect()).toAlignedRect();
338 }
339
340 if (!canvasUpdateRect.isEmpty()) {
341 // grow rect a bit to follow interpolation fuzziness
342 canvasUpdateRect = kisGrowRect(canvasUpdateRect, 2);
343 m_canvas->updateCanvas(canvasUpdateRect);
344 }
345}
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 487 of file kis_tool_transform.cc.

488{
490}
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 476 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 392 of file kis_tool_transform.cc.

393{
394 if (mode() != KisTool::PAINT_MODE) return;
395
397
399 currentStrategy()->acceptsClicks()) {
400
401 bool result = false;
402
403 if (usePrimaryAction) {
404 result = currentStrategy()->endPrimaryAction(event);
405 } else {
406 result = currentStrategy()->endAlternateAction(event, action);
407 }
408
409 if (result) {
411 }
412
414 }
415
418}
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 502 of file kis_tool_transform.cc.

503{
504 endActionImpl(event, false, action);
505}
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 465 of file kis_tool_transform.cc.

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

References endActionImpl(), and KisTool::NONE.

◆ endStroke()

void KisToolTransform::endStroke ( )
private

Definition at line 1025 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 217 of file kis_tool_transform.cc.

218{
219 if (!m_optionsWidget) return;
221}
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 759 of file kis_tool_transform.cc.

760{
761 QImage origImg;
762 m_selectedPortionCache = previewDevice;
763
764 QTransform thumbToImageTransform;
765
766 const int maxSize = 2000;
767
768 QRect srcRect(m_transaction.originalRect().toAlignedRect());
769 int x, y, w, h;
770 srcRect.getRect(&x, &y, &w, &h);
771
773 if (w > maxSize || h > maxSize) {
774 qreal scale = qreal(maxSize) / (w > h ? w : h);
775 QTransform scaleTransform = QTransform::fromScale(scale, scale);
776
777 QRect thumbRect = scaleTransform.mapRect(m_transaction.originalRect()).toAlignedRect();
778
779 origImg = m_selectedPortionCache->
780 createThumbnail(thumbRect.width(),
781 thumbRect.height(),
782 srcRect, 1,
785 thumbToImageTransform = scaleTransform.inverted();
786
787 } else {
788 origImg = m_selectedPortionCache->convertToQImage(0, x, y, w, h,
791 thumbToImageTransform = QTransform();
792 }
793 }
794
795 // init both strokes since the thumbnail is initialized only once
796 // during the stroke
797 m_freeStrategy->setThumbnailImage(origImg, thumbToImageTransform);
798 m_perspectiveStrategy->setThumbnailImage(origImg, thumbToImageTransform);
799 m_warpStrategy->setThumbnailImage(origImg, thumbToImageTransform);
800 m_cageStrategy->setThumbnailImage(origImg, thumbToImageTransform);
801 m_liquifyStrategy->setThumbnailImage(origImg, thumbToImageTransform);
802 m_meshStrategy->setThumbnailImage(origImg, thumbToImageTransform);
803}
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 744 of file kis_tool_transform.cc.

745{
748}
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 520 of file kis_tool_transform.cc.

521{
522 QPointF mousePos = m_canvas->coordinatesConverter()->documentToImage(event->point);
523
525
526 if (this->mode() != KisTool::PAINT_MODE) {
530 return;
531 }
532}
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 507 of file kis_tool_transform.cc.

508{
509 // When using touch drawing, we only ever receive move events after the
510 // finger has pressed down. This confuses the strategies greatly, since they
511 // expect to receive a hover to tell which anchor the user wants to
512 // manipulate or similar. So in this case, we send an artificial hover.
513 if (event->isTouchEvent() && this->mode() != KisTool::PAINT_MODE) {
516 }
518}
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 534 of file kis_tool_transform.cc.

535{
537}
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 805 of file kis_tool_transform.cc.

806{
807 m_externalSourceForNextActivation = externalSource;
808 if (isActive()) {
809 QSet<KoShape*> dummy;
810 deactivate();
811 activate(dummy);
812 } else {
813 KoToolManager::instance()->switchToolRequested("KisToolTransform");
814 }
815}
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 188 of file kis_tool_transform.cc.

189{
190 Q_EMIT freeTransformChanged();
191 m_canvas->updateCanvas();
192}
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 283 of file kis_tool_transform.cc.

284{
285 Q_UNUSED(converter);
286
287 if (!m_strokeId || m_transaction.rootNodes().isEmpty()) return;
288
289 QRectF newRefRect = KisTransformUtils::imageToFlake(m_canvas->coordinatesConverter(), QRectF(0.0,0.0,1.0,1.0));
290 if (m_refRect != newRefRect) {
291 m_refRect = newRefRect;
293 }
295 currentStrategy()->paint(gc);
296
297
298 if (!m_cursorOutline.isEmpty()) {
299 QPainterPath mappedOutline =
301 m_canvas->coordinatesConverter()).map(m_cursorOutline);
302 paintToolOutline(&gc, mappedOutline);
303 }
304}
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 420 of file kis_tool_transform.cc.

421{
422 if (m_contextMenu) {
423 m_contextMenu->clear();
424
425 m_contextMenu->addSection(i18n("Transform Tool Actions"));
426 // add a quick switch to different transform types
429 m_contextMenu->addAction(warpAction);
430 m_contextMenu->addAction(cageAction);
431 m_contextMenu->addAction(liquifyAction);
432 m_contextMenu->addAction(meshAction);
433
434 // extra options if free transform is selected
436 m_contextMenu->addSeparator();
441
442 m_contextMenu->addSeparator();
445 }
446
447 m_contextMenu->addSeparator();
450 }
451
452 return m_contextMenu.data();
453}
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 878 of file kis_tool_transform.cc.

879{
880 endStroke();
881}

References endStroke().

◆ requestUndoDuringStroke

◆ resetCursorStyle

void KisToolTransform::resetCursorStyle ( )
overrideprotectedslot

Definition at line 199 of file kis_tool_transform.cc.

200{
202}

References setFunctionalCursor().

◆ resetRotationCenterButtonsRequested

void KisToolTransform::resetRotationCenterButtonsRequested ( )
slot

◆ rotateX()

double KisToolTransform::rotateX ( ) const

Definition at line 590 of file kis_tool_transform.cc.

591{
592 return m_currentArgs.aX();
593}

References ToolTransformArgs::aX(), and m_currentArgs.

◆ rotateY()

double KisToolTransform::rotateY ( ) const

Definition at line 595 of file kis_tool_transform.cc.

596{
597 return m_currentArgs.aY();
598}

References ToolTransformArgs::aY(), and m_currentArgs.

◆ rotateZ()

double KisToolTransform::rotateZ ( ) const

Definition at line 600 of file kis_tool_transform.cc.

601{
602 return m_currentArgs.aZ();
603}

References ToolTransformArgs::aZ(), and m_currentArgs.

◆ scaleX()

double KisToolTransform::scaleX ( ) const

Definition at line 605 of file kis_tool_transform.cc.

606{
607 return m_currentArgs.scaleX();
608}

References m_currentArgs, and ToolTransformArgs::scaleX().

◆ scaleY()

double KisToolTransform::scaleY ( ) const

Definition at line 610 of file kis_tool_transform.cc.

611{
612 return m_currentArgs.scaleY();
613}

References m_currentArgs, and ToolTransformArgs::scaleY().

◆ setFunctionalCursor()

void KisToolTransform::setFunctionalCursor ( )
private

Definition at line 306 of file kis_tool_transform.cc.

307{
309 return;
310 }
311
312 if (!m_strokeId) {
314 } else if (m_strokeId && m_transaction.rootNodes().isEmpty()) {
315 // we are in the middle of stroke initialization
317 } else {
318 useCursor(currentStrategy()->getCurrentCursor());
319 }
320}
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().

◆ setNextActivationTransformMode()

void KisToolTransform::setNextActivationTransformMode ( KisToolTransform::TransformToolMode mode)

Definition at line 544 of file kis_tool_transform.cc.

References KisTool::mode(), and nextActivationTransformMode.

◆ setRotateX

void KisToolTransform::setRotateX ( double rotation)
slot

Definition at line 702 of file kis_tool_transform.cc.

703{
704 m_currentArgs.setAX( rotation );
705}

References m_currentArgs, and ToolTransformArgs::setAX().

◆ setRotateY

void KisToolTransform::setRotateY ( double rotation)
slot

Definition at line 707 of file kis_tool_transform.cc.

708{
709 m_currentArgs.setAY( rotation );
710}

References m_currentArgs, and ToolTransformArgs::setAY().

◆ setRotateZ

void KisToolTransform::setRotateZ ( double rotation)
slot

Definition at line 712 of file kis_tool_transform.cc.

713{
714 m_currentArgs.setAZ( rotation );
715}

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 679 of file kis_tool_transform.cc.

680{
682
683 if( mode != m_currentArgs.mode() ) {
684 if( newMode == FreeTransformMode ) {
686 } else if( newMode == WarpTransformMode ) {
688 } else if( newMode == CageTransformMode ) {
690 } else if( newMode == LiquifyTransformMode ) {
692 } else if( newMode == PerspectiveTransformMode ) {
694 } else if( newMode == MeshTransformMode ) {
696 }
697
698 Q_EMIT transformModeChanged();
699 }
700}
void transformModeChanged()

References CageTransformMode, FreeTransformMode, LiquifyTransformMode, m_currentArgs, m_optionsWidget, MeshTransformMode, KisTool::mode(), ToolTransformArgs::mode(), PerspectiveTransformMode, KisToolTransformConfigWidget::slotSetCageModeButtonClicked(), KisToolTransformConfigWidget::slotSetFreeTransformModeButtonClicked(), KisToolTransformConfigWidget::slotSetLiquifyModeButtonClicked(), KisToolTransformConfigWidget::slotSetMeshModeButtonClicked(), KisToolTransformConfigWidget::slotSetPerspectiveModeButtonClicked(), KisToolTransformConfigWidget::slotSetWarpModeButtonClicked(), toArgsMode(), transformModeChanged(), and WarpTransformMode.

◆ setTranslateX

◆ setTranslateY

◆ setWarpFlexibility

void KisToolTransform::setWarpFlexibility ( double flexibility)
slot

Definition at line 734 of file kis_tool_transform.cc.

735{
736 m_currentArgs.setAlpha( flexibility );
737}
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 615 of file kis_tool_transform.cc.

616{
617 return m_currentArgs.shearX();
618}

References m_currentArgs, and ToolTransformArgs::shearX().

◆ shearY()

double KisToolTransform::shearY ( ) const

Definition at line 620 of file kis_tool_transform.cc.

621{
622 return m_currentArgs.shearY();
623}

References m_currentArgs, and ToolTransformArgs::shearY().

◆ slotApplyTransform

void KisToolTransform::slotApplyTransform ( )
privateslot

Definition at line 1246 of file kis_tool_transform.cc.

1247{
1248 KisCursorOverrideLock cursorLock(KisCursor::waitCursor());
1249 endStroke();
1250}

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 245 of file kis_tool_transform.cc.

246{
247 if (!m_strokeId || strokeStrategyCookie != m_strokeStrategyCookie) return;
248 QPolygonF hullF = hull;
255 if (hullF.boundingRect() == m_transaction.originalRect()) {
259 } else {
260 warnTools << "WARNING: KisToolTransform: calculated convex hull's bounds "
261 "differ from the bounding rect of the source clip. It shouldn't "
262 "have happened";
263 }
264}
#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 1335 of file kis_tool_transform.cc.

1336{
1337 commitChanges();
1338}

References commitChanges().

◆ slotGlobalConfigChanged

void KisToolTransform::slotGlobalConfigChanged ( )
protectedslot

Definition at line 204 of file kis_tool_transform.cc.

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

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

◆ slotMoveDiscreteDown

void KisToolTransform::slotMoveDiscreteDown ( )
privateslot

Definition at line 1350 of file kis_tool_transform.cc.

1351{
1353}
void setTranslateY(double translateY)

References setTranslateY(), and translateY.

◆ slotMoveDiscreteDownMore

void KisToolTransform::slotMoveDiscreteDownMore ( )
privateslot

Definition at line 1355 of file kis_tool_transform.cc.

1356{
1357 setTranslateY(translateY()+10.0);
1358}

References setTranslateY(), and translateY.

◆ slotMoveDiscreteLeft

void KisToolTransform::slotMoveDiscreteLeft ( )
privateslot

Definition at line 1360 of file kis_tool_transform.cc.

1361{
1363}
void setTranslateX(double translateX)

References setTranslateX(), and translateX.

◆ slotMoveDiscreteLeftMore

void KisToolTransform::slotMoveDiscreteLeftMore ( )
privateslot

Definition at line 1365 of file kis_tool_transform.cc.

1366{
1367 setTranslateX(translateX()-10.0);
1368}

References setTranslateX(), and translateX.

◆ slotMoveDiscreteRight

void KisToolTransform::slotMoveDiscreteRight ( )
privateslot

Definition at line 1370 of file kis_tool_transform.cc.

1371{
1373}

References setTranslateX(), and translateX.

◆ slotMoveDiscreteRightMore

void KisToolTransform::slotMoveDiscreteRightMore ( )
privateslot

Definition at line 1375 of file kis_tool_transform.cc.

1376{
1377 setTranslateX(translateX()+10.0);
1378}

References setTranslateX(), and translateX.

◆ slotMoveDiscreteUp

void KisToolTransform::slotMoveDiscreteUp ( )
privateslot

Definition at line 1340 of file kis_tool_transform.cc.

1341{
1343}

References setTranslateY(), and translateY.

◆ slotMoveDiscreteUpMore

void KisToolTransform::slotMoveDiscreteUpMore ( )
privateslot

Definition at line 1345 of file kis_tool_transform.cc.

1346{
1347 setTranslateY(translateY()-10.0);
1348}

References setTranslateY(), and translateY.

◆ slotPreviewDeviceGenerated

void KisToolTransform::slotPreviewDeviceGenerated ( KisPaintDeviceSP device)
privateslot

Definition at line 1093 of file kis_tool_transform.cc.

1094{
1095 if (device && device->exactBounds().isEmpty()) {
1096 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
1097 KIS_SAFE_ASSERT_RECOVER(kisCanvas) { cancelStroke(); return; }
1098 kisCanvas->viewManager()->
1099 showFloatingMessage(
1100 i18nc("floating message in transformation tool",
1101 "Cannot transform empty layer "),
1102 QIcon(), 1000, KisFloatingMessage::Medium);
1103
1104 cancelStroke();
1105 } else {
1106 initThumbnailImage(device);
1108 }
1109}
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 1252 of file kis_tool_transform.cc.

1253{
1255 const ToolTransformArgs::TransformMode previousMode = config->mode();
1256 config->setMode(mode);
1257
1259 config->setWarpCalculation(KisWarpTransformWorker::WarpCalculation::GRID);
1260 }
1261
1262 if (!m_strokeId || m_transaction.rootNodes().isEmpty()) return;
1263
1266
1276 const bool transformDiffers = !m_currentArgs.continuedTransform()->isSameMode(m_currentArgs);
1277
1278 if (transformDiffers &&
1279 m_currentArgs.continuedTransform()->mode() == savedMode) {
1280
1284
1285 } else {
1286 cancelStroke();
1287 startStroke(savedMode, true);
1288
1290 }
1291 } else {
1297
1298 } else {
1299 cancelStroke();
1301
1302 }
1303 }
1304}
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
#define KIS_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:97

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 1323 of file kis_tool_transform.cc.

1324{
1325 if (!m_strokeId || m_transaction.rootNodes().isEmpty()) return;
1326
1327 KisNodeSP root = m_transaction.rootNodes()[0];
1328 KIS_ASSERT_RECOVER_RETURN(root); // the stroke is guaranteed to be started by an 'if' above
1329
1331 endStroke();
1332 startStroke(savedArgs.mode(), false);
1333}
#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 1311 of file kis_tool_transform.cc.

1312{
1313 if (!m_strokeId || m_transaction.rootNodes().isEmpty()) return;
1314
1315 KisNodeSP root = m_transaction.rootNodes()[0];
1316 KIS_ASSERT_RECOVER_RETURN(root); // the stroke is guaranteed to be started by an 'if' above
1317
1319 cancelStroke();
1320 startStroke(savedArgs.mode(), true);
1321}

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 1134 of file kis_tool_transform.cc.

1135{
1136 const ToolTransformArgs *newArgs = dynamic_cast<const ToolTransformArgs*>(status.data());
1138
1139 *m_transaction.currentConfig() = *newArgs;
1140
1141 slotUiChangedConfig(true);
1143}
#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 1050 of file kis_tool_transform.cc.

1051{
1052 if (!m_strokeId || strokeStrategyCookie != m_strokeStrategyCookie) return;
1053
1054 if (transaction.transformedNodes().isEmpty() ||
1055 transaction.originalRect().isEmpty()) {
1056
1057 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
1058 KIS_ASSERT(kisCanvas);
1059 kisCanvas->viewManager()->
1060 showFloatingMessage(
1061 i18nc("floating message in transformation tool",
1062 "Cannot transform empty layer "),
1063 QIcon(), 1000, KisFloatingMessage::Medium);
1064
1065 cancelStroke();
1066 return;
1067 }
1068
1069 m_transaction = transaction;
1070 m_currentArgs = args;
1072
1075 }
1076
1078 commitChanges();
1079
1081
1083 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
1084 KIS_ASSERT(kisCanvas);
1085 kisCanvas->viewManager()->
1086 showFloatingMessage(
1087 i18nc("floating message in transformation tool",
1088 "Invisible sublayers will also be transformed. Lock layers if you do not want them to be transformed "),
1089 QIcon(), 4000, KisFloatingMessage::Low);
1090 }
1091}
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 1405 of file kis_tool_transform.cc.

1406{
1408}
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 903 of file kis_tool_transform.cc.

904{
905 Q_ASSERT(!m_strokeId);
906
909
910 // set up and null checks before we do anything
911 KisResourcesSnapshotSP resources =
912 new KisResourcesSnapshot(image(), currentNode(), this->canvas()->resourceManager(), 0, selectedNodes(), 0);
913 KisNodeList rootNodes = resources->selectedNodes();
914 //Filter out any nodes that might be children of other selected nodes so they aren't used twice
917
920
921 Q_FOREACH (KisNodeSP currentNode, resources->selectedNodes()) {
922 if (!currentNode || !currentNode->isEditable()) return;
923
924 // some layer types cannot be transformed. Give a message and return if a user tries it
925 if (currentNode->inherits("KisColorizeMask") ||
926 currentNode->inherits("KisFileLayer") ||
927 currentNode->inherits("KisCloneLayer")) {
928
929 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
930 KIS_ASSERT(kisCanvas);
931
932 if(currentNode->inherits("KisColorizeMask")){
933 kisCanvas->viewManager()->
934 showFloatingMessage(
935 i18nc("floating message in transformation tool",
936 "Layer type cannot use the transform tool"),
937 koIcon("object-locked"), 4000, KisFloatingMessage::High);
938 }
939 else{
940 kisCanvas->viewManager()->
941 showFloatingMessage(
942 i18nc("floating message in transformation tool",
943 "Layer type cannot use the transform tool. Use transform mask instead."),
944 koIcon("object-locked"), 4000, KisFloatingMessage::High);
945 }
946 return;
947 }
948
949 KisNodeSP impossibleMask =
951 [currentNode] (KisNodeSP node) {
952 // we can process transform masks of the first level
953 if (node == currentNode || node->parent() == currentNode) return false;
954
955 return node->inherits("KisTransformMask") && node->visible(true);
956 });
957
958 if (impossibleMask) {
959 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
960 kisCanvas->viewManager()->
961 showFloatingMessage(
962 i18nc("floating message in transformation tool",
963 "Layer has children with transform masks. Please disable them before doing transformation."),
964 koIcon("object-locked"), 8000, KisFloatingMessage::High);
965 return;
966 }
967
972 if (selection && dynamic_cast<KisTransformMask*>(currentNode.data())) {
973 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
974 kisCanvas->viewManager()->
975 showFloatingMessage(
976 i18nc("floating message in transformation tool",
977 "Selections are not used when editing transform masks "),
978 QIcon(), 4000, KisFloatingMessage::Low);
979
980 selection = 0;
981 }
982 }
983 // Overlay preview is never used when transforming an externally provided image
985
986 KisStrokeStrategy *strategy = 0;
987
989 TransformStrokeStrategy *transformStrategy = new TransformStrokeStrategy(mode, m_currentArgs.filterId(), forceReset, rootNodes, selection, image().data(), image().data());
990 connect(transformStrategy, SIGNAL(sigPreviewDeviceReady(KisPaintDeviceSP)), SLOT(slotPreviewDeviceGenerated(KisPaintDeviceSP)));
991 connect(transformStrategy, SIGNAL(sigTransactionGenerated(TransformTransactionProperties, ToolTransformArgs, void*)), SLOT(slotTransactionGenerated(TransformTransactionProperties, ToolTransformArgs, void*)));
992 connect(transformStrategy, SIGNAL(sigConvexHullCalculated(QPolygon, void*)), SLOT(slotConvexHullCalculated(QPolygon, void*)));
993 strategy = transformStrategy;
994
995 // save unique identifier of the stroke so we could
996 // recognize it when sigTransactionGenerated() is
997 // received (theoretically, the user can start two
998 // strokes at the same time, if he is quick enough)
999 m_strokeStrategyCookie = transformStrategy;
1000
1001 } else {
1002 InplaceTransformStrokeStrategy *transformStrategy = new InplaceTransformStrokeStrategy(mode, m_currentArgs.filterId(), forceReset, rootNodes, selection, externalSource, image().data(), image().data(), image()->root(), m_forceLodMode);
1003 connect(transformStrategy, SIGNAL(sigTransactionGenerated(TransformTransactionProperties, ToolTransformArgs, void*)), SLOT(slotTransactionGenerated(TransformTransactionProperties, ToolTransformArgs, void*)));
1004 connect(transformStrategy, SIGNAL(sigConvexHullCalculated(QPolygon, void*)), SLOT(slotConvexHullCalculated(QPolygon, void*)));
1005 strategy = transformStrategy;
1006
1007 // save unique identifier of the stroke so we could
1008 // recognize it when sigTransactionGenerated() is
1009 // received (theoretically, the user can start two
1010 // strokes at the same time, if he is quick enough)
1011 m_strokeStrategyCookie = transformStrategy;
1012 }
1013
1014 m_strokeId = image()->startStroke(strategy);
1015
1018 }
1019
1021
1023}
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(), 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().

◆ toArgsMode()

◆ transformMode()

◆ transformModeChanged

void KisToolTransform::transformModeChanged ( )
signal

◆ translateX()

double KisToolTransform::translateX ( ) const

Definition at line 580 of file kis_tool_transform.cc.

581{
582 return m_currentArgs.transformedCenter().x();
583}
QPointF transformedCenter() const

References m_currentArgs, and ToolTransformArgs::transformedCenter().

◆ translateY()

double KisToolTransform::translateY ( ) const

Definition at line 585 of file kis_tool_transform.cc.

586{
587 return m_currentArgs.transformedCenter().y();
588}

References m_currentArgs, and ToolTransformArgs::transformedCenter().

◆ updateApplyResetAvailability()

void KisToolTransform::updateApplyResetAvailability ( )
private

◆ updateOptionWidget

void KisToolTransform::updateOptionWidget ( )
slot

Definition at line 1209 of file kis_tool_transform.cc.

1210{
1211 if (!m_optionsWidget) return;
1212
1213 if (!currentNode()) {
1214 m_optionsWidget->setEnabled(false);
1215 return;
1216 }
1217 else {
1218 m_optionsWidget->setEnabled(true);
1220 }
1221}
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 639 of file kis_tool_transform.cc.

640{
641 return m_currentArgs.alpha();
642}

References ToolTransformArgs::alpha(), and m_currentArgs.

◆ warpPointDensity()

int KisToolTransform::warpPointDensity ( ) const

Definition at line 644 of file kis_tool_transform.cc.

645{
646 return m_currentArgs.numPoints();
647}

References m_currentArgs, and ToolTransformArgs::numPoints().

◆ warpTransformChanged

void KisToolTransform::warpTransformChanged ( )
signal

◆ warpType()

Member Data Documentation

◆ applyTransformation

KisAction* KisToolTransform::applyTransformation {0}
private

Definition at line 294 of file kis_tool_transform.h.

294{0};

◆ cageAction

KisAction* KisToolTransform::cageAction {0}
private

Definition at line 291 of file kis_tool_transform.h.

291{0};

◆ freeTransformAction

KisAction* KisToolTransform::freeTransformAction {0}
private

Definition at line 292 of file kis_tool_transform.h.

292{0};

◆ keepAspectRatioAction

KisAction* KisToolTransform::keepAspectRatioAction {0}
private

Definition at line 302 of file kis_tool_transform.h.

302{0};

◆ liquifyAction

KisAction* KisToolTransform::liquifyAction {0}
private

Definition at line 290 of file kis_tool_transform.h.

290{0};

◆ m_actionConnections

KisSignalAutoConnectionsStore KisToolTransform::m_actionConnections
private

Definition at line 283 of file kis_tool_transform.h.

◆ m_actuallyMoveWhileSelected

bool KisToolTransform::m_actuallyMoveWhileSelected {false}
private

Definition at line 266 of file kis_tool_transform.h.

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

◆ m_asyncUpdateHelper

KisAsynchronousStrokeUpdateHelper KisToolTransform::m_asyncUpdateHelper
private

Definition at line 324 of file kis_tool_transform.h.

◆ m_cageStrategy

QScopedPointer<KisCageTransformStrategy> KisToolTransform::m_cageStrategy
private

Definition at line 315 of file kis_tool_transform.h.

◆ m_canvas

QPointer<KisCanvas2> KisToolTransform::m_canvas
private

Definition at line 279 of file kis_tool_transform.h.

◆ m_changesTracker

KisToolChangesTracker KisToolTransform::m_changesTracker
private

Definition at line 282 of file kis_tool_transform.h.

◆ m_contextMenu

QScopedPointer<QMenu> KisToolTransform::m_contextMenu
private

Definition at line 238 of file kis_tool_transform.h.

◆ m_currentArgs

ToolTransformArgs KisToolTransform::m_currentArgs
private

Definition at line 260 of file kis_tool_transform.h.

◆ m_currentlyUsingOverlayPreviewStyle

bool KisToolTransform::m_currentlyUsingOverlayPreviewStyle {false}
private

Definition at line 271 of file kis_tool_transform.h.

271{false};

◆ m_cursorOutline

QPainterPath KisToolTransform::m_cursorOutline
private

Definition at line 322 of file kis_tool_transform.h.

◆ m_externalSourceForNextActivation

KisPaintDeviceSP KisToolTransform::m_externalSourceForNextActivation
private

Definition at line 264 of file kis_tool_transform.h.

◆ m_forceLodMode

bool KisToolTransform::m_forceLodMode {false}
private

Definition at line 273 of file kis_tool_transform.h.

273{false};

◆ m_freeStrategy

QScopedPointer<KisFreeTransformStrategy> KisToolTransform::m_freeStrategy
private

Definition at line 318 of file kis_tool_transform.h.

◆ m_liquifyStrategy

QScopedPointer<KisLiquifyTransformStrategy> KisToolTransform::m_liquifyStrategy
private

Definition at line 316 of file kis_tool_transform.h.

◆ m_meshStrategy

QScopedPointer<KisMeshTransformStrategy> KisToolTransform::m_meshStrategy
private

Definition at line 317 of file kis_tool_transform.h.

◆ m_optionsWidget

KisToolTransformConfigWidget* KisToolTransform::m_optionsWidget {0}
private

Definition at line 278 of file kis_tool_transform.h.

278{0};

◆ m_perspectiveStrategy

QScopedPointer<KisPerspectiveTransformStrategy> KisToolTransform::m_perspectiveStrategy
private

Definition at line 319 of file kis_tool_transform.h.

◆ m_preferOverlayPreviewStyle

bool KisToolTransform::m_preferOverlayPreviewStyle {false}
private

Definition at line 272 of file kis_tool_transform.h.

272{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 312 of file kis_tool_transform.h.

◆ m_selectedPortionCache

KisPaintDeviceSP KisToolTransform::m_selectedPortionCache
private

Definition at line 268 of file kis_tool_transform.h.

◆ m_selectionPath

QPainterPath KisToolTransform::m_selectionPath
private

Definition at line 276 of file kis_tool_transform.h.

◆ m_strokeId

KisStrokeId KisToolTransform::m_strokeId
private

Definition at line 269 of file kis_tool_transform.h.

◆ m_strokeStrategyCookie

void* KisToolTransform::m_strokeStrategyCookie {0}
private

Definition at line 270 of file kis_tool_transform.h.

270{0};

◆ m_transaction

TransformTransactionProperties KisToolTransform::m_transaction
private

Definition at line 281 of file kis_tool_transform.h.

◆ m_warpStrategy

QScopedPointer<KisWarpTransformStrategy> KisToolTransform::m_warpStrategy
private

Definition at line 314 of file kis_tool_transform.h.

◆ meshAction

KisAction* KisToolTransform::meshAction {0}
private

Definition at line 289 of file kis_tool_transform.h.

289{0};

◆ mirrorHorizontalAction

KisAction* KisToolTransform::mirrorHorizontalAction {0}
private

Definition at line 298 of file kis_tool_transform.h.

298{0};

◆ mirrorVerticalAction

KisAction* KisToolTransform::mirrorVerticalAction {0}
private

Definition at line 299 of file kis_tool_transform.h.

299{0};

◆ nextActivationTransformMode

TransformToolMode KisToolTransform::nextActivationTransformMode {FreeTransformMode}
private

Definition at line 285 of file kis_tool_transform.h.

◆ perspectiveAction

KisAction* KisToolTransform::perspectiveAction {0}
private

Definition at line 293 of file kis_tool_transform.h.

293{0};

◆ resetTransformation

KisAction* KisToolTransform::resetTransformation {0}
private

Definition at line 295 of file kis_tool_transform.h.

295{0};

◆ rotateNinetyCCWAction

KisAction* KisToolTransform::rotateNinetyCCWAction {0}
private

Definition at line 301 of file kis_tool_transform.h.

301{0};

◆ rotateNinetyCWAction

KisAction* KisToolTransform::rotateNinetyCWAction {0}
private

Definition at line 300 of file kis_tool_transform.h.

300{0};

◆ warpAction

KisAction* KisToolTransform::warpAction {0}
private

actions for the context click menu

Definition at line 288 of file kis_tool_transform.h.

288{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: