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

#include <kis_tool_ellipse.h>

+ Inheritance diagram for KisToolEllipse:

Public Member Functions

 KisToolEllipse (KoCanvasBase *canvas)
 
bool supportsPaintingAssistants () const override
 
 ~KisToolEllipse () override
 
- Public Member Functions inherited from KisToolEllipseBase
 KisToolEllipseBase (KoCanvasBase *canvas, KisToolEllipseBase::ToolType type, const QCursor &cursor=KisCursor::load("tool_ellipse_cursor.png", 6, 6))
 
void paintRectangle (QPainter &gc, const QRectF &imageRect) override
 
- Public Member Functions inherited from KisToolRectangleBase
void activate (const QSet< KoShape * > &shapes) override
 
void beginPrimaryAction (KoPointerEvent *event) override
 
void continuePrimaryAction (KoPointerEvent *event) override
 
QList< QPointer< QWidget > > createOptionWidgets () override
 
void deactivate () override
 
void endPrimaryAction (KoPointerEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void keyReleaseEvent (QKeyEvent *event) override
 
 KisToolRectangleBase (KoCanvasBase *canvas, KisToolRectangleBase::ToolType type, const QCursor &cursor=KisCursor::load("tool_rectangle_cursor.png", 6, 6))
 
void paint (QPainter &gc, const KoViewConverter &converter) override
 
void showSize ()
 
- Public Member Functions inherited from KisToolShape
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
 
KisPopupWidgetInterface * popupWidget () override
 
 ~KisToolPaint () override
 
- Public Member Functions inherited from KisTool
virtual bool alternateActionSupportsHiResEvents (AlternateAction action) const
 
virtual void beginAlternateDoubleClickAction (KoPointerEvent *event, AlternateAction action)
 
virtual void beginPrimaryDoubleClickAction (KoPointerEvent *event)
 
void deleteSelection () override
 
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
 
 ~KisTool () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- 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 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 the Enter key or any equivalent key. 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
 
 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 KoToolSelection * selection ()
 
Q_INVOKABLE QString toolId () const
 
virtual bool wantsAutoScroll () const
 
 ~KoToolBase () override
 

Protected Types

enum  PlacementMode { BoundingBoxPlacement , ThreePointPlacement }
 
- 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

void resetCursorStyle () override
 
void slotPlacementModeChanged (int mode, bool checked)
 
- Protected Slots inherited from KisTool
virtual void resetCursorStyle ()
 

Protected Member Functions

void beginPrimaryAction (KoPointerEvent *event) override
 
void continuePrimaryAction (KoPointerEvent *event) override
 
QList< QPointer< QWidget > > createOptionWidgets () override
 
void deactivate () override
 
void endPrimaryAction (KoPointerEvent *event) override
 
void finishRect (const QRectF &rect, qreal roundCornersX, qreal roundCornersY) override
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void paint (QPainter &gc, const KoViewConverter &converter) override
 
KisPopupWidgetInterface * popupWidget () override
 
void requestStrokeCancellation () override
 
void requestStrokeEnd () override
 
- Protected Member Functions inherited from KisToolEllipseBase
bool showRoundCornersGUI () const override
 
- Protected Member Functions inherited from KisToolRectangleBase
void applyConstraints (QSizeF &area, bool overrideRatio)
 
void cancelStroke ()
 
virtual QRectF createRect (const QPointF &start, const QPointF &end)
 
QPainterPath drawX (const QPointF &pt)
 
void endStroke ()
 
void getRotatedPath (QPainterPath &path, const QPointF &center, const qreal &angle)
 
qreal getRotationAngle ()
 
bool isFixedSize ()
 
void updateArea ()
 
- Protected Member Functions inherited from KisToolShape
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
 
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
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)
 
KoPointerEvent * lastDeliveredPointerEvent () const
 
void setAbstractResource (KoAbstractCanvasResourceInterfaceSP abstractResource)
 
void setConverter (KoDerivedResourceConverterSP converter)
 
void setIsOpacityPresetMode (bool value)
 
void setMaskSyntheticEvents (bool value)
 
void setTextMode (bool value)
 
QHash< int, KoAbstractCanvasResourceInterfaceSP > toolAbstractResources ()
 
QHash< int, KoDerivedResourceConverterSP > toolConverters ()
 
void useCursor (const QCursor &cursor)
 

Private Member Functions

void addThreePointEllipsePath (const QPainterPath &path)
 
void cancelThreePointEllipse ()
 
bool canStartThreePointEllipse (KoPointerEvent *event)
 
void commitThreePointEllipse ()
 
bool hasCompleteThreePointEllipse () const
 
bool isThreePointPlacement () const
 
void paintThreePointEllipse (QPainter &gc)
 
void paintThreePointHandles (QPainter &gc)
 
void resetThreePointState ()
 
QCursor threePointConfirmCursor () const
 
bool threePointEllipsePath (const QPointF &thirdPoint, QPainterPath *path) const
 
int threePointHandleAt (const QPointF &pos) const
 
QPointF threePointPreviewPoint () const
 
QRectF threePointUpdateRect () const
 
void updateThreePointCursor (const QPointF &pos)
 
void updateThreePointPreview (const QPointF &pos)
 

Private Attributes

PlacementMode m_placementMode {BoundingBoxPlacement}
 
bool m_threePointCommitInProgress {false}
 
bool m_threePointCommittedOnPress {false}
 
int m_threePointDraggedHandle {-1}
 
bool m_threePointEllipseActive {false}
 
QVector< QPointF > m_threePointHandles
 
