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}
 
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 ,
  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 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);
167 connect(action("increase_brush_size"), SIGNAL(triggered()), SLOT(increaseBrushSize()), Qt::UniqueConnection);
168 connect(action("decrease_brush_size"), SIGNAL(triggered()), SLOT(decreaseBrushSize()), Qt::UniqueConnection);
169 connect(action("increase_brush_size"), SIGNAL(triggered()), this, SLOT(showBrushSize()));
170 connect(action("decrease_brush_size"), SIGNAL(triggered()), this, SLOT(showBrushSize()));
171
172 }
173
174 connect(action("rotate_brush_tip_clockwise"), SIGNAL(triggered()), SLOT(rotateBrushTipClockwise()), Qt::UniqueConnection);
175 connect(action("rotate_brush_tip_clockwise_precise"), SIGNAL(triggered()), SLOT(rotateBrushTipClockwisePrecise()), Qt::UniqueConnection);
176 connect(action("rotate_brush_tip_counter_clockwise"), SIGNAL(triggered()), SLOT(rotateBrushTipCounterClockwise()), Qt::UniqueConnection);
177 connect(action("rotate_brush_tip_counter_clockwise_precise"), SIGNAL(triggered()), SLOT(rotateBrushTipCounterClockwisePrecise()), Qt::UniqueConnection);
178
180}
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(), 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 284 of file kis_tool_paint.cc.

285{
286 if (!isSamplingAction(action)) {
288 return;
289 }
290
291 const bool sampleCurrentLayer = action == SampleFgNode || action == SampleBgNode;
292 const bool sampleFgColor = action == SampleFgNode || action == SampleFgImage;
293 m_colorSamplerHelper.activate(sampleCurrentLayer, sampleFgColor);
294}
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 489 of file kis_tool_paint.cc.

490{
491 setOutlineVisible(true);
493}
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 463 of file kis_tool_paint.cc.

464{
465 Q_ASSERT(m_optionsWidgetLayout != 0);
466 int rowCount = m_optionsWidgetLayout->rowCount();
467 m_optionsWidgetLayout->addLayout(layout, rowCount, 0, 1, 2);
468}
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 471 of file kis_tool_paint.cc.

472{
473 Q_ASSERT(m_optionsWidgetLayout != 0);
474 if (label) {
475 m_optionsWidgetLayout->addWidget(label, m_optionsWidgetLayout->rowCount(), 0);
476 m_optionsWidgetLayout->addWidget(control, m_optionsWidgetLayout->rowCount() - 1, 1);
477 }
478 else {
479 m_optionsWidgetLayout->addWidget(control, m_optionsWidgetLayout->rowCount(), 0, 1, 2);
480 }
481}

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

314{
317
319 config.load();
320
321 m_colorSamplerHelper.startAction(event->point, config.radius, config.blend);
322 requestUpdateOutline(event->point, event);
323 } else {
325 }
326}
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 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 385 of file kis_tool_paint.cc.

386{
387 QWidget *optionWidget = new QWidget();
388 optionWidget->setObjectName(toolId());
389
390 QVBoxLayout *verticalLayout = new QVBoxLayout(optionWidget);
391 verticalLayout->setObjectName("KisToolPaint::OptionWidget::VerticalLayout");
392 verticalLayout->setContentsMargins(0,0,0,0);
393 verticalLayout->setSpacing(5);
394
395 // See https://bugs.kde.org/show_bug.cgi?id=316896
396 QWidget *specialSpacer = new QWidget(optionWidget);
397 specialSpacer->setObjectName("SpecialSpacer");
398 specialSpacer->setFixedSize(0, 0);
399 verticalLayout->addWidget(specialSpacer);
400 verticalLayout->addWidget(specialSpacer);
401
402 m_optionsWidgetLayout = new QGridLayout();
403 m_optionsWidgetLayout->setColumnStretch(1, 1);
404 verticalLayout->addLayout(m_optionsWidgetLayout);
405 m_optionsWidgetLayout->setContentsMargins(0,0,0,0);
406 m_optionsWidgetLayout->setSpacing(5);
407
408 if (!quickHelp().isEmpty()) {
409 QPushButton *push = new QPushButton(KisIconUtils::loadIcon("help-contents"), QString(), optionWidget);
410 connect(push, SIGNAL(clicked()), this, SLOT(slotPopupQuickHelp()));
411 QHBoxLayout *hLayout = new QHBoxLayout();
412 hLayout->addWidget(push);
413 hLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
414 verticalLayout->addLayout(hLayout);
415 }
416
417 return optionWidget;
418}
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 182 of file kis_tool_paint.cc.

