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

Fix gap width in Knife Tool

Agata Cacko1c9a2e7cf8a9
diff --git a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
index 4728232c79..3ffaaaeb97 100644
--- a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
+++ b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
@@ -109,8 +109,21 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
// TODO: two lines, for both sides of the gap
QLineF gapLine = QLineF(m_startPoint, m_endPoint);
+ qreal eps = 0.0000001;
+ if (gapLine.length() < eps) {
+ return;
+ }
+
+ KisCanvas2* canvas = dynamic_cast<KisCanvas2*>(tool()->canvas());
+ QLineF helperGapWidthLine = QLineF(QPointF(0, 0), QPointF(0, m_width));
+ QLineF helperGapWidthLineTransformed = canvas->coordinatesConverter()->imageToDocument(helperGapWidthLine);
+ qreal gapWidth = helperGapWidthLineTransformed.length();
+
+ //tool()->canvas()->viewConverter()
+ //coo
+
+ QList<QLineF> gapLines = KisAlgebra2D::getParallelLines(gapLine, gapWidth/2);
- QList<QLineF> gapLines = KisAlgebra2D::getParallelLines(gapLine, 2*m_width);
qCritical() << "############ Are those lines correct? " << KisAlgebra2D::pointToLineDistSquared(gapLines[0].p1(), gapLines[1])
<< KisAlgebra2D::pointToLineDistSquared(gapLines[1].p1(), gapLines[0]) << KisAlgebra2D::pointToLineDistSquared(gapLines[0].p1(), gapLine);
//qCritical() << "Should be: " << pow2(gapWidth/2) << "or" << pow2(gapWidth);