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

#include <kis_tool_shape.h>

+ Inheritance diagram for KisToolShape:

Classes

struct  ShapeAddInfo
 

Public Slots

void activate (const QSet< KoShape * > &shapes) override
 
virtual void fillSettingChanged (int value)
 
virtual void outlineSettingChanged (int value)
 
virtual void patternRotationSettingChanged (qreal value)
 
virtual void patternScaleSettingChanged (qreal value)
 
- Public Slots inherited from KisToolPaint
void activate (const QSet< KoShape * > &shapes) override
 
void deactivate () override
 
- Public Slots inherited from KisTool
void activate (const QSet< KoShape * > &shapes) override
 
void canvasResourceChanged (int key, const QVariant &res) override
 
void deactivate () override
 
virtual void updateSettingsViews ()
 
- Public Slots inherited from KoToolBase
virtual void activate (const QSet< KoShape * > &shapes)
 
virtual void deactivate ()
 
virtual void documentResourceChanged (int key, const QVariant &res)
 
virtual void repaintDecorations ()
 
virtual void requestRedoDuringStroke ()
 
virtual void requestStrokeCancellation ()
 
virtual void requestStrokeEnd ()
 
virtual void requestUndoDuringStroke ()
 
void setStatusText (const QString &statusText)
 
void updateOptionsWidgetIcons ()
 

Public Member Functions

int flags () const override
 
 KisToolShape (KoCanvasBase *canvas, const QCursor &cursor)
 
 ~KisToolShape () override
 
- Public Member Functions inherited from KisToolPaint
 KisToolPaint (KoCanvasBase *canvas, const QCursor &cursor)
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mousePressEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
KisPopupWidgetInterfacepopupWidget () override
 
 ~KisToolPaint () override
 
- Public Member Functions inherited from KisTool
virtual bool alternateActionSupportsHiResEvents (AlternateAction action) const
 
virtual void beginAlternateDoubleClickAction (KoPointerEvent *event, AlternateAction action)
 
virtual void 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
 

Public Attributes

WdgGeometryOptionsm_shapeOptionsWidget
 
- Public Attributes inherited from KisTool
KoColor currentBgColor
 
float currentExposure {1.0}
 
KoColor currentFgColor
 
KisFilterConfigurationSP currentGenerator
 
KoAbstractGradientSP currentGradient
 
KoPatternSP currentPattern
 
QCursor cursor
 
bool m_isActive {false}
 
ToolMode m_mode {HOVER_MODE}
 
QWidget * optionWidget {0}
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Protected Member Functions

void addPathShape (KoPathShape *pathShape, const KUndo2MagicString &name)
 
void addShape (KoShape *shape)
 
virtual void beginShape ()
 
QWidget * createOptionWidget () override
 
qreal currentStrokeWidth () const
 
virtual void endShape ()
 
KisToolShapeUtils::FillStyle fillStyle ()
 
QTransform fillTransform ()
 
ShapeAddInfo shouldAddShape (KisNodeSP currentNode) const
 
KisToolShapeUtils::StrokeStyle strokeStyle ()
 
- Protected Member Functions inherited from KisToolPaint
void activateAlternateAction (AlternateAction action) override
 
void activatePrimaryAction () override
 
void addOptionWidgetLayout (QLayout *layout)
 Add the tool-specific layout to the default option widget layout.
 
virtual void addOptionWidgetOption (QWidget *control, QWidget *label=nullptr)
 Add a widget and a label to the current option widget layout.
 
void beginAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void canvasResourceChanged (int key, const QVariant &v) override
 
void continueAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void deactivateAlternateAction (AlternateAction action) override
 
void deactivatePrimaryAction () override
 
void enableControl (QWidget *control, bool value)
 
void endAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
virtual KisOptimizedBrushOutline getOutlinePath (const QPointF &documentPos, const KoPointerEvent *event, KisPaintOpSettings::OutlineMode outlineMode)
 
bool isEraser () const
 
bool isOutlineEnabled () const
 
bool isOutlineVisible () const
 
void paint (QPainter &gc, const KoViewConverter &converter) override
 
virtual QString quickHelp () const
 
