Krita Source Code Documentation
Loading...
Searching...
No Matches
KisToolOutlineBase Class Referenceabstract

#include <KisToolOutlineBase.h>

+ Inheritance diagram for KisToolOutlineBase:

Public Types

enum  ToolType { PAINT , SELECT }
 
- 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 deactivate () override
 
void requestStrokeCancellation () override
 
void requestStrokeEnd () override
 
void undoLastPoint ()
 
- Public Slots inherited from KisToolShape
void activate (const QSet< KoShape * > &shapes) override
 
virtual void fillSettingChanged (int value)
 
virtual void outlineSettingChanged (int value)
 
virtual void patternRotationSettingChanged (qreal value)
 
virtual void patternScaleSettingChanged (qreal value)
 
- Public Slots inherited from KisToolPaint
void activate (const QSet< KoShape * > &shapes) override
 
void deactivate () override
 
- 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 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 ()
 

Public Member Functions

void beginPrimaryAction (KoPointerEvent *event) override
 
void continuePrimaryAction (KoPointerEvent *event) override
 
void endPrimaryAction (KoPointerEvent *event) override
 
bool eventFilter (QObject *obj, QEvent *event) override
 
bool hasUserInteractionRunning () const
 
void keyPressEvent (QKeyEvent *event) override
 
void keyReleaseEvent (QKeyEvent *event) override
 
 KisToolOutlineBase (KoCanvasBase *canvas, ToolType type, const QCursor &cursor=KisCursor::load("tool_outline_selection_cursor.png", 6, 6))
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void paint (QPainter &gc, const KoViewConverter &converter) override
 
KisPopupWidgetInterfacepopupWidget () override
 
 ~KisToolOutlineBase () override
 
- Public Member Functions inherited from KisToolShape
int flags () const override
 
 KisToolShape (KoCanvasBase *canvas, const QCursor &cursor)
 
 ~KisToolShape () override
 
- Public Member Functions inherited from KisToolPaint
 KisToolPaint (KoCanvasBase *canvas, const QCursor &cursor)
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mousePressEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
KisPopupWidgetInterfacepopupWidget () override
 
 ~KisToolPaint () 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
 
bool isActive () const
 
 KisTool (KoCanvasBase *canvas, const QCursor &cursor)
 
void mouseDoubleClickEvent (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
 
 KoToolBase (KoCanvasBase *canvas)
 
bool maskSyntheticEvents () const
 
QList< QPointer< QWidget > > optionWidgets ()
 
virtual bool paste ()
 
virtual QMenu * popupActionsMenu ()
 
virtual bool selectAll ()
 selectAll select all data the tool can select.
 
virtual KoToolSelectionselection ()
 
Q_INVOKABLE QString toolId () const
 
virtual bool wantsAutoScroll () const
 
 ~KoToolBase () override
 

Protected Member Functions

virtual void finishOutline (const QVector< QPointF > &points)=0
 
- Protected Member Functions inherited from KisToolShape
void addPathShape (KoPathShape *pathShape, const KUndo2MagicString &name)
 
void addShape (KoShape *shape)
 
virtual void beginShape ()
 
QWidget * createOptionWidget () override
 
qreal currentStrokeWidth () const
 
virtual void endShape ()
 
KisToolShapeUtils::FillStyle fillStyle ()
 
QTransform fillTransform ()
 
ShapeAddInfo shouldAddShape (KisNodeSP currentNode) const
 
KisToolShapeUtils::StrokeStyle strokeStyle ()
 
- Protected Member Functions inherited from KisToolPaint
void activateAlternateAction (AlternateAction action) override
 
void activatePrimaryAction () override
 
void addOptionWidgetLayout (QLayout *layout)
 Add the tool-specific layout to the default option widget layout.
 
virtual void addOptionWidgetOption (QWidget *control, QWidget *label=nullptr)
 Add a widget and a label to the current option widget layout.
 
void beginAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void canvasResourceChanged (int key, const QVariant &v) override
 
void continueAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void deactivateAlternateAction (AlternateAction action) override
 
void deactivatePrimaryAction () override
 
void enableControl (QWidget *control, bool value)
 
void endAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
virtual KisOptimizedBrushOutline getOutlinePath (const QPointF &documentPos, const KoPointerEvent *event, KisPaintOpSettings::OutlineMode outlineMode)
 
bool isEraser () const
 
bool isOutlineEnabled () const
 
bool isOutlineVisible () const
 
void paint (QPainter &gc, const KoViewConverter &converter) override
 
virtual QString quickHelp () const
 
virtual void requestUpdateOutline (const QPointF &outlineDocPoint, const KoPointerEvent *event)
 
void setMode (ToolMode mode) override
 
void setOutlineEnabled (bool enabled)
 
void setOutlineVisible (bool visible)
 
void setSupportOutline (bool supportOutline)
 
void showControl (QWidget *control, bool value)
 
- 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)
 
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)
 

