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++

Try to optimize Knife Tool for a big number of shapes

Agata Cackoc0656aa21cbe
diff --git a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
index 979708edee..c107f1323b 100644
--- a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
+++ b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
@@ -185,6 +185,12 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
QPainterPath left = paths[0];
QPainterPath right = paths[1];
+ QList<QPainterPath> pathsOpposite = KisAlgebra2D::getPathsFromRectangleCutThrough(QRectF(outlineRectBiggerInt), rightLine, leftLine);
+ QPainterPath leftOpposite = pathsOpposite[0];
+ QPainterPath rightOpposite = pathsOpposite[1];
+
+
+
//QPainterPath dstOutline;
//QList<QPainterPath> dstOutlines;
@@ -193,13 +199,25 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
QList<KoShape*> shapesToRemove;
for (int i = 0; i < srcOutlines.size(); i++) {
+
+ KoShape* referenceShape = m_selectedShapes[i];
+
+ if ((srcOutlines[i].boundingRect() & leftOpposite.boundingRect()).isEmpty()
+ || (srcOutlines[i].boundingRect() & rightOpposite.boundingRect()).isEmpty()) {
+ // there is nothing on one side
+ // everything is on the other, far away from the gap line
+ // it just makes it a bit fast when there is a whole lot of shapes
+
+ newSelectedShapes << referenceShape;
+ continue;
+ }
+
QPainterPath leftPath = srcOutlines[i] & left;
QPainterPath rightPath = srcOutlines[i] & right;
QList<QPainterPath> paths;
paths << leftPath << rightPath;
- KoShape* referenceShape = m_selectedShapes[i];
Q_FOREACH(QPainterPath path, paths) {
if (path.isEmpty()) {