diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 9f41ae600..509634035 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -666,7 +666,7 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement) { const quint32 id = VDomDocument::GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR); const bool reverse = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeReverse, "0"); - const bool excluded = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeExcluded, "0"); + const bool excluded = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeExcluded, falseStr); const QString saBefore = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSABefore, currentSeamAllowance); const QString saAfter = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSAAfter, diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 19f4443e3..44b74b287 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -58,8 +58,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.4.4"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.4.4.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.4.5"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.4.5.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index ef954c760..1de1c57ca 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -121,9 +121,9 @@ QVector VPiece::MainPathPoints(const VContainer *data) const } //--------------------------------------------------------------------------------------------------------------------- -QVector VPiece::MainPathNodePoints(const VContainer *data) const +QVector VPiece::MainPathNodePoints(const VContainer *data, bool showExcluded) const { - return GetPath().PathNodePoints(data); + return GetPath().PathNodePoints(data, showExcluded); } //--------------------------------------------------------------------------------------------------------------------- @@ -146,6 +146,11 @@ QVector VPiece::SeamAllowancePoints(const VContainer *data) const for (int i = 0; i< d->m_path.CountNodes(); ++i) { const VPieceNode &node = d->m_path.at(i); + if (node.IsExcluded()) + { + continue;// skip excluded node + } + switch (node.GetTypeTool()) { case (Tool::NodePoint): @@ -491,12 +496,16 @@ QVector VPiece::GetValidRecords() const for (int i = 0; i < d->m_customSARecords.size(); ++i) { const CustomSARecord &record = d->m_customSARecords.at(i); + const int indexStartPoint = d->m_path.indexOfNode(record.startPoint); + const int indexEndPoint = d->m_path.indexOfNode(record.endPoint); if (record.startPoint > NULL_ID && record.path > NULL_ID && record.endPoint > NULL_ID - && d->m_path.indexOfNode(record.startPoint) != -1 - && d->m_path.indexOfNode(record.endPoint) != -1) + && indexStartPoint != -1 + && not d->m_path.at(indexStartPoint).IsExcluded() + && indexEndPoint != -1 + && not d->m_path.at(indexEndPoint).IsExcluded()) { records.append(record); } diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 31c7fe476..234a2bbf1 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -59,7 +59,7 @@ public: void SetPath(const VPiecePath &path); QVector MainPathPoints(const VContainer *data) const; - QVector MainPathNodePoints(const VContainer *data) const; + QVector MainPathNodePoints(const VContainer *data, bool showExcluded = false) const; QVector SeamAllowancePoints(const VContainer *data) const; QPainterPath MainPathPath(const VContainer *data) const; diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index d11956179..998061e1b 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -243,6 +243,11 @@ QVector VPiecePath::PathPoints(const VContainer *data) const QVector points; for (int i = 0; i < CountNodes(); ++i) { + if (at(i).IsExcluded()) + { + continue;// skip excluded node + } + switch (at(i).GetTypeTool()) { case (Tool::NodePoint): @@ -274,7 +279,7 @@ QVector VPiecePath::PathPoints(const VContainer *data) const } //--------------------------------------------------------------------------------------------------------------------- -QVector VPiecePath::PathNodePoints(const VContainer *data) const +QVector VPiecePath::PathNodePoints(const VContainer *data, bool showExcluded) const { QVector points; for (int i = 0; i < CountNodes(); ++i) @@ -283,8 +288,11 @@ QVector VPiecePath::PathNodePoints(const VContainer *data) const { case Tool::NodePoint: { - const QSharedPointer point = data->GeometricObject(at(i).GetId()); - points.append(*point); + if (showExcluded || not at(i).IsExcluded()) + { + const QSharedPointer point = data->GeometricObject(at(i).GetId()); + points.append(*point); + } } break; case Tool::NodeArc: diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h index 4bb8400fe..492053c0c 100644 --- a/src/libs/vpatterndb/vpiecepath.h +++ b/src/libs/vpatterndb/vpiecepath.h @@ -71,7 +71,7 @@ public: void SetPenType(const Qt::PenStyle &type); QVector PathPoints(const VContainer *data) const; - QVector PathNodePoints(const VContainer *data) const; + QVector PathNodePoints(const VContainer *data, bool showExcluded = true) const; QVector SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const; QPainterPath PainterPath(const VContainer *data) const; diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 6216b6b20..93628eb88 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -79,6 +79,25 @@ Q_LOGGING_CATEGORY(vDialog, "v.dialog") #define DIALOG_MAX_FORMULA_HEIGHT 64 +namespace +{ +//--------------------------------------------------------------------------------------------------------------------- +quint32 RowId(QListWidget *listWidget, int i) +{ + SCASSERT(listWidget != nullptr); + + if (i < 0 || i >= listWidget->count()) + { + return NULL_ID; + } + + const QListWidgetItem *rowItem = listWidget->item(i); + SCASSERT(rowItem != nullptr); + const VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + return rowNode.GetId(); +} +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogTool create dialog @@ -411,13 +430,65 @@ quint32 DialogTool::DNumber(const QString &baseName) const } //--------------------------------------------------------------------------------------------------------------------- -quint32 DialogTool::RowId(QListWidget *listWidget, int i) +quint32 DialogTool::FindNotExcludedNodeDown(QListWidget *listWidget, int candidate) { SCASSERT(listWidget != nullptr); - const QListWidgetItem *rowItem = listWidget->item(i); - SCASSERT(rowItem != nullptr); - const VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); - return rowNode.GetId(); + + quint32 id = NULL_ID; + if (candidate < 0 || candidate >= listWidget->count()) + { + return id; + } + + int i = candidate; + VPieceNode rowNode; + do + { + const QListWidgetItem *rowItem = listWidget->item(i); + SCASSERT(rowItem != nullptr); + rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + + if (not rowNode.IsExcluded()) + { + id = rowNode.GetId(); + } + + ++i; + } + while (rowNode.IsExcluded() && i < listWidget->count()); + + return id; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogTool::FindNotExcludedNodeUp(QListWidget *listWidget, int candidate) +{ + SCASSERT(listWidget != nullptr); + + quint32 id = NULL_ID; + if (candidate < 0 || candidate >= listWidget->count()) + { + return id; + } + + int i = candidate; + VPieceNode rowNode; + do + { + const QListWidgetItem *rowItem = listWidget->item(i); + SCASSERT(rowItem != nullptr); + rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + + if (not rowNode.IsExcluded()) + { + id = rowNode.GetId(); + } + + --i; + } + while (rowNode.IsExcluded() && i > -1); + + return id; } //--------------------------------------------------------------------------------------------------------------------- @@ -426,7 +497,9 @@ bool DialogTool::FirstPointEqualLast(QListWidget *listWidget) SCASSERT(listWidget != nullptr); if (listWidget->count() > 1) { - return RowId(listWidget, 0) == RowId(listWidget, listWidget->count()-1); + const quint32 topId = FindNotExcludedNodeDown(listWidget, 0); + const quint32 bottomId = FindNotExcludedNodeUp(listWidget, listWidget->count()-1); + return topId == bottomId; } return false; } @@ -437,7 +510,10 @@ bool DialogTool::DoublePoints(QListWidget *listWidget) SCASSERT(listWidget != nullptr); for (int i=0, sz = listWidget->count()-1; isetFont(QFont("Times", 12, QFont::Bold)); + item->setFont(NodeFont(node.IsExcluded())); item->setData(Qt::UserRole, QVariant::fromValue(node)); listWidget->addItem(item); listWidget->setCurrentRow(listWidget->count()-1); diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index b57bcb642..95ea94b98 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -266,10 +266,12 @@ protected: virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; quint32 DNumber(const QString &baseName) const; - static quint32 RowId(QListWidget *listWidget, int i); + static quint32 FindNotExcludedNodeDown(QListWidget *listWidget, int candidate); + static quint32 FindNotExcludedNodeUp(QListWidget *listWidget, int candidate); static bool FirstPointEqualLast(QListWidget *listWidget); static bool DoublePoints(QListWidget *listWidget); static QString DialogWarningIcon(); + static QFont NodeFont(bool nodeExcluded); QString GetNodeName(const VPieceNode &node) const; void NewNodeItem(QListWidget *listWidget, const VPieceNode &node); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 7fb12683a..b1060eb01 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -587,6 +587,10 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos) actionReverse->setChecked(rowNode.GetReverse()); } + QAction *actionExcluded = menu->addAction(tr("Excluded")); + actionExcluded->setCheckable(true); + actionExcluded->setChecked(rowNode.IsExcluded()); + QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); QAction *selectedAction = menu->exec(uiTabPaths->listWidgetMainPath->viewport()->mapToGlobal(pos)); @@ -602,6 +606,14 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos) rowItem->setText(GetNodeName(rowNode)); ValidObjects(MainPathIsValid()); } + else if (selectedAction == actionExcluded) + { + rowNode.SetExcluded(not rowNode.IsExcluded()); + rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); + rowItem->setText(GetNodeName(rowNode)); + rowItem->setFont(NodeFont(rowNode.IsExcluded())); + ValidObjects(MainPathIsValid()); + } ListChanged(); } @@ -1989,12 +2001,13 @@ QString DialogSeamAllowance::GetPathName(quint32 path, bool reverse) const bool DialogSeamAllowance::MainPathIsValid() const { QString url = DialogWarningIcon(); + bool valid = true; if(CreatePiece().MainPathPoints(data).count() < 3) { url += tr("You need more points!"); uiTabPaths->helpLabel->setText(url); - return false; + valid = false; } else { @@ -2002,23 +2015,33 @@ bool DialogSeamAllowance::MainPathIsValid() const { url += tr("You have to choose points in a clockwise direction!"); uiTabPaths->helpLabel->setText(url); - return false; + valid = false; } if (FirstPointEqualLast(uiTabPaths->listWidgetMainPath)) { url += tr("First point cannot be equal to the last point!"); uiTabPaths->helpLabel->setText(url); - return false; + valid = false; } else if (DoublePoints(uiTabPaths->listWidgetMainPath)) { url += tr("You have double points!"); uiTabPaths->helpLabel->setText(url); - return false; + valid = false; } } - uiTabPaths->helpLabel->setText(tr("Ready!")); - return true; + + if (valid) + { + m_ftb->SetTabText(TabOrder::Paths, tr("Paths")); + uiTabPaths->helpLabel->setText(tr("Ready!")); + } + else + { + m_ftb->SetTabText(TabOrder::Paths, tr("Paths") + QLatin1String("*")); + } + + return valid; } //--------------------------------------------------------------------------------------------------------------------- @@ -2059,7 +2082,7 @@ void DialogSeamAllowance::InitNodesList() for (int i = 0; i < nodes.size(); ++i) { const VPieceNode node = nodes.at(i); - if (node.GetTypeTool() == Tool::NodePoint) + if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded()) { const QString name = GetNodeName(node); @@ -2283,7 +2306,7 @@ void DialogSeamAllowance::InitCSAPoint(QComboBox *box) for (int i = 0; i < nodes.size(); ++i) { const VPieceNode &node = nodes.at(i); - if (node.GetTypeTool() == Tool::NodePoint) + if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded()) { const QString name = GetNodeName(node); box->addItem(name, node.GetId()); diff --git a/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp b/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp index 6d1ec701b..906e3df5d 100644 --- a/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp +++ b/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp @@ -58,8 +58,13 @@ const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool"); */ VAbstractNode::VAbstractNode(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode, const QString &drawName, const quint32 &idTool, QObject *parent) - : VAbstractTool(doc, data, id, parent), parentType(ParentType::Item), idNode(idNode), idTool(idTool), - currentColor(Qt::black), m_drawName(drawName) + : VAbstractTool(doc, data, id, parent), + parentType(ParentType::Item), + idNode(idNode), + idTool(idTool), + currentColor(Qt::black), + m_drawName(drawName), + m_exluded(false) { _referens = 0; } @@ -140,6 +145,18 @@ void VAbstractNode::GroupVisibility(quint32 object, bool visible) Q_UNUSED(visible) } +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractNode::IsExluded() const +{ + return m_exluded; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::SetExluded(bool exluded) +{ + m_exluded = exluded; +} + //--------------------------------------------------------------------------------------------------------------------- void VAbstractNode::ToolCreation(const Source &typeCreation) { diff --git a/src/libs/vtools/tools/nodeDetails/vabstractnode.h b/src/libs/vtools/tools/nodeDetails/vabstractnode.h index cfc45919a..fa666b9c2 100644 --- a/src/libs/vtools/tools/nodeDetails/vabstractnode.h +++ b/src/libs/vtools/tools/nodeDetails/vabstractnode.h @@ -61,11 +61,12 @@ public: virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; + bool IsExluded() const; + void SetExluded(bool exluded); + protected: ParentType parentType; - virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE; -protected: /** @brief idNodenode id. */ quint32 idNode; @@ -77,11 +78,16 @@ protected: QString m_drawName; + bool m_exluded; + void AddToModeling(const QDomElement &domElement); + virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE {} virtual void ShowNode()=0; virtual void HideNode()=0; +private: + Q_DISABLE_COPY(VAbstractNode) }; #endif // VABSTRACTNODE_H diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index 2a0a9a1a2..2d645a141 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -321,7 +321,7 @@ void VNodePoint::RefreshLine() //--------------------------------------------------------------------------------------------------------------------- void VNodePoint::ShowNode() { - if (parentType != ParentType::Scene) + if (parentType != ParentType::Scene && not m_exluded) { show(); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index d0788a5cc..d02b237ee 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -453,6 +453,7 @@ void VToolSeamAllowance::GroupVisibility(quint32 object, bool visible) //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::FullUpdateFromFile() { + UpdateExcludeState(); RefreshGeometry(); } @@ -1207,6 +1208,24 @@ VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, UpdateGrainline(); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::UpdateExcludeState() +{ + const VPiece detail = VAbstractTool::data.GetPiece(id); + for (int i = 0; i< detail.GetPath().CountNodes(); ++i) + { + const VPieceNode &node = detail.GetPath().at(i); + if (node.GetTypeTool() == Tool::NodePoint) + { + VNodePoint *tool = qobject_cast(doc->getTool(node.GetId())); + SCASSERT(tool != nullptr); + + tool->SetExluded(node.IsExcluded()); + tool->setVisible(not node.IsExcluded());//Hide excluded point + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::RefreshGeometry() { @@ -1462,6 +1481,7 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); tool->setParentItem(parent); tool->SetParentType(ParentType::Item); + tool->SetExluded(node.IsExcluded()); tool->setVisible(not node.IsExcluded());//Hide excluded point doc->IncrementReferens(node.GetId()); break; diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 4eab60d9e..469c3a19e 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -153,6 +153,7 @@ private: VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VMainGraphicsScene *scene, const QString &m_drawName, QGraphicsItem * parent = nullptr); + void UpdateExcludeState(); void RefreshGeometry(); void SaveDialogChange(); VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth,