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

#include <kis_tool_paint.h>

+ Inheritance diagram for KisToolPaint:

Classes

struct  Private
 

Public Slots

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

Signals

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)
 

Public Member Functions

int flags () const override
 
 KisToolPaint (KoCanvasBase *canvas, const QCursor &cursor)
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mousePressEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
KisPopupWidgetInterface * popupWidget () override
 
 ~KisToolPaint () override
 
- Public Member Functions inherited from KisTool
virtual bool alternateActionSupportsHiResEvents (AlternateAction action) const
 
virtual void beginAlternateDoubleClickAction (KoPointerEvent *event, AlternateAction action)
 
virtual void beginPrimaryAction (KoPointerEvent *event)
 
virtual void beginPrimaryDoubleClickAction (KoPointerEvent *event)
 
virtual void continuePrimaryAction (KoPointerEvent *event)
 
void deleteSelection () override
 
virtual void endPrimaryAction (KoPointerEvent *event)
 
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
 
KoCanvasBase * canvas () 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 the Enter key or any equivalent key. This callback comes before requestStrokeEnd(), which comes from a different source.
 
KoToolFactoryBase * factory () 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 QMenu * popupActionsMenu ()
 
virtual bool selectAll ()
 selectAll select all data the tool can select.
 
virtual KoToolSelection * selection ()
 
Q_INVOKABLE QString toolId () const
 
virtual bool wantsAutoScroll () const
 
 ~KoToolBase () override
 

Protected Member Functions

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
 
QWidget * createOptionWidget () 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)
 
KoPointerEvent * lastDeliveredPointerEvent () const
 
void setAbstractResource (KoAbstractCanvasResourceInterfaceSP abstractResource)
 
void setConverter (KoDerivedResourceConverterSP converter)
 
void setIsOpacityPresetMode (bool value)
 
void setMaskSyntheticEvents (bool value)
 
void setTextMode (bool value)
 
QHash< int, KoAbstractCanvasResourceInterfaceSP > toolAbstractResources ()
 
QHash< int, KoDerivedResourceConverterSP > toolConverters ()
 
void useCursor (const QCursor &cursor)
 

Protected Attributes

KisOptimizedBrushOutline m_currentOutline
 
QRectF m_oldColorPreviewUpdateRect
 
QRectF m_oldOutlineRect
 
QPointF m_outlineDocPoint
 
bool m_paintOutline {false}
 
- Protected Attributes inherited from KoToolBase
KoToolBasePrivate * d_ptr
 

Private Slots

void decreaseBrushSize ()
 
void increaseBrushSize ()
 
void rotateBrushTipClockwise ()
 
void rotateBrushTipClockwisePrecise ()
 
void rotateBrushTipCounterClockwise ()
 
void rotateBrushTipCounterClockwisePrecise ()
 
void showBrushSize ()
 
void slotCanvasStateChanged ()
 
void slotColorPickerRequestedCursor (const QCursor &cursor)
 
void slotColorPickerRequestedCursorReset ()
 
void slotColorPickerRequestedOutlineUpdate ()
 
void slotPopupQuickHelp ()
 

Private Member Functions

bool isSamplingAction (AlternateAction action)
 
KisOptimizedBrushOutline tryFixBrushOutline (const KisOptimizedBrushOutline &originalOutline)
 
void tryRestoreOpacitySnapshot ()
 

Private Attributes

KisAsyncColorSamplerHelper m_colorSamplerHelper
 
QScopedPointer< Private > m_d
 
bool m_isOutlineEnabled
 
bool m_isOutlineVisible
 
qreal m_oldOpacity {1.0}
 
KisPaintOpPresetSP m_oldPreset
 
bool m_oldPresetIsDirty {false}
 
int m_oldPresetVersion {-1}
 
QGridLayout * m_optionsWidgetLayout {nullptr}
 
bool m_specialHoverModifier {false}
 
KisToolUtils::StandardBrushSizes m_standardBrushSizes
 
bool m_supportOutline {false}
 

Additional Inherited Members

- 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 ,
  SampleFgGroup = AlternateSampleFgGroup , SampleBgGroup = AlternateSampleBgGroup , 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 , AlternateSampleFgGroup , AlternateSampleBgGroup , AlternateSampleFgImage ,
  AlternateSampleBgImage , AlternateSecondary , AlternateThird , AlternateFourth ,
  AlternateFifth , Alternate_NONE = 10000
}
 
- Static Public Member Functions inherited from KisTool
static AlternateAction actionToAlternateAction (ToolAction action)
 
- Public Attributes inherited from KisTool
KoColor currentBgColor
 
float currentExposure {1.0}
 
KoColor currentFgColor
 
KisFilterConfigurationSP currentGenerator
 
KoAbstractGradientSP currentGradient
 
KoPatternSP currentPattern
 
QCursor cursor
 
bool m_isActive {false}
 
ToolMode m_mode {HOVER_MODE}
 
QWidget * optionWidget {0}
 
- Public Attributes inherited from Private
KisCanvas2 * canvas
 
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 ()
 
- Properties inherited from KisTool
bool isActive
 

Detailed Description

Definition at line 34 of file kis_tool_paint.h.

Constructor & Destructor Documentation

◆ KisToolPaint()

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

Definition at line 78 of file kis_tool_paint.cc.

82 m_standardBrushSizes(1, KisImageConfig(true).maxBrushSize()),
83 m_colorSamplerHelper(dynamic_cast<KisCanvas2*>(canvas)),
84 m_d(new Private())
85{
86 KisCanvas2 *kiscanvas = dynamic_cast<KisCanvas2*>(canvas);
87 KIS_ASSERT(kiscanvas);
88 connect(this, SIGNAL(sigPaintingFinished()), kiscanvas->viewManager()->canvasResourceProvider(), SLOT(slotPainting()));
89
90 connect(&m_colorSamplerHelper, SIGNAL(sigRequestCursor(QCursor)), this, SLOT(slotColorPickerRequestedCursor(QCursor)));
91 connect(&m_colorSamplerHelper, SIGNAL(sigRequestCursorReset()), this, SLOT(slotColorPickerRequestedCursorReset()));
92 connect(&m_colorSamplerHelper, SIGNAL(sigRequestUpdateOutline()), this, SLOT(slotColorPickerRequestedOutlineUpdate()));
93}
KisViewManager * viewManager() const
void slotColorPickerRequestedOutlineUpdate()
void sigPaintingFinished()
QScopedPointer< Private > m_d
void slotColorPickerRequestedCursor(const QCursor &cursor)
KisAsyncColorSamplerHelper m_colorSamplerHelper
KisToolUtils::StandardBrushSizes m_standardBrushSizes
void slotColorPickerRequestedCursorReset()
KisCanvasResourceProvider * canvasResourceProvider()
#define KIS_ASSERT(cond)
Definition kis_assert.h:33
KisTool(KoCanvasBase *canvas, const QCursor &cursor)
Definition kis_tool.cc:78
QCursor cursor
Definition kis_tool.cc:64
KisCanvas2 * canvas