virtual void requestUpdateOutline (const QPointF &outlineDocPoint, const KoPointerEvent *event)
 
void setMode (ToolMode mode) override
 
void setOutlineEnabled (bool enabled)
 
void setOutlineVisible (bool visible)
 
void setSupportOutline (bool supportOutline)
 
void showControl (QWidget *control, bool value)
 
- Protected Member Functions inherited from KisTool
bool blockUntilOperationsFinished ()
 
void blockUntilOperationsFinishedForced ()
 
QPointF convertDocumentToWidget (const QPointF &pt)
 
QPoint convertToImagePixelCoordFloored (KoPointerEvent *e)
 
QPointF convertToPixelCoord (const QPointF &pt)
 
QPointF convertToPixelCoord (KoPointerEvent *e)
 
QPointF convertToPixelCoordAndAlignOnWidget (const QPointF &pt)
 
QPointF convertToPixelCoordAndSnap (const QPointF &pt, const QPointF &offset=QPointF())
 
QPointF convertToPixelCoordAndSnap (KoPointerEvent *e, const QPointF &offset=QPointF(), bool useModifiers=true)
 
QRectF convertToPt (const QRectF &rect)
 
qreal convertToPt (qreal value)
 
KoColor currentBgColor ()
 
KoColor currentFgColor ()
 
KisFilterConfigurationSP currentGenerator ()
 
KoAbstractGradientSP currentGradient ()
 
KisImageWSP currentImage ()
 
KisNodeSP currentNode () const
 
KisPaintOpPresetSP currentPaintOpPreset ()
 
KoPatternSP currentPattern ()
 
QCursor cursor () const
 
KisImageWSP image () const
 
virtual bool listeningToModifiers ()
 
virtual void listenToModifiers (bool listen)
 
virtual ToolMode mode () const
 
bool nodeEditable ()
 Checks checks if the current node is editable.
 
bool overrideCursorIfNotEditable ()
 Override the cursor appropriately if current node is not editable.
 
void paintToolOutline (QPainter *painter, const KisOptimizedBrushOutline &path)
 
KisOptimizedBrushOutline pixelToView (const KisOptimizedBrushOutline &path) const
 
QPainterPath pixelToView (const QPainterPath &pixelPath) const
 Convert a pixel path into a view path.
 
QPointF pixelToView (const QPoint &pixelCoord) const
 
QPointF pixelToView (const QPointF &pixelCoord) const
 Convert a floating point pixel coordinate into a view coordinate.
 
QPolygonF pixelToView (const QPolygonF &pixelPolygon) const
 Convert a pixel polygon into a view path.
 
QRectF pixelToView (const QRectF &pixelRect) const
 Convert a pixel rectangle into a view rectangle.
 
KisNodeList selectedNodes () const
 
bool selectionEditable ()
 Checks checks if the selection is editable, only applies to local selection as global selection is always editable.
 
void setCursor (const QCursor &cursor)
 
void updateCanvasPixelRect (const QRectF &pixelRect)
 Update the canvas for the given rectangle in image pixel coordinates.
 
void updateCanvasViewRect (const QRectF &viewRect)
 Update the canvas for the given rectangle in view coordinates.
 
QPointF viewToPixel (const QPointF &viewCoord) const
 
QPointF widgetCenterInWidgetPixels ()
 
- Protected Member Functions inherited from KoToolBase
virtual QList< QPointer< QWidget > > createOptionWidgets ()
 
int grabSensitivity () const
 Convenience function to get the current grab sensitivity.
 
qreal handleDocRadius () const
 
QRectF handleGrabRect (const QPointF &position) const
 
QRectF handlePaintRect (const QPointF &position) const
 
int handleRadius () const
 Convenience function to get the current handle radius.
 
bool isActivated () const
 
 KoToolBase (KoToolBasePrivate &dd)
 
KoPointerEventlastDeliveredPointerEvent () const
 
void setAbstractResource (KoAbstractCanvasResourceInterfaceSP abstractResource)
 
void setConverter (KoDerivedResourceConverterSP converter)
 
void setIsOpacityPresetMode (bool value)
 
void setMaskSyntheticEvents (bool value)
 
