diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index de188950a..ec5234dbf 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -58,6 +58,7 @@ #include "dialogs/vwidgetgroups.h" #include "../vtools/undocommands/addgroup.h" #include "dialogs/vwidgetdetails.h" +#include "../vpatterndb/vpiecepath.h" #include #include @@ -558,9 +559,16 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons ui->view->setShowToolOptions(false); dialogTool = new Dialog(pattern, 0, this); - if (t == Tool::Midpoint) + switch(t) { - dialogTool->Build(t); + case Tool::Midpoint: + dialogTool->Build(t); + break; + case Tool::PiecePath: + dialogTool->SetPiecesList(doc->GetActivePPPieces()); + break; + default: + break; } VMainGraphicsScene *scene = qobject_cast(currentScene); @@ -1121,8 +1129,12 @@ void MainWindow::ClosedDialogPiecePath(int result) DialogPiecePath *dialog = qobject_cast(dialogTool); SCASSERT(dialog != nullptr); + const PiecePathType type = dialog->GetType(); + const VPiecePath path = dialog->GetPiecePath(); + //VToolDetail::Create(dialogTool, sceneDetails, doc, pattern); } ArrowTool(); + doc->LiteParseTree(Document::LiteParse); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index a7ddee41c..65e808953 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -350,6 +350,31 @@ quint32 VPattern::SPointActiveDraw() return 0; } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPattern::GetActivePPPieces() const +{ + QVector pieces; + QDomElement drawElement; + if (GetActivDrawElement(drawElement)) + { + const QDomElement details = drawElement.firstChildElement(TagDetails); + if (not details.isNull()) + { + QDomElement detail = details.firstChildElement(TagDetail); + while(not detail.isNull()) + { + bool united = GetParametrBool(detail, VToolSeamAllowance::AttrUnited, falseStr); + if (not united) + { + pieces.append(GetParametrId(detail)); + } + detail = detail.nextSiblingElement(TagDetail); + } + } + } + return pieces; +} + //--------------------------------------------------------------------------------------------------------------------- bool VPattern::SaveDocument(const QString &fileName, QString &error) const { diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index 08ba4bfda..0992f1a68 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -59,6 +59,8 @@ public: quint32 SPointActiveDraw(); + QVector GetActivePPPieces() const; + virtual void setXMLContent(const QString &fileName) Q_DECL_OVERRIDE; virtual bool SaveDocument(const QString &fileName, QString &error) const Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp index b95a50b96..bdb3a1426 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp @@ -282,6 +282,52 @@ void DialogPiecePath::SetType(PiecePathType type) } } +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPiecePath::GetPieceId() const +{ + quint32 id = NULL_ID; + + if (ui->comboBoxPiece->count() > 0) + { +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) + id = ui->comboBoxPiece->itemData(ui->comboBoxPiece->currentIndex()).toUInt(); +#else + id = ui->comboBoxPiece->currentData().toUInt(); +#endif + } + + return id; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::SetPieceId(quint32 id) +{ + if (ui->comboBoxPiece->count() <= 0) + { + const VPiece piece = data->GetPiece(id); + ui->comboBoxPiece->addItem(piece.GetName(), id); + } + else + { + const qint32 index = ui->comboBoxPiece->findData(id); + if (index != -1) + { + ui->comboBoxType->setCurrentIndex(index); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::SetPiecesList(const QVector &list) +{ + for (int i=0; i < list.size(); ++i) + { + const VPiece piece = data->GetPiece(list.at(i)); + ui->comboBoxPiece->addItem(piece.GetName(), list.at(i)); + } + ValidObjects(PathIsValid()); +} + //--------------------------------------------------------------------------------------------------------------------- VPiecePath DialogPiecePath::CreatePath() const { diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.h b/src/libs/vtools/dialogs/tools/dialogpiecepath.h index fcd347b5a..443e0d60f 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.h +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.h @@ -51,6 +51,11 @@ public: PiecePathType GetType() const; void SetType(PiecePathType type); + quint32 GetPieceId() const; + void SetPieceId(quint32 id); + + virtual void SetPiecesList(const QVector &list) Q_DECL_OVERRIDE; + public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; virtual void ShowDialog(bool click) Q_DECL_OVERRIDE; @@ -71,6 +76,7 @@ private: bool m_showMode; void InitPathTypes(); + void InitListPieces(); VPiecePath CreatePath() const; diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 11f9d808f..a26626ce4 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -1073,6 +1073,12 @@ void DialogTool::Build(const Tool &type) Q_UNUSED(type); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::SetPiecesList(const QVector &list) +{ + Q_UNUSED(list); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogTool::SetAssociatedTool(VAbstractTool *tool) { diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index 313f45c34..46ed7d9fa 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -95,6 +95,7 @@ public: virtual void ShowDialog(bool click); virtual void Build(const Tool &type); + virtual void SetPiecesList(const QVector &list); quint32 GetToolId() const; void SetToolId(const quint32 &value);