QPointF m_threePointHoverPoint
 

Additional Inherited Members

- Public Types inherited from KisToolRectangleBase
enum  ToolType { PAINT , SELECT }
 
- 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 ,
  SampleFgGroup = AlternateSampleFgGroup , SampleBgGroup = AlternateSampleBgGroup , 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 , AlternateSampleFgGroup , AlternateSampleBgGroup , AlternateSampleFgImage ,
  AlternateSampleBgImage , AlternateSecondary , AlternateThird , AlternateFourth ,
  AlternateFifth , Alternate_NONE = 10000
}
 
- Public Slots inherited from KisToolRectangleBase
void constraintsChanged (bool forceRatio, bool forceWidth, bool forceHeight, float ratio, float width, float height)
 
void requestStrokeCancellation () override
 
void requestStrokeEnd () override
 
void roundCornersChanged (int rx, int ry)
 
- Public Slots inherited from KisToolShape
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 documentResourceChanged (int key, const QVariant &res)
 
virtual void repaintDecorations ()
 
virtual void requestRedoDuringStroke ()
 
virtual void requestUndoDuringStroke ()
 
void setStatusText (const QString &statusText)
 
void updateOptionsWidgetIcons ()
 
- Signals inherited from KisToolRectangleBase
void rectangleChanged (const QRectF &newRect)
 
void sigRequestReloadConfig ()
 
- 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)
 
- Public Attributes inherited from KisToolShape
WdgGeometryOptions * m_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
KisCanvas2 * canvas
 
int displayedFrame
 
int intendedFrame
 
- Protected Attributes inherited from KisToolRectangleBase
qreal m_angle
 
qreal m_angleBuffer
 
Qt::KeyboardModifiers m_currentModifiers
 
QPointF m_dragCenter
 
QPointF m_dragEnd
 
QPointF m_dragStart
 
float m_forcedHeight
 
float m_forcedRatio
 
float m_forcedWidth
 
bool m_isHeightForced
 
bool m_isRatioForced
 
bool m_isWidthForced
 
qreal m_referenceAngle
 
bool m_rotateActive
 
int m_roundCornersX
 
int m_roundCornersY
 
ToolType m_type
 
- Protected Attributes inherited from KisToolShape
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
KoToolBasePrivate * d_ptr
 
- Properties inherited from KisTool
bool isActive
 

Detailed Description

Definition at line 27 of file kis_tool_ellipse.h.

Member Enumeration Documentation

◆ PlacementMode

Enumerator
BoundingBoxPlacement 
ThreePointPlacement 

Definition at line 42 of file kis_tool_ellipse.h.

Constructor & Destructor Documentation

◆ KisToolEllipse()

KisToolEllipse::KisToolEllipse ( KoCanvasBase * canvas)

Definition at line 54 of file kis_tool_ellipse.cc.

55 : KisToolEllipseBase(canvas, KisToolEllipseBase::PAINT, KisCursor::loadWithSize("tool_ellipse_cursor.svg", 32, 32, 6, 6))
56{
57 setObjectName("tool_ellipse");
60
61 KisCanvas2 *kritaCanvas = dynamic_cast<KisCanvas2*>(canvas);
62
63 connect(kritaCanvas->viewManager()->canvasResourceProvider(), SIGNAL(sigEffectiveCompositeOpChanged()), SLOT(resetCursorStyle()));
64}
KisViewManager * viewManager() const
static QCursor loadWithSize(const QString &cursorName, int width, int height, int hotspotX=-1, int hotspotY=-1)
KisToolEllipseBase(KoCanvasBase *canvas, KisToolEllipseBase::ToolType type, const QCursor &cursor=KisCursor::load("tool_ellipse_cursor.png", 6, 6))
void resetCursorStyle() override
void setSupportOutline(bool supportOutline)
KisCanvasResourceProvider * canvasResourceProvider()
void setIsOpacityPresetMode(bool value)
KisCanvas2 * canvas

References Private::canvas, KisViewManager::canvasResourceProvider(), resetCursorStyle(), KoToolBase::setIsOpacityPresetMode(), KisToolPaint::setSupportOutline(), and KisCanvas2::viewManager().

◆ ~KisToolEllipse()

KisToolEllipse::~KisToolEllipse ( )
override

Definition at line 66 of file kis_tool_ellipse.cc.

67{
68}

Member Function Documentation

◆ addThreePointEllipsePath()

void KisToolEllipse::addThreePointEllipsePath ( const QPainterPath & path)
private

Definition at line 581 of file kis_tool_ellipse.cc.

582{
583 const KisToolShape::ShapeAddInfo info =
585
586 if (!info.shouldAddShape) {
587 KisFigurePaintingToolHelper helper(kundo2_i18n("Draw Ellipse"),
588 image(),
589 currentNode(),
590 canvas()->resourceManager(),
591 strokeStyle(),
592 fillStyle(),
593 fillTransform());
594 helper.paintPainterPath(path);
595 } else {
596 QPainterPath documentPath = path;
597 if (image()) {
598 QTransform pixelToDocument;
599 pixelToDocument.scale(1.0 / image()->xRes(), 1.0 / image()->yRes());
600 documentPath = pixelToDocument.map(path);
601 }
602
605 if (info.shouldAddSelectionShape) {
606 shape->normalize();
607 addShape(shape);
608 } else {
609 addPathShape(shape, kundo2_i18n("Draw Ellipse"));
610 }
611 }
612}
KisToolShapeUtils::StrokeStyle strokeStyle()
ShapeAddInfo shouldAddShape(KisNodeSP currentNode) const
void addPathShape(KoPathShape *pathShape, const KUndo2MagicString &name)
QTransform fillTransform()
void addShape(KoShape *shape)
KisToolShapeUtils::FillStyle fillStyle()
The position of a path point within a path shape.
Definition KoPathShape.h:63
virtual QPointF normalize()
Normalizes the path data.
static KoPathShape * createShapeFromPainterPath(const QPainterPath &path)
Creates path shape from given QPainterPath.
KUndo2MagicString kundo2_i18n(const char *text)
void markAsSelectionShapeIfNeeded(KoShape *shape) const
KisNodeSP currentNode() const
Definition kis_tool.cc:370
KisImageWSP image() const
Definition kis_tool.cc:332