Private Member Functions

void cancelStroke ()
 
QRectF dragBoundingRect ()
 
void endStroke ()
 
void installBlockActionGuard ()
 
void uninstallBlockActionGuard ()
 
void updateCanvas ()
 
void updateContinuedMode ()
 
void updateFeedback ()
 

Private Attributes

QScopedPointer< KisInputActionGroupsMaskGuardm_blockModifyingActionsGuard
 
bool m_continuedMode
 
bool m_hasUserInteractionRunning
 
QPointF m_lastCursorPos
 
int m_numberOfContinuedModePoints
 
QPainterPath m_paintPath
 
QVector< QPointF > m_points
 
ToolType m_type
 

Static Private Attributes

static constexpr int FEEDBACK_LINE_WIDTH {2}
 

Additional Inherited Members

- Signals inherited from KisToolPaint
void sigPaintingFinished ()
 
- 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)
 
- Static Public Member Functions inherited from KisTool
static AlternateAction actionToAlternateAction (ToolAction action)
 
- Public Attributes inherited from KisToolShape
WdgGeometryOptionsm_shapeOptionsWidget
 
- 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 Slots inherited from KisTool
virtual void resetCursorStyle ()
 
- Protected Attributes inherited from KisToolShape
KConfigGroup m_configGroup
 
- Protected Attributes inherited from KisToolPaint
KisOptimizedBrushOutline m_currentOutline
 
QRectF m_oldColorPreviewUpdateRect
 
QRectF m_oldOutlineRect
 
QPointF m_outlineDocPoint
 
bool m_paintOutline {false}
 
- Protected Attributes inherited from KoToolBase
KoToolBasePrivated_ptr
 
- Properties inherited from KisTool
bool isActive
 

Detailed Description

Definition at line 18 of file KisToolOutlineBase.h.

Member Enumeration Documentation

◆ ToolType

Enumerator
PAINT 
SELECT 

Definition at line 23 of file KisToolOutlineBase.h.

Constructor & Destructor Documentation

◆ KisToolOutlineBase()

KisToolOutlineBase::KisToolOutlineBase ( KoCanvasBase * canvas,
ToolType type,
const QCursor & cursor = KisCursor::load("tool_outline_selection_cursor.png", 6, 6) )

Definition at line 25 of file KisToolOutlineBase.cpp.

27 , m_continuedMode(false)
28 , m_type(type)
31{}
KisToolShape(KoCanvasBase *canvas, const QCursor &cursor)
QCursor cursor
Definition kis_tool.cc:64
KisCanvas2 * canvas

◆ ~KisToolOutlineBase()

KisToolOutlineBase::~KisToolOutlineBase ( )
override

Definition at line 33 of file KisToolOutlineBase.cpp.

34{}

Member Function Documentation

◆ activate

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

Definition at line 73 of file KisToolOutlineBase.cpp.

74{
76 connect(action("undo_polygon_selection"), SIGNAL(triggered()), SLOT(undoLastPoint()), Qt::UniqueConnection);
77
78 KisInputManager *inputManager = (static_cast<KisCanvas2*>(canvas()))->globalInputManager();
79 if (inputManager) {
80 inputManager->attachPriorityEventFilter(this);
81 }
82}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
Central object to manage canvas input.
void attachPriorityEventFilter(QObject *filter, int priority=0)
attachPriorityEventFilter
void activate(const QSet< KoShape * > &shapes) override
QAction * action(const QString &name) const

References KoToolBase::action(), KisToolShape::activate(), KisInputManager::attachPriorityEventFilter(), Private::canvas, connect(), and undoLastPoint().

◆ beginPrimaryAction()

void KisToolOutlineBase::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.

Reimplemented in KisToolSelectBase< __KisToolSelectOutlineLocal >.

Definition at line 156 of file KisToolOutlineBase.cpp.

