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

#include <kis_tool_pencil.h>

+ Inheritance diagram for __KisToolPencilLocalTool:

Public Member Functions

 __KisToolPencilLocalTool (KoCanvasBase *canvas, KisToolPencil *parentTool)
 
void addPathShape (KoPathShape *pathShape, bool closePath) override
 
QList< QPointer< QWidget > > createOptionWidgets () override
 
void paint (QPainter &painter, const KoViewConverter &converter) override
 
virtual void paintPath (KoPathShape *path, QPainter &painter, const KoViewConverter &converter)
 
- Public Member Functions inherited from KoPencilTool
void activate (const QSet< KoShape * > &shapes) override
 
void deactivate () override
 
void keyPressEvent (QKeyEvent *event) override
 
 KoPencilTool (KoCanvasBase *canvas)
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mousePressEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
void paint (QPainter &painter, const KoViewConverter &converter) override
 
 ~KoPencilTool () override
 
- 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 deleteSelection ()
 
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 keyReleaseEvent (QKeyEvent *event)
 
 KoToolBase (KoCanvasBase *canvas)
 
bool maskSyntheticEvents () const
 
virtual void mouseDoubleClickEvent (KoPointerEvent *event)
 
virtual void mouseTripleClickEvent (KoPointerEvent *event)
 
QList< QPointer< QWidget > > optionWidgets ()
 
virtual bool paste ()
 
virtual QMenu * popupActionsMenu ()
 
virtual KisPopupWidgetInterfacepopupWidget ()
 
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 slotUpdatePencilCursor () override
 
- Protected Member Functions inherited from KoPencilTool
QList< QPointer< QWidget > > createOptionWidgets () override
 
KoShapeStrokeSP createStroke ()
 
qreal getFittingError ()
 
KoPathShapepath ()
 
void setFittingError (qreal fittingError)
 
- Protected Member Functions inherited from KoToolBase
virtual QWidget * createOptionWidget ()
 
int grabSensitivity () const
 Convenience function to get the current grab sensitivity.
 
qreal handleDocRadius () const
 
QRectF handleGrabRect (const QPointF &position) const
 
QRectF handlePaintRect (const QPointF &position) const
 
int handleRadius () const
 Convenience function to get the current handle radius.
 
bool isActivated () const
 
 KoToolBase (KoToolBasePrivate &dd)
 
KoPointerEventlastDeliveredPointerEvent () const
 
void setAbstractResource (KoAbstractCanvasResourceInterfaceSP abstractResource)
 
void setConverter (KoDerivedResourceConverterSP converter)
 
void setIsOpacityPresetMode (bool value)
 
void setMaskSyntheticEvents (bool value)
 
void setTextMode (bool value)
 
QHash< int, KoAbstractCanvasResourceInterfaceSPtoolAbstractResources ()
 
QHash< int, KoDerivedResourceConverterSPtoolConverters ()
 
void useCursor (const QCursor &cursor)
 

Private Attributes

KisToolPencil *const m_parentTool
 

Additional Inherited Members

- Public Slots inherited from KoToolBase
virtual void canvasResourceChanged (int key, const QVariant &res)
 
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 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)
 
- Protected Slots inherited from KoPencilTool
- Protected Attributes inherited from KoToolBase
KoToolBasePrivated_ptr
 

Detailed Description

Definition at line 23 of file kis_tool_pencil.h.

Constructor & Destructor Documentation

◆ __KisToolPencilLocalTool()

__KisToolPencilLocalTool::__KisToolPencilLocalTool ( KoCanvasBase * canvas,
KisToolPencil * parentTool )

Definition at line 97 of file kis_tool_pencil.cc.

98 : KoPencilTool(canvas), m_parentTool(parentTool) {
100}
KoPencilTool(KoCanvasBase *canvas)
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
void setIsOpacityPresetMode(bool value)
KisToolPencil *const m_parentTool

References KoToolBase::setIsOpacityPresetMode().

Member Function Documentation

◆ addPathShape()

void __KisToolPencilLocalTool::addPathShape ( KoPathShape * path,
bool closePath )
overridevirtual

Add path shape to document. This method can be overridden and change the behaviour of the tool. In that case the subclass takes ownership of pathShape. It gets only called, if there are two or more points in the path.

Reimplemented from KoPencilTool.

