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
 
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 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
 
KoCanvasBasecanvas () const
 Returns the canvas the tool is working on.
 
virtual void copy () const
 
QCursor cursor () const
 return the last emitted cursor
 
virtual void customMoveEvent (KoPointerEvent *event)
 
virtual void customPressEvent (KoPointerEvent *event)
 
virtual void customReleaseEvent (KoPointerEvent *event)
 
virtual void cut ()
 
virtual QRectF decorationsRect () const
 
int decorationThickness () const
 decorationThickness The minimum thickness for tool decoration lines, this is derived from the screen magnification, thus the HiDPI settings. Note: to use this effectively, also set the pen to isCosmetic(true);
 
virtual void deselect ()
 deselect the tool should clear the selection if it has one.
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event, const QPointF &point)
 
virtual void dropEvent (QDropEvent *event, const QPointF &point)
 
virtual void explicitUserStrokeEndRequest ()
 explicitUserStrokeEndRequest is called by the input manager when the user presses Enter key or any equivalent. This callback comes before requestStrokeEnd(), which comes from a different source.
 
KoToolFactoryBasefactory () const
 
virtual void focusInEvent (QFocusEvent *event)
 
virtual void focusOutEvent (QFocusEvent *event)
 
virtual bool hasSelection ()
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
bool isInTextMode () const
 
bool isOpacityPresetMode () const
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
 KoToolBase (KoCanvasBase *canvas)
 
bool maskSyntheticEvents () const
 
QList< QPointer< QWidget > > optionWidgets ()
 
virtual bool paste ()
 
virtual 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

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)
 
KoPointerEventlastDeliveredPointerEvent () const
 
void setAbstractResource (KoAbstractCanvasResourceInterfaceSP abstractResource)
 
void setConverter (KoDerivedResourceConverterSP converter)
 
void setIsOpacityPresetMode (bool value)
 
void setMaskSyntheticEvents (bool value)
 
void setTextMode (bool value)
 
QHash< int, KoAbstractCanvasResourceInterfaceSPtoolAbstractResources ()
 
QHash< int, KoDerivedResourceConverterSPtoolConverters ()
 
void useCursor (const QCursor &cursor)
 

Protected Attributes

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

Private Slots

void decreaseBrushSize ()
 
void increaseBrushSize ()
 
void rotateBrushTipClockwise ()
 
void rotateBrushTipClockwisePrecise ()
 
void rotateBrushTipCounterClockwise ()
 
void rotateBrushTipCounterClockwisePrecise ()
 
void showBrushSize ()
 
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< Privatem_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}
 
std::vector< int > 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 ,
  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
}
 
- Static Public Member Functions inherited from KisTool
static AlternateAction actionToAlternateAction (ToolAction action)
 
- Public Attributes inherited from KisTool
KoColor currentBgColor
 
float currentExposure {1.0}
 
KoColor currentFgColor
 
KisFilterConfigurationSP currentGenerator
 
KoAbstractGradientSP currentGradient
 
KoPatternSP currentPattern
 
QCursor cursor
 
bool m_isActive {false}
 
ToolMode m_mode {HOVER_MODE}
 
QWidget * optionWidget {0}
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Protected Types inherited from KisTool
enum  ToolMode : int {
  HOVER_MODE , PAINT_MODE , SECONDARY_PAINT_MODE , MIRROR_AXIS_SETUP_MODE ,
  GESTURE_MODE , PAN_MODE , OTHER , OTHER_1
}
 
- Protected Slots inherited from KisTool
virtual void resetCursorStyle ()
 
- Properties inherited from KisTool
bool isActive
 

Detailed Description