void setTextMode (bool value)
 
QHash< int, KoAbstractCanvasResourceInterfaceSPtoolAbstractResources ()
 
QHash< int, KoDerivedResourceConverterSPtoolConverters ()
 
void useCursor (const QCursor &cursor)
 

Protected Attributes

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

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
}
 
- Signals inherited from KisToolPaint
void sigPaintingFinished ()
 
- Signals inherited from KisTool
void isActiveChanged (bool isActivated)
 
- Signals inherited from KoToolBase
void activateTool (const QString &id)
 
void cursorChanged (const QCursor &cursor)
 
void selectionChanged (bool hasSelection)
 
void statusTextChanged (const QString &statusText)
 
void textModeChanged (bool inTextMode)
 
- Static Public Member Functions inherited from KisTool
static AlternateAction actionToAlternateAction (ToolAction action)
 
- 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

Base for tools specialized in drawing shapes

Definition at line 40 of file kis_tool_shape.h.

Constructor & Destructor Documentation

◆ KisToolShape()

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

Definition at line 43 of file kis_tool_shape.cc.

45{
47}
KisToolPaint(KoCanvasBase *canvas, const QCursor &cursor)
WdgGeometryOptions * m_shapeOptionsWidget
QCursor cursor
Definition kis_tool.cc:64
KisCanvas2 * canvas

References m_shapeOptionsWidget.

◆ ~KisToolShape()

KisToolShape::~KisToolShape ( )
override

Definition at line 49 of file kis_tool_shape.cc.

50{
51 // in case the widget hasn't been shown
54 }
55}

References m_shapeOptionsWidget.

Member Function Documentation

◆ activate

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

Definition at line 57 of file kis_tool_shape.cc.

58{
60 m_configGroup = KSharedConfig::openConfig()->group(toolId());
61}
void activate(const QSet< KoShape * > &shapes) override
KConfigGroup m_configGroup
Q_INVOKABLE QString toolId() const

References KisToolPaint::activate(), m_configGroup, and KoToolBase::toolId().

◆ addPathShape()

void KisToolShape::addPathShape ( KoPathShape * pathShape,
const KUndo2MagicString & name )
protected

Definition at line 246 of file kis_tool_shape.cc.

247{
248 KisNodeSP node = currentNode();
249 if (!node) {
250 return;
251 }
252
253 // Compute the outline
254 KisImageSP image = this->image();
255 QTransform matrix;
256 matrix.scale(image->xRes(), image->yRes());
257 matrix.translate(pathShape->position().x(), pathShape->position().y());
258 QPainterPath mappedOutline = matrix.map(pathShape->outline());
259
260 if (node->hasEditablePaintDevice()) {
261 KisFigurePaintingToolHelper helper(name,
262 image,
263 node,
264 canvas()->resourceManager(),
265 strokeStyle(),
266 fillStyle(),
267 fillTransform());
268 helper.paintPainterPath(mappedOutline);
269 } else if (node->inherits("KisShapeLayer")) {
270 pathShape->normalize();
271 addShape(pathShape);
272
273 }
274}
double xRes() const
double yRes() const
KisToolShapeUtils::StrokeStyle strokeStyle()
QTransform fillTransform()
void addShape(KoShape *shape)
KisToolShapeUtils::FillStyle fillStyle()
virtual QPointF normalize()
Normalizes the path data.
QPainterPath outline() const override
reimplemented
QPointF position() const
Get the position of the shape in pt.
Definition KoShape.cpp:825
bool hasEditablePaintDevice() const
KisNodeSP currentNode() const
Definition kis_tool.cc:370
KisImageWSP image() const
Definition kis_tool.cc:332

References addShape(), Private::canvas, KisTool::currentNode(), fillStyle(), fillTransform(), KisBaseNode::hasEditablePaintDevice(), KisTool::image(), KoPathShape::normalize(), KoPathShape::outline(), KisFigurePaintingToolHelper::paintPainterPath(), KoShape::position(), strokeStyle(), KisImage::xRes(), and KisImage::yRes().

◆ addShape()

void KisToolShape::addShape ( KoShape * shape)
protected

Definition at line 192 of file kis_tool_shape.cc.