Definition at line 126 of file kis_tool_pencil.cc.

127{
128 if (closePath) {
129 pathShape->close();
130 pathShape->normalize();
131 }
132
133 m_parentTool->addPathShape(pathShape, kundo2_i18n("Draw Freehand Path"));
134}
KUndo2MagicString kundo2_i18n(const char *text)

References KoPathShape::close(), kundo2_i18n(), m_parentTool, and KoPathShape::normalize().

◆ createOptionWidgets()

QList< QPointer< QWidget > > KoPencilTool::createOptionWidgets ( )
overridevirtual

Reimplemented from KoToolBase.

Definition at line 39 of file KoPencilTool.cpp.

281{
282 m_mode = static_cast<PencilMode>(m_configGroup.readEntry<int>("pencilMode", m_mode));
283 m_optimizeRaw = m_configGroup.readEntry<bool>("optimizeRaw", m_optimizeRaw);
284 m_optimizeCurve = m_configGroup.readEntry<bool>("optimizeCurve", m_optimizeCurve);
285 m_combineAngle = m_configGroup.readEntry<qreal>("combineAngle", m_combineAngle);
286 m_fittingError = m_configGroup.readEntry<qreal>("fittingError", m_fittingError);
287
288 QList<QPointer<QWidget> > widgets;
289 QWidget *optionWidget = new QWidget();
290 QVBoxLayout * layout = new QVBoxLayout(optionWidget);
291
292 QHBoxLayout *modeLayout = new QHBoxLayout;
293 modeLayout->setSpacing(3);
294 QLabel *modeLabel = new QLabel(i18n("Precision:"), optionWidget);
295 QComboBox * modeBox = new QComboBox(optionWidget);
296 modeBox->addItem(i18nc("The raw line data", "Raw"));
297 modeBox->addItem(i18n("Curve"));
298 modeBox->addItem(i18n("Straight"));
299 modeLayout->addWidget(modeLabel);
300 modeLayout->addWidget(modeBox, 1);
301 layout->addLayout(modeLayout);
302
303 QStackedWidget * stackedWidget = new QStackedWidget(optionWidget);
304
305 QWidget * rawBox = new QWidget(stackedWidget);
306 QVBoxLayout * rawLayout = new QVBoxLayout(rawBox);
307 QCheckBox * optimizeRaw = new QCheckBox(i18n("Optimize"), rawBox);
308 optimizeRaw->setChecked(m_optimizeRaw);
309 rawLayout->addWidget(optimizeRaw);
310 rawLayout->setContentsMargins(0, 0, 0, 0);
311
312 QWidget * curveBox = new QWidget(stackedWidget);
313 QHBoxLayout * curveLayout = new QHBoxLayout(curveBox);
314 QCheckBox * optimizeCurve = new QCheckBox(i18n("Optimize"), curveBox);
315 optimizeCurve->setChecked(m_optimizeCurve);
316 QDoubleSpinBox * fittingError = new KisDoubleParseSpinBox(curveBox);
317 fittingError->setSingleStep(0.50);
318 fittingError->setMaximum(400.0);
319 fittingError->setMinimum(0.0);
320 fittingError->setValue(m_fittingError);
321 fittingError->setToolTip(i18n("Exactness:"));
322 curveLayout->addWidget(optimizeCurve);
323 curveLayout->addWidget(fittingError);
324 curveLayout->setContentsMargins(0, 0, 0, 0);
325
326 QWidget *straightBox = new QWidget(stackedWidget);
327 QVBoxLayout *straightLayout = new QVBoxLayout(straightBox);
328 QDoubleSpinBox *combineAngle = new KisDoubleParseSpinBox(straightBox);
329 combineAngle->setSingleStep(0.50);
330 combineAngle->setMaximum(360.0);
331 combineAngle->setMinimum(0.0);
332 combineAngle->setValue(m_combineAngle);
333 combineAngle->setSuffix(" deg");
334 // QT5TODO
335 //combineAngle->setLabel(i18n("Combine angle:"), Qt::AlignLeft | Qt::AlignVCenter);
336 straightLayout->addWidget(combineAngle);
337 straightLayout->setContentsMargins(0, 0, 0, 0);
338
339 stackedWidget->addWidget(rawBox);
340 stackedWidget->addWidget(curveBox);
341 stackedWidget->addWidget(straightBox);
342 layout->addWidget(stackedWidget);
343 layout->addStretch(1);
344
345 connect(modeBox, SIGNAL(activated(int)), stackedWidget, SLOT(setCurrentIndex(int)));
346 connect(modeBox, SIGNAL(activated(int)), this, SLOT(selectMode(int)));
347 connect(optimizeRaw, SIGNAL(stateChanged(int)), this, SLOT(setOptimize(int)));
348 connect(optimizeCurve, SIGNAL(stateChanged(int)), this, SLOT(setOptimize(int)));
349 connect(fittingError, SIGNAL(valueChanged(double)), this, SLOT(setDelta(double)));
350 connect(combineAngle, SIGNAL(valueChanged(double)), this, SLOT(setDelta(double)));
351
352 modeBox->setCurrentIndex(m_mode);
353 stackedWidget->setCurrentIndex(m_mode);
354 optionWidget->setObjectName(i18n("Pencil"));
355 optionWidget->setWindowTitle(i18n("Pencil"));
356 widgets.append(optionWidget);
357
360 m_strokeWidget->setWindowTitle(i18n("Line"));
361 connect(m_strokeWidget, SIGNAL(sigStrokeChanged()), SLOT(slotUpdatePencilCursor()));
362 if (isActivated()) {
364 }
365 widgets.append(m_strokeWidget);
366 return widgets;
367}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.
void setDelta(double delta)
void selectMode(int mode)
qreal m_fittingError
KoStrokeConfigWidget * m_strokeWidget
PencilMode m_mode
KConfigGroup m_configGroup
bool m_optimizeCurve
void setOptimize(int state)
qreal m_combineAngle
A widget for configuring the stroke of a shape.
void setNoSelectionTrackingMode(bool value)
bool isActivated() const
void slotUpdatePencilCursor() override

