diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index faf18ed06..7a3d84f3f 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -51,6 +51,7 @@ #include "../vpatterndb/calculator.h" #include "../vpatterndb/vpatternpiecedata.h" #include "../vpatterndb/vpatterninfogeometry.h" +#include "../vpatterndb/vgrainlinegeometry.h" #include #include @@ -716,6 +717,25 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document qreal dRot = GetParametrDouble(element, VToolDetail::AttrRotation, "0"); detail.GetPatternInfo().SetRotation(dRot); } + else if (element.tagName() == TagGrainline) + { + detail.GetGrainlineGeometry().SetVisible(GetParametrBool(element, AttrVisible, falseStr)); + QPointF ptPos; + ptPos.setX(GetParametrDouble(element, AttrMx, "0")); + ptPos.setY(GetParametrDouble(element, AttrMy, "0")); + detail.GetGrainlineGeometry().SetPos(ptPos); + qreal dLength = GetParametrDouble(element, AttrLength, "0"); + detail.GetGrainlineGeometry().SetLength(dLength); + if (detail.GetGrainlineGeometry().IsVisible() == true) + { + qreal dRot = GetParametrDouble(element, VToolDetail::AttrRotation, "0"); + detail.GetGrainlineGeometry().SetRotation(dRot); + } + else + { + detail.GetGrainlineGeometry().SetRotation(0); + } + } } } VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Source::FromFile); diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index c55cd654e..6661ca5b6 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -27,5 +27,6 @@ schema/individual_measurements/v0.3.1.xsd schema/individual_measurements/v0.3.2.xsd schema/individual_measurements/v0.3.3.xsd + schema/pattern/v0.3.5.xsd diff --git a/src/libs/ifc/schema/pattern/v0.3.5.xsd b/src/libs/ifc/schema/pattern/v0.3.5.xsd new file mode 100644 index 000000000..db1b7232f --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.3.5.xsd @@ -0,0 +1,581 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 2d1cf5568..661387eb8 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -88,6 +88,7 @@ const QString VAbstractPattern::TagCompanyName = QStringLiteral("company"); const QString VAbstractPattern::TagSize = QStringLiteral("size"); const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate"); const QString VAbstractPattern::TagShowMeasurements = QStringLiteral("showMeasurements"); +const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline"); const QString VAbstractPattern::AttrName = QStringLiteral("name"); const QString VAbstractPattern::AttrVisible = QStringLiteral("visible"); diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 467eb6da5..116a31769 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -192,6 +192,7 @@ public: static const QString TagSize; static const QString TagShowDate; static const QString TagShowMeasurements; + static const QString TagGrainline; static const QString AttrName; static const QString AttrVisible; diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 33b652163..606555335 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.3.4"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.4.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.5"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.5.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -167,6 +167,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000303): return QStringLiteral("://schema/pattern/v0.3.3.xsd"); case (0x000304): + return QStringLiteral("://schema/pattern/v0.3.4.xsd"); + case (0x000305): return CurrentSchema; default: InvalidVersion(ver); @@ -250,6 +252,9 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000304), fileName); V_FALLTHROUGH case (0x000304): + ToV0_3_5(); + ValidateXML(XSDSchema(0x000305), fileName); + case (0x000305): break; default: break; @@ -410,6 +415,13 @@ void VPatternConverter::ToV0_3_4() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_3_5() +{ + SetVersion(QStringLiteral("0.3.5")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index b4af935ac..cca5e3c2f 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -55,10 +55,10 @@ public: // GCC 4.6 doesn't allow constexpr and const together #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406 static Q_DECL_CONSTEXPR int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 4); + static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 5); #else static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 4); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 5); #endif protected: @@ -93,6 +93,7 @@ private: void ToV0_3_2(); void ToV0_3_3(); void ToV0_3_4(); + void ToV0_3_5(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vpatterndb/vdetail.cpp b/src/libs/vpatterndb/vdetail.cpp index 555f54a83..209265950 100644 --- a/src/libs/vpatterndb/vdetail.cpp +++ b/src/libs/vpatterndb/vdetail.cpp @@ -47,6 +47,7 @@ #include "vdetail_p.h" #include "vnodedetail.h" #include "vpatternpiecedata.h" +#include "vgrainlinegeometry.h" class QPointF; @@ -580,6 +581,28 @@ const VPatternInfoGeometry& VDetail::GetPatternInfo() const return d->m_piPatternInfo; } +//--------------------------------------------------------------------------------------------------------------------- + +/** + * @brief VDetail::GetGrainlineGeometry full access to the grainline geometry object + * @return reference to grainline geometry object + */ +VGrainlineGeometry& VDetail::GetGrainlineGeometry() +{ + return d->m_glGrainline; +} + +//--------------------------------------------------------------------------------------------------------------------- + +/** + * @brief VDetail::GetGrainlineGeometry returns the read-only reference to the grainline geometry object + * @return reference to grainline geometry object + */ +const VGrainlineGeometry& VDetail::GetGrainlineGeometry() const +{ + return d->m_glGrainline; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief indexOfNode return index in list node using id object. diff --git a/src/libs/vpatterndb/vdetail.h b/src/libs/vpatterndb/vdetail.h index 626fb4a0f..4f14115c7 100644 --- a/src/libs/vpatterndb/vdetail.h +++ b/src/libs/vpatterndb/vdetail.h @@ -47,6 +47,7 @@ class VDetailData; class VNodeDetail; class VPatternInfoGeometry; class VPatternPieceData; +class VGrainlineGeometry; /** * @brief The VDetail class for path of object (points, arcs, splines). @@ -101,6 +102,8 @@ public: const VPatternPieceData& GetPatternPieceData() const; VPatternInfoGeometry& GetPatternInfo(); const VPatternInfoGeometry& GetPatternInfo() const; + VGrainlineGeometry& GetGrainlineGeometry(); + const VGrainlineGeometry& GetGrainlineGeometry() const; private: QSharedDataPointer d; diff --git a/src/libs/vpatterndb/vdetail_p.h b/src/libs/vpatterndb/vdetail_p.h index 7e256b9e5..d3692ca24 100644 --- a/src/libs/vpatterndb/vdetail_p.h +++ b/src/libs/vpatterndb/vdetail_p.h @@ -33,6 +33,7 @@ #include "vnodedetail.h" #include "vpatternpiecedata.h" #include "vpatterninfogeometry.h" +#include "vgrainlinegeometry.h" #include "../ifc/ifcdef.h" #include "../vmisc/diagnostic.h" @@ -52,7 +53,8 @@ public: VDetailData(const VDetailData &detail) :QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), mx(detail.mx), my(detail.my), - m_ppData(detail.m_ppData), m_piPatternInfo(detail.m_piPatternInfo), inLayout(detail.inLayout) + m_ppData(detail.m_ppData), m_piPatternInfo(detail.m_piPatternInfo), + m_glGrainline(detail.m_glGrainline), inLayout(detail.inLayout) {} ~VDetailData() {} @@ -73,6 +75,10 @@ public: VPatternPieceData m_ppData; /** @brief Pattern info coordinates */ VPatternInfoGeometry m_piPatternInfo; + /** + * @brief m_glGrainline grainline geometry object + */ + VGrainlineGeometry m_glGrainline; bool inLayout; diff --git a/src/libs/vpatterndb/vgrainlinegeometry.cpp b/src/libs/vpatterndb/vgrainlinegeometry.cpp new file mode 100644 index 000000000..4f64d6158 --- /dev/null +++ b/src/libs/vpatterndb/vgrainlinegeometry.cpp @@ -0,0 +1,101 @@ +/************************************************************************ + ** + ** @file vgrainlinegeometry.cpp + ** @author Bojan Kverh + ** @date September 06, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013-2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include + +#include "vgrainlinegeometry.h" + +//--------------------------------------------------------------------------------------------------------------------- + +VGrainlineGeometry::VGrainlineGeometry() + :m_ptPos(0, 0), m_dLength(0), m_dRotation(0), m_bVisible(true) +{} + +//--------------------------------------------------------------------------------------------------------------------- + +VGrainlineGeometry::~VGrainlineGeometry() +{} + +//--------------------------------------------------------------------------------------------------------------------- + +QPointF VGrainlineGeometry::GetPos() const +{ + return m_ptPos; +} + +//--------------------------------------------------------------------------------------------------------------------- + +void VGrainlineGeometry::SetPos(const QPointF &ptPos) +{ + m_ptPos = ptPos; +} + +//--------------------------------------------------------------------------------------------------------------------- + +qreal VGrainlineGeometry::GetLength() const +{ + return m_dLength; +} + +//--------------------------------------------------------------------------------------------------------------------- + +void VGrainlineGeometry::SetLength(qreal dLen) +{ + m_dLength = dLen; +} + +//--------------------------------------------------------------------------------------------------------------------- + +qreal VGrainlineGeometry::GetRotation() const +{ + return m_dRotation; +} + +//--------------------------------------------------------------------------------------------------------------------- + +void VGrainlineGeometry::SetRotation(qreal dRot) +{ + m_dRotation = dRot; +} + +//--------------------------------------------------------------------------------------------------------------------- + +bool VGrainlineGeometry::IsVisible() const +{ + return m_bVisible; +} + +//--------------------------------------------------------------------------------------------------------------------- + +void VGrainlineGeometry::SetVisible(bool bVisible) +{ + m_bVisible = bVisible; +} + +//--------------------------------------------------------------------------------------------------------------------- + diff --git a/src/libs/vpatterndb/vgrainlinegeometry.h b/src/libs/vpatterndb/vgrainlinegeometry.h new file mode 100644 index 000000000..ae7fad4b6 --- /dev/null +++ b/src/libs/vpatterndb/vgrainlinegeometry.h @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vgrainlinegeometry.h + ** @author Bojan Kverh + ** @date September 06, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013-2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VGRAINLINEGEOMETRY_H +#define VGRAINLINEGEOMETRY_H + +#include + +class QPointF; + +/** + * @brief The VGrainlineGeometry class holds information about a grainline like + * position, size, rotation and visibility + */ +class VGrainlineGeometry +{ +public: + VGrainlineGeometry(); + ~VGrainlineGeometry(); + + // methods, which set and return values of different parameters + QPointF GetPos() const; + void SetPos(const QPointF& ptPos); + qreal GetLength() const; + void SetLength(qreal dLen); + qreal GetRotation() const; + void SetRotation(qreal dRot); + bool IsVisible() const; + void SetVisible(bool bVisible); + +private: + /** + * @brief m_ptPos position of grainline's center + */ + QPointF m_ptPos; + /** + * @brief m_dLength total length of grainline + */ + qreal m_dLength; + /** + * @brief m_dRotation rotation of grainline in [degrees] + */ + qreal m_dRotation; + /** + * @brief m_bVisible visibility flag + */ + bool m_bVisible; +}; + +#endif // VGRAINLINEGEOMETRY_H + diff --git a/src/libs/vpatterndb/vpatterndb.pri b/src/libs/vpatterndb/vpatterndb.pri index b2e055a6e..7ea6f076d 100644 --- a/src/libs/vpatterndb/vpatterndb.pri +++ b/src/libs/vpatterndb/vpatterndb.pri @@ -19,7 +19,8 @@ SOURCES += \ $$PWD/variables/vvariable.cpp \ $$PWD/vformula.cpp \ $$PWD/vpatternpiecedata.cpp \ - $$PWD/vpatterninfogeometry.cpp + $$PWD/vpatterninfogeometry.cpp \ + $$PWD/vgrainlinegeometry.cpp win32-msvc*:SOURCES += $$PWD/stable.cpp @@ -53,4 +54,5 @@ HEADERS += \ $$PWD/variables/vvariable_p.h \ $$PWD/vformula.h \ $$PWD/vpatternpiecedata.h \ - $$PWD/vpatterninfogeometry.h + $$PWD/vpatterninfogeometry.h \ + $$PWD/vgrainlinegeometry.h diff --git a/src/libs/vpatterndb/vpatterndb.pro b/src/libs/vpatterndb/vpatterndb.pro index 10c0b507f..02883e19f 100644 --- a/src/libs/vpatterndb/vpatterndb.pro +++ b/src/libs/vpatterndb/vpatterndb.pro @@ -67,3 +67,5 @@ CONFIG(release, debug|release){ } include (../libs.pri) + +HEADERS += diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index 6ee916db0..8334eae68 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -76,7 +76,7 @@ class QWidget; */ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true), - m_bAddMode(true), m_qslMaterials(), m_qslPlacements(), m_conMCP(), m_oldData(), m_oldGeom() + m_bAddMode(true), m_qslMaterials(), m_qslPlacements(), m_conMCP(), m_oldData(), m_oldGeom(), m_oldGrainline() { ui.setupUi(this); @@ -150,7 +150,9 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge connect(ui.pushButtonRemove, &QPushButton::clicked, this, &DialogDetail::Remove); connect(ui.listWidgetMCP, &QListWidget::itemClicked, this, &DialogDetail::SetEditMode); connect(ui.comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogDetail::MaterialChanged); + connect(ui.checkBoxGrainline, &QCheckBox::toggled, this, &DialogDetail::EnableGrainlineRotation); SetAddMode(); + EnableGrainlineRotation(); ui.tabWidget->setCurrentIndex(0); } @@ -463,6 +465,12 @@ VDetail DialogDetail::CreateDetail() const detail.GetPatternInfo() = m_oldGeom; detail.GetPatternInfo().SetVisible(ui.checkBoxPattern->isChecked()); + detail.GetGrainlineGeometry() = m_oldGrainline; + detail.GetGrainlineGeometry().SetVisible(ui.checkBoxGrainline->isChecked()); + if (ui.checkBoxGrainline->isChecked() == true) + { + detail.GetGrainlineGeometry().SetRotation(ui.spinBoxGrainlineRotation->value()); + } return detail; } @@ -532,10 +540,16 @@ void DialogDetail::setDetail(const VDetail &value) } UpdateList(); + + ui.checkBoxGrainline->setChecked(detail.GetGrainlineGeometry().IsVisible()); + ui.spinBoxGrainlineRotation->setValue(detail.GetGrainlineGeometry().GetRotation()); + m_oldData = detail.GetPatternPieceData(); m_oldGeom = detail.GetPatternInfo(); + m_oldGrainline = detail.GetGrainlineGeometry(); ValidObjects(DetailIsValid()); + EnableGrainlineRotation(); } //--------------------------------------------------------------------------------------------------------------------- @@ -847,3 +861,9 @@ void DialogDetail::SetEditMode() m_bAddMode = false; } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogDetail::EnableGrainlineRotation() +{ + ui.spinBoxGrainlineRotation->setEnabled(ui.checkBoxGrainline->isChecked()); +} diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.h b/src/libs/vtools/dialogs/tools/dialogdetail.h index 26dbe48a0..d56787390 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.h +++ b/src/libs/vtools/dialogs/tools/dialogdetail.h @@ -40,6 +40,7 @@ #include "../vpatterndb/vdetail.h" #include "../vpatterndb/vpatterninfogeometry.h" #include "../vpatterndb/vpatternpiecedata.h" +#include "../vpatterndb/vgrainlinegeometry.h" #include "dialogtool.h" #include "ui_dialogdetail.h" @@ -107,6 +108,7 @@ private: MCPContainer m_conMCP; VPatternPieceData m_oldData; VPatternInfoGeometry m_oldGeom; + VGrainlineGeometry m_oldGrainline; bool DetailIsValid() const; @@ -126,6 +128,7 @@ private: private slots: void SetAddMode(); void SetEditMode(); + void EnableGrainlineRotation(); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.ui b/src/libs/vtools/dialogs/tools/dialogdetail.ui index be5300e33..ef40167f3 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.ui +++ b/src/libs/vtools/dialogs/tools/dialogdetail.ui @@ -7,7 +7,7 @@ 0 0 581 - 468 + 478 @@ -24,7 +24,7 @@ - 0 + 2 @@ -318,7 +318,8 @@ - .. + + @@ -332,7 +333,8 @@ - .. + + @@ -526,6 +528,50 @@ + + + SizeVerCursor + + + Grainline + + + + + 10 + 10 + 291 + 62 + + + + + + + Rotation: + + + + + + + ° + + + 359 + + + + + + + Grainline visible + + + + + + @@ -539,11 +585,8 @@ - buttonBox - tabWidget - lineEditLetter lineEditName comboBoxMaterial spinBoxCutNumber @@ -551,8 +594,6 @@ pushButtonAdd pushButtonCancel pushButtonRemove - listWidgetMCP - buttonBox toolButtonUp listWidget checkBoxClosed @@ -563,6 +604,13 @@ checkBoxSeams doubleSpinBoxSeams toolButtonDown + tabWidget + checkBoxForbidFlipping + checkBoxDetail + checkBoxPattern + lineEditLetter + checkBoxGrainline + spinBoxGrainlineRotation diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index ed036006c..c8ad14fa8 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -435,6 +435,7 @@ void VToolDetail::AddToFile() doc->SetAttribute(domElement, AttrWidth, detail.getWidth()); doc->SetAttribute(domElement, AttrForbidFlipping, static_cast(detail.getForbidFlipping())); + // detail data QDomElement domData = doc->createElement(VAbstractPattern::TagData); const VPatternPieceData& data = detail.GetPatternPieceData(); doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter()); @@ -461,6 +462,7 @@ void VToolDetail::AddToFile() } domElement.appendChild(domData); + // pattern info domData = doc->createElement(VAbstractPattern::TagPatternInfo); const VPatternInfoGeometry& geom = detail.GetPatternInfo(); doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsVisible() == true? trueStr : falseStr); @@ -471,6 +473,16 @@ void VToolDetail::AddToFile() doc->SetAttribute(domData, AttrFont, geom.GetFontSize()); doc->SetAttribute(domData, AttrRotation, geom.GetRotation()); + // grainline + domData = doc->createElement(VAbstractPattern::TagGrainline); + const VGrainlineGeometry& glGeom = detail.GetGrainlineGeometry(); + doc->SetAttribute(domData, VAbstractPattern::AttrVisible, glGeom.IsVisible() == true? trueStr : falseStr); + doc->SetAttribute(domData, AttrMx, glGeom.GetPos().x()); + doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y()); + doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); + doc->SetAttribute(domData, AttrRotation, glGeom.GetRotation()); + + // nodes for (int i = 0; i < detail.CountNode(); ++i) { AddNode(doc, domElement, detail.at(i)); @@ -497,6 +509,7 @@ void VToolDetail::RefreshDataInFile() doc->SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); doc->RemoveAllChildren(domElement); + // detail data QDomElement domData = doc->createElement(VAbstractPattern::TagData); const VPatternPieceData& data = det.GetPatternPieceData(); doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter()); @@ -527,6 +540,7 @@ void VToolDetail::RefreshDataInFile() } domElement.appendChild(domData); + // pattern info domData = doc->createElement(VAbstractPattern::TagPatternInfo); const VPatternInfoGeometry& geom = det.GetPatternInfo(); doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsVisible() == true? trueStr : falseStr); @@ -537,6 +551,16 @@ void VToolDetail::RefreshDataInFile() doc->SetAttribute(domData, AttrFont, geom.GetFontSize()); doc->SetAttribute(domData, AttrRotation, geom.GetRotation()); + // grainline + domData = doc->createElement(VAbstractPattern::TagGrainline); + const VGrainlineGeometry& glGeom = det.GetGrainlineGeometry(); + doc->SetAttribute(domData, VAbstractPattern::AttrVisible, glGeom.IsVisible() == true? trueStr : falseStr); + doc->SetAttribute(domData, AttrMx, glGeom.GetPos().x()); + doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y()); + doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); + doc->SetAttribute(domData, AttrRotation, glGeom.GetRotation()); + + // nodes for (int i = 0; i < det.CountNode(); ++i) { AddNode(doc, domElement, det.at(i)); diff --git a/src/libs/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index 7da804348..11a418c52 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -38,6 +38,7 @@ #include "../vmisc/def.h" #include "../vpatterndb/vpatterninfogeometry.h" #include "../vpatterndb/vpatternpiecedata.h" +#include "../vpatterndb/vgrainlinegeometry.h" #include "../tools/vtooldetail.h" #include "vundocommand.h" @@ -69,6 +70,8 @@ void SaveDetailOptions::undo() doc->RemoveAllChildren(domElement); SavePatternPieceData(domElement, oldDet); SavePatternInfo(domElement, oldDet); + SaveGrainline(domElement, oldDet); + for (int i = 0; i < oldDet.CountNode(); ++i) { VToolDetail::AddNode(doc, domElement, oldDet.at(i)); @@ -95,6 +98,7 @@ void SaveDetailOptions::redo() doc->RemoveAllChildren(domElement); SavePatternPieceData(domElement, newDet); SavePatternInfo(domElement, newDet); + SaveGrainline(domElement, newDet); for (int i = 0; i < newDet.CountNode(); ++i) { @@ -194,3 +198,17 @@ void SaveDetailOptions::SavePatternInfo(QDomElement &domElement, const VDetail & domElement.appendChild(domData); } + +//--------------------------------------------------------------------------------------------------------------------- +void SaveDetailOptions::SaveGrainline(QDomElement &domElement, const VDetail &det) +{ + QDomElement domData = doc->createElement(VAbstractPattern::TagGrainline); + const VGrainlineGeometry& glGeom = det.GetGrainlineGeometry(); + doc->SetAttribute(domData, VAbstractPattern::AttrVisible, glGeom.IsVisible() == true? trueStr : falseStr); + doc->SetAttribute(domData, AttrMx, glGeom.GetPos().x()); + doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y()); + doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); + doc->SetAttribute(domData, VToolDetail::AttrRotation, glGeom.GetRotation()); + + domElement.appendChild(domData); +} diff --git a/src/libs/vtools/undocommands/savedetailoptions.h b/src/libs/vtools/undocommands/savedetailoptions.h index d1ff979d9..5b4cbc058 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.h +++ b/src/libs/vtools/undocommands/savedetailoptions.h @@ -65,6 +65,7 @@ private: void SaveDet(QDomElement &domElement, const VDetail &det); void SavePatternPieceData(QDomElement &domElement, const VDetail &det); void SavePatternInfo(QDomElement &domElement, const VDetail &det); + void SaveGrainline(QDomElement &domElement, const VDetail &det); }; //---------------------------------------------------------------------------------------------------------------------