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

#include <kis_tool.h>

+ Inheritance diagram for KisTool:

Public Types

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 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 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

virtual void activateAlternateAction (AlternateAction action)
 
virtual void activatePrimaryAction ()
 
virtual bool alternateActionSupportsHiResEvents (AlternateAction action) const
 
virtual void beginAlternateAction (KoPointerEvent *event, AlternateAction action)
 
virtual void beginAlternateDoubleClickAction (KoPointerEvent *event, AlternateAction action)
 
virtual void beginPrimaryAction (KoPointerEvent *event)
 
virtual void beginPrimaryDoubleClickAction (KoPointerEvent *event)
 
virtual void continueAlternateAction (KoPointerEvent *event, AlternateAction action)
 
virtual void continuePrimaryAction (KoPointerEvent *event)
 
virtual void deactivateAlternateAction (AlternateAction action)
 
virtual void deactivatePrimaryAction ()
 
void deleteSelection () override
 
virtual void endAlternateAction (KoPointerEvent *event, AlternateAction action)
 
virtual void endPrimaryAction (KoPointerEvent *event)
 
virtual int flags () const
 
bool isActive () const
 
 KisTool (KoCanvasBase *canvas, const QCursor &cursor)
 
void mouseDoubleClickEvent (KoPointerEvent *event) override
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mousePressEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
void mouseTripleClickEvent (KoPointerEvent *event) override
 
virtual void newActivationWithExternalSource (KisPaintDeviceSP externalSource)
 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.
 
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 void paint (QPainter &painter, const KoViewConverter &converter)=0
 
virtual bool paste ()
 
virtual QMenu * popupActionsMenu ()
 
virtual KisPopupWidgetInterfacepopupWidget ()
 
virtual bool selectAll ()
 selectAll select all data the tool can select.
 
virtual KoToolSelectionselection ()
 
Q_INVOKABLE QString toolId () const
 
virtual bool wantsAutoScroll () const
 
 ~KoToolBase () override
 

Static Public Member Functions

static AlternateAction actionToAlternateAction (ToolAction action)
 

Public Attributes

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

enum  ToolMode : int {
  HOVER_MODE , PAINT_MODE , SECONDARY_PAINT_MODE , MIRROR_AXIS_SETUP_MODE ,
  GESTURE_MODE , PAN_MODE , OTHER , OTHER_1
}
 

Protected Slots

virtual void resetCursorStyle ()
 

Protected Member Functions

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)
 
QWidget * createOptionWidget () override
 
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)
 

Properties

bool isActive
 

Private Attributes

Private *const d
 

Friends

class KisToolPaintingInformationBuilder
 

Additional Inherited Members

- Protected Attributes inherited from KoToolBase
KoToolBasePrivated_ptr
 

Detailed Description

Definition at line 63 of file kis_tool.cc.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
FLAG_USES_CUSTOM_PRESET 
FLAG_USES_CUSTOM_COMPOSITEOP 
FLAG_USES_CUSTOM_SIZE 

Definition at line 47 of file kis_tool.h.

@ FLAG_USES_CUSTOM_SIZE
Definition kis_tool.h:47
@ FLAG_USES_CUSTOM_COMPOSITEOP
Definition kis_tool.h:47
@ FLAG_USES_CUSTOM_PRESET
Definition kis_tool.h:47

◆ AlternateAction

Enumerator
ChangeSize 
ChangeSizeSnap 
SampleFgNode 
SampleBgNode 
SampleFgImage 
SampleBgImage 
Secondary 
Third 
Fourth 
Fifth 
NONE 

Definition at line 134 of file kis_tool.h.

134 {
135 ChangeSize = AlternateChangeSize, // Default: Shift+Left click
136 ChangeSizeSnap = AlternateChangeSizeSnap, // Default: Shift+Z+Left click
137 SampleFgNode = AlternateSampleFgNode, // Default: Ctrl+Alt+Left click
138 SampleBgNode = AlternateSampleBgNode, // Default: Ctrl+Alt+Right click
139 SampleFgImage = AlternateSampleFgImage, // Default: Ctrl+Left click
140 SampleBgImage = AlternateSampleBgImage, // Default: Ctrl+Right click
145 NONE = 10000
146 };
@ AlternateFourth
Definition kis_tool.h:127
@ AlternateSampleFgImage
Definition kis_tool.h:123
@ AlternateChangeSize
Definition kis_tool.h:119
@ AlternateSecondary
Definition kis_tool.h:125
@ AlternateSampleBgNode
Definition kis_tool.h:122
@ AlternateSampleBgImage
Definition kis_tool.h:124
@ AlternateThird
Definition kis_tool.h:126
@ AlternateSampleFgNode
Definition kis_tool.h:121
@ AlternateChangeSizeSnap
Definition kis_tool.h:120
@ AlternateFifth
Definition kis_tool.h:128
@ SampleFgImage
Definition kis_tool.h:139
@ SampleFgNode
Definition kis_tool.h:137
@ ChangeSizeSnap
Definition kis_tool.h:136
@ Secondary
Definition kis_tool.h:141
@ SampleBgImage
Definition kis_tool.h:140
@ SampleBgNode
Definition kis_tool.h:138
@ ChangeSize
Definition kis_tool.h:135

◆ NodePaintAbility

Enumerator
VECTOR 
CLONE 
PAINT 
UNPAINTABLE 
MYPAINTBRUSH_UNPAINTABLE 

Definition at line 148 of file kis_tool.h.

148 {
149 VECTOR,
150 CLONE,
151 PAINT,
154 };
@ MYPAINTBRUSH_UNPAINTABLE
Definition kis_tool.h:153
@ UNPAINTABLE
Definition kis_tool.h:152

◆ ToolAction

Enumerator
Primary 
AlternateChangeSize 
AlternateChangeSizeSnap 
AlternateSampleFgNode 
AlternateSampleBgNode 
AlternateSampleFgImage 
AlternateSampleBgImage 
AlternateSecondary 
AlternateThird 
AlternateFourth 
AlternateFifth 
Alternate_NONE 

