Krita Source Code Documentation
Loading...
Searching...
No Matches
CutThroughShapeStrategy.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 Agata Cacko
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef CUT_THROUGH_SHAPE_STRATEGY_H_
8#define CUT_THROUGH_SHAPE_STRATEGY_H_
9
10#include <QScopedPointer>
11#include <QRectF>
12
14#include <KoShape.h>
15#include "GutterWidthsConfig.h"
16
17#include "GutterWidthsConfig.h"
18
19class KoSelection;
20
21
22
24{
25public:
26 CutThroughShapeStrategy(KoToolBase *tool, KoSelection *selection, const QList<KoShape *> &allShapes, QPointF startPoint, const GutterWidthsConfig &width);
27
28 ~CutThroughShapeStrategy() override;
29
30
31 KUndo2Command *createCommand() override;
32
33 void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
34 void finishInteraction(Qt::KeyboardModifiers modifiers) override;
35 void paint(QPainter &painter, const KoViewConverter &converter) override;
36
37private:
38
39 qreal gutterWidthInDocumentCoordinates(qreal lineAngle);
40 qreal calculateLineAngle(QPointF start, QPointF end);
41
42 bool willShapeBeCutGeneral(KoShape* referenceShape, const QPainterPath &srcOutline, const QRectF &leftOppositeRect, const QRectF &rightOppositeRect, bool checkGapLineRect, const QRectF &gapLineRect);
43 bool willShapeBeCutPrecise(const QPainterPath& srcOutline, const QLineF gapLine, const QLineF& leftLine, const QLineF& rightLine, const QPolygonF& gapLinePolygon);
44
45
46private:
47
48 QPointF m_startPoint = QPointF();
49 QPointF m_endPoint = QPointF();
50 QRectF m_previousLineDirtyRect = QRectF();
54};
55
56
57
58
59#endif // CUT_THROUGH_SHAPE_STRATEGY_H_
bool willShapeBeCutGeneral(KoShape *referenceShape, const QPainterPath &srcOutline, const QRectF &leftOppositeRect, const QRectF &rightOppositeRect, bool checkGapLineRect, const QRectF &gapLineRect)
void finishInteraction(Qt::KeyboardModifiers modifiers) override
qreal calculateLineAngle(QPointF start, QPointF end)
bool willShapeBeCutPrecise(const QPainterPath &srcOutline, const QLineF gapLine, const QLineF &leftLine, const QLineF &rightLine, const QPolygonF &gapLinePolygon)
QList< KoShape * > m_selectedShapes
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override
KUndo2Command * createCommand() override
CutThroughShapeStrategy(KoToolBase *tool, KoSelection *selection, const QList< KoShape * > &allShapes, QPointF startPoint, const GutterWidthsConfig &width)
qreal gutterWidthInDocumentCoordinates(qreal lineAngle)
void paint(QPainter &painter, const KoViewConverter &converter) override