183{
185 disconnect(action("increase_brush_size"), 0, this, 0);
186 disconnect(action("decrease_brush_size"), 0, this, 0);
187 }
188
189 disconnect(action("rotate_brush_tip_clockwise"), 0, this, 0);
190 disconnect(action("rotate_brush_tip_clockwise_precise"), 0, this, 0);
191 disconnect(action("rotate_brush_tip_counter_clockwise"), 0, this, 0);
192 disconnect(action("rotate_brush_tip_counter_clockwise_precise"), 0, this, 0);
193
195 Q_EMIT statusTextChanged(QString());
196
198}
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 495 of file kis_tool_paint.cc.

496{
497 setOutlineVisible(false);
499}
virtual void deactivatePrimaryAction()
Definition kis_tool.cc:426

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

◆ decreaseBrushSize

void KisToolPaint::decreaseBrushSize ( )
privateslot

Definition at line 531 of file kis_tool_paint.cc.

532{
533 qreal paintopSize = currentPaintOpPreset()->settings()->paintOpSize();
534 int newValue = m_standardBrushSizes.decreaseBrushSize(paintopSize);
535 currentPaintOpPreset()->settings()->setPaintOpSize(newValue);
537}

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

◆ enableControl()

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

Definition at line 454 of file kis_tool_paint.cc.

455{
456 control->setEnabled(value);
457 QWidget *label = findLabelWidget(m_optionsWidgetLayout, control);
458 if (label) {
459 label->setEnabled(value);
460 }
461}
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 719 of file kis_tool_paint.cc.

722{
723 KisCanvas2 *canvas2 = dynamic_cast<KisCanvas2 *>(canvas());
724 KIS_ASSERT(canvas2);
725 const KisCoordinatesConverter *converter = canvas2->coordinatesConverter();
726
727 const QPointF pixelPos = convertToPixelCoord(documentPos);
728 // When touch drawing, a "hover" event means the finger was just pressed
729 // down. The last cursor position is invalid with regards to distance and
730 // speed, since it isn't updated while the finger isn't down, so reset it.
731 if (event && event->isTouchEvent() && mode() == HOVER_MODE) {
732 m_d->lastCursorPos.reset(pixelPos);
733 }
734
735 KisPaintInformation info(pixelPos);
736 info.setCanvasMirroredH(canvas2->coordinatesConverter()->xAxisMirrored());
737 info.setCanvasMirroredV(canvas2->coordinatesConverter()->yAxisMirrored());
738 info.setCanvasRotation(canvas2->coordinatesConverter()->rotationAngle());
739 info.setRandomSource(new KisRandomSource());
740 info.setPerStrokeRandomSource(new KisPerStrokeRandomSource());
741
742 const qreal currentZoom = canvas2->resourceManager() ? canvas2->resourceManager()->resource(KoCanvasResource::EffectiveZoom).toReal() : 1.0;
743
744 QPointF prevPoint = m_d->lastCursorPos.pushThroughHistory(pixelPos, currentZoom);
745 qreal startAngle = KisAlgebra2D::directionBetweenPoints(prevPoint, pixelPos, 0);
746 KisDistanceInformation distanceInfo(prevPoint, startAngle);
747
749 info.registerDistanceInformation(&distanceInfo);
750
752 brushOutline(info,
753 outlineMode, converter->effectivePhysicalZoom());
754
755 return path;
756}
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 523 of file kis_tool_paint.cc.

524{
525 qreal paintopSize = currentPaintOpPreset()->settings()->paintOpSize();
526 int newValue = m_standardBrushSizes.increaseBrushSize(paintopSize);
527 currentPaintOpPreset()->settings()->setPaintOpSize(newValue);
529}

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

502{
503 return m_isOutlineEnabled;
504}

References m_isOutlineEnabled.

◆ isOutlineVisible()

bool KisToolPaint::isOutlineVisible ( ) const
protected

Definition at line 512 of file kis_tool_paint.cc.

513{
514 return m_isOutlineVisible;
515}

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