Definition at line 33 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_colorSamplerHelper(dynamic_cast<KisCanvas2*>(canvas)),
83 m_d(new Private())
84{
85
86 {
87 const int maxSize = KisImageConfig(true).maxBrushSize();
88
89 int brushSize = 1;
90 do {
91 m_standardBrushSizes.push_back(brushSize);
92 int increment = qMax(1, int(std::ceil(qreal(brushSize) / 15)));
93 brushSize += increment;
94 } while (brushSize < maxSize);
95
96 m_standardBrushSizes.push_back(maxSize);
97 }
98
99 KisCanvas2 *kiscanvas = dynamic_cast<KisCanvas2*>(canvas);
100 KIS_ASSERT(kiscanvas);
101 connect(this, SIGNAL(sigPaintingFinished()), kiscanvas->viewManager()->canvasResourceProvider(), SLOT(slotPainting()));
102
103 connect(&m_colorSamplerHelper, SIGNAL(sigRequestCursor(QCursor)), this, SLOT(slotColorPickerRequestedCursor(QCursor)));
104 connect(&m_colorSamplerHelper, SIGNAL(sigRequestCursorReset()), this, SLOT(slotColorPickerRequestedCursorReset()));
105 connect(&m_colorSamplerHelper, SIGNAL(sigRequestUpdateOutline()), this, SLOT(slotColorPickerRequestedOutlineUpdate()));
106}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisViewManager * viewManager() const
int maxBrushSize(bool defaultValue=false) const
std::vector< int > m_standardBrushSizes
void slotColorPickerRequestedOutlineUpdate()
void sigPaintingFinished()
QScopedPointer< Private > m_d
void slotColorPickerRequestedCursor(const QCursor &cursor)
KisAsyncColorSamplerHelper m_colorSamplerHelper
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(), connect(), KIS_ASSERT, m_colorSamplerHelper, m_standardBrushSizes, KisImageConfig::maxBrushSize(), sigPaintingFinished(), slotColorPickerRequestedCursor(), slotColorPickerRequestedCursorReset(), slotColorPickerRequestedOutlineUpdate(), and KisCanvas2::viewManager().

◆ ~KisToolPaint()

KisToolPaint::~KisToolPaint ( )
override

Definition at line 109 of file kis_tool_paint.cc.

110{
111}

Member Function Documentation

◆ activate

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

Definition at line 171 of file kis_tool_paint.cc.

172{
173 if (currentPaintOpPreset()) {
174 const QString formattedBrushName = currentPaintOpPreset() ? currentPaintOpPreset()->name().replace("_", " ") : QString();
175 Q_EMIT statusTextChanged(formattedBrushName);
176 }
177
178 KisTool::activate(shapes);
180 connect(action("increase_brush_size"), SIGNAL(triggered()), SLOT(increaseBrushSize()), Qt::UniqueConnection);
181 connect(action("decrease_brush_size"), SIGNAL(triggered()), SLOT(decreaseBrushSize()), Qt::UniqueConnection);
182 connect(action("increase_brush_size"), SIGNAL(triggered()), this, SLOT(showBrushSize()));
183 connect(action("decrease_brush_size"), SIGNAL(triggered()), this, SLOT(showBrushSize()));
184
185 }
186
187 connect(action("rotate_brush_tip_clockwise"), SIGNAL(triggered()), SLOT(rotateBrushTipClockwise()), Qt::UniqueConnection);
188 connect(action("rotate_brush_tip_clockwise_precise"), SIGNAL(triggered()), SLOT(rotateBrushTipClockwisePrecise()), Qt::UniqueConnection);
189 connect(action("rotate_brush_tip_counter_clockwise"), SIGNAL(triggered()), SLOT(rotateBrushTipCounterClockwise()), Qt::UniqueConnection);
190 connect(action("rotate_brush_tip_counter_clockwise_precise"), SIGNAL(triggered()), SLOT(rotateBrushTipCounterClockwisePrecise()), Qt::UniqueConnection);
191
193}
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(), connect(), KisTool::currentPaintOpPreset(), decreaseBrushSize(), KisTool::FLAG_USES_CUSTOM_SIZE, flags(), increaseBrushSize(), rotateBrushTipClockwise(), rotateBrushTipClockwisePrecise(), rotateBrushTipCounterClockwise(), rotateBrushTipCounterClockwisePrecise(), showBrushSize(), 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 297 of file kis_tool_paint.cc.