Definition at line 117 of file kis_tool.h.

◆ ToolMode

enum KisTool::ToolMode : int
protected
Enumerator
HOVER_MODE 
PAINT_MODE 
SECONDARY_PAINT_MODE 
MIRROR_AXIS_SETUP_MODE 
GESTURE_MODE 
PAN_MODE 
OTHER 
OTHER_1 

Definition at line 298 of file kis_tool.h.

298 : int {
304 PAN_MODE,
305 OTHER, // tool-specific modes, like multibrush's symmetry axis setup
306 OTHER_1
307 };
@ SECONDARY_PAINT_MODE
Definition kis_tool.h:301
@ GESTURE_MODE
Definition kis_tool.h:303
@ MIRROR_AXIS_SETUP_MODE
Definition kis_tool.h:302
@ PAINT_MODE
Definition kis_tool.h:300
@ OTHER_1
Definition kis_tool.h:306
@ PAN_MODE
Definition kis_tool.h:304
@ HOVER_MODE
Definition kis_tool.h:299

Constructor & Destructor Documentation

◆ KisTool()

KisTool::KisTool ( KoCanvasBase * canvas,
const QCursor & cursor )

Definition at line 78 of file kis_tool.cc.

80 , d(new Private)
81{
82 d->cursor = cursor;
83
84 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(resetCursorStyle()));
85 connect(this, SIGNAL(isActiveChanged(bool)), SLOT(resetCursorStyle()));
86}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static KisConfigNotifier * instance()
void isActiveChanged(bool isActivated)
virtual void resetCursorStyle()
Definition kis_tool.cc:613
Private *const d
Definition kis_tool.h:321
QCursor cursor
Definition kis_tool.cc:64
KisCanvas2 * canvas

References connect(), cursor, d, KisConfigNotifier::instance(), isActiveChanged(), and resetCursorStyle().

◆ ~KisTool()

KisTool::~KisTool ( )
override

Definition at line 88 of file kis_tool.cc.

89{
90 delete d;
91}

References d.

Member Function Documentation

◆ actionToAlternateAction()

KisTool::AlternateAction KisTool::actionToAlternateAction ( ToolAction action)
static

Definition at line 416 of file kis_tool.cc.

416 {
418 return (AlternateAction)action;
419}
QAction * action(const QString &name) const
#define KIS_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:85
AlternateAction
Definition kis_tool.h:134

References KoToolBase::action(), KIS_ASSERT_RECOVER_RETURN_VALUE, Primary, and Secondary.

◆ activate

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

Definition at line 93 of file kis_tool.cc.

94{
96
98
99 if (!canvas()) return;
100 if (!canvas()->resourceManager()) return;
101
102
103 d->currentFgColor = canvas()->resourceManager()->resource(KoCanvasResource::ForegroundColor).value<KoColor>();
104 d->currentBgColor = canvas()->resourceManager()->resource(KoCanvasResource::BackgroundColor).value<KoColor>();
105
107 d->currentPattern = canvas()->resourceManager()->resource(KoCanvasResource::CurrentPattern).value<KoPatternSP>();
108 }
109
111 d->currentGradient = canvas()->resourceManager()->resource(KoCanvasResource::CurrentGradient).value<KoAbstractGradientSP>();
112 }
113
115 if (preset && preset->settings()) {
116 preset->settings()->activate();
117 }
118
120 d->currentExposure = static_cast<float>(canvas()->resourceManager()->resource(KoCanvasResource::HdrExposure).toDouble());
121 }
122
125 }
126
127 d->m_isActive = true;
128 Q_EMIT isActiveChanged(true);
129}
QPointer< KoCanvasResourceProvider > resourceManager
virtual void activate(const QSet< KoShape * > &shapes)
@ BackgroundColor
The active background color selected for this canvas.
@ ForegroundColor
The active foreground color selected for this canvas.

References KoToolBase::activate(), KoCanvasResource::BackgroundColor, Private::canvas, KoCanvasResource::CurrentGeneratorConfiguration, KoCanvasResource::CurrentGradient, KoCanvasResource::CurrentPaintOpPreset, KoCanvasResource::CurrentPattern, d, KoCanvasResource::ForegroundColor, KoCanvasResource::HdrExposure, isActiveChanged(), resetCursorStyle(), and KoCanvasBase::resourceManager.

◆ activateAlternateAction()

◆ activatePrimaryAction()

void KisTool::activatePrimaryAction ( )
virtual

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 in KisToolPaint, KisToolColorSampler, KisDynamicDelegatedTool< KisToolShape >, KisToolLazyBrush, KisToolSmartPatch, and KisToolTransform.

Definition at line 421 of file kis_tool.cc.

422{
424}

References resetCursorStyle().

◆ alternateActionSupportsHiResEvents()

bool KisTool::alternateActionSupportsHiResEvents ( AlternateAction action) const
virtual

Reimplemented in KisToolSelectOutline.

Definition at line 489 of file kis_tool.cc.

490{
491 Q_UNUSED(action);
492 return false;
493}

References KoToolBase::action().

◆ beginAlternateAction()

◆ beginAlternateDoubleClickAction()

void KisTool::beginAlternateDoubleClickAction ( KoPointerEvent * event,
AlternateAction action )
virtual

Reimplemented in KisToolEncloseAndFill.

Definition at line 472 of file kis_tool.cc.

473{
475}
virtual void beginAlternateAction(KoPointerEvent *event, AlternateAction action)
Definition kis_tool.cc:466

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

◆ beginPrimaryAction()

