Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Remove unnecessary performance check in CutThroughShapeStrategy

Agata Cackoba9e1eaee0f8
diff --git a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
index 53ba7550cf..23fd2b545c 100644
--- a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
+++ b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
@@ -89,21 +89,13 @@ void CutThroughShapeStrategy::handleMouseMove(const QPointF &mouseLocation, Qt::
}
-bool CutThroughShapeStrategy::willShapeBeCutGeneral(KoShape* referenceShape, const QPainterPath& srcOutline, const QRectF& leftOppositeRect, const QRectF& rightOppositeRect, bool checkGapLineRect, const QRectF& gapLineRect)
+bool CutThroughShapeStrategy::willShapeBeCutGeneral(KoShape* referenceShape, const QPainterPath& srcOutline, bool checkGapLineRect, const QRectF& gapLineRect)
{
if (dynamic_cast<KoSvgTextShape*>(referenceShape)) {
// skip all text
return false;
}
- if ((srcOutline.boundingRect() & leftOppositeRect).isEmpty()
- || (srcOutline.boundingRect() & rightOppositeRect).isEmpty()) {
- // there is nothing on one side
- // everything is on the other, far away from the gap line
- // it just makes it a bit faster when there is a whole lot of shapes
-
- return false;
- }
if (checkGapLineRect && (srcOutline.boundingRect() & gapLineRect).isEmpty()) {
// the gap lines can't cross the shape since their bounding rects don't cross it
@@ -160,7 +152,7 @@ void CutThroughShapeStrategy::initializeOutlineObjects(const QTransform &boolean
}
}
-void CutThroughShapeStrategy::initializeGapShapes(QRectF outlineRect, QLineF leftLine, QLineF rightLine, QPainterPath& outLeft, QPainterPath& outRight, QPainterPath &outLeftOpposite, QPainterPath &outRightOpposite,
+void CutThroughShapeStrategy::initializeGapShapes(QRectF outlineRect, QLineF leftLine, QLineF rightLine, QPainterPath& outLeft, QPainterPath& outRight,
QRectF& outGapLineRect, QPolygonF& outGapLinePolygon)
{
@@ -178,11 +170,6 @@ void CutThroughShapeStrategy::initializeGapShapes(QRectF outlineRect, QLineF lef
outLeft = paths[0];
outRight = paths[1];
- QList<QPainterPath> pathsOpposite = KisAlgebra2D::getPathsFromRectangleCutThrough(QRectF(outlineRectBiggerInt), rightLineLong, leftLineLong);
- outLeftOpposite = pathsOpposite[0];
- outRightOpposite = pathsOpposite[1];
-
-
outGapLineRect = KisAlgebra2D::createRectFromCorners(leftLine) | KisAlgebra2D::createRectFromCorners(rightLine); // will not be empty if the gutterWidth > 0
outGapLinePolygon = QPolygonF({leftLine.p1(), leftLine.p2(), rightLine.p2(), rightLine.p1(), leftLine.p1()});
@@ -241,11 +228,11 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
// -------------
- QPainterPath left, right, leftOpposite, rightOpposite;
+ QPainterPath left, right;
QRectF gapLineRect;
QPolygonF gapLinePolygon;
- initializeGapShapes(outlineRect, leftLine, rightLine, left, right, leftOpposite, rightOpposite, gapLineRect, gapLinePolygon);
+ initializeGapShapes(outlineRect, leftLine, rightLine, left, right, gapLineRect, gapLinePolygon);
bool checkGapLineRect = !gapLineRect.isEmpty();
@@ -265,7 +252,7 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
KoShape* referenceShape = m_allShapes[i];
bool wasSelected = m_selectedShapes.contains(referenceShape);
- bool skipThisShape = !willShapeBeCutGeneral(referenceShape, srcOutlines[i], leftOpposite.boundingRect(), rightOpposite.boundingRect(), checkGapLineRect, gapLineRect);
+ bool skipThisShape = !willShapeBeCutGeneral(referenceShape, srcOutlines[i], checkGapLineRect, gapLineRect);
skipThisShape = skipThisShape || !willShapeBeCutPrecise(srcOutlines[i], gapLine, leftLine, rightLine, gapLinePolygon);
if (skipThisShape) {
diff --git a/plugins/tools/tool_knife/CutThroughShapeStrategy.h b/plugins/tools/tool_knife/CutThroughShapeStrategy.h
index fdbd340cd9..1fdee58e70 100644
--- a/plugins/tools/tool_knife/CutThroughShapeStrategy.h
+++ b/plugins/tools/tool_knife/CutThroughShapeStrategy.h
@@ -39,12 +39,11 @@ private:
qreal gutterWidthInDocumentCoordinates(qreal lineAngle);
qreal calculateLineAngle(QPointF start, QPointF end);
- static bool willShapeBeCutGeneral(KoShape* referenceShape, const QPainterPath &srcOutline, const QRectF &leftOppositeRect, const QRectF &rightOppositeRect, bool checkGapLineRect, const QRectF &gapLineRect);
+ static bool willShapeBeCutGeneral(KoShape* referenceShape, const QPainterPath &srcOutline, bool checkGapLineRect, const QRectF &gapLineRect);
static bool willShapeBeCutPrecise(const QPainterPath& srcOutline, const QLineF gapLine, const QLineF& leftLine, const QLineF& rightLine, const QPolygonF& gapLinePolygon);
static void initializeOutlineObjects(const QTransform &booleanWorkaroundTransform, QList<KoShape *> allShapes, QList<QPainterPath> &outSrcOutlines, QRectF &outOutlineRect);
- static void initializeGapShapes(QRectF outlineRect, QLineF leftLine, QLineF rightLine, QPainterPath& outLeft, QPainterPath& outRight,
- QPainterPath& outLeftOpposite, QPainterPath& outRightOpposite, QRectF& outGapLineRect, QPolygonF& outGapLinePolygon);
+ static void initializeGapShapes(QRectF outlineRect, QLineF leftLine, QLineF rightLine, QPainterPath& outLeft, QPainterPath& outRight, QRectF& outGapLineRect, QPolygonF& outGapLinePolygon);