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

Implement nicer behaviour in cutting comic panels

Agata Cackodd96686e2bf3
diff --git a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
index 7641580750..deb4d73328 100644
--- a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
+++ b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
@@ -219,9 +219,20 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
continue;
}
- // either one of the points is inside the path, or the line crosses one of the segments
- bool containsGapLinePoint = srcOutlines[i].contains(leftLine.p1()) || srcOutlines[i].contains(leftLine.p2())
- || srcOutlines[i].contains(rightLine.p1()) || srcOutlines[i].contains(rightLine.p2());
+ bool containsGapLinePointStart = srcOutlines[i].contains(gapLine.p1());
+ bool containsGapLinePointEnd = srcOutlines[i].contains(gapLine.p2());
+
+ // if should skip if there is exactly one gap line point inside the shape
+ bool exactlyOneGapLinePointInside = (containsGapLinePointStart != containsGapLinePointEnd);
+ bool bothGapLinePointsInside = containsGapLinePointStart && containsGapLinePointEnd;
+
+ if (exactlyOneGapLinePointInside) {
+ if (wasSelected) {
+ newSelectedShapes << referenceShape;
+ }
+ continue;
+ }
+
bool crossesGapLine = KisAlgebra2D::getLineSegmentCrossingLineIndexes(leftLine, srcOutlines[i]).count() > 0
|| KisAlgebra2D::getLineSegmentCrossingLineIndexes(rightLine, srcOutlines[i]).count() > 0;
@@ -232,7 +243,7 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
break;
}
}
- if (!containsGapLinePoint && !crossesGapLine && !containsPointWithinGap) {
+ if (!bothGapLinePointsInside && !crossesGapLine && !containsPointWithinGap) {
//qCritical() << "it doesn't cross the line!";
if (wasSelected) {