358{
360 if (mode() == KisTool::HOVER_MODE) {
361 requestUpdateOutline(event->point, event);
362 }
363}
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 349 of file kis_tool_paint.cc.

350{
352 if (mode() == KisTool::HOVER_MODE) {
353 requestUpdateOutline(event->point, event);
354 }
355}
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 377 of file kis_tool_paint.cc.

378{
380 if (mode() == KisTool::HOVER_MODE) {
381 requestUpdateOutline(event->point, event);
382 }
383}
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 262 of file kis_tool_paint.cc.

263{
264 Q_UNUSED(converter);
265
267 paintToolOutline(&gc, path);
268
269 m_colorSamplerHelper.paint(gc, converter);
270}
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 365 of file kis_tool_paint.cc.

366{
367 KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
368
369 if (!kisCanvas) {
370 return nullptr;
371 }
372
374 return popupWidget;
375}
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 572 of file kis_tool_paint.cc.

573{
574 QRectF outlinePixelRect;
575 QRectF outlineDocRect;
576
577 QRectF colorPreviewDocUpdateRect;
578
579 QPointF outlineMoveVector;
580
581 if (m_supportOutline) {
582 KisConfig cfg(true);
584
585 bool useSeparateEraserCursor = cfg.separateEraserCursor() && isEraser();
586
587 const OutlineStyle currentOutlineStyle = !useSeparateEraserCursor ? cfg.newOutlineStyle() : cfg.eraserOutlineStyle();
588 const auto outlineStyleIsVisible = [&]() {
589 return currentOutlineStyle == OUTLINE_FULL ||
590 currentOutlineStyle == OUTLINE_CIRCLE ||
591 currentOutlineStyle == OUTLINE_TILT;
592 };
593 const auto shouldShowOutlineWhilePainting = [&]() {
594 return !useSeparateEraserCursor ? cfg.showOutlineWhilePainting() : cfg.showEraserOutlineWhilePainting();
595 };
598 (outlineStyleIsVisible() &&
599 (mode() == HOVER_MODE ||
600 (mode() == PAINT_MODE && shouldShowOutlineWhilePainting()))))) { // lisp forever!
601
602 outlineMode.isVisible = true;
603
604 switch (!useSeparateEraserCursor ? cfg.newOutlineStyle() : cfg.eraserOutlineStyle()) {
605 case OUTLINE_CIRCLE:
606 outlineMode.forceCircle = true;
607 break;
608 case OUTLINE_TILT:
609 outlineMode.forceCircle = true;
610 outlineMode.showTiltDecoration = true;
611 break;
612 default:
613 break;
614 }
615 }
616
617 outlineMode.forceFullSize = !useSeparateEraserCursor ? cfg.forceAlwaysFullSizedOutline() : cfg.forceAlwaysFullSizedEraserOutline();
618
619 outlineMoveVector = outlineDocPoint - m_outlineDocPoint;
620
621 m_outlineDocPoint = outlineDocPoint;
623
625 outlineDocRect = currentImage()->pixelToDocument(outlinePixelRect);
626
627 // This adjusted call is needed as we paint with a 3 pixel wide brush and the pen is outside the bounds of the path
628 // Pen uses view coordinates so we have to zoom the document value to match 2 pixel in view coordinates
629 // See BUG 275829
630 qreal zoomX;
631 qreal zoomY;
632 canvas()->viewConverter()->zoom(&zoomX, &zoomY);
633 qreal xoffset = 2.0/zoomX;
634 qreal yoffset = 2.0/zoomY;
635
636 if (!outlineDocRect.isEmpty()) {
637 outlineDocRect.adjust(-xoffset,-yoffset,xoffset,yoffset);
638 }
639
641
642 if (!colorPreviewDocUpdateRect.isEmpty()) {
643 colorPreviewDocUpdateRect = colorPreviewDocUpdateRect.adjusted(-xoffset,-yoffset,xoffset,yoffset);
644 }
645
646 }
647
648 // DIRTY HACK ALERT: we should fetch the assistant's dirty rect when requesting
649 // the update, instead of just dumbly update the entire canvas!
650
651 // WARNING: assistants code is also duplicated in KisDelegatedSelectPathWrapper::mouseMoveEvent
652
653 KisCanvas2 *kiscanvas = qobject_cast<KisCanvas2*>(canvas());
655 if (decoration && decoration->visible() && decoration->hasPaintableAssistants()) {
656 kiscanvas->updateCanvasDecorations();
657 }
658
659 if (!m_oldColorPreviewUpdateRect.isEmpty()) {
661 }
662
663 if (!m_oldOutlineRect.isEmpty()) {
665 }
666
667 if (!outlineDocRect.isEmpty()) {
691 const qreal maxUpdateAheadOutlinePortion = 0.5;
692
694 const qreal offsetFuzzyExtension = 0.1;
695
696 const qreal moveDistance = KisAlgebra2D::norm(outlineMoveVector);
697
698 QRectF offsetRect;
699
700 if (moveDistance < maxUpdateAheadOutlinePortion * KisAlgebra2D::maxDimension(outlineDocRect)) {
701 offsetRect = outlineDocRect.translated((1.0 + offsetFuzzyExtension) * outlineMoveVector);
702 }
703
704 kiscanvas->updateCanvasToolOutlineDoc(outlineDocRect | offsetRect);
705 }
706
707 if (!colorPreviewDocUpdateRect.isEmpty()) {
708 kiscanvas->updateCanvasToolOutlineDoc(colorPreviewDocUpdateRect);
709 }
710
711 m_oldOutlineRect = outlineDocRect;
712 m_oldColorPreviewUpdateRect = colorPreviewDocUpdateRect;
713}
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 544 of file kis_tool_paint.cc.

