From 2574ecda0e0586d4a269a721eaa0a022dde59e95 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 4 Nov 2020 18:14:21 +0200 Subject: [PATCH] Alias field for tool Cut Arc. --- .../core/vtooloptionspropertybrowser.cpp | 75 +++++++++++++++- .../core/vtooloptionspropertybrowser.h | 12 +++ src/app/valentina/xml/vpattern.cpp | 14 +-- src/libs/ifc/ifcdef.cpp | 2 + src/libs/ifc/ifcdef.h | 2 + src/libs/vpatterndb/vcontainer.cpp | 20 +++-- src/libs/vpatterndb/vcontainer.h | 9 +- .../vtools/dialogs/tools/dialogcutarc.cpp | 78 ++++++++++++++++ src/libs/vtools/dialogs/tools/dialogcutarc.h | 26 ++++-- src/libs/vtools/dialogs/tools/dialogcutarc.ui | 32 ++++++- .../toolsinglepoint/toolcut/vtoolcut.cpp | 89 +++++++++++++++++-- .../toolsinglepoint/toolcut/vtoolcut.h | 30 ++++++- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 53 +++++++---- .../toolsinglepoint/toolcut/vtoolcutarc.h | 16 +--- .../toolcut/vtoolcutspline.cpp | 28 +++--- .../toolsinglepoint/toolcut/vtoolcutspline.h | 16 +--- .../toolcut/vtoolcutsplinepath.cpp | 28 +++--- .../toolcut/vtoolcutsplinepath.h | 16 +--- 18 files changed, 417 insertions(+), 129 deletions(-) diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 97895ea4d..b3ac5507c 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -544,6 +544,26 @@ void VToolOptionsPropertyBrowser::AddPropertyAlias(Tool *i, const QString &prope AddProperty(itemName, AttrAlias); } +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::AddPropertyAlias1(Tool *i, const QString &propertyName) +{ + auto *itemName = new VPE::VStringProperty(propertyName); + itemName->setClearButtonEnable(true); + itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix1())); + AddProperty(itemName, AttrAlias1); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::AddPropertyAlias2(Tool *i, const QString &propertyName) +{ + auto *itemName = new VPE::VStringProperty(propertyName); + itemName->setClearButtonEnable(true); + itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix2())); + AddProperty(itemName, AttrAlias2); +} + //--------------------------------------------------------------------------------------------------------------------- template void VToolOptionsPropertyBrowser::AddPropertyPointName1(Tool *i, const QString &propertyName) @@ -967,6 +987,46 @@ void VToolOptionsPropertyBrowser::SetAlias(VPE::VProperty *property) } } +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::SetAlias1(VPE::VProperty *property) +{ + if (auto *i = qgraphicsitem_cast(currentItem)) + { + QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); + if (notes == i->GetAliasSuffix1()) + { + return; + } + + i->SetAliasSuffix1(notes); + } + else + { + qWarning()<<"Can't cast item"; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::SetAlias2(VPE::VProperty *property) +{ + if (auto *i = qgraphicsitem_cast(currentItem)) + { + QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); + if (notes == i->GetAliasSuffix2()) + { + return; + } + + i->SetAliasSuffix2(notes); + } + else + { + qWarning()<<"Can't cast item"; + } +} + //--------------------------------------------------------------------------------------------------------------------- template void VToolOptionsPropertyBrowser::SetLineType(VPE::VProperty *property) @@ -1452,6 +1512,12 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutArc(VPE::VProperty *property) case 61: // AttrNotes SetNotes(property); break; + case 63: // AttrAlias1 + SetAlias1(property); + break; + case 64: // AttrAlias2 + SetAlias2(property); + break; default: qWarning()<<"Unknown property type. id = "<CurveName(), tr("Arc:"), AttrArc); + AddPropertyAlias1(i, tr("Alias1:")); + AddPropertyAlias2(i, tr("Alias2:")); AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength); AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes); } @@ -3232,6 +3300,9 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutArc() idToProperty[AttrArc]->setValue(valueArc); idToProperty[AttrNotes]->setValue(i->GetNotes()); + + idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1()); + idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2()); } //--------------------------------------------------------------------------------------------------------------------- @@ -3995,7 +4066,9 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const AttrPenStyle, /* 59 */ AttrAScale, /* 60 */ AttrNotes, /* 61 */ - AttrAlias /* 62 */ + AttrAlias, /* 62 */ + AttrAlias1, /* 63 */ + AttrAlias2 /* 64 */ }; return attr; } diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.h b/src/app/valentina/core/vtooloptionspropertybrowser.h index d15a5f80d..cee994701 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.h +++ b/src/app/valentina/core/vtooloptionspropertybrowser.h @@ -99,6 +99,12 @@ private: template void SetAlias(VPE::VProperty *property); + template + void SetAlias1(VPE::VProperty *property); + + template + void SetAlias2(VPE::VProperty *property); + template void SetLineType(VPE::VProperty *property); @@ -135,6 +141,12 @@ private: template void AddPropertyAlias(Tool *i, const QString &propertyName); + template + void AddPropertyAlias1(Tool *i, const QString &propertyName); + + template + void AddPropertyAlias2(Tool *i, const QString &propertyName); + template void AddPropertyPointName1(Tool *i, const QString &propertyName); diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index aff8cb85a..b1a7c77f9 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -2030,7 +2030,7 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle try { - VToolCutSplineInitData initData; + VToolCutInitData initData; initData.scene = scene; initData.doc = this; initData.data = data; @@ -2040,7 +2040,7 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle PointsCommonAttributes(domElement, initData); initData.formula = GetParametrString(domElement, AttrLength, QChar('0')); const QString f = initData.formula;//need for saving fixed formula; - initData.splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR); + initData.baseCurveId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR); VToolCutSpline::Create(initData); //Rewrite attribute formula. Need for situation when we have wrong formula. @@ -2073,7 +2073,7 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do try { - VToolCutSplinePathInitData initData; + VToolCutInitData initData; initData.scene = scene; initData.doc = this; initData.data = data; @@ -2083,7 +2083,7 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do PointsCommonAttributes(domElement, initData); initData.formula = GetParametrString(domElement, AttrLength, QChar('0')); const QString f = initData.formula;//need for saving fixed formula; - initData.splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR); + initData.baseCurveId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR); VToolCutSplinePath::Create(initData); //Rewrite attribute formula. Need for situation when we have wrong formula. @@ -2116,7 +2116,7 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen try { - VToolCutArcInitData initData; + VToolCutInitData initData; initData.scene = scene; initData.doc = this; initData.data = data; @@ -2126,7 +2126,9 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen PointsCommonAttributes(domElement, initData); initData.formula = GetParametrString(domElement, AttrLength, QChar('0')); const QString f = initData.formula;//need for saving fixed formula; - initData.arcId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR); + initData.baseCurveId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR); + initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1); + initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2); VToolCutArc::Create(initData); //Rewrite attribute formula. Need for situation when we have wrong formula. diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index 58f304e94..ed39c11ec 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -135,6 +135,8 @@ const QString AttrFirstToCountour = QStringLiteral("firstToCountour"); const QString AttrLastToCountour = QStringLiteral("lastToCountour"); const QString AttrNotes = QStringLiteral("notes"); const QString AttrAlias = QStringLiteral("alias"); +const QString AttrAlias1 = QStringLiteral("alias1"); +const QString AttrAlias2 = QStringLiteral("alias2"); const QString TypeLineNone = QStringLiteral("none"); const QString TypeLineLine = QStringLiteral("hair"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 3305bcdf2..cd32a74e6 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -153,6 +153,8 @@ extern const QString AttrFirstToCountour; extern const QString AttrLastToCountour; extern const QString AttrNotes; extern const QString AttrAlias; +extern const QString AttrAlias1; +extern const QString AttrAlias2; extern const QString TypeLineNone; extern const QString TypeLineLine; diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index 44aff5aed..0e186af6e 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -241,6 +241,19 @@ quint32 VContainer::GetPieceForPiecePath(quint32 id) const return NULL_ID; } +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::RegisterUniqueName(const QSharedPointer &obj) +{ + SCASSERT(not obj.isNull()) + + uniqueNames[d->nspace].insert(obj->name()); + + if (not obj->GetAlias().isEmpty()) + { + uniqueNames[d->nspace].insert(obj->GetAlias()); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddGObject add new GObject to container @@ -265,12 +278,7 @@ quint32 VContainer::AddGObject(const QSharedPointer &obj) return NULL_ID; } - uniqueNames[d->nspace].insert(obj->name()); - - if (not obj->GetAlias().isEmpty()) - { - uniqueNames[d->nspace].insert(obj->GetAlias()); - } + RegisterUniqueName(obj); const quint32 id = getNextId(); obj->setId(id); diff --git a/src/libs/vpatterndb/vcontainer.h b/src/libs/vpatterndb/vcontainer.h index 5bb839bbf..a43d10012 100644 --- a/src/libs/vpatterndb/vcontainer.h +++ b/src/libs/vpatterndb/vcontainer.h @@ -151,6 +151,8 @@ public: void UpdateId(quint32 newId) const; static void UpdateId(quint32 newId, const QString &nspace); + void RegisterUniqueName(const QSharedPointer &obj); + quint32 AddGObject(VGObject *obj); quint32 AddGObject(const QSharedPointer &obj); quint32 AddPiece(const VPiece &detail); @@ -402,12 +404,7 @@ void VContainer::UpdateGObject(quint32 id, const QSharedPointer &obj) { SCASSERT(not obj.isNull()) UpdateObject(id, obj); - uniqueNames[d->nspace].insert(obj->name()); - - if (not obj->GetAlias().isEmpty()) - { - uniqueNames[d->nspace].insert(obj->GetAlias()); - } + RegisterUniqueName(obj); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp index 4c9ae5de1..24a24e356 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp @@ -93,6 +93,9 @@ DialogCutArc::DialogCutArc(const VContainer *data, quint32 toolId, QWidget *pare connect(ui->comboBoxArc, &QComboBox::currentTextChanged, this, &DialogCutArc::ArcChanged); + connect(ui->lineEditAlias1, &QLineEdit::textEdited, this, &DialogCutArc::ValidateAlias); + connect(ui->lineEditAlias2, &QLineEdit::textEdited, this, &DialogCutArc::ValidateAlias); + vis = new VisToolCutArc(data); ui->tabWidget->setCurrentIndex(0); @@ -201,6 +204,55 @@ void DialogCutArc::ArcChanged() CurrentCurveLength(getArcId(), const_cast (data)); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::ValidateAlias() +{ + VArc arc1; + arc1.SetAliasSuffix(GetAliasSuffix1()); + if (not GetAliasSuffix1().isEmpty() && not data->IsUnique(arc1.GetAlias())) + { + flagAlias1 = false; + ChangeColor(ui->labelAlias1, errorColor); + } + else + { + flagAlias1 = true; + ChangeColor(ui->labelAlias1, OkColor(this)); + } + + VArc arc2; + arc2.SetAliasSuffix(GetAliasSuffix2()); + if (not GetAliasSuffix2().isEmpty() && not data->IsUnique(arc2.GetAlias())) + { + flagAlias2 = false; + ChangeColor(ui->labelAlias2, errorColor); + } + else + { + flagAlias2 = true; + ChangeColor(ui->labelAlias2, OkColor(this)); + } + + if (arc1.GetAlias() == arc2.GetAlias()) + { + flagAlias1 = false; + ChangeColor(ui->labelAlias1, errorColor); + + flagAlias2 = false; + ChangeColor(ui->labelAlias2, errorColor); + } + else + { + flagAlias1 = true; + ChangeColor(ui->labelAlias1, OkColor(this)); + + flagAlias2 = true; + ChangeColor(ui->labelAlias2, OkColor(this)); + } + + CheckState(); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief setArcId set id of arc @@ -279,3 +331,29 @@ QString DialogCutArc::GetNotes() const { return ui->plainTextEditToolNotes->toPlainText(); } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::SetAliasSuffix1(const QString &alias) +{ + ui->lineEditAlias1->setText(alias); + ValidateAlias(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCutArc::GetAliasSuffix1() const +{ + return ui->lineEditAlias1->text(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::SetAliasSuffix2(const QString &alias) +{ + ui->lineEditAlias2->setText(alias); + ValidateAlias(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCutArc::GetAliasSuffix2() const +{ + return ui->lineEditAlias2->text(); +} diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.h b/src/libs/vtools/dialogs/tools/dialogcutarc.h index ec88a1598..385023b96 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.h +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.h @@ -54,17 +54,24 @@ public: DialogCutArc(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogCutArc() override; - QString GetPointName() const; - void SetPointName(const QString &value); + QString GetPointName() const; + void SetPointName(const QString &value); - QString GetFormula() const; - void SetFormula(const QString &value); + QString GetFormula() const; + void SetFormula(const QString &value); - quint32 getArcId() const; - void setArcId(quint32 value); + quint32 getArcId() const; + void setArcId(quint32 value); void SetNotes(const QString ¬es); QString GetNotes() const; + + void SetAliasSuffix1(const QString &alias); + QString GetAliasSuffix1() const; + + void SetAliasSuffix2(const QString &alias); + QString GetAliasSuffix2() const; + public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) override; /** @@ -84,6 +91,7 @@ protected: virtual bool IsValid() const final; private slots: void ArcChanged(); + void ValidateAlias(); private: Q_DISABLE_COPY(DialogCutArc) /** @brief ui keeps information about user interface */ @@ -94,18 +102,20 @@ private: QString pointName; /** @brief formulaBaseHeight base height defined by dialogui */ - int formulaBaseHeight; + int formulaBaseHeight; QTimer *timerFormula; bool flagFormula; bool flagName; + bool flagAlias1{true}; + bool flagAlias2{true}; }; //--------------------------------------------------------------------------------------------------------------------- inline bool DialogCutArc::IsValid() const { - return flagFormula && flagName; + return flagFormula && flagName && flagAlias1 && flagAlias2; } #endif // DIALOGCUTARC_H diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.ui b/src/libs/vtools/dialogs/tools/dialogcutarc.ui index b50e73564..3bd921c16 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.ui +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.ui @@ -6,8 +6,8 @@ 0 0 - 334 - 247 + 573 + 295 @@ -255,6 +255,34 @@ + + + + Alias1: + + + + + + + true + + + + + + + Alias2: + + + + + + + true + + + diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp index d20aac17c..7c4e747d5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp @@ -44,14 +44,15 @@ #include "../vtoolsinglepoint.h" //--------------------------------------------------------------------------------------------------------------------- -VToolCut::VToolCut(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &curveCutId, const QString ¬es, QGraphicsItem *parent) - : VToolSinglePoint(doc, data, id, notes, parent), - formula(formula), - curveCutId(curveCutId), - detailsMode(qApp->Settings()->IsShowCurveDetails()) +VToolCut::VToolCut(const VToolCutInitData &initData, QGraphicsItem *parent) + : VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent), + formula(initData.formula), + baseCurveId(initData.baseCurveId), + detailsMode(qApp->Settings()->IsShowCurveDetails()), + m_aliasSuffix1(initData.aliasSuffix1), + m_aliasSuffix2(initData.aliasSuffix2) { - Q_ASSERT_X(curveCutId != 0, Q_FUNC_INFO, "curveCutId == 0"); //-V654 //-V712 + Q_ASSERT_X(initData.baseCurveId != 0, Q_FUNC_INFO, "curveCutId == 0"); //-V654 //-V712 } //--------------------------------------------------------------------------------------------------------------------- @@ -100,10 +101,62 @@ void VToolCut::SetFormulaLength(const VFormula &value) } } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolCut::GetAliasSuffix1() const +{ + return m_aliasSuffix1; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCut::SetAliasSuffix1(const QString &alias) +{ + QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); + + const QString oldAliasSuffix = curve->GetAliasSuffix(); + curve->SetAliasSuffix(alias); + + if (alias.isEmpty() || VAbstractTool::data.IsUnique(curve->GetAlias())) + { + m_aliasSuffix1 = alias; + QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); + SaveOption(obj); + } + else + { + curve->SetAliasSuffix(oldAliasSuffix); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolCut::GetAliasSuffix2() const +{ + return m_aliasSuffix2; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCut::SetAliasSuffix2(const QString &alias) +{ + QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); + + const QString oldAliasSuffix = curve->GetAliasSuffix(); + curve->SetAliasSuffix(alias); + + if (alias.isEmpty() || VAbstractTool::data.IsUnique(curve->GetAlias())) + { + m_aliasSuffix2 = alias; + QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); + SaveOption(obj); + } + else + { + curve->SetAliasSuffix(oldAliasSuffix); + } +} + //--------------------------------------------------------------------------------------------------------------------- QString VToolCut::CurveName() const { - return VAbstractTool::data.GetGObject(curveCutId)->name(); + return VAbstractTool::data.GetGObject(baseCurveId)->name(); } //--------------------------------------------------------------------------------------------------------------------- @@ -121,7 +174,25 @@ void VToolCut::RefreshGeometry() */ void VToolCut::RemoveReferens() { - const auto curve = VAbstractTool::data.GetGObject(curveCutId); + const auto curve = VAbstractTool::data.GetGObject(baseCurveId); doc->DecrementReferens(curve->getIdTool()); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCut::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + VToolSinglePoint::SaveOptions(tag, obj); + + doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, m_aliasSuffix1.isEmpty()); + doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, m_aliasSuffix2.isEmpty()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCut::ReadToolAttributes(const QDomElement &domElement) +{ + VToolSinglePoint::ReadToolAttributes(domElement); + + m_aliasSuffix1 = doc->GetParametrEmptyString(domElement, AttrAlias1); + m_aliasSuffix2 = doc->GetParametrEmptyString(domElement, AttrAlias2); +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h index 7dfff48e6..d18ef52d6 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h @@ -45,18 +45,35 @@ class VFormula; +struct VToolCutInitData : VToolSinglePointInitData +{ + VToolCutInitData() + : VToolSinglePointInitData() + {} + + quint32 baseCurveId{NULL_ID}; + QString formula{}; + QString aliasSuffix1{}; + QString aliasSuffix2{}; +}; + class VToolCut : public VToolSinglePoint { Q_OBJECT public: - VToolCut(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &curveCutId, const QString ¬es, QGraphicsItem * parent = nullptr); + explicit VToolCut(const VToolCutInitData &initData, QGraphicsItem * parent = nullptr); virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Tool::Cut)}; VFormula GetFormulaLength() const; void SetFormulaLength(const VFormula &value); + QString GetAliasSuffix1() const; + void SetAliasSuffix1(const QString &alias); + + QString GetAliasSuffix2() const; + void SetAliasSuffix2(const QString &alias); + QString CurveName() const; public slots: @@ -67,11 +84,16 @@ protected: /** @brief formula keep formula of length */ QString formula; - quint32 curveCutId; + quint32 baseCurveId; bool detailsMode; + QString m_aliasSuffix1{}; + QString m_aliasSuffix2{}; + void RefreshGeometry(); virtual void RemoveReferens() override; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) override; + virtual void ReadToolAttributes(const QDomElement &domElement) override; template void ShowToolVisualization(bool show); @@ -104,7 +126,7 @@ inline void VToolCut::ShowToolVisualization(bool show) delete vis; } - VDataTool *parent = VAbstractPattern::getTool(VAbstractTool::data.GetGObject(curveCutId)->getIdTool()); + VDataTool *parent = VAbstractPattern::getTool(VAbstractTool::data.GetGObject(baseCurveId)->getIdTool()); if (VAbstractSpline *parentCurve = qobject_cast(parent)) { detailsMode ? parentCurve->ShowHandles(detailsMode) : parentCurve->ShowHandles(show); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index 6fa112a1b..8792e66f7 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -62,8 +62,8 @@ const QString VToolCutArc::ToolType = QStringLiteral("cutArc"); * @param initData init data. * @param parent parent object. */ -VToolCutArc::VToolCutArc(const VToolCutArcInitData &initData, QGraphicsItem * parent) - :VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.arcId, initData.notes, parent) +VToolCutArc::VToolCutArc(const VToolCutInitData &initData, QGraphicsItem * parent) + :VToolCut(initData, parent) { ToolCreation(initData.typeCreation); } @@ -79,9 +79,11 @@ void VToolCutArc::setDialog() SCASSERT(not dialogTool.isNull()) const QSharedPointer point = VAbstractTool::data.GeometricObject(m_id); dialogTool->SetFormula(formula); - dialogTool->setArcId(curveCutId); + dialogTool->setArcId(baseCurveId); dialogTool->SetPointName(point->name()); dialogTool->SetNotes(m_notes); + dialogTool->SetAliasSuffix1(m_aliasSuffix1); + dialogTool->SetAliasSuffix2(m_aliasSuffix2); } //--------------------------------------------------------------------------------------------------------------------- @@ -99,9 +101,9 @@ VToolCutArc* VToolCutArc::Create(const QPointer &dialog, VMainGraphi const QPointer dialogTool = qobject_cast(dialog); SCASSERT(not dialogTool.isNull()) - VToolCutArcInitData initData; + VToolCutInitData initData; initData.formula = dialogTool->GetFormula(); - initData.arcId = dialogTool->getArcId(); + initData.baseCurveId = dialogTool->getArcId(); initData.name = dialogTool->GetPointName(); initData.scene = scene; initData.doc = doc; @@ -109,6 +111,8 @@ VToolCutArc* VToolCutArc::Create(const QPointer &dialog, VMainGraphi initData.parse = Document::FullParse; initData.typeCreation = Source::FromGui; initData.notes = dialogTool->GetNotes(); + initData.aliasSuffix1 = dialogTool->GetAliasSuffix1(); + initData.aliasSuffix2 = dialogTool->GetAliasSuffix2(); VToolCutArc* point = Create(initData); if (point != nullptr) @@ -123,12 +127,12 @@ VToolCutArc* VToolCutArc::Create(const QPointer &dialog, VMainGraphi * @brief Create help create tool. * @param initData init data. */ -VToolCutArc* VToolCutArc::Create(VToolCutArcInitData &initData) +VToolCutArc* VToolCutArc::Create(VToolCutInitData &initData) { - const QSharedPointer arc = initData.data->GeometricObject(initData.arcId); + const QSharedPointer arc = initData.data->GeometricObject(initData.baseCurveId); //Declare special variable "CurrentLength" - VCurveLength *length = new VCurveLength(initData.arcId, initData.arcId, arc.data(), + VCurveLength *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, arc.data(), *initData.data->GetPatternUnit()); length->SetName(currentLength); initData.data->AddVariable(length); @@ -139,6 +143,9 @@ VToolCutArc* VToolCutArc::Create(VToolCutArcInitData &initData) VArc arc2; QPointF point = arc->CutArc(qApp->toPixel(result), arc1, arc2); + arc1.SetAliasSuffix(initData.aliasSuffix1); + arc1.SetAliasSuffix(initData.aliasSuffix2); + VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); p->SetShowLabel(initData.showLabel); @@ -147,17 +154,25 @@ VToolCutArc* VToolCutArc::Create(VToolCutArcInitData &initData) if (initData.typeCreation == Source::FromGui) { initData.id = initData.data->AddGObject(p); + a1->setId(initData.data->getNextId()); - a2->setId(initData.data->getNextId()); + initData.data->RegisterUniqueName(a1); initData.data->AddArc(a1, a1->id(), initData.id); + + a2->setId(initData.data->getNextId()); + initData.data->RegisterUniqueName(a2); initData.data->AddArc(a2, a2->id(), initData.id); } else { initData.data->UpdateGObject(initData.id, p); + a1->setId(initData.id + 1); - a2->setId(initData.id + 2); + initData.data->RegisterUniqueName(a1); initData.data->AddArc(a1, a1->id(), initData.id); + + a2->setId(initData.id + 2); + initData.data->RegisterUniqueName(a2); initData.data->AddArc(a2, a2->id(), initData.id); if (initData.parse != Document::FullParse) @@ -212,12 +227,16 @@ void VToolCutArc::SaveDialog(QDomElement &domElement, QList &oldDepende const QPointer dialogTool = qobject_cast(m_dialog); SCASSERT(not dialogTool.isNull()) - AddDependence(oldDependencies, curveCutId); + AddDependence(oldDependencies, baseCurveId); AddDependence(newDependencies, dialogTool->getArcId()); doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId())); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), + dialogTool->GetAliasSuffix1().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), + dialogTool->GetAliasSuffix2().isEmpty()); const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); @@ -230,7 +249,7 @@ void VToolCutArc::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrType, ToolType); doc->SetAttribute(tag, AttrLength, formula); - doc->SetAttribute(tag, AttrArc, curveCutId); + doc->SetAttribute(tag, AttrArc, baseCurveId); } //--------------------------------------------------------------------------------------------------------------------- @@ -239,7 +258,7 @@ void VToolCutArc::ReadToolAttributes(const QDomElement &domElement) VToolCut::ReadToolAttributes(domElement); formula = doc->GetParametrString(domElement, AttrLength, QString()); - curveCutId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR); + baseCurveId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR); } //--------------------------------------------------------------------------------------------------------------------- @@ -250,10 +269,10 @@ void VToolCutArc::SetVisualization() VisToolCutArc *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(curveCutId); + visual->setObject1Id(baseCurveId); visual->setLength(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator())); - const QSharedPointer curve = VAbstractTool::data.GeometricObject(curveCutId); + const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); visual->RefreshGeometry(); @@ -263,7 +282,7 @@ void VToolCutArc::SetVisualization() //--------------------------------------------------------------------------------------------------------------------- QString VToolCutArc::MakeToolTip() const { - const QSharedPointer arc = VAbstractTool::data.GeometricObject(curveCutId); + const QSharedPointer arc = VAbstractTool::data.GeometricObject(baseCurveId); const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); @@ -296,7 +315,7 @@ QString VToolCutArc::MakeToolTip() const .arg(arc.GetStartAngle()) .arg(arcStr + arcNumber + QChar(QChar::Space) + endAngleStr) .arg(arc.GetEndAngle()) - .arg(arcStr + arcNumber + QChar(QChar::Space) + tr("label"), arc.name()); + .arg(arcStr + arcNumber + QChar(QChar::Space) + tr("label"), arc.ObjectName()); return toolTip; }; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h index 785875651..0dc8c464d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h @@ -43,18 +43,6 @@ template class QSharedPointer; -struct VToolCutArcInitData : VToolSinglePointInitData -{ - VToolCutArcInitData() - : VToolSinglePointInitData(), - formula(), - arcId(NULL_ID) - {} - - QString formula; - quint32 arcId; -}; - /** * @brief The VToolCutArc class tool for cutting arc. */ @@ -65,7 +53,7 @@ public: virtual void setDialog() override; static VToolCutArc* Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolCutArc* Create(VToolCutArcInitData &initData); + static VToolCutArc* Create(VToolCutInitData &initData); static const QString ToolType; virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Tool::CutArc)}; @@ -82,7 +70,7 @@ protected: private: Q_DISABLE_COPY(VToolCutArc) - VToolCutArc(const VToolCutArcInitData &initData, QGraphicsItem *parent = nullptr); + explicit VToolCutArc(const VToolCutInitData &initData, QGraphicsItem *parent = nullptr); }; #endif // VTOOLCUTARC_H diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index 3c7308148..293408b87 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -65,8 +65,8 @@ const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); * @param initData init data. * @param parent parent object. */ -VToolCutSpline::VToolCutSpline(const VToolCutSplineInitData &initData, QGraphicsItem *parent) - :VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.splineId, initData.notes, parent) +VToolCutSpline::VToolCutSpline(const VToolCutInitData &initData, QGraphicsItem *parent) + :VToolCut(initData, parent) { ToolCreation(initData.typeCreation); } @@ -82,7 +82,7 @@ void VToolCutSpline::setDialog() SCASSERT(not dialogTool.isNull()) const QSharedPointer point = VAbstractTool::data.GeometricObject(m_id); dialogTool->SetFormula(formula); - dialogTool->setSplineId(curveCutId); + dialogTool->setSplineId(baseCurveId); dialogTool->SetPointName(point->name()); dialogTool->SetNotes(m_notes); } @@ -102,9 +102,9 @@ VToolCutSpline* VToolCutSpline::Create(const QPointer &dialog, VMain const QPointer dialogTool = qobject_cast(dialog); SCASSERT(not dialogTool.isNull()) - VToolCutSplineInitData initData; + VToolCutInitData initData; initData.formula = dialogTool->GetFormula(); - initData.splineId = dialogTool->getSplineId(); + initData.baseCurveId = dialogTool->getSplineId(); initData.name = dialogTool->GetPointName(); initData.scene = scene; initData.doc = doc; @@ -126,12 +126,12 @@ VToolCutSpline* VToolCutSpline::Create(const QPointer &dialog, VMain * @brief Create help create tool. * @param initData init data. */ -VToolCutSpline* VToolCutSpline::Create(VToolCutSplineInitData &initData) +VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData) { - const auto spl = initData.data->GeometricObject(initData.splineId); + const auto spl = initData.data->GeometricObject(initData.baseCurveId); //Declare special variable "CurrentLength" - VCurveLength *length = new VCurveLength(initData.splineId, initData.splineId, spl.data(), + VCurveLength *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, spl.data(), *initData.data->GetPatternUnit()); length->SetName(currentLength); initData.data->AddVariable(length); @@ -211,7 +211,7 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement, QList &oldDepe const QPointer dialogTool = qobject_cast(m_dialog); SCASSERT(not dialogTool.isNull()) - AddDependence(oldDependencies, curveCutId); + AddDependence(oldDependencies, baseCurveId); AddDependence(newDependencies, dialogTool->getSplineId()); doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName()); @@ -229,7 +229,7 @@ void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer &obj doc->SetAttribute(tag, AttrType, ToolType); doc->SetAttribute(tag, AttrLength, formula); - doc->SetAttribute(tag, AttrSpline, curveCutId); + doc->SetAttribute(tag, AttrSpline, baseCurveId); } //--------------------------------------------------------------------------------------------------------------------- @@ -238,7 +238,7 @@ void VToolCutSpline::ReadToolAttributes(const QDomElement &domElement) VToolCut::ReadToolAttributes(domElement); formula = doc->GetParametrString(domElement, AttrLength, QString()); - curveCutId = doc->GetParametrUInt(domElement, AttrSpline, NULL_ID_STR); + baseCurveId = doc->GetParametrUInt(domElement, AttrSpline, NULL_ID_STR); } //--------------------------------------------------------------------------------------------------------------------- @@ -249,10 +249,10 @@ void VToolCutSpline::SetVisualization() VisToolCutSpline *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(curveCutId); + visual->setObject1Id(baseCurveId); visual->setLength(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator())); - const QSharedPointer curve = VAbstractTool::data.GeometricObject(curveCutId); + const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); visual->RefreshGeometry(); @@ -262,7 +262,7 @@ void VToolCutSpline::SetVisualization() //--------------------------------------------------------------------------------------------------------------------- QString VToolCutSpline::MakeToolTip() const { - const auto spl = VAbstractTool::data.GeometricObject(curveCutId); + const auto spl = VAbstractTool::data.GeometricObject(baseCurveId); const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h index f309ae03a..ed7f7d6fe 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h @@ -43,18 +43,6 @@ template class QSharedPointer; -struct VToolCutSplineInitData : VToolSinglePointInitData -{ - VToolCutSplineInitData() - : VToolSinglePointInitData(), - formula(), - splineId(NULL_ID) - {} - - QString formula; - quint32 splineId; -}; - /** * @brief The VToolCutSpline class for tool CutSpline. This tool find point on spline and cut spline on two. */ @@ -65,7 +53,7 @@ public: virtual void setDialog() override; static VToolCutSpline *Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolCutSpline *Create(VToolCutSplineInitData &initData); + static VToolCutSpline *Create(VToolCutInitData &initData); static const QString ToolType; static const QString AttrSpline; virtual int type() const override {return Type;} @@ -83,7 +71,7 @@ protected: private: Q_DISABLE_COPY(VToolCutSpline) - VToolCutSpline(const VToolCutSplineInitData &initData, QGraphicsItem * parent = nullptr); + VToolCutSpline(const VToolCutInitData &initData, QGraphicsItem * parent = nullptr); }; #endif // VTOOLCUTSPLINE_H diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index f184679cc..2636837ac 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -68,8 +68,8 @@ const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath"); * @param initData init data. * @param parent parent object. */ -VToolCutSplinePath::VToolCutSplinePath(const VToolCutSplinePathInitData &initData, QGraphicsItem *parent) - :VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.splinePathId, initData.notes, parent) +VToolCutSplinePath::VToolCutSplinePath(const VToolCutInitData &initData, QGraphicsItem *parent) + :VToolCut(initData, parent) { ToolCreation(initData.typeCreation); } @@ -85,7 +85,7 @@ void VToolCutSplinePath::setDialog() SCASSERT(not dialogTool.isNull()) const QSharedPointer point = VAbstractTool::data.GeometricObject(m_id); dialogTool->SetFormula(formula); - dialogTool->setSplinePathId(curveCutId); + dialogTool->setSplinePathId(baseCurveId); dialogTool->SetPointName(point->name()); dialogTool->SetNotes(m_notes); } @@ -105,9 +105,9 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const QPointer &dialo const QPointer dialogTool = qobject_cast(dialog); SCASSERT(not dialogTool.isNull()) - VToolCutSplinePathInitData initData; + VToolCutInitData initData; initData.formula = dialogTool->GetFormula(); - initData.splinePathId = dialogTool->getSplinePathId(); + initData.baseCurveId = dialogTool->getSplinePathId(); initData.name = dialogTool->GetPointName(); initData.scene = scene; initData.doc = doc; @@ -129,13 +129,13 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const QPointer &dialo * @brief Create help create tool. * @param initData init data. */ -VToolCutSplinePath* VToolCutSplinePath::Create(VToolCutSplinePathInitData &initData) +VToolCutSplinePath* VToolCutSplinePath::Create(VToolCutInitData &initData) { - const auto splPath = initData.data->GeometricObject(initData.splinePathId); + const auto splPath = initData.data->GeometricObject(initData.baseCurveId); SCASSERT(splPath != nullptr) //Declare special variable "CurrentLength" - VCurveLength *length = new VCurveLength(initData.splinePathId, initData.splinePathId, splPath.data(), + VCurveLength *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, splPath.data(), *initData.data->GetPatternUnit()); length->SetName(currentLength); initData.data->AddVariable(length); @@ -302,7 +302,7 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement, QList &old const QPointer dialogTool = qobject_cast(m_dialog); SCASSERT(not dialogTool.isNull()) - AddDependence(oldDependencies, curveCutId); + AddDependence(oldDependencies, baseCurveId); AddDependence(newDependencies, dialogTool->getSplinePathId()); doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName()); @@ -320,7 +320,7 @@ void VToolCutSplinePath::SaveOptions(QDomElement &tag, QSharedPointer doc->SetAttribute(tag, AttrType, ToolType); doc->SetAttribute(tag, AttrLength, formula); - doc->SetAttribute(tag, AttrSplinePath, curveCutId); + doc->SetAttribute(tag, AttrSplinePath, baseCurveId); } //--------------------------------------------------------------------------------------------------------------------- @@ -329,7 +329,7 @@ void VToolCutSplinePath::ReadToolAttributes(const QDomElement &domElement) VToolCut::ReadToolAttributes(domElement); formula = doc->GetParametrString(domElement, AttrLength, QString()); - curveCutId = doc->GetParametrUInt(domElement, AttrSplinePath, NULL_ID_STR); + baseCurveId = doc->GetParametrUInt(domElement, AttrSplinePath, NULL_ID_STR); } //--------------------------------------------------------------------------------------------------------------------- @@ -340,10 +340,10 @@ void VToolCutSplinePath::SetVisualization() VisToolCutSplinePath *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(curveCutId); + visual->setObject1Id(baseCurveId); visual->setLength(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator())); - const QSharedPointer curve = VAbstractTool::data.GeometricObject(curveCutId); + const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); visual->RefreshGeometry(); @@ -353,7 +353,7 @@ void VToolCutSplinePath::SetVisualization() //--------------------------------------------------------------------------------------------------------------------- QString VToolCutSplinePath::MakeToolTip() const { - const auto splPath = VAbstractTool::data.GeometricObject(curveCutId); + const auto splPath = VAbstractTool::data.GeometricObject(baseCurveId); const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h index 7a31ba963..d800b297f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h @@ -44,18 +44,6 @@ class VSplinePath; template class QSharedPointer; -struct VToolCutSplinePathInitData : VToolSinglePointInitData -{ - VToolCutSplinePathInitData() - : VToolSinglePointInitData(), - formula(), - splinePathId(NULL_ID) - {} - - QString formula; - quint32 splinePathId; -}; - /** * @brief The VToolCutSplinePath class for tool CutSplinePath. This tool find point on splinePath and cut splinePath on * two. @@ -67,7 +55,7 @@ public: virtual void setDialog() override; static VToolCutSplinePath *Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolCutSplinePath *Create(VToolCutSplinePathInitData &initData); + static VToolCutSplinePath *Create(VToolCutInitData &initData); static const QString ToolType; static const QString AttrSplinePath; virtual int type() const override {return Type;} @@ -90,7 +78,7 @@ protected: private: Q_DISABLE_COPY(VToolCutSplinePath) - VToolCutSplinePath(const VToolCutSplinePathInitData &initData, QGraphicsItem *parent = nullptr); + VToolCutSplinePath(const VToolCutInitData &initData, QGraphicsItem *parent = nullptr); }; #endif // VTOOLCUTSPLINEPATH_H