diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index e7fc7f246..a83835fb7 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -730,8 +730,9 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document detail.GetGrainlineGeometry().SetLength(qsLength); QString qsRot = GetParametrString(element, VToolDetail::AttrRotation, "90"); detail.GetGrainlineGeometry().SetRotation(qsRot); - detail.GetGrainlineGeometry().SetFrontArrow(GetParametrBool(element, AttrFront, trueStr)); - detail.GetGrainlineGeometry().SetRearArrow(GetParametrBool(element, AttrRear, trueStr)); + VGrainlineGeometry::ArrowType eAT = + VGrainlineGeometry::ArrowType(GetParametrUInt(element, AttrArrows, "0")); + detail.GetGrainlineGeometry().SetArrowType(eAT); } } } diff --git a/src/libs/ifc/schema/pattern/v0.3.8.xsd b/src/libs/ifc/schema/pattern/v0.3.8.xsd index 5ea1157ca..7533631a6 100644 --- a/src/libs/ifc/schema/pattern/v0.3.8.xsd +++ b/src/libs/ifc/schema/pattern/v0.3.8.xsd @@ -384,9 +384,8 @@ - - - + + @@ -600,4 +599,11 @@ + + + + + + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 2287bbffb..4246c9091 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -100,8 +100,7 @@ const QString VAbstractPattern::AttrMaterial = QStringLiteral("material") const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef"); const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber"); const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement"); -const QString VAbstractPattern::AttrFront = QStringLiteral("front"); -const QString VAbstractPattern::AttrRear = QStringLiteral("rear"); +const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows"); const QString VAbstractPattern::AttrAll = QStringLiteral("all"); diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index abe023c69..50aeb8521 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -205,8 +205,7 @@ public: static const QString AttrUserDefined; static const QString AttrCutNumber; static const QString AttrPlacement; - static const QString AttrFront; - static const QString AttrRear; + static const QString AttrArrows; static const QString AttrAll; diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 8f746bc48..8aadd1ea3 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -220,7 +220,7 @@ void VLayoutDetail::SetGrainline(const VGrainlineGeometry& geom, const VContaine v << pt1; - if (geom.HasFrontArrow() == true) { + if (geom.GetArrowType() != VGrainlineGeometry::atRear) { pt.setX(pt1.x() + dArrowLen * qCos(dAng + dArrowAng)); pt.setY(pt1.y() - dArrowLen * qSin(dAng + dArrowAng)); v << pt; @@ -233,7 +233,7 @@ void VLayoutDetail::SetGrainline(const VGrainlineGeometry& geom, const VContaine v << pt2; - if (geom.HasRearArrow() == true) + if (geom.GetArrowType() != VGrainlineGeometry::atFront) { dAng += M_PI; diff --git a/src/libs/vpatterndb/vgrainlinegeometry.cpp b/src/libs/vpatterndb/vgrainlinegeometry.cpp index bd9557ab0..da8f32a90 100644 --- a/src/libs/vpatterndb/vgrainlinegeometry.cpp +++ b/src/libs/vpatterndb/vgrainlinegeometry.cpp @@ -33,7 +33,7 @@ //--------------------------------------------------------------------------------------------------------------------- VGrainlineGeometry::VGrainlineGeometry() - :m_ptPos(0, 0), m_qsLength(), m_qsRotation(), m_bVisible(false), m_bFrontArrow(true), m_bRearArrow(true) + :m_ptPos(0, 0), m_qsLength(), m_qsRotation(), m_bVisible(false), m_eArrowType(atBoth) {} //--------------------------------------------------------------------------------------------------------------------- @@ -99,30 +99,16 @@ void VGrainlineGeometry::SetVisible(bool bVisible) //--------------------------------------------------------------------------------------------------------------------- -bool VGrainlineGeometry::HasFrontArrow() const +VGrainlineGeometry::ArrowType VGrainlineGeometry::GetArrowType() const { - return m_bFrontArrow; + return m_eArrowType; } //--------------------------------------------------------------------------------------------------------------------- -void VGrainlineGeometry::SetFrontArrow(bool bVal) +void VGrainlineGeometry::SetArrowType(ArrowType eAT) { - m_bFrontArrow = bVal; -} - -//--------------------------------------------------------------------------------------------------------------------- - -bool VGrainlineGeometry::HasRearArrow() const -{ - return m_bRearArrow; -} - -//--------------------------------------------------------------------------------------------------------------------- - -void VGrainlineGeometry::SetRearArrow(bool bVal) -{ - m_bRearArrow = bVal; + m_eArrowType = eAT; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vgrainlinegeometry.h b/src/libs/vpatterndb/vgrainlinegeometry.h index 9cd38eada..f556331db 100644 --- a/src/libs/vpatterndb/vgrainlinegeometry.h +++ b/src/libs/vpatterndb/vgrainlinegeometry.h @@ -40,6 +40,15 @@ class QPointF; */ class VGrainlineGeometry { +public: + // denotes the type of arrow for the grainline + enum ArrowType + { + atBoth, + atFront, + atRear + }; + public: VGrainlineGeometry(); ~VGrainlineGeometry(); @@ -53,10 +62,8 @@ public: void SetRotation(const QString& qsRot); bool IsVisible() const; void SetVisible(bool bVisible); - bool HasFrontArrow() const; - void SetFrontArrow(bool bVal); - bool HasRearArrow() const; - void SetRearArrow(bool bVal); + ArrowType GetArrowType() const; + void SetArrowType(ArrowType eAT); private: /** @@ -76,13 +83,9 @@ private: */ bool m_bVisible; /** - * @brief m_bFrontArrow front arrow flag + * @brief m_eArrowType type of arrow on the grainline */ - bool m_bFrontArrow; - /** - * @brief m_bRearArrow back arrow flag - */ - bool m_bRearArrow; + ArrowType m_eArrowType; }; #endif // VGRAINLINEGEOMETRY_H diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index 08a27e264..6b0a6333c 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -168,6 +168,10 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge SetAddMode(); EnableGrainlineRotation(); + ui.comboBoxArrow->addItem(tr("Both")); + ui.comboBoxArrow->addItem(tr("Just front")); + ui.comboBoxArrow->addItem(tr("Just rear")); + ui.tabWidget->setCurrentIndex(0); m_iRotBaseHeight = ui.lineEditRotFormula->height(); @@ -486,11 +490,9 @@ VDetail DialogDetail::CreateDetail() const detail.GetGrainlineGeometry().SetVisible(ui.checkBoxGrainline->isChecked()); detail.GetGrainlineGeometry().SetRotation(ui.lineEditRotFormula->toPlainText()); detail.GetGrainlineGeometry().SetLength(ui.lineEditLenFormula->toPlainText()); - detail.GetGrainlineGeometry().SetFrontArrow(ui.checkBoxFrontArrow->isChecked()); - detail.GetGrainlineGeometry().SetRearArrow(ui.checkBoxRearArrow->isChecked()); + VGrainlineGeometry::ArrowType eAT = VGrainlineGeometry::ArrowType(ui.comboBoxArrow->currentIndex()); + detail.GetGrainlineGeometry().SetArrowType(eAT); - qDebug() << "DIALOG ARROWS" << detail.GetGrainlineGeometry().HasFrontArrow() - << detail.GetGrainlineGeometry().HasRearArrow(); return detail; } @@ -564,8 +566,7 @@ void DialogDetail::setDetail(const VDetail &value) ui.checkBoxGrainline->setChecked(detail.GetGrainlineGeometry().IsVisible()); ui.lineEditRotFormula->setPlainText(detail.GetGrainlineGeometry().GetRotation()); ui.lineEditLenFormula->setPlainText(detail.GetGrainlineGeometry().GetLength()); - ui.checkBoxFrontArrow->setChecked(detail.GetGrainlineGeometry().HasFrontArrow()); - ui.checkBoxRearArrow->setChecked(detail.GetGrainlineGeometry().HasRearArrow()); + ui.comboBoxArrow->setCurrentIndex(int(detail.GetGrainlineGeometry().GetArrowType())); m_oldData = detail.GetPatternPieceData(); m_oldGeom = detail.GetPatternInfo(); diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.ui b/src/libs/vtools/dialogs/tools/dialogdetail.ui index 3cc061acf..7198fcea0 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.ui +++ b/src/libs/vtools/dialogs/tools/dialogdetail.ui @@ -977,30 +977,70 @@ - + + + + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + - Front arrow + Arrows: - - - - - - 10 - 310 - 541 - 41 - - - - - - Rear arrow + + + + + + Qt::Horizontal - + + + 40 + 20 + + + diff --git a/src/libs/vtools/tools/vgrainlineitem.cpp b/src/libs/vtools/tools/vgrainlineitem.cpp index f368d2f9f..48b8fc9bd 100644 --- a/src/libs/vtools/tools/vgrainlineitem.cpp +++ b/src/libs/vtools/tools/vgrainlineitem.cpp @@ -54,7 +54,7 @@ VGrainlineItem::VGrainlineItem(QGraphicsItem* pParent) :QGraphicsObject(pParent), m_eMode(VGrainlineItem::mNormal), m_bReleased(false), m_dRotation(0), m_dStartRotation(0), m_dLength(0), m_rectBoundingBox(), m_polyBound(), m_ptStartPos(), m_ptStartMove(), m_dScale(1), m_polyResize(), - m_ptStart(), m_ptFinish(), m_ptCenter(), m_dAngle(0), m_bFrontArrow(false), m_bRearArrow(false) + m_ptStart(), m_ptFinish(), m_ptCenter(), m_dAngle(0), m_eArrowType(VGrainlineGeometry::atBoth) { m_rectBoundingBox.setTopLeft(QPointF(0, 0)); setAcceptHoverEvents(true); @@ -97,7 +97,7 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption QPolygonF poly; QPointF ptA; qreal dArrLen = ARROW_LENGTH*m_dScale; - if (m_bFrontArrow == true) + if (m_eArrowType != VGrainlineGeometry::atRear) { // first arrow poly << pt1; @@ -109,7 +109,7 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption poly << ptA; pP->drawPolygon(poly); } - if (m_bRearArrow == true) + if (m_eArrowType != VGrainlineGeometry::atFront) { // second arrow poly.clear(); @@ -177,7 +177,8 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption * @param dRotation rotation of the grainline in [degrees] * @param dLength length of the grainline in user's units */ -void VGrainlineItem::UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, bool bFA, bool bRA) +void VGrainlineItem::UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, + VGrainlineGeometry::ArrowType eAT) { m_dRotation = qDegreesToRadians(dRotation); m_dLength = dLength; @@ -191,8 +192,7 @@ void VGrainlineItem::UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal pt.setY(pt.y() + dY); } setPos(pt); - m_bFrontArrow = bFA; - m_bRearArrow = bRA; + m_eArrowType = eAT; UpdateRectangle(); UpdateBox(); diff --git a/src/libs/vtools/tools/vgrainlineitem.h b/src/libs/vtools/tools/vgrainlineitem.h index d020697c5..41ea59eb5 100644 --- a/src/libs/vtools/tools/vgrainlineitem.h +++ b/src/libs/vtools/tools/vgrainlineitem.h @@ -54,7 +54,8 @@ public: virtual ~VGrainlineItem(); void paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption, QWidget* pWidget); - void UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, bool bFA, bool bRA); + void UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, + VGrainlineGeometry::ArrowType eAT); QRectF boundingRect() const; void Reset(); @@ -79,25 +80,24 @@ signals: void SignalRotated(qreal dRot, const QPointF& ptNewPos); private: - Mode m_eMode; - bool m_bReleased; - qreal m_dRotation; - qreal m_dStartRotation; - qreal m_dLength; - QRectF m_rectBoundingBox; - QPolygonF m_polyBound; - QPointF m_ptStartPos; - QPointF m_ptStartMove; - qreal m_dScale; - QPolygonF m_polyResize; - qreal m_dStartLength; - QPointF m_ptStart; - QPointF m_ptFinish; - QPointF m_ptCenter; - QPointF m_ptRotCenter; - qreal m_dAngle; - bool m_bFrontArrow; - bool m_bRearArrow; + Mode m_eMode; + bool m_bReleased; + qreal m_dRotation; + qreal m_dStartRotation; + qreal m_dLength; + QRectF m_rectBoundingBox; + QPolygonF m_polyBound; + QPointF m_ptStartPos; + QPointF m_ptStartMove; + qreal m_dScale; + QPolygonF m_polyResize; + qreal m_dStartLength; + QPointF m_ptStart; + QPointF m_ptFinish; + QPointF m_ptCenter; + QPointF m_ptRotCenter; + qreal m_dAngle; + VGrainlineGeometry::ArrowType m_eArrowType; }; #endif // VGRAINLINEITEM_H diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 7b732dc0d..912f81f7e 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -509,8 +509,7 @@ void VToolDetail::AddToFile() doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y()); doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); doc->SetAttribute(domData, AttrRotation, glGeom.GetRotation()); - doc->SetAttribute(domData, VAbstractPattern::AttrFront, glGeom.HasFrontArrow() == true? trueStr : falseStr); - doc->SetAttribute(domData, VAbstractPattern::AttrRear, glGeom.HasRearArrow() == true? trueStr : falseStr); + doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType())); qDebug() << "XML ROTATION" << glGeom.GetRotation(); // nodes @@ -590,8 +589,7 @@ void VToolDetail::RefreshDataInFile() doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y()); doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); doc->SetAttribute(domData, AttrRotation, glGeom.GetRotation()); - doc->SetAttribute(domData, VAbstractPattern::AttrFront, glGeom.HasFrontArrow() == true? trueStr : falseStr); - doc->SetAttribute(domData, VAbstractPattern::AttrRear, glGeom.HasRearArrow() == true? trueStr : falseStr); + doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType())); // nodes for (int i = 0; i < det.CountNode(); ++i) @@ -954,8 +952,7 @@ void VToolDetail::UpdateGrainline() } grainLine->UpdateGeometry(geom.GetPos(), dRotation, ToPixel(dLength, *VDataTool::data.GetPatternUnit()), - geom.HasFrontArrow(), geom.HasRearArrow()); - qDebug() << "ARROWS" << geom.HasFrontArrow() << geom.HasRearArrow(); + geom.GetArrowType()); grainLine->show(); } else diff --git a/src/libs/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index 612180025..032db725e 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -210,8 +210,7 @@ void SaveDetailOptions::SaveGrainline(QDomElement &domElement, const VDetail &de doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y()); doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); doc->SetAttribute(domData, VToolDetail::AttrRotation, glGeom.GetRotation()); - doc->SetAttribute(domData, VAbstractPattern::AttrFront, glGeom.HasFrontArrow() == true? trueStr : falseStr); - doc->SetAttribute(domData, VAbstractPattern::AttrRear, glGeom.HasRearArrow() == true? trueStr : falseStr); + doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType())); domElement.appendChild(domData); }