References KisToolShape::addPathShape(), KisToolShape::addShape(), Private::canvas, KoPathShape::createShapeFromPainterPath(), KisTool::currentNode(), KisToolShape::fillStyle(), KisToolShape::fillTransform(), KisTool::image(), kundo2_i18n(), KisToolShape::ShapeAddInfo::markAsSelectionShapeIfNeeded(), KoPathShape::normalize(), KisFigurePaintingToolHelper::paintPainterPath(), KisToolShape::ShapeAddInfo::shouldAddSelectionShape, KisToolShape::ShapeAddInfo::shouldAddShape, KisToolShape::shouldAddShape(), and KisToolShape::strokeStyle().

◆ beginPrimaryAction()

void KisToolEllipse::beginPrimaryAction ( KoPointerEvent * event)
overrideprotectedvirtual

Called by KisToolProxy when a primary action for the tool is started. The event stores the original event that started the stroke. The event is accepted by default. If the tool decides to ignore this particular action (e.g. when the node is not editable), it should call event->ignore(). Then no further continuePrimaryAction() or endPrimaryAction() will be called until the next user action.

Reimplemented from KisTool.

Definition at line 245 of file kis_tool_ellipse.cc.

246{
247 if (!isThreePointPlacement()) {
249 return;
250 }
251
252 if (!canStartThreePointEllipse(event)) {
253 return;
254 }
255
261 event->accept();
262 return;
263 } else {
265 }
266 }
267
269 event->accept();
270}
static QCursor pointingHandCursor()
bool canStartThreePointEllipse(KoPointerEvent *event)
bool isThreePointPlacement() const
bool m_threePointCommittedOnPress
bool hasCompleteThreePointEllipse() const
int threePointHandleAt(const QPointF &pos) const
void setMode(ToolMode mode) override
void useCursor(const QCursor &cursor)
virtual void beginPrimaryAction(KoPointerEvent *event)
Definition kis_tool.cc:431
@ PAINT_MODE
Definition kis_tool.h:304
QPointF convertToPixelCoordAndSnap(KoPointerEvent *e, const QPointF &offset=QPointF(), bool useModifiers=true)
Definition kis_tool.cc:214

References KisTool::beginPrimaryAction(), canStartThreePointEllipse(), commitThreePointEllipse(), KisTool::convertToPixelCoordAndSnap(), hasCompleteThreePointEllipse(), isThreePointPlacement(), m_threePointCommittedOnPress, m_threePointDraggedHandle, KisTool::PAINT_MODE, KisCursor::pointingHandCursor(), KisToolPaint::setMode(), threePointHandleAt(), and KoToolBase::useCursor().

◆ cancelThreePointEllipse()

void KisToolEllipse::cancelThreePointEllipse ( )
private

Definition at line 441 of file kis_tool_ellipse.cc.

442{
444 return;
445 }
446
449}
QVector< QPointF > m_threePointHandles
QRectF threePointUpdateRect() const
void updateCanvasPixelRect(const QRectF &pixelRect)
Update the canvas for the given rectangle in image pixel coordinates.
Definition kis_tool.cc:322

References m_threePointEllipseActive, m_threePointHandles, resetThreePointState(), threePointUpdateRect(), and KisTool::updateCanvasPixelRect().

◆ canStartThreePointEllipse()

bool KisToolEllipse::canStartThreePointEllipse ( KoPointerEvent * event)
private

Definition at line 155 of file kis_tool_ellipse.cc.

156{
157 NodePaintAbility paintability = nodePaintAbility();
158 if (!nodeEditable() || paintability == UNPAINTABLE || paintability == KisToolPaint::CLONE || paintability == KisToolPaint::MYPAINTBRUSH_UNPAINTABLE) {
159 if (paintability == KisToolPaint::CLONE) {
160 KisCanvas2 *kiscanvas = static_cast<KisCanvas2*>(canvas());
161 kiscanvas->viewManager()->showFloatingMessage(
162 i18n("This tool cannot paint on clone layers. Please select a paint or vector layer or mask."),
163 koIcon("object-locked"));
164 }
165
166 if (paintability == KisToolPaint::MYPAINTBRUSH_UNPAINTABLE) {
167 KisCanvas2 *kiscanvas = static_cast<KisCanvas2*>(canvas());
168 kiscanvas->viewManager()->showFloatingMessage(
169 i18n("The MyPaint Brush Engine is not available for this colorspace"),
170 koIcon("object-locked"));
171 }
172
173 event->ignore();
174 return false;
175 }
176
177 return true;
178}
void showFloatingMessage(const QString &message, const QIcon &icon, int timeout=4500, KisFloatingMessage::Priority priority=KisFloatingMessage::Medium, int alignment=Qt::AlignCenter|Qt::TextWordWrap)
shows a floating message in the top right corner of the canvas
#define koIcon(name)
Use these macros for icons without any issues.
Definition kis_icon.h:25
KisTool::NodePaintAbility nodePaintAbility()
Definition kis_tool.cc:539
bool nodeEditable()
Checks checks if the current node is editable.
Definition kis_tool.cc:651
NodePaintAbility
Definition kis_tool.h:152
@ MYPAINTBRUSH_UNPAINTABLE
Definition kis_tool.h:157
@ UNPAINTABLE
Definition kis_tool.h:156