References Private::canvas, KisViewManager::canvasResourceProvider(), KIS_ASSERT, m_colorSamplerHelper, sigPaintingFinished(), slotColorPickerRequestedCursor(), slotColorPickerRequestedCursorReset(), slotColorPickerRequestedOutlineUpdate(), and KisCanvas2::viewManager().

◆ ~KisToolPaint()

KisToolPaint::~KisToolPaint ( )
override

Definition at line 96 of file kis_tool_paint.cc.

97{
98}

Member Function Documentation

◆ activate

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

Definition at line 158 of file kis_tool_paint.cc.

159{
160 if (currentPaintOpPreset()) {
161 const QString formattedBrushName = currentPaintOpPreset() ? currentPaintOpPreset()->name().replace("_", " ") : QString();
162 Q_EMIT statusTextChanged(formattedBrushName);
163 }
164
165 KisTool::activate(shapes);
166
167 if (canvas() && canvas()->canvasController()) {
168 connect(canvas()->canvasController()->proxyObject,
169 SIGNAL(canvasStateChanged()),
170 this,
172 Qt::UniqueConnection);
173 }
174
176 connect(action("increase_brush_size"), SIGNAL(triggered()), SLOT(increaseBrushSize()), Qt::UniqueConnection);
177 connect(action("decrease_brush_size"), SIGNAL(triggered()), SLOT(decreaseBrushSize()), Qt::UniqueConnection);
178 connect(action("increase_brush_size"), SIGNAL(triggered()), this, SLOT(showBrushSize()));
179 connect(action("decrease_brush_size"), SIGNAL(triggered()), this, SLOT(showBrushSize()));
180
181 }
182
183 connect(action("rotate_brush_tip_clockwise"), SIGNAL(triggered()), SLOT(rotateBrushTipClockwise()), Qt::UniqueConnection);
184 connect(action("rotate_brush_tip_clockwise_precise"), SIGNAL(triggered()), SLOT(rotateBrushTipClockwisePrecise()), Qt::UniqueConnection);
185 connect(action("rotate_brush_tip_counter_clockwise"), SIGNAL(triggered()), SLOT(rotateBrushTipCounterClockwise()), Qt::UniqueConnection);
186 connect(action("rotate_brush_tip_counter_clockwise_precise"), SIGNAL(triggered()), SLOT(rotateBrushTipCounterClockwisePrecise()), Qt::UniqueConnection);
187
189}
void slotCanvasStateChanged()
int flags() const override
void increaseBrushSize()
void rotateBrushTipCounterClockwisePrecise()
void rotateBrushTipClockwise()
void rotateBrushTipClockwisePrecise()
void decreaseBrushSize()
void rotateBrushTipCounterClockwise()
void tryRestoreOpacitySnapshot()
void statusTextChanged(const QString &statusText)
QAction * action(const QString &name) const
KisPaintOpPresetSP currentPaintOpPreset()
Definition kis_tool.cc:359
@ FLAG_USES_CUSTOM_SIZE
Definition kis_tool.h:47
void activate(const QSet< KoShape * > &shapes) override
Definition kis_tool.cc:93

References KoToolBase::action(), KisTool::activate(), Private::canvas, KisTool::currentPaintOpPreset(), decreaseBrushSize(), KisTool::FLAG_USES_CUSTOM_SIZE, flags(), increaseBrushSize(), rotateBrushTipClockwise(), rotateBrushTipClockwisePrecise(), rotateBrushTipCounterClockwise(), rotateBrushTipCounterClockwisePrecise(), showBrushSize(), slotCanvasStateChanged(), KoToolBase::statusTextChanged(), and tryRestoreOpacitySnapshot().

◆ activateAlternateAction()

void KisToolPaint::activateAlternateAction ( AlternateAction action)
overrideprotectedvirtual

Reimplemented from KisTool.

Reimplemented in KisToolSelectBase< __KisToolSelectEllipticalLocal >, KisToolSelectBase< __KisToolSelectOutlineLocal >, KisToolSelectBase< __KisToolSelectPolygonalLocal >, and KisToolSelectBase< __KisToolSelectRectangularLocal >.

Definition at line 322 of file kis_tool_paint.cc.

323{
324 if (!isSamplingAction(action)) {
326 return;
327 }
328
330
331 switch (action) {
332 case SampleFgGroup:
333 case SampleBgGroup:
334 sampleSource = KisToolUtils::SampleSourceGroup;
335 break;
336 case SampleFgNode:
337 case SampleBgNode:
338 sampleSource = KisToolUtils::SampleSourceNode;
339 break;
340 case SampleFgImage:
341 case SampleBgImage:
342 default:
343 sampleSource = KisToolUtils::SampleSourceImage;
344 break;
345 }
346
347 const bool sampleFgColor = action == SampleFgNode || action == SampleFgGroup || action == SampleFgImage;
348 m_colorSamplerHelper.activate(sampleSource, sampleFgColor);
349}
void activate(KisToolUtils::ColorSamplerSource sampleSource, bool pickFgColor)
bool isSamplingAction(AlternateAction action)
virtual void activateAlternateAction(AlternateAction action)
Definition kis_tool.cc:456
@ SampleFgImage
Definition kis_tool.h:143
@ SampleFgNode
Definition kis_tool.h:139
@ SampleBgImage
Definition kis_tool.h:144
@ SampleBgGroup
Definition kis_tool.h:142
@ SampleFgGroup
Definition kis_tool.h:141
@ SampleBgNode
Definition kis_tool.h:140

References KoToolBase::action(), KisAsyncColorSamplerHelper::activate(), KisTool::activateAlternateAction(), isSamplingAction(), m_colorSamplerHelper, KisTool::SampleBgGroup, KisTool::SampleBgImage, KisTool::SampleBgNode, KisTool::SampleFgGroup, KisTool::SampleFgImage, KisTool::SampleFgNode, KisToolUtils::SampleSourceGroup, KisToolUtils::SampleSourceImage, and KisToolUtils::SampleSourceNode.

◆ activatePrimaryAction()

void KisToolPaint::activatePrimaryAction ( )
overrideprotectedvirtual

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.

Reimplemented in KisToolSmartPatch.

Definition at line 546 of file kis_tool_paint.cc.

547{
548 setOutlineVisible(true);
550}
void setOutlineVisible(bool visible)
virtual void activatePrimaryAction()
Definition kis_tool.cc:421

References KisTool::activatePrimaryAction(), and setOutlineVisible().

◆ addOptionWidgetLayout()

void KisToolPaint::addOptionWidgetLayout ( QLayout * layout)
protected