298{
299 if (!isSamplingAction(action)) {
301 return;
302 }
303
304 const bool sampleCurrentLayer = action == SampleFgNode || action == SampleBgNode;
305 const bool sampleFgColor = action == SampleFgNode || action == SampleFgImage;
306 m_colorSamplerHelper.activate(sampleCurrentLayer, sampleFgColor);
307}
void activate(bool sampleCurrentLayer, bool pickFgColor)
bool isSamplingAction(AlternateAction action)
virtual void activateAlternateAction(AlternateAction action)
Definition kis_tool.cc:456
@ SampleFgImage
Definition kis_tool.h:139
@ SampleFgNode
Definition kis_tool.h:137
@ SampleBgNode
Definition kis_tool.h:138

References KoToolBase::action(), KisAsyncColorSamplerHelper::activate(), KisTool::activateAlternateAction(), isSamplingAction(), m_colorSamplerHelper, KisTool::SampleBgNode, KisTool::SampleFgImage, and KisTool::SampleFgNode.

◆ 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 502 of file kis_tool_paint.cc.

503{
504 setOutlineVisible(true);
506}
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 476 of file kis_tool_paint.cc.

477{
478 Q_ASSERT(m_optionsWidgetLayout != 0);
479 int rowCount = m_optionsWidgetLayout->rowCount();
480 m_optionsWidgetLayout->addLayout(layout, rowCount, 0, 1, 2);
481}
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 484 of file kis_tool_paint.cc.

485{
486 Q_ASSERT(m_optionsWidgetLayout != 0);
487 if (label) {
488 m_optionsWidgetLayout->addWidget(label, m_optionsWidgetLayout->rowCount(), 0);
489 m_optionsWidgetLayout->addWidget(control, m_optionsWidgetLayout->rowCount() - 1, 1);
490 }
491 else {
492 m_optionsWidgetLayout->addWidget(control, m_optionsWidgetLayout->rowCount(), 0, 1, 2);
493 }
494}

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 326 of file kis_tool_paint.cc.

327{
330
332 config.load();
333
334 m_colorSamplerHelper.startAction(event->point, config.radius, config.blend);
335 requestUpdateOutline(event->point, event);
336 } else {
338 }
339}
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:301
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 118 of file kis_tool_paint.cc.

119{
121
122 switch(key) {
124 break;
126 if (isActive()) {
128 }
129 break;
130 }
132 if (isActive()) {
133 const QString formattedBrushName = v.toString().replace("_", " ");
134 Q_EMIT statusTextChanged(formattedBrushName);
135 }
136 break;
137 }
138 default: //nothing
139 break;
140 }
141
142 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(resetCursorStyle()), Qt::UniqueConnection);
143
144}
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(), connect(), 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 398 of file kis_tool_paint.cc.

399{
400 QWidget *optionWidget = new QWidget();
401 optionWidget->setObjectName(toolId());
402
403 QVBoxLayout *verticalLayout = new QVBoxLayout(optionWidget);
404 verticalLayout->setObjectName("KisToolPaint::OptionWidget::VerticalLayout");
405 verticalLayout->setContentsMargins(0,0,0,0);
406 verticalLayout->setSpacing(5);
407
408 // See https://bugs.kde.org/show_bug.cgi?id=316896
409 QWidget *specialSpacer = new QWidget(optionWidget);
410 specialSpacer->setObjectName("SpecialSpacer");
411 specialSpacer->setFixedSize(0, 0);
412 verticalLayout->addWidget(specialSpacer);
413 verticalLayout->addWidget(specialSpacer);
414
415 m_optionsWidgetLayout = new QGridLayout();
416 m_optionsWidgetLayout->setColumnStretch(1, 1);
417 verticalLayout->addLayout(m_optionsWidgetLayout);
418 m_optionsWidgetLayout->setContentsMargins(0,0,0,0);
419 m_optionsWidgetLayout->setSpacing(5);
420
421 if (!quickHelp().isEmpty()) {
422 QPushButton *push = new QPushButton(KisIconUtils::loadIcon("help-contents"), QString(), optionWidget);
423 connect(push, SIGNAL(clicked()), this, SLOT(slotPopupQuickHelp()));
424 QHBoxLayout *hLayout = new QHBoxLayout();
425 hLayout->addWidget(push);
426 hLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
427 verticalLayout->addLayout(hLayout);
428 }
429
430 return optionWidget;
431}
void slotPopupQuickHelp()
virtual QString quickHelp() const
Q_INVOKABLE QString toolId() const
QIcon loadIcon(const QString &name)
QWidget * optionWidget
Definition kis_tool.cc:73

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