157{
158 NodePaintAbility paintability = nodePaintAbility();
159 if ((m_type == PAINT && (!nodeEditable() || paintability == UNPAINTABLE || paintability == KisToolPaint::CLONE || paintability == KisToolPaint::MYPAINTBRUSH_UNPAINTABLE)) || (m_type == SELECT && !selectionEditable())) {
160
161 if (paintability == KisToolPaint::CLONE){
162 KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
163 QString message = i18n("This tool cannot paint on clone layers. Please select a paint or vector layer or mask.");
164 kiscanvas->viewManager()->showFloatingMessage(message, koIcon("object-locked"));
165 }
166
167 if (paintability == KisToolPaint::MYPAINTBRUSH_UNPAINTABLE) {
168 KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
169 QString message = i18n("The MyPaint Brush Engine is not available for this colorspace");
170 kiscanvas->viewManager()->showFloatingMessage(message, koIcon("object-locked"));
171 }
172
173 event->ignore();
174 return;
175 }
176
178
179 if (!m_continuedMode || m_points.isEmpty()) {
181 beginShape();
182 }
183
184 if (m_continuedMode) {
187 } else {
189 m_points.append(convertToPixelCoord(event));
190 }
191}
KisViewManager * viewManager() const
QVector< QPointF > m_points
void setMode(ToolMode mode) override
virtual void beginShape()
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
#define koIcon(name)
Use these macros for icons without any issues.
Definition kis_icon.h:25
QPointF convertToPixelCoord(KoPointerEvent *e)
Definition kis_tool.cc:189
KisTool::NodePaintAbility nodePaintAbility()
Definition kis_tool.cc:539
bool nodeEditable()
Checks checks if the current node is editable.
Definition kis_tool.cc:651
@ PAINT_MODE
Definition kis_tool.h:300
QPointF convertToPixelCoordAndSnap(KoPointerEvent *e, const QPointF &offset=QPointF(), bool useModifiers=true)
Definition kis_tool.cc:214
bool selectionEditable()
Checks checks if the selection is editable, only applies to local selection as global selection is al...
Definition kis_tool.cc:696
NodePaintAbility
Definition kis_tool.h:148
@ MYPAINTBRUSH_UNPAINTABLE
Definition kis_tool.h:153
@ UNPAINTABLE
Definition kis_tool.h:152

References KisToolShape::beginShape(), Private::canvas, KisTool::CLONE, KisTool::convertToPixelCoord(), KisTool::convertToPixelCoordAndSnap(), koIcon, m_continuedMode, m_hasUserInteractionRunning, m_numberOfContinuedModePoints, m_points, m_type, KisTool::MYPAINTBRUSH_UNPAINTABLE, KisTool::nodeEditable(), KisTool::nodePaintAbility(), PAINT, KisTool::PAINT_MODE, SELECT, KisTool::selectionEditable(), KisToolPaint::setMode(), KisViewManager::showFloatingMessage(), KisTool::UNPAINTABLE, and KisCanvas2::viewManager().

◆ cancelStroke()

void KisToolOutlineBase::cancelStroke ( )
private

◆ continuePrimaryAction()

void KisToolOutlineBase::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.

Reimplemented in KisToolSelectBase< __KisToolSelectOutlineLocal >.

Definition at line 193 of file KisToolOutlineBase.cpp.

194{
196
197 QPointF point = convertToPixelCoord(event);
198 m_points.append(point);
200}
#define CHECK_MODE_SANITY_OR_RETURN(_mode)
Definition kis_tool.h:27

References CHECK_MODE_SANITY_OR_RETURN, KisTool::convertToPixelCoord(), m_points, KisTool::PAINT_MODE, and updateFeedback().

◆ deactivate

void KisToolOutlineBase::deactivate ( )
overrideslot

Definition at line 84 of file KisToolOutlineBase.cpp.

85{
87
88 KisCanvas2 * kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
90 kisCanvas->updateCanvas();
91
92 m_continuedMode = false;
93
94 KisInputManager *inputManager = kisCanvas->globalInputManager();
95 if (inputManager) {
96 inputManager->detachPriorityEventFilter(this);
97 }
98
100}
KisInputManager * globalInputManager() const
void updateCanvas(const QRectF &rc) override
void detachPriorityEventFilter(QObject *filter)
detachPriorityEventFilter
virtual void deactivate()
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75

References cancelStroke(), Private::canvas, KoToolBase::deactivate(), KisInputManager::detachPriorityEventFilter(), KisCanvas2::globalInputManager(), KIS_ASSERT_RECOVER_RETURN, m_continuedMode, and KisCanvas2::updateCanvas().

◆ dragBoundingRect()

QRectF KisToolOutlineBase::dragBoundingRect ( )
private

Definition at line 249 of file KisToolOutlineBase.cpp.

250{
251 QRectF updateRect = pixelToView(QRectF(m_points.last(), m_lastCursorPos).normalized());
252 updateRect = kisGrowRect(updateRect, FEEDBACK_LINE_WIDTH);
253 return updateRect;
254}
static constexpr int FEEDBACK_LINE_WIDTH
T kisGrowRect(const T &rect, U offset)
Definition kis_global.h:186
QPointF pixelToView(const QPoint &pixelCoord) const
Definition kis_tool.cc:269

References FEEDBACK_LINE_WIDTH, kisGrowRect(), m_lastCursorPos, m_points, and KisTool::pixelToView().

◆ endPrimaryAction()

void KisToolOutlineBase::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.

Reimplemented in KisToolSelectBase< __KisToolSelectOutlineLocal >.

Definition at line 202 of file KisToolOutlineBase.cpp.

203{
206 if (!m_continuedMode) {
207 // If the event was not originated by the user releasing the button
208 // (for example due to the canvas loosing focus), then we just cancel
209 // the operation. This prevents some issues with shapes being added
210 // after the image was closed while the shape was being made
211 if (event->spontaneous()) {
212 endStroke();
213 } else {
214 cancelStroke();
215 }
216 event->accept();
217 }
218}
bool spontaneous() const
return if this event was spontaneous (see QMouseEvent::spontaneous())

References cancelStroke(), CHECK_MODE_SANITY_OR_RETURN, endStroke(), KisTool::HOVER_MODE, m_continuedMode, KisTool::PAINT_MODE, KisToolPaint::setMode(), and KoPointerEvent::spontaneous().

◆ endStroke()

void KisToolOutlineBase::endStroke ( )
private

◆ eventFilter()

bool KisToolOutlineBase::eventFilter ( QObject * obj,
QEvent * event )
override

Definition at line 109 of file KisToolOutlineBase.cpp.

110{
111 Q_UNUSED(obj);
112
113 if (m_points.isEmpty()) {
114 return false;
115 }
116 if (event->type() == QEvent::MouseButtonPress ||
117 event->type() == QEvent::MouseButtonDblClick) {
118 QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
119 if (mouseEvent->button() == Qt::RightButton) {
121 return true;
122 }
123 } else if (event->type() == QEvent::TabletPress) {
124 QTabletEvent *tabletEvent = static_cast<QTabletEvent*>(event);
125 if (tabletEvent->button() == Qt::RightButton) {
127 return true;
128 }
129 }
130 return false;
131}

References m_points, and undoLastPoint().

◆ finishOutline()

virtual void KisToolOutlineBase::finishOutline ( const QVector< QPointF > & points)
protectedpure virtual

◆ hasUserInteractionRunning()

bool KisToolOutlineBase::hasUserInteractionRunning ( ) const

Definition at line 263 of file KisToolOutlineBase.cpp.

264{
266}

References m_hasUserInteractionRunning.

◆ installBlockActionGuard()

void KisToolOutlineBase::installBlockActionGuard ( )
private

Definition at line 305 of file KisToolOutlineBase.cpp.

306{
308 return;
310 static_cast<KisCanvas2*>(canvas())->inputActionGroupsMaskInterface(),
312 ));
313}
@ ToolInvoactionActionGroup
@ ViewTransformActionGroup
QScopedPointer< KisInputActionGroupsMaskGuard > m_blockModifyingActionsGuard

References Private::canvas, m_blockModifyingActionsGuard, ToolInvoactionActionGroup, and ViewTransformActionGroup.

◆ keyPressEvent()

void KisToolOutlineBase::keyPressEvent ( QKeyEvent * event)
overridevirtual

Called when a key is pressed. Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this key press

Reimplemented from KoToolBase.

Reimplemented in KisToolSelectBase< __KisToolSelectOutlineLocal >.

Definition at line 36 of file KisToolOutlineBase.cpp.

37{
38 // Allow to enter continued mode only if we started drawing the shape
39 if (mode() == PAINT_MODE && event->key() == Qt::Key_Control) {
40 m_continuedMode = true;
42 }
44}
virtual void keyPressEvent(QKeyEvent *event)
virtual ToolMode mode() const
Definition kis_tool.cc:407