void KisTool::beginPrimaryAction ( KoPointerEvent * event)
virtual

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 in KisToolFreehand, KisToolPolylineBase, KisToolRectangleBase, KisToolSelectBase< __KisToolSelectEllipticalLocal >, KisToolSelectBase< __KisToolSelectOutlineLocal >, KisToolSelectBase< __KisToolSelectPolygonalLocal >, KisToolSelectBase< __KisToolSelectRectangularLocal >, KisToolOutlineBase, KisAssistantTool, KisToolColorSampler, KisToolFill, KisToolGradient, KisToolLine, KisToolMeasure, KisToolMove, KisToolMultihand, KisToolPan, KisToolCrop, KisToolDyna, KisToolEncloseAndFill, KisDynamicDelegatedTool< KisToolShape >, KisToolBasicBrushBase, KisToolLazyBrush, KisToolSmartPatch, and KisToolTransform.

Definition at line 431 of file kis_tool.cc.

432{
433 Q_UNUSED(event);
434}

◆ beginPrimaryDoubleClickAction()

void KisTool::beginPrimaryDoubleClickAction ( KoPointerEvent * event)
virtual

The same as beginPrimaryAction(), but called when the stroke is started by a double-click

See also
beginPrimaryAction()

Reimplemented in KisToolPolylineBase, KisToolCrop, and KisDynamicDelegatedTool< KisToolShape >.

Definition at line 436 of file kis_tool.cc.

437{
438 beginPrimaryAction(event);
439}
virtual void beginPrimaryAction(KoPointerEvent *event)
Definition kis_tool.cc:431

References beginPrimaryAction().

◆ blockUntilOperationsFinished()

bool KisTool::blockUntilOperationsFinished ( )
protected

Definition at line 632 of file kis_tool.cc.

633{
634 KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
635 KisViewManager* viewManager = kiscanvas->viewManager();
636 return viewManager->blockUntilOperationsFinished(image());
637}
KisViewManager * viewManager() const
bool blockUntilOperationsFinished(KisImageSP image)
blockUntilOperationsFinished blocks the GUI of the application until execution of actions on image is...
KisImageWSP image() const
Definition kis_tool.cc:332

References KisViewManager::blockUntilOperationsFinished(), Private::canvas, image(), and KisCanvas2::viewManager().

◆ blockUntilOperationsFinishedForced()

void KisTool::blockUntilOperationsFinishedForced ( )
protected

Definition at line 639 of file kis_tool.cc.

640{
641 KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
642 KisViewManager* viewManager = kiscanvas->viewManager();
644}
void blockUntilOperationsFinishedForced(KisImageSP image)
blockUntilOperationsFinished blocks the GUI of the application until execution of actions on image is...

References KisViewManager::blockUntilOperationsFinishedForced(), Private::canvas, image(), and KisCanvas2::viewManager().

◆ canvasResourceChanged

void KisTool::canvasResourceChanged ( int key,
const QVariant & res )
overrideslot

Definition at line 139 of file kis_tool.cc.

140{
141 switch (key) {
143 d->currentFgColor = v.value<KoColor>();
144 break;
146 d->currentBgColor = v.value<KoColor>();
147 break;
149 d->currentPattern = v.value<KoPatternSP>();
150 break;
152 d->currentGradient = v.value<KoAbstractGradientSP>();
153 break;
155 d->currentExposure = static_cast<float>(v.toDouble());
156 break;
158 d->currentGenerator = static_cast<KisFilterConfiguration*>(v.value<void *>());
159 break;
162 break;
163 default:
164 break; // Do nothing
165 };
166}
qreal v

References KoCanvasResource::BackgroundColor, KoCanvasResource::CurrentGeneratorConfiguration, KoCanvasResource::CurrentGradient, KoCanvasResource::CurrentKritaNode, KoCanvasResource::CurrentPattern, d, KoCanvasResource::ForegroundColor, KoCanvasResource::HdrExposure, resetCursorStyle(), and v.

◆ continueAlternateAction()

◆ continuePrimaryAction()

◆ convertDocumentToWidget()

QPointF KisTool::convertDocumentToWidget ( const QPointF & pt)
protected

Definition at line 181 of file kis_tool.cc.

182{
183 KisCanvas2 *kritaCanvas = dynamic_cast<KisCanvas2*>(canvas());
184 Q_ASSERT(kritaCanvas);
185
186 return kritaCanvas->coordinatesConverter()->documentToWidget(pt);
187}
KisCoordinatesConverter * coordinatesConverter
_Private::Traits< T >::Result documentToWidget(const T &obj) const

References Private::canvas, KisCanvas2::coordinatesConverter, and KisCoordinatesConverter::documentToWidget().

◆ convertToImagePixelCoordFloored()

QPoint KisTool::convertToImagePixelCoordFloored ( KoPointerEvent * e)
protected

Convert from native (postscript points) to integer image pixel coordinates. This rounds down (not truncate) the pixel coordinates and should be used in preference to QPointF::toPoint(), which rounds, to ensure the cursor acts on the pixel it is visually over.

Definition at line 236 of file kis_tool.cc.

237{
238 if (!image())
239 return e->point.toPoint();
240
242}
QPoint documentToImagePixelFloored(const QPointF &documentCoord) const
QPointF point
The point in document coordinates.

References KisImage::documentToImagePixelFloored(), image(), and KoPointerEvent::point.

◆ convertToPixelCoord() [1/2]

QPointF KisTool::convertToPixelCoord ( const QPointF & pt)
protected

Definition at line 197 of file kis_tool.cc.

198{
199 if (!image())
200 return pt;
201
202 return image()->documentToPixel(pt);
203}
QPointF documentToPixel(const QPointF &documentCoord) const

References KisImage::documentToPixel(), and image().

◆ convertToPixelCoord() [2/2]

QPointF KisTool::convertToPixelCoord ( KoPointerEvent * e)
protected

Convert from native (postscript points) to image pixel coordinates.

Definition at line 189 of file kis_tool.cc.

190{
191 if (!image())
192 return e->point;
193
194 return image()->documentToPixel(e->point);
195}

References KisImage::documentToPixel(), image(), and KoPointerEvent::point.

◆ convertToPixelCoordAndAlignOnWidget()

QPointF KisTool::convertToPixelCoordAndAlignOnWidget ( const QPointF & pt)
protected