Add the tool-specific layout to the default option widget layout.

Definition at line 520 of file kis_tool_paint.cc.

521{
522 Q_ASSERT(m_optionsWidgetLayout != 0);
523 int rowCount = m_optionsWidgetLayout->rowCount();
524 m_optionsWidgetLayout->addLayout(layout, rowCount, 0, 1, 2);
525}
QGridLayout * m_optionsWidgetLayout

References m_optionsWidgetLayout.

◆ addOptionWidgetOption()

void KisToolPaint::addOptionWidgetOption ( QWidget * control,
QWidget * label = nullptr )
protectedvirtual

Add a widget and a label to the current option widget layout.

Definition at line 528 of file kis_tool_paint.cc.

529{
530 Q_ASSERT(m_optionsWidgetLayout != 0);
531 if (label) {
532 m_optionsWidgetLayout->addWidget(label, m_optionsWidgetLayout->rowCount(), 0);
533 m_optionsWidgetLayout->addWidget(control, m_optionsWidgetLayout->rowCount() - 1, 1);
534 }
535 else {
536 m_optionsWidgetLayout->addWidget(control, m_optionsWidgetLayout->rowCount(), 0, 1, 2);
537 }
538}

References m_optionsWidgetLayout.

◆ beginAlternateAction()

void KisToolPaint::beginAlternateAction ( KoPointerEvent * event,
AlternateAction action )
overrideprotectedvirtual

Reimplemented from KisTool.

Reimplemented in KisToolPolylineBase, KisToolSelectBase< __KisToolSelectEllipticalLocal >, KisToolSelectBase< __KisToolSelectOutlineLocal >, KisToolSelectBase< __KisToolSelectPolygonalLocal >, and KisToolSelectBase< __KisToolSelectRectangularLocal >.

Definition at line 370 of file kis_tool_paint.cc.

371{
374
376 config.load();
377
378 m_colorSamplerHelper.startAction(event->point, config.radius, config.blend);
379 requestUpdateOutline(event->point, event);
380 } else {
382 }
383}
void startAction(const QPointF &docPoint, int radius, int blend)
virtual void requestUpdateOutline(const QPointF &outlineDocPoint, const KoPointerEvent *event)
void setMode(ToolMode mode) override
QPointF point
The point in document coordinates.
@ SECONDARY_PAINT_MODE
Definition kis_tool.h:305
virtual void beginAlternateAction(KoPointerEvent *event, AlternateAction action)
Definition kis_tool.cc:466

References KoToolBase::action(), KisTool::beginAlternateAction(), KisToolUtils::ColorSamplerConfig::blend, isSamplingAction(), KisToolUtils::ColorSamplerConfig::load(), m_colorSamplerHelper, KoPointerEvent::point, KisToolUtils::ColorSamplerConfig::radius, requestUpdateOutline(), KisTool::SECONDARY_PAINT_MODE, setMode(), and KisAsyncColorSamplerHelper::startAction().

◆ canvasResourceChanged()

void KisToolPaint::canvasResourceChanged ( int key,
const QVariant & res )
overrideprotectedvirtual

This method is called whenever a property in the resource provider associated with the canvas this tool belongs to changes. An example is currently selected foreground color.

Reimplemented from KoToolBase.

Definition at line 105 of file kis_tool_paint.cc.

106{
108
109 switch(key) {
111 break;
113 if (isActive()) {
115 }
116 break;
117 }
119 if (isActive()) {
120 const QString formattedBrushName = v.toString().replace("_", " ");
121 Q_EMIT statusTextChanged(formattedBrushName);
122 }
123 break;
124 }
125 default: //nothing
126 break;
127 }
128
129 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(resetCursorStyle()), Qt::UniqueConnection);
130
131}
qreal v
static KisConfigNotifier * instance()
QPointF m_outlineDocPoint
virtual void resetCursorStyle()
Definition kis_tool.cc:613
bool isActive
Definition kis_tool.h:44
void canvasResourceChanged(int key, const QVariant &res) override
Definition kis_tool.cc:139

References KisTool::canvasResourceChanged(), KoCanvasResource::CurrentPaintOpPreset, KoCanvasResource::CurrentPaintOpPresetName, KisConfigNotifier::instance(), KisTool::isActive, m_outlineDocPoint, KoCanvasResource::Opacity, requestUpdateOutline(), KisTool::resetCursorStyle(), KoToolBase::statusTextChanged(), and v.

◆ continueAlternateAction()

◆ createOptionWidget()

QWidget * KisToolPaint::createOptionWidget ( )
overrideprotectedvirtual

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

Reimplemented from KisTool.

Reimplemented in KisToolSelectBase< __KisToolSelectEllipticalLocal >, KisToolSelectBase< __KisToolSelectOutlineLocal >, KisToolSelectBase< __KisToolSelectPolygonalLocal >, KisToolSelectBase< __KisToolSelectRectangularLocal >, KisToolShape, KisToolPolyline, and KisToolSmartPatch.

Definition at line 442 of file kis_tool_paint.cc.

443{
444 QWidget *optionWidget = new QWidget();
445 optionWidget->setObjectName(toolId());
446
447 QVBoxLayout *verticalLayout = new QVBoxLayout(optionWidget);
448 verticalLayout->setObjectName("KisToolPaint::OptionWidget::VerticalLayout");
449 verticalLayout->setContentsMargins(0,0,0,0);
450 verticalLayout->setSpacing(5);
451
452 // See https://bugs.kde.org/show_bug.cgi?id=316896
453 QWidget *specialSpacer = new QWidget(optionWidget);
454 specialSpacer->setObjectName("SpecialSpacer");
455 specialSpacer->setFixedSize(0, 0);
456 verticalLayout->addWidget(specialSpacer);
457 verticalLayout->addWidget(specialSpacer);
458
459 m_optionsWidgetLayout = new QGridLayout();
460 m_optionsWidgetLayout->setColumnStretch(1, 1);
461 verticalLayout->addLayout(m_optionsWidgetLayout);
462 m_optionsWidgetLayout->setContentsMargins(0,0,0,0);
463 m_optionsWidgetLayout->setSpacing(5);
464
465 if (!quickHelp().isEmpty()) {
466 QPushButton *push = new QPushButton(KisIconUtils::loadIcon("help-contents"), QString(), optionWidget);
467 connect(push, SIGNAL(clicked()), this, SLOT(slotPopupQuickHelp()));
468 QHBoxLayout *hLayout = new QHBoxLayout();
469 hLayout->addWidget(push);
470 hLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
471 verticalLayout->addLayout(hLayout);
472 }
473
474 return optionWidget;
475}
void slotPopupQuickHelp()
virtual QString quickHelp() const
Q_INVOKABLE QString toolId() const
QIcon loadIcon(const QString &name)
QWidget * optionWidget
Definition kis_tool.cc:73

References KisIconUtils::loadIcon(), m_optionsWidgetLayout, KisTool::optionWidget, quickHelp(), slotPopupQuickHelp(), and KoToolBase::toolId().

◆ deactivate

void KisToolPaint::deactivate ( )
overrideslot

Definition at line 191 of file kis_tool_paint.cc.

192{
194 disconnect(action("increase_brush_size"), 0, this, 0);
195 disconnect(action("decrease_brush_size"), 0, this, 0);
196 }
197
198 disconnect(action("rotate_brush_tip_clockwise"), 0, this, 0);
199 disconnect(action("rotate_brush_tip_clockwise_precise"), 0, this, 0);
200 disconnect(action("rotate_brush_tip_counter_clockwise"), 0, this, 0);
201 disconnect(action("rotate_brush_tip_counter_clockwise_precise"), 0, this, 0);
202
204 Q_EMIT statusTextChanged(QString());
205
206 if (canvas() && canvas()->canvasController()) {
207 disconnect(canvas()->canvasController()->proxyObject,
208 SIGNAL(canvasStateChanged()),
209 this,
210 SLOT(slotCanvasStateChanged()));
211 }
212
214}
void deactivate() override
Definition kis_tool.cc:131

References KoToolBase::action(), Private::canvas, KisTool::deactivate(), KisTool::FLAG_USES_CUSTOM_SIZE, flags(), slotCanvasStateChanged(), KoToolBase::statusTextChanged(), and tryRestoreOpacitySnapshot().

◆ deactivateAlternateAction()

◆ deactivatePrimaryAction()

void KisToolPaint::deactivatePrimaryAction ( )
overrideprotectedvirtual

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.

Reimplemented in KisToolSmartPatch.

Definition at line 552 of file kis_tool_paint.cc.

553{
554 setOutlineVisible(false);
556}
virtual void deactivatePrimaryAction()
Definition kis_tool.cc:426

References KisTool::deactivatePrimaryAction(), and setOutlineVisible().

◆ decreaseBrushSize

void KisToolPaint::decreaseBrushSize ( )
privateslot

Definition at line 588 of file kis_tool_paint.cc.

589{
590 qreal paintopSize = currentPaintOpPreset()->settings()->paintOpSize();
591 int newValue = m_standardBrushSizes.decreaseBrushSize(paintopSize);
592 currentPaintOpPreset()->settings()->setPaintOpSize(newValue);
594}

References KisTool::currentPaintOpPreset(), KisToolUtils::StandardBrushSizes::decreaseBrushSize(), m_outlineDocPoint, m_standardBrushSizes, and requestUpdateOutline().

◆ enableControl()

void KisToolPaint::enableControl ( QWidget * control,
bool value )
protected

Definition at line 511 of file kis_tool_paint.cc.

512{
513 control->setEnabled(value);
514 QWidget *label = findLabelWidget(m_optionsWidgetLayout, control);
515 if (label) {
516 label->setEnabled(value);
517 }
518}
float value(const T *src, size_t ch)
QWidget * findLabelWidget(QGridLayout *layout, QWidget *control)

References findLabelWidget(), m_optionsWidgetLayout, and value().

◆ endAlternateAction()

◆ flags()

int KisToolPaint::flags ( ) const
overridevirtual

Reimplemented from KisTool.

Reimplemented in KisToolShape, and KisToolSmartPatch.

Definition at line 100 of file kis_tool_paint.cc.

101{
103}
@ FLAG_USES_CUSTOM_COMPOSITEOP
Definition kis_tool.h:47

References KisTool::FLAG_USES_CUSTOM_COMPOSITEOP.

◆ getOutlinePath()

KisOptimizedBrushOutline KisToolPaint::getOutlinePath ( const QPointF & documentPos,
const KoPointerEvent * event,
KisPaintOpSettings::OutlineMode outlineMode )
protectedvirtual

Reimplemented in KisToolFreehand, and KisToolBasicBrushBase.

Definition at line 776 of file kis_tool_paint.cc.

779{
780 KisCanvas2 *canvas2 = dynamic_cast<KisCanvas2 *>(canvas());
781 KIS_ASSERT(canvas2);
782 const KisCoordinatesConverter *converter = canvas2->coordinatesConverter();
783
784 const QPointF pixelPos = convertToPixelCoord(documentPos);
785 // When touch drawing, a "hover" event means the finger was just pressed
786 // down. The last cursor position is invalid with regards to distance and
787 // speed, since it isn't updated while the finger isn't down, so reset it.
788 if (event && event->isTouchEvent() && mode() == HOVER_MODE) {
789 m_d->lastCursorPos.reset(pixelPos);
790 }
791
792 KisPaintInformation info(pixelPos);
793 info.setCanvasMirroredH(canvas2->coordinatesConverter()->xAxisMirrored());
794 info.setCanvasMirroredV(canvas2->coordinatesConverter()->yAxisMirrored());
795 info.setCanvasRotation(canvas2->coordinatesConverter()->rotationAngle());
796 info.setRandomSource(new KisRandomSource());
797 info.setPerStrokeRandomSource(new KisPerStrokeRandomSource());
798
799 const qreal currentZoom = canvas2->resourceManager() ? canvas2->resourceManager()->resource(KoCanvasResource::EffectiveZoom).toReal() : 1.0;
800
801 QPointF prevPoint = m_d->lastCursorPos.pushThroughHistory(pixelPos, currentZoom);
802 qreal startAngle = KisAlgebra2D::directionBetweenPoints(prevPoint, pixelPos, 0);
803 KisDistanceInformation distanceInfo(prevPoint, startAngle);
804
806 info.registerDistanceInformation(&distanceInfo);
807
809 brushOutline(info,
810 outlineMode, converter->effectivePhysicalZoom());
811
812 return path;
813}
KisCoordinatesConverter * coordinatesConverter
QPointer< KoCanvasResourceProvider > resourceManager
bool isTouchEvent() const
qreal directionBetweenPoints(const QPointF &p1, const QPointF &p2, qreal defaultAngle)
@ EffectiveZoom
-Used only by painting tools for non-displaying purposes
QPointF convertToPixelCoord(KoPointerEvent *e)
Definition kis_tool.cc:189
virtual ToolMode mode() const
Definition kis_tool.cc:407

References Private::canvas, KisTool::convertToPixelCoord(), KisCanvas2::coordinatesConverter, KisTool::currentPaintOpPreset(), KisAlgebra2D::directionBetweenPoints(), KisCoordinatesConverter::effectivePhysicalZoom(), KoCanvasResource::EffectiveZoom, KisTool::HOVER_MODE, KoPointerEvent::isTouchEvent(), KIS_ASSERT, m_d, KisTool::mode(), KisPaintInformation::registerDistanceInformation(), KoCanvasBase::resourceManager, KisCoordinatesConverter::rotationAngle(), KisPaintInformation::setCanvasMirroredH(), KisPaintInformation::setCanvasMirroredV(), KisPaintInformation::setCanvasRotation(), KisPaintInformation::setPerStrokeRandomSource(), KisPaintInformation::setRandomSource(), KisCoordinatesConverter::xAxisMirrored(), and KisCoordinatesConverter::yAxisMirrored().

◆ increaseBrushSize

void KisToolPaint::increaseBrushSize ( )
privateslot

Definition at line 580 of file kis_tool_paint.cc.

581{
582 qreal paintopSize = currentPaintOpPreset()->settings()->paintOpSize();
583 int newValue = m_standardBrushSizes.increaseBrushSize(paintopSize);
584 currentPaintOpPreset()->settings()->setPaintOpSize(newValue);
586}

References KisTool::currentPaintOpPreset(), KisToolUtils::StandardBrushSizes::increaseBrushSize(), m_outlineDocPoint, m_standardBrushSizes, and requestUpdateOutline().

◆ isEraser()

bool KisToolPaint::isEraser ( ) const
protected

◆ isOutlineEnabled()

bool KisToolPaint::isOutlineEnabled ( ) const
protected

Definition at line 558 of file kis_tool_paint.cc.

559{
560 return m_isOutlineEnabled;
561}

References m_isOutlineEnabled.

◆ isOutlineVisible()

bool KisToolPaint::isOutlineVisible ( ) const
protected

Definition at line 569 of file kis_tool_paint.cc.

570{
571 return m_isOutlineVisible;
572}

References m_isOutlineVisible.

◆ isSamplingAction()

bool KisToolPaint::isSamplingAction ( AlternateAction action)
private

◆ mouseMoveEvent()

void KisToolPaint::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 KisToolPolylineBase, KisToolSelectBase< __KisToolSelectEllipticalLocal >, KisToolSelectBase< __KisToolSelectOutlineLocal >, KisToolSelectBase< __KisToolSelectPolygonalLocal >, and KisToolSelectBase< __KisToolSelectRectangularLocal >.

Definition at line 414 of file kis_tool_paint.cc.

415{
417 if (mode() == KisTool::HOVER_MODE) {
418 requestUpdateOutline(event->point, event);
419 }
420}
void mouseMoveEvent(KoPointerEvent *event) override
Definition kis_tool.cc:520

References KisTool::HOVER_MODE, KisTool::mode(), KisTool::mouseMoveEvent(), KoPointerEvent::point, and requestUpdateOutline().

◆ mousePressEvent()

void KisToolPaint::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 406 of file kis_tool_paint.cc.

407{
409 if (mode() == KisTool::HOVER_MODE) {
410 requestUpdateOutline(event->point, event);
411 }
412}
void mousePressEvent(KoPointerEvent *event) override
Definition kis_tool.cc:510

References KisTool::HOVER_MODE, KisTool::mode(), KisTool::mousePressEvent(), KoPointerEvent::point, and requestUpdateOutline().

◆ mouseReleaseEvent()

void KisToolPaint::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 434 of file kis_tool_paint.cc.

435{
437 if (mode() == KisTool::HOVER_MODE) {
438 requestUpdateOutline(event->point, event);
439 }
440}
void mouseReleaseEvent(KoPointerEvent *event) override
Definition kis_tool.cc:515

References KisTool::HOVER_MODE, KisTool::mode(), KisTool::mouseReleaseEvent(), KoPointerEvent::point, and requestUpdateOutline().

◆ paint()

void KisToolPaint::paint ( QPainter & painter,
const KoViewConverter & converter )
overrideprotectedvirtual

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.

Reimplemented in KisToolPolylineBase, KisToolRectangleBase, and KisToolSmartPatch.

Definition at line 300 of file kis_tool_paint.cc.

301{
302 Q_UNUSED(converter);
303
305 paintToolOutline(&gc, path);
306
307 m_colorSamplerHelper.paint(gc, converter);
308}
void paint(QPainter &gc, const KoViewConverter &converter)
KisOptimizedBrushOutline m_currentOutline
KisOptimizedBrushOutline tryFixBrushOutline(const KisOptimizedBrushOutline &originalOutline)
QPointF pixelToView(const QPoint &pixelCoord) const
Definition kis_tool.cc:269
void paintToolOutline(QPainter *painter, const KisOptimizedBrushOutline &path)
Definition kis_tool.cc:589

References m_colorSamplerHelper, m_currentOutline, KisAsyncColorSamplerHelper::paint(), KisTool::paintToolOutline(), KisTool::pixelToView(), and tryFixBrushOutline().

◆ popupWidget()

KisPopupWidgetInterface * KisToolPaint::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 KisToolPolylineBase, KisToolSelectBase< __KisToolSelectEllipticalLocal >, KisToolSelectBase< __KisToolSelectOutlineLocal >, KisToolSelectBase< __KisToolSelectPolygonalLocal >, and KisToolSelectBase< __KisToolSelectRectangularLocal >.

Definition at line 422 of file kis_tool_paint.cc.

423{
424 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
425
426 if (!kisCanvas) {
427 return nullptr;
428 }
429
431 return popupWidget;
432}
KisPopupPalette * popupPalette
The PopupWidgetInterface abstract class defines the basic interface that will be used by all popup wi...
KisPopupWidgetInterface * popupWidget() override

References Private::canvas, KisCanvas2::popupPalette, and popupWidget().

◆ quickHelp()

virtual QString KisToolPaint::quickHelp ( ) const
inlineprotectedvirtual

Quick help is a short help text about the way the tool functions.

Reimplemented in KisToolLine.

Definition at line 103 of file kis_tool_paint.h.

103 {
104 return QString();
105 }

◆ requestUpdateOutline()

void KisToolPaint::requestUpdateOutline ( const QPointF & outlineDocPoint,
const KoPointerEvent * event )
protectedvirtual

A simple "update-ahead" implementation that issues an update a little bigger to accommodate the possible following outline.

The point is that canvas rendering comes through two stages of compression and the canvas may request outline update when the outline itself has already been changed. It causes visual tearing on the screen (see https://bugs.kde.org/show_bug.cgi?id=476300).

We can solve that in two ways:

1) Pass the actual outline with the update rect itself, which is a bit complicated and may result in the outline being a bit delayed visually. We don't implement this method (yet).

2) Just pass the update rect a bit bigger than the actual outline to accommodate a possible change in the outline. We calculate this bigger rect by offsetting the rect by the previous cursor offset.

Don't try to update-ahead if the offset is bigger than 50% of the brush outline

10% of extra move is added to offset

Reimplemented in KisDynamicDelegatedTool< KisToolShape >, and KisToolSmartPatch.

Definition at line 629 of file kis_tool_paint.cc.

630{
631 QRectF outlinePixelRect;
632 QRectF outlineDocRect;
633
634 QRectF colorPreviewDocUpdateRect;
635
636 QPointF outlineMoveVector;
637
638 if (m_supportOutline) {
639 KisConfig cfg(true);
641
642 bool useSeparateEraserCursor = cfg.separateEraserCursor() && isEraser();
643
644 const OutlineStyle currentOutlineStyle = !useSeparateEraserCursor ? cfg.newOutlineStyle() : cfg.eraserOutlineStyle();
645 const auto outlineStyleIsVisible = [&]() {
646 return currentOutlineStyle == OUTLINE_FULL ||
647 currentOutlineStyle == OUTLINE_CIRCLE ||
648 currentOutlineStyle == OUTLINE_TILT;
649 };
650 const auto shouldShowOutlineWhilePainting = [&]() {
651 return !useSeparateEraserCursor ? cfg.showOutlineWhilePainting() : cfg.showEraserOutlineWhilePainting();
652 };
655 (outlineStyleIsVisible() &&
656 (mode() == HOVER_MODE ||
657 (mode() == PAINT_MODE && shouldShowOutlineWhilePainting()))))) { // lisp forever!
658
659 outlineMode.isVisible = true;
660
661 switch (!useSeparateEraserCursor ? cfg.newOutlineStyle() : cfg.eraserOutlineStyle()) {
662 case OUTLINE_CIRCLE:
663 outlineMode.forceCircle = true;
664 break;
665 case OUTLINE_TILT:
666 outlineMode.forceCircle = true;
667 outlineMode.showTiltDecoration = true;
668 break;
669 default:
670 break;
671 }
672 }
673
674 outlineMode.forceFullSize = !useSeparateEraserCursor ? cfg.forceAlwaysFullSizedOutline() : cfg.forceAlwaysFullSizedEraserOutline();
675
676 outlineMoveVector = outlineDocPoint - m_outlineDocPoint;
677
678 m_outlineDocPoint = outlineDocPoint;
680
682 outlineDocRect = currentImage()->pixelToDocument(outlinePixelRect);
683
684 // This adjusted call is needed as we paint with a 3 pixel wide brush and the pen is outside the bounds of the path
685 // Pen uses view coordinates so we have to zoom the document value to match 2 pixel in view coordinates
686 // See BUG 275829
687 qreal zoomX;
688 qreal zoomY;
689 canvas()->viewConverter()->zoom(&zoomX, &zoomY);
690 qreal xoffset = 2.0/zoomX;
691 qreal yoffset = 2.0/zoomY;
692
693 if (!outlineDocRect.isEmpty()) {
694 outlineDocRect.adjust(-xoffset,-yoffset,xoffset,yoffset);
695 }
696
698
699 if (!colorPreviewDocUpdateRect.isEmpty()) {
700 colorPreviewDocUpdateRect = colorPreviewDocUpdateRect.adjusted(-xoffset,-yoffset,xoffset,yoffset);
701 }
702
703 }
704
705 // DIRTY HACK ALERT: we should fetch the assistant's dirty rect when requesting
706 // the update, instead of just dumbly update the entire canvas!
707
708 // WARNING: assistants code is also duplicated in KisDelegatedSelectPathWrapper::mouseMoveEvent
709
710 KisCanvas2 *kiscanvas = qobject_cast<KisCanvas2*>(canvas());
712 if (decoration && decoration->visible() && decoration->hasPaintableAssistants()) {
713 kiscanvas->updateCanvasDecorations();
714 }
715
716 if (!m_oldColorPreviewUpdateRect.isEmpty()) {
718 }
719
720 if (!m_oldOutlineRect.isEmpty()) {
722 }
723
724 if (!outlineDocRect.isEmpty()) {
748 const qreal maxUpdateAheadOutlinePortion = 0.5;
749
751 const qreal offsetFuzzyExtension = 0.1;
752
753 const qreal moveDistance = KisAlgebra2D::norm(outlineMoveVector);
754
755 QRectF offsetRect;
756
757 if (moveDistance < maxUpdateAheadOutlinePortion * KisAlgebra2D::maxDimension(outlineDocRect)) {
758 offsetRect = outlineDocRect.translated((1.0 + offsetFuzzyExtension) * outlineMoveVector);
759 }
760
761 kiscanvas->updateCanvasToolOutlineDoc(outlineDocRect | offsetRect);
762 }
763
764 if (!colorPreviewDocUpdateRect.isEmpty()) {
765 kiscanvas->updateCanvasToolOutlineDoc(colorPreviewDocUpdateRect);
766 }
767
768 m_oldOutlineRect = outlineDocRect;
769 m_oldColorPreviewUpdateRect = colorPreviewDocUpdateRect;
770}
QRectF colorPreviewDocRect(const QPointF &docPoint)
void updateCanvasToolOutlineDoc(const QRectF &docRect)
KisPaintingAssistantsDecorationSP paintingAssistantsDecoration() const
void updateCanvasDecorations()
const KoViewConverter * viewConverter() const override
QPointF pixelToDocument(const QPointF &pixelCoord) const
QRectF m_oldColorPreviewUpdateRect
virtual KisOptimizedBrushOutline getOutlinePath(const QPointF &documentPos, const KoPointerEvent *event, KisPaintOpSettings::OutlineMode outlineMode)
QRectF m_oldOutlineRect
bool isOutlineEnabled() const
bool isOutlineVisible() const
bool isEraser() const
virtual void zoom(qreal *zoomX, qreal *zoomY) const
OutlineStyle
Definition kis_global.h:53
@ OUTLINE_CIRCLE
Definition kis_global.h:55
@ OUTLINE_FULL
Definition kis_global.h:56
@ OUTLINE_TILT
Definition kis_global.h:57
auto maxDimension(Size size) -> decltype(size.width())
qreal norm(const T &a)
KisImageWSP currentImage()
Definition kis_tool.cc:393
@ GESTURE_MODE
Definition kis_tool.h:307
@ PAINT_MODE
Definition kis_tool.h:304