References installBlockActionGuard(), KoToolBase::keyPressEvent(), m_continuedMode, KisTool::mode(), and KisTool::PAINT_MODE.

◆ keyReleaseEvent()

void KisToolOutlineBase::keyReleaseEvent ( QKeyEvent * event)
overridevirtual

Called when a key is released Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this key release

Reimplemented from KoToolBase.

Reimplemented in KisToolSelectBase< __KisToolSelectOutlineLocal >.

Definition at line 46 of file KisToolOutlineBase.cpp.

47{
48 if (event->key() == Qt::Key_Control ||
49 !(event->modifiers() & Qt::ControlModifier)) {
50 m_continuedMode = false;
51 if (mode() != PAINT_MODE) {
52 endStroke();
53 }
54 }
56}
virtual void keyReleaseEvent(QKeyEvent *event)

References endStroke(), KoToolBase::keyReleaseEvent(), m_continuedMode, KisTool::mode(), and KisTool::PAINT_MODE.

◆ mouseMoveEvent()

void KisToolOutlineBase::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.

Reimplemented in KisToolSelectBase< __KisToolSelectOutlineLocal >.

Definition at line 58 of file KisToolOutlineBase.cpp.

59{
60 if (m_continuedMode && mode() != PAINT_MODE) {
63 } else {
65 }
66 if (mode() == PAINT_MODE) {
68 }
69
71}
virtual void requestUpdateOutline(const QPointF &outlineDocPoint, const KoPointerEvent *event)
QPointF point
The point in document coordinates.
virtual void mouseMoveEvent(KoPointerEvent *event)=0

References KisTool::convertToPixelCoord(), KisTool::convertToPixelCoordAndSnap(), m_continuedMode, m_lastCursorPos, KisTool::mode(), KoToolBase::mouseMoveEvent(), KisTool::PAINT_MODE, KoPointerEvent::point, KisToolPaint::requestUpdateOutline(), and updateContinuedMode().

◆ paint()

void KisToolOutlineBase::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 220 of file KisToolOutlineBase.cpp.

221{
222 if ((mode() == KisTool::PAINT_MODE || m_continuedMode) && !m_points.isEmpty()) {
223 QPainterPath outline;
224 outline.moveTo(pixelToView(m_points.first()));
225 for (qint32 i = 1; i < m_points.size(); ++i) {
226 outline.lineTo(pixelToView(m_points[i]));
227 }
229 outline.lineTo(pixelToView(m_lastCursorPos));
230 }
231 paintToolOutline(&gc, outline);
232 }
233
234 KisToolShape::paint(gc, converter);
235}
virtual void paint(QPainter &painter, const KoViewConverter &converter)=0
void paintToolOutline(QPainter *painter, const KisOptimizedBrushOutline &path)
Definition kis_tool.cc:589

References m_continuedMode, m_lastCursorPos, m_points, KisTool::mode(), KoToolBase::paint(), KisTool::PAINT_MODE, KisTool::paintToolOutline(), and KisTool::pixelToView().

◆ popupWidget()

KisPopupWidgetInterface * KisToolOutlineBase::popupWidget ( )
overridevirtual
Returns
a widget with useful controls to be popped up on top of the canvas. Will not be called if popupActionsMenu() does not return null.

Reimplemented from KoToolBase.

Reimplemented in KisToolSelectBase< __KisToolSelectOutlineLocal >.

Definition at line 102 of file KisToolOutlineBase.cpp.

103{
104 return !m_points.isEmpty() || m_type == SELECT ? nullptr : KisToolShape::popupWidget();
105}
virtual KisPopupWidgetInterface * popupWidget()
Definition KoToolBase.h:340

References m_points, m_type, KoToolBase::popupWidget(), and SELECT.

◆ requestStrokeCancellation

void KisToolOutlineBase::requestStrokeCancellation ( )
overrideslot

Definition at line 300 of file KisToolOutlineBase.cpp.

301{
302 cancelStroke();
303}

References cancelStroke().

◆ requestStrokeEnd

void KisToolOutlineBase::requestStrokeEnd ( )
overrideslot

Definition at line 295 of file KisToolOutlineBase.cpp.

296{
297 endStroke();
298}

References endStroke().

◆ undoLastPoint