193{
194 using namespace KisToolShapeUtils;
195
196 KisResourcesSnapshot resources(image(),
197 currentNode(),
198 canvas()->resourceManager());
199 switch(fillStyle()) {
201 shape->setBackground(QSharedPointer<KoColorBackground>(new KoColorBackground(resources.currentFgColor().toQColor())));
202 break;
204 shape->setBackground(QSharedPointer<KoColorBackground>(new KoColorBackground(resources.currentBgColor().toQColor())));
205 break;
206 case FillStylePattern:
208 break;
209 case FillStyleNone:
211 break;
212 }
213
214 switch (strokeStyle()) {
217 break;
220 KoShapeStrokeSP stroke(new KoShapeStroke());
221 stroke->setLineWidth(currentStrokeWidth());
222 const QColor color = strokeStyle() == KisToolShapeUtils::StrokeStyleForeground ?
223 resources.currentFgColor().toQColor() :
224 resources.currentBgColor().toQColor();
225 stroke->setColor(color);
226 shape->setStroke(stroke);
227 break;
228 }
229 }
230
231 KUndo2Command *parentCommand = new KUndo2Command();
232
234 const QList<KoShape*> oldSelectedShapes = selection->selectedShapes();
235
236 // reset selection on the newly added shape :)
237 // TODO: think about moving this into controller->addShape?
238 new KoKeepShapesSelectedCommand(oldSelectedShapes, {shape}, canvas()->selectedShapesProxy(), false, parentCommand);
239 KUndo2Command *cmd = canvas()->shapeController()->addShape(shape, 0, parentCommand);
240 parentCommand->setText(cmd->text());
241 new KoKeepShapesSelectedCommand(oldSelectedShapes, {shape}, canvas()->selectedShapesProxy(), true, parentCommand);
242
244}
QSharedPointer< KoShapeStrokeModel > KoShapeStrokeModelSP
void setText(const KUndo2MagicString &text)
KisSelectedShapesProxy selectedShapesProxy
static void runSingleCommandStroke(KisImageSP image, KUndo2Command *cmd, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
runSingleCommandStroke creates a stroke and runs cmd in it. The text() field of cmd is used as a titl...
The KisResourcesSnapshot class takes a snapshot of the various resources like colors and settings use...
KoSelection * selection() override
qreal currentStrokeWidth() const
QPointer< KoShapeController > shapeController
A simple solid color shape background.
virtual void setStroke(KoShapeStrokeModelSP stroke)
Definition KoShape.cpp:1081
virtual void setBackground(QSharedPointer< KoShapeBackground > background)
Definition KoShape.cpp:918
virtual KoToolSelection * selection()

References Private::canvas, KisResourcesSnapshot::currentBgColor(), KisResourcesSnapshot::currentFgColor(), KisTool::currentNode(), currentStrokeWidth(), KisStrokeJobData::EXCLUSIVE, fillStyle(), KisTool::image(), KisProcessingApplicator::runSingleCommandStroke(), KisCanvas2::selectedShapesProxy, KoToolBase::selection(), KisSelectedShapesProxy::selection(), KisStrokeJobData::SEQUENTIAL, KoShape::setBackground(), KoShape::setStroke(), KUndo2Command::setText(), KoCanvasBase::shapeController, strokeStyle(), KisToolShapeUtils::StrokeStyleBackground, KisToolShapeUtils::StrokeStyleForeground, KisToolShapeUtils::StrokeStyleNone, and KoColor::toQColor().

◆ beginShape()

virtual void KisToolShape::beginShape ( )
inlineprotectedvirtual

Use these methods in subclassed to notify when the user starts and finishes making a shape, and override to be notified

Reimplemented in KisToolSelectElliptical, KisToolSelectOutline, KisToolSelectPolygonal, KisToolSelectRectangular, KisBrushEnclosingProducer, KisEllipseEnclosingProducer, KisLassoEnclosingProducer, and KisRectangleEnclosingProducer.

Definition at line 84 of file kis_tool_shape.h.

84{}

◆ createOptionWidget()

QWidget * KisToolShape::createOptionWidget ( )
overrideprotectedvirtual

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

Reimplemented from KisToolPaint.

Definition at line 70 of file kis_tool_shape.cc.

71{
73
74 m_shapeOptionsWidget->cmbOutline->setCurrentIndex(KisPainter::StrokeStyleBrush);
75
76 m_shapeOptionsWidget->angleSelectorRotation->setIncreasingDirection(KisAngleGauge::IncreasingDirection_Clockwise);
77 m_shapeOptionsWidget->angleSelectorRotation->setFlipOptionsMode(KisAngleSelector::FlipOptionsMode_MenuButton);
78
79 m_shapeOptionsWidget->sldScale->setSuffix("%");
80 m_shapeOptionsWidget->sldScale->setRange(0.0, 10000.0, 2);
81 m_shapeOptionsWidget->sldScale->setSoftMaximum(500);
82 m_shapeOptionsWidget->sldScale->setSingleStep(1.0);
83
84 //connect two combo box event. Inherited classes can call the slots to make appropriate changes
85 connect(m_shapeOptionsWidget->cmbOutline, SIGNAL(currentIndexChanged(int)), this, SLOT(outlineSettingChanged(int)));
86 connect(m_shapeOptionsWidget->cmbFill, SIGNAL(currentIndexChanged(int)), this, SLOT(fillSettingChanged(int)));
87 connect(m_shapeOptionsWidget->angleSelectorRotation, SIGNAL(angleChanged(qreal)), this, SLOT(patternRotationSettingChanged(qreal)));
88 connect(m_shapeOptionsWidget->sldScale, SIGNAL(valueChanged(qreal)), this, SLOT(patternScaleSettingChanged(qreal)));
89
90 m_shapeOptionsWidget->cmbOutline->setCurrentIndex(m_configGroup.readEntry("outlineType", 0));
91 m_shapeOptionsWidget->cmbFill->setCurrentIndex(m_configGroup.readEntry("fillType", 0));
92 m_shapeOptionsWidget->sldScale->setValue(m_configGroup.readEntry("patternTransformScale", 100));
93 m_shapeOptionsWidget->angleSelectorRotation->setAngle(m_configGroup.readEntry("patternTransformRotation", 0));
94
95 //if both settings are empty, force the outline to brush so the tool will work when first activated
96 if ( m_shapeOptionsWidget->cmbFill->currentIndex() == 0 &&
97 m_shapeOptionsWidget->cmbOutline->currentIndex() == 0)
98 {
99 m_shapeOptionsWidget->cmbOutline->setCurrentIndex(1); // brush
100 }
101
102 bool enablePatternTransform = (m_shapeOptionsWidget->cmbFill->currentIndex() == int(KisToolShapeUtils::FillStylePattern));
103 m_shapeOptionsWidget->gbPatternTransform->setEnabled(enablePatternTransform);
104
106}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
@ IncreasingDirection_Clockwise
@ FlipOptionsMode_MenuButton
The flip options are shown as a menu accessible via a options button.
virtual void patternScaleSettingChanged(qreal value)
virtual void outlineSettingChanged(int value)
virtual void patternRotationSettingChanged(qreal value)
virtual void fillSettingChanged(int value)

References connect(), fillSettingChanged(), KisToolShapeUtils::FillStylePattern, KisAngleSelector::FlipOptionsMode_MenuButton, KisAngleGauge::IncreasingDirection_Clockwise, m_configGroup, m_shapeOptionsWidget, outlineSettingChanged(), patternRotationSettingChanged(), patternScaleSettingChanged(), and KisPainter::StrokeStyleBrush.

◆ currentStrokeWidth()

qreal KisToolShape::currentStrokeWidth ( ) const
protected

Definition at line 161 of file kis_tool_shape.cc.

162{
163 const qreal sizeInPx =
164 canvas()->resourceManager()->resource(KoCanvasResource::Size).toReal();
165
166 return canvas()->unit().fromUserValue(sizeInPx);
167}
KoUnit unit() const override
QPointer< KoCanvasResourceProvider > resourceManager
qreal fromUserValue(qreal value) const
Definition KoUnit.cpp:201

References Private::canvas, KoUnit::fromUserValue(), KoCanvasBase::resourceManager, KoCanvasResource::Size, and KisCanvas2::unit().

◆ endShape()

◆ fillSettingChanged

void KisToolShape::fillSettingChanged ( int value)
virtualslot

Definition at line 113 of file kis_tool_shape.cc.

114{
115 m_configGroup.writeEntry("fillType", value);
116 bool enable = (value == int(KisToolShapeUtils::FillStylePattern));
117 m_shapeOptionsWidget->gbPatternTransform->setEnabled(enable);
118}
float value(const T *src, size_t ch)

References KisToolShapeUtils::FillStylePattern, m_configGroup, m_shapeOptionsWidget, and value().

◆ fillStyle()

KisToolShapeUtils::FillStyle KisToolShape::fillStyle ( )
protected

Definition at line 130 of file kis_tool_shape.cc.

131{
133 return static_cast<KisToolShapeUtils::FillStyle>(m_shapeOptionsWidget->cmbFill->currentIndex());
134 } else {
136 }
137}

