diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 0942de9d2..c0ea2580d 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -1852,6 +1852,8 @@ void VToolOptionsPropertyBrowser::ChangeDataToolMove(VPE::VProperty *property) case 42: // AttrRotationAngle i->SetFormulaRotationAngle(value.value()); break; + case 11: // AttrCenter (read only) + break; default: qWarning()<<"Unknown property type. id = "<GetFormulaAngle(), AttrAngle); AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength); AddPropertyFormula(tr("Rotation angle:"), i->GetFormulaRotationAngle(), AttrRotationAngle); + AddPropertyParentPointName(i->OriginPointName(), tr("Rotation origin point:"), AttrCenter); } //--------------------------------------------------------------------------------------------------------------------- @@ -3240,6 +3243,10 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolMove() QVariant valueRotationAngle; valueRotationAngle.setValue(i->GetFormulaRotationAngle()); idToProperty[AttrRotationAngle]->setValue(valueRotationAngle); + + QVariant valueRotationOriginPoint; + valueRotationOriginPoint.setValue(i->OriginPointName()); + idToProperty[AttrCenter]->setValue(valueRotationOriginPoint); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index a79aaee54..896ff7ac7 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -3162,6 +3162,7 @@ void VPattern::ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement, initData.formulaLength = GetParametrString(domElement, AttrLength, "0"); const QString len = initData.formulaLength;//need for saving fixed formula; initData.suffix = GetParametrString(domElement, AttrSuffix, ""); + initData.rotationOrigin = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); VAbstractOperation::ExtractData(domElement, initData); diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 7ebb4551d..8679ff113 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -44,6 +44,7 @@ schema/pattern/v0.7.0.xsd schema/pattern/v0.7.1.xsd schema/pattern/v0.7.2.xsd + schema/pattern/v0.7.3.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.7.3.xsd b/src/libs/ifc/schema/pattern/v0.7.3.xsd new file mode 100644 index 000000000..db394df4d --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.7.3.xsd @@ -0,0 +1,1044 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 6f53b07f0..0c356ddae 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.7.2"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.2.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.3"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.3.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -173,98 +173,62 @@ VPatternConverter::VPatternConverter(const QString &fileName) //--------------------------------------------------------------------------------------------------------------------- QString VPatternConverter::XSDSchema(int ver) const { - switch (ver) + QHash schemas = { - case (0x000100): - return QStringLiteral("://schema/pattern/v0.1.0.xsd"); - case (0x000101): - return QStringLiteral("://schema/pattern/v0.1.1.xsd"); - case (0x000102): - return QStringLiteral("://schema/pattern/v0.1.2.xsd"); - case (0x000103): - return QStringLiteral("://schema/pattern/v0.1.3.xsd"); - case (0x000104): - return QStringLiteral("://schema/pattern/v0.1.4.xsd"); - case (0x000200): - return QStringLiteral("://schema/pattern/v0.2.0.xsd"); - case (0x000201): - return QStringLiteral("://schema/pattern/v0.2.1.xsd"); - case (0x000202): - return QStringLiteral("://schema/pattern/v0.2.2.xsd"); - case (0x000203): - return QStringLiteral("://schema/pattern/v0.2.3.xsd"); - case (0x000204): - return QStringLiteral("://schema/pattern/v0.2.4.xsd"); - case (0x000205): - return QStringLiteral("://schema/pattern/v0.2.5.xsd"); - case (0x000206): - return QStringLiteral("://schema/pattern/v0.2.6.xsd"); - case (0x000207): - return QStringLiteral("://schema/pattern/v0.2.7.xsd"); - case (0x000300): - return QStringLiteral("://schema/pattern/v0.3.0.xsd"); - case (0x000301): - return QStringLiteral("://schema/pattern/v0.3.1.xsd"); - case (0x000302): - return QStringLiteral("://schema/pattern/v0.3.2.xsd"); - case (0x000303): - return QStringLiteral("://schema/pattern/v0.3.3.xsd"); - case (0x000304): - return QStringLiteral("://schema/pattern/v0.3.4.xsd"); - case (0x000305): - return QStringLiteral("://schema/pattern/v0.3.5.xsd"); - case (0x000306): - return QStringLiteral("://schema/pattern/v0.3.6.xsd"); - case (0x000307): - return QStringLiteral("://schema/pattern/v0.3.7.xsd"); - case (0x000308): - return QStringLiteral("://schema/pattern/v0.3.8.xsd"); - case (0x000309): - return QStringLiteral("://schema/pattern/v0.3.9.xsd"); - case (0x000400): - return QStringLiteral("://schema/pattern/v0.4.0.xsd"); - case (0x000401): - return QStringLiteral("://schema/pattern/v0.4.1.xsd"); - case (0x000402): - return QStringLiteral("://schema/pattern/v0.4.2.xsd"); - case (0x000403): - return QStringLiteral("://schema/pattern/v0.4.3.xsd"); - case (0x000404): - return QStringLiteral("://schema/pattern/v0.4.4.xsd"); - case (0x000405): - return QStringLiteral("://schema/pattern/v0.4.5.xsd"); - case (0x000406): - return QStringLiteral("://schema/pattern/v0.4.6.xsd"); - case (0x000407): - return QStringLiteral("://schema/pattern/v0.4.7.xsd"); - case (0x000408): - return QStringLiteral("://schema/pattern/v0.4.8.xsd"); - case (0x000500): - return QStringLiteral("://schema/pattern/v0.5.0.xsd"); - case (0x000501): - return QStringLiteral("://schema/pattern/v0.5.1.xsd"); - case (0x000600): - return QStringLiteral("://schema/pattern/v0.6.0.xsd"); - case (0x000601): - return QStringLiteral("://schema/pattern/v0.6.1.xsd"); - case (0x000602): - return QStringLiteral("://schema/pattern/v0.6.2.xsd"); - case (0x000603): - return QStringLiteral("://schema/pattern/v0.6.3.xsd"); - case (0x000604): - return QStringLiteral("://schema/pattern/v0.6.4.xsd"); - case (0x000605): - return QStringLiteral("://schema/pattern/v0.6.5.xsd"); - case (0x000606): - return QStringLiteral("://schema/pattern/v0.6.6.xsd"); - case (0x000700): - return QStringLiteral("://schema/pattern/v0.7.0.xsd"); - case (0x000701): - return QStringLiteral("://schema/pattern/v0.7.1.xsd"); - case (0x000702): - return CurrentSchema; - default: - InvalidVersion(ver); + std::make_pair(0x000100, QStringLiteral("://schema/pattern/v0.1.0.xsd")), + std::make_pair(0x000101, QStringLiteral("://schema/pattern/v0.1.1.xsd")), + std::make_pair(0x000102, QStringLiteral("://schema/pattern/v0.1.2.xsd")), + std::make_pair(0x000103, QStringLiteral("://schema/pattern/v0.1.3.xsd")), + std::make_pair(0x000104, QStringLiteral("://schema/pattern/v0.1.4.xsd")), + std::make_pair(0x000200, QStringLiteral("://schema/pattern/v0.2.0.xsd")), + std::make_pair(0x000201, QStringLiteral("://schema/pattern/v0.2.1.xsd")), + std::make_pair(0x000202, QStringLiteral("://schema/pattern/v0.2.2.xsd")), + std::make_pair(0x000203, QStringLiteral("://schema/pattern/v0.2.3.xsd")), + std::make_pair(0x000204, QStringLiteral("://schema/pattern/v0.2.4.xsd")), + std::make_pair(0x000205, QStringLiteral("://schema/pattern/v0.2.5.xsd")), + std::make_pair(0x000206, QStringLiteral("://schema/pattern/v0.2.6.xsd")), + std::make_pair(0x000207, QStringLiteral("://schema/pattern/v0.2.7.xsd")), + std::make_pair(0x000300, QStringLiteral("://schema/pattern/v0.3.0.xsd")), + std::make_pair(0x000301, QStringLiteral("://schema/pattern/v0.3.1.xsd")), + std::make_pair(0x000302, QStringLiteral("://schema/pattern/v0.3.2.xsd")), + std::make_pair(0x000303, QStringLiteral("://schema/pattern/v0.3.3.xsd")), + std::make_pair(0x000304, QStringLiteral("://schema/pattern/v0.3.4.xsd")), + std::make_pair(0x000305, QStringLiteral("://schema/pattern/v0.3.5.xsd")), + std::make_pair(0x000306, QStringLiteral("://schema/pattern/v0.3.6.xsd")), + std::make_pair(0x000307, QStringLiteral("://schema/pattern/v0.3.7.xsd")), + std::make_pair(0x000308, QStringLiteral("://schema/pattern/v0.3.8.xsd")), + std::make_pair(0x000309, QStringLiteral("://schema/pattern/v0.3.9.xsd")), + std::make_pair(0x000400, QStringLiteral("://schema/pattern/v0.4.0.xsd")), + std::make_pair(0x000401, QStringLiteral("://schema/pattern/v0.4.1.xsd")), + std::make_pair(0x000402, QStringLiteral("://schema/pattern/v0.4.2.xsd")), + std::make_pair(0x000403, QStringLiteral("://schema/pattern/v0.4.3.xsd")), + std::make_pair(0x000404, QStringLiteral("://schema/pattern/v0.4.4.xsd")), + std::make_pair(0x000405, QStringLiteral("://schema/pattern/v0.4.5.xsd")), + std::make_pair(0x000406, QStringLiteral("://schema/pattern/v0.4.6.xsd")), + std::make_pair(0x000407, QStringLiteral("://schema/pattern/v0.4.7.xsd")), + std::make_pair(0x000408, QStringLiteral("://schema/pattern/v0.4.8.xsd")), + std::make_pair(0x000500, QStringLiteral("://schema/pattern/v0.5.0.xsd")), + std::make_pair(0x000501, QStringLiteral("://schema/pattern/v0.5.1.xsd")), + std::make_pair(0x000600, QStringLiteral("://schema/pattern/v0.6.0.xsd")), + std::make_pair(0x000601, QStringLiteral("://schema/pattern/v0.6.1.xsd")), + std::make_pair(0x000602, QStringLiteral("://schema/pattern/v0.6.2.xsd")), + std::make_pair(0x000603, QStringLiteral("://schema/pattern/v0.6.3.xsd")), + std::make_pair(0x000604, QStringLiteral("://schema/pattern/v0.6.4.xsd")), + std::make_pair(0x000605, QStringLiteral("://schema/pattern/v0.6.5.xsd")), + std::make_pair(0x000606, QStringLiteral("://schema/pattern/v0.6.6.xsd")), + std::make_pair(0x000700, QStringLiteral("://schema/pattern/v0.7.0.xsd")), + std::make_pair(0x000701, QStringLiteral("://schema/pattern/v0.7.1.xsd")), + std::make_pair(0x000702, QStringLiteral("://schema/pattern/v0.7.2.xsd")), + std::make_pair(0x000703, CurrentSchema) + }; + + if (schemas.contains(ver)) + { + return schemas.value(ver); + } + else + { + InvalidVersion(ver); } } @@ -446,6 +410,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000702), m_convertedFileName); V_FALLTHROUGH case (0x000702): + ToV0_7_3(); + ValidateXML(XSDSchema(0x000703), m_convertedFileName); + V_FALLTHROUGH + case (0x000703): break; default: InvalidVersion(m_ver); @@ -463,7 +431,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() bool VPatternConverter::IsReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 2), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 3), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -957,6 +925,16 @@ void VPatternConverter::ToV0_7_2() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_7_3() +{ + // TODO. Delete if minimal supported version is 0.7.3 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 3), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.7.3")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 3f3e9fef9..47aa9a946 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 = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 2); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 3); protected: virtual int MinVer() const Q_DECL_OVERRIDE; @@ -115,6 +115,7 @@ private: void ToV0_7_0(); void ToV0_7_1(); void ToV0_7_2(); + void ToV0_7_3(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vtools/dialogs/tools/dialogmove.cpp b/src/libs/vtools/dialogs/tools/dialogmove.cpp index 9a406e65c..c11575ba8 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.cpp +++ b/src/libs/vtools/dialogs/tools/dialogmove.cpp @@ -81,7 +81,8 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent) objects(), stage1(true), stage2(false), - m_suffix() + m_suffix(), + optionalRotationOrigin(false) { ui->setupUi(this); @@ -107,6 +108,12 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent) InitOkCancelApply(ui); + FillComboBoxPoints(ui->comboBoxRotationOriginPoint); + + ui->comboBoxRotationOriginPoint->blockSignals(true); + ui->comboBoxRotationOriginPoint->addItem(tr("Center point"), NULL_ID); + ui->comboBoxRotationOriginPoint->blockSignals(false); + flagName = true; CheckState(); @@ -122,6 +129,8 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent) connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit); vis = new VisToolMove(data); + + SetRotationOrigPointId(NULL_ID); } //--------------------------------------------------------------------------------------------------------------------- @@ -215,6 +224,21 @@ void DialogMove::SetSuffix(const QString &value) ui->lineEditSuffix->setText(value); } +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogMove::GetRotationOrigPointId() const +{ + return getCurrentObjectId(ui->comboBoxRotationOriginPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogMove::SetRotationOrigPointId(const quint32 &value) +{ + ChangeCurrentData(ui->comboBoxRotationOriginPoint, value); + VisToolMove *operation = qobject_cast(vis); + SCASSERT(operation != nullptr) + operation->SetRotationOriginPointId(value); +} + //--------------------------------------------------------------------------------------------------------------------- QVector DialogMove::GetObjects() const { @@ -278,24 +302,49 @@ void DialogMove::ShowDialog(bool click) VisToolMove *operation = qobject_cast(vis); SCASSERT(operation != nullptr) - SetAngle(qApp->TrVars()->FormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator())); - SetLength(qApp->TrVars()->FormulaFromUser(formulaLength, qApp->Settings()->GetOsSeparator())); - SetRotationAngle(operation->RotationAngle()); - setModal(true); - emit ToolTip(""); - timerAngle->start(); - timerRotationAngle->start(); - timerLength->start(); - show(); + if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) + { + if (not optionalRotationOrigin) + { + operation->SetRotationOriginPointId(NULL_ID); + SetObject(NULL_ID, ui->comboBoxRotationOriginPoint, ""); + operation->RefreshGeometry(); + } + optionalRotationOrigin = false; // Handled, next click on empty filed will disable selection + } + else + { + SetAngle(qApp->TrVars()->FormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator())); + SetLength(qApp->TrVars()->FormulaFromUser(formulaLength, qApp->Settings()->GetOsSeparator())); + SetRotationAngle(operation->RotationAngle()); + setModal(true); + emit ToolTip(""); + timerAngle->start(); + timerRotationAngle->start(); + timerLength->start(); + show(); + } } } //--------------------------------------------------------------------------------------------------------------------- void DialogMove::ChosenObject(quint32 id, const SceneObject &type) { - Q_UNUSED(id) - Q_UNUSED(type) - // do nothing + if (not stage1 && stage2 && prepare)// After first choose we ignore all objects + { + if (type == SceneObject::Point && QGuiApplication::keyboardModifiers() == Qt::ControlModifier) + { + if (SetObject(id, ui->comboBoxRotationOriginPoint, "")) + { + VisToolMove *operation = qobject_cast(vis); + SCASSERT(operation != nullptr) + + operation->SetRotationOriginPointId(id); + operation->RefreshGeometry(); + optionalRotationOrigin = true; + } + } + } } //--------------------------------------------------------------------------------------------------------------------- @@ -478,6 +527,7 @@ void DialogMove::SaveData() operation->SetAngle(formulaAngle); operation->SetLength(formulaLength); operation->SetRotationAngle(formulaRotationAngle); + operation->SetRotationOriginPointId(GetRotationOrigPointId()); operation->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogmove.h b/src/libs/vtools/dialogs/tools/dialogmove.h index 97ffc7fcb..ba533adea 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.h +++ b/src/libs/vtools/dialogs/tools/dialogmove.h @@ -65,6 +65,9 @@ public: QString GetSuffix() const; void SetSuffix(const QString &value); + quint32 GetRotationOrigPointId() const; + void SetRotationOrigPointId(const quint32 &value); + QVector GetObjects() const; virtual void ShowDialog(bool click) Q_DECL_OVERRIDE; @@ -128,6 +131,8 @@ private: QString m_suffix; + bool optionalRotationOrigin; + void EvalAngle(); void EvalRotationAngle(); void EvalLength(); diff --git a/src/libs/vtools/dialogs/tools/dialogmove.ui b/src/libs/vtools/dialogs/tools/dialogmove.ui index 01f89a72f..2dcc1d530 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.ui +++ b/src/libs/vtools/dialogs/tools/dialogmove.ui @@ -7,7 +7,7 @@ 0 0 292 - 301 + 332 @@ -559,8 +559,11 @@ - - + + + QFormLayout::ExpandingFieldsGrow + + @@ -573,9 +576,19 @@ - + + + + + Rotation origin point: + + + + + + diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 53f13eccc..ca9f1b4bb 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -1295,7 +1295,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons { if (rule == FillComboBox::NoChildren) { - if (i.key() != toolId && i.key() != ch1 && i.key() != ch2) + if (i.key() != toolId && i.value()->getIdTool() != toolId && i.key() != ch1 && i.key() != ch2) { QSharedPointer obj = i.value(); if (obj->getType() == gType) @@ -1306,7 +1306,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons } else { - if (i.key() != toolId) + if (i.key() != toolId && i.value()->getIdTool() != toolId) { QSharedPointer obj = i.value(); if (obj->getType() == gType && obj->getMode() == Draw::Calculation) diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index 1f8c479ba..e6a66de24 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -138,6 +138,7 @@ void VToolMove::setDialog() dialogTool->SetRotationAngle(formulaRotationAngle); dialogTool->SetLength(formulaLength); dialogTool->SetSuffix(suffix); + dialogTool->SetRotationOrigPointId(origPointId); } //--------------------------------------------------------------------------------------------------------------------- @@ -179,7 +180,18 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData) calcRotationAngle = CheckFormula(initData.id, initData.formulaRotationAngle, initData.data); calcLength = qApp->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data)); - const QPointF rotationOrigin = GetOriginPoint(initData.source, initData.data, calcLength, calcAngle); + QPointF rotationOrigin; + QSharedPointer originPoint; + + if (initData.rotationOrigin == NULL_ID) + { + rotationOrigin = GetOriginPoint(initData.source, initData.data, calcLength, calcAngle); + } + else + { + originPoint = initData.data->GeometricObject(initData.rotationOrigin); + rotationOrigin = static_cast(*originPoint); + } if (initData.typeCreation == Source::FromGui) { @@ -313,6 +325,12 @@ QT_WARNING_POP initData.scene->addItem(tool); InitOperationToolConnections(initData.scene, tool); VAbstractPattern::AddTool(initData.id, tool); + + if (not originPoint.isNull()) + { + initData.doc->IncrementReferens(originPoint->getIdTool()); + } + for (int i = 0; i < initData.source.size(); ++i) { initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool()); @@ -388,6 +406,19 @@ void VToolMove::SetFormulaLength(const VFormula &value) } } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolMove::OriginPointName() const +{ + try + { + return VAbstractTool::data.GetGObject(origPointId)->name(); + } + catch (const VExceptionBadId &) + { + return tr("Center point"); + } +} + //--------------------------------------------------------------------------------------------------------------------- void VToolMove::ShowVisualization(bool show) { @@ -421,6 +452,7 @@ void VToolMove::SetVisualization() visual->SetRotationAngle(qApp->TrVars()->FormulaToUser(formulaRotationAngle, qApp->Settings()->GetOsSeparator())); visual->SetLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator())); + visual->SetRotationOriginPointId(origPointId); visual->RefreshGeometry(); } } @@ -432,18 +464,19 @@ void VToolMove::SaveDialog(QDomElement &domElement, QList &oldDependenc QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) - Q_UNUSED(oldDependencies); - Q_UNUSED(newDependencies) + AddDependence(oldDependencies, origPointId); + AddDependence(newDependencies, dialogTool->GetRotationOrigPointId()); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); - QString length = dialogTool->GetLength(); - doc->SetAttribute(domElement, AttrLength, length); + doc->SetAttribute(domElement, AttrLength, dialogTool->GetLength()); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); + doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetRotationOrigPointId())); } //--------------------------------------------------------------------------------------------------------------------- void VToolMove::ReadToolAttributes(const QDomElement &domElement) { + origPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); formulaAngle = doc->GetParametrString(domElement, AttrAngle, "0"); formulaRotationAngle = doc->GetParametrString(domElement, AttrRotationAngle, "0"); formulaLength = doc->GetParametrString(domElement, AttrLength, "0"); @@ -460,6 +493,7 @@ void VToolMove::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrRotationAngle, formulaRotationAngle); doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrSuffix, suffix); + doc->SetAttribute(tag, AttrCenter, QString().setNum(origPointId)); SaveSourceDestination(tag); } @@ -468,12 +502,18 @@ void VToolMove::SaveOptions(QDomElement &tag, QSharedPointer &obj) QString VToolMove::MakeToolTip() const { const QString toolTip = QString(" %1: %2° " - " %3: %4 %5 ") - .arg(tr("Rotation angle")) - .arg(GetFormulaAngle().getDoubleValue()) - .arg(tr("Length")) - .arg(GetFormulaLength().getDoubleValue()) - .arg(UnitsToStr(qApp->patternUnit(), true)); + " %3: %4 %5 " + " %6: %7° " + " %8: %9 ") + .arg(tr("Angle")) // 1 + .arg(GetFormulaAngle().getDoubleValue()) // 2 + .arg(tr("Length")) // 3 + .arg(GetFormulaLength().getDoubleValue()) // 4 + .arg(UnitsToStr(qApp->patternUnit(), true)) // 5 + .arg(tr("Rotation angle")) // 6 + .arg(GetFormulaRotationAngle().getDoubleValue()) // 7 + .arg(tr("Rotation origin point")) // 8 + .arg(OriginPointName()); // 9 return toolTip; } @@ -483,7 +523,8 @@ VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent) initData.destination, parent), formulaAngle(initData.formulaAngle), formulaRotationAngle(initData.formulaRotationAngle), - formulaLength(initData.formulaLength) + formulaLength(initData.formulaLength), + origPointId(initData.rotationOrigin) { InitOperatedObjects(); ToolCreation(initData.typeCreation); diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.h b/src/libs/vtools/tools/drawTools/operation/vtoolmove.h index 4fe7ac111..aeefd5320 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.h +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.h @@ -51,12 +51,14 @@ struct VToolMoveInitData : VAbstractOperationInitData : VAbstractOperationInitData(), formulaAngle(), formulaRotationAngle(), - formulaLength() + formulaLength(), + rotationOrigin(NULL_ID) {} QString formulaAngle; QString formulaRotationAngle; QString formulaLength; + quint32 rotationOrigin; }; class VToolMove : public VAbstractOperation @@ -83,6 +85,8 @@ public: VFormula GetFormulaLength() const; void SetFormulaLength(const VFormula &value); + QString OriginPointName() const; + virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; @@ -98,6 +102,7 @@ private: QString formulaAngle; QString formulaRotationAngle; QString formulaLength; + quint32 origPointId; VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent = nullptr); diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 39c33d1f5..dcd82b5d4 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -237,8 +237,11 @@ void VDrawTool::AddToCalculation(const QDomElement &domElement) //--------------------------------------------------------------------------------------------------------------------- void VDrawTool::AddDependence(QList &list, quint32 objectId) const { - auto originPoint = VAbstractTool::data.GetGObject(objectId); - list.append(originPoint->getIdTool()); + if (objectId != NULL_ID) + { + auto originPoint = VAbstractTool::data.GetGObject(objectId); + list.append(originPoint->getIdTool()); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp index 20d0ec52f..6fde97be6 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp @@ -64,12 +64,14 @@ VisToolMove::VisToolMove(const VContainer *data, QGraphicsItem *parent) rotationAngle(INT_MIN), length(0), pointOrigin(nullptr), + pointRotationOrigin(nullptr), pointFinish(nullptr), angleArc(nullptr), rotationLine(nullptr), xAxis(nullptr) { pointOrigin = InitPoint(supportColor2, this); + pointRotationOrigin = InitPoint(supportColor2, this); pointFinish = InitPoint(supportColor, this); angleArc = InitItem(supportColor3, this); rotationLine = InitItem(supportColor3, this); @@ -89,7 +91,7 @@ void VisToolMove::RefreshGeometry() const QVector originObjects = CreateOriginObjects(iPoint, iCurve); - const QPointF origin = GetOriginPoint(originObjects); + QPointF origin = GetOriginPoint(originObjects); DrawPoint(pointOrigin, origin, supportColor2); qreal tempAngle = 0; @@ -118,10 +120,21 @@ void VisToolMove::RefreshGeometry() tempAngle = angle; tempLength = length; + if (object1Id != NULL_ID) + { + origin = Visualization::data->GeometricObject(object1Id)->toQPointF(); + DrawPoint(pointRotationOrigin, origin, supportColor2); + } + else + { + origin = line.p2(); + pointRotationOrigin->setVisible(false); + } + QLineF rLine; if (VFuzzyComparePossibleNulls(rotationAngle, INT_MIN)) { - rLine = QLineF(line.p2(), Visualization::scenePos); + rLine = QLineF(origin, Visualization::scenePos); if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) { @@ -129,7 +142,7 @@ void VisToolMove::RefreshGeometry() } qreal cursorLength = rLine.length(); - rLine.setP2(Ray(line.p2(), rLine.angle())); + rLine.setP2(Ray(origin, rLine.angle())); //Radius of point circle, but little bigger. Need handle with hover sizes. qreal minL = ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5; if (cursorLength > minL) @@ -143,14 +156,14 @@ void VisToolMove::RefreshGeometry() } else { - rLine = QLineF(line.p2(), Ray(line.p2(), rotationAngle)); + rLine = QLineF(origin, Ray(origin, rotationAngle)); tempRoationAngle = rotationAngle; } DrawLine(rotationLine, rLine, supportColor3, Qt::DashLine); - DrawLine(xAxis, QLineF(line.p2(), Ray(line.p2(), 0)), supportColor3, Qt::DashLine); + DrawLine(xAxis, QLineF(origin, Ray(origin, 0)), supportColor3, Qt::DashLine); - VArc arc(VPointF(line.p2()), ScaledRadius(SceneScale(qApp->getCurrentScene()))*2, 0, tempRoationAngle); + VArc arc(VPointF(origin), ScaledRadius(SceneScale(qApp->getCurrentScene()))*2, 0, tempRoationAngle); DrawPath(angleArc, arc.GetPath(), supportColor3, Qt::SolidLine, Qt::RoundCap); } DrawLine(this, line, supportColor2, Qt::DashLine); @@ -169,7 +182,7 @@ void VisToolMove::RefreshGeometry() else { Visualization::toolTip = tr("Length = %1%2, angle = %3°, rotation angle = %4°, Shift - sticking angle, " - "Mouse click - finish creating") + "Ctrl - change rotation origin point, Mouse click - finish creating") .arg(qApp->TrVars()->FormulaToUser(QString::number(qApp->fromPixel(tempLength)), qApp->Settings()->GetOsSeparator())) .arg(prefix) @@ -177,7 +190,7 @@ void VisToolMove::RefreshGeometry() .arg(tempRoationAngle); } - CreateMovedRotatedObjects(iPoint, iCurve, tempLength, tempAngle, tempRoationAngle, line.p2()); + CreateMovedRotatedObjects(iPoint, iCurve, tempLength, tempAngle, tempRoationAngle, origin); } //--------------------------------------------------------------------------------------------------------------------- @@ -222,6 +235,12 @@ void VisToolMove::SetLength(const QString &expression) length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } +//--------------------------------------------------------------------------------------------------------------------- +void VisToolMove::SetRotationOriginPointId(quint32 value) +{ + object1Id = value; +} + //--------------------------------------------------------------------------------------------------------------------- template QGraphicsPathItem *VisToolMove::AddOriginCurve(quint32 id, int &i) diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.h b/src/libs/vtools/visualization/line/operation/vistoolmove.h index 28ffd74e4..f43f46b77 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolmove.h +++ b/src/libs/vtools/visualization/line/operation/vistoolmove.h @@ -62,6 +62,8 @@ public: qreal LengthValue() const; void SetLength(const QString &expression); + void SetRotationOriginPointId(quint32 value); + virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Vis::ToolMove)}; private: @@ -70,6 +72,7 @@ private: qreal rotationAngle; qreal length; VScaledEllipse *pointOrigin; + VScaledEllipse *pointRotationOrigin; VScaledEllipse *pointFinish; VCurvePathItem *angleArc; VScaledLine *rotationLine;