void KisToolOutlineBase::undoLastPoint ( )
slot

Definition at line 133 of file KisToolOutlineBase.cpp.

134{
135 if(!m_points.isEmpty() && m_continuedMode && mode() != PAINT_MODE && m_numberOfContinuedModePoints > 0) {
136 // Initialize with the dragging segment's rect
137 QRectF updateRect = dragBoundingRect();
138
139 if (m_points.size() > 1) {
140 // Add the rect for the last segment
141 const QRectF lastSegmentRect =
142 pixelToView(QRectF(m_points.last(), m_points.at(m_points.size() - 2)).normalized())
144 updateRect = updateRect.united(lastSegmentRect);
145
146 m_points.pop_back();
148 }
149
150 // Add the new dragging segment's rect
151 updateRect = updateRect.united(dragBoundingRect());
152 updateCanvasViewRect(updateRect);
153 }
154}
void updateCanvasViewRect(const QRectF &viewRect)
Update the canvas for the given rectangle in view coordinates.
Definition kis_tool.cc:327

References dragBoundingRect(), FEEDBACK_LINE_WIDTH, m_continuedMode, m_numberOfContinuedModePoints, m_points, KisTool::mode(), KisTool::PAINT_MODE, KisTool::pixelToView(), and KisTool::updateCanvasViewRect().

◆ uninstallBlockActionGuard()

void KisToolOutlineBase::uninstallBlockActionGuard ( )
private

Definition at line 315 of file KisToolOutlineBase.cpp.

316{
318}

References m_blockModifyingActionsGuard.

◆ updateCanvas()

void KisToolOutlineBase::updateCanvas ( )
private

◆ updateContinuedMode()

void KisToolOutlineBase::updateContinuedMode ( )
private

Definition at line 256 of file KisToolOutlineBase.cpp.

257{
258 if (!m_points.isEmpty()) {
260 }
261}

References dragBoundingRect(), m_points, and KisTool::updateCanvasViewRect().

◆ updateFeedback()

void KisToolOutlineBase::updateFeedback ( )
private

Definition at line 237 of file KisToolOutlineBase.cpp.

238{
239 if (m_points.count() > 1) {
240 qint32 lastPointIndex = m_points.count() - 1;
241
242 QRectF updateRect = QRectF(m_points[lastPointIndex - 1], m_points[lastPointIndex]).normalized();
243 updateRect = kisGrowRect(updateRect, FEEDBACK_LINE_WIDTH);
244
245 updateCanvasPixelRect(updateRect);
246 }
247}
void updateCanvasPixelRect(const QRectF &pixelRect)
Update the canvas for the given rectangle in image pixel coordinates.
Definition kis_tool.cc:322

References FEEDBACK_LINE_WIDTH, kisGrowRect(), m_points, and KisTool::updateCanvasPixelRect().

Member Data Documentation

◆ FEEDBACK_LINE_WIDTH

constexpr int KisToolOutlineBase::FEEDBACK_LINE_WIDTH {2}
staticconstexprprivate

Definition at line 58 of file KisToolOutlineBase.h.

58{2};

◆ m_blockModifyingActionsGuard

QScopedPointer<KisInputActionGroupsMaskGuard> KisToolOutlineBase::m_blockModifyingActionsGuard
private

Definition at line 67 of file KisToolOutlineBase.h.

◆ m_continuedMode

bool KisToolOutlineBase::m_continuedMode
private

Definition at line 62 of file KisToolOutlineBase.h.

◆ m_hasUserInteractionRunning

bool KisToolOutlineBase::m_hasUserInteractionRunning
private

Definition at line 66 of file KisToolOutlineBase.h.

◆ m_lastCursorPos

QPointF KisToolOutlineBase::m_lastCursorPos
private

Definition at line 63 of file KisToolOutlineBase.h.

◆ m_numberOfContinuedModePoints

int KisToolOutlineBase::m_numberOfContinuedModePoints
private

Definition at line 65 of file KisToolOutlineBase.h.

◆ m_paintPath

QPainterPath KisToolOutlineBase::m_paintPath
private

Definition at line 60 of file KisToolOutlineBase.h.

◆ m_points

QVector<QPointF> KisToolOutlineBase::m_points
private

Definition at line 61 of file KisToolOutlineBase.h.

◆ m_type

ToolType KisToolOutlineBase::m_type
private

Definition at line 64 of file KisToolOutlineBase.h.


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