References Private::canvas, KisTool::CLONE, koIcon, KisTool::MYPAINTBRUSH_UNPAINTABLE, KisTool::nodeEditable(), KisTool::nodePaintAbility(), KisViewManager::showFloatingMessage(), KisTool::UNPAINTABLE, and KisCanvas2::viewManager().

◆ commitThreePointEllipse()

void KisToolEllipse::commitThreePointEllipse ( )
private

Definition at line 451 of file kis_tool_ellipse.cc.

452{
454 return;
455 }
456
457 QPainterPath path;
459 return;
460 }
461
462 const QRectF updateRect = threePointUpdateRect().united(path.boundingRect());
463 updateCanvasPixelRect(updateRect);
464
465 // The painting helper starts a stroke, which re-emits requestStrokeEnd().
466 // Clear the pending preview before painting to avoid recursive commits.
471
472 updateCanvasPixelRect(updateRect);
473}
bool threePointEllipsePath(const QPointF &thirdPoint, QPainterPath *path) const
QPointF threePointPreviewPoint() const
void addThreePointEllipsePath(const QPainterPath &path)
bool m_threePointCommitInProgress

References addThreePointEllipsePath(), m_threePointCommitInProgress, resetThreePointState(), threePointEllipsePath(), threePointPreviewPoint(), threePointUpdateRect(), and KisTool::updateCanvasPixelRect().

◆ continuePrimaryAction()

void KisToolEllipse::continuePrimaryAction ( KoPointerEvent * event)
overrideprotectedvirtual

Called by KisToolProxy when the primary action is in progress of pointer movement. If the tool has ignored the event in beginPrimaryAction(), this method will not be called.

Reimplemented from KisTool.

Definition at line 272 of file kis_tool_ellipse.cc.

273{
274 if (!isThreePointPlacement()) {
276 return;
277 }
278
280 event->accept();
281 return;
282 }
283
285 const QPointF pos = convertToPixelCoordAndSnap(event, QPointF(), false);
287 const QRectF oldRect = threePointUpdateRect();
290 } else if (!hasCompleteThreePointEllipse()) {
292 }
294}
void updateThreePointPreview(const QPointF &pos)
virtual void requestUpdateOutline(const QPointF &outlineDocPoint, const KoPointerEvent *event)
QPointF point
The point in document coordinates.
#define CHECK_MODE_SANITY_OR_RETURN(_mode)
Definition kis_tool.h:27
virtual void continuePrimaryAction(KoPointerEvent *event)
Definition kis_tool.cc:441

References CHECK_MODE_SANITY_OR_RETURN, KisTool::continuePrimaryAction(), KisTool::convertToPixelCoordAndSnap(), hasCompleteThreePointEllipse(), isThreePointPlacement(), m_threePointCommittedOnPress, m_threePointDraggedHandle, m_threePointHandles, KisTool::PAINT_MODE, KoPointerEvent::point, KisToolPaint::requestUpdateOutline(), threePointUpdateRect(), KisTool::updateCanvasPixelRect(), and updateThreePointPreview().

◆ createOptionWidgets()

QList< QPointer< QWidget > > KisToolEllipse::createOptionWidgets ( )
overrideprotectedvirtual

Disable geometry contraints widget in 3-point mode. It is used in the bounding box mode only

Reimplemented from KoToolBase.

Definition at line 70 of file kis_tool_ellipse.cc.

71{
73
74 QWidget *widget = new QWidget();
75 widget->setObjectName("PlacementModeWidget");
76
77 KisOptionButtonStrip *placementStrip = new KisOptionButtonStrip(widget);
78 KoGroupButton *boundingBoxButton = placementStrip->addButton(i18nc("Ellipse tool placement mode", "Bounding Box"));
79 KoGroupButton *threePointButton = placementStrip->addButton(i18nc("Ellipse tool placement mode", "3-Point"));
80 boundingBoxButton->setToolTip(i18n("Place the ellipse inside a bounding box"));
81 threePointButton->setToolTip(i18n("Place the ellipse by setting the major axis and width"));
82
83 KConfigGroup cfg = KSharedConfig::openConfig()->group(toolId());
84 m_placementMode = static_cast<PlacementMode>(cfg.readEntry("placementMode", int(BoundingBoxPlacement)));
87 }
88 placementStrip->button(int(m_placementMode))->setChecked(true);
89
90 connect(placementStrip, SIGNAL(buttonToggled(int,bool)), SLOT(slotPlacementModeChanged(int,bool)));
91
96 Q_FOREACH (QPointer<QWidget> other, widgets) {
97 if (qobject_cast<KisRectangleConstraintWidget*>(other)) {
98 connect(placementStrip,
99 qOverload<int, bool>(&KisOptionButtonStrip::buttonToggled),
100 other,
101 [other](int mode, bool checked) {
102 if (!checked)
103 return;
104 other->setEnabled(static_cast<PlacementMode>(mode) == BoundingBoxPlacement);
105 });
106 other->setEnabled(m_placementMode == BoundingBoxPlacement);
107 break;
108 }
109 }
110
111 QHBoxLayout *hLayout = new QHBoxLayout(widget);
112 hLayout->addWidget(new QLabel(i18nc("Ellipse tool placement mode option label", "Placement:")), 0, Qt::AlignLeft);
113 hLayout->addWidget(placementStrip, 1, Qt::AlignRight);
114 widgets.prepend(widget);
115
116 return widgets;
117}
Provides a list of consecutive tool buttons.
void buttonToggled(KoGroupButton *button, bool checked)
KoGroupButton * addButton(const QIcon &icon, const QString &text=QString())
KoGroupButton * button(int index) const
PlacementMode m_placementMode
void slotPlacementModeChanged(int mode, bool checked)
Q_INVOKABLE QString toolId() const
virtual QList< QPointer< QWidget > > createOptionWidgets()
virtual ToolMode mode() const
Definition kis_tool.cc:407