545{
546 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
547 currentPaintOpPreset()->settings()->setPaintOpAngle(angle - 15);
549}

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

◆ rotateBrushTipClockwisePrecise

void KisToolPaint::rotateBrushTipClockwisePrecise ( )
privateslot

Definition at line 551 of file kis_tool_paint.cc.

552{
553 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
554 currentPaintOpPreset()->settings()->setPaintOpAngle(angle - 1);
556}

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

◆ rotateBrushTipCounterClockwise

void KisToolPaint::rotateBrushTipCounterClockwise ( )
privateslot

Definition at line 558 of file kis_tool_paint.cc.

559{
560 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
561 currentPaintOpPreset()->settings()->setPaintOpAngle(angle + 15);
563}

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

◆ rotateBrushTipCounterClockwisePrecise

void KisToolPaint::rotateBrushTipCounterClockwisePrecise ( )
privateslot

Definition at line 565 of file kis_tool_paint.cc.

566{
567 const qreal angle = currentPaintOpPreset()->settings()->paintOpAngle();
568 currentPaintOpPreset()->settings()->setPaintOpAngle(angle + 1);
570}

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

◆ setMode()

void KisToolPaint::setMode ( ToolMode mode)
overrideprotectedvirtual

Reimplemented from KisTool.

Definition at line 272 of file kis_tool_paint.cc.

273{
274 if(this->mode() == KisTool::PAINT_MODE &&
276
277 // Let's add history information about recently used colors
278 Q_EMIT sigPaintingFinished();
279 }
280
282}
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 539 of file kis_tool_paint.cc.

540{
542}
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 445 of file kis_tool_paint.cc.

446{
447 control->setVisible(value);
448 QWidget *label = findLabelWidget(m_optionsWidgetLayout, control);
449 if (label) {
450 label->setVisible(value);
451 }
452}

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

◆ sigPaintingFinished

void KisToolPaint::sigPaintingFinished ( )
signal

◆ slotColorPickerRequestedCursor

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

Definition at line 200 of file kis_tool_paint.cc.

201{
203}
void useCursor(const QCursor &cursor)

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

◆ slotColorPickerRequestedCursorReset

void KisToolPaint::slotColorPickerRequestedCursorReset ( )
privateslot

Definition at line 205 of file kis_tool_paint.cc.

206{
208}

References KisTool::resetCursorStyle().

◆ slotColorPickerRequestedOutlineUpdate

void KisToolPaint::slotColorPickerRequestedOutlineUpdate ( )
privateslot

Definition at line 210 of file kis_tool_paint.cc.

References m_outlineDocPoint, and requestUpdateOutline().

◆ slotPopupQuickHelp

void KisToolPaint::slotPopupQuickHelp ( )
privateslot

Definition at line 484 of file kis_tool_paint.cc.

485{
486 QWhatsThis::showText(QCursor::pos(), quickHelp());
487}

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

