Merge branch 'develop' into feature/manual-layout

This commit is contained in:
Roman Telezhynskyi 2020-11-27 11:56:55 +02:00
commit aa5f026c58
38 changed files with 426 additions and 70 deletions

View File

@ -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.

View File

@ -15163,7 +15163,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Point at intersection of arc and line</translation>
<translation type="vanished">Point at intersection of arc and line</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15625,6 +15625,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14816,7 +14816,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Bod v průsečíku oblouku a čáry</translation>
<translation type="vanished">Bod v průsečíku oblouku a čáry</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15278,6 +15278,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished">Průsečík kruhu a části</translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14774,7 +14774,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Laufender Schnittpunkt auf Kreisbogen</translation>
<translation type="vanished">Laufender Schnittpunkt auf Kreisbogen</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15228,6 +15228,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished">Punkt am Schnittpunkt von Kreis und Abschnitt</translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14284,7 +14284,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Σημείο στην τομή τόξου και γραμμής</translation>
<translation type="vanished">Σημείο στην τομή τόξου και γραμμής</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -14742,6 +14742,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14763,7 +14763,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Point at intersection of arc and line</translation>
<translation type="vanished">Point at intersection of arc and line</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15225,6 +15225,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14763,7 +14763,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Point at intersection of arc and line</translation>
<translation type="vanished">Point at intersection of arc and line</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15225,6 +15225,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14763,7 +14763,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Point at intersection of arc and line</translation>
<translation type="vanished">Point at intersection of arc and line</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15225,6 +15225,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14821,7 +14821,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Punto de intersección del arco y la línea</translation>
<translation type="vanished">Punto de intersección del arco y la línea</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15283,6 +15283,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished">Punto de intersección circulo y segmento</translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -13198,7 +13198,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Kaaren ja viivan leikkauspiste</translation>
<translation type="vanished">Kaaren ja viivan leikkauspiste</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -13600,6 +13600,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14719,7 +14719,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Point à l&apos;intersection d&apos;un arc et d&apos;une ligne</translation>
<translation type="vanished">Point à l&apos;intersection d&apos;un arc et d&apos;une ligne</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15177,6 +15177,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -11862,10 +11862,6 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Point along perpendicular</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
<translation type="unfinished"></translation>
@ -12254,6 +12250,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -12258,10 +12258,6 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Point along perpendicular</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
<translation type="unfinished"></translation>
@ -12650,6 +12646,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14691,7 +14691,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Punto di intersezione tra arco e linea</translation>
<translation type="vanished">Punto di intersezione tra arco e linea</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15145,6 +15145,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -13349,10 +13349,6 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Point along perpendicular</source>
<translation>Dodaj punkt prostopadły</translation>
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
<translation type="unfinished"></translation>
@ -13753,6 +13749,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14722,7 +14722,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Ponto de interseção entre arco e linha</translation>
<translation type="vanished">Ponto de interseção entre arco e linha</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15184,6 +15184,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -13047,10 +13047,6 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Additional angle degrees</source>
<translation type="vanished">Grade de unghi suplimentare</translation>
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
<translation type="unfinished"></translation>
@ -13447,6 +13443,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14822,7 +14822,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Точка на пересечении дуги и линии</translation>
<translation type="vanished">Точка на пересечении дуги и линии</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15284,6 +15284,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation>Псевдоним 2:</translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished">Точка пересечения окружности и отрезка</translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -14762,7 +14762,7 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation>Точка на перетині дуги та лінії</translation>
<translation type="vanished">Точка на перетині дуги та лінії</translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
@ -15224,6 +15224,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -12051,10 +12051,6 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Point along perpendicular</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point at intersection of arc and line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tool to make point from x &amp; y of two other points</source>
<translation type="unfinished"></translation>
@ -12451,6 +12447,10 @@ Raw layout format compatibility error: actualFileVersion = %1 and fileVersion =
<source>Alias2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Point of intersection circle and segment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VToolPointFromArcAndTangent</name>

View File

@ -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<VToolPointOfContact *>(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);

View File

