10#include "QPainterPath"
12#include <klocalizedstring.h>
61 setObjectName(
"tool_knife");
68 m_d->optionsWidget =
nullptr;
78 QColor color = Qt::blue;
80 QColor white = Qt::white;
81 white.setAlphaF(0.75);
83 QPen pen = QPen(color, width);
84 QPen alternative = QPen(white, width);
86 alternative.setStyle(Qt::CustomDashLine);
88 alternative.setDashPattern({dashLength - 1, dashLength + 1});
89 alternative.setCapStyle(Qt::RoundCap);
91 pen.setCosmetic(
true);
95 painter.drawLine(lineInView);
97 alternative.setCosmetic(
true);
98 painter.setPen(alternative);
100 painter.drawLine(lineInView);
110 polygon << QPointF(-size, 0);
111 polygon << QPointF(0, size);
112 polygon << QPointF(size, 0);
113 polygon << QPointF(0, -size);
114 polygon.translate(location);
124 QColor color = Qt::blue;
125 color.setAlphaF(0.9);
126 QColor white = Qt::white;
127 white.setAlphaF(0.75);
129 QPen pen = QPen(color, 2);
130 pen.setCosmetic(
true);
131 QBrush brush = QBrush(white);
133 painter.setBrush(brush);
135 painter.drawPolygon(diamond);
147 painter.setBrush(Qt::darkGray);
156 bool paintSelection =
true;
157 if (paintSelection) {
168 Q_FOREACH(
KoShape* shape, shapes) {
171 painter.setTransform(painter.transform());
205 i18n(
"This tool only works on vector layers. You probably want to create a vector layer and a starting shape first."),
217 if (event->
buttons().testFlag(Qt::MouseButton::LeftButton)) {
219 m_d->endPoint =
event->point;
224 QRectF accumulatedWithPrevious =
m_d->previousLineDirtyRect;
225 accumulatedWithPrevious |= dirtyRect;
228 m_d->previousLineDirtyRect = dirtyRect;
239 m_d->endPoint =
event->point;
245 QRectF accumulatedWithPrevious =
m_d->previousLineDirtyRect | dirtyRect;
248 m_d->previousLineDirtyRect = dirtyRect;
268 const KisShapeLayer *shapeLayer = qobject_cast<const KisShapeLayer*>(node.
data());
269 return (shapeLayer !=
nullptr);
276 qreal resolution = 1.0;
277 if (kiscanvas->
image()) {
283 m_d->optionsWidget->setObjectName(
toolId() +
"option widget");
286 return m_d->optionsWidget;
VectorPathPoint pointAt(int i) const
int segmentsCount() const
QLineF segmentAtAsLine(int i) const
KisImageWSP image() const
KisViewManager * viewManager() const
KisNodeSP currentNode() const
static QCursor arrowCursor()
KisCanvasResourceProvider * canvasResourceProvider()
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
virtual KoShapeManager * shapeManager() const =0
virtual void updateCanvas(const QRectF &rc)=0
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
Qt::MouseButtons buttons() const
return buttons pressed (see QMouseEvent::buttons());
QPointF point
The point in document coordinates.
virtual KoSelection * selection()=0
QList< KoShape * > shapes
virtual QPainterPath outline() const
QTransform absoluteTransformation() const
virtual QPointF documentToView(const QPointF &documentPoint) const
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
void accumulateBounds(const Point &pt, Rect *bounds)
QList< QLineF > getParallelLines(const QLineF &line, const qreal distance)