References KisToolShapeUtils::FillStyleNone, and m_shapeOptionsWidget.

◆ fillTransform()

QTransform KisToolShape::fillTransform ( )
protected

Definition at line 148 of file kis_tool_shape.cc.

149{
150 QTransform transform;
151
153 transform.rotate(m_shapeOptionsWidget->angleSelectorRotation->angle());
154 qreal scale = m_shapeOptionsWidget->sldScale->value()*0.01;
155 transform.scale(scale, scale);
156 }
157
158 return transform;
159}

References m_shapeOptionsWidget.

◆ flags()

int KisToolShape::flags ( ) const
overridevirtual

◆ outlineSettingChanged

void KisToolShape::outlineSettingChanged ( int value)
virtualslot

Definition at line 108 of file kis_tool_shape.cc.

109{
110 m_configGroup.writeEntry("outlineType", value);
111}

References m_configGroup, and value().

◆ patternRotationSettingChanged

void KisToolShape::patternRotationSettingChanged ( qreal value)
virtualslot

Definition at line 120 of file kis_tool_shape.cc.

121{
122 m_configGroup.writeEntry("patternTransformRotation", value);
123}

References m_configGroup, and value().

◆ patternScaleSettingChanged

void KisToolShape::patternScaleSettingChanged ( qreal value)
virtualslot