References KisOptionButtonStrip::addButton(), BoundingBoxPlacement, KisOptionButtonStrip::button(), KisOptionButtonStrip::buttonToggled(), KoToolBase::createOptionWidgets(), m_placementMode, KisTool::mode(), slotPlacementModeChanged(), ThreePointPlacement, and KoToolBase::toolId().

◆ deactivate()

void KisToolEllipse::deactivate ( )
overrideprotectedvirtual

This method is called whenever this tool is no longer the active tool

See also
activate()

Reimplemented from KoToolBase.

Definition at line 414 of file kis_tool_ellipse.cc.

415{
416 if (isThreePointPlacement()) {
418 }
419
421}
virtual void deactivate()

References cancelThreePointEllipse(), KoToolBase::deactivate(), and isThreePointPlacement().

◆ endPrimaryAction()

void KisToolEllipse::endPrimaryAction ( KoPointerEvent * event)
overrideprotectedvirtual

Called by KisToolProxy when the primary action is being finished, that is while mouseRelease or tabletRelease event. If the tool has ignored the event in beginPrimaryAction(), this method will not be called.

Reimplemented from KisTool.

Definition at line 296 of file kis_tool_ellipse.cc.

297{
298 if (!isThreePointPlacement()) {
300 return;
301 }
302
306 event->accept();
307 return;
308 }
309
311
312 if (!event->spontaneous()) {
314 event->accept();
315 return;
316 }
317
318 const QPointF pos = convertToPixelCoordAndSnap(event, QPointF(), false);
320
322 const QRectF oldRect = threePointUpdateRect();
327 event->accept();
328 return;
329 }
330
332 beginShape();
334 }
335
337 if (!m_threePointHandles.isEmpty()) {
339 }
340 m_threePointHandles.append(pos);
343
344 if (m_threePointHandles.size() == 1) {
345 setStatusText(i18n("Click to place the other end of the ellipse axis."));
346 } else if (m_threePointHandles.size() == 2) {
347 setStatusText(i18n("Click to set the ellipse width."));
348 } else {
349 setStatusText(i18n("Drag handles to adjust the ellipse. Press Enter to apply or Esc to cancel."));
351 }
352 }
353
354 event->accept();
355}
QPointF m_threePointHoverPoint
void updateThreePointCursor(const QPointF &pos)
virtual void beginShape()
bool spontaneous() const
return if this event was spontaneous (see QMouseEvent::spontaneous())
void setStatusText(const QString &statusText)
virtual void endPrimaryAction(KoPointerEvent *event)
Definition kis_tool.cc:446
@ HOVER_MODE
Definition kis_tool.h:303

References KisToolShape::beginShape(), cancelThreePointEllipse(), CHECK_MODE_SANITY_OR_RETURN, KisTool::convertToPixelCoordAndSnap(), KisTool::endPrimaryAction(), hasCompleteThreePointEllipse(), KisTool::HOVER_MODE, isThreePointPlacement(), m_threePointCommittedOnPress, m_threePointDraggedHandle, m_threePointEllipseActive, m_threePointHandles, m_threePointHoverPoint, KisTool::PAINT_MODE, KisToolPaint::setMode(), KoToolBase::setStatusText(), KoPointerEvent::spontaneous(), threePointUpdateRect(), KisTool::updateCanvasPixelRect(), and updateThreePointCursor().

◆ finishRect()

void KisToolEllipse::finishRect ( const QRectF & rect,
qreal roundCornersX,
qreal roundCornersY )
overrideprotectedvirtual

Implements KisToolRectangleBase.

Definition at line 614 of file kis_tool_ellipse.cc.

615{
616 Q_UNUSED(roundCornersX);
617 Q_UNUSED(roundCornersY);
618
619 if (rect.isEmpty())
620 return;
621
622 const KisToolShape::ShapeAddInfo info =
624
625 if (!info.shouldAddShape) {
626 KisFigurePaintingToolHelper helper(kundo2_i18n("Draw Ellipse"),
627 image(),
628 currentNode(),
629 canvas()->resourceManager(),
630 strokeStyle(),
631 fillStyle(),
632 fillTransform());
633 QPainterPath path;
634 path.addEllipse(rect);
635 getRotatedPath(path, rect.center(), getRotationAngle());
636 helper.paintPainterPath(path);
637 } else {
638 KisResourcesSnapshot resources(image(),
639 currentNode(),
640 canvas()->resourceManager());
641 QRectF r = convertToPt(rect);
643 shape->rotate(qRadiansToDegrees(getRotationAngle()));
644 KoShapeStrokeSP border(new KoShapeStroke(currentStrokeWidth(), resources.currentFgColor().toQColor()));
645 shape->setStroke(border);
646
648
649 addShape(shape);
650 }
651}
The KisResourcesSnapshot class takes a snapshot of the various resources like colors and settings use...
static KoShape * createEllipseShape(const QRectF &rect)
void getRotatedPath(QPainterPath &path, const QPointF &center, const qreal &angle)
qreal currentStrokeWidth() const
void rotate(qreal angle)
Rotate the shape (relative)
Definition KoShape.cpp:223
virtual void setStroke(KoShapeStrokeModelSP stroke)
Definition KoShape.cpp:902
QRectF convertToPt(const QRectF &rect)
Definition kis_tool.cc:252

