diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index c996b5427..9ba89c342 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -60,7 +60,7 @@ //--------------------------------------------------------------------------------------------------------------------- MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) - : VAbstractMainWindow(parent), listDetails(QVector()), currentScene(nullptr), tempSceneLayout(nullptr), + : VAbstractMainWindow(parent), listDetails(QVector()), currentScene(nullptr), tempSceneLayout(nullptr), pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())), doc(nullptr), papers(QList()), shadows(QList()), scenes(QList()), details(QList >()), undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), actionDockWidgetGroups(nullptr), @@ -475,7 +475,7 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash *det QHash::const_iterator i = details->constBegin(); while (i != details->constEnd()) { - listDetails.append(VLayoutDetail::Create(i.value(), pattern)); + listDetails.append(VLayoutPiece::Create(i.value(), pattern)); ++i; } } diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index 6b5cfc26f..17f715dfb 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -32,7 +32,7 @@ #include #include -#include "../vlayout/vlayoutdetail.h" +#include "../vlayout/vlayoutpiece.h" #include "xml/vpattern.h" #include "dialogs/dialogsavelayout.h" #include "../vlayout/vlayoutgenerator.h" @@ -58,7 +58,7 @@ public slots: void PrintOrigin(); void PrintTiled(); protected: - QVector listDetails; + QVector listDetails; /** @brief currentScene pointer to current scene. */ QGraphicsScene *currentScene; diff --git a/src/libs/vlayout/vbank.cpp b/src/libs/vlayout/vbank.cpp index f28787391..17b8eb7cf 100644 --- a/src/libs/vlayout/vbank.cpp +++ b/src/libs/vlayout/vbank.cpp @@ -32,7 +32,7 @@ #include "../vmisc/diagnostic.h" #include "../vmisc/logging.h" -#include "vlayoutdetail.h" +#include "vlayoutpiece.h" QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") @@ -52,7 +52,7 @@ QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- VBank::VBank() - :details(QVector()), unsorted(QHash()), big(QHash()), + :details(QVector()), unsorted(QHash()), big(QHash()), middle(QHash()), small(QHash()), layoutWidth(0), caseType(Cases::CaseDesc), prepare(false), diagonal(0) {} @@ -71,7 +71,7 @@ void VBank::SetLayoutWidth(const qreal &value) } //--------------------------------------------------------------------------------------------------------------------- -void VBank::SetDetails(const QVector &details) +void VBank::SetDetails(const QVector &details) { this->details = details; Reset(); @@ -111,7 +111,7 @@ int VBank::GetTiket() } //--------------------------------------------------------------------------------------------------------------------- -VLayoutDetail VBank::GetDetail(int i) const +VLayoutPiece VBank::GetDetail(int i) const { if (i >= 0 && i < details.size()) { @@ -119,7 +119,7 @@ VLayoutDetail VBank::GetDetail(int i) const } else { - return VLayoutDetail(); + return VLayoutPiece(); } } diff --git a/src/libs/vlayout/vbank.h b/src/libs/vlayout/vbank.h index 51cd7e312..340f034d2 100644 --- a/src/libs/vlayout/vbank.h +++ b/src/libs/vlayout/vbank.h @@ -43,7 +43,7 @@ #endif class QPointF; -class VLayoutDetail; +class VLayoutPiece; enum class Cases : char { CaseThreeGroup = 0, CaseTwoGroup, CaseDesc, UnknownCase}; @@ -55,9 +55,9 @@ public: qreal GetLayoutWidth() const; void SetLayoutWidth(const qreal &value); - void SetDetails(const QVector &details); + void SetDetails(const QVector &details); int GetTiket(); - VLayoutDetail GetDetail(int i) const; + VLayoutPiece GetDetail(int i) const; void Arranged(int i); void NotArranged(int i); @@ -74,7 +74,7 @@ public: private: Q_DISABLE_COPY(VBank) - QVector details; + QVector details; QHash unsorted; QHash big; diff --git a/src/libs/vlayout/vcontour.cpp b/src/libs/vlayout/vcontour.cpp index 03ae18dee..da72142cb 100644 --- a/src/libs/vlayout/vcontour.cpp +++ b/src/libs/vlayout/vcontour.cpp @@ -37,7 +37,7 @@ #include #include "vcontour_p.h" -#include "vlayoutdetail.h" +#include "vlayoutpiece.h" #include "../vmisc/vmath.h" //--------------------------------------------------------------------------------------------------------------------- @@ -125,7 +125,7 @@ QSizeF VContour::GetSize() const } //--------------------------------------------------------------------------------------------------------------------- -QVector VContour::UniteWithContour(const VLayoutDetail &detail, int globalI, int detJ, BestFrom type) const +QVector VContour::UniteWithContour(const VLayoutPiece &detail, int globalI, int detJ, BestFrom type) const { QVector newContour; if (d->globalContour.isEmpty()) //-V807 @@ -333,7 +333,7 @@ QPainterPath VContour::ContourPath() const } //--------------------------------------------------------------------------------------------------------------------- -void VContour::AppendWhole(QVector &contour, const VLayoutDetail &detail, int detJ) const +void VContour::AppendWhole(QVector &contour, const VLayoutPiece &detail, int detJ) const { int processedEdges = 0; const int nD = detail.LayoutEdgesCount(); diff --git a/src/libs/vlayout/vcontour.h b/src/libs/vlayout/vcontour.h index baa64f963..cfa622da4 100644 --- a/src/libs/vlayout/vcontour.h +++ b/src/libs/vlayout/vcontour.h @@ -43,7 +43,7 @@ class QPointF; class QRectF; class QSizeF; class VContourData; -class VLayoutDetail; +class VLayoutPiece; class VContour { @@ -68,7 +68,7 @@ public: QSizeF GetSize() const; - QVector UniteWithContour(const VLayoutDetail &detail, int globalI, int detJ, BestFrom type) const; + QVector UniteWithContour(const VLayoutPiece &detail, int globalI, int detJ, BestFrom type) const; QLineF EmptySheetEdge() const; int GlobalEdgesCount() const; @@ -85,7 +85,7 @@ public: private: QSharedDataPointer d; - void AppendWhole(QVector &contour, const VLayoutDetail &detail, int detJ) const; + void AppendWhole(QVector &contour, const VLayoutPiece &detail, int detJ) const; }; Q_DECLARE_TYPEINFO(VContour, Q_MOVABLE_TYPE); diff --git a/src/libs/vlayout/vlayout.pri b/src/libs/vlayout/vlayout.pri index 29ef87f7c..1ed0558d0 100644 --- a/src/libs/vlayout/vlayout.pri +++ b/src/libs/vlayout/vlayout.pri @@ -4,10 +4,8 @@ HEADERS += \ $$PWD/stable.h \ $$PWD/vlayoutgenerator.h \ - $$PWD/vlayoutdetail.h \ $$PWD/vabstractdetail.h \ $$PWD/vabstractdetail_p.h \ - $$PWD/vlayoutdetail_p.h \ $$PWD/vlayoutdef.h \ $$PWD/vlayoutpaper.h \ $$PWD/vlayoutpaper_p.h \ @@ -20,11 +18,12 @@ HEADERS += \ $$PWD/vposter.h \ $$PWD/vgraphicsfillitem.h \ $$PWD/vabstractpiece.h \ - $$PWD/vabstractpiece_p.h + $$PWD/vabstractpiece_p.h \ + $$PWD/vlayoutpiece.h \ + $$PWD/vlayoutpiece_p.h SOURCES += \ $$PWD/vlayoutgenerator.cpp \ - $$PWD/vlayoutdetail.cpp \ $$PWD/vabstractdetail.cpp \ $$PWD/vlayoutpaper.cpp \ $$PWD/vbank.cpp \ @@ -34,6 +33,7 @@ SOURCES += \ $$PWD/vtextmanager.cpp \ $$PWD/vposter.cpp \ $$PWD/vgraphicsfillitem.cpp \ - $$PWD/vabstractpiece.cpp + $$PWD/vabstractpiece.cpp \ + $$PWD/vlayoutpiece.cpp win32-msvc*:SOURCES += $$PWD/stable.cpp diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index cc374eed7..0117f04ee 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -34,7 +34,7 @@ #include "../vmisc/def.h" #include "../vmisc/vmath.h" -#include "vlayoutdetail.h" +#include "vlayoutpiece.h" #include "vlayoutpaper.h" class QMarginsF; @@ -54,7 +54,7 @@ VLayoutGenerator::~VLayoutGenerator() } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutGenerator::SetDetails(const QVector &details) +void VLayoutGenerator::SetDetails(const QVector &details) { bank->SetDetails(details); } @@ -273,7 +273,7 @@ void VLayoutGenerator::GatherPages() return; } - QList> nDetails; + QList> nDetails; qreal length = 0; int j = 0; // papers count @@ -328,7 +328,7 @@ void VLayoutGenerator::UnitePages() } QList papersLength; - QList > nDetails; + QList > nDetails; qreal length = 0; int j = 0; // papers count @@ -385,7 +385,7 @@ void VLayoutGenerator::UnitePages() } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutGenerator::UniteDetails(int j, QList > &nDetails, qreal length, int i) +void VLayoutGenerator::UniteDetails(int j, QList > &nDetails, qreal length, int i) { if ((j == 0 && nDetails.isEmpty()) || j >= nDetails.size()) {//First or new details in paper @@ -411,17 +411,17 @@ void VLayoutGenerator::UnitePapers(int j, QList &papersLength, qreal leng } //--------------------------------------------------------------------------------------------------------------------- -QList VLayoutGenerator::MoveDetails(qreal length, const QVector &details) +QList VLayoutGenerator::MoveDetails(qreal length, const QVector &details) { if (qFuzzyIsNull(length)) { return details.toList(); } - QList newDetails; + QList newDetails; for (int i = 0; i < details.size(); ++i) { - VLayoutDetail d = details.at(i); + VLayoutPiece d = details.at(i); d.Translate(0, length); newDetails.append(d); } diff --git a/src/libs/vlayout/vlayoutgenerator.h b/src/libs/vlayout/vlayoutgenerator.h index 90caa59bd..822e35658 100644 --- a/src/libs/vlayout/vlayoutgenerator.h +++ b/src/libs/vlayout/vlayoutgenerator.h @@ -50,7 +50,7 @@ class QMarginsF; #endif class QGraphicsItem; -class VLayoutDetail; +class VLayoutPiece; class VLayoutPaper; class VLayoutGenerator :public QObject @@ -60,7 +60,7 @@ public: explicit VLayoutGenerator(QObject *parent = nullptr); virtual ~VLayoutGenerator() Q_DECL_OVERRIDE; - void SetDetails(const QVector &details); + void SetDetails(const QVector &details); void SetLayoutWidth(qreal width); void SetCaseType(Cases caseType); int DetailsCount(); @@ -140,9 +140,9 @@ private: void GatherPages(); void UnitePages(); - void UniteDetails(int j, QList > &nDetails, qreal length, int i); + void UniteDetails(int j, QList > &nDetails, qreal length, int i); void UnitePapers(int j, QList &papersLength, qreal length); - QList MoveDetails(qreal length, const QVector &details); + QList MoveDetails(qreal length, const QVector &details); }; typedef std::shared_ptr VLayoutGeneratorPtr; diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 6422faeea..890c6dea4 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -45,7 +45,7 @@ #include "vbestsquare.h" #include "vcontour.h" -#include "vlayoutdetail.h" +#include "vlayoutpiece.h" #include "vlayoutpaper_p.h" #include "vposition.h" @@ -185,7 +185,7 @@ void VLayoutPaper::SetPaperIndex(quint32 index) } //--------------------------------------------------------------------------------------------------------------------- -bool VLayoutPaper::ArrangeDetail(const VLayoutDetail &detail, volatile bool &stop) +bool VLayoutPaper::ArrangeDetail(const VLayoutPiece &detail, volatile bool &stop) { // First need set size of paper if (d->globalContour.GetHeight() <= 0 || d->globalContour.GetWidth() <= 0) @@ -221,7 +221,7 @@ int VLayoutPaper::Count() const } //--------------------------------------------------------------------------------------------------------------------- -bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, volatile bool &stop) +bool VLayoutPaper::AddToSheet(const VLayoutPiece &detail, volatile bool &stop) { VBestSquare bestResult(d->globalContour.GetSize(), d->saveLength); QThreadPool *thread_pool = QThreadPool::globalInstance(); @@ -289,11 +289,11 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, volatile bool &stop) } //--------------------------------------------------------------------------------------------------------------------- -bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutDetail &detail) +bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutPiece &detail) { if (bestResult.ValidResult()) { - VLayoutDetail workDetail = detail; + VLayoutPiece workDetail = detail; workDetail.SetMatrix(bestResult.Matrix());// Don't forget set matrix workDetail.SetMirror(bestResult.Mirror()); const QVector newGContour = d->globalContour.UniteWithContour(workDetail, bestResult.GContourEdge(), @@ -369,13 +369,13 @@ QList VLayoutPaper::GetItemDetails() const } //--------------------------------------------------------------------------------------------------------------------- -QVector VLayoutPaper::GetDetails() const +QVector VLayoutPaper::GetDetails() const { return d->details; } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutPaper::SetDetails(const QList &details) +void VLayoutPaper::SetDetails(const QList &details) { d->details = details.toVector(); } diff --git a/src/libs/vlayout/vlayoutpaper.h b/src/libs/vlayout/vlayoutpaper.h index 8c48a076d..7a28b8d74 100644 --- a/src/libs/vlayout/vlayoutpaper.h +++ b/src/libs/vlayout/vlayoutpaper.h @@ -40,7 +40,7 @@ class QGraphicsItem; class QGraphicsRectItem; class QRectF; class VBestSquare; -class VLayoutDetail; +class VLayoutPiece; class VLayoutPaperData; template class QList; template class QVector; @@ -77,22 +77,22 @@ public: void SetPaperIndex(quint32 index); - bool ArrangeDetail(const VLayoutDetail &detail, volatile bool &stop); + bool ArrangeDetail(const VLayoutPiece &detail, volatile bool &stop); int Count() const; QGraphicsRectItem *GetPaperItem(bool autoCrop) const Q_REQUIRED_RESULT; QList GetItemDetails() const Q_REQUIRED_RESULT; - QVector GetDetails() const; - void SetDetails(const QList& details); + QVector GetDetails() const; + void SetDetails(const QList& details); QRectF DetailsBoundingRect() const; private: QSharedDataPointer d; - bool AddToSheet(const VLayoutDetail &detail, volatile bool &stop); + bool AddToSheet(const VLayoutPiece &detail, volatile bool &stop); - bool SaveResult(const VBestSquare &bestResult, const VLayoutDetail &detail); + bool SaveResult(const VBestSquare &bestResult, const VLayoutPiece &detail); }; diff --git a/src/libs/vlayout/vlayoutpaper_p.h b/src/libs/vlayout/vlayoutpaper_p.h index 34ec699bf..81acb7a45 100644 --- a/src/libs/vlayout/vlayoutpaper_p.h +++ b/src/libs/vlayout/vlayoutpaper_p.h @@ -33,7 +33,7 @@ #include #include -#include "vlayoutdetail.h" +#include "vlayoutpiece.h" #include "vcontour.h" QT_WARNING_PUSH @@ -43,7 +43,7 @@ class VLayoutPaperData : public QSharedData { public: VLayoutPaperData() - : details(QVector()), + : details(QVector()), globalContour(VContour()), paperIndex(0), frame(0), @@ -57,7 +57,7 @@ public: VLayoutPaperData(int height, int width) - : details(QVector()), + : details(QVector()), globalContour(VContour(height, width)), paperIndex(0), frame(0), @@ -86,7 +86,7 @@ public: ~VLayoutPaperData() {} /** @brief details list of arranged details. */ - QVector details; + QVector details; /** @brief globalContour list of global points contour. */ VContour globalContour; diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutpiece.cpp similarity index 89% rename from src/libs/vlayout/vlayoutdetail.cpp rename to src/libs/vlayout/vlayoutpiece.cpp index da6ff54a0..29c1235e2 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -26,7 +26,7 @@ ** *************************************************************************/ -#include "vlayoutdetail.h" +#include "vlayoutpiece.h" #include #include @@ -49,7 +49,7 @@ #include "../vmisc/vabstractapplication.h" #include "../vpatterndb/calculator.h" #include "vlayoutdef.h" -#include "vlayoutdetail_p.h" +#include "vlayoutpiece_p.h" #include "vtextmanager.h" #include "vgraphicsfillitem.h" @@ -58,17 +58,17 @@ class QLineF; class VAbstractPattern; //--------------------------------------------------------------------------------------------------------------------- -VLayoutDetail::VLayoutDetail() - :VAbstractPiece(), d(new VLayoutDetailData) +VLayoutPiece::VLayoutPiece() + :VAbstractPiece(), d(new VLayoutPieceData) {} //--------------------------------------------------------------------------------------------------------------------- -VLayoutDetail::VLayoutDetail(const VLayoutDetail &detail) +VLayoutPiece::VLayoutPiece(const VLayoutPiece &detail) :VAbstractPiece(detail), d(detail.d) {} //--------------------------------------------------------------------------------------------------------------------- -VLayoutDetail &VLayoutDetail::operator=(const VLayoutDetail &detail) +VLayoutPiece &VLayoutPiece::operator=(const VLayoutPiece &detail) { if ( &detail == this ) { @@ -80,13 +80,13 @@ VLayoutDetail &VLayoutDetail::operator=(const VLayoutDetail &detail) } //--------------------------------------------------------------------------------------------------------------------- -VLayoutDetail::~VLayoutDetail() +VLayoutPiece::~VLayoutPiece() {} //--------------------------------------------------------------------------------------------------------------------- -VLayoutDetail VLayoutDetail::Create(const VPiece &piece, const VContainer *pattern) +VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern) { - VLayoutDetail det = VLayoutDetail(); + VLayoutPiece det = VLayoutPiece(); det.SetCountourPoints(piece.MainPathPoints(pattern)); det.SetSeamAllowencePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance()); det.SetName(piece.GetName()); @@ -120,26 +120,26 @@ VLayoutDetail VLayoutDetail::Create(const VPiece &piece, const VContainer *patte //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction -QVector VLayoutDetail::GetContourPoints() const +QVector VLayoutPiece::GetContourPoints() const { return Map(d->contour); } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetCountourPoints(const QVector &points) +void VLayoutPiece::SetCountourPoints(const QVector &points) { d->contour = RemoveDublicates(RoundPoints(points)); } //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction -QVector VLayoutDetail::GetSeamAllowencePoints() const +QVector VLayoutPiece::GetSeamAllowencePoints() const { return Map(d->seamAllowence); } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetSeamAllowencePoints(const QVector &points, bool seamAllowence) +void VLayoutPiece::SetSeamAllowencePoints(const QVector &points, bool seamAllowence) { if (seamAllowence) { @@ -158,13 +158,13 @@ void VLayoutDetail::SetSeamAllowencePoints(const QVector &points, bool } //--------------------------------------------------------------------------------------------------------------------- -QVector VLayoutDetail::GetLayoutAllowencePoints() const +QVector VLayoutPiece::GetLayoutAllowencePoints() const { return Map(d->layoutAllowence); } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetDetail(const QString& qsName, const VPatternPieceData& data, const QFont &font) +void VLayoutPiece::SetDetail(const QString& qsName, const VPatternPieceData& data, const QFont &font) { d->detailData = data; qreal dAng = qDegreesToRadians(data.GetRotation()); @@ -190,7 +190,7 @@ void VLayoutDetail::SetDetail(const QString& qsName, const VPatternPieceData& da } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont &font, +void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont &font, qreal dSize, qreal dHeight) { d->patternGeom = geom; @@ -219,7 +219,7 @@ void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternI } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetGrainline(const VGrainlineGeometry& geom, const VContainer& rPattern) +void VLayoutPiece::SetGrainline(const VGrainlineGeometry& geom, const VContainer& rPattern) { d->grainlineGeom = geom; qreal dAng; @@ -286,31 +286,31 @@ void VLayoutDetail::SetGrainline(const VGrainlineGeometry& geom, const VContaine } //--------------------------------------------------------------------------------------------------------------------- -QTransform VLayoutDetail::GetMatrix() const +QTransform VLayoutPiece::GetMatrix() const { return d->matrix; } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetMatrix(const QTransform &matrix) +void VLayoutPiece::SetMatrix(const QTransform &matrix) { d->matrix = matrix; } //--------------------------------------------------------------------------------------------------------------------- -qreal VLayoutDetail::GetLayoutWidth() const +qreal VLayoutPiece::GetLayoutWidth() const { return d->layoutWidth; } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetLayoutWidth(const qreal &value) +void VLayoutPiece::SetLayoutWidth(const qreal &value) { d->layoutWidth = value; } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::Translate(qreal dx, qreal dy) +void VLayoutPiece::Translate(qreal dx, qreal dy) { QTransform m; m.translate(dx, dy); @@ -318,7 +318,7 @@ void VLayoutDetail::Translate(qreal dx, qreal dy) } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::Rotate(const QPointF &originPoint, qreal degrees) +void VLayoutPiece::Rotate(const QPointF &originPoint, qreal degrees) { QTransform m; m.translate(originPoint.x(), originPoint.y()); @@ -328,7 +328,7 @@ void VLayoutDetail::Rotate(const QPointF &originPoint, qreal degrees) } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::Mirror(const QLineF &edge) +void VLayoutPiece::Mirror(const QLineF &edge) { if (edge.isNull()) { @@ -361,43 +361,43 @@ void VLayoutDetail::Mirror(const QLineF &edge) } //--------------------------------------------------------------------------------------------------------------------- -int VLayoutDetail::DetailEdgesCount() const +int VLayoutPiece::DetailEdgesCount() const { return DetailPath().count(); } //--------------------------------------------------------------------------------------------------------------------- -int VLayoutDetail::LayoutEdgesCount() const +int VLayoutPiece::LayoutEdgesCount() const { return d->layoutAllowence.count(); } //--------------------------------------------------------------------------------------------------------------------- -QLineF VLayoutDetail::DetailEdge(int i) const +QLineF VLayoutPiece::DetailEdge(int i) const { return Edge(DetailPath(), i); } //--------------------------------------------------------------------------------------------------------------------- -QLineF VLayoutDetail::LayoutEdge(int i) const +QLineF VLayoutPiece::LayoutEdge(int i) const { return Edge(d->layoutAllowence, i); } //--------------------------------------------------------------------------------------------------------------------- -int VLayoutDetail::DetailEdgeByPoint(const QPointF &p1) const +int VLayoutPiece::DetailEdgeByPoint(const QPointF &p1) const { return EdgeByPoint(DetailPath(), p1); } //--------------------------------------------------------------------------------------------------------------------- -int VLayoutDetail::LayoutEdgeByPoint(const QPointF &p1) const +int VLayoutPiece::LayoutEdgeByPoint(const QPointF &p1) const { return EdgeByPoint(d->layoutAllowence, p1); } //--------------------------------------------------------------------------------------------------------------------- -QRectF VLayoutDetail::DetailBoundingRect() const +QRectF VLayoutPiece::DetailBoundingRect() const { QVector points; if (IsSeamAllowance()) @@ -414,7 +414,7 @@ QRectF VLayoutDetail::DetailBoundingRect() const } //--------------------------------------------------------------------------------------------------------------------- -QRectF VLayoutDetail::LayoutBoundingRect() const +QRectF VLayoutPiece::LayoutBoundingRect() const { QVector points = GetLayoutAllowencePoints(); points.append(points.first()); @@ -422,14 +422,14 @@ QRectF VLayoutDetail::LayoutBoundingRect() const } //--------------------------------------------------------------------------------------------------------------------- -qreal VLayoutDetail::Diagonal() const +qreal VLayoutPiece::Diagonal() const { const QRectF rec = LayoutBoundingRect(); return qSqrt(pow(rec.height(), 2) + pow(rec.width(), 2)); } //--------------------------------------------------------------------------------------------------------------------- -bool VLayoutDetail::isNull() const +bool VLayoutPiece::isNull() const { if (d->contour.isEmpty() == false && d->layoutWidth > 0) { @@ -449,7 +449,7 @@ bool VLayoutDetail::isNull() const } //--------------------------------------------------------------------------------------------------------------------- -qint64 VLayoutDetail::Square() const +qint64 VLayoutPiece::Square() const { if (d->layoutAllowence.isEmpty()) //-V807 { @@ -463,7 +463,7 @@ qint64 VLayoutDetail::Square() const } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetLayoutAllowencePoints() +void VLayoutPiece::SetLayoutAllowencePoints() { if (d->layoutWidth > 0) { @@ -499,7 +499,7 @@ void VLayoutDetail::SetLayoutAllowencePoints() } //--------------------------------------------------------------------------------------------------------------------- -QVector VLayoutDetail::Map(const QVector &points) const +QVector VLayoutPiece::Map(const QVector &points) const { QVector p; for (int i = 0; i < points.size(); ++i) @@ -520,7 +520,7 @@ QVector VLayoutDetail::Map(const QVector &points) const } //--------------------------------------------------------------------------------------------------------------------- -QVector VLayoutDetail::RoundPoints(const QVector &points) +QVector VLayoutPiece::RoundPoints(const QVector &points) { QVector p; for (int i=0; i < points.size(); ++i) @@ -531,7 +531,7 @@ QVector VLayoutDetail::RoundPoints(const QVector &points) } //--------------------------------------------------------------------------------------------------------------------- -QPainterPath VLayoutDetail::ContourPath() const +QPainterPath VLayoutPiece::ContourPath() const { QPainterPath path; @@ -569,13 +569,13 @@ QPainterPath VLayoutDetail::ContourPath() const } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::ClearTextItems() +void VLayoutPiece::ClearTextItems() { d->m_liPP.clear(); } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::CreateTextItems() +void VLayoutPiece::CreateTextItems() { ClearTextItems(); // first add detail texts @@ -696,7 +696,7 @@ void VLayoutDetail::CreateTextItems() } //--------------------------------------------------------------------------------------------------------------------- -int VLayoutDetail::GetTextItemsCount() const +int VLayoutPiece::GetTextItemsCount() const { return d->m_liPP.count(); } @@ -707,7 +707,7 @@ int VLayoutDetail::GetTextItemsCount() const * @param i index of the requested item * @return pointer to the newly created item. The caller is responsible to delete it. */ -QGraphicsItem* VLayoutDetail::GetTextItem(int i) const +QGraphicsItem* VLayoutPiece::GetTextItem(int i) const { QGraphicsPathItem* item = new QGraphicsPathItem(); QTransform transform = d->matrix; @@ -751,7 +751,7 @@ QGraphicsItem* VLayoutDetail::GetTextItem(int i) const } //--------------------------------------------------------------------------------------------------------------------- -QPainterPath VLayoutDetail::LayoutAllowencePath() const +QPainterPath VLayoutPiece::LayoutAllowencePath() const { QPainterPath path; path.setFillRule(Qt::WindingFill); @@ -768,7 +768,7 @@ QPainterPath VLayoutDetail::LayoutAllowencePath() const } //--------------------------------------------------------------------------------------------------------------------- -QGraphicsItem *VLayoutDetail::GetItem() const +QGraphicsItem *VLayoutPiece::GetItem() const { QGraphicsPathItem *item = new QGraphicsPathItem(); item->setPath(ContourPath()); @@ -776,7 +776,7 @@ QGraphicsItem *VLayoutDetail::GetItem() const } //--------------------------------------------------------------------------------------------------------------------- -QGraphicsItem* VLayoutDetail::GetGrainlineItem() const +QGraphicsItem* VLayoutPiece::GetGrainlineItem() const { if (d->grainlinePoints.count() < 2) { @@ -795,7 +795,7 @@ QGraphicsItem* VLayoutDetail::GetGrainlineItem() const } //--------------------------------------------------------------------------------------------------------------------- -QVector VLayoutDetail::DetailPath() const +QVector VLayoutPiece::DetailPath() const { if (IsSeamAllowance()) { @@ -808,7 +808,7 @@ QVector VLayoutDetail::DetailPath() const } //--------------------------------------------------------------------------------------------------------------------- -QVector VLayoutDetail::PrepareAllowance(const QVector &points) +QVector VLayoutPiece::PrepareAllowance(const QVector &points) { QVector allowancePoints; for(int i = 0; i < points.size(); +i) @@ -819,13 +819,13 @@ QVector VLayoutDetail::PrepareAllowance(const QVector &points } //--------------------------------------------------------------------------------------------------------------------- -bool VLayoutDetail::IsMirror() const +bool VLayoutPiece::IsMirror() const { return d->mirror; } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetMirror(bool value) +void VLayoutPiece::SetMirror(bool value) { d->mirror = value; } @@ -838,7 +838,7 @@ void VLayoutDetail::SetMirror(bool value) * @param dAng angle of rotation * @return position of point pt after rotating it around the center for dAng radians */ -QPointF VLayoutDetail::RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng) +QPointF VLayoutPiece::RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng) { QPointF ptDest; QPointF ptRel = pt - ptCenter; @@ -855,7 +855,7 @@ QPointF VLayoutDetail::RotatePoint(const QPointF &ptCenter, const QPointF& pt, q * @param points list of 4 label vertices * @return list of flipped points */ -QVector VLayoutDetail::Mirror(const QVector &points) const +QVector VLayoutPiece::Mirror(const QVector &points) const { // should only call this method with rectangular shapes Q_ASSERT(points.count() == 4); @@ -880,7 +880,7 @@ QVector VLayoutDetail::Mirror(const QVector &points) const * @param pt2 second point * @return Euclidian distance between the two points */ -qreal VLayoutDetail::GetDistance(const QPointF &pt1, const QPointF &pt2) +qreal VLayoutPiece::GetDistance(const QPointF &pt1, const QPointF &pt2) { const qreal dX = pt1.x() - pt2.x(); const qreal dY = pt1.y() - pt2.y(); @@ -889,7 +889,7 @@ qreal VLayoutDetail::GetDistance(const QPointF &pt1, const QPointF &pt2) } //--------------------------------------------------------------------------------------------------------------------- -QLineF VLayoutDetail::Edge(const QVector &path, int i) const +QLineF VLayoutPiece::Edge(const QVector &path, int i) const { if (i < 1 || i > path.count()) { // Doesn't exist such edge @@ -923,7 +923,7 @@ QLineF VLayoutDetail::Edge(const QVector &path, int i) const } //--------------------------------------------------------------------------------------------------------------------- -int VLayoutDetail::EdgeByPoint(const QVector &path, const QPointF &p1) const +int VLayoutPiece::EdgeByPoint(const QVector &path, const QPointF &p1) const { if (p1.isNull()) { diff --git a/src/libs/vlayout/vlayoutdetail.h b/src/libs/vlayout/vlayoutpiece.h similarity index 91% rename from src/libs/vlayout/vlayoutdetail.h rename to src/libs/vlayout/vlayoutpiece.h index 138f65184..63a46a9db 100644 --- a/src/libs/vlayout/vlayoutdetail.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -55,20 +55,20 @@ class QPointF; class QRectF; class QTransform; class VAbstractPattern; -class VLayoutDetailData; +class VLayoutPieceData; class VPatternInfoGeometry; class VPatternPieceData; class VGrainlineGeometry; -class VLayoutDetail :public VAbstractPiece +class VLayoutPiece :public VAbstractPiece { public: - VLayoutDetail(); - VLayoutDetail(const VLayoutDetail &detail); - VLayoutDetail &operator=(const VLayoutDetail &detail); - virtual ~VLayoutDetail() Q_DECL_OVERRIDE; + VLayoutPiece(); + VLayoutPiece(const VLayoutPiece &detail); + VLayoutPiece &operator=(const VLayoutPiece &detail); + virtual ~VLayoutPiece() Q_DECL_OVERRIDE; - static VLayoutDetail Create(const VPiece &piece, const VContainer *pattern); + static VLayoutPiece Create(const VPiece &piece, const VContainer *pattern); QVector GetContourPoints() const; void SetCountourPoints(const QVector &points); @@ -124,7 +124,7 @@ public: QGraphicsItem* GetGrainlineItem() const Q_REQUIRED_RESULT; private: - QSharedDataPointer d; + QSharedDataPointer d; QVector DetailPath() const; @@ -140,6 +140,6 @@ private: int EdgeByPoint(const QVector &path, const QPointF &p1) const; }; -Q_DECLARE_TYPEINFO(VLayoutDetail, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VLayoutPiece, Q_MOVABLE_TYPE); #endif // VLAYOUTDETAIL_H diff --git a/src/libs/vlayout/vlayoutdetail_p.h b/src/libs/vlayout/vlayoutpiece_p.h similarity index 94% rename from src/libs/vlayout/vlayoutdetail_p.h rename to src/libs/vlayout/vlayoutpiece_p.h index 289af3275..76a5b1cff 100644 --- a/src/libs/vlayout/vlayoutdetail_p.h +++ b/src/libs/vlayout/vlayoutpiece_p.h @@ -43,17 +43,17 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") -class VLayoutDetailData : public QSharedData +class VLayoutPieceData : public QSharedData { public: - VLayoutDetailData() + VLayoutPieceData() :contour(QVector()), seamAllowence(QVector()), layoutAllowence(QVector()), matrix(QMatrix()), layoutWidth(0), mirror(false), detailLabel(QVector()), patternInfo(QVector()), grainlinePoints(QVector()), detailData(), patternGeom(), grainlineGeom(), m_tmDetail(), m_tmPattern(), m_liPP(QList()) {} - VLayoutDetailData(const VLayoutDetailData &detail) + VLayoutPieceData(const VLayoutPieceData &detail) :QSharedData(detail), contour(detail.contour), seamAllowence(detail.seamAllowence), layoutAllowence(detail.layoutAllowence), matrix(detail.matrix), layoutWidth(detail.layoutWidth), mirror(detail.mirror), detailLabel(detail.detailLabel), @@ -62,7 +62,7 @@ public: m_tmPattern(detail.m_tmPattern), m_liPP(detail.m_liPP) {} - ~VLayoutDetailData() {} + ~VLayoutPieceData() {} /** @brief contour list of contour points. */ QVector contour; @@ -101,7 +101,7 @@ public: QList m_liPP; private: - VLayoutDetailData &operator=(const VLayoutDetailData &) Q_DECL_EQ_DELETE; + VLayoutPieceData &operator=(const VLayoutPieceData &) Q_DECL_EQ_DELETE; }; QT_WARNING_POP diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index 6524dddb6..cbe25ef01 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -50,10 +50,10 @@ #include "../vmisc/vmath.h" //--------------------------------------------------------------------------------------------------------------------- -VPosition::VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, volatile bool *stop, +VPosition::VPosition(const VContour &gContour, int j, const VLayoutPiece &detail, int i, volatile bool *stop, bool rotate, int rotationIncrease, bool saveLength) :QRunnable(), bestResult(VBestSquare(gContour.GetSize(), saveLength)), gContour(gContour), detail(detail), i(i), - j(j), paperIndex(0), frame(0), detailsCount(0), details(QVector()), stop(stop), rotate(rotate), + j(j), paperIndex(0), frame(0), detailsCount(0), details(QVector()), stop(stop), rotate(rotate), rotationIncrease(rotationIncrease), angle_between(0) { if ((rotationIncrease >= 1 && rotationIncrease <= 180 && 360 % rotationIncrease == 0) == false) @@ -71,7 +71,7 @@ void VPosition::run() } // We should use copy of the detail. - VLayoutDetail workDetail = detail; + VLayoutPiece workDetail = detail; int dEdge = i;// For mirror detail edge will be different if (CheckCombineEdges(workDetail, j, dEdge)) @@ -139,7 +139,7 @@ void VPosition::setDetailsCount(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -void VPosition::setDetails(const QVector &details) +void VPosition::setDetails(const QVector &details) { this->details = details; } @@ -151,8 +151,8 @@ VBestSquare VPosition::getBestResult() const } //--------------------------------------------------------------------------------------------------------------------- -void VPosition::DrawDebug(const VContour &contour, const VLayoutDetail &detail, int frame, quint32 paperIndex, - int detailsCount, const QVector &details) +void VPosition::DrawDebug(const VContour &contour, const VLayoutPiece &detail, int frame, quint32 paperIndex, + int detailsCount, const QVector &details) { const int biasWidth = Bias(contour.GetWidth(), QIMAGE_MAX); const int biasHeight = Bias(contour.GetHeight(), QIMAGE_MAX); @@ -242,7 +242,7 @@ int VPosition::Bias(int length, int maxLength) } //--------------------------------------------------------------------------------------------------------------------- -void VPosition::SaveCandidate(VBestSquare &bestResult, const VLayoutDetail &detail, int globalI, int detJ, +void VPosition::SaveCandidate(VBestSquare &bestResult, const VLayoutPiece &detail, int globalI, int detJ, BestFrom type) { QVector newGContour = gContour.UniteWithContour(detail, globalI, detJ, type); @@ -252,7 +252,7 @@ void VPosition::SaveCandidate(VBestSquare &bestResult, const VLayoutDetail &deta } //--------------------------------------------------------------------------------------------------------------------- -bool VPosition::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge) +bool VPosition::CheckCombineEdges(VLayoutPiece &detail, int j, int &dEdge) { const QLineF globalEdge = gContour.GlobalEdge(j); bool flagMirror = false; @@ -340,7 +340,7 @@ bool VPosition::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge) } //--------------------------------------------------------------------------------------------------------------------- -bool VPosition::CheckRotationEdges(VLayoutDetail &detail, int j, int dEdge, int angle) const +bool VPosition::CheckRotationEdges(VLayoutPiece &detail, int j, int dEdge, int angle) const { const QLineF globalEdge = gContour.GlobalEdge(j); bool flagSquare = false; @@ -376,7 +376,7 @@ bool VPosition::CheckRotationEdges(VLayoutDetail &detail, int j, int dEdge, int } //--------------------------------------------------------------------------------------------------------------------- -VPosition::CrossingType VPosition::Crossing(const VLayoutDetail &detail) const +VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const { const QRectF gRect = gContour.BoundingRect(); if (not gRect.intersects(detail.LayoutBoundingRect()) && not gRect.contains(detail.DetailBoundingRect())) @@ -404,7 +404,7 @@ bool VPosition::SheetContains(const QRectF &rect) const } //--------------------------------------------------------------------------------------------------------------------- -void VPosition::CombineEdges(VLayoutDetail &detail, const QLineF &globalEdge, const int &dEdge) +void VPosition::CombineEdges(VLayoutPiece &detail, const QLineF &globalEdge, const int &dEdge) { QLineF detailEdge; if (gContour.GetContour().isEmpty()) @@ -433,7 +433,7 @@ void VPosition::CombineEdges(VLayoutDetail &detail, const QLineF &globalEdge, co } //--------------------------------------------------------------------------------------------------------------------- -void VPosition::RotateEdges(VLayoutDetail &detail, const QLineF &globalEdge, int dEdge, int angle) const +void VPosition::RotateEdges(VLayoutPiece &detail, const QLineF &globalEdge, int dEdge, int angle) const { QLineF detailEdge; if (gContour.GetContour().isEmpty()) @@ -472,7 +472,7 @@ void VPosition::Rotate(int increase) } // We should use copy of the detail. - VLayoutDetail workDetail = detail; + VLayoutPiece workDetail = detail; if (CheckRotationEdges(workDetail, j, i, angle)) { @@ -549,7 +549,7 @@ QPainterPath VPosition::DrawContour(const QVector &points) } //--------------------------------------------------------------------------------------------------------------------- -QPainterPath VPosition::DrawDetails(const QVector &details) +QPainterPath VPosition::DrawDetails(const QVector &details) { QPainterPath path; path.setFillRule(Qt::WindingFill); diff --git a/src/libs/vlayout/vposition.h b/src/libs/vlayout/vposition.h index 692d05d42..c607d4777 100644 --- a/src/libs/vlayout/vposition.h +++ b/src/libs/vlayout/vposition.h @@ -37,7 +37,7 @@ #include "vbestsquare.h" #include "vcontour.h" #include "vlayoutdef.h" -#include "vlayoutdetail.h" +#include "vlayoutpiece.h" class QLineF; class QPainterPath; @@ -48,7 +48,7 @@ class QRectF; class VPosition : public QRunnable { public: - VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, volatile bool *stop, bool rotate, + VPosition(const VContour &gContour, int j, const VLayoutPiece &detail, int i, volatile bool *stop, bool rotate, int rotationIncrease, bool saveLength); virtual ~VPosition() Q_DECL_OVERRIDE{} @@ -61,12 +61,12 @@ public: quint32 getDetailsCount() const; void setDetailsCount(const quint32 &value); - void setDetails(const QVector &details); + void setDetails(const QVector &details); VBestSquare getBestResult() const; - static void DrawDebug(const VContour &contour, const VLayoutDetail &detail, int frame, quint32 paperIndex, - int detailsCount, const QVector &details = QVector()); + static void DrawDebug(const VContour &contour, const VLayoutPiece &detail, int frame, quint32 paperIndex, + int detailsCount, const QVector &details = QVector()); static int Bias(int length, int maxLength); @@ -74,13 +74,13 @@ private: Q_DISABLE_COPY(VPosition) VBestSquare bestResult; const VContour gContour; - const VLayoutDetail detail; + const VLayoutPiece detail; int i; int j; quint32 paperIndex; quint32 frame; quint32 detailsCount; - QVector details; + QVector details; volatile bool *stop; bool rotate; int rotationIncrease; @@ -105,20 +105,20 @@ private: virtual void run() Q_DECL_OVERRIDE; - void SaveCandidate(VBestSquare &bestResult, const VLayoutDetail &detail, int globalI, int detJ, BestFrom type); + void SaveCandidate(VBestSquare &bestResult, const VLayoutPiece &detail, int globalI, int detJ, BestFrom type); - bool CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge); - bool CheckRotationEdges(VLayoutDetail &detail, int j, int dEdge, int angle) const; + bool CheckCombineEdges(VLayoutPiece &detail, int j, int &dEdge); + bool CheckRotationEdges(VLayoutPiece &detail, int j, int dEdge, int angle) const; - CrossingType Crossing(const VLayoutDetail &detail) const; + CrossingType Crossing(const VLayoutPiece &detail) const; bool SheetContains(const QRectF &rect) const; - void CombineEdges(VLayoutDetail &detail, const QLineF &globalEdge, const int &dEdge); - void RotateEdges(VLayoutDetail &detail, const QLineF &globalEdge, int dEdge, int angle) const; + void CombineEdges(VLayoutPiece &detail, const QLineF &globalEdge, const int &dEdge); + void RotateEdges(VLayoutPiece &detail, const QLineF &globalEdge, int dEdge, int angle) const; static QPainterPath ShowDirection(const QLineF &edge); static QPainterPath DrawContour(const QVector &points); - static QPainterPath DrawDetails(const QVector &details); + static QPainterPath DrawDetails(const QVector &details); void Rotate(int increase); }; diff --git a/src/test/ValentinaTest/tst_vlayoutdetail.cpp b/src/test/ValentinaTest/tst_vlayoutdetail.cpp index cf29172ef..f440e813a 100644 --- a/src/test/ValentinaTest/tst_vlayoutdetail.cpp +++ b/src/test/ValentinaTest/tst_vlayoutdetail.cpp @@ -27,7 +27,7 @@ *************************************************************************/ #include "tst_vlayoutdetail.h" -#include "../vlayout/vlayoutdetail.h" +#include "../vlayout/vlayoutpiece.h" #include @@ -56,7 +56,7 @@ void TST_VLayoutDetail::Case1() const // See issue #304. Layout appears different than my pattern. // https://bitbucket.org/dismine/valentina/issue/304/layout-appears-different-than-my-pattern - VLayoutDetail det = VLayoutDetail(); + VLayoutPiece det = VLayoutPiece(); det.SetCountourPoints(InputPointsCase1()); // Begin comparison @@ -118,7 +118,7 @@ QVector TST_VLayoutDetail::OutputPointsCase1() const //-V524 //--------------------------------------------------------------------------------------------------------------------- void TST_VLayoutDetail::Case2() const { - VLayoutDetail det = VLayoutDetail(); + VLayoutPiece det = VLayoutPiece(); det.SetCountourPoints(InputPointsCase2()); // Begin comparison @@ -159,7 +159,7 @@ QVector TST_VLayoutDetail::OutputPointsCase2() const //--------------------------------------------------------------------------------------------------------------------- void TST_VLayoutDetail::Case3() const { - VLayoutDetail det = VLayoutDetail(); + VLayoutPiece det = VLayoutPiece(); det.SetCountourPoints(InputPointsCase3()); // Begin comparison