◆ deactivate

void KisToolPaint::deactivate ( )
overrideslot

Definition at line 195 of file kis_tool_paint.cc.

196{
198 disconnect(action("increase_brush_size"), 0, this, 0);
199 disconnect(action("decrease_brush_size"), 0, this, 0);
200 }
201
202 disconnect(action("rotate_brush_tip_clockwise"), 0, this, 0);
203 disconnect(action("rotate_brush_tip_clockwise_precise"), 0, this, 0);
204 disconnect(action("rotate_brush_tip_counter_clockwise"), 0, this, 0);
205 disconnect(action("rotate_brush_tip_counter_clockwise_precise"), 0, this, 0);
206
208 Q_EMIT statusTextChanged(QString());
209
211}
void deactivate() override
Definition kis_tool.cc:131

References KoToolBase::action(), KisTool::deactivate(), KisTool::FLAG_USES_CUSTOM_SIZE, flags(), 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 508 of file kis_tool_paint.cc.

509{
510 setOutlineVisible(false);
512}
virtual void deactivatePrimaryAction()
Definition kis_tool.cc:426

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

◆ decreaseBrushSize

void KisToolPaint::decreaseBrushSize ( )
privateslot

Definition at line 551 of file kis_tool_paint.cc.

552{
553 qreal paintopSize = currentPaintOpPreset()->settings()->paintOpSize();
554
555 std::vector<int>::reverse_iterator result =
556 std::upper_bound(m_standardBrushSizes.rbegin(),
558 qRound(paintopSize),
559 std::greater<int>());
560
561 int newValue = result != m_standardBrushSizes.rend() ? *result : m_standardBrushSizes.front();
562
563 currentPaintOpPreset()->settings()->setPaintOpSize(newValue);
565}

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

◆ enableControl()

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

Definition at line 467 of file kis_tool_paint.cc.

468{
469 control->setEnabled(value);
470 QWidget *label = findLabelWidget(m_optionsWidgetLayout, control);
471 if (label) {
472 label->setEnabled(value);
473 }
474}
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 113 of file kis_tool_paint.cc.

114{
116}
@ 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 750 of file kis_tool_paint.cc.

753{
754 KisCanvas2 *canvas2 = dynamic_cast<KisCanvas2 *>(canvas());
755 KIS_ASSERT(canvas2);
756 const KisCoordinatesConverter *converter = canvas2->coordinatesConverter();
757
758 const QPointF pixelPos = convertToPixelCoord(documentPos);
759 // When touch drawing, a "hover" event means the finger was just pressed
760 // down. The last cursor position is invalid with regards to distance and
761 // speed, since it isn't updated while the finger isn't down, so reset it.
762 if (event && event->isTouchEvent() && mode() == HOVER_MODE) {
763 m_d->lastCursorPos.reset(pixelPos);
764 }
765
766 KisPaintInformation info(pixelPos);
767 info.setCanvasMirroredH(canvas2->coordinatesConverter()->xAxisMirrored());
768 info.setCanvasMirroredV(canvas2->coordinatesConverter()->yAxisMirrored());
769 info.setCanvasRotation(canvas2->coordinatesConverter()->rotationAngle());
770 info.setRandomSource(new KisRandomSource());
771 info.setPerStrokeRandomSource(new KisPerStrokeRandomSource());
772
773 const qreal currentZoom = canvas2->resourceManager() ? canvas2->resourceManager()->resource(KoCanvasResource::EffectiveZoom).toReal() : 1.0;
774
775 QPointF prevPoint = m_d->lastCursorPos.pushThroughHistory(pixelPos, currentZoom);
776 qreal startAngle = KisAlgebra2D::directionBetweenPoints(prevPoint, pixelPos, 0);
777 KisDistanceInformation distanceInfo(prevPoint, startAngle);
778
780 info.registerDistanceInformation(&distanceInfo);
781
783 brushOutline(info,
784 outlineMode, converter->effectivePhysicalZoom());
785
786 return path;
787}
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 536 of file kis_tool_paint.cc.