References KisToolShape::addShape(), Private::canvas, KisTool::convertToPt(), KisShapeToolHelper::createEllipseShape(), KisResourcesSnapshot::currentFgColor(), KisTool::currentNode(), KisToolShape::currentStrokeWidth(), KisToolShape::fillStyle(), KisToolShape::fillTransform(), KisToolRectangleBase::getRotatedPath(), KisToolRectangleBase::getRotationAngle(), KisTool::image(), kundo2_i18n(), KisToolShape::ShapeAddInfo::markAsSelectionShapeIfNeeded(), KisFigurePaintingToolHelper::paintPainterPath(), KoShape::rotate(), KoShape::setStroke(), KisToolShape::ShapeAddInfo::shouldAddShape, KisToolShape::shouldAddShape(), KisToolShape::strokeStyle(), and KoColor::toQColor().

◆ hasCompleteThreePointEllipse()

bool KisToolEllipse::hasCompleteThreePointEllipse ( ) const
private

Definition at line 180 of file kis_tool_ellipse.cc.

181{
182 return m_threePointHandles.size() == 3;
183}

References m_threePointHandles.

◆ isThreePointPlacement()

bool KisToolEllipse::isThreePointPlacement ( ) const
private

Definition at line 150 of file kis_tool_ellipse.cc.

151{
153}

References m_placementMode, and ThreePointPlacement.

◆ mouseMoveEvent()

void KisToolEllipse::mouseMoveEvent ( KoPointerEvent * event)
overrideprotectedvirtual

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.

Definition at line 357 of file kis_tool_ellipse.cc.

358{
361 return;
362 }
363
365 updateThreePointPreview(convertToPixelCoordAndSnap(event, QPointF(), false));
366 } else {
367 updateThreePointCursor(convertToPixelCoordAndSnap(event, QPointF(), false));
368 }
370}
void mouseMoveEvent(KoPointerEvent *event) override
virtual void mouseMoveEvent(KoPointerEvent *event)=0

References KisTool::convertToPixelCoordAndSnap(), hasCompleteThreePointEllipse(), isThreePointPlacement(), m_threePointEllipseActive, KisToolPaint::mouseMoveEvent(), KoToolBase::mouseMoveEvent(), updateThreePointCursor(), and updateThreePointPreview().

◆ paint()

void KisToolEllipse::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.

Definition at line 372 of file kis_tool_ellipse.cc.

373{
374 if (!isThreePointPlacement()) {
375 KisToolEllipseBase::paint(gc, converter);
376 return;
377 }
378
380 KisToolPaint::paint(gc, converter);
381}
void paintThreePointEllipse(QPainter &gc)
void paint(QPainter &gc, const KoViewConverter &converter) override
virtual void paint(QPainter &painter, const KoViewConverter &converter)=0

References isThreePointPlacement(), KisToolPaint::paint(), KoToolBase::paint(), and paintThreePointEllipse().

◆ paintThreePointEllipse()

void KisToolEllipse::paintThreePointEllipse ( QPainter & gc)
private

Definition at line 475 of file kis_tool_ellipse.cc.

476{
478 return;
479 }
480
481 QPainterPath path;
482 const QPointF firstPoint = pixelToView(m_threePointHandles[0]);
483
484 if (m_threePointHandles.size() == 1) {
485 path.addPath(drawX(firstPoint));
486 path.moveTo(firstPoint);
488 } else {
489 QPainterPath ellipsePath;
490 if (threePointEllipsePath(threePointPreviewPoint(), &ellipsePath)) {
491 path.addPath(pixelToView(ellipsePath));
492 } else {
493 path.moveTo(firstPoint);
494 path.lineTo(pixelToView(m_threePointHandles[1]));
495 }
496 }
497
498 paintToolOutline(&gc, path);
500}
void paintThreePointHandles(QPainter &gc)
QPainterPath drawX(const QPointF &pt)
QPointF pixelToView(const QPoint &pixelCoord) const
Definition kis_tool.cc:269
void paintToolOutline(QPainter *painter, const KisOptimizedBrushOutline &path)
Definition kis_tool.cc:589

References KisToolRectangleBase::drawX(), m_threePointEllipseActive, m_threePointHandles, m_threePointHoverPoint, paintThreePointHandles(), KisTool::paintToolOutline(), KisTool::pixelToView(), threePointEllipsePath(), and threePointPreviewPoint().

◆ paintThreePointHandles()

void KisToolEllipse::paintThreePointHandles ( QPainter & gc)
private

Definition at line 502 of file kis_tool_ellipse.cc.

