diff --git a/src/app/share/collection/MaleShirt/MaleShirt.val b/src/app/share/collection/MaleShirt/MaleShirt.val index cec3bc8f0..8fbb0a6f9 100644 --- a/src/app/share/collection/MaleShirt/MaleShirt.val +++ b/src/app/share/collection/MaleShirt/MaleShirt.val @@ -1,7 +1,7 @@ - 0.3.1 + 0.4.0 cm Timo Virtaneva This a male shirt pattern. @@ -14,7 +14,7 @@ The design is based on the measuring table. The table must be loaded, but the va Adjust/verify curves after parameter modifications. Delete layouts which are not needed. - + MaleShirt.vit @@ -197,49 +197,55 @@ Delete layouts which are not needed.
- - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + +
@@ -310,36 +316,44 @@ Delete layouts which are not needed.
- - - - - - - - + + + + + + + + + + - - - - - - - + + + + + + + + + - - - - - - + + + + + + + + - - - - - - + + + + + + + +
@@ -447,45 +461,53 @@ Delete layouts which are not needed.
- - - - - + + + + + + + - - - - - + + + + + + + - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +
@@ -543,37 +565,45 @@ Delete layouts which are not needed.
- - - - - - - + + + + + + + + + - - - - - - - + + + + + + + + + - - - - - - - + + + + + + + + + - - - - - - - + + + + + + + + +
@@ -609,20 +639,24 @@ Delete layouts which are not needed.
- - - - - + + + + + + + - - - - - - - - + + + + + + + + + +
diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index b785a9aa7..c4ec79478 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -747,7 +747,8 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document << TagData << TagPatternInfo << TagGrainline - << VToolSeamAllowance::TagCSA; + << VToolSeamAllowance::TagCSA + << VToolSeamAllowance::TagIPaths; const QDomNodeList nodeList = domElement.childNodes(); for (qint32 i = 0; i < nodeList.size(); ++i) @@ -780,6 +781,8 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document case 4:// VToolSeamAllowance::TagCSA ParseDetailCSARecords(element, detail); break; + case 5:// VToolSeamAllowance::TagIPaths + ParseDetailInternalPaths(element, detail); default: break; } @@ -875,7 +878,8 @@ void VPattern::ParseDetailNodes(const QDomElement &domElement, VPiece &detail, b for (qint32 i = 0; i < nodeList.size(); ++i) { const QDomElement element = nodeList.at(i).toElement(); - if (not element.isNull() && element.tagName() == VAbstractPattern::TagNode) + if (not element.isNull() + && element.tagName() == VAbstractPattern::TagNode) // Old detail version need this check! { oldNodes.append(ParseDetailNode(element)); } @@ -891,7 +895,7 @@ void VPattern::ParsePieceNodes(const QDomElement &domElement, VPiece &detail) co for (qint32 i = 0; i < nodeList.size(); ++i) { const QDomElement element = nodeList.at(i).toElement(); - if (not element.isNull() && element.tagName() == VAbstractPattern::TagNode) + if (not element.isNull()) { detail.GetPath().Append(ParseSANode(element)); } @@ -906,7 +910,7 @@ void VPattern::ParseDetailCSARecords(const QDomElement &domElement, VPiece &deta for (qint32 i = 0; i < nodeList.size(); ++i) { const QDomElement element = nodeList.at(i).toElement(); - if (not element.isNull() && element.tagName() == VToolSeamAllowance::TagRecord) + if (not element.isNull()) { CustomSARecord record; record.startPoint = GetParametrUInt(element, VToolSeamAllowance::AttrStart, NULL_ID_STR); @@ -922,6 +926,26 @@ void VPattern::ParseDetailCSARecords(const QDomElement &domElement, VPiece &deta detail.SetCustomSARecords(records); } +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::ParseDetailInternalPaths(const QDomElement &domElement, VPiece &detail) const +{ + QVector records; + const QDomNodeList nodeList = domElement.childNodes(); + for (qint32 i = 0; i < nodeList.size(); ++i) + { + const QDomElement element = nodeList.at(i).toElement(); + if (not element.isNull()) + { + const quint32 path = GetParametrUInt(element, VToolSeamAllowance::AttrPath, NULL_ID_STR); + if (path > NULL_ID) + { + records.append(path); + } + } + } + detail.SetInternalPaths(records); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ParseDetails parse details tag. @@ -3131,6 +3155,7 @@ void VPattern::ParsePathElement(VMainGraphicsScene *scene, QDomElement &domEleme const QString defType = QString().setNum(static_cast(PiecePathType::CustomSeamAllowance)); const PiecePathType type = static_cast(GetParametrUInt(domElement, AttrType, defType)); const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); + const QString penType = GetParametrString(domElement, AttrTypeLine, TypeLineLine); VPiecePath path; const QDomElement element = domElement.firstChildElement(VAbstractPattern::TagNodes); @@ -3141,6 +3166,7 @@ void VPattern::ParsePathElement(VMainGraphicsScene *scene, QDomElement &domEleme path.SetType(type); path.SetName(name); + path.SetPenType(VAbstractTool::LineStyleToPenStyle(penType)); VToolPiecePath::Create(id, path, 0, scene, this, data, parse, Source::FromFile, "", idTool); } diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index 73caf79d5..25d0f6ec6 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -123,6 +123,7 @@ private: void ParseDetailNodes(const QDomElement &domElement, VPiece &detail, bool closed) const; void ParsePieceNodes(const QDomElement &domElement, VPiece &detail) const; void ParseDetailCSARecords(const QDomElement &domElement, VPiece &detail) const; + void ParseDetailInternalPaths(const QDomElement &domElement, VPiece &detail) const; void ParseDetails(const QDomElement &domElement, const Document &parse); void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement, diff --git a/src/libs/ifc/schema/pattern/v0.4.0.xsd b/src/libs/ifc/schema/pattern/v0.4.0.xsd index 4a76b947a..af5e2e278 100644 --- a/src/libs/ifc/schema/pattern/v0.4.0.xsd +++ b/src/libs/ifc/schema/pattern/v0.4.0.xsd @@ -329,6 +329,7 @@ + @@ -451,6 +452,17 @@ + + + + + + + + + + + diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 2d32a4be8..469e31daa 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -269,6 +269,18 @@ void VPiece::SetUnited(bool united) d->m_united = united; } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::GetInternalPaths() const +{ + return d->m_internalPaths; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPiece::SetInternalPaths(const QVector &iPaths) +{ + d->m_internalPaths = iPaths; +} + //--------------------------------------------------------------------------------------------------------------------- QVector VPiece::GetCustomSARecords() const { @@ -324,6 +336,37 @@ QVector VPiece::MissingCSAPath(const VPiece &det) const return r; } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::MissingInternalPaths(const VPiece &det) const +{ + const QVector detRecords = det.GetInternalPaths(); + if (d->m_internalPaths.size() == detRecords.size()) //-V807 + { + return QVector(); + } + + QSet set1; + for (qint32 i = 0; i < d->m_internalPaths.size(); ++i) + { + set1.insert(d->m_internalPaths.at(i)); + } + + QSet set2; + for (qint32 j = 0; j < detRecords.size(); ++j) + { + set2.insert(detRecords.at(j)); + } + + const QList set3 = set1.subtract(set2).toList(); + QVector r; + for (qint32 i = 0; i < set3.size(); ++i) + { + r.append(set3.at(i)); + } + + return r; +} + //--------------------------------------------------------------------------------------------------------------------- QVector VPiece::GetValidRecords() const { diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 6e4a842eb..6a65dee2e 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -76,11 +76,15 @@ public: bool IsUnited() const; void SetUnited(bool united); + QVector GetInternalPaths() const; + void SetInternalPaths(const QVector &iPaths); + QVector GetCustomSARecords() const; void SetCustomSARecords(const QVector &records); QVector MissingNodes(const VPiece &det) const; QVector MissingCSAPath(const VPiece &det) const; + QVector MissingInternalPaths(const VPiece &det) const; private: QSharedDataPointer d; diff --git a/src/libs/vpatterndb/vpiece_p.h b/src/libs/vpatterndb/vpiece_p.h index 2b9a8c961..fcfc7e01b 100644 --- a/src/libs/vpatterndb/vpiece_p.h +++ b/src/libs/vpatterndb/vpiece_p.h @@ -49,7 +49,8 @@ public: m_my(0), m_inLayout(true), m_united(false), - m_customSARecords() + m_customSARecords(), + m_internalPaths() {} VPieceData(const VPieceData &detail) @@ -59,7 +60,8 @@ public: m_my(detail.m_my), m_inLayout(detail.m_inLayout), m_united(detail.m_united), - m_customSARecords(detail.m_customSARecords) + m_customSARecords(detail.m_customSARecords), + m_internalPaths(detail.m_internalPaths) {} ~VPieceData(); @@ -74,6 +76,7 @@ public: bool m_united; QVector m_customSARecords; + QVector m_internalPaths; private: VPieceData &operator=(const VPieceData &) Q_DECL_EQ_DELETE; diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index cbaa5061a..3e9718b76 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -130,6 +130,18 @@ void VPiecePath::SetName(const QString &name) d->m_name = name; } +//--------------------------------------------------------------------------------------------------------------------- +Qt::PenStyle VPiecePath::GetPenType() const +{ + return d->m_penType; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPiecePath::SetPenType(const Qt::PenStyle &type) +{ + d->m_penType = type; +} + //--------------------------------------------------------------------------------------------------------------------- QVector VPiecePath::PathPoints(const VContainer *data) const { diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h index 783166eac..1f3dbf901 100644 --- a/src/libs/vpatterndb/vpiecepath.h +++ b/src/libs/vpatterndb/vpiecepath.h @@ -68,6 +68,9 @@ public: QString GetName() const; void SetName(const QString &name); + Qt::PenStyle GetPenType() const; + void SetPenType(const Qt::PenStyle &type); + QVector PathPoints(const VContainer *data) const; QVector PathNodePoints(const VContainer *data) const; QVector SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const; diff --git a/src/libs/vpatterndb/vpiecepath_p.h b/src/libs/vpatterndb/vpiecepath_p.h index 77bcfdf85..1ad364ce9 100644 --- a/src/libs/vpatterndb/vpiecepath_p.h +++ b/src/libs/vpatterndb/vpiecepath_p.h @@ -44,20 +44,23 @@ public: VPiecePathData() : m_nodes(), m_type(PiecePathType::Unknown), - m_name() + m_name(), + m_penType(Qt::SolidLine) {} explicit VPiecePathData(PiecePathType type) : m_nodes(), m_type(type), - m_name() + m_name(), + m_penType(Qt::SolidLine) {} VPiecePathData(const VPiecePathData &path) : QSharedData(path), m_nodes(path.m_nodes), m_type(path.m_type), - m_name(path.m_name) + m_name(path.m_name), + m_penType(path.m_penType) {} ~VPiecePathData(); @@ -65,6 +68,7 @@ public: QVector m_nodes; PiecePathType m_type; QString m_name; + Qt::PenStyle m_penType; private: VPiecePathData &operator=(const VPiecePathData &) Q_DECL_EQ_DELETE; diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp index 4316fb2cd..ed8d41b2b 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp @@ -30,6 +30,7 @@ #include "ui_dialogpiecepath.h" #include "../vpatterndb/vpiecenode.h" #include "visualization/path/vistoolpiecepath.h" +#include "../../tools/vabstracttool.h" #include @@ -46,11 +47,17 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget ui->lineEditName->setClearButtonEnabled(true); #endif + FillComboBoxTypeLine(ui->comboBoxPenType, VAbstractTool::LineStylesPics()); + connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogPiecePath::NameChanged); InitPathTypes(); connect(ui->comboBoxType, static_cast(&QComboBox::currentIndexChanged), - [this](){ValidObjects(PathIsValid());}); + [this]() + { + ui->comboBoxPenType->setEnabled(GetType() == PiecePathType::InternalPath); + ValidObjects(PathIsValid()); + }); flagName = true;//We have default name of piece. flagError = PathIsValid(); @@ -376,7 +383,9 @@ void DialogPiecePath::ChangedSAAfter(double d) void DialogPiecePath::InitPathTypes() { ui->comboBoxType->addItem(tr("Custom seam allowance"), static_cast(PiecePathType::CustomSeamAllowance)); - //ui->comboBoxType->addItem(tr("Internal path"), static_cast(PiecePathType::InternalPath)); + ui->comboBoxType->addItem(tr("Internal path"), static_cast(PiecePathType::InternalPath)); + + ui->comboBoxPenType->setEnabled(GetType() == PiecePathType::InternalPath); } //--------------------------------------------------------------------------------------------------------------------- @@ -468,6 +477,7 @@ void DialogPiecePath::SetPiecePath(const VPiecePath &path) VisToolPiecePath *visPath = qobject_cast(vis); SCASSERT(visPath != nullptr); visPath->SetPath(path); + SetPenType(path.GetPenType()); ValidObjects(PathIsValid()); @@ -495,6 +505,21 @@ void DialogPiecePath::SetType(PiecePathType type) { ui->comboBoxType->setCurrentIndex(index); } + + ui->comboBoxPenType->setEnabled(type == PiecePathType::InternalPath); +} + +//--------------------------------------------------------------------------------------------------------------------- +Qt::PenStyle DialogPiecePath::GetPenType() const +{ + return VAbstractTool::LineStyleToPenStyle(GetComboBoxCurrentData(ui->comboBoxPenType, TypeLineLine)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::SetPenType(const Qt::PenStyle &type) +{ + ChangeCurrentData(ui->comboBoxPenType, VAbstractTool::PenStyleToLineStyle(type)); + vis->setLineStyle(type); } //--------------------------------------------------------------------------------------------------------------------- @@ -635,6 +660,7 @@ VPiecePath DialogPiecePath::CreatePath() const path.SetType(GetType()); path.SetName(ui->lineEditName->text()); + path.SetPenType(GetType() == PiecePathType::InternalPath ? GetPenType() : Qt::SolidLine); return path; } diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.h b/src/libs/vtools/dialogs/tools/dialogpiecepath.h index 3f30be6a0..75c51429f 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.h +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.h @@ -94,6 +94,9 @@ private: PiecePathType GetType() const; void SetType(PiecePathType type); + Qt::PenStyle GetPenType() const; + void SetPenType(const Qt::PenStyle &type); + QListWidgetItem *GetItemById(quint32 id); void SetCurrentSABefore(qreal value); diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.ui b/src/libs/vtools/dialogs/tools/dialogpiecepath.ui index 0c414e4df..6ee68ac25 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.ui +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.ui @@ -60,16 +60,39 @@ - + Piece: - + + + + + Type of pen: + + + + + + + + 80 + 0 + + + + + 80 + 14 + + + + diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp index 5db25b0e9..f08bcb45b 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp @@ -106,6 +106,10 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & connect(ui->comboBoxIncludeType, static_cast(&QComboBox::currentIndexChanged), this, &DialogSeamAllowance::CSAIncludeTypeChanged); + ui->listWidgetInternalPaths->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->listWidgetInternalPaths, &QListWidget::customContextMenuRequested, this, + &DialogSeamAllowance::ShowInternalPathsContextMenu); + if (not applyAllowed) { vis = new VisToolPiece(data); @@ -127,6 +131,7 @@ void DialogSeamAllowance::EnableApply(bool enable) bApply->setEnabled(enable); applyAllowed = enable; ui->tabSeamAllowance->setEnabled(applyAllowed); + ui->tabInternalPaths->setEnabled(applyAllowed); } //--------------------------------------------------------------------------------------------------------------------- @@ -153,6 +158,13 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) } ui->listWidgetCustomSA->blockSignals(false); + ui->listWidgetInternalPaths->clear(); + const QVector iPaths = piece.GetInternalPaths(); + for (int i = 0; i < iPaths.size(); ++i) + { + NewInternalPath(iPaths.at(i)); + } + ui->comboBoxStartPoint->blockSignals(true); ui->comboBoxStartPoint->clear(); ui->comboBoxStartPoint->blockSignals(false); @@ -347,7 +359,7 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos) { record.reverse = not record.reverse; rowItem->setData(Qt::UserRole, QVariant::fromValue(record)); - rowItem->setText(GetCustomSARecordName(record)); + rowItem->setText(GetPathName(record.path, record.reverse)); } else if (selectedAction == actionOption) { @@ -366,6 +378,42 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos) } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::ShowInternalPathsContextMenu(const QPoint &pos) +{ + const int row = ui->listWidgetInternalPaths->currentRow(); + if (ui->listWidgetInternalPaths->count() == 0 || row == -1 || row >= ui->listWidgetInternalPaths->count()) + { + return; + } + + QMenu *menu = new QMenu(this); + QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); + + QListWidgetItem *rowItem = ui->listWidgetInternalPaths->item(row); + SCASSERT(rowItem != nullptr); + const quint32 pathId = qvariant_cast(rowItem->data(Qt::UserRole)); + + QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options")); + + QAction *selectedAction = menu->exec(ui->listWidgetInternalPaths->viewport()->mapToGlobal(pos)); + if (selectedAction == actionDelete) + { + delete ui->listWidgetInternalPaths->item(row); + } + else if (selectedAction == actionOption) + { + auto *dialog = new DialogPiecePath(data, pathId, this); + dialog->SetPiecePath(data->GetPiecePath(pathId)); + dialog->SetPieceId(toolId); + dialog->EnbleShowMode(true); + m_dialog = dialog; + m_dialog->setModal(true); + connect(m_dialog.data(), &DialogTool::DialogClosed, this, &DialogSeamAllowance::PathDialogClosed); + m_dialog->show(); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::ListChanged() { @@ -662,7 +710,8 @@ void DialogSeamAllowance::PathDialogClosed(int result) const_cast(data), dialogTool->GetToolId()); qApp->getUndoStack()->push(saveCommand); - UpdateCurrentRecord(); + UpdateCurrentCustomSARecord(); + UpdateCurrentInternalPathRecord(); } catch (const VExceptionBadId &e) { @@ -691,6 +740,14 @@ VPiece DialogSeamAllowance::CreatePiece() const } piece.SetCustomSARecords(records); + QVector iPaths; + for (qint32 i = 0; i < ui->listWidgetInternalPaths->count(); ++i) + { + QListWidgetItem *item = ui->listWidgetInternalPaths->item(i); + iPaths.append(qvariant_cast(item->data(Qt::UserRole))); + } + piece.SetInternalPaths(iPaths); + piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked()); piece.SetSeamAllowance(ui->checkBoxSeams->isChecked()); piece.SetSAWidth(ui->doubleSpinBoxSeams->value()); @@ -711,7 +768,7 @@ void DialogSeamAllowance::NewCustomSA(const CustomSARecord &record) { if (record.path > NULL_ID) { - const QString name = GetCustomSARecordName(record); + const QString name = GetPathName(record.path, record.reverse); QListWidgetItem *item = new QListWidgetItem(name); item->setFont(QFont("Times", 12, QFont::Bold)); @@ -722,16 +779,30 @@ void DialogSeamAllowance::NewCustomSA(const CustomSARecord &record) } //--------------------------------------------------------------------------------------------------------------------- -QString DialogSeamAllowance::GetCustomSARecordName(const CustomSARecord &record) const +void DialogSeamAllowance::NewInternalPath(quint32 path) +{ + if (path > NULL_ID) + { + const QString name = GetPathName(path); + + QListWidgetItem *item = new QListWidgetItem(name); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setData(Qt::UserRole, QVariant::fromValue(path)); + ui->listWidgetInternalPaths->addItem(item); + ui->listWidgetInternalPaths->setCurrentRow(ui->listWidgetInternalPaths->count()-1); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogSeamAllowance::GetPathName(quint32 path, bool reverse) const { QString name; - if (record.path > NULL_ID) + if (path > NULL_ID) { - const VPiecePath path = data->GetPiecePath(record.path); - name = path.GetName(); + name = data->GetPiecePath(path).GetName(); - if (record.reverse) + if (reverse) { name = QLatin1String("- ") + name; } @@ -934,7 +1005,7 @@ void DialogSeamAllowance::InitSAIncludeType() } //--------------------------------------------------------------------------------------------------------------------- -void DialogSeamAllowance::UpdateCurrentRecord() +void DialogSeamAllowance::UpdateCurrentCustomSARecord() { const int row = ui->listWidgetCustomSA->currentRow(); if (ui->listWidgetCustomSA->count() == 0 || row == -1) @@ -945,5 +1016,20 @@ void DialogSeamAllowance::UpdateCurrentRecord() QListWidgetItem *item = ui->listWidgetCustomSA->item(row); SCASSERT(item != nullptr); const CustomSARecord record = qvariant_cast(item->data(Qt::UserRole)); - item->setText(GetCustomSARecordName(record)); + item->setText(GetPathName(record.path, record.reverse)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::UpdateCurrentInternalPathRecord() +{ + const int row = ui->listWidgetInternalPaths->currentRow(); + if (ui->listWidgetInternalPaths->count() == 0 || row == -1) + { + return; + } + + QListWidgetItem *item = ui->listWidgetInternalPaths->item(row); + SCASSERT(item != nullptr); + const quint32 path = qvariant_cast(item->data(Qt::UserRole)); + item->setText(GetPathName(path)); } diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/dialogseamallowance.h index 4a6b986fc..c761f8d76 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.h @@ -62,6 +62,8 @@ protected: private slots: void ShowMainPathContextMenu(const QPoint &pos); void ShowCustomSAContextMenu(const QPoint &pos); + void ShowInternalPathsContextMenu(const QPoint &pos); + void ListChanged(); void EnableSeamAllowance(bool enable); void NodeChanged(int index); @@ -90,14 +92,16 @@ private: void NewMainPathItem(const VPieceNode &node); void NewCustomSA(const CustomSARecord &record); - QString GetCustomSARecordName(const CustomSARecord &record) const; + void NewInternalPath(quint32 path); + QString GetPathName(quint32 path, bool reverse = false) const; bool MainPathIsValid() const; void ValidObjects(bool value); bool MainPathIsClockwise() const; void InitNodesList(); void InitCSAPoint(QComboBox *box); void InitSAIncludeType(); - void UpdateCurrentRecord(); + void UpdateCurrentCustomSARecord(); + void UpdateCurrentInternalPathRecord(); QListWidgetItem *GetItemById(quint32 id); diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.ui b/src/libs/vtools/dialogs/tools/dialogseamallowance.ui index 047a79a7b..75ff3623e 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.ui +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.ui @@ -385,6 +385,20 @@ + + + Internal paths + + + + + + QAbstractItemView::InternalMove + + + + + diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp index 48c804129..54fc53749 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp @@ -173,6 +173,7 @@ void VToolPiecePath::AddAttributes(VAbstractPattern *doc, QDomElement &domElemen doc->SetAttribute(domElement, VDomDocument::AttrId, id); doc->SetAttribute(domElement, AttrName, path.GetName()); doc->SetAttribute(domElement, AttrType, static_cast(path.GetType())); + doc->SetAttribute(domElement, AttrTypeLine, PenStyleToLineStyle(path.GetPenType())); } //--------------------------------------------------------------------------------------------------------------------- @@ -219,7 +220,9 @@ void VToolPiecePath::AddToFile() if (path.GetType() == PiecePathType::InternalPath) { - + QVector iPaths = newDet.GetInternalPaths(); + iPaths.append(id); + newDet.SetInternalPaths(iPaths); } else if (path.GetType() == PiecePathType::CustomSeamAllowance) { @@ -287,7 +290,11 @@ void VToolPiecePath::RefreshGeometry() { QPainterPath p = path.PainterPath(this->getData()); p.setFillRule(Qt::OddEvenFill); + this->setPath(p); + QPen pen = this->pen(); + pen.setStyle(path.GetPenType()); + this->setPen(pen); } } diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index 556e0a77d..a1f59c1fa 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -197,6 +197,35 @@ Qt::PenStyle VAbstractTool::LineStyleToPenStyle(const QString &typeLine) } } +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractTool::PenStyleToLineStyle(Qt::PenStyle penStyle) +{ + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Wswitch-default") + + switch (penStyle) + { + case Qt::NoPen: + return TypeLineNone; + case Qt::DashLine: + return TypeLineDashLine; + case Qt::DotLine: + return TypeLineDotLine; + case Qt::DashDotLine: + return TypeLineDashDotLine; + case Qt::DashDotDotLine: + return TypeLineDashDotDotLine; + case Qt::SolidLine: + case Qt::CustomDashLine: + default: + break; + } + + QT_WARNING_POP + + return TypeLineLine; +} + //--------------------------------------------------------------------------------------------------------------------- QMap VAbstractTool::LineStylesPics() { diff --git a/src/libs/vtools/tools/vabstracttool.h b/src/libs/vtools/tools/vabstracttool.h index 3bc0187b7..17ccf8b69 100644 --- a/src/libs/vtools/tools/vabstracttool.h +++ b/src/libs/vtools/tools/vabstracttool.h @@ -75,6 +75,7 @@ public: static const QStringList StylesList(); static Qt::PenStyle LineStyleToPenStyle(const QString &typeLine); + static QString PenStyleToLineStyle(Qt::PenStyle penStyle); static QMap LineStylesPics(); static const QStringList Colors(); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 66f580c41..1dea63415 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -34,6 +34,7 @@ #include "nodeDetails/vnodepoint.h" #include "nodeDetails/vnodespline.h" #include "nodeDetails/vnodesplinepath.h" +#include "nodeDetails/vtoolpiecepath.h" #include "../vgeometry/varc.h" #include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vcubicbezierpath.h" @@ -59,6 +60,7 @@ const quint8 VToolSeamAllowance::pieceVersion = 2; const QString VToolSeamAllowance::TagCSA = QStringLiteral("csa"); const QString VToolSeamAllowance::TagRecord = QStringLiteral("record"); +const QString VToolSeamAllowance::TagIPaths = QStringLiteral("iPaths"); const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version"); const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping"); @@ -263,6 +265,22 @@ void VToolSeamAllowance::AddCSARecords(VAbstractPattern *doc, QDomElement &domEl } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::AddInternalPaths(VAbstractPattern *doc, QDomElement &domElement, const QVector &paths) +{ + if (paths.size() > 0) + { + QDomElement iPathsElement = doc->createElement(VToolSeamAllowance::TagIPaths); + for (int i = 0; i < paths.size(); ++i) + { + QDomElement recordNode = doc->createElement(VToolSeamAllowance::TagRecord); + doc->SetAttribute(recordNode, AttrPath, paths.at(i)); + iPathsElement.appendChild(recordNode); + } + domElement.appendChild(iPathsElement); + } +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece) { @@ -362,6 +380,7 @@ void VToolSeamAllowance::AddToFile() AddNodes(doc, domElement, piece); //custom seam allowance AddCSARecords(doc, domElement, piece.GetCustomSARecords()); + AddInternalPaths(doc, domElement, piece.GetInternalPaths()); AddPiece *addDet = new AddPiece(domElement, doc, piece, m_drawName); connect(addDet, &AddPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); @@ -393,6 +412,7 @@ void VToolSeamAllowance::RefreshDataInFile() AddGrainline(doc, domElement, piece); AddNodes(doc, domElement, piece); AddCSARecords(doc, domElement, piece.GetCustomSARecords()); + AddInternalPaths(doc, domElement, piece.GetInternalPaths()); } } } @@ -637,6 +657,7 @@ VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, VPiece detail = data->GetPiece(id); InitNodes(detail, scene); InitCSAPaths(detail); + InitInternalPaths(detail); this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true); RefreshGeometry(); @@ -737,6 +758,22 @@ void VToolSeamAllowance::InitCSAPaths(const VPiece &detail) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::InitInternalPaths(const VPiece &detail) +{ + QVector records = detail.GetInternalPaths(); + for (int i = 0; i < records.size(); ++i) + { + QHash* tools = doc->getTools(); + SCASSERT(tools != nullptr); + VToolPiecePath *tool = qobject_cast(tools->value(records.at(i))); + SCASSERT(tool != nullptr); + tool->setParentItem(this); + tool->SetParentType(ParentType::Item); + doc->IncrementReferens(records.at(i)); + } +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::DeleteTool(bool ask) { diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 03a53157d..3750b0823 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -56,6 +56,7 @@ public: static const QString TagCSA; static const QString TagRecord; + static const QString TagIPaths; static const QString AttrVersion; static const QString AttrForbidFlipping; @@ -74,6 +75,7 @@ public: static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiece &piece); static void AddCSARecord(VAbstractPattern *doc, QDomElement &domElement, const CustomSARecord &record); static void AddCSARecords(VAbstractPattern *doc, QDomElement &domElement, const QVector &records); + static void AddInternalPaths(VAbstractPattern *doc, QDomElement &domElement, const QVector &paths); static void AddPatternPieceData(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece); static void AddPatternInfo(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece); static void AddGrainline(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece); @@ -131,6 +133,7 @@ private: void InitNodes(const VPiece &detail, VMainGraphicsScene *scene); void InitCSAPaths(const VPiece &detail); + void InitInternalPaths(const VPiece &detail); template Tool* InitTool(VMainGraphicsScene *scene, quint32 toolId); diff --git a/src/libs/vtools/undocommands/addpiece.cpp b/src/libs/vtools/undocommands/addpiece.cpp index c27b9e250..9f4ccc2ff 100644 --- a/src/libs/vtools/undocommands/addpiece.cpp +++ b/src/libs/vtools/undocommands/addpiece.cpp @@ -64,6 +64,7 @@ void AddPiece::undo() DecrementReferences(m_detail.GetPath().GetNodes()); DecrementReferences(m_detail.GetCustomSARecords()); + DecrementReferences(m_detail.GetInternalPaths()); } else { diff --git a/src/libs/vtools/undocommands/deletepiece.cpp b/src/libs/vtools/undocommands/deletepiece.cpp index 6fb5fd5bf..d75e879a0 100644 --- a/src/libs/vtools/undocommands/deletepiece.cpp +++ b/src/libs/vtools/undocommands/deletepiece.cpp @@ -108,6 +108,7 @@ void DeletePiece::redo() DecrementReferences(m_detail.GetPath().GetNodes()); DecrementReferences(m_detail.GetCustomSARecords()); + DecrementReferences(m_detail.GetInternalPaths()); emit NeedFullParsing(); // Doesn't work when UnionDetail delete detail. } else diff --git a/src/libs/vtools/undocommands/savepieceoptions.cpp b/src/libs/vtools/undocommands/savepieceoptions.cpp index 92759370e..daeef8aab 100644 --- a/src/libs/vtools/undocommands/savepieceoptions.cpp +++ b/src/libs/vtools/undocommands/savepieceoptions.cpp @@ -77,9 +77,11 @@ void SavePieceOptions::undo() VToolSeamAllowance::AddGrainline(doc, domElement, m_oldDet); VToolSeamAllowance::AddNodes(doc, domElement, m_oldDet); VToolSeamAllowance::AddCSARecords(doc, domElement, m_oldDet.GetCustomSARecords()); + VToolSeamAllowance::AddInternalPaths(doc, domElement, m_oldDet.GetInternalPaths()); IncrementReferences(m_oldDet.MissingNodes(m_newDet)); IncrementReferences(m_oldDet.MissingCSAPath(m_newDet)); + IncrementReferences(m_oldDet.MissingInternalPaths(m_newDet)); emit NeedLiteParsing(Document::LiteParse); } else @@ -104,9 +106,11 @@ void SavePieceOptions::redo() VToolSeamAllowance::AddGrainline(doc, domElement, m_newDet); VToolSeamAllowance::AddNodes(doc, domElement, m_newDet); VToolSeamAllowance::AddCSARecords(doc, domElement, m_newDet.GetCustomSARecords()); + VToolSeamAllowance::AddInternalPaths(doc, domElement, m_newDet.GetInternalPaths()); DecrementReferences(m_oldDet.MissingNodes(m_newDet)); DecrementReferences(m_oldDet.MissingCSAPath(m_newDet)); + DecrementReferences(m_oldDet.MissingInternalPaths(m_newDet)); emit NeedLiteParsing(Document::LiteParse); }