537{
538 qreal paintopSize = currentPaintOpPreset()->settings()->paintOpSize();
539
540 std::vector<int>::iterator result =
541 std::upper_bound(m_standardBrushSizes.begin(),
543 qRound(paintopSize));
544
545 int newValue = result != m_standardBrushSizes.end() ? *result : m_standardBrushSizes.back();
546
547 currentPaintOpPreset()->settings()->setPaintOpSize(newValue);
549}

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

◆ isEraser()

bool KisToolPaint::isEraser ( ) const
protected

◆ isOutlineEnabled()

bool KisToolPaint::isOutlineEnabled ( ) const
protected

Definition at line 514 of file kis_tool_paint.cc.

515{
516 return m_isOutlineEnabled;
517}

References m_isOutlineEnabled.

◆ isOutlineVisible()

bool KisToolPaint::isOutlineVisible ( ) const
protected

Definition at line 525 of file kis_tool_paint.cc.

526{
527 return m_isOutlineVisible;
528}

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 370 of file kis_tool_paint.cc.

371{
373 if (mode() == KisTool::HOVER_MODE) {
374 requestUpdateOutline(event->point, event);
375 }
376}
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 362 of file kis_tool_paint.cc.

363{
365 if (mode() == KisTool::HOVER_MODE) {
366 requestUpdateOutline(event->point, event);
367 }
368}
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 390 of file kis_tool_paint.cc.

391{
393 if (mode() == KisTool::HOVER_MODE) {
394 requestUpdateOutline(event->point, event);
395 }
396}
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 275 of file kis_tool_paint.cc.

276{
277 Q_UNUSED(converter);
278
280 paintToolOutline(&gc, path);
281
282 m_colorSamplerHelper.paint(gc, converter);
283}
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 378 of file kis_tool_paint.cc.

379{
380 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
381
382 if (!kisCanvas) {
383 return nullptr;
384 }
385
387 return popupWidget;
388}
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 102 of file kis_tool_paint.h.

102 {
103 return QString();
104 }

◆ 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 603 of file kis_tool_paint.cc.

