From 57d6d79a53479ac5be594c9ea06b0b4e8037b2be Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 23 Apr 2019 17:42:09 +0300 Subject: [PATCH] New placelabel shape Circle. --HG-- branch : develop --- ChangeLog.txt | 1 + src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.8.4.xsd | 1167 +++++++++++++++++ src/libs/ifc/xml/vpatternconverter.cpp | 23 +- src/libs/ifc/xml/vpatternconverter.h | 3 +- src/libs/vdxf/vdxfengine.cpp | 6 +- src/libs/vgeometry/vgeometrydef.h | 3 +- src/libs/vgeometry/vplacelabelitem.cpp | 16 + .../dialogs/tools/piece/dialogplacelabel.cpp | 1 + .../tools/piece/dialogseamallowance.cpp | 5 + 10 files changed, 1218 insertions(+), 8 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.8.4.xsd diff --git a/ChangeLog.txt b/ChangeLog.txt index c321536b6..c78561eaa 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -14,6 +14,7 @@ - Extend Label language to support Czech alphabet. - [#916] Improve layout generation. - [#965] Control passmark length with formula. +- New placelabel shape Circle. # Version 0.6.2 (unreleased) - [#903] Bug in tool Cut Spline path. diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 94fef1188..a9c546d2c 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -55,6 +55,7 @@ schema/pattern/v0.8.1.xsd schema/pattern/v0.8.2.xsd schema/pattern/v0.8.3.xsd + schema/pattern/v0.8.4.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.8.4.xsd b/src/libs/ifc/schema/pattern/v0.8.4.xsd new file mode 100644 index 000000000..a9b06e259 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.8.4.xsd @@ -0,0 +1,1167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 25e0061a9..a32237343 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -59,8 +59,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.3"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.3.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.4"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.4.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -233,7 +233,8 @@ QString VPatternConverter::XSDSchema(int ver) const std::make_pair(FORMAT_VERSION(0, 8, 0), QStringLiteral("://schema/pattern/v0.8.0.xsd")), std::make_pair(FORMAT_VERSION(0, 8, 1), QStringLiteral("://schema/pattern/v0.8.1.xsd")), std::make_pair(FORMAT_VERSION(0, 8, 2), QStringLiteral("://schema/pattern/v0.8.2.xsd")), - std::make_pair(FORMAT_VERSION(0, 8, 3), CurrentSchema) + std::make_pair(FORMAT_VERSION(0, 8, 3), QStringLiteral("://schema/pattern/v0.8.3.xsd")), + std::make_pair(FORMAT_VERSION(0, 8, 4), CurrentSchema) }; if (schemas.contains(ver)) @@ -466,6 +467,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 3)), m_convertedFileName); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 3)): + ToV0_8_4(); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 4)), m_convertedFileName); + Q_FALLTHROUGH(); + case (FORMAT_VERSION(0, 8, 4)): break; default: InvalidVersion(m_ver); @@ -483,7 +488,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() bool VPatternConverter::IsReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 3), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 4), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -1083,6 +1088,16 @@ void VPatternConverter::ToV0_8_3() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_8_4() +{ + // TODO. Delete if minimal supported version is 0.8.4 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 4), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.8.4")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 33eb1d7f8..b4be45a63 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -53,7 +53,7 @@ public: static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4); - static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 3); + static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 4); protected: virtual int MinVer() const override; @@ -126,6 +126,7 @@ private: void ToV0_8_1(); void ToV0_8_2(); void ToV0_8_3(); + void ToV0_8_4(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index dc800d65f..06b2e750c 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -700,7 +700,8 @@ void VDxfEngine::ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece & const QVector labels = detail.GetPlaceLabels(); for(auto &label : labels) { - if (label.type != PlaceLabelType::Doubletree && label.type != PlaceLabelType::Button) + if (label.type != PlaceLabelType::Doubletree && label.type != PlaceLabelType::Button + && label.type != PlaceLabelType::Circle) { for(auto &p : qAsConst(label.shape)) { @@ -793,7 +794,8 @@ void VDxfEngine::ExportAAMADrill(dx_ifaceBlock *detailBlock, const VLayoutPiece for(auto &label : labels) { - if (label.type == PlaceLabelType::Doubletree || label.type == PlaceLabelType::Button) + if (label.type == PlaceLabelType::Doubletree || label.type == PlaceLabelType::Button + || label.type == PlaceLabelType::Circle) { DRW_Point *point = new DRW_Point(); point->basePoint = DRW_Coord(FromPixel(label.center.x(), varInsunits), diff --git a/src/libs/vgeometry/vgeometrydef.h b/src/libs/vgeometry/vgeometrydef.h index 5faea0bdd..2132d4838 100644 --- a/src/libs/vgeometry/vgeometrydef.h +++ b/src/libs/vgeometry/vgeometrydef.h @@ -57,7 +57,8 @@ enum class PlaceLabelType : unsigned char Corner = 5, Triangle = 6, Hshaped = 7, - Button = 8 + Button = 8, + Circle = 9 }; typedef QVector PlaceLabelImg; diff --git a/src/libs/vgeometry/vplacelabelitem.cpp b/src/libs/vgeometry/vplacelabelitem.cpp index 22d7b5921..da5a320fb 100644 --- a/src/libs/vgeometry/vplacelabelitem.cpp +++ b/src/libs/vgeometry/vplacelabelitem.cpp @@ -341,6 +341,20 @@ PlaceLabelImg VPlaceLabelItem::LabelShape() const return PlaceLabelImg({t.map(shape1), t.map(shape2), t.map(shape3)}); }; + auto CircleShape = [t, this]() + { + const qreal radius = qMin(d->wValue/2.0, d->hValue/2.0); + VArc arc(*this, radius, 0, 360); + arc.SetApproximationScale(10); + QPolygonF circle(arc.GetPoints()); + if (not circle.isClosed() && not circle.isEmpty()) + { + circle << circle.first(); + } + + return PlaceLabelImg({t.map(circle)}); + }; + QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") switch(d->type) @@ -363,6 +377,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") return HshapedShape(); case PlaceLabelType::Button: return ButtonShape(); + case PlaceLabelType::Circle: + return CircleShape(); } QT_WARNING_POP diff --git a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp index ed88977c3..84ec055fb 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp @@ -499,6 +499,7 @@ void DialogPlaceLabel::FillPlaceLabelTypes() ui->comboBoxLabelType->addItem(tr("Triangle"), static_cast(PlaceLabelType::Triangle)); ui->comboBoxLabelType->addItem(tr("H-shaped"), static_cast(PlaceLabelType::Hshaped)); ui->comboBoxLabelType->addItem(tr("Button"), static_cast(PlaceLabelType::Button)); + ui->comboBoxLabelType->addItem(tr("Circle"), static_cast(PlaceLabelType::Circle)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 7f8f05b55..1f3981c36 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -856,6 +856,7 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos) QAction *actionTriangle = InitAction(tr("Triangle"), PlaceLabelType::Triangle); QAction *actionHshaped = InitAction(tr("H-shaped"), PlaceLabelType::Hshaped); QAction *actionButton = InitAction(tr("Button"), PlaceLabelType::Button); + QAction *actionCircle = InitAction(tr("Circle"), PlaceLabelType::Circle); menu->addSeparator(); QAction *actionDelete = menu->addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete")); @@ -917,6 +918,10 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos) { SaveType(PlaceLabelType::Button); } + else if (selectedAction == actionCircle) + { + SaveType(PlaceLabelType::Circle); + } } //---------------------------------------------------------------------------------------------------------------------