Definition at line 205 of file kis_tool.cc.

206{
207 KisCanvas2 *canvas2 = dynamic_cast<KisCanvas2 *>(canvas());
208 KIS_ASSERT(canvas2);
209 const KisCoordinatesConverter *converter = canvas2->coordinatesConverter();
210 const QPointF imagePos = converter->widgetToImage(QPointF(converter->documentToWidget(pt).toPoint()));
211 return imagePos;
212}
_Private::Traits< T >::Result widgetToImage(const T &obj) const
#define KIS_ASSERT(cond)
Definition kis_assert.h:33

References Private::canvas, KisCanvas2::coordinatesConverter, KisCoordinatesConverter::documentToWidget(), KIS_ASSERT, and KisCoordinatesConverter::widgetToImage().

◆ convertToPixelCoordAndSnap() [1/2]

QPointF KisTool::convertToPixelCoordAndSnap ( const QPointF & pt,
const QPointF & offset = QPointF() )
protected

Definition at line 225 of file kis_tool.cc.

226{
227 if (!image())
228 return pt;
229
230 KoSnapGuide *snapGuide = canvas()->snapGuide();
231 QPointF pos = snapGuide->snap(pt, offset, Qt::NoModifier);
232
233 return image()->documentToPixel(pos);
234}
KoSnapGuide * snapGuide
QPointF snap(const QPointF &mousePosition, Qt::KeyboardModifiers modifiers)
snaps the mouse position, returns if mouse was snapped

References Private::canvas, KisImage::documentToPixel(), image(), KoSnapGuide::snap(), and KoCanvasBase::snapGuide.

◆ convertToPixelCoordAndSnap() [2/2]

QPointF KisTool::convertToPixelCoordAndSnap ( KoPointerEvent * e,
const QPointF & offset = QPointF(),
bool useModifiers = true )
protected

Definition at line 214 of file kis_tool.cc.

215{
216 if (!image())
217 return e->point;
218
219 KoSnapGuide *snapGuide = canvas()->snapGuide();
220 QPointF pos = snapGuide->snap(e->point, offset, useModifiers ? e->modifiers() : Qt::NoModifier);
221
222 return image()->documentToPixel(pos);
223}
Qt::KeyboardModifiers modifiers() const

References Private::canvas, KisImage::documentToPixel(), image(), KoPointerEvent::modifiers(), KoPointerEvent::point, KoSnapGuide::snap(), and KoCanvasBase::snapGuide.

◆ convertToPt() [1/2]

QRectF KisTool::convertToPt ( const QRectF & rect)
protected

Definition at line 252 of file kis_tool.cc.

253{
254 if (!image())
255 return rect;
256 QRectF r;
257 //We add 1 in the following to the extreme coords because a pixel always has size
258 r.setCoords(int(rect.left()) / image()->xRes(), int(rect.top()) / image()->yRes(),
259 int(rect.right()) / image()->xRes(), int( rect.bottom()) / image()->yRes());
260 return r;
261}

References image().

◆ convertToPt() [2/2]

qreal KisTool::convertToPt ( qreal value)
protected

Definition at line 263 of file kis_tool.cc.

264{
265 const qreal avgResolution = 0.5 * (image()->xRes() + image()->yRes());
266 return value / avgResolution;
267}
float value(const T *src, size_t ch)
double xRes() const
double yRes() const

References image(), value(), KisImage::xRes(), and KisImage::yRes().

◆ createOptionWidget()

QWidget * KisTool::createOptionWidget ( )
overrideprotectedvirtual

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

Reimplemented from KoToolBase.

Reimplemented in KisToolPaint, KisToolSelectBase< __KisToolSelectEllipticalLocal >, KisToolSelectBase< __KisToolSelectOutlineLocal >, KisToolSelectBase< __KisToolSelectPolygonalLocal >, KisToolSelectBase< __KisToolSelectRectangularLocal >, KisToolShape, KisToolBrush, KisToolColorSampler, KisToolFill, KisToolGradient, KisToolLine, KisToolMeasure, KisToolMove, KisToolMultihand, KisToolCrop, KisToolDyna, KisToolEncloseAndFill, KisToolLazyBrush, KisToolPolyline, KisToolSmartPatch, and KisToolTransform.

Definition at line 578 of file kis_tool.cc.

579{
580 d->optionWidget = new QLabel(i18n("No options"));
581 d->optionWidget->setObjectName("SpecialSpacer");
582 return d->optionWidget;
583}

References d.

◆ currentBgColor()

KoColor KisTool::currentBgColor ( )
protected

◆ currentFgColor()

KoColor KisTool::currentFgColor ( )
protected

◆ currentGenerator()

KisFilterConfigurationSP KisTool::currentGenerator ( )
protected

◆ currentGradient()

KoAbstractGradientSP KisTool::currentGradient ( )
protected

◆ currentImage()

KisImageWSP KisTool::currentImage ( )
protected

Definition at line 393 of file kis_tool.cc.

394{
395 return image();
396}

References image().

◆ currentNode()

KisNodeSP KisTool::currentNode ( ) const
protected

◆ currentPaintOpPreset()

KisPaintOpPresetSP KisTool::currentPaintOpPreset ( )
protected

Definition at line 359 of file kis_tool.cc.

360{
362 if (v.isNull()) {
363 return 0;
364 }
365 else {
366 return v.value<KisPaintOpPresetSP>();
367 }
368}

References Private::canvas, KoCanvasResource::CurrentPaintOpPreset, KoCanvasBase::resourceManager, and v.

◆ currentPattern()

KoPatternSP KisTool::currentPattern ( )
protected

◆ cursor()

QCursor KisTool::cursor ( ) const
protected

◆ deactivate

void KisTool::deactivate ( )
overrideslot

Definition at line 131 of file kis_tool.cc.

132{
133 d->m_isActive = false;
134 Q_EMIT isActiveChanged(false);
135
137}
virtual void deactivate()

