diff --git a/ChangeLog.txt b/ChangeLog.txt index 29246a77f..3cfe0552c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -101,6 +101,7 @@ - [#803] Bug in FancyTabBar widget. Wrongly calculated widget width. - [#805] Invalid regular expression for validation layout output filename mask. - [#823] SVG Export - seam and cutting line of one piece missing. +- Added submenu to quick access to piece node point angle type. # Version 0.5.0 May 9, 2017 - [#581] User can now filter input lists by keyword in function wizard. diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index f130c7223..a9212aea9 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -52,6 +52,7 @@ #include "../ifc/ifcdef.h" #include "../vmisc/vabstractapplication.h" #include "../vpatterndb/vcontainer.h" +#include "../vpatterndb/vpiecenode.h" #include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsview.h" #include "../vabstracttool.h" @@ -282,14 +283,47 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) QAction *actionExclude = menu.addAction(tr("Exclude")); + QMenu *angleTypeMenu = menu.addMenu(tr("Angle")); + PieceNodeAngle curType = PieceNodeAngle::ByLength; + + const VPiece detail = VAbstractTool::data.GetPiece(piece->getId()); + const int nodeIndex = detail.GetPath().indexOfNode(m_id); + if (nodeIndex != -1) + { + const VPieceNode &node = detail.GetPath().at(nodeIndex); + curType = node.GetAngleType(); + } + else + { + angleTypeMenu->setVisible(false); + } + + auto InitAngleAction = [angleTypeMenu, curType](const QString &name, PieceNodeAngle checkType) + { + QAction *action = angleTypeMenu->addAction(name); + action->setCheckable(true); + action->setChecked(curType == checkType); + return action; + }; + + QAction *actionByLength = InitAngleAction(tr("by length"), PieceNodeAngle::ByLength); + QAction *actionByPointsIntersection = InitAngleAction(tr("by points intersetions"), + PieceNodeAngle::ByPointsIntersection); + QAction *actionByFirstEdgeSymmetry = InitAngleAction(tr("by first edge symmetry"), + PieceNodeAngle::ByFirstEdgeSymmetry); + QAction *actionBySecondEdgeSymmetry = InitAngleAction(tr("by second edge symmetry"), + PieceNodeAngle::BySecondEdgeSymmetry); + QAction *actionByFirstEdgeRightAngle = InitAngleAction(tr("by first edge right angle"), + PieceNodeAngle::ByFirstEdgeRightAngle); + QAction *actionBySecondEdgeRightAngle = InitAngleAction(tr("by second edge right angle"), + PieceNodeAngle::BySecondEdgeRightAngle); + QAction *separatorAct = new QAction(this); separatorAct->setSeparator(true); menu.addAction(separatorAct); QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options")); - const VPiece detail = VAbstractTool::data.GetPiece(piece->getId()); - QAction *inLayoutOption = menu.addAction(tr("In layout")); inLayoutOption->setCheckable(true); inLayoutOption->setChecked(detail.IsInLayout()); @@ -343,6 +377,30 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { emit ToggleExcludeState(m_id); } + else if (selectedAction == actionByLength) + { + emit ToggleAngleType(m_id, PieceNodeAngle::ByLength); + } + else if (selectedAction == actionByPointsIntersection) + { + emit ToggleAngleType(m_id, PieceNodeAngle::ByPointsIntersection); + } + else if (selectedAction == actionByFirstEdgeSymmetry) + { + emit ToggleAngleType(m_id, PieceNodeAngle::ByFirstEdgeSymmetry); + } + else if (selectedAction == actionBySecondEdgeSymmetry) + { + emit ToggleAngleType(m_id, PieceNodeAngle::BySecondEdgeSymmetry); + } + else if (selectedAction == actionByFirstEdgeRightAngle) + { + emit ToggleAngleType(m_id, PieceNodeAngle::ByFirstEdgeRightAngle); + } + else if (selectedAction == actionBySecondEdgeRightAngle) + { + emit ToggleAngleType(m_id, PieceNodeAngle::BySecondEdgeRightAngle); + } } } diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.h b/src/libs/vtools/tools/nodeDetails/vnodepoint.h index 4b1395917..a46669928 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.h +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.h @@ -66,6 +66,7 @@ signals: void ToggleForceFlipping(bool checked); void Delete(); void ToggleExcludeState(quint32 id); + void ToggleAngleType(quint32 id, PieceNodeAngle type); public slots: virtual void FullUpdateFromFile() override; void NameChangePosition(const QPointF &pos); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 84b4fd27c..44f8f10fd 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1524,6 +1524,26 @@ void VToolSeamAllowance::ToggleExcludeState(quint32 id) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::ToggleNodePointAngleType(quint32 id, PieceNodeAngle type) +{ + const VPiece oldDet = VAbstractTool::data.GetPiece(m_id); + VPiece newDet = oldDet; + + for (int i = 0; i< oldDet.GetPath().CountNodes(); ++i) + { + VPieceNode node = oldDet.GetPath().at(i); + if (node.GetId() == id && node.GetTypeTool() == Tool::NodePoint) + { + node.SetAngleType(type); + newDet.GetPath()[i] = node; + + qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); + return; + } + } +} + //--------------------------------------------------------------------------------------------------------------------- VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData& labelData, qreal &rotationAngle, qreal &labelWidth, qreal &labelHeight, QPointF &pos) @@ -1749,6 +1769,8 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc connect(tool, &VNodePoint::Delete, parent, &VToolSeamAllowance::DeleteFromMenu, Qt::UniqueConnection); connect(tool, &VNodePoint::ToggleExcludeState, parent, &VToolSeamAllowance::ToggleExcludeState, Qt::UniqueConnection); + connect(tool, &VNodePoint::ToggleAngleType, parent, &VToolSeamAllowance::ToggleNodePointAngleType, + Qt::UniqueConnection); connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem, Qt::UniqueConnection); tool->setParentItem(parent); tool->SetParentType(ParentType::Item); diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index f582f957f..cb9644e7a 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -166,6 +166,7 @@ private slots: void ToggleForceFlipping(bool checked); void DeleteFromMenu(); void ToggleExcludeState(quint32 id); + void ToggleNodePointAngleType(quint32 id, PieceNodeAngle type); private: Q_DISABLE_COPY(VToolSeamAllowance)