References KisOptimizedBrushOutline::boundingRect(), Private::canvas, KisAsyncColorSamplerHelper::colorPreviewDocRect(), KisTool::currentImage(), KisConfig::eraserOutlineStyle(), KisConfig::forceAlwaysFullSizedEraserOutline(), KisConfig::forceAlwaysFullSizedOutline(), KisPaintOpSettings::OutlineMode::forceCircle, KisPaintOpSettings::OutlineMode::forceFullSize, KisTool::GESTURE_MODE, getOutlinePath(), KisPaintingAssistantsDecoration::hasPaintableAssistants(), KisTool::HOVER_MODE, isEraser(), isOutlineEnabled(), isOutlineVisible(), KisPaintOpSettings::OutlineMode::isVisible, m_colorSamplerHelper, m_currentOutline, m_oldColorPreviewUpdateRect, m_oldOutlineRect, m_outlineDocPoint, m_supportOutline, KisAlgebra2D::maxDimension(), KisTool::mode(), KisConfig::newOutlineStyle(), KisAlgebra2D::norm(), OUTLINE_CIRCLE, OUTLINE_FULL, OUTLINE_TILT, KisTool::PAINT_MODE, KisCanvas2::paintingAssistantsDecoration(), KisImage::pixelToDocument(), KisConfig::separateEraserCursor(), KisConfig::showEraserOutlineWhilePainting(), KisConfig::showOutlineWhilePainting(), KisPaintOpSettings::OutlineMode::showTiltDecoration, tryFixBrushOutline(), KisCanvas2::updateCanvasDecorations(), KisCanvas2::updateCanvasToolOutlineDoc(), KisCanvas2::viewConverter(), KisCanvasDecoration::visible(), and KoViewConverter::zoom().

◆ rotateBrushTipClockwise

void KisToolPaint::rotateBrushTipClockwise ( )
privateslot

Definition at line 601 of file kis_tool_paint.cc.

602{
603 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
604 currentPaintOpPreset()->settings()->setPaintOpAngle(angle - 15);
606}

References KisTool::currentPaintOpPreset(), m_outlineDocPoint, and requestUpdateOutline().

◆ rotateBrushTipClockwisePrecise

void KisToolPaint::rotateBrushTipClockwisePrecise ( )
privateslot

Definition at line 608 of file kis_tool_paint.cc.

609{
610 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
611 currentPaintOpPreset()->settings()->setPaintOpAngle(angle - 1);
613}

References KisTool::currentPaintOpPreset(), m_outlineDocPoint, and requestUpdateOutline().

◆ rotateBrushTipCounterClockwise

void KisToolPaint::rotateBrushTipCounterClockwise ( )
privateslot

Definition at line 615 of file kis_tool_paint.cc.

616{
617 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
618 currentPaintOpPreset()->settings()->setPaintOpAngle(angle + 15);
620}

References KisTool::currentPaintOpPreset(), m_outlineDocPoint, and requestUpdateOutline().

◆ rotateBrushTipCounterClockwisePrecise

void KisToolPaint::rotateBrushTipCounterClockwisePrecise ( )
privateslot

Definition at line 622 of file kis_tool_paint.cc.

623{
624 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
625 currentPaintOpPreset()->settings()->setPaintOpAngle(angle + 1);
627}

References KisTool::currentPaintOpPreset(), m_outlineDocPoint, and requestUpdateOutline().

◆ setMode()

void KisToolPaint::setMode ( ToolMode mode)
overrideprotectedvirtual

Reimplemented from KisTool.

Definition at line 310 of file kis_tool_paint.cc.

311{
312 if(this->mode() == KisTool::PAINT_MODE &&
314
315 // Let's add history information about recently used colors
316 Q_EMIT sigPaintingFinished();
317 }
318
320}
virtual void setMode(ToolMode mode)
Definition kis_tool.cc:403

References KisTool::mode(), KisTool::PAINT_MODE, KisTool::setMode(), and sigPaintingFinished().

◆ setOutlineEnabled()

void KisToolPaint::setOutlineEnabled ( bool enabled)
protected

◆ setOutlineVisible()

void KisToolPaint::setOutlineVisible ( bool visible)
protected

◆ setSupportOutline()

void KisToolPaint::setSupportOutline ( bool supportOutline)
inlineprotected

If the paint tool support outline like brushes, set to true. If not (e.g. gradient tool), set to false. Default is false.

Definition at line 73 of file kis_tool_paint.h.

73 {
74 m_supportOutline = supportOutline;
75 }

◆ showBrushSize

void KisToolPaint::showBrushSize ( )
privateslot

Definition at line 596 of file kis_tool_paint.cc.

597{
599}
void KRITAUI_EXPORT showBrushSizeFloatingMessage(KoCanvasBase *canvas, qreal size)

References Private::canvas, KisTool::currentPaintOpPreset(), and KisToolUtils::showBrushSizeFloatingMessage().

◆ showControl()

void KisToolPaint::showControl ( QWidget * control,
bool value )
protected

Definition at line 502 of file kis_tool_paint.cc.

503{
504 control->setVisible(value);
505 QWidget *label = findLabelWidget(m_optionsWidgetLayout, control);
506 if (label) {
507 label->setVisible(value);
508 }
509}

References findLabelWidget(), m_optionsWidgetLayout, and value().

◆ sigPaintingFinished

void KisToolPaint::sigPaintingFinished ( )
signal

◆ slotCanvasStateChanged

void KisToolPaint::slotCanvasStateChanged ( )
privateslot

Definition at line 216 of file kis_tool_paint.cc.

217{
218 if (!isActive() || !isOutlineEnabled())
219 return;
220
221 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2 *>(canvas());
222 if (!kisCanvas)
223 return;
224
225 QWidget *widget = kisCanvas->canvasWidget();
226 if (!widget)
227 return;
228
229 const QPointF widgetPos = widget->mapFromGlobal(QCursor::pos());
230 if (!widget->rect().contains(widgetPos.toPoint()))
231 return;
232
233 const QPointF docPoint = kisCanvas->coordinatesConverter()->widgetToDocument(widgetPos);
234
236}
KisAbstractCanvasWidget * canvasWidget
_Private::Traits< T >::Result widgetToDocument(const T &obj) const

References Private::canvas, KisCanvas2::canvasWidget, KisCanvas2::coordinatesConverter, KisTool::isActive, isOutlineEnabled(), KoToolBase::lastDeliveredPointerEvent(), requestUpdateOutline(), and KisCoordinatesConverter::widgetToDocument().

◆ slotColorPickerRequestedCursor

void KisToolPaint::slotColorPickerRequestedCursor ( const QCursor & cursor)
privateslot

Definition at line 238 of file kis_tool_paint.cc.

239{
241}
void useCursor(const QCursor &cursor)

References KisTool::cursor, and KoToolBase::useCursor().

◆ slotColorPickerRequestedCursorReset

void KisToolPaint::slotColorPickerRequestedCursorReset ( )
privateslot

Definition at line 243 of file kis_tool_paint.cc.

244{
246}

References KisTool::resetCursorStyle().

◆ slotColorPickerRequestedOutlineUpdate

void KisToolPaint::slotColorPickerRequestedOutlineUpdate ( )
privateslot

Definition at line 248 of file kis_tool_paint.cc.

References m_outlineDocPoint, and requestUpdateOutline().

◆ slotPopupQuickHelp

void KisToolPaint::slotPopupQuickHelp ( )
privateslot