503{
504 gc.save();
505 gc.setRenderHint(QPainter::Antialiasing, true);
507 gc.setPen(QPen(palette.black, 1.0));
508 gc.setBrush(QBrush(palette.white));
509
510 const qreal radius = qMax<qreal>(3.0, handleRadius() * 0.75);
511 for (const QPointF &point : m_threePointHandles) {
512 const QPointF viewPoint = pixelToView(point);
513 gc.drawEllipse(QRectF(viewPoint - QPointF(radius, radius), QSizeF(radius * 2.0, radius * 2.0)));
514 }
515
516 gc.restore();
517}
KoColorDisplayRendererInterface * displayRendererInterface() const override
displayRendererInterface The display renderer interface has a number of color conversion functions wh...
virtual KisHandlePalette handlePaletteForDisplayColorSpace() const =0
handlePaletteForDisplayColorSpace
int handleRadius() const
Convenience function to get the current handle radius.

References KisHandlePalette::black, Private::canvas, KisCanvas2::displayRendererInterface(), KoColorDisplayRendererInterface::handlePaletteForDisplayColorSpace(), KoToolBase::handleRadius(), m_threePointHandles, KisTool::pixelToView(), and KisHandlePalette::white.

◆ popupWidget()

KisPopupWidgetInterface * KisToolEllipse::popupWidget ( )
overrideprotectedvirtual
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.

Definition at line 383 of file kis_tool_ellipse.cc.

384{
386 return nullptr;
387 }
388
390}
virtual KisPopupWidgetInterface * popupWidget()
Definition KoToolBase.h:340

References m_threePointEllipseActive, and KoToolBase::popupWidget().

◆ requestStrokeCancellation()

void KisToolEllipse::requestStrokeCancellation ( )
overrideprotectedvirtual

Called when the user requests cancellation of the current stroke. If your tool supports cancelling, override this method and implement the desired effects there.

Reimplemented from KoToolBase.

Definition at line 404 of file kis_tool_ellipse.cc.

405{
406 if (!isThreePointPlacement()) {
408 return;
409 }
410
412}
virtual void requestStrokeCancellation()

References cancelThreePointEllipse(), isThreePointPlacement(), and KoToolBase::requestStrokeCancellation().

◆ requestStrokeEnd()

void KisToolEllipse::requestStrokeEnd ( )
overrideprotectedvirtual

Called when the image decided that the stroke should better be ended. If your tool supports long strokes, override this method and implement the desired effects there.

Reimplemented from KoToolBase.

Definition at line 392 of file kis_tool_ellipse.cc.

393{
394 if (!isThreePointPlacement()) {
396 return;
397 }
398
401 }
402}
virtual void requestStrokeEnd()

References commitThreePointEllipse(), hasCompleteThreePointEllipse(), isThreePointPlacement(), and KoToolBase::requestStrokeEnd().

◆ resetCursorStyle

void KisToolEllipse::resetCursorStyle ( )
overrideprotectedslot

Definition at line 133 of file kis_tool_ellipse.cc.

134{
138 return;
139 }
140
142 useCursor(KisCursor::loadWithSize("tool_ellipse_eraser_cursor.svg", 32, 32, 6, 6));
143 } else {
145 }
146
148}
QCursor threePointConfirmCursor() const
bool isEraser() const
virtual void resetCursorStyle()
Definition kis_tool.cc:613
bool overrideCursorIfNotEditable()
Override the cursor appropriately if current node is not editable.
Definition kis_tool.cc:618

References hasCompleteThreePointEllipse(), KisToolPaint::isEraser(), isThreePointPlacement(), KisCursor::loadWithSize(), KisTool::nodePaintAbility(), KisTool::overrideCursorIfNotEditable(), KisTool::PAINT, KisTool::resetCursorStyle(), threePointConfirmCursor(), and KoToolBase::useCursor().

◆ resetThreePointState()

◆ slotPlacementModeChanged

void KisToolEllipse::slotPlacementModeChanged ( int mode,
bool checked )
protectedslot

Definition at line 119 of file kis_tool_ellipse.cc.

120{
121 if (!checked) {
122 return;
123 }
124
126 setStatusText(QString());
128
129 KConfigGroup cfg = KSharedConfig::openConfig()->group(toolId());
130 cfg.writeEntry("placementMode", int(m_placementMode));
131}

References BoundingBoxPlacement, cancelThreePointEllipse(), m_placementMode, KisTool::mode(), KoToolBase::setStatusText(), ThreePointPlacement, and KoToolBase::toolId().

◆ supportsPaintingAssistants()

bool KisToolEllipse::supportsPaintingAssistants ( ) const
overridevirtual

Reimplemented from KisTool.

Definition at line 653 of file kis_tool_ellipse.cc.

654{
655 return true;
656}

◆ threePointConfirmCursor()

QCursor KisToolEllipse::threePointConfirmCursor ( ) const
private

Definition at line 204 of file kis_tool_ellipse.cc.