604{
605 QRectF outlinePixelRect;
606 QRectF outlineDocRect;
607
608 QRectF colorPreviewDocUpdateRect;
609
610 QPointF outlineMoveVector;
611
612 if (m_supportOutline) {
613 KisConfig cfg(true);
615
616 bool useSeparateEraserCursor = cfg.separateEraserCursor() && isEraser();
617
618 const OutlineStyle currentOutlineStyle = !useSeparateEraserCursor ? cfg.newOutlineStyle() : cfg.eraserOutlineStyle();
619 const auto outlineStyleIsVisible = [&]() {
620 return currentOutlineStyle == OUTLINE_FULL ||
621 currentOutlineStyle == OUTLINE_CIRCLE ||
622 currentOutlineStyle == OUTLINE_TILT;
623 };
624 const auto shouldShowOutlineWhilePainting = [&]() {
625 return !useSeparateEraserCursor ? cfg.showOutlineWhilePainting() : cfg.showEraserOutlineWhilePainting();
626 };
629 (outlineStyleIsVisible() &&
630 (mode() == HOVER_MODE ||
631 (mode() == PAINT_MODE && shouldShowOutlineWhilePainting()))))) { // lisp forever!
632
633 outlineMode.isVisible = true;
634
635 switch (!useSeparateEraserCursor ? cfg.newOutlineStyle() : cfg.eraserOutlineStyle()) {
636 case OUTLINE_CIRCLE:
637 outlineMode.forceCircle = true;
638 break;
639 case OUTLINE_TILT:
640 outlineMode.forceCircle = true;
641 outlineMode.showTiltDecoration = true;
642 break;
643 default:
644 break;
645 }
646 }
647
648 outlineMode.forceFullSize = !useSeparateEraserCursor ? cfg.forceAlwaysFullSizedOutline() : cfg.forceAlwaysFullSizedEraserOutline();
649
650 outlineMoveVector = outlineDocPoint - m_outlineDocPoint;
651
652 m_outlineDocPoint = outlineDocPoint;
654
656 outlineDocRect = currentImage()->pixelToDocument(outlinePixelRect);
657
658 // This adjusted call is needed as we paint with a 3 pixel wide brush and the pen is outside the bounds of the path
659 // Pen uses view coordinates so we have to zoom the document value to match 2 pixel in view coordinates
660 // See BUG 275829
661 qreal zoomX;
662 qreal zoomY;
663 canvas()->viewConverter()->zoom(&zoomX, &zoomY);
664 qreal xoffset = 2.0/zoomX;
665 qreal yoffset = 2.0/zoomY;
666
667 if (!outlineDocRect.isEmpty()) {
668 outlineDocRect.adjust(-xoffset,-yoffset,xoffset,yoffset);
669 }
670
672
673 if (!colorPreviewDocUpdateRect.isEmpty()) {
674 colorPreviewDocUpdateRect = colorPreviewDocUpdateRect.adjusted(-xoffset,-yoffset,xoffset,yoffset);
675 }
676
677 }
678
679 // DIRTY HACK ALERT: we should fetch the assistant's dirty rect when requesting
680 // the update, instead of just dumbly update the entire canvas!
681
682 // WARNING: assistants code is also duplicated in KisDelegatedSelectPathWrapper::mouseMoveEvent
683
684 KisCanvas2 *kiscanvas = qobject_cast<KisCanvas2*>(canvas());
686 if (decoration && decoration->visible() && decoration->hasPaintableAssistants()) {
687 kiscanvas->updateCanvasDecorations();
688 }
689
690 if (!m_oldColorPreviewUpdateRect.isEmpty()) {
692 }
693
694 if (!m_oldOutlineRect.isEmpty()) {
696 }
697
698 if (!outlineDocRect.isEmpty()) {
722 const qreal maxUpdateAheadOutlinePortion = 0.5;
723
725 const qreal offsetFuzzyExtension = 0.1;
726
727 const qreal moveDistance = KisAlgebra2D::norm(outlineMoveVector);
728
729 QRectF offsetRect;
730
731 if (moveDistance < maxUpdateAheadOutlinePortion * KisAlgebra2D::maxDimension(outlineDocRect)) {
732 offsetRect = outlineDocRect.translated((1.0 + offsetFuzzyExtension) * outlineMoveVector);
733 }
734
735 kiscanvas->updateCanvasToolOutlineDoc(outlineDocRect | offsetRect);
736 }
737
738 if (!colorPreviewDocUpdateRect.isEmpty()) {
739 kiscanvas->updateCanvasToolOutlineDoc(colorPreviewDocUpdateRect);
740 }
741
742 m_oldOutlineRect = outlineDocRect;
743 m_oldColorPreviewUpdateRect = colorPreviewDocUpdateRect;
744}
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:303
@ PAINT_MODE
Definition kis_tool.h:300

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 575 of file kis_tool_paint.cc.

576{
577 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
578 currentPaintOpPreset()->settings()->setPaintOpAngle(angle - 15);
580}

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

◆ rotateBrushTipClockwisePrecise

void KisToolPaint::rotateBrushTipClockwisePrecise ( )
privateslot

Definition at line 582 of file kis_tool_paint.cc.

583{
584 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
585 currentPaintOpPreset()->settings()->setPaintOpAngle(angle - 1);
587}

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

◆ rotateBrushTipCounterClockwise

void KisToolPaint::rotateBrushTipCounterClockwise ( )
privateslot

