diff --git a/ChangeLog.txt b/ChangeLog.txt
index 2a4a53921..045473ba3 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,5 +1,9 @@
# Version 0.7.41 (unreleased)
- Bug fixes.
+- Improve canceling nesting.
+- Fix incorrect nesting status for valid cases.
+- Improve crossing check for the layout algorithm.
+- Fix crash after creating an elliptical arc.
# Version 0.7.40 Nov 23, 2020
- New function Warning.
diff --git a/share/translations/valentina.ts b/share/translations/valentina.ts
index 418092c03..2462e6f3e 100644
--- a/share/translations/valentina.ts
+++ b/share/translations/valentina.ts
@@ -15163,7 +15163,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Point at intersection of arc and line
+ Point at intersection of arc and line
@@ -15625,6 +15625,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_cs_CZ.ts b/share/translations/valentina_cs_CZ.ts
index bc45a0ace..db8f7b83c 100644
--- a/share/translations/valentina_cs_CZ.ts
+++ b/share/translations/valentina_cs_CZ.ts
@@ -14816,7 +14816,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Bod v průsečíku oblouku a čáry
+ Bod v průsečíku oblouku a čáry
@@ -15278,6 +15278,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+ Průsečík kruhu a části
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_de_DE.ts b/share/translations/valentina_de_DE.ts
index 9aec049a1..52f2e0ce3 100644
--- a/share/translations/valentina_de_DE.ts
+++ b/share/translations/valentina_de_DE.ts
@@ -14774,7 +14774,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Laufender Schnittpunkt auf Kreisbogen
+ Laufender Schnittpunkt auf Kreisbogen
@@ -15228,6 +15228,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+ Punkt am Schnittpunkt von Kreis und Abschnitt
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_el_GR.ts b/share/translations/valentina_el_GR.ts
index 7426908ed..d9926ab32 100644
--- a/share/translations/valentina_el_GR.ts
+++ b/share/translations/valentina_el_GR.ts
@@ -14284,7 +14284,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Σημείο στην τομή τόξου και γραμμής
+ Σημείο στην τομή τόξου και γραμμής
@@ -14742,6 +14742,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_en_CA.ts b/share/translations/valentina_en_CA.ts
index 8125edf52..ce31bf801 100644
--- a/share/translations/valentina_en_CA.ts
+++ b/share/translations/valentina_en_CA.ts
@@ -14763,7 +14763,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Point at intersection of arc and line
+ Point at intersection of arc and line
@@ -15225,6 +15225,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_en_IN.ts b/share/translations/valentina_en_IN.ts
index ee59cf563..3a57574b8 100644
--- a/share/translations/valentina_en_IN.ts
+++ b/share/translations/valentina_en_IN.ts
@@ -14763,7 +14763,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Point at intersection of arc and line
+ Point at intersection of arc and line
@@ -15225,6 +15225,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_en_US.ts b/share/translations/valentina_en_US.ts
index c6be266db..41fb77754 100644
--- a/share/translations/valentina_en_US.ts
+++ b/share/translations/valentina_en_US.ts
@@ -14763,7 +14763,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Point at intersection of arc and line
+ Point at intersection of arc and line
@@ -15225,6 +15225,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_es_ES.ts b/share/translations/valentina_es_ES.ts
index e443ac790..ae8126045 100644
--- a/share/translations/valentina_es_ES.ts
+++ b/share/translations/valentina_es_ES.ts
@@ -14821,7 +14821,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Punto de intersección del arco y la línea
+ Punto de intersección del arco y la línea
@@ -15283,6 +15283,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+ Punto de intersección circulo y segmento
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_fi_FI.ts b/share/translations/valentina_fi_FI.ts
index 3d1bcf476..9f7b7e8a1 100644
--- a/share/translations/valentina_fi_FI.ts
+++ b/share/translations/valentina_fi_FI.ts
@@ -13198,7 +13198,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Kaaren ja viivan leikkauspiste
+ Kaaren ja viivan leikkauspiste
@@ -13600,6 +13600,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_fr_FR.ts b/share/translations/valentina_fr_FR.ts
index f740d1131..f9d1ca04c 100644
--- a/share/translations/valentina_fr_FR.ts
+++ b/share/translations/valentina_fr_FR.ts
@@ -14719,7 +14719,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Point à l'intersection d'un arc et d'une ligne
+ Point à l'intersection d'un arc et d'une ligne
@@ -15177,6 +15177,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_he_IL.ts b/share/translations/valentina_he_IL.ts
index 5ad729648..bfa5d44f1 100644
--- a/share/translations/valentina_he_IL.ts
+++ b/share/translations/valentina_he_IL.ts
@@ -11862,10 +11862,6 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
-
-
-
-
@@ -12254,6 +12250,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_id_ID.ts b/share/translations/valentina_id_ID.ts
index 587d8377a..d87b0564f 100644
--- a/share/translations/valentina_id_ID.ts
+++ b/share/translations/valentina_id_ID.ts
@@ -12258,10 +12258,6 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
-
-
-
-
@@ -12650,6 +12646,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_it_IT.ts b/share/translations/valentina_it_IT.ts
index be29ba4ba..8a51a1f00 100644
--- a/share/translations/valentina_it_IT.ts
+++ b/share/translations/valentina_it_IT.ts
@@ -14691,7 +14691,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Punto di intersezione tra arco e linea
+ Punto di intersezione tra arco e linea
@@ -15145,6 +15145,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_pl_PL.ts b/share/translations/valentina_pl_PL.ts
index d7307d2fc..79e8b6d8f 100644
--- a/share/translations/valentina_pl_PL.ts
+++ b/share/translations/valentina_pl_PL.ts
@@ -13349,10 +13349,6 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
Dodaj punkt prostopadły
-
-
-
-
@@ -13753,6 +13749,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_pt_BR.ts b/share/translations/valentina_pt_BR.ts
index b738ec820..7749106e0 100644
--- a/share/translations/valentina_pt_BR.ts
+++ b/share/translations/valentina_pt_BR.ts
@@ -14722,7 +14722,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Ponto de interseção entre arco e linha
+ Ponto de interseção entre arco e linha
@@ -15184,6 +15184,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_ro_RO.ts b/share/translations/valentina_ro_RO.ts
index f22d0e020..64fbe3368 100644
--- a/share/translations/valentina_ro_RO.ts
+++ b/share/translations/valentina_ro_RO.ts
@@ -13047,10 +13047,6 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
Grade de unghi suplimentare
-
-
-
-
@@ -13447,6 +13443,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_ru_RU.ts b/share/translations/valentina_ru_RU.ts
index 224f5571c..321619df0 100644
--- a/share/translations/valentina_ru_RU.ts
+++ b/share/translations/valentina_ru_RU.ts
@@ -14822,7 +14822,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Точка на пересечении дуги и линии
+ Точка на пересечении дуги и линии
@@ -15284,6 +15284,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
Псевдоним 2:
+
+
+ Точка пересечения окружности и отрезка
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_uk_UA.ts b/share/translations/valentina_uk_UA.ts
index 70699293b..6b1756e2e 100644
--- a/share/translations/valentina_uk_UA.ts
+++ b/share/translations/valentina_uk_UA.ts
@@ -14762,7 +14762,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
- Точка на перетині дуги та лінії
+ Точка на перетині дуги та лінії
@@ -15224,6 +15224,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/share/translations/valentina_zh_CN.ts b/share/translations/valentina_zh_CN.ts
index e30a1a78b..2ae48649c 100644
--- a/share/translations/valentina_zh_CN.ts
+++ b/share/translations/valentina_zh_CN.ts
@@ -12051,10 +12051,6 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
-
-
-
-
@@ -12451,6 +12447,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
+
+
+
+
VToolPointFromArcAndTangent
diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp
index 392172920..bf71188c2 100644
--- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp
+++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp
@@ -2473,6 +2473,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolEllipticalArc(VPE::VProperty *pr
switch (PropertiesList().indexOf(id))
{
+ case 0: // AttrName
+ Q_UNREACHABLE();//The attribute is read only
+ break;
case 40://AttrRadius1
SetFormulaRadius1(property);
break;
@@ -2749,7 +2752,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfContact(QGraphicsItem *i
{
auto *i = qgraphicsitem_cast(item);
i->ShowVisualization(true);
- formView->setTitle(tr("Point at intersection of arc and line"));
+ formView->setTitle(tr("Point of intersection circle and segment"));
AddPropertyObjectName(i, tr("Point label:"));
AddPropertyParentPointName(i->ArcCenterPointName(), tr("Center of arc:"), AttrCenter);
@@ -3067,6 +3070,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolEllipticalArc(QGraphicsItem *it
i->ShowVisualization(true);
formView->setTitle(tr("Elliptical arc"));
+ AddPropertyObjectName(i, tr("Name:"), true);
AddPropertyParentPointName(i->CenterPointName(), tr("Center point:"), AttrCenter);
AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius1(), AttrRadius1);
AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius2(), AttrRadius2);
diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp
index 9c7cfb216..28c930822 100644
--- a/src/app/valentina/mainwindow.cpp
+++ b/src/app/valentina/mainwindow.cpp
@@ -1336,7 +1336,7 @@ void MainWindow::ClosedDialogInsertNode(int result)
{
const QPointer dTool = qobject_cast(dialogTool);
SCASSERT(not dTool.isNull())
- VToolSeamAllowance::InsertNode(dTool->GetNodes(), dTool->GetPieceId(), sceneDetails, pattern, doc);
+ VToolSeamAllowance::InsertNodes(dTool->GetNodes(), dTool->GetPieceId(), sceneDetails, pattern, doc);
}
ArrowTool(true);
doc->LiteParseTree(Document::LiteParse);
diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp
index 475ad183e..77d4a49df 100644
--- a/src/app/valentina/mainwindowsnogui.cpp
+++ b/src/app/valentina/mainwindowsnogui.cpp
@@ -294,6 +294,13 @@ bool MainWindowsNoGUI::GenerateLayout(VLayoutGenerator& lGenerator)
QCoreApplication::processEvents();
+#ifdef LAYOUT_DEBUG
+ const QString path = QDir::homePath()+QStringLiteral("/LayoutDebug");
+ QDir debugDir(path);
+ debugDir.removeRecursively();
+ debugDir.mkpath(path);
+#endif
+
forever
{
if (IsTimeout())
@@ -308,7 +315,9 @@ bool MainWindowsNoGUI::GenerateLayout(VLayoutGenerator& lGenerator)
break;
}
- switch (lGenerator.State())
+ nestingState = lGenerator.State();
+
+ switch (nestingState)
{
case LayoutErrors::NoError:
if (lGenerator.PapersCount() <= papersCount)
diff --git a/src/libs/vlayout/vbank.cpp b/src/libs/vlayout/vbank.cpp
index 8931bec50..23c70c9f6 100644
--- a/src/libs/vlayout/vbank.cpp
+++ b/src/libs/vlayout/vbank.cpp
@@ -438,15 +438,15 @@ int VBank::LeftToArrange() const
}
//---------------------------------------------------------------------------------------------------------------------
-qreal VBank::GetBiggestDiagonal() const
+int VBank::FailedToArrange() const
{
- return diagonal;
+ return CountDetails(unsorted);
}
//---------------------------------------------------------------------------------------------------------------------
-int VBank::ArrangedCount() const
+qreal VBank::GetBiggestDiagonal() const
{
- return details.size() - AllDetailsCount();
+ return diagonal;
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vlayout/vbank.h b/src/libs/vlayout/vbank.h
index 37b821e72..976c28f41 100644
--- a/src/libs/vlayout/vbank.h
+++ b/src/libs/vlayout/vbank.h
@@ -80,7 +80,7 @@ public:
int AllDetailsCount() const;
int LeftToArrange() const;
- int ArrangedCount() const;
+ int FailedToArrange() const;
qreal GetBiggestDiagonal() const;
diff --git a/src/libs/vlayout/vlayoutdef.h b/src/libs/vlayout/vlayoutdef.h
index b6e76a5af..d0dab1a86 100644
--- a/src/libs/vlayout/vlayoutdef.h
+++ b/src/libs/vlayout/vlayoutdef.h
@@ -116,4 +116,26 @@ struct VCachedPositions
QPainterPath layoutAllowancePath{};
};
+/* Warning! Debugging doesn't work stable in debug mode. If you need big allocation use release mode. Or disable
+ * Address Sanitizer. See page https://bitbucket.org/dismine/valentina/wiki/developers/Address_Sanitizer
+ */
+//#define LAYOUT_DEBUG // Enable debug mode
+
+// This block help rule debug mode. Don't turn all options at the same time!
+#ifdef LAYOUT_DEBUG
+// Nice looking
+# define SHOW_VERTICES // Show contour vertices
+# define SHOW_DIRECTION // Show contour direction
+# define ARRANGED_DETAILS // Show already arranged details
+# define SHOW_SHEET // Show sheet rect
+# define SHOW_CANDIDATE // Show each position
+
+// Debugging
+//# define SHOW_ROTATION // For each position show rotation part
+//# define SHOW_COMBINE // For each position show edge combine part
+//# define SHOW_MIRROR // For each position show mirror part
+//# define SHOW_CANDIDATE_BEST // For only correct positions that pass checks
+# define SHOW_BEST // Show only best position for workpiece
+#endif//LAYOUT_DEBUG
+
#endif // VLAYOUTDEF_H
diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp
index c34d403c3..a2e0efe86 100644
--- a/src/libs/vlayout/vlayoutgenerator.cpp
+++ b/src/libs/vlayout/vlayoutgenerator.cpp
@@ -267,6 +267,11 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
{
UnitePages();
}
+
+ if (bank->FailedToArrange() == 0)
+ {
+ state = LayoutErrors::NoError;
+ }
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp
index 364436c14..59761af8e 100644
--- a/src/libs/vlayout/vlayoutpaper.cpp
+++ b/src/libs/vlayout/vlayoutpaper.cpp
@@ -43,6 +43,10 @@
#include
#include
+#ifdef LAYOUT_DEBUG
+#include
+#endif
+
#include "vbestsquare.h"
#include "vcontour.h"
#include "vlayoutpiece.h"
@@ -239,6 +243,10 @@ bool VLayoutPaper::ArrangeDetail(const VLayoutPiece &detail, std::atomic_bool &s
d->localRotationNumber = d->globalRotationNumber;
}
+#ifdef LAYOUT_DEBUG
+ QMutex mutex;
+#endif
+
VPositionData data;
data.gContour = d->globalContour;
data.detail = detail;
@@ -247,9 +255,17 @@ bool VLayoutPaper::ArrangeDetail(const VLayoutPiece &detail, std::atomic_bool &s
data.followGrainline = d->followGrainline;
data.positionsCache = d->positionsCache;
data.isOriginPaperOrientationPortrait = d->originPaperOrientation;
+#ifdef LAYOUT_DEBUG
+ data.details = d->details;
+ data.mutex = &mutex;
+#endif
const VBestSquare result = VPosition::ArrangeDetail(data, &stop, d->saveLength);
+#ifdef LAYOUT_DEBUG
+ return SaveResult(result, detail, &mutex);
+#else
return SaveResult(result, detail);
+#endif
}
//---------------------------------------------------------------------------------------------------------------------
@@ -259,7 +275,11 @@ int VLayoutPaper::Count() const
}
//---------------------------------------------------------------------------------------------------------------------
-bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutPiece &detail)
+bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutPiece &detail
+#ifdef LAYOUT_DEBUG
+ , QMutex *mutex
+#endif
+ )
{
if (bestResult.HasValidResult())
{
@@ -287,6 +307,12 @@ bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutPiece
positionChache.boundingRect = VLayoutPiece::BoundingRect(layoutPoints);
positionChache.layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints);
d->positionsCache.append(positionChache);
+
+#ifdef LAYOUT_DEBUG
+# ifdef SHOW_BEST
+ VPosition::DumpFrame(d->globalContour, workDetail, mutex, d->details);
+# endif
+#endif
}
else if (bestResult.IsTerminatedByException())
{
diff --git a/src/libs/vlayout/vlayoutpaper.h b/src/libs/vlayout/vlayoutpaper.h
index d913bcf1c..1e77ee890 100644
--- a/src/libs/vlayout/vlayoutpaper.h
+++ b/src/libs/vlayout/vlayoutpaper.h
@@ -44,6 +44,7 @@ class VLayoutPiece;
class QGraphicsRectItem;
class QRectF;
class QGraphicsItem;
+class QMutex;
template class QList;
template class QVector;
@@ -107,7 +108,11 @@ public:
private:
QSharedDataPointer d;
- bool SaveResult(const VBestSquare &bestResult, const VLayoutPiece &detail);
+ bool SaveResult(const VBestSquare &bestResult, const VLayoutPiece &detail
+#ifdef LAYOUT_DEBUG
+ , QMutex *mutex
+#endif
+ );
};
diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp
index b1cfd6f50..4570d8ab0 100644
--- a/src/libs/vlayout/vposition.cpp
+++ b/src/libs/vlayout/vposition.cpp
@@ -61,6 +61,85 @@
#include
#endif
+namespace
+{
+#ifdef LAYOUT_DEBUG
+//---------------------------------------------------------------------------------------------------------------------
+QPainterPath ShowDirection(const QLineF &edge)
+{
+ const int arrowLength = 14;
+ QPainterPath path;
+ if (edge.length()/arrowLength < 5)
+ {
+ return path;
+ }
+
+ QLineF arrow = edge;
+ arrow.setLength(edge.length()/2.0);
+
+ //Reverse line because we want start arrow from this point
+ arrow = QLineF(arrow.p2(), arrow.p1());
+ const qreal angle = arrow.angle();//we each time change line angle, better save original angle value
+ arrow.setLength(arrowLength);//arrow length in pixels
+
+ arrow.setAngle(angle-35);
+ path.moveTo(arrow.p1());
+ path.lineTo(arrow.p2());
+
+ arrow.setAngle(angle+35);
+ path.moveTo(arrow.p1());
+ path.lineTo(arrow.p2());
+ return path;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+QPainterPath DumpContour(const QVector &points)
+{
+ QPainterPath path;
+ path.setFillRule(Qt::WindingFill);
+ if (points.count() >= 2)
+ {
+ for (qint32 i = 0; i < points.count()-1; ++i)
+ {
+ path.moveTo(points.at(i));
+ path.lineTo(points.at(i+1));
+ }
+ path.lineTo(points.at(0));
+
+#ifdef SHOW_DIRECTION
+ for (qint32 i = 0; i < points.count()-1; ++i)
+ {
+ path.addPath(ShowDirection(QLineF(points.at(i), points.at(i+1))));
+ }
+#endif
+
+#ifdef SHOW_VERTICES
+ for (qint32 i = 0; i < points.count(); ++i)
+ {
+ path.addRect(points.at(i).x()-3, points.at(i).y()-3, 6, 6);
+ }
+#endif
+ }
+ return path;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+QPainterPath DumpDetails(const QVector &details)
+{
+ QPainterPath path;
+ path.setFillRule(Qt::WindingFill);
+ if (details.count() > 0)
+ {
+ for (auto &detail : details)
+ {
+ path.addPath(detail.ContourPath());
+ }
+ }
+ return path;
+}
+#endif
+} //anonymous namespace
+
//---------------------------------------------------------------------------------------------------------------------
VPosition::VPosition()
{}
@@ -246,6 +325,12 @@ bool VPosition::CheckCombineEdges(VLayoutPiece &detail, int j, int &dEdge)
CombineEdges(detail, globalEdge, dEdge);
+#ifdef LAYOUT_DEBUG
+# ifdef SHOW_COMBINE
+ DumpFrame(m_data.gContour, detail, m_data.mutex, m_data.details);
+# endif
+#endif
+
CrossingType type = CrossingType::Intersection;
if (not detail.IsForceFlipping() && SheetContains(detail.DetailBoundingRect()))
{
@@ -276,6 +361,12 @@ bool VPosition::CheckCombineEdges(VLayoutPiece &detail, int j, int &dEdge)
if (flagMirror && not detail.IsForbidFlipping())
{
+#ifdef LAYOUT_DEBUG
+# ifdef SHOW_MIRROR
+ DumpFrame(m_data.gContour, detail, m_data.mutex, m_data.details);
+# endif
+#endif
+
dEdge = detail.LayoutEdgeByPoint(globalEdge.p2());
if (dEdge <= 0)
@@ -319,6 +410,12 @@ bool VPosition::CheckRotationEdges(VLayoutPiece &detail, int j, int dEdge, qreal
RotateEdges(detail, globalEdge, dEdge, angle);
+#ifdef LAYOUT_DEBUG
+# ifdef SHOW_ROTATION
+ DumpFrame(m_data.gContour, detail, m_data.mutex, m_data.details);
+# endif
+#endif
+
CrossingType type = CrossingType::Intersection;
if (SheetContains(detail.DetailBoundingRect()))
{
@@ -349,6 +446,17 @@ void VPosition::RotateOnAngle(qreal angle)
if (CheckRotationEdges(workDetail, m_data.j, m_data.i, angle))
{
+ if (stop->load())
+ {
+ return;
+ }
+
+#ifdef LAYOUT_DEBUG
+# ifdef SHOW_CANDIDATE_BEST
+ DumpFrame(m_data.gContour, workDetail, m_data.mutex, m_data.details);
+# endif
+#endif
+
SaveCandidate(m_bestResult, workDetail, m_data.j, m_data.i, BestFrom::Rotation);
}
}
@@ -372,10 +480,11 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const
for(auto &position : m_data.positionsCache)
{
- if (position.boundingRect.intersects(layoutBoundingRect) || position.boundingRect.contains(detailBoundingRect))
+ if (position.boundingRect.intersects(layoutBoundingRect) || position.boundingRect.contains(detailBoundingRect)
+ || detailBoundingRect.contains(position.boundingRect))
{
- if (position.layoutAllowancePath.contains(contourPath) ||
- position.layoutAllowancePath.intersects(layoutAllowancePath))
+ if (position.layoutAllowancePath.contains(contourPath) || contourPath.contains(position.layoutAllowancePath)
+ || position.layoutAllowancePath.intersects(layoutAllowancePath))
{
return CrossingType::Intersection;
}
@@ -489,6 +598,11 @@ void VPosition::FollowGrainline()
//---------------------------------------------------------------------------------------------------------------------
void VPosition::FindBestPosition()
{
+ if (stop->load())
+ {
+ return;
+ }
+
if (not m_data.followGrainline || not m_data.detail.IsGrainlineEnabled())
{
// We should use copy of the detail.
@@ -497,6 +611,17 @@ void VPosition::FindBestPosition()
int dEdge = m_data.i;// For mirror detail edge will be different
if (CheckCombineEdges(workDetail, m_data.j, dEdge))
{
+ if (stop->load())
+ {
+ return;
+ }
+
+#ifdef LAYOUT_DEBUG
+# ifdef SHOW_CANDIDATE_BEST
+ DumpFrame(m_data.gContour, workDetail, m_data.mutex, m_data.details);
+# endif
+#endif
+
SaveCandidate(m_bestResult, workDetail, m_data.j, dEdge, BestFrom::Combine);
}
@@ -515,3 +640,92 @@ void VPosition::FindBestPosition()
FollowGrainline();
}
}
+
+#ifdef LAYOUT_DEBUG
+//---------------------------------------------------------------------------------------------------------------------
+void VPosition::DumpFrame(const VContour &contour, const VLayoutPiece &detail, QMutex *mutex,
+ const QVector &details = QVector())
+{
+ auto Bias = [](int length, int maxLength)
+ {
+ return length < maxLength && length*2 < maxLength ? length : maxLength-length;
+ };
+
+ const int biasWidth = Bias(contour.GetWidth(), QIMAGE_MAX);
+ const int biasHeight = Bias(contour.GetHeight(), QIMAGE_MAX);
+
+ QPicture picture;
+ QPainter paint;
+ paint.begin(&picture);
+
+ paint.setPen(QPen(Qt::black, 6, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ QPainterPath p;
+ if (contour.GetContour().isEmpty())
+ {
+ p = DumpContour(contour.CutEmptySheetEdge());
+ p.translate(biasWidth/2, biasHeight/2);
+ paint.drawPath(p);
+ }
+ else
+ {
+ p = DumpContour(contour.GetContour());
+ p.translate(biasWidth/2, biasHeight/2);
+ paint.drawPath(p);
+ }
+
+#ifdef SHOW_CANDIDATE
+ paint.setPen(QPen(Qt::darkGreen, 6, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ p = DumpContour(detail.GetLayoutAllowancePoints());
+ p.translate(biasWidth/2, biasHeight/2);
+ paint.drawPath(p);
+#else
+ Q_UNUSED(detail)
+ Q_UNUSED(details)
+#endif
+
+#ifdef ARRANGED_DETAILS
+ paint.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ p = DumpDetails(details);
+ p.translate(biasWidth/2, biasHeight/2);
+ paint.drawPath(p);
+#else
+ Q_UNUSED(details)
+#endif
+
+ // Calculate bounding rect before draw sheet rect
+ const QRect pictureRect = picture.boundingRect();
+
+ // Sheet
+#ifdef SHOW_SHEET
+ paint.setPen(QPen(Qt::darkRed, 15, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ paint.drawRect(QRectF(biasWidth/2, biasHeight/2, contour.GetWidth(), contour.GetHeight()));
+#endif
+
+ paint.end();
+
+ // Dump frame to image
+ // Note. If program was build with Address Sanitizer possible crashes. Address Sanitizer doesn't support big
+ // allocations. See page https://bitbucket.org/dismine/valentina/wiki/developers/Address_Sanitizer
+ QImage frameImage(pictureRect.width()+biasWidth, pictureRect.height()+biasHeight, QImage::Format_RGB32);
+
+ if (frameImage.isNull())
+ {
+ return;
+ }
+
+ frameImage.fill(Qt::white);
+
+ QPainter paintFrameImage;
+ paintFrameImage.begin(&frameImage);
+ paintFrameImage.drawPicture(0, 0, picture);
+ paintFrameImage.end();
+
+ QMutexLocker locker(mutex);
+
+ static int frame = 0;
+ ++frame;
+
+ const QString path = QDir::homePath()+QStringLiteral("/LayoutDebug/%1.png").arg(frame);
+ frameImage.save (path);
+}
+#endif
diff --git a/src/libs/vlayout/vposition.h b/src/libs/vlayout/vposition.h
index b3db55370..2f80199e2 100644
--- a/src/libs/vlayout/vposition.h
+++ b/src/libs/vlayout/vposition.h
@@ -35,6 +35,10 @@
#include
#include
+#ifdef LAYOUT_DEBUG
+#include
+#endif
+
#include "vbestsquare.h"
#include "vcontour.h"
#include "vlayoutdef.h"
@@ -51,6 +55,10 @@ struct VPositionData
bool followGrainline{false};
QVector positionsCache{};
bool isOriginPaperOrientationPortrait{true};
+#ifdef LAYOUT_DEBUG
+ QVector details{};
+ QMutex *mutex{nullptr};
+#endif
};
QT_WARNING_PUSH
@@ -72,6 +80,11 @@ public:
static VBestSquare ArrangeDetail(const VPositionData &data, std::atomic_bool *stop, bool saveLength);
+#ifdef LAYOUT_DEBUG
+ static void DumpFrame(const VContour &contour, const VLayoutPiece &detail, QMutex *mutex,
+ const QVector &details);
+#endif
+
private:
bool m_isValid{false};
VBestSquare m_bestResult{};
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp
index 662185787..91cdefdd2 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp
+++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp
@@ -222,7 +222,7 @@ void VToolCurveIntersectAxis::SetFormulaAngle(const VFormula &value)
//---------------------------------------------------------------------------------------------------------------------
QString VToolCurveIntersectAxis::CurveName() const
{
- return VAbstractTool::data.GetGObject(curveId)->name();
+ return VAbstractTool::data.GetGObject(curveId)->ObjectName();
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp
index a7536d80b..34df55804 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp
+++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp
@@ -234,7 +234,7 @@ QString VToolPointFromArcAndTangent::TangentPointName() const
//---------------------------------------------------------------------------------------------------------------------
QString VToolPointFromArcAndTangent::ArcName() const
{
- return VAbstractTool::data.GetGObject(arcId)->name();
+ return VAbstractTool::data.GetGObject(arcId)->ObjectName();
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp
index 33069a0b1..9f9c44d4f 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp
+++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp
@@ -250,13 +250,13 @@ bool VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *arc2,
//---------------------------------------------------------------------------------------------------------------------
QString VToolPointOfIntersectionArcs::FirstArcName() const
{
- return VAbstractTool::data.GetGObject(firstArcId)->name();
+ return VAbstractTool::data.GetGObject(firstArcId)->ObjectName();
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolPointOfIntersectionArcs::SecondArcName() const
{
- return VAbstractTool::data.GetGObject(secondArcId)->name();
+ return VAbstractTool::data.GetGObject(secondArcId)->ObjectName();
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp
index 0a8e0cc5d..95a2ce7a5 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp
+++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp
@@ -283,13 +283,13 @@ bool VToolPointOfIntersectionCurves::FindPoint(const QVector &curve1Poi
//---------------------------------------------------------------------------------------------------------------------
QString VToolPointOfIntersectionCurves::FirstCurveName() const
{
- return VAbstractTool::data.GetGObject(firstCurveId)->name();
+ return VAbstractTool::data.GetGObject(firstCurveId)->ObjectName();
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolPointOfIntersectionCurves::SecondCurveName() const
{
- return VAbstractTool::data.GetGObject(secondCurveId)->name();
+ return VAbstractTool::data.GetGObject(secondCurveId)->ObjectName();
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp
index f6d006a43..913fc8e29 100644
--- a/src/libs/vtools/tools/vtoolseamallowance.cpp
+++ b/src/libs/vtools/tools/vtoolseamallowance.cpp
@@ -225,8 +225,8 @@ void VToolSeamAllowance::RemoveWithConfirm(bool ask)
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolSeamAllowance::InsertNode(const QVector &nodes, quint32 pieceId, VMainGraphicsScene *scene,
- VContainer *data, VAbstractPattern *doc)
+void VToolSeamAllowance::InsertNodes(const QVector &nodes, quint32 pieceId, VMainGraphicsScene *scene,
+ VContainer *data, VAbstractPattern *doc)
{
SCASSERT(scene != nullptr)
SCASSERT(data != nullptr)
@@ -261,7 +261,7 @@ void VToolSeamAllowance::InsertNode(const QVector &nodes, quint32 pi
VToolSeamAllowance *saTool = qobject_cast(VAbstractPattern::getTool(pieceId));
SCASSERT(saTool != nullptr);
- InitNode(node, scene, data, doc, saTool);
+ InitNode(node, scene, saTool);
}
qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, pieceId));
@@ -1747,17 +1747,16 @@ void VToolSeamAllowance::InitNodes(const VPiece &detail, VMainGraphicsScene *sce
{
for (int i = 0; i< detail.GetPath().CountNodes(); ++i)
{
- InitNode(detail.GetPath().at(i), scene, &(VAbstractTool::data), doc, this);
+ const VPieceNode &node = detail.GetPath().at(i);
+ InitNode(node, scene, this);
+ doc->IncrementReferens(VAbstractTool::data.GetGObject(node.GetId())->getIdTool());
}
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *scene, VContainer *data,
- VAbstractPattern *doc, VToolSeamAllowance *parent)
+void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *scene, VToolSeamAllowance *parent)
{
SCASSERT(scene != nullptr)
- SCASSERT(data != nullptr)
- SCASSERT(doc != nullptr)
SCASSERT(parent != nullptr)
switch (node.GetTypeTool())
diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h
index 64022a839..bea05f8d6 100644
--- a/src/libs/vtools/tools/vtoolseamallowance.h
+++ b/src/libs/vtools/tools/vtoolseamallowance.h
@@ -91,7 +91,7 @@ public:
void RemoveWithConfirm(bool ask);
- static void InsertNode(const QVector &nodes, quint32 pieceId, VMainGraphicsScene *scene,
+ static void InsertNodes(const QVector &nodes, quint32 pieceId, VMainGraphicsScene *scene,
VContainer *data, VAbstractPattern *doc);
static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiece &piece);
@@ -202,8 +202,7 @@ private:
qreal &rotationAngle, QPointF &pos);
void InitNodes(const VPiece &detail, VMainGraphicsScene *scene);
- static void InitNode(const VPieceNode &node, VMainGraphicsScene *scene, VContainer *data, VAbstractPattern *doc,
- VToolSeamAllowance *parent);
+ static void InitNode(const VPieceNode &node, VMainGraphicsScene *scene, VToolSeamAllowance *parent);
void InitCSAPaths(const VPiece &detail) const;
void InitInternalPaths(const VPiece &detail);
void InitSpecialPoints(const QVector &points) const;
diff --git a/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.cpp b/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.cpp
index 7ddce1671..c6c159ce1 100644
--- a/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.cpp
+++ b/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.cpp
@@ -98,16 +98,16 @@ void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc)
const qreal radius = arc->GetRadius();
const int res = VGObject::ContactPoints (p, center, radius, p1, p2);
- QLineF r1Arc(center, p1);
- r1Arc.setLength(radius+10);
-
- QLineF r2Arc(center, p2);
- r2Arc.setLength(radius+10);
-
switch(res)
{
case 2:
{
+ QLineF r1Arc(center, p1);
+ r1Arc.setLength(radius+10);
+
+ QLineF r2Arc(center, p2);
+ r2Arc.setLength(radius+10);
+
int localRes = 0;
bool flagP1 = false;