205{
206 static const QCursor cursor = [] {
207 QPixmap pixmap(42, 32);
208 pixmap.fill(Qt::transparent);
209
210 QPainter painter(&pixmap);
211 painter.drawPixmap(0, 0, QIcon(QStringLiteral(":/tool_ellipse_cursor.svg")).pixmap(32, 32));
212 painter.setRenderHint(QPainter::Antialiasing, true);
213
214 QPainterPath checkPath;
215 checkPath.moveTo(31.0, 23.0);
216 checkPath.lineTo(34.0, 26.0);
217 checkPath.lineTo(41.0, 17.0);
218
219 QPen outlinePen(Qt::white, 4.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
220 painter.setPen(outlinePen);
221 painter.drawPath(checkPath);
222
223 QPen checkPen(Qt::black, 2.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
224 painter.setPen(checkPen);
225 painter.drawPath(checkPath);
226 painter.end();
227
228 return QCursor(pixmap, 6, 6);
229 }();
230
231 return cursor;
232}
QCursor cursor
Definition kis_tool.cc:64

References KisTool::cursor.

◆ threePointEllipsePath()

bool KisToolEllipse::threePointEllipsePath ( const QPointF & thirdPoint,
QPainterPath * path ) const
private

Definition at line 519 of file kis_tool_ellipse.cc.

520{
521 if (m_threePointHandles.size() < 2) {
522 return false;
523 }
524
525 const QPointF p1 = m_threePointHandles[0];
526 const QPointF p2 = m_threePointHandles[1];
527 const QPointF center = (p1 + p2) * 0.5;
528 const QPointF majorVector = p2 - p1;
529 const qreal majorLength = std::hypot(majorVector.x(), majorVector.y());
530
531 if (majorLength < MinAxisLength) {
532 return false;
533 }
534
535 const qreal semiMajor = majorLength * 0.5;
536 const QPointF majorUnit = majorVector / majorLength;
537 const QPointF minorUnit = rotate90(majorUnit);
538 const QPointF localPoint = thirdPoint - center;
539 const qreal localX = QPointF::dotProduct(localPoint, majorUnit);
540 const qreal localY = QPointF::dotProduct(localPoint, minorUnit);
541 const qreal divisor = 1.0 - (localX * localX) / (semiMajor * semiMajor);
542
543 if (divisor <= 0.0 || qFuzzyIsNull(localY)) {
544 return false;
545 }
546
547 const qreal semiMinor = qAbs(localY) / std::sqrt(divisor);
548 if (semiMinor <= 0.0) {
549 return false;
550 }
551
552 QPainterPath canonicalPath;
553 canonicalPath.addEllipse(QPointF(0, 0), semiMajor, semiMinor);
554
555 QTransform ellipseTransform(majorUnit.x(), majorUnit.y(),
556 minorUnit.x(), minorUnit.y(),
557 center.x(), center.y());
558
559 *path = ellipseTransform.map(canonicalPath);
560 return true;
561}
QPointF rotate90(const QPointF &p)
Definition Ellipse.cc:58
QPointF p2
QPointF p1
static bool qFuzzyIsNull(half h)

References m_threePointHandles, p1, p2, qFuzzyIsNull(), and rotate90().

◆ threePointHandleAt()

int KisToolEllipse::threePointHandleAt ( const QPointF & pos) const
private

Definition at line 190 of file kis_tool_ellipse.cc.

191{
192 const QPointF viewPos = pixelToView(pos);
193 const qreal radius = qMax<qreal>(grabSensitivity(), handleRadius() + 3);
194
195 for (int i = m_threePointHandles.size() - 1; i >= 0; --i) {
196 if (QLineF(viewPos, pixelToView(m_threePointHandles[i])).length() <= radius) {
197 return i;
198 }
199 }
200
201 return -1;
202}
int grabSensitivity() const
Convenience function to get the current grab sensitivity.

References KoToolBase::grabSensitivity(), KoToolBase::handleRadius(), m_threePointHandles, and KisTool::pixelToView().

◆ threePointPreviewPoint()

QPointF KisToolEllipse::threePointPreviewPoint ( ) const
private

◆ threePointUpdateRect()

QRectF KisToolEllipse::threePointUpdateRect ( ) const
private

Definition at line 563 of file kis_tool_ellipse.cc.

564{
565 QRectF rect;
566
567 for (const QPointF &point : m_threePointHandles) {
568 rect |= QRectF(point, QSizeF(1.0, 1.0));
569 }
570
571 rect |= QRectF(m_threePointHoverPoint, QSizeF(1.0, 1.0));
572
573 QPainterPath path;
575 rect |= path.boundingRect();
576 }
577
578 return rect.adjusted(-20.0, -20.0, 20.0, 20.0);
579}

References m_threePointHandles, m_threePointHoverPoint, threePointEllipsePath(), and threePointPreviewPoint().

◆ updateThreePointCursor()

◆ updateThreePointPreview()

void KisToolEllipse::updateThreePointPreview ( const QPointF & pos)
private

Definition at line 423 of file kis_tool_ellipse.cc.

424{
425 const QRectF oldRect = threePointUpdateRect();
428}

References m_threePointHoverPoint, threePointUpdateRect(), and KisTool::updateCanvasPixelRect().

Member Data Documentation

◆ m_placementMode

PlacementMode KisToolEllipse::m_placementMode {BoundingBoxPlacement}
private

Definition at line 79 of file kis_tool_ellipse.h.

◆ m_threePointCommitInProgress

bool KisToolEllipse::m_threePointCommitInProgress {false}
private

Definition at line 84 of file kis_tool_ellipse.h.

84{false};

◆ m_threePointCommittedOnPress

bool KisToolEllipse::m_threePointCommittedOnPress {false}
private

Definition at line 85 of file kis_tool_ellipse.h.

85{false};

◆ m_threePointDraggedHandle

int KisToolEllipse::m_threePointDraggedHandle {-1}
private

Definition at line 82 of file kis_tool_ellipse.h.

82{-1};

◆ m_threePointEllipseActive

bool KisToolEllipse::m_threePointEllipseActive {false}
private

Definition at line 83 of file kis_tool_ellipse.h.

83{false};

◆ m_threePointHandles

QVector<QPointF> KisToolEllipse::m_threePointHandles
private

Definition at line 80 of file kis_tool_ellipse.h.

◆ m_threePointHoverPoint

QPointF KisToolEllipse::m_threePointHoverPoint
private

Definition at line 81 of file kis_tool_ellipse.h.


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