Definition at line 589 of file kis_tool_paint.cc.

590{
591 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
592 currentPaintOpPreset()->settings()->setPaintOpAngle(angle + 15);
594}

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

◆ rotateBrushTipCounterClockwisePrecise

void KisToolPaint::rotateBrushTipCounterClockwisePrecise ( )
privateslot

Definition at line 596 of file kis_tool_paint.cc.

597{
598 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
599 currentPaintOpPreset()->settings()->setPaintOpAngle(angle + 1);
601}

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

◆ setMode()

void KisToolPaint::setMode ( ToolMode mode)
overrideprotectedvirtual

Reimplemented from KisTool.

Definition at line 285 of file kis_tool_paint.cc.

286{
287 if(this->mode() == KisTool::PAINT_MODE &&
289
290 // Let's add history information about recently used colors
291 Q_EMIT sigPaintingFinished();
292 }
293
295}
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 72 of file kis_tool_paint.h.

72 {
73 m_supportOutline = supportOutline;
74 }

◆ showBrushSize

void KisToolPaint::showBrushSize ( )
privateslot

Definition at line 567 of file kis_tool_paint.cc.

568{
569 KisCanvas2 *kisCanvas =dynamic_cast<KisCanvas2*>(canvas());
571 kisCanvas->viewManager()->showFloatingMessage(i18n("Brush Size: %1 px", currentPaintOpPreset()->settings()->paintOpSize())
572 , QIcon(), 1000, KisFloatingMessage::High, Qt::AlignLeft | Qt::TextWordWrap | Qt::AlignVCenter);
573}
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 KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References Private::canvas, KisTool::currentPaintOpPreset(), KisFloatingMessage::High, KIS_SAFE_ASSERT_RECOVER_RETURN, KisViewManager::showFloatingMessage(), and KisCanvas2::viewManager().

◆ showControl()

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

Definition at line 458 of file kis_tool_paint.cc.

459{
460 control->setVisible(value);
461 QWidget *label = findLabelWidget(m_optionsWidgetLayout, control);
462 if (label) {
463 label->setVisible(value);
464 }
465}

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

◆ sigPaintingFinished

void KisToolPaint::sigPaintingFinished ( )
signal

◆ slotColorPickerRequestedCursor

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

Definition at line 213 of file kis_tool_paint.cc.

214{
216}
void useCursor(const QCursor &cursor)

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

◆ slotColorPickerRequestedCursorReset

void KisToolPaint::slotColorPickerRequestedCursorReset ( )
privateslot

Definition at line 218 of file kis_tool_paint.cc.

219{
221}

References KisTool::resetCursorStyle().

◆ slotColorPickerRequestedOutlineUpdate

void KisToolPaint::slotColorPickerRequestedOutlineUpdate ( )
privateslot

Definition at line 223 of file kis_tool_paint.cc.

References m_outlineDocPoint, and requestUpdateOutline().

◆ slotPopupQuickHelp

void KisToolPaint::slotPopupQuickHelp ( )
privateslot

Definition at line 497 of file kis_tool_paint.cc.

498{
499 QWhatsThis::showText(QCursor::pos(), quickHelp());
500}

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 228 of file kis_tool_paint.cc.