References d, KoToolBase::deactivate(), and isActiveChanged().

◆ deactivateAlternateAction()

◆ deactivatePrimaryAction()

void KisTool::deactivatePrimaryAction ( )
virtual

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 in KisToolPaint, KisToolColorSampler, KisDynamicDelegatedTool< KisToolShape >, KisToolLazyBrush, KisToolSmartPatch, and KisToolTransform.

Definition at line 426 of file kis_tool.cc.

427{
429}

References resetCursorStyle().

◆ deleteSelection()

void KisTool::deleteSelection ( )
overridevirtual

Delete the tools selection. The default implementation is empty to aid tools that don't have any selection.

See also
selection()

Reimplemented from KoToolBase.

Definition at line 525 of file kis_tool.cc.

526{
527 KisResourcesSnapshotSP resources =
528 new KisResourcesSnapshot(image(), currentNode(), this->canvas()->resourceManager(), 0, selectedNodes());
529
531 return;
532 }
533
534 if (!KisToolUtils::clearImage(image(), resources->selectedNodes(), resources->activeSelection())) {
536 }
537}
The KisResourcesSnapshot class takes a snapshot of the various resources like colors and settings use...
KisNodeList selectedNodes() const
KisSelectionSP activeSelection() const
virtual void deleteSelection()
bool clearImage(KisImageSP image, KisNodeList nodes, KisSelectionSP selection)
KisNodeList selectedNodes() const
Definition kis_tool.cc:376
KisNodeSP currentNode() const
Definition kis_tool.cc:370
bool blockUntilOperationsFinished()
Definition kis_tool.cc:632

References KisResourcesSnapshot::activeSelection(), blockUntilOperationsFinished(), Private::canvas, KisToolUtils::clearImage(), currentNode(), KoToolBase::deleteSelection(), image(), KisResourcesSnapshot::selectedNodes(), and selectedNodes().

◆ endAlternateAction()

◆ endPrimaryAction()

◆ flags()

virtual int KisTool::flags ( ) const
inlinevirtual

Reimplemented in KisToolFreehand, KisToolPaint, KisToolShape, KisToolEncloseAndFill, and KisToolSmartPatch.

Definition at line 52 of file kis_tool.h.

52{ return 0; }

◆ image()

KisImageWSP KisTool::image ( ) const
protected

Definition at line 332 of file kis_tool.cc.

333{
334 // For now, krita tools only work in krita, not for a krita shape. Krita shapes are for 2.1
335 KisCanvas2 * kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
336 if (kisCanvas) {
337 return kisCanvas->currentImage();
338 }
339
340 return 0;
341
342}
KisImageWSP currentImage() const

References Private::canvas, and KisCanvas2::currentImage().

◆ isActive()

bool KisTool::isActive ( ) const

Definition at line 646 of file kis_tool.cc.

647{
648 return d->m_isActive;
649}

References d.

◆ isActiveChanged

void KisTool::isActiveChanged ( bool isActivated)
signal

◆ listeningToModifiers()

bool KisTool::listeningToModifiers ( )
protectedvirtual

To determine whether this tool will change its behavior when modifier keys are pressed

Reimplemented in KisDynamicDelegatedTool< KisToolShape >.

Definition at line 714 of file kis_tool.cc.

715{
716 return false;
717}

◆ listenToModifiers()

void KisTool::listenToModifiers ( bool listen)
protectedvirtual

Request that this tool no longer listen to modifier keys (Responding to the request is optional)

Reimplemented in KisDynamicDelegatedTool< KisToolShape >.

Definition at line 709 of file kis_tool.cc.

710{
711 Q_UNUSED(listen);
712}

◆ mode()

KisTool::ToolMode KisTool::mode ( ) const
protectedvirtual

Reimplemented in KisDynamicDelegatedTool< KisToolShape >.

Definition at line 407 of file kis_tool.cc.

407 {
408 return d->m_mode;
409}

References d.

◆ mouseDoubleClickEvent()

void KisTool::mouseDoubleClickEvent ( KoPointerEvent * event)
overridevirtual

Called when (one of) the mouse or stylus buttons is double clicked. Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this mouse or stylus press

Reimplemented from KoToolBase.

Definition at line 500 of file kis_tool.cc.

501{
502 Q_UNUSED(event);
503}

◆ mouseMoveEvent()

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

Implements KoToolBase.

Reimplemented in KisToolCrop, KisToolTransform, KisToolFreehand, KisToolPaint, KisToolPolylineBase, KisToolSelectBase< __KisToolSelectEllipticalLocal >, KisToolSelectBase< __KisToolSelectOutlineLocal >, KisToolSelectBase< __KisToolSelectPolygonalLocal >, KisToolSelectBase< __KisToolSelectRectangularLocal >, KisToolOutlineBase, KisToolColorSampler, KisToolMove, KisToolMultihand, and KisToolBasicBrushBase.

Definition at line 520 of file kis_tool.cc.

521{
522 Q_UNUSED(event);
523}

◆ mousePressEvent()

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

Implements KoToolBase.

Reimplemented in KisToolTransform, and KisToolPaint.

Definition at line 510 of file kis_tool.cc.

511{
512 Q_UNUSED(event);
513}

◆ mouseReleaseEvent()

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

Implements KoToolBase.

Reimplemented in KisToolTransform, and KisToolPaint.

Definition at line 515 of file kis_tool.cc.

516{
517 Q_UNUSED(event);
518}

◆ mouseTripleClickEvent()

void KisTool::mouseTripleClickEvent ( KoPointerEvent * event)
overridevirtual

Called when (one of) the mouse or stylus buttons is triple clicked. Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this mouse or stylus press

Reimplemented from KoToolBase.

Definition at line 505 of file kis_tool.cc.

506{
508}
void mouseDoubleClickEvent(KoPointerEvent *event) override
Definition kis_tool.cc:500

References mouseDoubleClickEvent().

◆ newActivationWithExternalSource()

