From b3f236dbb5a3a034500e1cd2008d77c01d4ca6c7 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 7 Jan 2020 13:54:23 +0200 Subject: [PATCH] Refactoring. Rename ArrowType enum class. --HG-- branch : develop --- src/app/valentina/xml/vpattern.cpp | 2 +- src/libs/vlayout/vabstractpiece.cpp | 4 ++-- src/libs/vlayout/vlayoutpiece.cpp | 2 +- src/libs/vlayout/vlayoutpiece.h | 2 +- src/libs/vlayout/vlayoutpiece_p.h | 2 +- src/libs/vlayout/vposition.cpp | 8 ++++---- src/libs/vpatterndb/floatItemData/floatitemdef.h | 2 +- src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp | 4 ++-- src/libs/vpatterndb/floatItemData/vgrainlinedata.h | 4 ++-- src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h | 4 ++-- .../dialogs/tools/piece/dialogseamallowance.cpp | 3 ++- src/libs/vwidgets/vgrainlineitem.cpp | 12 ++++++------ src/libs/vwidgets/vgrainlineitem.h | 4 ++-- 13 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 7c19936fd..f4b7b3e08 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -1100,7 +1100,7 @@ VGrainlineData VPattern::ParsePieceGrainline(const QDomElement &domElement, VGra gGeometry.SetVisible(GetParametrBool(domElement, AttrVisible, falseStr)); gGeometry.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')), GetParametrDouble(domElement, AttrMy, QChar('0')))); - gGeometry.SetArrowType(static_cast(GetParametrUInt(domElement, AttrArrows, QChar('0')))); + gGeometry.SetArrowType(static_cast(GetParametrUInt(domElement, AttrArrows, QChar('0')))); const quint32 topPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopPin, NULL_ID_STR); const quint32 bottomPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomPin, NULL_ID_STR); diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 94cef227d..00d3055cd 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -2004,7 +2004,7 @@ QVector VAbstractPiece::GrainlinePoints(const VGrainlineData &geom, con QVector v; v << pt1; - if (geom.GetArrowType() != ArrowType::atFront) + if (geom.GetArrowType() != GrainlineArrowDirection::atFront) { v << QPointF(pt1.x() + dArrowLen * qCos(rotation + dArrowAng), pt1.y() - dArrowLen * qSin(rotation + dArrowAng)); @@ -2015,7 +2015,7 @@ QVector VAbstractPiece::GrainlinePoints(const VGrainlineData &geom, con v << pt2; - if (geom.GetArrowType() != ArrowType::atRear) + if (geom.GetArrowType() != GrainlineArrowDirection::atRear) { rotation += M_PI; diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 220bad840..cb5467b7b 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -773,7 +773,7 @@ qreal VLayoutPiece::GrainlineAngle() const } //--------------------------------------------------------------------------------------------------------------------- -ArrowType VLayoutPiece::GrainlineArrowType() const +GrainlineArrowDirection VLayoutPiece::GrainlineArrowType() const { return d->grainlineArrowType; } diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index 011ef2f8b..8a81439b5 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -108,7 +108,7 @@ public: QVector GetGrainline() const; bool IsGrainlineEnabled() const; qreal GrainlineAngle() const; - ArrowType GrainlineArrowType() const; + GrainlineArrowDirection GrainlineArrowType() const; QTransform GetMatrix() const; void SetMatrix(const QTransform &matrix); diff --git a/src/libs/vlayout/vlayoutpiece_p.h b/src/libs/vlayout/vlayoutpiece_p.h index 7c53713a8..f2d783066 100644 --- a/src/libs/vlayout/vlayoutpiece_p.h +++ b/src/libs/vlayout/vlayoutpiece_p.h @@ -117,7 +117,7 @@ public: /** @brief grainlineInfo line */ QVector grainlinePoints{}; - ArrowType grainlineArrowType{ArrowType::atFront}; + GrainlineArrowDirection grainlineArrowType{GrainlineArrowDirection::atFront}; qreal grainlineAngle{0}; bool grainlineEnabled{false}; diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index cbbd95ac5..72724d749 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -468,8 +468,8 @@ void VPosition::FollowGrainline() const qreal angle = detailGrainline.angleTo(FabricGrainline()); - if (m_data.detail.GrainlineArrowType() == ArrowType::atBoth || - m_data.detail.GrainlineArrowType() == ArrowType::atFront) + if (m_data.detail.GrainlineArrowType() == GrainlineArrowDirection::atBoth || + m_data.detail.GrainlineArrowType() == GrainlineArrowDirection::atFront) { RotateOnAngle(angle); } @@ -479,8 +479,8 @@ void VPosition::FollowGrainline() return; } - if (m_data.detail.GrainlineArrowType() == ArrowType::atBoth || - m_data.detail.GrainlineArrowType() == ArrowType::atRear) + if (m_data.detail.GrainlineArrowType() == GrainlineArrowDirection::atBoth || + m_data.detail.GrainlineArrowType() == GrainlineArrowDirection::atRear) { RotateOnAngle(angle+180); } diff --git a/src/libs/vpatterndb/floatItemData/floatitemdef.h b/src/libs/vpatterndb/floatItemData/floatitemdef.h index cc605ceda..36eca6880 100644 --- a/src/libs/vpatterndb/floatItemData/floatitemdef.h +++ b/src/libs/vpatterndb/floatItemData/floatitemdef.h @@ -33,7 +33,7 @@ #include // denotes the type of arrow for the grainline -enum class ArrowType : qint8 +enum class GrainlineArrowDirection : qint8 { atBoth, atFront, diff --git a/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp b/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp index 516c58db8..2d5f90316 100644 --- a/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp +++ b/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp @@ -100,13 +100,13 @@ void VGrainlineData::SetRotation(const QString& qsRot) } //--------------------------------------------------------------------------------------------------------------------- -ArrowType VGrainlineData::GetArrowType() const +GrainlineArrowDirection VGrainlineData::GetArrowType() const { return d->m_eArrowType; } //--------------------------------------------------------------------------------------------------------------------- -void VGrainlineData::SetArrowType(ArrowType eAT) +void VGrainlineData::SetArrowType(GrainlineArrowDirection eAT) { d->m_eArrowType = eAT; } diff --git a/src/libs/vpatterndb/floatItemData/vgrainlinedata.h b/src/libs/vpatterndb/floatItemData/vgrainlinedata.h index 4d31614ac..03af37e7e 100644 --- a/src/libs/vpatterndb/floatItemData/vgrainlinedata.h +++ b/src/libs/vpatterndb/floatItemData/vgrainlinedata.h @@ -62,8 +62,8 @@ public: QString GetRotation() const; void SetRotation(const QString& qsRot); - ArrowType GetArrowType() const; - void SetArrowType(ArrowType eAT); + GrainlineArrowDirection GetArrowType() const; + void SetArrowType(GrainlineArrowDirection eAT); quint32 CenterPin() const; void SetCenterPin(quint32 centerPin); diff --git a/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h b/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h index 1f64c4c53..31e361b67 100644 --- a/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h +++ b/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h @@ -48,7 +48,7 @@ public: VGrainlineDataPrivate() : m_qsLength(), m_dRotation(), - m_eArrowType(ArrowType::atBoth), + m_eArrowType(GrainlineArrowDirection::atBoth), m_centerPin(NULL_ID), m_topPin(NULL_ID), m_bottomPin(NULL_ID) @@ -71,7 +71,7 @@ public: /** @brief m_dRotation formula to calculate the rotation of grainline in [degrees] */ QString m_dRotation; /** @brief m_eArrowType type of arrow on the grainline */ - ArrowType m_eArrowType; + GrainlineArrowDirection m_eArrowType; /** @brief m_centerPin center pin id */ quint32 m_centerPin; /** @brief m_topPin top pin id */ diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 2b8bb41e6..6e0a8d9a9 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -2506,7 +2506,8 @@ VPiece DialogSeamAllowance::CreatePiece() const } piece.GetGrainlineGeometry().SetVisible(uiTabGrainline->groupBoxGrainline->isChecked()); - piece.GetGrainlineGeometry().SetArrowType(static_cast(uiTabGrainline->comboBoxArrow->currentIndex())); + piece.GetGrainlineGeometry().SetArrowType( + static_cast(uiTabGrainline->comboBoxArrow->currentIndex())); if (not flagGPin) { diff --git a/src/libs/vwidgets/vgrainlineitem.cpp b/src/libs/vwidgets/vgrainlineitem.cpp index 6eeab3794..8c12ae760 100644 --- a/src/libs/vwidgets/vgrainlineitem.cpp +++ b/src/libs/vwidgets/vgrainlineitem.cpp @@ -68,7 +68,7 @@ VGrainlineItem::VGrainlineItem(QGraphicsItem* pParent) m_ptFinish(), m_ptCenter(), m_dAngle(0), - m_eArrowType(ArrowType::atBoth), + m_eArrowType(GrainlineArrowDirection::atBoth), m_penWidth(LINE_PEN_WIDTH) { setAcceptHoverEvents(true); @@ -116,12 +116,12 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption m_dScale = GetScale(); qreal dArrLen = ARROW_LENGTH*m_dScale; - if (m_eArrowType != ArrowType::atRear) + if (m_eArrowType != GrainlineArrowDirection::atRear) { // first arrow pP->drawPolygon(FirstArrow(dArrLen)); } - if (m_eArrowType != ArrowType::atFront) + if (m_eArrowType != GrainlineArrowDirection::atFront) { // second arrow pP->drawPolygon(SecondArrow(dArrLen)); @@ -181,7 +181,7 @@ 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, ArrowType eAT) +void VGrainlineItem::UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, GrainlineArrowDirection eAT) { m_dRotation = qDegreesToRadians(dRotation); m_dLength = dLength; @@ -691,7 +691,7 @@ QPainterPath VGrainlineItem::MainShape() const path.closeSubpath(); const qreal dArrLen = ARROW_LENGTH*GetScale(); - if (m_eArrowType != ArrowType::atRear) + if (m_eArrowType != GrainlineArrowDirection::atRear) { // first arrow QPainterPath polyPath; @@ -700,7 +700,7 @@ QPainterPath VGrainlineItem::MainShape() const path.closeSubpath(); } - if (m_eArrowType != ArrowType::atFront) + if (m_eArrowType != GrainlineArrowDirection::atFront) { // second arrow QPainterPath polyPath; diff --git a/src/libs/vwidgets/vgrainlineitem.h b/src/libs/vwidgets/vgrainlineitem.h index a503ea7c2..1231cd433 100644 --- a/src/libs/vwidgets/vgrainlineitem.h +++ b/src/libs/vwidgets/vgrainlineitem.h @@ -43,7 +43,7 @@ public: virtual QPainterPath shape() const override; virtual void paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption, QWidget* pWidget) override; - void UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, ArrowType eAT); + void UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, GrainlineArrowDirection eAT); virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::GrainlineItem)}; @@ -83,7 +83,7 @@ private: QPointF m_ptFinish; QPointF m_ptCenter; qreal m_dAngle; - ArrowType m_eArrowType; + GrainlineArrowDirection m_eArrowType; int m_penWidth; qreal GetScale() const;