229{
230 KisConfig cfg(true);
231
232 bool useSeparateEraserCursor = cfg.separateEraserCursor() && isEraser();
233
234 const OutlineStyle currentOutlineStyle = !useSeparateEraserCursor ? cfg.newOutlineStyle() : cfg.eraserOutlineStyle();
235 if (currentOutlineStyle == OUTLINE_NONE) return originalOutline;
236
237 const qreal minThresholdSize = cfg.outlineSizeMinimum();
238
245 QSize widgetSize = canvas()->canvasWidget()->size();
246 const int maxThresholdSum = widgetSize.width() + widgetSize.height();
247
248 KisOptimizedBrushOutline outline = originalOutline;
249 QRectF boundingRect = outline.boundingRect();
250 const qreal sum = boundingRect.width() + boundingRect.height();
251
252 QPointF center = boundingRect.center();
253
254 if (sum > maxThresholdSum) {
255 const int hairOffset = 7;
256
257 QPainterPath crossIcon;
258
259 crossIcon.moveTo(center.x(), center.y() - hairOffset);
260 crossIcon.lineTo(center.x(), center.y() + hairOffset);
261
262 crossIcon.moveTo(center.x() - hairOffset, center.y());
263 crossIcon.lineTo(center.x() + hairOffset, center.y());
264
265 outline.addPath(crossIcon);
266
267 } else if (sum < minThresholdSize && !outline.isEmpty()) {
268 outline = QPainterPath();
269 outline.addEllipse(center, 0.5 * minThresholdSize, 0.5 * minThresholdSize);
270 }
271
272 return outline;
273}
KisAbstractCanvasWidget * canvasWidget
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 146 of file kis_tool_paint.cc.

147{
159 KisCanvasResourceProvider *provider = qobject_cast<KisCanvas2*>(canvas())->viewManager()->canvasResourceProvider();
160
161 KisPaintOpPresetSP newPreset = provider->currentPreset();
162
163 if (newPreset) {
164 m_oldPreset = newPreset;
165 m_oldPresetIsDirty = newPreset->isDirty();
166 m_oldPresetVersion = newPreset->version();
167 }
168}
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 156 of file kis_tool_paint.h.

◆ m_currentOutline

KisOptimizedBrushOutline KisToolPaint::m_currentOutline
protected

Definition at line 130 of file kis_tool_paint.h.

◆ m_d

QScopedPointer<Private> KisToolPaint::m_d
private

Definition at line 161 of file kis_tool_paint.h.

◆ m_isOutlineEnabled

bool KisToolPaint::m_isOutlineEnabled
private

Used as a switch for sampleColor

Definition at line 148 of file kis_tool_paint.h.

◆ m_isOutlineVisible

bool KisToolPaint::m_isOutlineVisible
private

Definition at line 149 of file kis_tool_paint.h.

◆ m_oldColorPreviewUpdateRect

QRectF KisToolPaint::m_oldColorPreviewUpdateRect
protected

Definition at line 132 of file kis_tool_paint.h.

◆ m_oldOpacity

qreal KisToolPaint::m_oldOpacity {1.0}
private

Definition at line 153 of file kis_tool_paint.h.

153{1.0};

◆ m_oldOutlineRect

QRectF KisToolPaint::m_oldOutlineRect
protected

Definition at line 131 of file kis_tool_paint.h.

◆ m_oldPreset

KisPaintOpPresetSP KisToolPaint::m_oldPreset
private

Definition at line 152 of file kis_tool_paint.h.

◆ m_oldPresetIsDirty

bool KisToolPaint::m_oldPresetIsDirty {false}
private

Definition at line 154 of file kis_tool_paint.h.

154{false};

◆ m_oldPresetVersion

int KisToolPaint::m_oldPresetVersion {-1}
private

Definition at line 155 of file kis_tool_paint.h.

155{-1};

◆ m_optionsWidgetLayout

QGridLayout* KisToolPaint::m_optionsWidgetLayout {nullptr}
private

Definition at line 140 of file kis_tool_paint.h.

140{nullptr};

◆ m_outlineDocPoint

QPointF KisToolPaint::m_outlineDocPoint
protected

Definition at line 129 of file kis_tool_paint.h.

◆ m_paintOutline

bool KisToolPaint::m_paintOutline {false}
protected

Definition at line 128 of file kis_tool_paint.h.

128{false};

◆ m_specialHoverModifier

bool KisToolPaint::m_specialHoverModifier {false}
private

Definition at line 139 of file kis_tool_paint.h.

139{false};

◆ m_standardBrushSizes

std::vector<int> KisToolPaint::m_standardBrushSizes
private

Definition at line 150 of file kis_tool_paint.h.

◆ m_supportOutline

bool KisToolPaint::m_supportOutline {false}
private

Definition at line 142 of file kis_tool_paint.h.

142{false};

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