void KisTool::newActivationWithExternalSource ( KisPaintDeviceSP externalSource)
virtual

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 in KisDynamicDelegatedTool< KisToolShape >, and KisToolTransform.

Definition at line 573 of file kis_tool.cc.

574{
575 Q_UNUSED(externalSource);
576}

◆ nodeEditable()

bool KisTool::nodeEditable ( )
protected

Checks checks if the current node is editable.

Definition at line 651 of file kis_tool.cc.

652{
653 KisNodeSP node = currentNode();
654 if (!node) {
655 return false;
656 }
657
658 if (!currentPaintOpPreset()) {
659 return false;
660 }
661
662 bool blockedNoIndirectPainting = false;
663
664 const bool presetUsesIndirectPainting =
665 !currentPaintOpPreset()->settings()->paintIncremental();
666
667 if (!presetUsesIndirectPainting) {
668 const KisIndirectPaintingSupport *indirectPaintingLayer =
669 dynamic_cast<const KisIndirectPaintingSupport*>(node.data());
670 if (indirectPaintingLayer) {
671 blockedNoIndirectPainting = !indirectPaintingLayer->supportsNonIndirectPainting();
672 }
673 }
674
675 bool nodeEditable = node->isEditable() && !blockedNoIndirectPainting;
676
677 if (!nodeEditable) {
678 KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
679 QString message;
680 if (!node->visible() && node->userLocked()) {
681 message = i18n("Layer is locked and invisible.");
682 } else if (node->userLocked()) {
683 message = i18n("Layer is locked.");
684 } else if(!node->visible()) {
685 message = i18n("Layer is invisible.");
686 } else if (blockedNoIndirectPainting) {
687 message = i18n("Layer can be painted in Wash Mode only.");
688 } else {
689 message = i18n("Group not editable.");
690 }
691 kiscanvas->viewManager()->showFloatingMessage(message, KisIconUtils::loadIcon("object-locked"));
692 }
693 return nodeEditable;
694}
void showFloatingMessage(const QString &message, const QIcon &icon, int timeout=4500, KisFloatingMessage::Priority priority=KisFloatingMessage::Medium, int alignment=Qt::AlignCenter|Qt::TextWordWrap)
shows a floating message in the top right corner of the canvas
QIcon loadIcon(const QString &name)
bool isEditable(bool checkVisibility=true) const
bool userLocked() const
virtual bool visible(bool recursive=false) const
bool nodeEditable()
Checks checks if the current node is editable.
Definition kis_tool.cc:651
KisPaintOpPresetSP currentPaintOpPreset()
Definition kis_tool.cc:359

References Private::canvas, currentNode(), currentPaintOpPreset(), KisSharedPtr< T >::data(), KisBaseNode::isEditable(), KisIconUtils::loadIcon(), nodeEditable(), KisViewManager::showFloatingMessage(), KisIndirectPaintingSupport::supportsNonIndirectPainting(), KisBaseNode::userLocked(), KisCanvas2::viewManager(), and KisBaseNode::visible().

◆ nodePaintAbility()

KisTool::NodePaintAbility KisTool::nodePaintAbility ( )

Definition at line 539 of file kis_tool.cc.

540{
541 KisNodeSP node = currentNode();
542
543 if (canvas()->resourceManager()->resource(KoCanvasResource::CurrentPaintOpPreset).isNull()) {
545 }
546
547 if (!node) {
549 }
550
551 if (node->inherits("KisShapeLayer")) {
553 }
554 if (node->inherits("KisCloneLayer")) {
556 }
557 if (node->paintDevice()) {
558
560 if (currentPaintOpPreset->paintOp().id() == "mypaintbrush") {
561 const KoColorSpace *colorSpace = node->paintDevice()->colorSpace();
562 if (colorSpace->colorModelId() != RGBAColorModelID) {
564 }
565 }
566
568 }
569
571}
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
const KoColorSpace * colorSpace() const
virtual KoID colorModelId() const =0
virtual KisPaintDeviceSP paintDevice() const =0

References Private::canvas, CLONE, KoColorSpace::colorModelId(), KisPaintDevice::colorSpace(), currentNode(), KoCanvasResource::CurrentPaintOpPreset, currentPaintOpPreset(), MYPAINTBRUSH_UNPAINTABLE, PAINT, KisBaseNode::paintDevice(), KoCanvasBase::resourceManager, RGBAColorModelID, UNPAINTABLE, and VECTOR.

◆ overrideCursorIfNotEditable()

bool KisTool::overrideCursorIfNotEditable ( )
protected

Override the cursor appropriately if current node is not editable.

Definition at line 618 of file kis_tool.cc.

619{
620 // override cursor for canvas iff this tool is active
621 // and we can't paint on the active layer
622 if (isActive()) {
623 KisNodeSP node = currentNode();
624 if (node && !node->isEditable()) {
625 canvas()->setCursor(Qt::ForbiddenCursor);
626 return true;
627 }
628 }
629 return false;
630}
void setCursor(const QCursor &cursor) override
bool isActive
Definition kis_tool.h:44

References Private::canvas, currentNode(), isActive, KisBaseNode::isEditable(), and KisCanvas2::setCursor().

◆ paintToolOutline()

void KisTool::paintToolOutline ( QPainter * painter,
const KisOptimizedBrushOutline & path )
protected

paint the path which is in view coordinates, default paint mode is XOR_MODE, BW_MODE is also possible never apply transformations to the painter, they would be useless, if drawing in OpenGL mode. The coordinates in the path should be in view coordinates.

Definition at line 589 of file kis_tool.cc.

