From bb29984b4add10f0b0656094f81acd8ddc86ed5b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 1 Apr 2016 17:32:36 +0300 Subject: [PATCH] Cut tools do not create subcurves anymore. --HG-- branch : develop --- .../vpatterndb/variables/vcurvevariable.cpp | 2 +- src/libs/vpatterndb/vcontainer.cpp | 24 +++++++-- src/libs/vpatterndb/vcontainer.h | 21 ++------ .../vtools/dialogs/tools/dialogcutarc.cpp | 15 ++---- src/libs/vtools/dialogs/tools/dialogcutarc.h | 5 -- .../vtools/dialogs/tools/dialogcutspline.cpp | 15 ++---- .../vtools/dialogs/tools/dialogcutspline.h | 5 -- .../dialogs/tools/dialogcutsplinepath.cpp | 15 ++---- .../dialogs/tools/dialogcutsplinepath.h | 5 -- src/libs/vtools/dialogs/tools/dialogtool.cpp | 53 +++++-------------- src/libs/vtools/dialogs/tools/dialogtool.h | 14 ++--- .../tools/drawTools/toolcurve/vtoolarc.cpp | 6 +-- .../toolcurve/vtoolarcwithlength.cpp | 6 +-- .../drawTools/toolcurve/vtoolcubicbezier.cpp | 4 +- .../toolcurve/vtoolcubicbezierpath.cpp | 4 +- .../tools/drawTools/toolcurve/vtoolspline.cpp | 4 +- .../drawTools/toolcurve/vtoolsplinepath.cpp | 4 +- .../toolsinglepoint/toolcut/vtoolcut.cpp | 8 +-- .../toolsinglepoint/toolcut/vtoolcut.h | 6 +-- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 40 +++++--------- .../toolsinglepoint/toolcut/vtoolcutarc.h | 3 +- .../toolcut/vtoolcutspline.cpp | 44 +++++---------- .../toolsinglepoint/toolcut/vtoolcutspline.h | 4 +- .../toolcut/vtoolcutsplinepath.cpp | 38 ++++--------- .../toolcut/vtoolcutsplinepath.h | 4 +- 25 files changed, 108 insertions(+), 241 deletions(-) diff --git a/src/libs/vpatterndb/variables/vcurvevariable.cpp b/src/libs/vpatterndb/variables/vcurvevariable.cpp index 9a093a18a..db118bdea 100644 --- a/src/libs/vpatterndb/variables/vcurvevariable.cpp +++ b/src/libs/vpatterndb/variables/vcurvevariable.cpp @@ -68,7 +68,7 @@ VCurveVariable::~VCurveVariable() //--------------------------------------------------------------------------------------------------------------------- bool VCurveVariable::Filter(quint32 id) { - if (d->parentId != 0)//Do not check if value zero + if (d->parentId != NULL_ID)//Do not check if value zero {// Not all curves have parents. Only those who was created after cutting the parent curve. return d->id == id || d->parentId == id; } diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index be2ed287c..2fa5dbae7 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -372,10 +372,8 @@ void VContainer::AddLine(const quint32 &firstPointId, const quint32 &secondPoint } //--------------------------------------------------------------------------------------------------------------------- -void VContainer::AddArc(const quint32 &id, const quint32 &parentId) +void VContainer::AddArc(const QSharedPointer &arc, const quint32 &id, const quint32 &parentId) { - const QSharedPointer arc = GeometricObject(id); - VArcLength *length = new VArcLength(id, parentId, arc.data(), *GetPatternUnit()); AddVariable(length->GetName(), length); @@ -674,3 +672,23 @@ const QHash > *VContainer::DataVariab //--------------------------------------------------------------------------------------------------------------------- VContainerData::~VContainerData() {} + +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::AddCurve(const QSharedPointer &curve, const quint32 &id, const quint32 &parentId) +{ + const GOType curveType = curve->getType(); + if (curveType != GOType::Spline && curveType != GOType::SplinePath && + curveType != GOType::CubicBezier && curveType != GOType::CubicBezierPath) + { + throw VException(tr("Can't create a curve with type %1").arg(static_cast(curveType))); + } + + VSplineLength *length = new VSplineLength(id, parentId, curve.data(), *GetPatternUnit()); + AddVariable(length->GetName(), length); + + VSplineAngle *startAngle = new VSplineAngle(id, parentId, curve.data(), CurveAngle::StartAngle); + AddVariable(startAngle->GetName(), startAngle); + + VSplineAngle *endAngle = new VSplineAngle(id, parentId, curve.data(), CurveAngle::EndAngle); + AddVariable(endAngle->GetName(), endAngle); +} diff --git a/src/libs/vpatterndb/vcontainer.h b/src/libs/vpatterndb/vcontainer.h index 2ceaf97b2..c31921bd4 100644 --- a/src/libs/vpatterndb/vcontainer.h +++ b/src/libs/vpatterndb/vcontainer.h @@ -120,10 +120,10 @@ public: quint32 AddGObject(VGObject *obj); quint32 AddDetail(const VDetail &detail); void AddLine(const quint32 &firstPointId, const quint32 &secondPointId); - void AddArc(const quint32 &arcId, const quint32 &parentId = 0); + void AddArc(const QSharedPointer &arc, const quint32 &arcId, const quint32 &parentId = 0); + void AddCurve(const QSharedPointer &curve, const quint32 &id, + const quint32 &parentId = NULL_ID); - template - void AddCurve(const quint32 &id, const quint32 &parentId = 0); template void AddVariable(const QString& name, T *var); @@ -259,21 +259,6 @@ QSharedPointer VContainer::GetVariable(QString name) const } } -//--------------------------------------------------------------------------------------------------------------------- -template -void VContainer::AddCurve(const quint32 &id, const quint32 &parentId) -{ - const QSharedPointer curve = GeometricObject(id); - VSplineLength *length = new VSplineLength(id, parentId, curve.data(), *GetPatternUnit()); - AddVariable(length->GetName(), length); - - VSplineAngle *startAngle = new VSplineAngle(id, parentId, curve.data(), CurveAngle::StartAngle); - AddVariable(startAngle->GetName(), startAngle); - - VSplineAngle *endAngle = new VSplineAngle(id, parentId, curve.data(), CurveAngle::EndAngle); - AddVariable(endAngle->GetName(), endAngle); -} - //--------------------------------------------------------------------------------------------------------------------- template void VContainer::AddVariable(const QString& name, T *var) diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp index ee2af8f9e..03f0cc852 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp @@ -43,8 +43,7 @@ * @param parent parent widget */ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent) - : DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0), - ch1(NULL_ID), ch2(NULL_ID) + : DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0) { ui->setupUi(this); @@ -62,7 +61,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge flagFormula = false; CheckState(); - FillComboBoxArcs(ui->comboBoxArc, FillComboBox::NoChildren, ch1, ch2); + FillComboBoxArcs(ui->comboBoxArc); FillComboBoxLineColors(ui->comboBoxColor); connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutArc::FXLength); @@ -164,7 +163,7 @@ void DialogCutArc::closeEvent(QCloseEvent *event) */ void DialogCutArc::setArcId(const quint32 &value) { - setCurrentArcId(ui->comboBoxArc, value, FillComboBox::NoChildren, ch1, ch2); + setCurrentArcId(ui->comboBoxArc, value); VisToolCutArc *path = qobject_cast(vis); SCASSERT(path != nullptr); @@ -183,14 +182,6 @@ void DialogCutArc::SetColor(const QString &value) ChangeCurrentData(ui->comboBoxColor, value); } -//--------------------------------------------------------------------------------------------------------------------- -void DialogCutArc::SetChildrenId(const quint32 &ch1, const quint32 &ch2) -{ - this->ch1 = ch1; - this->ch2 = ch2; - FillComboBoxArcs(ui->comboBoxArc, FillComboBox::NoChildren, ch1, ch2); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SetFormula set string with formula length diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.h b/src/libs/vtools/dialogs/tools/dialogcutarc.h index 72d075447..fd219a3f3 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.h +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.h @@ -57,8 +57,6 @@ public: QString GetColor() const; void SetColor(const QString &value); - - void SetChildrenId(const quint32 &ch1, const quint32 &ch2); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; /** @@ -87,9 +85,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - - quint32 ch1; - quint32 ch2; }; #endif // DIALOGCUTARC_H diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp index 38bbb53e5..a52257a6c 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp @@ -42,8 +42,7 @@ * @param parent parent widget */ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0), - ch1(NULL_ID), ch2(NULL_ID) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0) { ui->setupUi(this); @@ -61,7 +60,7 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, flagFormula = false; CheckState(); - FillComboBoxSplines(ui->comboBoxSpline, FillComboBox::NoChildren, ch1, ch2); + FillComboBoxSplines(ui->comboBoxSpline); FillComboBoxLineColors(ui->comboBoxColor); connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSpline::FXLength); @@ -120,7 +119,7 @@ void DialogCutSpline::SetFormula(const QString &value) */ void DialogCutSpline::setSplineId(const quint32 &value) { - setCurrentSplineId(ui->comboBoxSpline, value, FillComboBox::NoChildren, ch1, ch2); + setCurrentSplineId(ui->comboBoxSpline, value); VisToolCutSpline *path = qobject_cast(vis); SCASSERT(path != nullptr); @@ -139,14 +138,6 @@ void DialogCutSpline::SetColor(const QString &value) ChangeCurrentData(ui->comboBoxColor, value); } -//--------------------------------------------------------------------------------------------------------------------- -void DialogCutSpline::SetChildrenId(const quint32 &ch1, const quint32 &ch2) -{ - this->ch1 = ch1; - this->ch2 = ch2; - FillComboBoxSplines(ui->comboBoxSpline, FillComboBox::NoChildren, ch1, ch2); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.h b/src/libs/vtools/dialogs/tools/dialogcutspline.h index 741967ff6..ff472d927 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.h +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.h @@ -56,8 +56,6 @@ public: QString GetColor() const; void SetColor(const QString &value); - - void SetChildrenId(const quint32 &ch1, const quint32 &ch2); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; /** @@ -83,9 +81,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - - quint32 ch1; - quint32 ch2; }; #endif // DIALOGCUTSPLINE_H diff --git a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp index 2237dc6a7..0b94b5fad 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp @@ -42,8 +42,7 @@ * @param parent parent widget */ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0), - ch1(NULL_ID), ch2(NULL_ID) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0) { ui->setupUi(this); @@ -61,7 +60,7 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 & flagFormula = false; CheckState(); - FillComboBoxSplinesPath(ui->comboBoxSplinePath, FillComboBox::NoChildren, ch1, ch2); + FillComboBoxSplinesPath(ui->comboBoxSplinePath); FillComboBoxLineColors(ui->comboBoxColor); connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSplinePath::FXLength); @@ -120,7 +119,7 @@ void DialogCutSplinePath::SetFormula(const QString &value) */ void DialogCutSplinePath::setSplinePathId(const quint32 &value) { - setCurrentSplinePathId(ui->comboBoxSplinePath, value, FillComboBox::NoChildren, ch1, ch2); + setCurrentSplinePathId(ui->comboBoxSplinePath, value); VisToolCutSplinePath *path = qobject_cast(vis); SCASSERT(path != nullptr); @@ -139,14 +138,6 @@ void DialogCutSplinePath::SetColor(const QString &value) ChangeCurrentData(ui->comboBoxColor, value); } -//--------------------------------------------------------------------------------------------------------------------- -void DialogCutSplinePath::SetChildrenId(const quint32 &ch1, const quint32 &ch2) -{ - this->ch1 = ch1; - this->ch2 = ch2; - FillComboBoxSplinesPath(ui->comboBoxSplinePath, FillComboBox::NoChildren, ch1, ch2); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. diff --git a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.h b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.h index 81b89daf5..167d74eae 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.h +++ b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.h @@ -56,8 +56,6 @@ public: QString GetColor() const; void SetColor(const QString &value); - - void SetChildrenId(const quint32 &ch1, const quint32 &ch2); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; /** @@ -83,9 +81,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - - quint32 ch1; - quint32 ch2; }; #endif // DIALOGCUTSPLINEPATH_H diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 92b24c48e..8e1d66333 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -132,7 +132,7 @@ void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule, const quint } //--------------------------------------------------------------------------------------------------------------------- -void DialogTool::FillComboBoxSplines(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const +void DialogTool::FillComboBoxSplines(QComboBox *box) const { SCASSERT(box != nullptr); box->blockSignals(true); @@ -142,24 +142,11 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, FillComboBox rule, const qu QMap list; for (i = objs->constBegin(); i != objs->constEnd(); ++i) { - if (rule == FillComboBox::NoChildren) + if (i.key() != toolId) { - if (i.key() != toolId && i.key() != ch1 && i.key() != ch2) + if (IsSpline(i.value())) { - if (IsSpline(i.value())) - { - PrepareList(list, i.key()); - } - } - } - else - { - if (i.key() != toolId) - { - if (IsSpline(i.value())) - { - PrepareList(list, i.key()); - } + PrepareList(list, i.key()); } } } @@ -169,8 +156,7 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, FillComboBox rule, const qu } //--------------------------------------------------------------------------------------------------------------------- -void DialogTool::FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule, const quint32 &ch1, - const quint32 &ch2) const +void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const { SCASSERT(box != nullptr); box->blockSignals(true); @@ -180,24 +166,11 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule, cons QMap list; for (i = objs->constBegin(); i != objs->constEnd(); ++i) { - if (rule == FillComboBox::NoChildren) + if (i.key() != toolId) { - if (i.key() != toolId && i.key() != ch1 && i.key() != ch2) + if (IsSplinePath(i.value())) { - if (IsSplinePath(i.value())) - { - PrepareList(list, i.key()); - } - } - } - else - { - if (i.key() != toolId) - { - if (IsSplinePath(i.value())) - { - PrepareList(list, i.key()); - } + PrepareList(list, i.key()); } } } @@ -532,11 +505,10 @@ void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value, FillCom /** * @brief setCurrentSplineId set current spline id in combobox */ -void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, FillComboBox rule, - const quint32 &ch1, const quint32 &ch2) const +void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value) const { SCASSERT(box != nullptr); - FillComboBoxSplines(box, rule, ch1, ch2); + FillComboBoxSplines(box); ChangeCurrentData(box, value); } @@ -558,11 +530,10 @@ void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, FillCombo * @param box combobox * @param value splinePath id */ -void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, FillComboBox rule, - const quint32 &ch1, const quint32 &ch2) const +void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value) const { SCASSERT(box != nullptr); - FillComboBoxSplinesPath(box, rule, ch1, ch2); + FillComboBoxSplinesPath(box); ChangeCurrentData(box, value); } diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index 72322ade0..fb70cb1ad 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -188,10 +188,8 @@ protected: const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const; void FillComboBoxArcs(QComboBox *box, FillComboBox rule = FillComboBox::Whole, const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const; - void FillComboBoxSplines(QComboBox *box, FillComboBox rule = FillComboBox::Whole, - const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const; - void FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule = FillComboBox::Whole, - const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const; + void FillComboBoxSplines(QComboBox *box)const; + void FillComboBoxSplinesPath(QComboBox *box)const; void FillComboBoxCurves(QComboBox *box)const; void FillComboBoxTypeLine(QComboBox *box, const QMap &stylesPics) const; void FillComboBoxLineColors(QComboBox *box)const; @@ -211,15 +209,11 @@ protected: void setCurrentPointId(QComboBox *box, const quint32 &value, FillComboBox rule = FillComboBox::NoChildren, const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const; - void setCurrentSplineId(QComboBox *box, const quint32 &value, - FillComboBox rule = FillComboBox::NoChildren, - const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const; + void setCurrentSplineId(QComboBox *box, const quint32 &value) const; void setCurrentArcId(QComboBox *box, const quint32 &value, FillComboBox rule = FillComboBox::NoChildren, const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const; - void setCurrentSplinePathId(QComboBox *box, const quint32 &value, - FillComboBox rule = FillComboBox::NoChildren, - const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const; + void setCurrentSplinePathId(QComboBox *box, const quint32 &value) const; void setCurrentCurveId(QComboBox *box, const quint32 &value) const; quint32 getCurrentObjectId(QComboBox *box) const; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index 599424926..de9687018 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -131,18 +131,18 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &ra calcF1 = CheckFormula(_id, f1, data); calcF2 = CheckFormula(_id, f2, data); - VPointF c = *data->GeometricObject(center); + const VPointF c = *data->GeometricObject(center); VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 ); quint32 id = _id; if (typeCreation == Source::FromGui) { id = data->AddGObject(arc); - data->AddArc(id); + data->AddArc(data->GeometricObject(id), id); } else { data->UpdateGObject(id, arc); - data->AddArc(id); + data->AddArc(data->GeometricObject(id), id); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index cbfc76864..f0edac174 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -100,18 +100,18 @@ VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32 calcLength = qApp->toPixel(CheckFormula(_id, length, data)); calcF1 = CheckFormula(_id, f1, data); - VPointF c = *data->GeometricObject(center); + const VPointF c = *data->GeometricObject(center); VArc *arc = new VArc(calcLength, length, c, calcRadius, radius, calcF1, f1); quint32 id = _id; if (typeCreation == Source::FromGui) { id = data->AddGObject(arc); - data->AddArc(id); + data->AddArc(data->GeometricObject(id), id); } else { data->UpdateGObject(id, arc); - data->AddArc(id); + data->AddArc(data->GeometricObject(id), id); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp index a00a11c43..81ac6476e 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp @@ -91,12 +91,12 @@ VToolCubicBezier *VToolCubicBezier::Create(const quint32 _id, VCubicBezier *spli if (typeCreation == Source::FromGui) { id = data->AddGObject(spline); - data->AddCurve(id); + data->AddCurve(data->GeometricObject(id), id); } else { data->UpdateGObject(id, spline); - data->AddCurve(id); + data->AddCurve(data->GeometricObject(id), id); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp index 3c7e3a24a..b25052264 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp @@ -92,12 +92,12 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(const quint32 _id, VCubicBezi if (typeCreation == Source::FromGui) { id = data->AddGObject(path); - data->AddCurve(id); + data->AddCurve(data->GeometricObject(id), id); } else { data->UpdateGObject(id, path); - data->AddCurve(id); + data->AddCurve(data->GeometricObject(id), id); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 0b73033bb..077e5957d 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -162,12 +162,12 @@ VToolSpline* VToolSpline::Create(const quint32 _id, VSpline *spline, const QStri if (typeCreation == Source::FromGui) { id = data->AddGObject(spline); - data->AddCurve(id); + data->AddCurve(data->GeometricObject(id), id); } else { data->UpdateGObject(id, spline); - data->AddCurve(id); + data->AddCurve(data->GeometricObject(id), id); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index c6075650e..4aab51ac2 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -166,12 +166,12 @@ VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, c if (typeCreation == Source::FromGui) { id = data->AddGObject(path); - data->AddCurve(id); + data->AddCurve(data->GeometricObject(id), id); } else { data->UpdateGObject(id, path); - data->AddCurve(id); + data->AddCurve(data->GeometricObject(id), id); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); 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 a5f263011..d78c488e3 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp @@ -32,14 +32,10 @@ //--------------------------------------------------------------------------------------------------------------------- VToolCut::VToolCut(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &curveCutId, const quint32 &curve1id, const quint32 &curve2id, const QString &color, - QGraphicsItem *parent) - :VToolSinglePoint(doc, data, id, parent), formula(formula), - curveCutId(curveCutId), curve1id(curve1id), curve2id(curve2id), detailsMode(false) + const quint32 &curveCutId, const QString &color, QGraphicsItem *parent) + :VToolSinglePoint(doc, data, id, parent), formula(formula), curveCutId(curveCutId), detailsMode(false) { Q_ASSERT_X(curveCutId != 0, Q_FUNC_INFO, "curveCutId == 0"); //-V654 //-V712 - Q_ASSERT_X(curve1id != 0, Q_FUNC_INFO, "curve1id == 0"); //-V654 //-V712 - Q_ASSERT_X(curve2id != 0, Q_FUNC_INFO, "curve2id == 0"); //-V654 //-V712 lineColor = color; } 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 6ba9fe2a1..8e580a250 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h @@ -39,8 +39,7 @@ class VToolCut : public VToolSinglePoint Q_OBJECT public: VToolCut(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &curveCutId, - const quint32 &curve1id, const quint32 &curve2id, const QString &color, QGraphicsItem * parent = nullptr); + const quint32 &curveCutId, const QString &color, QGraphicsItem * parent = nullptr); virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Tool::Cut)}; @@ -59,9 +58,6 @@ protected: QString formula; quint32 curveCutId; - quint32 curve1id; - quint32 curve2id; - bool detailsMode; void RefreshGeometry(); 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 f1699afb8..d35bd13c9 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -44,15 +44,14 @@ const QString VToolCutArc::ToolType = QStringLiteral("cutArc"); * @param id object id in container. * @param formula string with formula length first arc. * @param arcId id arc in data container. - * @param arc1id id first cutting arc. - * @param arc2id id second cutting arc. + * @param color arc color. * @param typeCreation way we create this tool. * @param parent parent object. */ VToolCutArc::VToolCutArc(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &arcId, const quint32 &arc1id, const quint32 &arc2id, const QString &color, - const Source &typeCreation, QGraphicsItem * parent) - :VToolCut(doc, data, id, formula, arcId, arc1id, arc2id, color, parent) + const quint32 &arcId, const QString &color, const Source &typeCreation, + QGraphicsItem * parent) + :VToolCut(doc, data, id, formula, arcId, color, parent) { ToolCreation(typeCreation); } @@ -67,7 +66,6 @@ void VToolCutArc::setDialog() DialogCutArc *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - dialogTool->SetChildrenId(curve1id, curve2id); dialogTool->SetFormula(formula); dialogTool->setArcId(curveCutId); dialogTool->SetPointName(point->name()); @@ -129,28 +127,20 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS QPointF point = arc->CutArc(qApp->toPixel(result), arc1, arc2); quint32 id = _id; - quint32 arc1id = 0; - quint32 arc2id = 0; + VPointF *p = new VPointF(point, pointName, mx, my); + auto a1 = QSharedPointer(new VArc(arc1)); + auto a2 = QSharedPointer(new VArc(arc2)); if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(point, pointName, mx, my)); - arc1id = data->AddGObject(new VArc(arc1)); - arc2id = data->AddGObject(new VArc(arc2)); - - data->AddArc(arc1id, id); - data->AddArc(arc2id, id); + id = data->AddGObject(p); + data->AddArc(a1, NULL_ID, id); + data->AddArc(a2, NULL_ID, id); } else { - data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); - arc1id = id + 1; - arc2id = id + 2; - - data->UpdateGObject(arc1id, new VArc(arc1)); - data->UpdateGObject(arc2id, new VArc(arc2)); - - data->AddArc(arc1id, id); - data->AddArc(arc2id, id); + data->UpdateGObject(id, p); + data->AddArc(a1, NULL_ID, id); + data->AddArc(a2, NULL_ID, id); if (parse != Document::FullParse) { @@ -161,12 +151,10 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS VDrawTool::AddRecord(id, Tool::CutArc, doc); if (parse == Document::FullParse) { - VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, color, typeCreation); + VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, color, typeCreation); scene->addItem(point); InitToolConnections(scene, point); doc->AddTool(id, point); - doc->AddTool(arc1id, point); - doc->AddTool(arc2id, point); doc->IncrementReferens(arc->getIdTool()); return point; } 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 3900fe74f..94d6944c5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h @@ -39,8 +39,7 @@ class VToolCutArc : public VToolCut Q_OBJECT public: VToolCutArc(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &arcId, - const quint32 &arc1id, const quint32 &arc2id, const QString &color, const Source &typeCreation, + const quint32 &arcId, const QString &color, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog() Q_DECL_OVERRIDE; static VToolCutArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); 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 896076bff..2f959f3bc 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -45,13 +45,14 @@ const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); * @param id object id in container. * @param formula string with formula length first spline. * @param splineId id spline in data container. + * @param color spline color. * @param typeCreation way we create this tool. * @param parent parent object. */ VToolCutSpline::VToolCutSpline(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, - const QString &color, const Source &typeCreation, QGraphicsItem *parent) - :VToolCut(doc, data, id, formula, splineId, spl1id, spl2id, color, parent) + const quint32 &splineId, const QString &color, const Source &typeCreation, + QGraphicsItem *parent) + :VToolCut(doc, data, id, formula, splineId, color, parent) { ToolCreation(typeCreation); } @@ -66,7 +67,6 @@ void VToolCutSpline::setDialog() DialogCutSpline *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - dialogTool->SetChildrenId(curve1id, curve2id); dialogTool->SetFormula(formula); dialogTool->setSplineId(curveCutId); dialogTool->SetPointName(point->name()); @@ -128,36 +128,21 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3); quint32 id = _id; - quint32 spl1id = 0; - quint32 spl2id = 0; + VPointF *p = new VPointF(point, pointName, mx, my); + auto spline1 = QSharedPointer(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p)); + auto spline2 = QSharedPointer(new VSpline(*p, spl2p2, spl2p3, spl->GetP4())); + if (typeCreation == Source::FromGui) { - VPointF *p = new VPointF(point, pointName, mx, my); id = data->AddGObject(p); - - VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p); - spl1id = data->AddGObject(spline1); - data->AddCurve(spl1id, id); - - VSpline *spline2 = new VSpline(*p, spl2p2, spl2p3, spl->GetP4()); - spl2id = data->AddGObject(spline2); - data->AddCurve(spl2id, id); + data->AddCurve(spline1, NULL_ID, id); + data->AddCurve(spline2, NULL_ID, id); } else { - VPointF *p = new VPointF(point, pointName, mx, my); data->UpdateGObject(id, p); - - spl1id = id + 1; - spl2id = id + 2; - - VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p); - data->UpdateGObject(spl1id, spline1); - data->AddCurve(spl1id, id); - - VSpline *spline2 = new VSpline(*p, spl2p2, spl2p3, spl->GetP4()); - data->UpdateGObject(spl2id, spline2); - data->AddCurve(spl2id, id); + data->AddCurve(spline1, NULL_ID, id); + data->AddCurve(spline2, NULL_ID, id); if (parse != Document::FullParse) { @@ -167,13 +152,10 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa VDrawTool::AddRecord(id, Tool::CutSpline, doc); if (parse == Document::FullParse) { - VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, color, - typeCreation); + VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, color, typeCreation); scene->addItem(point); InitToolConnections(scene, point); doc->AddTool(id, point); - doc->AddTool(spl1id, point); - doc->AddTool(spl2id, point); doc->IncrementReferens(spl->getIdTool()); return point; } 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 f29a1f4f2..84e0fc3bd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h @@ -40,8 +40,8 @@ class VToolCutSpline : public VToolCut public: VToolCutSpline(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, const QString &color, - const Source &typeCreation, QGraphicsItem * parent = nullptr); + const quint32 &splineId, const QString &color, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual void setDialog() Q_DECL_OVERRIDE; static VToolCutSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); 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 6cbe40add..dec424071 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -45,16 +45,14 @@ const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath"); * @param id object id in container. * @param formula string with formula length first splinePath. * @param splinePathId id splinePath (we cut this splinePath) in data container. - * @param splPath1id id first splinePath after cutting. - * @param splPath2id id second splinePath after cutting. + * @param color spline path color. * @param typeCreation way we create this tool. * @param parent parent object. */ VToolCutSplinePath::VToolCutSplinePath(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &splinePathId, - const quint32 &splPath1id, const quint32 &splPath2id, const QString &color, - const Source &typeCreation, QGraphicsItem *parent) - :VToolCut(doc, data, id, formula, splinePathId, splPath1id, splPath2id, color, parent) + const QString &color, const Source &typeCreation, QGraphicsItem *parent) + :VToolCut(doc, data, id, formula, splinePathId, color, parent) { ToolCreation(typeCreation); } @@ -69,7 +67,6 @@ void VToolCutSplinePath::setDialog() DialogCutSplinePath *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - dialogTool->SetChildrenId(curve1id, curve2id); dialogTool->SetFormula(formula); dialogTool->setSplinePathId(curveCutId); dialogTool->SetPointName(point->name()); @@ -143,30 +140,16 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString if (typeCreation == Source::FromGui) { id = data->AddGObject(p); + + data->AddCurve(QSharedPointer(splPath1), NULL_ID, id); + data->AddCurve(QSharedPointer(splPath2), NULL_ID, id); } else { data->UpdateGObject(id, p); - } - quint32 splPath1id = id + 1; - quint32 splPath2id = id + 2; - - if (typeCreation == Source::FromGui) - { - splPath1id = data->AddGObject(splPath1); - data->AddCurve(splPath1id, id); - - splPath2id = data->AddGObject(splPath2); - data->AddCurve(splPath2id, id); - } - else - { - data->UpdateGObject(splPath1id, splPath1); - data->AddCurve(splPath1id, id); - - data->UpdateGObject(splPath2id, splPath2); - data->AddCurve(splPath2id, id); + data->AddCurve(QSharedPointer(splPath1), NULL_ID, id); + data->AddCurve(QSharedPointer(splPath2), NULL_ID, id); if (parse != Document::FullParse) { @@ -177,13 +160,10 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString VDrawTool::AddRecord(id, Tool::CutSplinePath, doc); if (parse == Document::FullParse) { - VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id, - splPath2id, color, typeCreation); + VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, color, typeCreation); scene->addItem(point); InitToolConnections(scene, point); doc->AddTool(id, point); - doc->AddTool(splPath1id, point); - doc->AddTool(splPath2id, point); doc->IncrementReferens(splPath->getIdTool()); return point; } 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 fab09cf05..a0517d69c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h @@ -44,8 +44,8 @@ class VToolCutSplinePath : public VToolCut public: VToolCutSplinePath(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &splinePathId, const quint32 &splPath1id, const quint32 &splPath2id, - const QString &color, const Source &typeCreation, QGraphicsItem * parent = nullptr); + const quint32 &splinePathId, const QString &color, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual void setDialog() Q_DECL_OVERRIDE; static VToolCutSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data);