|
Krita Source Code Documentation
|
#include <KoPencilTool.h>
Inheritance diagram for KoPencilTool:Public Member Functions | |
| 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 |
| KoCanvasBase * | canvas () const |
| Returns the canvas the tool is working on. | |
| virtual void | copy () const |
| QCursor | cursor () const |
| return the last emitted cursor | |
| virtual void | customMoveEvent (KoPointerEvent *event) |
| virtual void | customPressEvent (KoPointerEvent *event) |
| virtual void | customReleaseEvent (KoPointerEvent *event) |
| virtual void | cut () |
| virtual QRectF | decorationsRect () const |
| int | decorationThickness () const |
| decorationThickness The minimum thickness for tool decoration lines, this is derived from the screen magnification, thus the HiDPI settings. Note: to use this effectively, also set the pen to isCosmetic(true); | |
| virtual void | 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. | |
| KoToolFactoryBase * | factory () const |
| virtual void | focusInEvent (QFocusEvent *event) |
| virtual void | focusOutEvent (QFocusEvent *event) |
| virtual bool | hasSelection () |
| virtual void | inputMethodEvent (QInputMethodEvent *event) |
| virtual QVariant | inputMethodQuery (Qt::InputMethodQuery query) const |
| bool | isInTextMode () const |
| bool | isOpacityPresetMode () const |
| virtual void | 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 KisPopupWidgetInterface * | popupWidget () |
| virtual bool | selectAll () |
| selectAll select all data the tool can select. | |
| virtual KoToolSelection * | selection () |
| Q_INVOKABLE QString | toolId () const |
| virtual bool | wantsAutoScroll () const |
| ~KoToolBase () override | |
Protected Slots | |
| virtual void | slotUpdatePencilCursor () |
Private Types | |
| enum | PencilMode { ModeRaw , ModeCurve , ModeStraight } |
Private Slots | |
| void | selectMode (int mode) |
| void | setDelta (double delta) |
| void | setOptimize (int state) |
Private Member Functions | |
| void | addPoint (const QPointF &point) |
| bool | connectPaths (KoPathShape *pathShape, KoPathPoint *pointAtStart, KoPathPoint *pointAtEnd) |
| Connects given path with the ones we hit when starting/finishing. | |
| KoPathPoint * | endPointAtPosition (const QPointF &position) |
| returns the nearest existing path point | |
| void | finish (bool closePath) |
| qreal | lineAngle (const QPointF &p1, const QPointF &p2) |
Private Attributes | |
| bool | m_close {false} |
| qreal | m_combineAngle {15.0} |
| KConfigGroup | m_configGroup |
| KoPathPoint * | m_existingEndPoint {0} |
| an existing path point we finished a new path at | |
| KoPathPoint * | m_existingStartPoint {0} |
| an existing path point we started a new path at | |
| qreal | m_fittingError {5.0} |
| KoPathPoint * | m_hoveredPoint {0} |
| an existing path end point the mouse is hovering on | |
| PencilMode | m_mode {ModeCurve} |
| bool | m_optimizeCurve {false} |
| bool | m_optimizeRaw {false} |
| QList< QPointF > | m_points |
| KoPathShape * | m_shape {0} |
| KoStrokeConfigWidget * | m_strokeWidget {0} |
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 Attributes inherited from KoToolBase | |
| KoToolBasePrivate * | d_ptr |
Definition at line 21 of file KoPencilTool.h.
|
private |
|
explicit |
Definition at line 43 of file KoPencilTool.cpp.
|
override |
Definition at line 48 of file KoPencilTool.cpp.
This method is called when this tool instance is activated. For any main window there is only one tool active at a time, which then gets all user input. Switching between tools will call deactivate on one and activate on the new tool allowing the tool to flush items (like a selection) when it is not in use.
| shapes | the set of shapes that are selected or suggested for editing by a selected shape for the tool to work on. Not all shapes will be meant for this tool. |
Reimplemented from KoToolBase.
Definition at line 156 of file KoPencilTool.cpp.
References KoStrokeConfigWidget::activate(), KoToolBase::activate(), m_close, m_configGroup, m_points, m_strokeWidget, slotUpdatePencilCursor(), and KoToolBase::toolId().
|
protectedvirtual |
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 in __KisToolPencilLocalTool.
Definition at line 369 of file KoPencilTool.cpp.
References KoCanvasBase::addCommand(), KoToolBase::canvas(), connectPaths(), m_existingEndPoint, m_existingStartPoint, KoPathPoint::parent(), path(), KoShapeManager::selection, KoToolBase::selection(), KoCanvasBase::shapeController, KoCanvasBase::shapeManager(), and KoCanvasBase::updateCanvas().
|
private |
Definition at line 192 of file KoPencilTool.cpp.
References KoPathShape::boundingRect(), KoToolBase::canvas(), KoPathShape::lineTo(), m_points, m_shape, KoPathShape::moveTo(), and KoCanvasBase::updateCanvas().
|
private |
Connects given path with the ones we hit when starting/finishing.
Definition at line 491 of file KoPencilTool.cpp.
References KoPathShape::combine(), KoPathShape::moveSubpath(), KoPathPoint::parent(), KoPathShape::pathPointIndex(), KoPathShape::pointByIndex(), KoPathPointMergeCommand::redo(), KoPathShape::reverseSubpath(), KoPathShape::subpathCount(), and KoPathShape::subpathPointCount().
Reimplemented from KoToolBase.
Definition at line 280 of file KoPencilTool.cpp.
References KoStrokeConfigWidget::activate(), KoToolBase::canvas(), connect(), KoToolBase::isActivated(), m_combineAngle, m_configGroup, m_fittingError, m_mode, m_optimizeCurve, m_optimizeRaw, m_strokeWidget, selectMode(), setDelta(), KoStrokeConfigWidget::setNoSelectionTrackingMode(), setOptimize(), and slotUpdatePencilCursor().
|
protected |
Definition at line 435 of file KoPencilTool.cpp.
References KoStrokeConfigWidget::createShapeStroke(), and m_strokeWidget.
|
overridevirtual |
This method is called whenever this tool is no longer the active tool
Reimplemented from KoToolBase.
Definition at line 170 of file KoPencilTool.cpp.
References KoToolBase::deactivate(), KoStrokeConfigWidget::deactivate(), m_existingEndPoint, m_existingStartPoint, m_hoveredPoint, m_points, m_shape, and m_strokeWidget.
|
private |
returns the nearest existing path point
Definition at line 449 of file KoPencilTool.cpp.
References KoToolBase::canvas(), KoToolBase::grabSensitivity(), KoToolBase::handleGrabRect(), KoParameterShape::isParametricShape(), p, KoCanvasBase::shapeManager(), KoShapeManager::shapesAt(), squareDistance(), KoCanvasBase::viewConverter(), and KoViewConverter::viewToDocumentX().
|
private |
Definition at line 219 of file KoPencilTool.cpp.
References addPathShape(), bezierFit(), createStroke(), KoPathShapeId, lineAngle(), m_combineAngle, m_fittingError, m_mode, m_optimizeCurve, m_optimizeRaw, m_points, ModeCurve, ModeRaw, and ModeStraight.
|
protected |
Definition at line 571 of file KoPencilTool.cpp.
References m_fittingError.
|
overridevirtual |
Called when a key is pressed. Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.
| event | state and reason of this key press |
Reimplemented from KoToolBase.
Definition at line 147 of file KoPencilTool.cpp.
References m_shape.
|
private |
Definition at line 210 of file KoPencilTool.cpp.
|
overridevirtual |
Called when the mouse or stylus moved over the canvas. Implementors should call event->ignore() if they do not actually use the event.
| event | state and reason of this mouse or stylus move |
Implements KoToolBase.
Definition at line 102 of file KoPencilTool.cpp.
References addPoint(), KoPointerEvent::buttons(), KoToolBase::canvas(), endPointAtPosition(), KoToolBase::handlePaintRect(), m_hoveredPoint, KoPathPoint::parent(), KoPathPoint::point, KoPointerEvent::point, KoShape::shapeToDocument(), and KoCanvasBase::updateCanvas().
|
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.
| event | state and reason of this mouse or stylus press |
Implements KoToolBase.
Definition at line 83 of file KoPencilTool.cpp.
References addPoint(), createStroke(), endPointAtPosition(), KoPathShapeId, m_existingStartPoint, m_points, m_shape, KoPathPoint::parent(), KoPathPoint::point, KoShape::setShapeId(), KoShape::setStroke(), and KoShape::shapeToDocument().
|
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.
| event | state and reason of this mouse or stylus release |
Implements KoToolBase.
Definition at line 121 of file KoPencilTool.cpp.
References addPoint(), KoPathShape::boundingRect(), KoToolBase::canvas(), endPointAtPosition(), finish(), m_existingEndPoint, m_existingStartPoint, m_hoveredPoint, m_points, m_shape, KoPointerEvent::modifiers(), KoPathPoint::parent(), KoPathPoint::point, KoShape::shapeToDocument(), and KoCanvasBase::updateCanvas().
|
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.
| painter | used for painting the shape |
| converter | to convert between internal and view coordinates. |
Implements KoToolBase.
Definition at line 52 of file KoPencilTool.cpp.
References KoShape::absoluteTransformation(), KoShape::createHandlePainterHelperView(), KoToolBase::decorationThickness(), KoViewConverter::documentToView(), KoToolBase::handleRadius(), m_hoveredPoint, m_shape, KoPathPoint::Node, KoPathPoint::paint(), KoPathShape::paint(), KoPathPoint::parent(), KisHandleStyle::primarySelection(), KisHandlePainterHelper::setHandleStyle(), and KoShape::stroke().
|
protected |
|
privateslot |
|
privateslot |
Definition at line 423 of file KoPencilTool.cpp.
References m_combineAngle, m_configGroup, m_fittingError, m_mode, ModeCurve, and ModeStraight.
|
protected |
Definition at line 576 of file KoPencilTool.cpp.
References m_fittingError.
|
privateslot |
Definition at line 411 of file KoPencilTool.cpp.
References m_configGroup, m_mode, m_optimizeCurve, m_optimizeRaw, and ModeRaw.
|
protectedvirtualslot |
Reimplemented in __KisToolPencilLocalTool.
Definition at line 186 of file KoPencilTool.cpp.
References createStroke(), and KoToolBase::useCursor().
|
private |
Definition at line 80 of file KoPencilTool.h.
|
private |
Definition at line 78 of file KoPencilTool.h.
|
private |
Definition at line 90 of file KoPencilTool.h.
|
private |
an existing path point we finished a new path at
Definition at line 86 of file KoPencilTool.h.
|
private |
an existing path point we started a new path at
Definition at line 85 of file KoPencilTool.h.
|
private |
Definition at line 79 of file KoPencilTool.h.
|
private |
an existing path end point the mouse is hovering on
Definition at line 87 of file KoPencilTool.h.
|
private |
Definition at line 75 of file KoPencilTool.h.
|
private |
Definition at line 77 of file KoPencilTool.h.
|
private |
Definition at line 76 of file KoPencilTool.h.
|
private |
Definition at line 82 of file KoPencilTool.h.
|
private |
Definition at line 84 of file KoPencilTool.h.
|
private |
Definition at line 88 of file KoPencilTool.h.