diff --git a/src/libs/ifc/schema/pattern/v0.8.10.xsd b/src/libs/ifc/schema/pattern/v0.8.10.xsd index 0eef3d1c6..73dbb01e0 100644 --- a/src/libs/ifc/schema/pattern/v0.8.10.xsd +++ b/src/libs/ifc/schema/pattern/v0.8.10.xsd @@ -183,6 +183,7 @@ + diff --git a/src/libs/vgeometry/varc.cpp b/src/libs/vgeometry/varc.cpp index 244737781..545b2f98f 100644 --- a/src/libs/vgeometry/varc.cpp +++ b/src/libs/vgeometry/varc.cpp @@ -145,6 +145,12 @@ VArc VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &pref VArc arc(center, GetRadius(), f1, f2); arc.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + arc.SetAliasSuffix(GetAliasSuffix() + prefix); + } + arc.SetColor(GetColor()); arc.SetPenStyle(GetPenStyle()); arc.SetFlipped(IsFlipped()); @@ -165,6 +171,12 @@ VArc VArc::Flip(const QLineF &axis, const QString &prefix) const VArc arc(center, GetRadius(), f1, f2); arc.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + arc.SetAliasSuffix(GetAliasSuffix() + prefix); + } + arc.SetColor(GetColor()); arc.SetPenStyle(GetPenStyle()); arc.SetFlipped(not IsFlipped()); @@ -185,6 +197,12 @@ VArc VArc::Move(qreal length, qreal angle, const QString &prefix) const VArc arc(center, GetRadius(), f1, f2); arc.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + arc.SetAliasSuffix(GetAliasSuffix() + prefix); + } + arc.SetColor(GetColor()); arc.SetPenStyle(GetPenStyle()); arc.SetFlipped(IsFlipped()); diff --git a/src/libs/vgeometry/vcubicbezier.cpp b/src/libs/vgeometry/vcubicbezier.cpp index 66559bc69..2f2303f2a 100644 --- a/src/libs/vgeometry/vcubicbezier.cpp +++ b/src/libs/vgeometry/vcubicbezier.cpp @@ -88,6 +88,12 @@ VCubicBezier VCubicBezier::Rotate(const QPointF &originPoint, qreal degrees, con const VPointF p4 = GetP4().Rotate(originPoint, degrees); VCubicBezier curve(p1, p2, p3, p4); curve.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + curve.SetAliasSuffix(GetAliasSuffix() + prefix); + } + curve.SetColor(GetColor()); curve.SetPenStyle(GetPenStyle()); curve.SetApproximationScale(GetApproximationScale()); @@ -103,6 +109,12 @@ VCubicBezier VCubicBezier::Flip(const QLineF &axis, const QString &prefix) const const VPointF p4 = GetP4().Flip(axis); VCubicBezier curve(p1, p2, p3, p4); curve.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + curve.SetAliasSuffix(GetAliasSuffix() + prefix); + } + curve.SetColor(GetColor()); curve.SetPenStyle(GetPenStyle()); curve.SetApproximationScale(GetApproximationScale()); @@ -118,6 +130,12 @@ VCubicBezier VCubicBezier::Move(qreal length, qreal angle, const QString &prefix const VPointF p4 = GetP4().Move(length, angle); VCubicBezier curve(p1, p2, p3, p4); curve.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + curve.SetAliasSuffix(GetAliasSuffix() + prefix); + } + curve.SetColor(GetColor()); curve.SetPenStyle(GetPenStyle()); curve.SetApproximationScale(GetApproximationScale()); diff --git a/src/libs/vgeometry/vcubicbezierpath.cpp b/src/libs/vgeometry/vcubicbezierpath.cpp index 2e2261092..ca94123a7 100644 --- a/src/libs/vgeometry/vcubicbezierpath.cpp +++ b/src/libs/vgeometry/vcubicbezierpath.cpp @@ -104,6 +104,12 @@ VCubicBezierPath VCubicBezierPath::Rotate(const QPointF &originPoint, qreal degr curve.append(point.Rotate(originPoint, degrees)); } curve.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + curve.SetAliasSuffix(GetAliasSuffix() + prefix); + } + curve.SetColor(GetColor()); curve.SetPenStyle(GetPenStyle()); curve.SetApproximationScale(GetApproximationScale()); @@ -120,6 +126,12 @@ VCubicBezierPath VCubicBezierPath::Flip(const QLineF &axis, const QString &prefi curve.append(point.Flip(axis)); } curve.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + curve.SetAliasSuffix(GetAliasSuffix() + prefix); + } + curve.SetColor(GetColor()); curve.SetPenStyle(GetPenStyle()); curve.SetApproximationScale(GetApproximationScale()); @@ -136,6 +148,12 @@ VCubicBezierPath VCubicBezierPath::Move(qreal length, qreal angle, const QString curve.append(point.Move(length, angle)); } curve.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + curve.SetAliasSuffix(GetAliasSuffix() + prefix); + } + curve.SetColor(GetColor()); curve.SetPenStyle(GetPenStyle()); curve.SetApproximationScale(GetApproximationScale()); diff --git a/src/libs/vgeometry/vellipticalarc.cpp b/src/libs/vgeometry/vellipticalarc.cpp index 0683dde6a..68b878de3 100644 --- a/src/libs/vgeometry/vellipticalarc.cpp +++ b/src/libs/vgeometry/vellipticalarc.cpp @@ -153,6 +153,12 @@ VEllipticalArc VEllipticalArc::Rotate(QPointF originPoint, qreal degrees, const VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(), VAbstractArc::GetEndAngle(), GetRotationAngle()); elArc.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + elArc.SetAliasSuffix(GetAliasSuffix() + prefix); + } + elArc.SetColor(GetColor()); elArc.SetPenStyle(GetPenStyle()); elArc.SetFlipped(IsFlipped()); @@ -166,6 +172,12 @@ VEllipticalArc VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) c VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(), VAbstractArc::GetEndAngle(), GetRotationAngle()); elArc.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + elArc.SetAliasSuffix(GetAliasSuffix() + prefix); + } + elArc.SetColor(GetColor()); elArc.SetPenStyle(GetPenStyle()); elArc.SetFlipped(not IsFlipped()); @@ -188,6 +200,12 @@ VEllipticalArc VEllipticalArc::Move(qreal length, qreal angle, const QString &pr VEllipticalArc elArc(oldCenter, GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(), VAbstractArc::GetEndAngle(), GetRotationAngle()); elArc.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + elArc.SetAliasSuffix(GetAliasSuffix() + prefix); + } + elArc.SetColor(GetColor()); elArc.SetPenStyle(GetPenStyle()); elArc.SetFlipped(IsFlipped()); diff --git a/src/libs/vgeometry/vgobject.h b/src/libs/vgeometry/vgobject.h index 2078d40c8..05f80a0e8 100644 --- a/src/libs/vgeometry/vgobject.h +++ b/src/libs/vgeometry/vgobject.h @@ -78,11 +78,11 @@ public: quint32 id() const; virtual void setId(const quint32 &id); - void SetAlias(const QString &alias); - QString GetAlias() const; + virtual void SetAlias(const QString &alias); + QString GetAlias() const; - virtual void SetAliasSuffix(const QString &aliasSuffix); - QString GetAliasSuffix() const; + virtual void SetAliasSuffix(const QString &aliasSuffix); + QString GetAliasSuffix() const; QString ObjectName() const; diff --git a/src/libs/vgeometry/vpointf.cpp b/src/libs/vgeometry/vpointf.cpp index cada4323c..ed15998d6 100644 --- a/src/libs/vgeometry/vpointf.cpp +++ b/src/libs/vgeometry/vpointf.cpp @@ -147,6 +147,7 @@ VPointF VPointF::Move(qreal length, qreal angle, const QString &prefix) const const QPointF p = MovePF(toQPointF(), length, angle); VPointF moved(p, name() + prefix, mx(), my()); moved.SetShowLabel(IsShowLabel()); + return moved; } @@ -260,6 +261,20 @@ QJsonObject VPointF::ToJson() const return object; } +//--------------------------------------------------------------------------------------------------------------------- +void VPointF::SetAlias(const QString &alias) +{ + Q_UNUSED(alias); + // do nothing +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPointF::SetAliasSuffix(const QString &aliasSuffix) +{ + Q_UNUSED(aliasSuffix); + // do nothing +} + //--------------------------------------------------------------------------------------------------------------------- QPointF VPointF::RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees) { diff --git a/src/libs/vgeometry/vpointf.h b/src/libs/vgeometry/vpointf.h index 820afeebc..4381b2f2d 100644 --- a/src/libs/vgeometry/vpointf.h +++ b/src/libs/vgeometry/vpointf.h @@ -85,6 +85,9 @@ public: virtual QJsonObject ToJson() const override; + virtual void SetAlias(const QString &alias) override; + virtual void SetAliasSuffix(const QString &aliasSuffix) override; + static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees); static QPointF FlipPF(const QLineF &axis, const QPointF &point); static QPointF MovePF(const QPointF &originPoint, qreal length, qreal angle); diff --git a/src/libs/vgeometry/vspline.cpp b/src/libs/vgeometry/vspline.cpp index 02e158c87..a9c6eaea9 100644 --- a/src/libs/vgeometry/vspline.cpp +++ b/src/libs/vgeometry/vspline.cpp @@ -122,6 +122,12 @@ VSpline VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString VSpline spl(p1, p2, p3, p4); spl.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + spl.SetAliasSuffix(GetAliasSuffix() + prefix); + } + spl.SetColor(GetColor()); spl.SetPenStyle(GetPenStyle()); spl.SetApproximationScale(GetApproximationScale()); @@ -139,6 +145,12 @@ VSpline VSpline::Flip(const QLineF &axis, const QString &prefix) const VSpline spl(p1, p2, p3, p4); spl.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + spl.SetAliasSuffix(GetAliasSuffix() + prefix); + } + spl.SetColor(GetColor()); spl.SetPenStyle(GetPenStyle()); spl.SetApproximationScale(GetApproximationScale()); @@ -156,6 +168,12 @@ VSpline VSpline::Move(qreal length, qreal angle, const QString &prefix) const VSpline spl(p1, p2, p3, p4); spl.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + spl.SetAliasSuffix(GetAliasSuffix() + prefix); + } + spl.SetColor(GetColor()); spl.SetPenStyle(GetPenStyle()); spl.SetApproximationScale(GetApproximationScale()); diff --git a/src/libs/vgeometry/vsplinepath.cpp b/src/libs/vgeometry/vsplinepath.cpp index 6e791eeee..e3ec4e726 100644 --- a/src/libs/vgeometry/vsplinepath.cpp +++ b/src/libs/vgeometry/vsplinepath.cpp @@ -122,6 +122,12 @@ VSplinePath VSplinePath::Rotate(const QPointF &originPoint, qreal degrees, const VSplinePath splPath(newPoints); splPath.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + splPath.SetAliasSuffix(GetAliasSuffix() + prefix); + } + splPath.SetColor(GetColor()); splPath.SetPenStyle(GetPenStyle()); splPath.SetApproximationScale(GetApproximationScale()); @@ -147,6 +153,12 @@ VSplinePath VSplinePath::Flip(const QLineF &axis, const QString &prefix) const VSplinePath splPath(newPoints); splPath.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + splPath.SetAliasSuffix(GetAliasSuffix() + prefix); + } + splPath.SetColor(GetColor()); splPath.SetPenStyle(GetPenStyle()); splPath.SetApproximationScale(GetApproximationScale()); @@ -172,6 +184,12 @@ VSplinePath VSplinePath::Move(qreal length, qreal angle, const QString &prefix) VSplinePath splPath(newPoints); splPath.setName(name() + prefix); + + if (not GetAliasSuffix().isEmpty()) + { + splPath.SetAliasSuffix(GetAliasSuffix() + prefix); + } + splPath.SetColor(GetColor()); splPath.SetPenStyle(GetPenStyle()); splPath.SetApproximationScale(GetApproximationScale()); diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp index 9cb7a6c04..b45d2a359 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp @@ -249,6 +249,10 @@ void DialogFlippingByAxis::SetSourceObjects(const QVector &value) { sourceObjects = value; FillSourceList(); + + VisToolFlippingByAxis *operation = qobject_cast(vis); + SCASSERT(operation != nullptr) + operation->SetObjects(SourceToObjects(sourceObjects)); } //--------------------------------------------------------------------------------------------------------------------- @@ -392,21 +396,8 @@ void DialogFlippingByAxis::ShowSourceDetails(int row) ui->lineEditAlias->setEnabled(true); ui->lineEditAlias->blockSignals(false); - QRegularExpression rx(NameRegExp()); - if (not rx.match(sourceItem.alias).hasMatch() || not data->IsUnique(sourceItem.alias)) - { - flagAlias = false; - ChangeColor(ui->labelAlias, errorColor); - ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias")); - CheckState(); - return; - } - else - { - flagAlias = true; - ChangeColor(ui->labelAlias, errorColor); - CheckState(); - } + SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data, + OriginAlias(sourceItem.id, sourceObjects, obj))); } //--------------------------------------------------------------------------------------------------------------------- @@ -515,8 +506,9 @@ void DialogFlippingByAxis::FillSourceList() for (auto &sourceItem : sourceObjects) { const QSharedPointer obj = data->GetGObject(sourceItem.id); + bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)); - auto *item = new QListWidgetItem(obj->ObjectName()); + auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*'); item->setToolTip(obj->ObjectName()); item->setData(Qt::UserRole, QVariant::fromValue(sourceItem)); ui->listWidget->insertItem(++row, item); @@ -535,8 +527,6 @@ void DialogFlippingByAxis::FillSourceList() //--------------------------------------------------------------------------------------------------------------------- void DialogFlippingByAxis::ValidateSourceAliases() { - QRegularExpression rx(NameRegExp()); - for (int i=0; ilistWidget->count(); ++i) { if (const QListWidgetItem *item = ui->listWidget->item(i)) @@ -545,27 +535,39 @@ void DialogFlippingByAxis::ValidateSourceAliases() const QSharedPointer obj = data->GetGObject(sourceItem.id); - QString name; - - if (obj->getType() == GOType::Point) - { - name = sourceItem.alias; - } - else - { - const QString oldAlias = obj->GetAliasSuffix(); - obj->SetAliasSuffix(sourceItem.alias); - name = obj->GetAlias(); - obj->SetAliasSuffix(oldAlias); - } - - if (not rx.match(name).hasMatch() || not data->IsUnique(name)) + if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj))) { flagAlias = false; ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias")); + SetAliasValid(sourceItem.id, false); CheckState(); return; } + else + { + SetAliasValid(sourceItem.id, true); + } + } + } + + flagAlias = true; + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogFlippingByAxis::SetAliasValid(quint32 id, bool valid) +{ + if (ui->listWidget->currentRow() != -1) + { + auto *item = ui->listWidget->item(ui->listWidget->currentRow()); + const auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + + if (id == sourceItem.id) + { + const QSharedPointer obj = data->GetGObject(sourceItem.id); + item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*'); + + ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor); } } } diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h index 4f62e5004..2128c8048 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h @@ -40,6 +40,7 @@ #include #include "../vmisc/def.h" +#include "../../tools/toolsdef.h" namespace Ui { @@ -63,8 +64,6 @@ public: QString GetSuffix() const; void SetSuffix(const QString &value); - QVector GetObjects() const; - QString GetVisibilityGroupName() const; void SetVisibilityGroupName(const QString &name); @@ -81,6 +80,9 @@ public: virtual void ShowDialog(bool click) override; + QVector GetSourceObjects() const; + void SetSourceObjects(const QVector &value); + public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) override; virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override; @@ -88,6 +90,8 @@ public slots: private slots: void SuffixChanged(); void GroupNameChanged(); + void ShowSourceDetails(int row); + void AliasChanged(const QString &text); protected: virtual void ShowVisualization() override; @@ -104,7 +108,7 @@ private: Ui::DialogFlippingByAxis *ui; - QList objects; + QVector sourceObjects{}; bool stage1; @@ -113,16 +117,16 @@ private: bool flagName; bool flagGroupName; bool flagError; + bool flagAlias{true}; QStringList m_groupTags{}; static void FillComboBoxAxisType(QComboBox *box); + + void FillSourceList(); + + void ValidateSourceAliases(); + void SetAliasValid(quint32 id, bool valid); }; -//--------------------------------------------------------------------------------------------------------------------- -inline bool DialogFlippingByAxis::IsValid() const -{ - return flagError && flagName && flagGroupName; -} - #endif // DIALOGFLIPPINGBYAXIS_H diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui index df35b0448..dada02ff6 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui @@ -6,8 +6,8 @@ 0 0 - 304 - 296 + 415 + 464 @@ -28,6 +28,35 @@ Tool + + + + Qt::Horizontal + + + + + + + + Alias: + + + + + + + false + + + true + + + + + + + @@ -48,7 +77,11 @@ - + + + true + + @@ -117,6 +150,13 @@ + + + + Ready + + + diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp index 6c050756a..d664e0f2e 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp @@ -64,7 +64,6 @@ DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, quint32 toolId, QWidget *parent) : DialogTool(data, toolId, parent), ui(new Ui::DialogFlippingByLine), - objects(), stage1(true), m_suffix(), flagName(true), @@ -142,12 +141,6 @@ void DialogFlippingByLine::SetSuffix(const QString &value) ui->lineEditSuffix->setText(value); } -//--------------------------------------------------------------------------------------------------------------------- -QVector DialogFlippingByLine::GetObjects() const -{ - return ConvertToVector(objects); -} - //--------------------------------------------------------------------------------------------------------------------- QString DialogFlippingByLine::GetVisibilityGroupName() const { @@ -196,7 +189,7 @@ void DialogFlippingByLine::ShowDialog(bool click) { if (stage1 && not click) { - if (objects.isEmpty()) + if (sourceObjects.isEmpty()) { return; } @@ -209,7 +202,7 @@ void DialogFlippingByLine::ShowDialog(bool click) VisToolFlippingByLine *operation = qobject_cast(vis); SCASSERT(operation != nullptr) - operation->SetObjects(ConvertToVector(objects)); + operation->SetObjects(SourceToObjects(sourceObjects)); operation->VisualMode(); scene->ToggleArcSelection(false); @@ -224,6 +217,8 @@ void DialogFlippingByLine::ShowDialog(bool click) qApp->getSceneView()->AllowRubberBand(false); + FillSourceList(); + emit ToolTip(tr("Select first line point")); } else if (not stage1 && prepare && click) @@ -234,6 +229,23 @@ void DialogFlippingByLine::ShowDialog(bool click) } } +//--------------------------------------------------------------------------------------------------------------------- +QVector DialogFlippingByLine::GetSourceObjects() const +{ + return sourceObjects; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogFlippingByLine::SetSourceObjects(const QVector &value) +{ + sourceObjects = value; + FillSourceList(); + + VisToolFlippingByLine *operation = qobject_cast(vis); + SCASSERT(operation != nullptr) + operation->SetObjects(SourceToObjects(sourceObjects)); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type) { @@ -241,10 +253,12 @@ void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [id](const SourceItem &sItem) { return sItem.id == id; }); switch (number) { case 0: - if (objects.contains(id)) + if (obj != sourceObjects.end()) { emit ToolTip(tr("Select first line point that is not part of the list of objects")); return; @@ -260,7 +274,7 @@ void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type) } break; case 1: - if (objects.contains(id)) + if (obj != sourceObjects.end()) { emit ToolTip(tr("Select second line point that is not part of the list of objects")); return; @@ -296,16 +310,23 @@ void DialogFlippingByLine::SelectedObject(bool selected, quint32 object, quint32 Q_UNUSED(tool) if (stage1) { + auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [object](const SourceItem &sItem) { return sItem.id == object; }); if (selected) { - if (not objects.contains(object)) + if (obj == sourceObjects.cend()) { - objects.append(object); + SourceItem item; + item.id = object; + sourceObjects.append(item); } } else { - objects.removeOne(object); + if (obj != sourceObjects.end()) + { + sourceObjects.erase(obj); + } } } } @@ -321,6 +342,7 @@ void DialogFlippingByLine::SuffixChanged() { flagName = false; ChangeColor(ui->labelSuffix, errorColor); + ui->labelStatus->setText(tr("Invalid suffix")); CheckState(); return; } @@ -337,6 +359,7 @@ void DialogFlippingByLine::SuffixChanged() { flagName = false; ChangeColor(ui->labelSuffix, errorColor); + ui->labelStatus->setText(tr("Invalid suffix")); CheckState(); return; } @@ -361,6 +384,7 @@ void DialogFlippingByLine::GroupNameChanged() { flagGroupName = false; ChangeColor(ui->labelGroupName, errorColor); + ui->labelStatus->setText(tr("Invalid group name")); CheckState(); return; } @@ -371,6 +395,50 @@ void DialogFlippingByLine::GroupNameChanged() CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogFlippingByLine::ShowSourceDetails(int row) +{ + ui->lineEditAlias->setDisabled(true); + + if (ui->listWidget->count() == 0) + { + return; + } + + const auto sourceItem = qvariant_cast(ui->listWidget->item(row)->data(Qt::UserRole)); + + const QSharedPointer obj = data->GetGObject(sourceItem.id); + + ui->labelAlias->setText(obj->getType() == GOType::Point ? tr("Label:") : tr("Alias:")); + + ui->lineEditAlias->blockSignals(true); + ui->lineEditAlias->setText(sourceItem.alias); + ui->lineEditAlias->setEnabled(true); + ui->lineEditAlias->blockSignals(false); + + SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data, + OriginAlias(sourceItem.id, sourceObjects, obj))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogFlippingByLine::AliasChanged(const QString &text) +{ + if (ui->listWidget->count() == 0) + { + return; + } + + if (auto *item = ui->listWidget->currentItem()) + { + auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + sourceItem.alias = text; + + item->setData(Qt::UserRole, QVariant::fromValue(sourceItem)); + + ValidateSourceAliases(); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogFlippingByLine::ShowVisualization() { @@ -382,10 +450,22 @@ void DialogFlippingByLine::SaveData() { m_suffix = ui->lineEditSuffix->text(); + sourceObjects.clear(); + sourceObjects.reserve(ui->listWidget->count()); + + for (int i=0; ilistWidget->count(); ++i) + { + if (const QListWidgetItem *item = ui->listWidget->item(i)) + { + auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + sourceObjects.append(sourceItem); + } + } + VisToolFlippingByLine *operation = qobject_cast(vis); SCASSERT(operation != nullptr) - operation->SetObjects(ConvertToVector(objects)); + operation->SetObjects(SourceToObjects(sourceObjects)); operation->SetFirstLinePointId(GetFirstLinePointId()); operation->SetSecondLinePointId(GetSecondLinePointId()); operation->RefreshGeometry(); @@ -411,29 +491,118 @@ void DialogFlippingByLine::PointChanged() ChangeColor(ui->labelFirstLinePoint, color); ChangeColor(ui->labelSecondLinePoint, color); + quint32 id1 = getCurrentObjectId(ui->comboBoxFirstLinePoint); + auto obj1 = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [id1](const SourceItem &sItem) { return sItem.id == id1; }); + + quint32 id2 = getCurrentObjectId(ui->comboBoxSecondLinePoint); + auto obj2 = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [id2](const SourceItem &sItem) { return sItem.id == id2; }); + if (getCurrentObjectId(ui->comboBoxFirstLinePoint) == getCurrentObjectId(ui->comboBoxSecondLinePoint)) { flagError = false; color = errorColor; ChangeColor(ui->labelFirstLinePoint, color); ChangeColor(ui->labelSecondLinePoint, color); + ui->labelStatus->setText(tr("Invalid line points")); } - else if (objects.contains(getCurrentObjectId(ui->comboBoxFirstLinePoint))) + else if (obj1 != sourceObjects.end()) { flagError = false; color = errorColor; ChangeColor(ui->labelFirstLinePoint, color); + ui->labelStatus->setText(tr("Invalid first line point")); } - else if (objects.contains(getCurrentObjectId(ui->comboBoxSecondLinePoint))) + else if (obj2 != sourceObjects.end()) { flagError = false; color = errorColor; ChangeColor(ui->labelSecondLinePoint, color); + ui->labelStatus->setText(tr("Invalid second line point")); } CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogFlippingByLine::FillSourceList() +{ + ui->listWidget->blockSignals(true); + + ui->listWidget->clear(); + + int row = -1; + + for (auto &sourceItem : sourceObjects) + { + const QSharedPointer obj = data->GetGObject(sourceItem.id); + bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)); + + auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*'); + item->setToolTip(obj->ObjectName()); + item->setData(Qt::UserRole, QVariant::fromValue(sourceItem)); + ui->listWidget->insertItem(++row, item); + } + + ui->listWidget->blockSignals(false); + + if (ui->listWidget->count() > 0) + { + ui->listWidget->setCurrentRow(0); + } + + ValidateSourceAliases(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogFlippingByLine::ValidateSourceAliases() +{ + for (int i=0; ilistWidget->count(); ++i) + { + if (const QListWidgetItem *item = ui->listWidget->item(i)) + { + auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + + const QSharedPointer obj = data->GetGObject(sourceItem.id); + + if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj))) + { + flagAlias = false; + ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias")); + SetAliasValid(sourceItem.id, false); + CheckState(); + return; + } + else + { + SetAliasValid(sourceItem.id, true); + } + } + } + + flagAlias = true; + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogFlippingByLine::SetAliasValid(quint32 id, bool valid) +{ + if (ui->listWidget->currentRow() != -1) + { + auto *item = ui->listWidget->item(ui->listWidget->currentRow()); + const auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + + if (id == sourceItem.id) + { + const QSharedPointer obj = data->GetGObject(sourceItem.id); + item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*'); + + ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogFlippingByLine::SetNotes(const QString ¬es) { @@ -445,3 +614,16 @@ QString DialogFlippingByLine::GetNotes() const { return ui->plainTextEditToolNotes->toPlainText(); } + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogFlippingByLine::IsValid() const +{ + bool ready = flagError && flagName && flagGroupName && flagAlias; + + if (ready) + { + ui->labelStatus->setText(tr("Ready")); + } + + return ready; +} diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.h b/src/libs/vtools/dialogs/tools/dialogflippingbyline.h index a00139c81..4a4dbf029 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.h +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.h @@ -40,6 +40,7 @@ #include #include "../vmisc/def.h" +#include "../../tools/toolsdef.h" namespace Ui { @@ -63,8 +64,6 @@ public: QString GetSuffix() const; void SetSuffix(const QString &value); - QVector GetObjects() const; - QString GetVisibilityGroupName() const; void SetVisibilityGroupName(const QString &name); @@ -81,6 +80,9 @@ public: virtual void ShowDialog(bool click) override; + QVector GetSourceObjects() const; + void SetSourceObjects(const QVector &value); + public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) override; virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override; @@ -88,6 +90,8 @@ public slots: private slots: void SuffixChanged(); void GroupNameChanged(); + void ShowSourceDetails(int row); + void AliasChanged(const QString &text); protected: virtual void ShowVisualization() override; @@ -104,7 +108,7 @@ private: Ui::DialogFlippingByLine *ui; - QList objects; + QVector sourceObjects{}; bool stage1; @@ -113,14 +117,14 @@ private: bool flagName; bool flagGroupName; bool flagError; + bool flagAlias{true}; QStringList m_groupTags{}; + + void FillSourceList(); + + void ValidateSourceAliases(); + void SetAliasValid(quint32 id, bool valid); }; -//--------------------------------------------------------------------------------------------------------------------- -inline bool DialogFlippingByLine::IsValid() const -{ - return flagError && flagName && flagGroupName; -} - #endif // DIALOGFLIPPINGBYLINE_H diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui b/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui index 41d39c969..3596a163c 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui @@ -6,8 +6,8 @@ 0 0 - 319 - 301 + 387 + 440 @@ -28,6 +28,35 @@ Tool + + + + Qt::Horizontal + + + + + + + + Alias: + + + + + + + false + + + true + + + + + + + @@ -48,7 +77,11 @@ - + + + true + + @@ -117,6 +150,13 @@ + + + + Ready + + + diff --git a/src/libs/vtools/dialogs/tools/dialogmove.cpp b/src/libs/vtools/dialogs/tools/dialogmove.cpp index 43bcd90ec..95264f4d8 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.cpp +++ b/src/libs/vtools/dialogs/tools/dialogmove.cpp @@ -78,7 +78,6 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent) formulaBaseHeightAngle(0), formulaBaseHeightRotationAngle(0), formulaBaseHeightLength(0), - objects(), stage1(true), stage2(false), m_suffix(), @@ -143,6 +142,9 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent) connect(ui->pushButtonGrowRotationAngle, &QPushButton::clicked, this, &DialogMove::DeployRotationAngleTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit); + connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogMove::ShowSourceDetails); + connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogMove::AliasChanged); + vis = new VisToolMove(data); SetRotationOrigPointId(NULL_ID); @@ -257,12 +259,6 @@ void DialogMove::SetRotationOrigPointId(const quint32 &value) operation->SetRotationOriginPointId(value); } -//--------------------------------------------------------------------------------------------------------------------- -QVector DialogMove::GetObjects() const -{ - return ConvertToVector(objects); -} - //--------------------------------------------------------------------------------------------------------------------- QString DialogMove::GetVisibilityGroupName() const { @@ -311,7 +307,7 @@ void DialogMove::ShowDialog(bool click) { if (stage1 && not click) { - if (objects.isEmpty()) + if (sourceObjects.isEmpty()) { return; } @@ -325,7 +321,7 @@ void DialogMove::ShowDialog(bool click) VisToolMove *operation = qobject_cast(vis); SCASSERT(operation != nullptr) - operation->SetObjects(ConvertToVector(objects)); + operation->SetObjects(SourceToObjects(sourceObjects)); operation->VisualMode(); VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); @@ -343,6 +339,8 @@ void DialogMove::ShowDialog(bool click) scene->ToggleSplinePathHover(false); qApp->getSceneView()->AllowRubberBand(false); + + FillSourceList(); } else if (not stage2 && not stage1 && prepare && click) { @@ -416,16 +414,23 @@ void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool) Q_UNUSED(tool) if (stage1) { + auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [object](const SourceItem &sItem) { return sItem.id == object; }); if (selected) { - if (not objects.contains(object)) + if (obj == sourceObjects.cend()) { - objects.append(object); + SourceItem item; + item.id = object; + sourceObjects.append(item); } } else { - objects.removeOne(object); + if (obj != sourceObjects.end()) + { + sourceObjects.erase(obj); + } } } } @@ -501,6 +506,7 @@ void DialogMove::SuffixChanged() { flagName = false; ChangeColor(ui->labelSuffix, errorColor); + ui->labelStatus->setText(tr("Invalid suffix")); CheckState(); return; } @@ -517,6 +523,7 @@ void DialogMove::SuffixChanged() { flagName = false; ChangeColor(ui->labelSuffix, errorColor); + ui->labelStatus->setText(tr("Invalid suffix")); CheckState(); return; } @@ -541,6 +548,7 @@ void DialogMove::GroupNameChanged() { flagGroupName = false; ChangeColor(ui->labelGroupName, errorColor); + ui->labelStatus->setText(tr("Invalid group name")); CheckState(); return; } @@ -551,6 +559,50 @@ void DialogMove::GroupNameChanged() CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogMove::ShowSourceDetails(int row) +{ + ui->lineEditAlias->setDisabled(true); + + if (ui->listWidget->count() == 0) + { + return; + } + + const auto sourceItem = qvariant_cast(ui->listWidget->item(row)->data(Qt::UserRole)); + + const QSharedPointer obj = data->GetGObject(sourceItem.id); + + ui->labelAlias->setText(obj->getType() == GOType::Point ? tr("Label:") : tr("Alias:")); + + ui->lineEditAlias->blockSignals(true); + ui->lineEditAlias->setText(sourceItem.alias); + ui->lineEditAlias->setEnabled(true); + ui->lineEditAlias->blockSignals(false); + + SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data, + OriginAlias(sourceItem.id, sourceObjects, obj))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogMove::AliasChanged(const QString &text) +{ + if (ui->listWidget->count() == 0) + { + return; + } + + if (auto *item = ui->listWidget->currentItem()) + { + auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + sourceItem.alias = text; + + item->setData(Qt::UserRole, QVariant::fromValue(sourceItem)); + + ValidateSourceAliases(); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogMove::ShowVisualization() { @@ -565,10 +617,22 @@ void DialogMove::SaveData() formulaRotationAngle = ui->plainTextEditRotationAngle->toPlainText(); formulaLength = ui->plainTextEditLength->toPlainText(); + sourceObjects.clear(); + sourceObjects.reserve(ui->listWidget->count()); + + for (int i=0; ilistWidget->count(); ++i) + { + if (const QListWidgetItem *item = ui->listWidget->item(i)) + { + auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + sourceObjects.append(sourceItem); + } + } + VisToolMove *operation = qobject_cast(vis); SCASSERT(operation != nullptr) - operation->SetObjects(ConvertToVector(objects)); + operation->SetObjects(SourceToObjects(sourceObjects)); operation->SetAngle(formulaAngle); operation->SetLength(formulaLength); operation->SetRotationAngle(formulaRotationAngle); @@ -597,6 +661,23 @@ void DialogMove::closeEvent(QCloseEvent *event) DialogTool::closeEvent(event); } +//--------------------------------------------------------------------------------------------------------------------- +QVector DialogMove::GetSourceObjects() const +{ + return sourceObjects; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogMove::SetSourceObjects(const QVector &value) +{ + sourceObjects = value; + FillSourceList(); + + VisToolMove *operation = qobject_cast(vis); + SCASSERT(operation != nullptr) + operation->SetObjects(SourceToObjects(sourceObjects)); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogMove::EvalAngle() { @@ -609,6 +690,11 @@ void DialogMove::EvalAngle() formulaData.checkZero = false; Eval(formulaData, flagAngle); + + if (not flagAngle) + { + ui->labelStatus->setText(tr("Invalid angle formula")); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -623,6 +709,11 @@ void DialogMove::EvalRotationAngle() formulaData.checkZero = false; Eval(formulaData, flagRotationAngle); + + if (not flagRotationAngle) + { + ui->labelStatus->setText(tr("Invalid rotation angle formula")); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -636,6 +727,89 @@ void DialogMove::EvalLength() formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); Eval(formulaData, flagLength); + + if (not flagLength) + { + ui->labelStatus->setText(tr("Invalid length formula")); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogMove::FillSourceList() +{ + ui->listWidget->blockSignals(true); + + ui->listWidget->clear(); + + int row = -1; + + for (auto &sourceItem : sourceObjects) + { + const QSharedPointer obj = data->GetGObject(sourceItem.id); + bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)); + + auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*'); + item->setToolTip(obj->ObjectName()); + item->setData(Qt::UserRole, QVariant::fromValue(sourceItem)); + ui->listWidget->insertItem(++row, item); + } + + ui->listWidget->blockSignals(false); + + if (ui->listWidget->count() > 0) + { + ui->listWidget->setCurrentRow(0); + } + + ValidateSourceAliases(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogMove::ValidateSourceAliases() +{ + for (int i=0; ilistWidget->count(); ++i) + { + if (const QListWidgetItem *item = ui->listWidget->item(i)) + { + auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + + const QSharedPointer obj = data->GetGObject(sourceItem.id); + + if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj))) + { + flagAlias = false; + ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias")); + SetAliasValid(sourceItem.id, false); + CheckState(); + return; + } + else + { + SetAliasValid(sourceItem.id, true); + } + } + } + + flagAlias = true; + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogMove::SetAliasValid(quint32 id, bool valid) +{ + if (ui->listWidget->currentRow() != -1) + { + auto *item = ui->listWidget->item(ui->listWidget->currentRow()); + const auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + + if (id == sourceItem.id) + { + const QSharedPointer obj = data->GetGObject(sourceItem.id); + item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*'); + + ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor); + } + } } //--------------------------------------------------------------------------------------------------------------------- @@ -649,3 +823,16 @@ QString DialogMove::GetNotes() const { return ui->plainTextEditToolNotes->toPlainText(); } + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogMove::IsValid() const +{ + bool ready = flagAngle && flagRotationAngle && flagLength && flagName && flagGroupName && flagAlias; + + if (ready) + { + ui->labelStatus->setText(tr("Ready")); + } + + return ready; +} diff --git a/src/libs/vtools/dialogs/tools/dialogmove.h b/src/libs/vtools/dialogs/tools/dialogmove.h index c67a4669e..f01c87198 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.h +++ b/src/libs/vtools/dialogs/tools/dialogmove.h @@ -39,6 +39,7 @@ #include "../vmisc/def.h" #include "dialogtool.h" +#include "../../tools/toolsdef.h" namespace Ui { @@ -68,8 +69,6 @@ public: quint32 GetRotationOrigPointId() const; void SetRotationOrigPointId(const quint32 &value); - QVector GetObjects() const; - QString GetVisibilityGroupName() const; void SetVisibilityGroupName(const QString &name); @@ -86,6 +85,9 @@ public: virtual void ShowDialog(bool click) override; + QVector GetSourceObjects() const; + void SetSourceObjects(const QVector &value); + public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) override; virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override; @@ -103,6 +105,9 @@ private slots: void SuffixChanged(); void GroupNameChanged(); + void ShowSourceDetails(int row); + void AliasChanged(const QString &text); + protected: virtual void ShowVisualization() override; @@ -130,7 +135,7 @@ private: int formulaBaseHeightRotationAngle; int formulaBaseHeightLength; - QList objects; + QVector sourceObjects{}; bool stage1; bool stage2; @@ -145,18 +150,18 @@ private: bool flagLength; bool flagName; bool flagGroupName; + bool flagAlias{true}; QStringList m_groupTags{}; void EvalAngle(); void EvalRotationAngle(); void EvalLength(); + + void FillSourceList(); + + void ValidateSourceAliases(); + void SetAliasValid(quint32 id, bool valid); }; -//--------------------------------------------------------------------------------------------------------------------- -inline bool DialogMove::IsValid() const -{ - return flagAngle && flagRotationAngle && flagLength && flagName && flagGroupName; -} - #endif // DIALOGMOVING_H diff --git a/src/libs/vtools/dialogs/tools/dialogmove.ui b/src/libs/vtools/dialogs/tools/dialogmove.ui index c8bb1b2d0..c9010c470 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.ui +++ b/src/libs/vtools/dialogs/tools/dialogmove.ui @@ -2,12 +2,15 @@ DialogMove + + true + 0 0 - 411 - 498 + 536 + 669 @@ -28,6 +31,39 @@ Tool + + + + Qt::Horizontal + + + + QAbstractItemView::CurrentChanged + + + + + + + + Alias: + + + + + + + false + + + true + + + + + + + @@ -656,6 +692,13 @@ + + + + Ready + + + diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp index 4d64cb5a1..2eab16690 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp +++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp @@ -72,7 +72,6 @@ DialogRotation::DialogRotation(const VContainer *data, quint32 toolId, QWidget * timerAngle(new QTimer(this)), formulaAngle(), formulaBaseHeightAngle(0), - objects(), stage1(true), m_suffix(), m_firstRelease(false), @@ -170,12 +169,6 @@ void DialogRotation::SetSuffix(const QString &value) ui->lineEditSuffix->setText(value); } -//--------------------------------------------------------------------------------------------------------------------- -QVector DialogRotation::GetObjects() const -{ - return ConvertToVector(objects); -} - //--------------------------------------------------------------------------------------------------------------------- QString DialogRotation::GetVisibilityGroupName() const { @@ -224,7 +217,7 @@ void DialogRotation::ShowDialog(bool click) { if (stage1 && not click) { - if (objects.isEmpty()) + if (sourceObjects.isEmpty()) { return; } @@ -237,7 +230,7 @@ void DialogRotation::ShowDialog(bool click) VisToolRotation *operation = qobject_cast(vis); SCASSERT(operation != nullptr) - operation->SetObjects(ConvertToVector(objects)); + operation->SetObjects(SourceToObjects(sourceObjects)); operation->VisualMode(); scene->ToggleArcSelection(false); @@ -252,6 +245,8 @@ void DialogRotation::ShowDialog(bool click) qApp->getSceneView()->AllowRubberBand(false); + FillSourceList(); + emit ToolTip(tr("Select origin point")); } else if (not stage1 && prepare && click) @@ -294,6 +289,23 @@ void DialogRotation::ShowDialog(bool click) } } +//--------------------------------------------------------------------------------------------------------------------- +QVector DialogRotation::GetSourceObjects() const +{ + return sourceObjects; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogRotation::SetSourceObjects(const QVector &value) +{ + sourceObjects = value; + FillSourceList(); + + VisToolRotation *operation = qobject_cast(vis); + SCASSERT(operation != nullptr) + operation->SetObjects(SourceToObjects(sourceObjects)); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogRotation::ChosenObject(quint32 id, const SceneObject &type) { @@ -304,14 +316,17 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type) VisToolRotation *operation = qobject_cast(vis); SCASSERT(operation != nullptr) - if (objects.contains(id)) + auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [id](const SourceItem &sItem) { return sItem.id == id; }); + + if (obj != sourceObjects.end()) { - if (objects.size() > 1) + if (sourceObjects.size() > 1) { // It's not really logical for a user that a center of rotation no need to select. // To fix this issue we just silently remove it from the list. - objects.removeOne(id); - operation->SetObjects(ConvertToVector(objects)); + sourceObjects.erase(obj); + operation->SetObjects(SourceToObjects(sourceObjects)); } else { @@ -341,16 +356,23 @@ void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool) Q_UNUSED(tool) if (stage1) { + auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [object](const SourceItem &sItem) { return sItem.id == object; }); if (selected) { - if (not objects.contains(object)) + if (obj == sourceObjects.cend()) { - objects.append(object); + SourceItem item; + item.id = object; + sourceObjects.append(item); } } else { - objects.removeOne(object); + if (obj != sourceObjects.end()) + { + sourceObjects.erase(obj); + } } } } @@ -386,6 +408,7 @@ void DialogRotation::SuffixChanged() { flagName = false; ChangeColor(ui->labelSuffix, errorColor); + ui->labelStatus->setText(tr("Invalid suffix")); CheckState(); return; } @@ -402,6 +425,7 @@ void DialogRotation::SuffixChanged() { flagName = false; ChangeColor(ui->labelSuffix, errorColor); + ui->labelStatus->setText(tr("Invalid suffix")); CheckState(); return; } @@ -426,6 +450,7 @@ void DialogRotation::GroupNameChanged() { flagGroupName = false; ChangeColor(ui->labelGroupName, errorColor); + ui->labelStatus->setText(tr("Invalid group name")); CheckState(); return; } @@ -448,10 +473,22 @@ void DialogRotation::SaveData() m_suffix = ui->lineEditSuffix->text(); formulaAngle = ui->plainTextEditFormula->toPlainText(); + sourceObjects.clear(); + sourceObjects.reserve(ui->listWidget->count()); + + for (int i=0; ilistWidget->count(); ++i) + { + if (const QListWidgetItem *item = ui->listWidget->item(i)) + { + auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + sourceObjects.append(sourceItem); + } + } + VisToolRotation *operation = qobject_cast(vis); SCASSERT(operation != nullptr) - operation->SetObjects(ConvertToVector(objects)); + operation->SetObjects(SourceToObjects(sourceObjects)); operation->SetOriginPointId(GetOrigPointId()); operation->SetAngle(formulaAngle); operation->RefreshGeometry(); @@ -479,11 +516,17 @@ void DialogRotation::closeEvent(QCloseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void DialogRotation::PointChanged() { + quint32 id = getCurrentObjectId(ui->comboBoxOriginPoint); + + auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(), + [id](const SourceItem &sItem) { return sItem.id == id; }); + QColor color; - if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint))) + if (obj != sourceObjects.end()) { flagError = false; color = errorColor; + ui->labelStatus->setText(tr("Invalid rotation point")); } else { @@ -494,6 +537,84 @@ void DialogRotation::PointChanged() CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogRotation::FillSourceList() +{ + ui->listWidget->blockSignals(true); + + ui->listWidget->clear(); + + int row = -1; + + for (auto &sourceItem : sourceObjects) + { + const QSharedPointer obj = data->GetGObject(sourceItem.id); + bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)); + + auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*'); + item->setToolTip(obj->ObjectName()); + item->setData(Qt::UserRole, QVariant::fromValue(sourceItem)); + ui->listWidget->insertItem(++row, item); + } + + ui->listWidget->blockSignals(false); + + if (ui->listWidget->count() > 0) + { + ui->listWidget->setCurrentRow(0); + } + + ValidateSourceAliases(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogRotation::ValidateSourceAliases() +{ + for (int i=0; ilistWidget->count(); ++i) + { + if (const QListWidgetItem *item = ui->listWidget->item(i)) + { + auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + + const QSharedPointer obj = data->GetGObject(sourceItem.id); + + if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj))) + { + flagAlias = false; + ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias")); + SetAliasValid(sourceItem.id, false); + CheckState(); + return; + } + else + { + SetAliasValid(sourceItem.id, true); + } + } + } + + flagAlias = true; + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogRotation::SetAliasValid(quint32 id, bool valid) +{ + if (ui->listWidget->currentRow() != -1) + { + auto *item = ui->listWidget->item(ui->listWidget->currentRow()); + const auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + + if (id == sourceItem.id) + { + const QSharedPointer obj = data->GetGObject(sourceItem.id); + item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*'); + + ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogRotation::EvalAngle() { @@ -506,6 +627,55 @@ void DialogRotation::EvalAngle() formulaData.checkZero = false; Eval(formulaData, flagAngle); + + if (not flagAngle) + { + ui->labelStatus->setText(tr("Invalid angle formula")); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogRotation::ShowSourceDetails(int row) +{ + ui->lineEditAlias->setDisabled(true); + + if (ui->listWidget->count() == 0) + { + return; + } + + const auto sourceItem = qvariant_cast(ui->listWidget->item(row)->data(Qt::UserRole)); + + const QSharedPointer obj = data->GetGObject(sourceItem.id); + + ui->labelAlias->setText(obj->getType() == GOType::Point ? tr("Label:") : tr("Alias:")); + + ui->lineEditAlias->blockSignals(true); + ui->lineEditAlias->setText(sourceItem.alias); + ui->lineEditAlias->setEnabled(true); + ui->lineEditAlias->blockSignals(false); + + SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data, + OriginAlias(sourceItem.id, sourceObjects, obj))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogRotation::AliasChanged(const QString &text) +{ + if (ui->listWidget->count() == 0) + { + return; + } + + if (auto *item = ui->listWidget->currentItem()) + { + auto sourceItem = qvariant_cast(item->data(Qt::UserRole)); + sourceItem.alias = text; + + item->setData(Qt::UserRole, QVariant::fromValue(sourceItem)); + + ValidateSourceAliases(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -519,3 +689,16 @@ QString DialogRotation::GetNotes() const { return ui->plainTextEditToolNotes->toPlainText(); } + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogRotation::IsValid() const +{ + bool ready = flagAngle && flagName && flagError && flagGroupName && flagAlias; + + if (ready) + { + ui->labelStatus->setText(tr("Ready")); + } + + return ready; +} diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.h b/src/libs/vtools/dialogs/tools/dialogrotation.h index 087736055..525911668 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.h +++ b/src/libs/vtools/dialogs/tools/dialogrotation.h @@ -39,6 +39,7 @@ #include "../vmisc/def.h" #include "dialogtool.h" +#include "../../tools/toolsdef.h" namespace Ui { @@ -61,8 +62,6 @@ public: QString GetSuffix() const; void SetSuffix(const QString &value); - QVector GetObjects() const; - QString GetVisibilityGroupName() const; void SetVisibilityGroupName(const QString &name); @@ -79,6 +78,9 @@ public: virtual void ShowDialog(bool click) override; + QVector GetSourceObjects() const; + void SetSourceObjects(const QVector &value); + public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) override; virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override; @@ -90,6 +92,8 @@ private slots: void SuffixChanged(); void GroupNameChanged(); void EvalAngle(); + void ShowSourceDetails(int row); + void AliasChanged(const QString &text); protected: virtual void ShowVisualization() override; @@ -115,7 +119,7 @@ private: /** @brief formulaBaseHeightAngle base height defined by dialogui */ int formulaBaseHeightAngle; - QList objects; + QVector sourceObjects{}; bool stage1; @@ -128,14 +132,14 @@ private: bool flagName; bool flagGroupName; bool flagError; + bool flagAlias{true}; QStringList m_groupTags{}; + + void FillSourceList(); + + void ValidateSourceAliases(); + void SetAliasValid(quint32 id, bool valid); }; -//--------------------------------------------------------------------------------------------------------------------- -inline bool DialogRotation::IsValid() const -{ - return flagAngle && flagName && flagError && flagGroupName; -} - #endif // DIALOGROTATION_H diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.ui b/src/libs/vtools/dialogs/tools/dialogrotation.ui index 238755e7f..7bb65120f 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.ui +++ b/src/libs/vtools/dialogs/tools/dialogrotation.ui @@ -6,8 +6,8 @@ 0 0 - 304 - 338 + 410 + 485 @@ -28,6 +28,35 @@ Tool + + + + Qt::Horizontal + + + + + + + + Alias + + + + + + + false + + + true + + + + + + + @@ -287,6 +316,13 @@ + + + + Ready + + + diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp index bf3f542ea..5b920afa4 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp @@ -38,12 +38,9 @@ #include "../vgeometry/vsplinepath.h" //--------------------------------------------------------------------------------------------------------------------- -VAbstractFlipping::VAbstractFlipping(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix, - const QVector &source, const QVector &destination, - const QString ¬es, QGraphicsItem *parent) - : VAbstractOperation(doc, data, id, suffix, source, destination, notes, parent) -{ -} +VAbstractFlipping::VAbstractFlipping(const VAbstractOperationInitData &initData, QGraphicsItem *parent) + : VAbstractOperation(initData, parent) +{} //--------------------------------------------------------------------------------------------------------------------- void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint, @@ -55,9 +52,9 @@ void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData, initData.id = initData.data->getNextId();//Just reserve id for tool - for (auto idObject : qAsConst(initData.source)) + for (auto object : qAsConst(initData.source)) { - const QSharedPointer obj = initData.data->GetGObject(idObject); + const QSharedPointer obj = initData.data->GetGObject(object.id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); @@ -67,32 +64,32 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") switch(static_cast(obj->getType())) { case GOType::Point: - initData.destination.append(CreatePoint(initData.id, idObject, fPoint, sPoint, initData.suffix, + initData.destination.append(CreatePoint(initData.id, object, fPoint, sPoint, initData.suffix, initData.data)); break; case GOType::Arc: - initData.destination.append(CreateArc(initData.id, idObject, fPoint, sPoint, initData.suffix, + initData.destination.append(CreateArc(initData.id, object, fPoint, sPoint, initData.suffix, initData.data)); break; case GOType::EllipticalArc: - initData.destination.append(CreateArc(initData.id, idObject, fPoint, sPoint, + initData.destination.append(CreateArc(initData.id, object, fPoint, sPoint, initData.suffix, initData.data)); break; case GOType::Spline: - initData.destination.append(CreateCurve(initData.id, idObject, fPoint, sPoint, + initData.destination.append(CreateCurve(initData.id, object, fPoint, sPoint, initData.suffix, initData.data)); break; case GOType::SplinePath: - initData.destination.append(CreateCurveWithSegments(initData.id, idObject, fPoint, + initData.destination.append(CreateCurveWithSegments(initData.id, object, fPoint, sPoint, initData.suffix, initData.data)); break; case GOType::CubicBezier: - initData.destination.append(CreateCurve(initData.id, idObject, fPoint, sPoint, + initData.destination.append(CreateCurve(initData.id, object, fPoint, sPoint, initData.suffix, initData.data)); break; case GOType::CubicBezierPath: - initData.destination.append(CreateCurveWithSegments(initData.id, idObject, fPoint, + initData.destination.append(CreateCurveWithSegments(initData.id, object, fPoint, sPoint, initData.suffix, initData.data)); break; @@ -108,8 +105,8 @@ QT_WARNING_POP { for (int i = 0; i < initData.source.size(); ++i) { - const quint32 idObject = initData.source.at(i); - const QSharedPointer obj = initData.data->GetGObject(idObject); + const SourceItem object = initData.source.at(i); + const QSharedPointer obj = initData.data->GetGObject(object.id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); @@ -121,31 +118,31 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") case GOType::Point: { const DestinationItem &item = initData.destination.at(i); - UpdatePoint(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data, item); + UpdatePoint(initData.id, object, fPoint, sPoint, initData.suffix, initData.data, item); break; } case GOType::Arc: - UpdateArc(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data, + UpdateArc(initData.id, object, fPoint, sPoint, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::EllipticalArc: - UpdateArc(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data, + UpdateArc(initData.id, object, fPoint, sPoint, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::Spline: - UpdateCurve(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data, + UpdateCurve(initData.id, object, fPoint, sPoint, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::SplinePath: - UpdateCurveWithSegments(initData.id, idObject, fPoint, sPoint, initData.suffix, + UpdateCurveWithSegments(initData.id, object, fPoint, sPoint, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::CubicBezier: - UpdateCurve(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data, + UpdateCurve(initData.id, object, fPoint, sPoint, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::CubicBezierPath: - UpdateCurveWithSegments(initData.id, idObject, fPoint, sPoint, initData.suffix, + UpdateCurveWithSegments(initData.id, object, fPoint, sPoint, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::Unknown: @@ -163,13 +160,18 @@ QT_WARNING_POP } //--------------------------------------------------------------------------------------------------------------------- -DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint, +DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data) { - const QSharedPointer point = data->GeometricObject(idItem); + const QSharedPointer point = data->GeometricObject(sItem.id); VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix); rotated.setIdObject(idTool); + if (not sItem.alias.isEmpty()) + { + rotated.setName(sItem.alias); + } + DestinationItem item; item.mx = rotated.mx(); item.my = rotated.my(); @@ -180,33 +182,39 @@ DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, quint32 idItem, c //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VAbstractFlipping::CreateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, +DestinationItem VAbstractFlipping::CreateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data) { - const DestinationItem item = CreateItem(idTool, idItem, firstPoint, secondPoint, suffix, data); + const DestinationItem item = CreateItem(idTool, sItem, firstPoint, secondPoint, suffix, data); data->AddArc(data->GeometricObject(item.id), item.id); return item; } //--------------------------------------------------------------------------------------------------------------------- -void VAbstractFlipping::UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint, +void VAbstractFlipping::UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data, const DestinationItem &item) { - const QSharedPointer point = data->GeometricObject(idItem); + const QSharedPointer point = data->GeometricObject(sItem.id); VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix); rotated.setIdObject(idTool); rotated.setMx(item.mx); rotated.setMy(item.my); rotated.SetShowLabel(item.showLabel); + + if (not sItem.alias.isEmpty()) + { + rotated.setName(sItem.alias); + } + data->UpdateGObject(item.id, new VPointF(rotated)); } //--------------------------------------------------------------------------------------------------------------------- template -void VAbstractFlipping::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint, - const QString &suffix, VContainer *data, quint32 id) +void VAbstractFlipping::UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, + const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id) { - UpdateItem(idTool, idItem, firstPoint, secondPoint, suffix, data, id); + UpdateItem(idTool, sItem, firstPoint, secondPoint, suffix, data, id); data->AddArc(data->GeometricObject(id), id); } diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.h b/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.h index 7af3b971a..ff662f328 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.h +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.h @@ -39,41 +39,40 @@ class VAbstractFlipping : public VAbstractOperation public: virtual ~VAbstractFlipping() Q_DECL_EQ_DEFAULT; protected: - VAbstractFlipping(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix, - const QVector &source, const QVector &destination, const QString ¬es, - QGraphicsItem *parent = nullptr); + explicit VAbstractFlipping(const VAbstractOperationInitData &initData, QGraphicsItem *parent = nullptr); static void CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint, const QPointF &sPoint); - static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint, + static DestinationItem CreatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data); template - static DestinationItem CreateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint, + static DestinationItem CreateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data); template - static DestinationItem CreateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, + static DestinationItem CreateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data); template - static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint, + static DestinationItem CreateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data); template - static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint, + static DestinationItem CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data); - static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint, - const QString &suffix, VContainer *data, const DestinationItem &item); + static void UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, + const QPointF &secondPoint, const QString &suffix, VContainer *data, + const DestinationItem &item); template - static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint, - const QString &suffix, VContainer *data, quint32 id); + static void UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, + const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id); template - static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint, - const QString &suffix, VContainer *data, quint32 id); + static void UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, + const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id); template - static void UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint, - const QString &suffix, VContainer *data, quint32 id); + static void UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, + const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id); template - static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint, + static void UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id); private: @@ -82,13 +81,18 @@ private: //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint, +DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data) { - const QSharedPointer i = data->GeometricObject(idItem); + const QSharedPointer i = data->GeometricObject(sItem.id); Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix); rotated.setIdObject(idTool); + if (not sItem.alias.isEmpty()) + { + rotated.SetAliasSuffix(sItem.alias); + } + DestinationItem item; item.mx = INT_MAX; item.my = INT_MAX; @@ -98,52 +102,58 @@ DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, quint32 idItem, co //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VAbstractFlipping::CreateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint, +DestinationItem VAbstractFlipping::CreateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data) { - const DestinationItem item = CreateItem(idTool, idItem, firstPoint, secondPoint, suffix, data); + const DestinationItem item = CreateItem(idTool, sItem, firstPoint, secondPoint, suffix, data); data->AddSpline(data->GeometricObject(item.id), item.id); return item; } //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VAbstractFlipping::CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint, - const QPointF &secondPoint, const QString &suffix, - VContainer *data) +DestinationItem VAbstractFlipping::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, + const QPointF &firstPoint, const QPointF &secondPoint, + const QString &suffix, VContainer *data) { - const DestinationItem item = CreateItem(idTool, idItem, firstPoint, secondPoint, suffix, data); + const DestinationItem item = CreateItem(idTool, sItem, firstPoint, secondPoint, suffix, data); data->AddCurveWithSegments(data->GeometricObject(item.id), item.id); return item; } //--------------------------------------------------------------------------------------------------------------------- template -void VAbstractFlipping::UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint, +void VAbstractFlipping::UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id) { - const QSharedPointer i = data->GeometricObject(idItem); + const QSharedPointer i = data->GeometricObject(sItem.id); Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix); rotated.setIdObject(idTool); + + if (not sItem.alias.isEmpty()) + { + rotated.SetAliasSuffix(sItem.alias); + } + data->UpdateGObject(id, new Item(rotated)); } //--------------------------------------------------------------------------------------------------------------------- template -void VAbstractFlipping::UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint, +void VAbstractFlipping::UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id) { - UpdateItem(idTool, idItem, firstPoint, secondPoint, suffix, data, id); + UpdateItem(idTool, sItem, firstPoint, secondPoint, suffix, data, id); data->AddSpline(data->GeometricObject(id), id); } //--------------------------------------------------------------------------------------------------------------------- template -void VAbstractFlipping::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint, +void VAbstractFlipping::UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint, const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id) { - UpdateItem(idTool, idItem, firstPoint, secondPoint, suffix, data, id); + UpdateItem(idTool, sItem, firstPoint, secondPoint, suffix, data, id); data->AddCurveWithSegments(data->GeometricObject(id), id); } diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp index bcac26423..e4aed0b78 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp @@ -75,6 +75,7 @@ void VToolFlippingByAxis::setDialog() dialogTool->SetAxisType(m_axisType); dialogTool->SetSuffix(suffix); dialogTool->SetNotes(m_notes); + dialogTool->SetSourceObjects(source); SetDialogVisibilityGroupData(dialogTool); } @@ -91,7 +92,7 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(const QPointer &dia initData.originPointId = dialogTool->GetOriginPointId(); initData.axisType = dialogTool->GetAxisType(); initData.suffix = dialogTool->GetSuffix(); - initData.source = dialogTool->GetObjects(); + initData.source = dialogTool->GetSourceObjects(); initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup(); initData.visibilityGroupName = dialogTool->GetVisibilityGroupName(); initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags(); @@ -141,9 +142,9 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini InitOperationToolConnections(initData.scene, tool); VAbstractPattern::AddTool(initData.id, tool); initData.doc->IncrementReferens(originPoint.getIdTool()); - for (auto idObject : qAsConst(initData.source)) + for (auto object : qAsConst(initData.source)) { - initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool()); + initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool()); } if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) @@ -206,7 +207,7 @@ void VToolFlippingByAxis::SetVisualization() VisToolFlippingByAxis *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->SetObjects(source); + visual->SetObjects(SourceToObjects(source)); visual->SetOriginPointId(m_originPointId); visual->SetAxisType(m_axisType); visual->RefreshGeometry(); @@ -231,6 +232,9 @@ void VToolFlippingByAxis::SaveDialog(QDomElement &domElement, QList &ol const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + source = dialogTool->GetSourceObjects(); + SaveSourceDestination(domElement); + // Save visibility data for later use SaveVisibilityGroupData(dialogTool); } @@ -242,7 +246,6 @@ void VToolFlippingByAxis::ReadToolAttributes(const QDomElement &domElement) m_originPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); m_axisType = static_cast(doc->GetParametrUInt(domElement, AttrAxisType, QChar('1'))); - suffix = doc->GetParametrString(domElement, AttrSuffix); } //--------------------------------------------------------------------------------------------------------------------- @@ -253,9 +256,6 @@ void VToolFlippingByAxis::SaveOptions(QDomElement &tag, QSharedPointer doc->SetAttribute(tag, AttrType, ToolType); doc->SetAttribute(tag, AttrCenter, QString().setNum(m_originPointId)); doc->SetAttribute(tag, AttrAxisType, QString().setNum(static_cast(m_axisType))); - doc->SetAttribute(tag, AttrSuffix, suffix); - - SaveSourceDestination(tag); } //--------------------------------------------------------------------------------------------------------------------- @@ -269,8 +269,7 @@ QString VToolFlippingByAxis::MakeToolTip() const //--------------------------------------------------------------------------------------------------------------------- VToolFlippingByAxis::VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent) - : VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source, - initData.destination, initData.notes, parent), + : VAbstractFlipping(initData, parent), m_originPointId(initData.originPointId), m_axisType(initData.axisType) { diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp index 5c70ec11b..f1bf49012 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp @@ -75,6 +75,7 @@ void VToolFlippingByLine::setDialog() dialogTool->SetSecondLinePointId(m_secondLinePointId); dialogTool->SetSuffix(suffix); dialogTool->SetNotes(m_notes); + dialogTool->SetSourceObjects(source); SetDialogVisibilityGroupData(dialogTool); } @@ -91,7 +92,7 @@ VToolFlippingByLine *VToolFlippingByLine::Create(const QPointer &dia initData.firstLinePointId = dialogTool->GetFirstLinePointId(); initData.secondLinePointId = dialogTool->GetSecondLinePointId(); initData.suffix = dialogTool->GetSuffix(); - initData.source = dialogTool->GetObjects(); + initData.source = dialogTool->GetSourceObjects(); initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup(); initData.visibilityGroupName = dialogTool->GetVisibilityGroupName(); initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags(); @@ -135,9 +136,9 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini VAbstractPattern::AddTool(initData.id, tool); initData.doc->IncrementReferens(firstPoint.getIdTool()); initData.doc->IncrementReferens(secondPoint.getIdTool()); - for (auto idObject : qAsConst(initData.source)) + for (auto object : qAsConst(initData.source)) { - initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool()); + initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool()); } if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) @@ -191,7 +192,7 @@ void VToolFlippingByLine::SetVisualization() VisToolFlippingByLine *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->SetObjects(source); + visual->SetObjects(SourceToObjects(source)); visual->SetFirstLinePointId(m_firstLinePointId); visual->SetSecondLinePointId(m_secondLinePointId); visual->RefreshGeometry(); @@ -218,6 +219,9 @@ void VToolFlippingByLine::SaveDialog(QDomElement &domElement, QList &ol const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + source = dialogTool->GetSourceObjects(); + SaveSourceDestination(domElement); + // Save visibility data for later use SaveVisibilityGroupData(dialogTool); } @@ -229,7 +233,6 @@ void VToolFlippingByLine::ReadToolAttributes(const QDomElement &domElement) m_firstLinePointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR); m_secondLinePointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR); - suffix = doc->GetParametrString(domElement, AttrSuffix); } //--------------------------------------------------------------------------------------------------------------------- @@ -240,9 +243,6 @@ void VToolFlippingByLine::SaveOptions(QDomElement &tag, QSharedPointer doc->SetAttribute(tag, AttrType, ToolType); doc->SetAttribute(tag, AttrP1Line, QString().setNum(m_firstLinePointId)); doc->SetAttribute(tag, AttrP2Line, QString().setNum(m_secondLinePointId)); - doc->SetAttribute(tag, AttrSuffix, suffix); - - SaveSourceDestination(tag); } //--------------------------------------------------------------------------------------------------------------------- @@ -258,8 +258,7 @@ QString VToolFlippingByLine::MakeToolTip() const //--------------------------------------------------------------------------------------------------------------------- VToolFlippingByLine::VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent) - : VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source, - initData.destination, initData.notes, parent), + : VAbstractFlipping(initData, parent), m_firstLinePointId(initData.firstLinePointId), m_secondLinePointId(initData.secondLinePointId) { diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index 0a284f22b..05a987b92 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -46,15 +46,15 @@ namespace * @param source list with source objects * @return visibility group data */ -QMap VisibilityGroupDataFromSource(const VContainer *data, const QVector &source) +QMap VisibilityGroupDataFromSource(const VContainer *data, const QVector &source) { QMap groupData; - for (auto &sId : source) + for (auto &sItem : source) { try { - groupData.insert(sId, data->GetGObject(sId)->getIdTool()); + groupData.insert(sItem.id, data->GetGObject(sItem.id)->getIdTool()); } catch (const VExceptionBadId &) { @@ -98,7 +98,7 @@ QVector VAbstractOperation::SourceItems() const { for (auto &item : source) { - itemNames.append(VAbstractTool::data.GetGObject(item)->name()); + itemNames.append(VAbstractTool::data.GetGObject(item.id)->ObjectName()); } } catch (const VExceptionBadId &e) @@ -201,27 +201,49 @@ void VAbstractOperation::SetLabelVisible(quint32 id, bool visible) //--------------------------------------------------------------------------------------------------------------------- void VAbstractOperation::ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData) { + initData.source = ExtractSourceData(domElement); + initData.destination = ExtractDestinationData(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VAbstractOperation::ExtractSourceData(const QDomElement &domElement) +{ + QVector source; const QDomNodeList nodeList = domElement.childNodes(); for (qint32 i = 0; i < nodeList.size(); ++i) { const QDomElement dataElement = nodeList.at(i).toElement(); if (not dataElement.isNull() && dataElement.tagName() == TagSource) { - initData.source.clear(); const QDomNodeList srcList = dataElement.childNodes(); for (qint32 j = 0; j < srcList.size(); ++j) { const QDomElement element = srcList.at(j).toElement(); if (not element.isNull()) { - initData.source.append(VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR)); + SourceItem item; + item.id = VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR); + item.alias = VDomDocument::GetParametrEmptyString(element, AttrAlias); + source.append(item); } } + return source; } + } + return source; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VAbstractOperation::ExtractDestinationData(const QDomElement &domElement) +{ + QVector destination; + const QDomNodeList nodeList = domElement.childNodes(); + for (qint32 i = 0; i < nodeList.size(); ++i) + { + const QDomElement dataElement = nodeList.at(i).toElement(); if (not dataElement.isNull() && dataElement.tagName() == TagDestination) { - initData.destination.clear(); const QDomNodeList srcList = dataElement.childNodes(); for (qint32 j = 0; j < srcList.size(); ++j) { @@ -233,11 +255,15 @@ void VAbstractOperation::ExtractData(const QDomElement &domElement, VAbstractOpe d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QString::number(INT_MAX))); d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QString::number(INT_MAX))); d.showLabel = VDomDocument::GetParametrBool(element, AttrShowLabel, trueStr); - initData.destination.append(d); + destination.append(d); } } + + return destination; } } + + return destination; } //--------------------------------------------------------------------------------------------------------------------- @@ -520,17 +546,15 @@ void VAbstractOperation::LabelChangePosition(const QPointF &pos, quint32 labelId } //--------------------------------------------------------------------------------------------------------------------- -VAbstractOperation::VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix, - const QVector &source, const QVector &destination, - const QString ¬es, QGraphicsItem *parent) - : VDrawTool(doc, data, id, notes), +VAbstractOperation::VAbstractOperation(const VAbstractOperationInitData &initData, QGraphicsItem *parent) + : VDrawTool(initData.doc, initData.data, initData.id, initData.notes), QGraphicsLineItem(parent), - suffix(suffix), - source(source), - destination(destination), + suffix(initData.suffix), + source(initData.source), + destination(initData.destination), operatedObjects() { - connect(doc, &VAbstractPattern::UpdateToolTip, this, [this]() + connect(initData.doc, &VAbstractPattern::UpdateToolTip, this, [this]() { QMapIterator i(operatedObjects); while (i.hasNext()) @@ -669,6 +693,26 @@ void VAbstractOperation::PerformDelete() } } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractOperation::ReadToolAttributes(const QDomElement &domElement) +{ + VDrawTool::ReadToolAttributes(domElement); + + source = ExtractSourceData(domElement); + destination = ExtractDestinationData(domElement); + suffix = doc->GetParametrString(domElement, AttrSuffix); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractOperation::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + VDrawTool::SaveOptions(tag, obj); + + doc->SetAttribute(tag, AttrSuffix, suffix); + + SaveSourceDestination(tag); +} + //--------------------------------------------------------------------------------------------------------------------- void VAbstractOperation::UpdateNamePosition(quint32 id, const QPointF &pos) { @@ -695,10 +739,11 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag) doc->RemoveAllChildren(tag); QDomElement tagObjects = doc->createElement(TagSource); - for (auto id : qAsConst(source)) + for (auto sItem : qAsConst(source)) { QDomElement item = doc->createElement(TagItem); - doc->SetAttribute(item, AttrIdObject, id); + doc->SetAttribute(item, AttrIdObject, sItem.id); + doc->SetAttributeOrRemoveIf(item, AttrAlias, sItem.alias, sItem.alias.isEmpty()); tagObjects.appendChild(item); } tag.appendChild(tagObjects); @@ -709,13 +754,13 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag) QDomElement item = doc->createElement(TagItem); doc->SetAttribute(item, AttrIdObject, dItem.id); - if (not VFuzzyComparePossibleNulls(dItem.mx, INT_MAX) && - not VFuzzyComparePossibleNulls(dItem.my, INT_MAX)) - { - doc->SetAttribute(item, AttrMx, qApp->fromPixel(dItem.mx)); - doc->SetAttribute(item, AttrMy, qApp->fromPixel(dItem.my)); - doc->SetAttribute(item, AttrShowLabel, dItem.showLabel); - } + VAbstractSimple *obj = operatedObjects.value(dItem.id); + + doc->SetAttributeOrRemoveIf(item, AttrMx, qApp->fromPixel(dItem.mx), + obj && obj->GetType() != GOType::Point); + doc->SetAttributeOrRemoveIf(item, AttrMy, qApp->fromPixel(dItem.my), + obj && obj->GetType() != GOType::Point); + doc->SetAttributeOrRemoveIf(item, AttrShowLabel, dItem.showLabel, dItem.showLabel); tagObjects.appendChild(item); } @@ -888,7 +933,7 @@ QString VAbstractOperation::ComplexCurveToolTip(quint32 itemId) const " %3: %4 %5 " "%6" "") - .arg(tr("Label"), curve->name(), tr("Length")) + .arg(tr("Label"), curve->ObjectName(), tr("Length")) .arg(qApp->fromPixel(curve->GetLength())) .arg(UnitsToStr(qApp->patternUnits(), true), MakeToolTip()); return toolTip; diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h index 57eb6ff06..d23b88bbc 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h @@ -41,6 +41,7 @@ #include "../vdrawtool.h" #include "../vwidgets/vsimplecurve.h" #include "../vwidgets/vsimplepoint.h" +#include "../../toolsdef.h" struct DestinationItem { @@ -57,7 +58,7 @@ struct VAbstractOperationInitData : VDrawToolInitData {} QString suffix{}; - QVector source{}; + QVector source{}; QVector destination{}; QString visibilityGroupName{}; QStringList visibilityGroupTags{}; @@ -95,6 +96,8 @@ public: virtual void SetLabelVisible(quint32 id, bool visible) override; static void ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData); + static QVector ExtractSourceData(const QDomElement &domElement); + static QVector ExtractDestinationData(const QDomElement &domElement); public slots: virtual void FullUpdateFromFile() override; @@ -128,7 +131,7 @@ public slots: protected: QString suffix; - QVector source; + QVector source; QVector destination; QMap operatedObjects; @@ -137,15 +140,15 @@ protected: QString groupName{}; QStringList groupTags{}; - VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix, - const QVector &source, const QVector &destination, - const QString ¬es, QGraphicsItem *parent = nullptr); + explicit VAbstractOperation(const VAbstractOperationInitData &initData, QGraphicsItem *parent = nullptr); virtual void AddToFile() override; virtual void ChangeLabelVisibility(quint32 id, bool visible) override; virtual void ApplyToolOptions(const QList &oldDependencies, const QList &newDependencies, const QDomElement &oldDomElement, const QDomElement &newDomElement) override; virtual void PerformDelete() override; + virtual void ReadToolAttributes(const QDomElement &domElement) override; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) override; void UpdateNamePosition(quint32 id, const QPointF &pos); void SaveSourceDestination(QDomElement &tag); diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index df6489f4e..8646ad2c4 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -78,13 +78,13 @@ namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") -QPointF GetOriginPoint(const QVector objects, const VContainer *data, qreal calcLength, qreal calcAngle) +QPointF GetOriginPoint(const QVector &objects, const VContainer *data, qreal calcLength, qreal calcAngle) { QPolygonF originObjects; - for (auto id : objects) + for (auto object : objects) { - const QSharedPointer obj = data->GetGObject(id); + const QSharedPointer obj = data->GetGObject(object.id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); @@ -92,7 +92,7 @@ QPointF GetOriginPoint(const QVector objects, const VContainer *data, q switch(static_cast(obj->getType())) { case GOType::Point: - originObjects.append(data->GeometricObject(id)->toQPointF()); + originObjects.append(data->GeometricObject(object.id)->toQPointF()); break; case GOType::Arc: case GOType::EllipticalArc: @@ -100,7 +100,7 @@ QPointF GetOriginPoint(const QVector objects, const VContainer *data, q case GOType::SplinePath: case GOType::CubicBezier: case GOType::CubicBezierPath: - AppendTo(originObjects, data->GeometricObject(id)->GetPoints()); + AppendTo(originObjects, data->GeometricObject(object.id)->GetPoints()); break; case GOType::Unknown: case GOType::PlaceLabel: @@ -129,6 +129,7 @@ void VToolMove::setDialog() dialogTool->SetSuffix(suffix); dialogTool->SetRotationOrigPointId(origPointId); dialogTool->SetNotes(m_notes); + dialogTool->SetSourceObjects(source); SetDialogVisibilityGroupData(dialogTool); } @@ -147,7 +148,7 @@ VToolMove *VToolMove::Create(const QPointer &dialog, VMainGraphicsSc initData.formulaLength = dialogTool->GetLength(); initData.rotationOrigin = dialogTool->GetRotationOrigPointId(); initData.suffix = dialogTool->GetSuffix(); - initData.source = dialogTool->GetObjects(); + initData.source = dialogTool->GetSourceObjects(); initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup(); initData.visibilityGroupName = dialogTool->GetVisibilityGroupName(); initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags(); @@ -196,9 +197,9 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData) initData.id = initData.data->getNextId();//Just reserve id for tool - for (auto idObject : qAsConst(initData.source)) + for (auto object : qAsConst(initData.source)) { - const QSharedPointer obj = initData.data->GetGObject(idObject); + const QSharedPointer obj = initData.data->GetGObject(object.id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); @@ -208,38 +209,38 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") switch(static_cast(obj->getType())) { case GOType::Point: - initData.destination.append(CreatePoint(initData.id, idObject, calcAngle, calcLength, + initData.destination.append(CreatePoint(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data)); break; case GOType::Arc: - initData.destination.append(CreateArc(initData.id, idObject, calcAngle, calcLength, + initData.destination.append(CreateArc(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data)); break; case GOType::EllipticalArc: - initData.destination.append(CreateArc(initData.id, idObject, calcAngle, calcLength, + initData.destination.append(CreateArc(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data)); break; case GOType::Spline: - initData.destination.append(CreateCurve(initData.id, idObject, calcAngle, calcLength, + initData.destination.append(CreateCurve(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data)); break; case GOType::SplinePath: - initData.destination.append(CreateCurveWithSegments(initData.id, idObject, calcAngle, + initData.destination.append(CreateCurveWithSegments(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data)); break; case GOType::CubicBezier: - initData.destination.append(CreateCurve(initData.id, idObject, calcAngle, calcLength, + initData.destination.append(CreateCurve(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data)); break; case GOType::CubicBezierPath: - initData.destination.append(CreateCurveWithSegments(initData.id, idObject, + initData.destination.append(CreateCurveWithSegments(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, @@ -258,8 +259,8 @@ QT_WARNING_POP { for (int i = 0; i < initData.source.size(); ++i) { - const quint32 idObject = initData.source.at(i); - const QSharedPointer obj = initData.data->GetGObject(idObject); + const SourceItem object = initData.source.at(i); + const QSharedPointer obj = initData.data->GetGObject(object.id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); @@ -269,34 +270,34 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") switch(static_cast(obj->getType())) { case GOType::Point: - UpdatePoint(initData.id, idObject, calcAngle, calcLength, calcRotationAngle, rotationOrigin, + UpdatePoint(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data, initData.destination.at(i)); break; case GOType::Arc: - UpdateArc(initData.id, idObject, calcAngle, calcLength, calcRotationAngle, rotationOrigin, + UpdateArc(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::EllipticalArc: - UpdateArc(initData.id, idObject, calcAngle, calcLength, calcRotationAngle, + UpdateArc(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::Spline: - UpdateCurve(initData.id, idObject, calcAngle, calcLength, calcRotationAngle, + UpdateCurve(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::SplinePath: - UpdateCurveWithSegments(initData.id, idObject, calcAngle, calcLength, + UpdateCurveWithSegments(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin,initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::CubicBezier: - UpdateCurve(initData.id, idObject, calcAngle, calcLength, calcRotationAngle, + UpdateCurve(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin,initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::CubicBezierPath: - UpdateCurveWithSegments(initData.id, idObject, calcAngle, calcLength, + UpdateCurveWithSegments(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix, initData.data, initData.destination.at(i).id); @@ -332,9 +333,9 @@ QT_WARNING_POP initData.doc->IncrementReferens(originPoint->getIdTool()); } - for (auto idObject : qAsConst(initData.source)) + for (auto object : qAsConst(initData.source)) { - initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool()); + initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool()); } if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) @@ -458,7 +459,7 @@ void VToolMove::SetVisualization() VisToolMove *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->SetObjects(source); + visual->SetObjects(SourceToObjects(source)); visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator())); visual->SetRotationAngle(qApp->TrVars()->FormulaToUser(formulaRotationAngle, qApp->Settings()->GetOsSeparator())); @@ -487,6 +488,9 @@ void VToolMove::SaveDialog(QDomElement &domElement, QList &oldDependenc const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + source = dialogTool->GetSourceObjects(); + SaveSourceDestination(domElement); + // Save visibility data for later use SaveVisibilityGroupData(dialogTool); } @@ -500,7 +504,6 @@ void VToolMove::ReadToolAttributes(const QDomElement &domElement) formulaAngle = doc->GetParametrString(domElement, AttrAngle, QChar('0')); formulaRotationAngle = doc->GetParametrString(domElement, AttrRotationAngle, QChar('0')); formulaLength = doc->GetParametrString(domElement, AttrLength, QChar('0')); - suffix = doc->GetParametrString(domElement, AttrSuffix); } //--------------------------------------------------------------------------------------------------------------------- @@ -512,10 +515,7 @@ void VToolMove::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrAngle, formulaAngle); doc->SetAttribute(tag, AttrRotationAngle, formulaRotationAngle); doc->SetAttribute(tag, AttrLength, formulaLength); - doc->SetAttribute(tag, AttrSuffix, suffix); doc->SetAttribute(tag, AttrCenter, QString().setNum(origPointId)); - - SaveSourceDestination(tag); } //--------------------------------------------------------------------------------------------------------------------- @@ -530,7 +530,7 @@ QString VToolMove::MakeToolTip() const .arg(GetFormulaAngle().getDoubleValue()) // 2 .arg(tr("Length")) // 3 .arg(GetFormulaLength().getDoubleValue()) // 4 - .arg(UnitsToStr(qApp->patternUnits(), true), // 5 + .arg(UnitsToStr(qApp->patternUnits(), true), // 5 tr("Rotation angle")) // 6 .arg(GetFormulaRotationAngle().getDoubleValue()) // 7 .arg(tr("Rotation origin point"), // 8 @@ -540,8 +540,7 @@ QString VToolMove::MakeToolTip() const //--------------------------------------------------------------------------------------------------------------------- VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent) - : VAbstractOperation(initData.doc, initData.data, initData.id, initData.suffix, initData.source, - initData.destination, initData.notes, parent), + : VAbstractOperation(initData, parent), formulaAngle(initData.formulaAngle), formulaRotationAngle(initData.formulaRotationAngle), formulaLength(initData.formulaLength), @@ -552,14 +551,19 @@ VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent) } //--------------------------------------------------------------------------------------------------------------------- -DestinationItem VToolMove::CreatePoint(quint32 idTool, quint32 idItem, qreal angle, - qreal length, qreal rotationAngle, const QPointF &rotationOrigin, +DestinationItem VToolMove::CreatePoint(quint32 idTool, const SourceItem &sItem, qreal angle, + qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data) { - const QSharedPointer point = data->GeometricObject(idItem); + const QSharedPointer point = data->GeometricObject(sItem.id); VPointF moved = point->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle); moved.setIdObject(idTool); + if (not sItem.alias.isEmpty()) + { + moved.setName(sItem.alias); + } + DestinationItem item; item.mx = moved.mx(); item.my = moved.my(); @@ -570,47 +574,60 @@ DestinationItem VToolMove::CreatePoint(quint32 idTool, quint32 idItem, qreal ang //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VToolMove::CreateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, - const QPointF &rotationOrigin, const QString &suffix, VContainer *data) +DestinationItem VToolMove::CreateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, + qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, + VContainer *data) { - const DestinationItem item = CreateItem(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix, + const DestinationItem item = CreateItem(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data); data->AddArc(data->GeometricObject(item.id), item.id); return item; } //--------------------------------------------------------------------------------------------------------------------- -void VToolMove::UpdatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, +void VToolMove::UpdatePoint(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, const DestinationItem &item) { - const QSharedPointer point = data->GeometricObject(idItem); + const QSharedPointer point = data->GeometricObject(sItem.id); VPointF moved = point->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle); moved.setIdObject(idTool); moved.setMx(item.mx); moved.setMy(item.my); moved.SetShowLabel(item.showLabel); + + if (not sItem.alias.isEmpty()) + { + moved.setName(sItem.alias); + } + data->UpdateGObject(item.id, new VPointF(moved)); } //--------------------------------------------------------------------------------------------------------------------- template -void VToolMove::UpdateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, +void VToolMove::UpdateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id) { - UpdateItem(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id); + UpdateItem(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id); data->AddArc(data->GeometricObject(id), id); } //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VToolMove::CreateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, - const QPointF &rotationOrigin, const QString &suffix, VContainer *data) +DestinationItem VToolMove::CreateItem(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, + qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, + VContainer *data) { - const QSharedPointer i = data->GeometricObject(idItem); + const QSharedPointer i = data->GeometricObject(sItem.id); Item moved = i->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle); moved.setIdObject(idTool); + if (not sItem.alias.isEmpty()) + { + moved.SetAliasSuffix(sItem.alias); + } + DestinationItem item; item.mx = INT_MAX; item.my = INT_MAX; @@ -620,10 +637,11 @@ DestinationItem VToolMove::CreateItem(quint32 idTool, quint32 idItem, qreal angl //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VToolMove::CreateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, - const QPointF &rotationOrigin, const QString &suffix, VContainer *data) +DestinationItem VToolMove::CreateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, + qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, + VContainer *data) { - const DestinationItem item = CreateItem(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix, + const DestinationItem item = CreateItem(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data); data->AddSpline(data->GeometricObject(item.id), item.id); return item; @@ -631,12 +649,12 @@ DestinationItem VToolMove::CreateCurve(quint32 idTool, quint32 idItem, qreal ang //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VToolMove::CreateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, +DestinationItem VToolMove::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data) { - const DestinationItem item = CreateItem(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix, + const DestinationItem item = CreateItem(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data); data->AddCurveWithSegments(data->GeometricObject(item.id), item.id); return item; @@ -644,30 +662,36 @@ DestinationItem VToolMove::CreateCurveWithSegments(quint32 idTool, quint32 idIte //--------------------------------------------------------------------------------------------------------------------- template -void VToolMove::UpdateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, +void VToolMove::UpdateItem(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id) { - const QSharedPointer i = data->GeometricObject(idItem); + const QSharedPointer i = data->GeometricObject(sItem.id); Item moved = i->Move(length, angle, suffix).Rotate(rotationOrigin, rotationAngle); moved.setIdObject(idTool); + + if (not sItem.alias.isEmpty()) + { + moved.SetAliasSuffix(sItem.alias); + } + data->UpdateGObject(id, new Item(moved)); } //--------------------------------------------------------------------------------------------------------------------- template -void VToolMove::UpdateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, +void VToolMove::UpdateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id) { - UpdateItem(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id); + UpdateItem(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id); data->AddSpline(data->GeometricObject(id), id); } //--------------------------------------------------------------------------------------------------------------------- template -void VToolMove::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, - const QPointF &rotationOrigin, const QString &suffix, VContainer *data, - quint32 id) +void VToolMove::UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, + qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, + VContainer *data, quint32 id) { - UpdateItem(idTool, idItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id); + UpdateItem(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data, id); data->AddCurveWithSegments(data->GeometricObject(id), id); } diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.h b/src/libs/vtools/tools/drawTools/operation/vtoolmove.h index 32982e81e..1b27befd8 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.h +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.h @@ -104,41 +104,45 @@ private: QString formulaLength; quint32 origPointId; - VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent = nullptr); + explicit VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent = nullptr); - static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, - const QPointF &rotationOrigin, const QString &suffix, VContainer *data); + static DestinationItem CreatePoint(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, + qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, + VContainer *data); template - static DestinationItem CreateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, - const QPointF &rotationOrigin, const QString &suffix, VContainer *data); + static DestinationItem CreateItem(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, + qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, + VContainer *data); template - static DestinationItem CreateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, - const QPointF &rotationOrigin, const QString &suffix, VContainer *data); + static DestinationItem CreateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, + qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, + VContainer *data); template - static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, - const QPointF &rotationOrigin,const QString &suffix, VContainer *data); + static DestinationItem CreateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, + qreal rotationAngle, const QPointF &rotationOrigin,const QString &suffix, + VContainer *data); template - static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length, + static DestinationItem CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data); - static void UpdatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, + static void UpdatePoint(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, const DestinationItem &item); template - static void UpdateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, + static void UpdateItem(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id); template - static void UpdateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, + static void UpdateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id); template - static void UpdateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, + static void UpdateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id); template - static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotationAngle, - const QPointF &rotationOrigin, const QString &suffix, VContainer *data, - quint32 id); + static void UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, + qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix, + VContainer *data, quint32 id); }; #endif // VTOOLMOVING_H diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp index 7506c7077..de1829a23 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp @@ -80,8 +80,7 @@ const QString VToolRotation::ToolType = QStringLiteral("rotation"); //--------------------------------------------------------------------------------------------------------------------- VToolRotation::VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent) - : VAbstractOperation(initData.doc, initData.data, initData.id, initData.suffix, initData.source, - initData.destination, initData.notes, parent), + : VAbstractOperation(initData, parent), origPointId(initData.origin), formulaAngle(initData.angle) { @@ -99,6 +98,7 @@ void VToolRotation::setDialog() dialogTool->SetAngle(formulaAngle); dialogTool->SetSuffix(suffix); dialogTool->SetNotes(m_notes); + dialogTool->SetSourceObjects(source); SetDialogVisibilityGroupData(dialogTool); } @@ -115,7 +115,7 @@ VToolRotation *VToolRotation::Create(const QPointer &dialog, VMainGr initData.origin = dialogTool->GetOrigPointId(); initData.angle = dialogTool->GetAngle(); initData.suffix = dialogTool->GetSuffix(); - initData.source = dialogTool->GetObjects(); + initData.source = dialogTool->GetSourceObjects(); initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup(); initData.visibilityGroupName = dialogTool->GetVisibilityGroupName(); initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags(); @@ -150,9 +150,9 @@ VToolRotation *VToolRotation::Create(VToolRotationInitData &initData) initData.id = initData.data->getNextId();//Just reserve id for tool - for (auto idObject : qAsConst(initData.source)) + for (auto object : qAsConst(initData.source)) { - const QSharedPointer obj = initData.data->GetGObject(idObject); + const QSharedPointer obj = initData.data->GetGObject(object.id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); @@ -162,32 +162,32 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") switch(static_cast(obj->getType())) { case GOType::Point: - initData.destination.append(CreatePoint(initData.id, idObject, oPoint, calcAngle, initData.suffix, + initData.destination.append(CreatePoint(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data)); break; case GOType::Arc: - initData.destination.append(CreateArc(initData.id, idObject, oPoint, calcAngle, + initData.destination.append(CreateArc(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data)); break; case GOType::EllipticalArc: - initData.destination.append(CreateArc(initData.id, idObject, oPoint, calcAngle, + initData.destination.append(CreateArc(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data)); break; case GOType::Spline: - initData.destination.append(CreateCurve(initData.id, idObject, oPoint, calcAngle, + initData.destination.append(CreateCurve(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data)); break; case GOType::SplinePath: - initData.destination.append(CreateCurveWithSegments(initData.id, idObject, oPoint, + initData.destination.append(CreateCurveWithSegments(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data)); break; case GOType::CubicBezier: - initData.destination.append(CreateCurve(initData.id, idObject, oPoint, calcAngle, + initData.destination.append(CreateCurve(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data)); break; case GOType::CubicBezierPath: - initData.destination.append(CreateCurveWithSegments(initData.id, idObject, oPoint, + initData.destination.append(CreateCurveWithSegments(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data)); break; @@ -203,8 +203,8 @@ QT_WARNING_POP { for (int i = 0; i < initData.source.size(); ++i) { - const quint32 idObject = initData.source.at(i); - const QSharedPointer obj = initData.data->GetGObject(idObject); + const SourceItem object = initData.source.at(i); + const QSharedPointer obj = initData.data->GetGObject(object.id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); @@ -215,32 +215,32 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") { case GOType::Point: { - UpdatePoint(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data, + UpdatePoint(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data, initData.destination.at(i)); break; } case GOType::Arc: - UpdateArc(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data, + UpdateArc(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::EllipticalArc: - UpdateArc(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data, + UpdateArc(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::Spline: - UpdateCurve(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data, + UpdateCurve(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::SplinePath: - UpdateCurveWithSegments(initData.id, idObject, oPoint, calcAngle, initData.suffix, + UpdateCurveWithSegments(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::CubicBezier: - UpdateCurve(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data, + UpdateCurve(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::CubicBezierPath: - UpdateCurveWithSegments(initData.id, idObject, oPoint, calcAngle, initData.suffix, + UpdateCurveWithSegments(initData.id, object, oPoint, calcAngle, initData.suffix, initData.data, initData.destination.at(i).id); break; case GOType::Unknown: @@ -269,9 +269,9 @@ QT_WARNING_POP InitOperationToolConnections(initData.scene, tool); VAbstractPattern::AddTool(initData.id, tool); initData.doc->IncrementReferens(originPoint.getIdTool()); - for (auto idObject : qAsConst(initData.source)) + for (auto object : qAsConst(initData.source)) { - initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool()); + initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool()); } if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) @@ -342,7 +342,7 @@ void VToolRotation::SetVisualization() VisToolRotation *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->SetObjects(source); + visual->SetObjects(SourceToObjects(source)); visual->SetOriginPointId(origPointId); visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator())); visual->RefreshGeometry(); @@ -367,6 +367,9 @@ void VToolRotation::SaveDialog(QDomElement &domElement, QList &oldDepen const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + source = dialogTool->GetSourceObjects(); + SaveSourceDestination(domElement); + // Save visibility data for later use SaveVisibilityGroupData(dialogTool); } @@ -378,7 +381,6 @@ void VToolRotation::ReadToolAttributes(const QDomElement &domElement) origPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); formulaAngle = doc->GetParametrString(domElement, AttrAngle, QChar('0')); - suffix = doc->GetParametrString(domElement, AttrSuffix); } //--------------------------------------------------------------------------------------------------------------------- @@ -389,9 +391,6 @@ void VToolRotation::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrType, ToolType); doc->SetAttribute(tag, AttrCenter, QString().setNum(origPointId)); doc->SetAttribute(tag, AttrAngle, formulaAngle); - doc->SetAttribute(tag, AttrSuffix, suffix); - - SaveSourceDestination(tag); } //--------------------------------------------------------------------------------------------------------------------- @@ -406,13 +405,18 @@ QString VToolRotation::MakeToolTip() const } //--------------------------------------------------------------------------------------------------------------------- -DestinationItem VToolRotation::CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, +DestinationItem VToolRotation::CreatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data) { - const QSharedPointer point = data->GeometricObject(idItem); + const QSharedPointer point = data->GeometricObject(sItem.id); VPointF rotated = point->Rotate(origin, angle, suffix); rotated.setIdObject(idTool); + if (not sItem.alias.isEmpty()) + { + rotated.setName(sItem.alias); + } + DestinationItem item; item.mx = rotated.mx(); item.my = rotated.my(); @@ -423,13 +427,18 @@ DestinationItem VToolRotation::CreatePoint(quint32 idTool, quint32 idItem, const //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VToolRotation::CreateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, +DestinationItem VToolRotation::CreateItem(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data) { - const QSharedPointer i = data->GeometricObject(idItem); + const QSharedPointer i = data->GeometricObject(sItem.id); Item rotated = i->Rotate(origin, angle, suffix); rotated.setIdObject(idTool); + if (not sItem.alias.isEmpty()) + { + rotated.SetAliasSuffix(sItem.alias); + } + DestinationItem item; item.mx = INT_MAX; item.my = INT_MAX; @@ -439,81 +448,93 @@ DestinationItem VToolRotation::CreateItem(quint32 idTool, quint32 idItem, const //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VToolRotation::CreateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, +DestinationItem VToolRotation::CreateArc(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data) { - const DestinationItem item = CreateItem(idTool, idItem, origin, angle, suffix, data); + const DestinationItem item = CreateItem(idTool, sItem, origin, angle, suffix, data); data->AddArc(data->GeometricObject(item.id), item.id); return item; } //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VToolRotation::CreateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, +DestinationItem VToolRotation::CreateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data) { - const DestinationItem item = CreateItem(idTool, idItem, origin, angle, suffix, data); + const DestinationItem item = CreateItem(idTool, sItem, origin, angle, suffix, data); data->AddSpline(data->GeometricObject(item.id), item.id); return item; } //--------------------------------------------------------------------------------------------------------------------- template -DestinationItem VToolRotation::CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, +DestinationItem VToolRotation::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data) { - const DestinationItem item = CreateItem(idTool, idItem, origin, angle, suffix, data); + const DestinationItem item = CreateItem(idTool, sItem, origin, angle, suffix, data); data->AddCurveWithSegments(data->GeometricObject(item.id), item.id); return item; } //--------------------------------------------------------------------------------------------------------------------- -void VToolRotation::UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, +void VToolRotation::UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data, const DestinationItem &item) { - const QSharedPointer point = data->GeometricObject(idItem); + const QSharedPointer point = data->GeometricObject(sItem.id); VPointF rotated = point->Rotate(origin, angle, suffix); rotated.setIdObject(idTool); rotated.setMx(item.mx); rotated.setMy(item.my); rotated.SetShowLabel(item.showLabel); + + if (not sItem.alias.isEmpty()) + { + rotated.setName(sItem.alias); + } + data->UpdateGObject(item.id, new VPointF(rotated)); } //--------------------------------------------------------------------------------------------------------------------- template -void VToolRotation::UpdateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, +void VToolRotation::UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data, quint32 id) { - const QSharedPointer i = data->GeometricObject(idItem); + const QSharedPointer i = data->GeometricObject(sItem.id); Item rotated = i->Rotate(origin, angle, suffix); rotated.setIdObject(idTool); + + if (not sItem.alias.isEmpty()) + { + rotated.SetAliasSuffix(sItem.alias); + } + data->UpdateGObject(id, new Item(rotated)); } //--------------------------------------------------------------------------------------------------------------------- template -void VToolRotation::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, +void VToolRotation::UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data, quint32 id) { - UpdateItem(idTool, idItem, origin, angle, suffix, data, id); + UpdateItem(idTool, sItem, origin, angle, suffix, data, id); data->AddArc(data->GeometricObject(id), id); } //--------------------------------------------------------------------------------------------------------------------- template -void VToolRotation::UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, +void VToolRotation::UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data, quint32 id) { - UpdateItem(idTool, idItem, origin, angle, suffix, data, id); + UpdateItem(idTool, sItem, origin, angle, suffix, data, id); data->AddSpline(data->GeometricObject(id), id); } //--------------------------------------------------------------------------------------------------------------------- template -void VToolRotation::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, +void VToolRotation::UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data, quint32 id) { - UpdateItem(idTool, idItem, origin, angle, suffix, data, id); + UpdateItem(idTool, sItem, origin, angle, suffix, data, id); data->AddCurveWithSegments(data->GeometricObject(id), id); } diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h index 96bc09e45..354ee2a83 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h @@ -95,35 +95,35 @@ private: VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent = nullptr); - static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, + static DestinationItem CreatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data); template - static DestinationItem CreateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, + static DestinationItem CreateItem(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data); template - static DestinationItem CreateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, + static DestinationItem CreateArc(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data); template - static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, + static DestinationItem CreateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data); template - static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, + static DestinationItem CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data); - static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, + static void UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data, const DestinationItem &item); template - static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, + static void UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data, quint32 id); template - static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, + static void UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data, quint32 id); template - static void UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, + static void UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data, quint32 id); template - static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle, + static void UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &origin, qreal angle, const QString &suffix, VContainer *data, quint32 id); }; diff --git a/src/libs/vtools/tools/tools.pri b/src/libs/vtools/tools/tools.pri index 3d3414519..93eec3025 100644 --- a/src/libs/vtools/tools/tools.pri +++ b/src/libs/vtools/tools/tools.pri @@ -2,6 +2,7 @@ # This need for corect working file translations.pro HEADERS += \ + $$PWD/toolsdef.h \ $$PWD/vdatatool.h \ $$PWD/vabstracttool.h \ $$PWD/tools.h \ @@ -64,6 +65,7 @@ HEADERS += \ $$PWD/nodeDetails/vtoolplacelabel.h SOURCES += \ + $$PWD/toolsdef.cpp \ $$PWD/vdatatool.cpp \ $$PWD/vabstracttool.cpp \ $$PWD/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp \ diff --git a/src/libs/vtools/tools/toolsdef.cpp b/src/libs/vtools/tools/toolsdef.cpp new file mode 100644 index 000000000..e76d15dc6 --- /dev/null +++ b/src/libs/vtools/tools/toolsdef.cpp @@ -0,0 +1,105 @@ +/************************************************************************ + ** + ** @file toolsdef.cpp + ** @author Roman Telezhynskyi + ** @date 6 11, 2020 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2020 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "toolsdef.h" + +#include +#include + +#include "../vgeometry/vgobject.h" +#include "../qmuparser/qmudef.h" +#include "../vpatterndb/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +QVector SourceToObjects(const QVector &source) +{ + QVector ids; + ids.reserve(source.size()); + + for (auto s: source) + { + ids.append(s.id); + } + + return ids; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool SourceAliasValid(const SourceItem &item, const QSharedPointer &obj, const VContainer *data, + const QString &originAlias) +{ + SCASSERT(data != nullptr) + + QRegularExpression rx(NameRegExp()); + + QString alias; + + if (obj->getType() == GOType::Point) + { + alias = item.alias; + } + else + { + const QString oldAlias = obj->GetAliasSuffix(); + obj->SetAliasSuffix(item.alias); + alias = obj->GetAlias(); + obj->SetAliasSuffix(oldAlias); + } + + if (not alias.isEmpty() && originAlias != alias && + (not rx.match(alias).hasMatch() || not data->IsUnique(alias))) + { + return false; + } + + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString OriginAlias(quint32 id, const QVector &source, const QSharedPointer &obj) +{ + auto item = std::find_if(source.begin(), source.end(), + [id](const SourceItem &sItem) { return sItem.id == id; }); + if (item != source.end()) + { + if (obj->getType() == GOType::Point) + { + return item->alias; + } + else + { + const QString oldAlias = obj->GetAliasSuffix(); + obj->SetAliasSuffix(item->alias); + QString alias = obj->GetAlias(); + obj->SetAliasSuffix(oldAlias); + return alias; + } + } + + return QString(); +} diff --git a/src/libs/vtools/tools/toolsdef.h b/src/libs/vtools/tools/toolsdef.h new file mode 100644 index 000000000..ce09a70f4 --- /dev/null +++ b/src/libs/vtools/tools/toolsdef.h @@ -0,0 +1,53 @@ +/************************************************************************ + ** + ** @file toolsdef.h + ** @author Roman Telezhynskyi + ** @date 6 11, 2020 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2020 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ +#ifndef TOOLSDEF_H +#define TOOLSDEF_H + +#include +#include + +class VGObject; +class VContainer; + +struct SourceItem +{ + quint32 id{0}; + QString alias{}; +}; + +Q_DECLARE_METATYPE(SourceItem) +Q_DECLARE_TYPEINFO(SourceItem, Q_MOVABLE_TYPE); + +QVector SourceToObjects(const QVector &source); + +QString OriginAlias(quint32 id, const QVector &source, const QSharedPointer &obj); + +bool SourceAliasValid(const SourceItem &item, const QSharedPointer &obj, const VContainer *data, + const QString &originAlias); + +#endif // TOOLSDEF_H diff --git a/src/libs/vtools/visualization/line/operation/visoperation.cpp b/src/libs/vtools/visualization/line/operation/visoperation.cpp index 258360e92..7147e14d7 100644 --- a/src/libs/vtools/visualization/line/operation/visoperation.cpp +++ b/src/libs/vtools/visualization/line/operation/visoperation.cpp @@ -57,7 +57,7 @@ VisOperation::~VisOperation() } //--------------------------------------------------------------------------------------------------------------------- -void VisOperation::SetObjects(QVector objects) +void VisOperation::SetObjects(const QVector &objects) { this->objects = objects; } diff --git a/src/libs/vtools/visualization/line/operation/visoperation.h b/src/libs/vtools/visualization/line/operation/visoperation.h index 0599a03fb..e444ddba1 100644 --- a/src/libs/vtools/visualization/line/operation/visoperation.h +++ b/src/libs/vtools/visualization/line/operation/visoperation.h @@ -41,7 +41,7 @@ public: explicit VisOperation(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisOperation(); - void SetObjects(QVector objects); + void SetObjects(const QVector &objects); virtual void VisualMode(const quint32 &pointId = NULL_ID) override;