590{
591 KisOpenGLCanvas2 *canvasWidget = dynamic_cast<KisOpenGLCanvas2 *>(canvas()->canvasWidget());
592 if (canvasWidget) {
593 painter->beginNativePainting();
594 canvasWidget->paintToolOutline(path, decorationThickness());
595 painter->endNativePainting();
596 }
597 else {
598 painter->save();
599 painter->setCompositionMode(QPainter::RasterOp_SourceXorDestination);
600 QPen p = QColor(128, 255, 128);
601 p.setCosmetic(true);
602 p.setWidth(decorationThickness());
603 painter->setPen(p);
604
605 for (auto it = path.begin(); it != path.end(); ++it) {
606 painter->drawPolyline(*it);
607 }
608
609 painter->restore();
610 }
611}
const Params2D p
KisAbstractCanvasWidget * canvasWidget
void paintToolOutline(const KisOptimizedBrushOutline &path, int thickness=1)
int decorationThickness() const
decorationThickness The minimum thickness for tool decoration lines, this is derived from the screen ...

References Private::canvas, KisCanvas2::canvasWidget, KoToolBase::decorationThickness(), p, and KisOpenGLCanvas2::paintToolOutline().

◆ pixelToView() [1/6]

KisOptimizedBrushOutline KisTool::pixelToView ( const KisOptimizedBrushOutline & path) const
protected

Definition at line 304 of file kis_tool.cc.

305{
306 KisCanvas2 *canvas2 = dynamic_cast<KisCanvas2 *>(canvas());
307 KIS_ASSERT(canvas2);
308 const KisCoordinatesConverter *coordsConverter = canvas2->coordinatesConverter();
309 return path.mapped(coordsConverter->imageToDocumentTransform() * coordsConverter->documentToFlakeTransform());
310}

References Private::canvas, KisCanvas2::coordinatesConverter, KisCoordinatesConverter::documentToFlakeTransform(), KisCoordinatesConverter::imageToDocumentTransform(), and KIS_ASSERT.

◆ pixelToView() [2/6]

QPainterPath KisTool::pixelToView ( const QPainterPath & pixelPath) const
protected

Convert a pixel path into a view path.

Definition at line 295 of file kis_tool.cc.

296{
297 QTransform matrix;
298 qreal zoomX, zoomY;
299 canvas()->viewConverter()->zoom(&zoomX, &zoomY);
300 matrix.scale(zoomX/image()->xRes(), zoomY/ image()->yRes());
301 return matrix.map(pixelPolygon);
302}
const KoViewConverter * viewConverter() const override
virtual void zoom(qreal *zoomX, qreal *zoomY) const

References Private::canvas, image(), KisCanvas2::viewConverter(), and KoViewConverter::zoom().

◆ pixelToView() [3/6]

QPointF KisTool::pixelToView ( const QPoint & pixelCoord) const
protected

Convert an integer pixel coordinate into a view coordinate. The view coordinate is at the centre of the pixel.

Definition at line 269 of file kis_tool.cc.

270{
271 if (!image())
272 return pixelCoord;
273 QPointF documentCoord = image()->pixelToDocument(pixelCoord);
274 return canvas()->viewConverter()->documentToView(documentCoord);
275}
QPointF pixelToDocument(const QPointF &pixelCoord) const
virtual QPointF documentToView(const QPointF &documentPoint) const

References Private::canvas, KoViewConverter::documentToView(), image(), KisImage::pixelToDocument(), and KisCanvas2::viewConverter().

◆ pixelToView() [4/6]

QPointF KisTool::pixelToView ( const QPointF & pixelCoord) const
protected

Convert a floating point pixel coordinate into a view coordinate.

Definition at line 277 of file kis_tool.cc.

278{
279 if (!image())
280 return pixelCoord;
281 QPointF documentCoord = image()->pixelToDocument(pixelCoord);
282 return canvas()->viewConverter()->documentToView(documentCoord);
283}

References Private::canvas, KoViewConverter::documentToView(), image(), KisImage::pixelToDocument(), and KisCanvas2::viewConverter().

◆ pixelToView() [5/6]

QPolygonF KisTool::pixelToView ( const QPolygonF & pixelPolygon) const
protected

Convert a pixel polygon into a view path.

Definition at line 313 of file kis_tool.cc.

314{
315 QTransform matrix;
316 qreal zoomX, zoomY;
317 canvas()->viewConverter()->zoom(&zoomX, &zoomY);
318 matrix.scale(zoomX/image()->xRes(), zoomY/ image()->yRes());
319 return matrix.map(pixelPath);
320}

References Private::canvas, image(), KisCanvas2::viewConverter(), and KoViewConverter::zoom().

◆ pixelToView() [6/6]

QRectF KisTool::pixelToView ( const QRectF & pixelRect) const
protected

Convert a pixel rectangle into a view rectangle.

Definition at line 285 of file kis_tool.cc.

286{
287 if (!image()) {
288 return pixelRect;
289 }
290 QPointF topLeft = pixelToView(pixelRect.topLeft());
291 QPointF bottomRight = pixelToView(pixelRect.bottomRight());
292 return {topLeft, bottomRight};
293}
QPointF pixelToView(const QPoint &pixelCoord) const
Definition kis_tool.cc:269

References image(), and pixelToView().

◆ primaryActionSupportsHiResEvents()

bool KisTool::primaryActionSupportsHiResEvents ( ) const
virtual

Returns true if the tool can handle (and wants to handle) a very tight flow of input events from the tablet

Reimplemented in KisToolFreehand, KisToolLine, KisToolSelectOutline, and KisDynamicDelegatedTool< KisToolShape >.

Definition at line 451 of file kis_tool.cc.

452{
453 return false;
454}

◆ resetCursorStyle

void KisTool::resetCursorStyle ( )
protectedvirtualslot

Called whenever the configuration settings change.

Reimplemented in KisToolSelectElliptical, KisToolSelectOutline, KisToolSelectPolygonal, and KisToolSelectRectangular.

Definition at line 613 of file kis_tool.cc.

614{
615 useCursor(d->cursor);
616}
void useCursor(const QCursor &cursor)

References d, and KoToolBase::useCursor().

◆ selectedNodes()

KisNodeList KisTool::selectedNodes ( ) const
protected

Definition at line 376 of file kis_tool.cc.

