Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_tool_ellipse.cc
Go to the documentation of this file.
1/*
2 * kis_tool_ellipse.cc - part of Krayon
3 *
4 * SPDX-FileCopyrightText: 2000 John Califf <jcaliff@compuzone.net>
5 * SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
6 * SPDX-FileCopyrightText: 2004 Boudewijn Rempt <boud@valdyas.org>
7 * SPDX-FileCopyrightText: 2004 Clarence Dang <dang@kde.org>
8 * SPDX-FileCopyrightText: 2009 Lukáš Tvrdý <lukast.dev@gmail.com>
9 * SPDX-FileCopyrightText: 2010 Cyrille Berger <cberger@cberger.net>
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 */
13
14#include "kis_tool_ellipse.h"
15#include <KoCanvasBase.h>
16#include <KoShapeStroke.h>
17
18#include <KisViewManager.h>
19#include <canvas/kis_canvas2.h>
24
26 : KisToolEllipseBase(canvas, KisToolEllipseBase::PAINT, KisCursor::load("tool_ellipse_cursor.png", 6, 6))
27{
28 setObjectName("tool_ellipse");
31
32 KisCanvas2 *kritaCanvas = dynamic_cast<KisCanvas2*>(canvas);
33
34 connect(kritaCanvas->viewManager()->canvasResourceProvider(), SIGNAL(sigEffectiveCompositeOpChanged()), SLOT(resetCursorStyle()));
35}
36
40
42{
44 useCursor(KisCursor::load("tool_ellipse_eraser_cursor.png", 6, 6));
45 } else {
47 }
48
50}
51
52void KisToolEllipse::finishRect(const QRectF& rect, qreal roundCornersX, qreal roundCornersY)
53{
54 Q_UNUSED(roundCornersX);
55 Q_UNUSED(roundCornersY);
56
57 if (rect.isEmpty())
58 return;
59
62
63 if (!info.shouldAddShape) {
64 KisFigurePaintingToolHelper helper(kundo2_i18n("Draw Ellipse"),
65 image(),
67 canvas()->resourceManager(),
69 fillStyle(),
71 QPainterPath path;
72 path.addEllipse(rect);
73 getRotatedPath(path, rect.center(), getRotationAngle());
74 helper.paintPainterPath(path);
75 } else {
76 KisResourcesSnapshot resources(image(),
78 canvas()->resourceManager());
79 QRectF r = convertToPt(rect);
81 shape->rotate(qRadiansToDegrees(getRotationAngle()));
83 shape->setStroke(border);
84
86
87 addShape(shape);
88 }
89}
90
92{
93 return true;
94}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisViewManager * viewManager() const
static QCursor load(const QString &cursorName, int hotspotX=-1, int hotspotY=-1)
void paintPainterPath(const QPainterPath &path)
The KisResourcesSnapshot class takes a snapshot of the various resources like colors and settings use...
static KoShape * createEllipseShape(const QRectF &rect)
~KisToolEllipse() override
bool supportsPaintingAssistants() const override
KisToolEllipse(KoCanvasBase *canvas)
void finishRect(const QRectF &rect, qreal roundCornersX, qreal roundCornersY) override
void resetCursorStyle() override
void setSupportOutline(bool supportOutline)
bool isEraser() const
void getRotatedPath(QPainterPath &path, const QPointF &center, const qreal &angle)
KisToolShapeUtils::StrokeStyle strokeStyle()
ShapeAddInfo shouldAddShape(KisNodeSP currentNode) const
qreal currentStrokeWidth() const
QTransform fillTransform()
void addShape(KoShape *shape)
KisToolShapeUtils::FillStyle fillStyle()
KisCanvasResourceProvider * canvasResourceProvider()
void toQColor(QColor *c) const
a convenience method for the above.
Definition KoColor.cpp:198
void rotate(qreal angle)
Rotate the shape (relative)
Definition KoShape.cpp:250
virtual void setStroke(KoShapeStrokeModelSP stroke)
Definition KoShape.cpp:1081
void setIsOpacityPresetMode(bool value)
void useCursor(const QCursor &cursor)
KUndo2MagicString kundo2_i18n(const char *text)
void markAsSelectionShapeIfNeeded(KoShape *shape) const
KisTool::NodePaintAbility nodePaintAbility()
Definition kis_tool.cc:539
virtual void resetCursorStyle()
Definition kis_tool.cc:613
KisNodeSP currentNode() const
Definition kis_tool.cc:370
bool overrideCursorIfNotEditable()
Override the cursor appropriately if current node is not editable.
Definition kis_tool.cc:618
QRectF convertToPt(const QRectF &rect)
Definition kis_tool.cc:252
KisImageWSP image() const
Definition kis_tool.cc:332
KisCanvas2 * canvas