◆ paint()

void __KisToolPencilLocalTool::paint ( QPainter & painter,
const KoViewConverter & converter )
overridevirtual

Called by the canvas to paint any decorations that the tool deems needed. The painter has the top left of the canvas as its origin.

Parameters
painterused for painting the shape
converterto convert between internal and view coordinates.

Implements KoToolBase.

Definition at line 102 of file kis_tool_pencil.cc.

103{
104 if (m_parentTool->strokeStyle() == KisToolShapeUtils::StrokeStyleNone) {
105 paintPath(path(), painter, converter);
106 } else {
107 KoPencilTool::paint(painter, converter);
108 }
109}
KoPathShape * path()
void paint(QPainter &painter, const KoViewConverter &converter) override
virtual void paintPath(KoPathShape *path, QPainter &painter, const KoViewConverter &converter)

References m_parentTool, KoPencilTool::paint(), paintPath(), KoPencilTool::path(), and KisToolShapeUtils::StrokeStyleNone.

◆ paintPath()

void __KisToolPencilLocalTool::paintPath ( KoPathShape * path,
QPainter & painter,
const KoViewConverter & converter )
virtual

Definition at line 113 of file kis_tool_pencil.cc.

114{
115 Q_UNUSED(converter);
116 if (!pathShape) {
117 return;
118 }
119
120 QTransform matrix;
121 matrix.scale(m_parentTool->image()->xRes(), m_parentTool->image()->yRes());
122 matrix.translate(pathShape->position().x(), pathShape->position().y());
123 m_parentTool->paintToolOutline(&painter, m_parentTool->pixelToView(matrix.map(pathShape->outline())));
124}

References m_parentTool, KoPathShape::outline(), and KoShape::position().

◆ slotUpdatePencilCursor()

void __KisToolPencilLocalTool::slotUpdatePencilCursor ( )
overrideprotectedvirtual

Reimplemented from KoPencilTool.

Definition at line 136 of file kis_tool_pencil.cc.

137{
138 KoShapeStrokeSP stroke = this->createStroke();
139 m_parentTool->updatePencilCursor(stroke && stroke->isVisible());
140}
void updatePencilCursor(bool value)
KoShapeStrokeSP createStroke()

References KoPencilTool::createStroke(), m_parentTool, and KisToolPencil::updatePencilCursor().

Member Data Documentation

◆ m_parentTool

KisToolPencil* const __KisToolPencilLocalTool::m_parentTool
private

Definition at line 36 of file kis_tool_pencil.h.


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