Definition at line 125 of file kis_tool_shape.cc.

126{
127 m_configGroup.writeEntry("patternTransformScale", value);
128}

References m_configGroup, and value().

◆ shouldAddShape()

KisToolShape::ShapeAddInfo KisToolShape::shouldAddShape ( KisNodeSP currentNode) const
protected

Definition at line 169 of file kis_tool_shape.cc.

170{
171 ShapeAddInfo info;
172
173 if (currentNode->inherits("KisShapeLayer")) {
174 info.shouldAddShape = true;
175 } else if (KisSelectionMask *mask = dynamic_cast<KisSelectionMask*>(currentNode.data())) {
176 if (mask->selection()->hasShapeSelection()) {
177 info.shouldAddShape = true;
178 info.shouldAddSelectionShape = true;
179 }
180 }
181
182 return info;
183}

References KisTool::currentNode(), KisSharedPtr< T >::data(), KisToolShape::ShapeAddInfo::shouldAddSelectionShape, and KisToolShape::ShapeAddInfo::shouldAddShape.

◆ strokeStyle()

KisToolShapeUtils::StrokeStyle KisToolShape::strokeStyle ( )
protected

Definition at line 139 of file kis_tool_shape.cc.

140{
142 return static_cast<KisToolShapeUtils::StrokeStyle>(m_shapeOptionsWidget->cmbOutline->currentIndex());
143 } else {
145 }
146}

References m_shapeOptionsWidget, and KisToolShapeUtils::StrokeStyleNone.

Member Data Documentation

◆ m_configGroup

KConfigGroup KisToolShape::m_configGroup
protected

Definition at line 87 of file kis_tool_shape.h.

◆ m_shapeOptionsWidget

WdgGeometryOptions* KisToolShape::m_shapeOptionsWidget

Definition at line 49 of file kis_tool_shape.h.


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