377{
378 KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
379 KisViewManager* viewManager = kiscanvas->viewManager();
380 return viewManager->nodeManager()->selectedNodes();
381}
KisNodeList selectedNodes()
KisNodeManager * nodeManager() const
The node manager handles everything about nodes.

References Private::canvas, KisViewManager::nodeManager(), KisNodeManager::selectedNodes(), and KisCanvas2::viewManager().

◆ selectionEditable()

bool KisTool::selectionEditable ( )
protected

Checks checks if the selection is editable, only applies to local selection as global selection is always editable.

Definition at line 696 of file kis_tool.cc.

697{
698 KisCanvas2 * kisCanvas = static_cast<KisCanvas2*>(canvas());
699 KisViewManager * view = kisCanvas->viewManager();
700
701 bool editable = view->selectionEditable();
702 if (!editable) {
703 KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
704 kiscanvas->viewManager()->showFloatingMessage(i18n("Local selection is locked."), KisIconUtils::loadIcon("object-locked"));
705 }
706 return editable;
707}
bool selectionEditable()
Checks if the current global or local selection is editable.

References Private::canvas, KisIconUtils::loadIcon(), KisViewManager::selectionEditable(), KisViewManager::showFloatingMessage(), and KisCanvas2::viewManager().

◆ setCursor()

void KisTool::setCursor ( const QCursor & cursor)
protected

Definition at line 411 of file kis_tool.cc.

412{
413 d->cursor = cursor;
414}

References cursor, and d.

◆ setMode()

void KisTool::setMode ( ToolMode mode)
protectedvirtual

Reimplemented in KisToolPaint.

Definition at line 403 of file kis_tool.cc.

403 {
404 d->m_mode = mode;
405}
virtual ToolMode mode() const
Definition kis_tool.cc:407

References d, and mode().

◆ supportsPaintingAssistants()

bool KisTool::supportsPaintingAssistants ( ) const
virtual

Reimplemented in KisToolFreehand, KisToolEllipse, KisToolLine, KisToolRectangle, KisToolPolygon, and KisToolPolyline.

Definition at line 495 of file kis_tool.cc.

496{
497 return false;
498}

◆ updateCanvasPixelRect()

void KisTool::updateCanvasPixelRect ( const QRectF & pixelRect)
protected

Update the canvas for the given rectangle in image pixel coordinates.

Definition at line 322 of file kis_tool.cc.

323{
324 canvas()->updateCanvas(convertToPt(pixelRect));
325}
void updateCanvas(const QRectF &rc) override
QRectF convertToPt(const QRectF &rect)
Definition kis_tool.cc:252

References Private::canvas, convertToPt(), and KisCanvas2::updateCanvas().

◆ updateCanvasViewRect()

void KisTool::updateCanvasViewRect ( const QRectF & viewRect)
protected

Update the canvas for the given rectangle in view coordinates.

Definition at line 327 of file kis_tool.cc.

328{
329 canvas()->updateCanvas(canvas()->viewConverter()->viewToDocument(viewRect));
330}

References Private::canvas, and KisCanvas2::updateCanvas().

◆ updateSettingsViews

void KisTool::updateSettingsViews ( )
virtualslot

Definition at line 168 of file kis_tool.cc.

169{
170}

◆ viewToPixel()

QPointF KisTool::viewToPixel ( const QPointF & viewCoord) const
protected

Definition at line 244 of file kis_tool.cc.

245{
246 if (!image())
247 return viewCoord;
248
249 return image()->documentToPixel(canvas()->viewConverter()->viewToDocument(viewCoord));
250}

References Private::canvas, KisImage::documentToPixel(), and image().

◆ widgetCenterInWidgetPixels()

QPointF KisTool::widgetCenterInWidgetPixels ( )
protected

Definition at line 172 of file kis_tool.cc.

173{
174 KisCanvas2 *kritaCanvas = dynamic_cast<KisCanvas2*>(canvas());
175 Q_ASSERT(kritaCanvas);
176
177 const KisCoordinatesConverter *converter = kritaCanvas->coordinatesConverter();
178 return converter->flakeToWidget(converter->flakeCenterPoint());
179}
_Private::Traits< T >::Result flakeToWidget(const T &obj) const

References Private::canvas, KisCanvas2::coordinatesConverter, KisCoordinatesConverter::flakeCenterPoint(), and KisCoordinatesConverter::flakeToWidget().

Friends And Related Symbol Documentation

◆ KisToolPaintingInformationBuilder

friend class KisToolPaintingInformationBuilder
friend

Definition at line 204 of file kis_tool.h.

Member Data Documentation

◆ currentBgColor

KoColor KisTool::currentBgColor

Definition at line 70 of file kis_tool.cc.

◆ currentExposure

float KisTool::currentExposure {1.0}

Definition at line 71 of file kis_tool.cc.

71{1.0};

◆ currentFgColor

KoColor KisTool::currentFgColor

Definition at line 69 of file kis_tool.cc.

◆ currentGenerator

KisFilterConfigurationSP KisTool::currentGenerator

Definition at line 72 of file kis_tool.cc.

◆ currentGradient

KoAbstractGradientSP KisTool::currentGradient

Definition at line 68 of file kis_tool.cc.

◆ currentPattern

KoPatternSP KisTool::currentPattern

Definition at line 67 of file kis_tool.cc.

◆ cursor

QCursor KisTool::cursor

Definition at line 64 of file kis_tool.cc.

◆ d

Private* const KisTool::d
private

Definition at line 321 of file kis_tool.h.

◆ m_isActive

bool KisTool::m_isActive {false}

Definition at line 75 of file kis_tool.cc.

75{false};

◆ m_mode

ToolMode KisTool::m_mode {HOVER_MODE}

Definition at line 74 of file kis_tool.cc.

◆ optionWidget

QWidget* KisTool::optionWidget {0}

Definition at line 73 of file kis_tool.cc.

73{0};

Property Documentation

◆ isActive

bool KisTool::isActive
read

Definition at line 44 of file kis_tool.h.


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