216{
217 KisConfig cfg(true);
218
219 bool useSeparateEraserCursor = cfg.separateEraserCursor() && isEraser();
220
221 const OutlineStyle currentOutlineStyle = !useSeparateEraserCursor ? cfg.newOutlineStyle() : cfg.eraserOutlineStyle();
222 if (currentOutlineStyle == OUTLINE_NONE) return originalOutline;
223
224 const qreal minThresholdSize = cfg.outlineSizeMinimum();
225
232 QSize widgetSize = canvas()->canvasWidget()->size();
233 const int maxThresholdSum = widgetSize.width() + widgetSize.height();
234
235 KisOptimizedBrushOutline outline = originalOutline;
236 QRectF boundingRect = outline.boundingRect();
237 const qreal sum = boundingRect.width() + boundingRect.height();
238
239 QPointF center = boundingRect.center();
240
241 if (sum > maxThresholdSum) {
242 const int hairOffset = 7;
243
244 QPainterPath crossIcon;
245
246 crossIcon.moveTo(center.x(), center.y() - hairOffset);
247 crossIcon.lineTo(center.x(), center.y() + hairOffset);
248
249 crossIcon.moveTo(center.x() - hairOffset, center.y());
250 crossIcon.lineTo(center.x() + hairOffset, center.y());
251
252 outline.addPath(crossIcon);
253
254 } else if (sum < minThresholdSize && !outline.isEmpty()) {
255 outline = QPainterPath();
256 outline.addEllipse(center, 0.5 * minThresholdSize, 0.5 * minThresholdSize);
257 }
258
259 return outline;
260}
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 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 157 of file kis_tool_paint.h.

◆ m_currentOutline

KisOptimizedBrushOutline KisToolPaint::m_currentOutline
protected

Definition at line 131 of file kis_tool_paint.h.

◆ m_d

QScopedPointer<Private> KisToolPaint::m_d
private

Definition at line 162 of file kis_tool_paint.h.

◆ m_isOutlineEnabled

bool KisToolPaint::m_isOutlineEnabled
private

Used as a switch for sampleColor

Definition at line 149 of file kis_tool_paint.h.

◆ m_isOutlineVisible

bool KisToolPaint::m_isOutlineVisible
private

Definition at line 150 of file kis_tool_paint.h.

◆ m_oldColorPreviewUpdateRect

QRectF KisToolPaint::m_oldColorPreviewUpdateRect
protected

Definition at line 133 of file kis_tool_paint.h.

◆ m_oldOpacity

qreal KisToolPaint::m_oldOpacity {1.0}
private

Definition at line 154 of file kis_tool_paint.h.

154{1.0};

◆ m_oldOutlineRect

QRectF KisToolPaint::m_oldOutlineRect
protected

Definition at line 132 of file kis_tool_paint.h.

◆ m_oldPreset

KisPaintOpPresetSP KisToolPaint::m_oldPreset
private

Definition at line 153 of file kis_tool_paint.h.

◆ m_oldPresetIsDirty

bool KisToolPaint::m_oldPresetIsDirty {false}
private

Definition at line 155 of file kis_tool_paint.h.

155{false};

◆ m_oldPresetVersion

int KisToolPaint::m_oldPresetVersion {-1}
private

Definition at line 156 of file kis_tool_paint.h.

156{-1};

◆ m_optionsWidgetLayout

QGridLayout* KisToolPaint::m_optionsWidgetLayout {nullptr}
private

Definition at line 141 of file kis_tool_paint.h.

141{nullptr};

◆ m_outlineDocPoint

QPointF KisToolPaint::m_outlineDocPoint
protected

Definition at line 130 of file kis_tool_paint.h.

◆ m_paintOutline

bool KisToolPaint::m_paintOutline {false}
protected

Definition at line 129 of file kis_tool_paint.h.

129{false};

◆ m_specialHoverModifier

bool KisToolPaint::m_specialHoverModifier {false}
private

Definition at line 140 of file kis_tool_paint.h.

140{false};

◆ m_standardBrushSizes

KisToolUtils::StandardBrushSizes KisToolPaint::m_standardBrushSizes
private

Definition at line 151 of file kis_tool_paint.h.

◆ m_supportOutline

bool KisToolPaint::m_supportOutline {false}
private

Definition at line 143 of file kis_tool_paint.h.

143{false};

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