@ -1336,7 +1336,7 @@ void MainWindow::ClosedDialogInsertNode(int result)
{
const QPointer<DialogInsertNode> dTool = qobject_cast<DialogInsertNode *>(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);

View File

@ -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)

View File

@ -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;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -80,7 +80,7 @@ public:
int AllDetailsCount() const;
int LeftToArrange() const;
int ArrangedCount() const;
int FailedToArrange() const;
qreal GetBiggestDiagonal() const;

View File

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

View File

@ -267,6 +267,11 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
{
UnitePages();
}
if (bank->FailedToArrange() == 0)
{
state = LayoutErrors::NoError;
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -43,6 +43,10 @@
#include <Qt>
#include <QtAlgorithms>
#ifdef LAYOUT_DEBUG
#include <QMutex>
#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())
{

View File

@ -44,6 +44,7 @@ class VLayoutPiece;
class QGraphicsRectItem;
class QRectF;
class QGraphicsItem;
class QMutex;
template <typename T> class QList;
template <typename T> class QVector;
@ -107,7 +108,11 @@ public:
private:
QSharedDataPointer<VLayoutPaperData> d;
bool SaveResult(const VBestSquare &bestResult, const VLayoutPiece &detail);
bool SaveResult(const VBestSquare &bestResult, const VLayoutPiece &detail
#ifdef LAYOUT_DEBUG
, QMutex *mutex
#endif
);
};

View File

@ -61,6 +61,85 @@
#include <QScopeGuard>
#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<QPointF> &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<VLayoutPiece> &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<VLayoutPiece> &details = QVector<VLayoutPiece>())
{
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

View File

@ -35,6 +35,10 @@
#include <QtGlobal>
#include <atomic>
#ifdef LAYOUT_DEBUG
#include <QMutex>
#endif
#include "vbestsquare.h"
#include "vcontour.h"
#include "vlayoutdef.h"
@ -51,6 +55,10 @@ struct VPositionData
bool followGrainline{false};
QVector<VCachedPositions> positionsCache{};
bool isOriginPaperOrientationPortrait{true};
#ifdef LAYOUT_DEBUG
QVector<VLayoutPiece> 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<VLayoutPiece> &details);
#endif
private:
bool m_isValid{false};
VBestSquare m_bestResult{};

View File

@ -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();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -234,7 +234,7 @@ QString VToolPointFromArcAndTangent::TangentPointName() const
//---------------------------------------------------------------------------------------------------------------------
QString VToolPointFromArcAndTangent::ArcName() const
{
return VAbstractTool::data.GetGObject(arcId)->name();
return VAbstractTool::data.GetGObject(arcId)->ObjectName();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -283,13 +283,13 @@ bool VToolPointOfIntersectionCurves::FindPoint(const QVector<QPointF> &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();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -225,7 +225,7 @@ void VToolSeamAllowance::RemoveWithConfirm(bool ask)
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::InsertNode(const QVector<VPieceNode> &nodes, quint32 pieceId, VMainGraphicsScene *scene,
void VToolSeamAllowance::InsertNodes(const QVector<VPieceNode> &nodes, quint32 pieceId, VMainGraphicsScene *scene,
VContainer *data, VAbstractPattern *doc)
{
SCASSERT(scene != nullptr)
@ -261,7 +261,7 @@ void VToolSeamAllowance::InsertNode(const QVector<VPieceNode> &nodes, quint32 pi
VToolSeamAllowance *saTool = qobject_cast<VToolSeamAllowance*>(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())

View File

@ -91,7 +91,7 @@ public:
void RemoveWithConfirm(bool ask);
static void InsertNode(const QVector<VPieceNode> &nodes, quint32 pieceId, VMainGraphicsScene *scene,
static void InsertNodes(const QVector<VPieceNode> &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<quint32> &points) const;

View File

@ -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);
switch(res)
{
case 2:
{
QLineF r1Arc(center, p1);
r1Arc.setLength(radius+10);
QLineF r2Arc(center, p2);
r2Arc.setLength(radius+10);
switch(res)
{
case 2:
{
int localRes = 0;
bool flagP1 = false;