Definition at line 541 of file kis_tool_paint.cc.

542{
543 QWhatsThis::showText(QCursor::pos(), quickHelp());
544}

References quickHelp().

◆ tryFixBrushOutline()

KisOptimizedBrushOutline KisToolPaint::tryFixBrushOutline ( const KisOptimizedBrushOutline & originalOutline)
private

If the brush outline is bigger than the canvas itself (which would make it invisible for a user in most of the cases) just add a cross in the center of it

Definition at line 253 of file kis_tool_paint.cc.

254{
255 KisConfig cfg(true);
256
257 bool useSeparateEraserCursor = cfg.separateEraserCursor() && isEraser();
258
259 const OutlineStyle currentOutlineStyle = !useSeparateEraserCursor ? cfg.newOutlineStyle() : cfg.eraserOutlineStyle();
260 if (currentOutlineStyle == OUTLINE_NONE) return originalOutline;
261
262 const qreal minThresholdSize = cfg.outlineSizeMinimum();
263
270 QSize widgetSize = canvas()->canvasWidget()->size();
271 const int maxThresholdSum = widgetSize.width() + widgetSize.height();
272
273 KisOptimizedBrushOutline outline = originalOutline;
274 QRectF boundingRect = outline.boundingRect();
275 const qreal sum = boundingRect.width() + boundingRect.height();
276
277 QPointF center = boundingRect.center();
278
279 if (sum > maxThresholdSum) {
280 const int hairOffset = 7;
281
282 QPainterPath crossIcon;
283
284 crossIcon.moveTo(center.x(), center.y() - hairOffset);
285 crossIcon.lineTo(center.x(), center.y() + hairOffset);
286
287 crossIcon.moveTo(center.x() - hairOffset, center.y());
288 crossIcon.lineTo(center.x() + hairOffset, center.y());
289
290 outline.addPath(crossIcon);
291
292 } else if (sum < minThresholdSize && !outline.isEmpty()) {
293 outline = QPainterPath();
294 outline.addEllipse(center, 0.5 * minThresholdSize, 0.5 * minThresholdSize);
295 }
296
297 return outline;
298}
void addPath(const QPainterPath &path)
void addEllipse(const QPointF &center, qreal rx, qreal ry)
@ OUTLINE_NONE
Definition kis_global.h:54

References KisOptimizedBrushOutline::addEllipse(), KisOptimizedBrushOutline::addPath(), KisOptimizedBrushOutline::boundingRect(), Private::canvas, KisCanvas2::canvasWidget, KisConfig::eraserOutlineStyle(), KisOptimizedBrushOutline::isEmpty(), isEraser(), KisConfig::newOutlineStyle(), OUTLINE_NONE, KisConfig::outlineSizeMinimum(), and KisConfig::separateEraserCursor().

◆ tryRestoreOpacitySnapshot()

void KisToolPaint::tryRestoreOpacitySnapshot ( )
private

Here is a weird heuristics on when to restore brush opacity and when not. Basically, we should restore opacity to its saved if the brush preset hasn't changed too much, that is, its version is the same and it hasn't been reset into a clean state since then. The latter condition is checked in a fuzzy manner by just mangling the isDirty state before and after.

Definition at line 133 of file kis_tool_paint.cc.

134{
146 KisCanvasResourceProvider *provider = qobject_cast<KisCanvas2*>(canvas())->viewManager()->canvasResourceProvider();
147
148 KisPaintOpPresetSP newPreset = provider->currentPreset();
149
150 if (newPreset) {
151 m_oldPreset = newPreset;
152 m_oldPresetIsDirty = newPreset->isDirty();
153 m_oldPresetVersion = newPreset->version();
154 }
155}
KisPaintOpPresetSP currentPreset() const
KisPaintOpPresetSP m_oldPreset

References Private::canvas, KisCanvasResourceProvider::currentPreset(), m_oldPreset, m_oldPresetIsDirty, and m_oldPresetVersion.

Member Data Documentation

◆ m_colorSamplerHelper

KisAsyncColorSamplerHelper KisToolPaint::m_colorSamplerHelper
private

Definition at line 159 of file kis_tool_paint.h.

◆ m_currentOutline

KisOptimizedBrushOutline KisToolPaint::m_currentOutline
protected

Definition at line 133 of file kis_tool_paint.h.

◆ m_d

QScopedPointer<Private> KisToolPaint::m_d
private

Definition at line 164 of file kis_tool_paint.h.

◆ m_isOutlineEnabled

bool KisToolPaint::m_isOutlineEnabled
private

Used as a switch for sampleColor

Definition at line 151 of file kis_tool_paint.h.

◆ m_isOutlineVisible

bool KisToolPaint::m_isOutlineVisible
private

Definition at line 152 of file kis_tool_paint.h.

◆ m_oldColorPreviewUpdateRect

QRectF KisToolPaint::m_oldColorPreviewUpdateRect
protected

Definition at line 135 of file kis_tool_paint.h.

◆ m_oldOpacity

qreal KisToolPaint::m_oldOpacity {1.0}
private

Definition at line 156 of file kis_tool_paint.h.

156{1.0};

◆ m_oldOutlineRect

QRectF KisToolPaint::m_oldOutlineRect
protected

Definition at line 134 of file kis_tool_paint.h.

◆ m_oldPreset

KisPaintOpPresetSP KisToolPaint::m_oldPreset
private

Definition at line 155 of file kis_tool_paint.h.

◆ m_oldPresetIsDirty

bool KisToolPaint::m_oldPresetIsDirty {false}
private

Definition at line 157 of file kis_tool_paint.h.

157{false};

◆ m_oldPresetVersion

int KisToolPaint::m_oldPresetVersion {-1}
private

Definition at line 158 of file kis_tool_paint.h.

158{-1};

◆ m_optionsWidgetLayout

QGridLayout* KisToolPaint::m_optionsWidgetLayout {nullptr}
private

Definition at line 143 of file kis_tool_paint.h.

143{nullptr};

◆ m_outlineDocPoint

QPointF KisToolPaint::m_outlineDocPoint
protected

Definition at line 132 of file kis_tool_paint.h.

◆ m_paintOutline

bool KisToolPaint::m_paintOutline {false}
protected

Definition at line 131 of file kis_tool_paint.h.

131{false};

◆ m_specialHoverModifier

bool KisToolPaint::m_specialHoverModifier {false}
private

Definition at line 142 of file kis_tool_paint.h.

142{false};

◆ m_standardBrushSizes

KisToolUtils::StandardBrushSizes KisToolPaint::m_standardBrushSizes
private

Definition at line 153 of file kis_tool_paint.h.

◆ m_supportOutline

bool KisToolPaint::m_supportOutline {false}
private

Definition at line 145 of file kis_tool_paint.h.

145{false};

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