diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp
index 39608bafd..4f6387df2 100644
--- a/src/app/valentina/xml/vpattern.cpp
+++ b/src/app/valentina/xml/vpattern.cpp
@@ -850,7 +850,7 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse
initData.width = GetParametrString(domElement, AttrWidth, "0.0");
const QString w = initData.width;//need for saving fixed formula;
- const uint version = GetParametrUInt(domElement, VToolSeamAllowance::AttrVersion, "1");
+ const uint version = GetParametrUInt(domElement, AttrVersion, "1");
const QStringList tags = QStringList() << TagNodes
<< TagData
@@ -1721,7 +1721,7 @@ void VPattern::ParsePlaceLabel(QDomElement &domElement, const Document &parse)
initData.centerPoint = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
- initData.width = GetParametrString(domElement, AttrLength, "1.0");
+ initData.width = GetParametrString(domElement, AttrWidth, "1.0");
const QString w = initData.width;//need for saving fixed formula;
initData.height = GetParametrString(domElement, AttrHeight, "1.0");
@@ -3550,6 +3550,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d
VToolUnionDetailsInitData initData;
initData.indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1");
initData.indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1");
+ initData.version = GetParametrUInt(domElement, AttrVersion, "1");
initData.scene = scene;
initData.doc = this;
initData.data = data;
diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp
index bd002fef8..7cf49e776 100644
--- a/src/libs/ifc/ifcdef.cpp
+++ b/src/libs/ifc/ifcdef.cpp
@@ -43,8 +43,6 @@
const QString CustomMSign = QStringLiteral("@");
const QString CustomIncrSign = QStringLiteral("#");
-
-
const QString AttrType = QStringLiteral("type");
const QString AttrMx = QStringLiteral("mx");
const QString AttrMy = QStringLiteral("my");
@@ -129,6 +127,7 @@ const QString AttrShowLabel2 = QStringLiteral("showLabel2");
const QString AttrWidth = QStringLiteral("width");
const QString AttrHeight = QStringLiteral("height");
const QString AttrPlaceLabelType = QStringLiteral("placeLabelType");
+const QString AttrVersion = QStringLiteral("version");
const QString TypeLineNone = QStringLiteral("none");
const QString TypeLineLine = QStringLiteral("hair");
diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h
index a14b930f7..9a1b95892 100644
--- a/src/libs/ifc/ifcdef.h
+++ b/src/libs/ifc/ifcdef.h
@@ -148,6 +148,7 @@ extern const QString AttrShowLabel2;
extern const QString AttrWidth;
extern const QString AttrHeight;
extern const QString AttrPlaceLabelType;
+extern const QString AttrVersion;
extern const QString TypeLineNone;
extern const QString TypeLineLine;
diff --git a/src/libs/ifc/schema/pattern/v0.7.0.xsd b/src/libs/ifc/schema/pattern/v0.7.0.xsd
index 2d716b4f7..970168e4f 100644
--- a/src/libs/ifc/schema/pattern/v0.7.0.xsd
+++ b/src/libs/ifc/schema/pattern/v0.7.0.xsd
@@ -548,6 +548,7 @@
+
@@ -1030,4 +1031,12 @@
+
+
+
+
+
+
+
+
diff --git a/src/libs/vgeometry/vellipticalarc.cpp b/src/libs/vgeometry/vellipticalarc.cpp
index 75f35f157..792f23abf 100644
--- a/src/libs/vgeometry/vellipticalarc.cpp
+++ b/src/libs/vgeometry/vellipticalarc.cpp
@@ -266,8 +266,16 @@ QVector VEllipticalArc::GetPoints() const
path = t.map(path);
- QPolygonF polygon = path.toSubpathPolygons().first();
- polygon.removeFirst(); // remove point (0;0)
+ QPolygonF polygon;
+ const QList sub = path.toSubpathPolygons();
+ if (not sub.isEmpty())
+ {
+ polygon = path.toSubpathPolygons().first();
+ if (not polygon.isEmpty())
+ {
+ polygon.removeFirst(); // remove point (0;0)
+ }
+ }
return polygon;
}
diff --git a/src/libs/vgeometry/vplacelabelitem.cpp b/src/libs/vgeometry/vplacelabelitem.cpp
index 3ced29e35..95eb9e65c 100644
--- a/src/libs/vgeometry/vplacelabelitem.cpp
+++ b/src/libs/vgeometry/vplacelabelitem.cpp
@@ -180,7 +180,7 @@ PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const
QTransform t;
t.translate(center->x(), center->y());
- t.rotate(-d->aValue+d->correctionAngle);
+ t.rotate(-(d->aValue+d->correctionAngle));
t.translate(-center->x(), -center->y());
auto SegmentShape = [center, t, this]()
diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp
index 4f9360c90..05280ec9c 100644
--- a/src/libs/vlayout/vlayoutpiece.cpp
+++ b/src/libs/vlayout/vlayoutpiece.cpp
@@ -350,8 +350,8 @@ QVector ConvertPlaceLabels(const VPiece &piece, const VContai
{
const auto label = pattern->GeometricObject(piece.GetPlaceLabels().at(i));
VLayoutPlaceLabel layoutLabel;
- layoutLabel.shape = label->LabelShape(pattern);
- layoutLabel.center = pattern->GeometricObject(label->GetCenterPoint())->toQPointF();
+ layoutLabel.shape = label->LabelShape();
+ layoutLabel.center = label->toQPointF();
layoutLabel.type = label->GetLabelType();
labels.append(layoutLabel);
}
diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp
index db76f5a6a..e01c1698b 100644
--- a/src/libs/vpatterndb/vpiece.cpp
+++ b/src/libs/vpatterndb/vpiece.cpp
@@ -662,6 +662,34 @@ void VPiece::SetPlaceLabels(const QVector &labels)
d->m_placeLabels = labels;
}
+//---------------------------------------------------------------------------------------------------------------------
+QList VPiece::Dependencies() const
+{
+ QList list = d->m_path.Dependencies();
+
+ foreach (const CustomSARecord &record, d->m_customSARecords)
+ {
+ list.append(record.path);
+ }
+
+ foreach (const quint32 &value, d->m_internalPaths)
+ {
+ list.append(value);
+ }
+
+ foreach (const quint32 &value, d->m_pins)
+ {
+ list.append(value);
+ }
+
+ foreach (const quint32 &value, d->m_placeLabels)
+ {
+ list.append(value);
+ }
+
+ return list;
+}
+
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief MissingNodes find missing nodes in detail. When we deleted object in detail and return this detail need
diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h
index 07b4f865a..5c2d976bf 100644
--- a/src/libs/vpatterndb/vpiece.h
+++ b/src/libs/vpatterndb/vpiece.h
@@ -106,6 +106,7 @@ public:
QVector &GetPlaceLabels();
void SetPlaceLabels(const QVector &labels);
+ QList Dependencies() const;
QVector MissingNodes(const VPiece &det) const;
QVector MissingCSAPath(const VPiece &det) const;
QVector MissingInternalPaths(const VPiece &det) const;
diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp
index 0ecf5d92d..1756552b2 100644
--- a/src/libs/vpatterndb/vpiecepath.cpp
+++ b/src/libs/vpatterndb/vpiecepath.cpp
@@ -435,6 +435,17 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector VPiecePath::Dependencies() const
+{
+ QList list;
+ foreach (const VPieceNode &node, d->m_nodes)
+ {
+ list.append(node.GetId());
+ }
+ return list;
+}
+
//---------------------------------------------------------------------------------------------------------------------
QVector VPiecePath::MissingNodes(const VPiecePath &path) const
{
diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h
index ae6cc0354..adaecb980 100644
--- a/src/libs/vpatterndb/vpiecepath.h
+++ b/src/libs/vpatterndb/vpiecepath.h
@@ -87,6 +87,7 @@ public:
QPainterPath PainterPath(const VContainer *data) const;
+ QList Dependencies() const;
QVector MissingNodes(const VPiecePath &path) const;
int indexOfNode(quint32 id) const;
diff --git a/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp b/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp
index faf2bdcde..c0c331f33 100644
--- a/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp
+++ b/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp
@@ -112,6 +112,7 @@ void DialogPlaceLabel::EnbleShowMode(bool disable)
{
m_showMode = disable;
ui->comboBoxPiece->setDisabled(m_showMode);
+ ui->comboBoxPoint->setDisabled(m_showMode);
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/dialogs/tools/dialogspline.cpp b/src/libs/vtools/dialogs/tools/dialogspline.cpp
index 439a347d5..ff4d0cee8 100644
--- a/src/libs/vtools/dialogs/tools/dialogspline.cpp
+++ b/src/libs/vtools/dialogs/tools/dialogspline.cpp
@@ -457,10 +457,10 @@ VSpline DialogSpline::CurrentSpline() const
const QHash > *vars = data->DataVariables();
- const qreal angle1 = Visualization::FindVal(angle1F, vars);
- const qreal angle2 = Visualization::FindVal(angle2F, vars);
- const qreal length1 = Visualization::FindLength(length1F, vars);
- const qreal length2 = Visualization::FindLength(length2F, vars);
+ const qreal angle1 = Visualization::FindValFromUser(angle1F, vars);
+ const qreal angle2 = Visualization::FindValFromUser(angle2F, vars);
+ const qreal length1 = Visualization::FindLengthFromUser(length1F, vars);
+ const qreal length2 = Visualization::FindLengthFromUser(length2F, vars);
const bool separator = qApp->Settings()->GetOsSeparator();
diff --git a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp
index 5de20eff2..e614b1cb5 100644
--- a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp
+++ b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp
@@ -307,7 +307,7 @@ void DialogSplinePath::Angle1Changed()
VSplinePoint p = qvariant_cast(item->data(Qt::UserRole));
const QString angle1F = ui->plainTextEditAngle1F->toPlainText().replace("\n", " ");
- const qreal angle1 = Visualization::FindVal(angle1F, data->DataVariables());
+ const qreal angle1 = Visualization::FindValFromUser(angle1F, data->DataVariables());
p.SetAngle1(angle1, VTranslateVars::TryFormulaFromUser(angle1F, qApp->Settings()->GetOsSeparator()));
item->setData(Qt::UserRole, QVariant::fromValue(p));
@@ -341,7 +341,7 @@ void DialogSplinePath::Angle2Changed()
VSplinePoint p = qvariant_cast(item->data(Qt::UserRole));
const QString angle2F = ui->plainTextEditAngle2F->toPlainText().replace("\n", " ");
- const qreal angle2 = Visualization::FindVal(angle2F, data->DataVariables());
+ const qreal angle2 = Visualization::FindValFromUser(angle2F, data->DataVariables());
p.SetAngle2(angle2, VTranslateVars::TryFormulaFromUser(angle2F, qApp->Settings()->GetOsSeparator()));
item->setData(Qt::UserRole, QVariant::fromValue(p));
@@ -375,7 +375,7 @@ void DialogSplinePath::Length1Changed()
VSplinePoint p = qvariant_cast(item->data(Qt::UserRole));
const QString length1F = ui->plainTextEditLength1F->toPlainText().replace("\n", " ");
- const qreal length1 = Visualization::FindLength(length1F, data->DataVariables());
+ const qreal length1 = Visualization::FindLengthFromUser(length1F, data->DataVariables());
p.SetLength1(length1, VTranslateVars::TryFormulaFromUser(length1F, qApp->Settings()->GetOsSeparator()));
item->setData(Qt::UserRole, QVariant::fromValue(p));
@@ -400,7 +400,7 @@ void DialogSplinePath::Length2Changed()
VSplinePoint p = qvariant_cast(item->data(Qt::UserRole));
const QString length2F = ui->plainTextEditLength2F->toPlainText().replace("\n", " ");
- const qreal length2 = Visualization::FindLength(length2F, data->DataVariables());
+ const qreal length2 = Visualization::FindLengthFromUser(length2F, data->DataVariables());
p.SetLength2(length2, VTranslateVars::TryFormulaFromUser(length2F, qApp->Settings()->GetOsSeparator()));
item->setData(Qt::UserRole, QVariant::fromValue(p));
diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp
index a1f830b2b..aaa567b9a 100644
--- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp
+++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp
@@ -128,7 +128,10 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
m_timerWidthBefore(nullptr),
m_timerWidthAfter(nullptr),
m_saWidth(0),
- m_templateLines()
+ m_templateLines(),
+ m_undoStack(),
+ m_newPlaceLabels(),
+ m_newPaths()
{
ui->setupUi(this);
@@ -641,7 +644,7 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos)
else if (selectedAction == actionOption)
{
auto *dialog = new DialogPiecePath(data, record.path, this);
- dialog->SetPiecePath(data->GetPiecePath(record.path));
+ dialog->SetPiecePath(CurrentPath(record.path));
dialog->SetPieceId(toolId);
if (record.includeType == PiecePathIncludeType::AsMainPath)
{
@@ -681,7 +684,7 @@ void DialogSeamAllowance::ShowInternalPathsContextMenu(const QPoint &pos)
const quint32 pathId = qvariant_cast(rowItem->data(Qt::UserRole));
auto *dialog = new DialogPiecePath(data, pathId, this);
- dialog->SetPiecePath(data->GetPiecePath(pathId));
+ dialog->SetPiecePath(CurrentPath(pathId));
dialog->SetPieceId(toolId);
dialog->EnbleShowMode(true);
m_dialog = dialog;
@@ -726,26 +729,28 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
QListWidgetItem *rowItem = uiTabPlaceLabels->listWidgetPlaceLabels->item(row);
SCASSERT(rowItem != nullptr);
const quint32 labelId = qvariant_cast(rowItem->data(Qt::UserRole));
- const auto label = data->GeometricObject(labelId);
+ VPlaceLabelItem currentLabel = CurrentPlaceLabel(labelId);
QScopedPointer menu(new QMenu());
- auto InitAction = [&menu, label](const QString &text, PlaceLabelType type)
+ auto InitAction = [currentLabel, &menu](const QString &text, PlaceLabelType type)
{
QAction *action = menu->addAction(text);
action->setCheckable(true);
- action->setChecked(label->GetLabelType() == type);
+ action->setChecked(currentLabel.GetLabelType() == type);
return action;
};
- auto SaveType = [this, label, labelId](PlaceLabelType type)
+ auto SaveType = [this, currentLabel, labelId](PlaceLabelType type)
{
- VPlaceLabelItem newLabel = VPlaceLabelItem(*label);
+ VPlaceLabelItem newLabel = VPlaceLabelItem(currentLabel);
newLabel.SetLabelType(type);
+ m_newPlaceLabels.insert(labelId, newLabel);
- SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(*label, newLabel, qApp->getCurrentDocument(),
+ SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(toolId, currentLabel, newLabel,
+ qApp->getCurrentDocument(),
const_cast(data), labelId);
- qApp->getUndoStack()->push(saveCommand);
+ m_undoStack.append(saveCommand);
UpdateCurrentPlaceLabelRecords();
};
@@ -772,11 +777,11 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
else if (selectedAction == actionOption)
{
auto *dialog = new DialogPlaceLabel(data, labelId, this);
- dialog->SetCenterPoint(label->GetCenterPoint());
- dialog->SetLabelType(label->GetLabelType());
- dialog->SetWidth(label->GetWidthFormula());
- dialog->SetHeight(label->GetHeightFormula());
- dialog->SetAngle(label->GetAngleFormula());
+ dialog->SetCenterPoint(labelId);
+ dialog->SetLabelType(currentLabel.GetLabelType());
+ dialog->SetWidth(currentLabel.GetWidthFormula());
+ dialog->SetHeight(currentLabel.GetHeightFormula());
+ dialog->SetAngle(currentLabel.GetAngleFormula());
dialog->SetPieceId(toolId);
dialog->EnbleShowMode(true);
m_dialog = dialog;
@@ -1175,13 +1180,15 @@ void DialogSeamAllowance::PathDialogClosed(int result)
SCASSERT(dialogTool != nullptr);
try
{
- const VPiecePath newPath = dialogTool->GetPiecePath();
- const VPiecePath oldPath = data->GetPiecePath(dialogTool->GetToolId());
+ VPiecePath currentPath = CurrentPath(dialogTool->GetToolId());
+ VPiecePath newPath = dialogTool->GetPiecePath();
+ m_newPaths.insert(dialogTool->GetToolId(), newPath);
- SavePiecePathOptions *saveCommand = new SavePiecePathOptions(oldPath, newPath, qApp->getCurrentDocument(),
+ SavePiecePathOptions *saveCommand = new SavePiecePathOptions(toolId, currentPath, newPath,
+ qApp->getCurrentDocument(),
const_cast(data),
dialogTool->GetToolId());
- qApp->getUndoStack()->push(saveCommand);
+ m_undoStack.append(saveCommand);
UpdateCurrentCustomSARecord();
UpdateCurrentInternalPathRecord();
}
@@ -1204,34 +1211,35 @@ void DialogSeamAllowance::PlaceLabelDialogClosed(int result)
SCASSERT(dialogTool != nullptr);
try
{
- auto oldLabel = data->GeometricObject(dialogTool->GetToolId());
-
- auto point = data->GeometricObject(dialogTool->GetCenterPoint());
+ VPlaceLabelItem currentLabel = CurrentPlaceLabel(dialogTool->GetToolId());
const QHash > *vars = data->DataVariables();
- const qreal w = qAbs(Visualization::FindLength(dialogTool->GetWidth(), vars));
- const qreal h = qAbs(Visualization::FindLength(dialogTool->GetHeight(), vars));
- const qreal a = Visualization::FindVal(dialogTool->GetAngle(), vars);
+ const qreal w = qAbs(Visualization::FindLengthFromUser(dialogTool->GetWidth(), vars, false));
+ const qreal h = qAbs(Visualization::FindLengthFromUser(dialogTool->GetHeight(), vars, false));
+ const qreal a = Visualization::FindValFromUser(dialogTool->GetAngle(), vars, false);
+ qDebug() << w << h << a;
- VPlaceLabelItem newLabel = VPlaceLabelItem();
- newLabel.setName(point->name());
- newLabel.setX(point->x());
- newLabel.setY(point->y());
- newLabel.setMx(point->mx());
- newLabel.setMy(point->my());
+ VPlaceLabelItem newLabel = VPlaceLabelItem();
+ newLabel.setName(currentLabel.name());
+ newLabel.setX(currentLabel.x());
+ newLabel.setY(currentLabel.y());
+ newLabel.setMx(currentLabel.mx());
+ newLabel.setMy(currentLabel.my());
newLabel.SetWidth(w, dialogTool->GetWidth());
newLabel.SetHeight(h, dialogTool->GetHeight());
newLabel.SetAngle(a, dialogTool->GetAngle());
newLabel.SetLabelType(dialogTool->GetLabelType());
- newLabel.SetCenterPoint(dialogTool->GetCenterPoint());
- newLabel.SetCorrectionAngle(oldLabel->GetCorrectionAngle());
+ newLabel.SetCenterPoint(currentLabel.GetCenterPoint());
+ newLabel.SetCorrectionAngle(currentLabel.GetCorrectionAngle());
- SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(*oldLabel, newLabel,
+ m_newPlaceLabels.insert(dialogTool->GetToolId(), newLabel);
+
+ SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(toolId, currentLabel, newLabel,
qApp->getCurrentDocument(),
const_cast(data),
dialogTool->GetToolId());
- qApp->getUndoStack()->push(saveCommand);
+ m_undoStack.append(saveCommand);
UpdateCurrentPlaceLabelRecords();
}
catch (const VExceptionBadId &e)
@@ -2271,7 +2279,7 @@ QString DialogSeamAllowance::GetPathName(quint32 path, bool reverse) const
if (path > NULL_ID)
{
- name = data->GetPiecePath(path).GetName();
+ name = CurrentPath(path).GetName();
if (reverse)
{
@@ -2883,6 +2891,12 @@ QString DialogSeamAllowance::GetFormulaSAWidth() const
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
}
+//---------------------------------------------------------------------------------------------------------------------
+QVector &DialogSeamAllowance::UndoStack()
+{
+ return m_undoStack;
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula)
{
@@ -2943,9 +2957,8 @@ void DialogSeamAllowance::UpdateCurrentPlaceLabelRecords()
QListWidgetItem *item = uiTabPlaceLabels->listWidgetPlaceLabels->item(row);
SCASSERT(item != nullptr);
- const quint32 pointId = qvariant_cast(item->data(Qt::UserRole));
- auto point = data->GeometricObject(pointId);
- item->setText(point->name());
+ const quint32 labelId = qvariant_cast(item->data(Qt::UserRole));
+ item->setText(CurrentPlaceLabel(labelId).name());
}
//---------------------------------------------------------------------------------------------------------------------
@@ -3131,3 +3144,15 @@ void DialogSeamAllowance::ShowPieceSpecialPoints(const QListWidget *list)
m_visSpecialPoints->RefreshGeometry();
}
}
+
+//---------------------------------------------------------------------------------------------------------------------
+VPiecePath DialogSeamAllowance::CurrentPath(quint32 id) const
+{
+ return m_newPaths.contains(id) ? m_newPaths.value(id) : data->GetPiecePath(id);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+VPlaceLabelItem DialogSeamAllowance::CurrentPlaceLabel(quint32 id) const
+{
+ return m_newPlaceLabels.contains(id) ? m_newPlaceLabels.value(id) : *data->GeometricObject(id);
+}
diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h
index ef2f2fb34..2e8883f99 100644
--- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h
+++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h
@@ -48,6 +48,8 @@ namespace Ui
class VisPieceSpecialPoints;
class FancyTabBar;
+class VPlaceLabelItem;
+class QUndoCommand;
class DialogSeamAllowance : public DialogTool
{
@@ -64,6 +66,8 @@ public:
QString GetFormulaSAWidth() const;
+ QVector &UndoStack();
+
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
@@ -209,6 +213,10 @@ private:
QVector m_templateLines;
+ QVector m_undoStack;
+ QHash m_newPlaceLabels;
+ QHash m_newPaths;
+
VPiece CreatePiece() const;
void NewMainPathItem(const VPieceNode &node);
@@ -261,6 +269,9 @@ private:
void SetPLAngle(QString angleFormula);
void ShowPieceSpecialPoints(const QListWidget *list);
+
+ VPiecePath CurrentPath(quint32 id) const;
+ VPlaceLabelItem CurrentPlaceLabel(quint32 id) const;
};
#endif // DIALOGSEAMALLOWANCE_H
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp
index c08ae727a..faf490820 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp
+++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp
@@ -251,7 +251,7 @@ QString VToolCutArc::MakeToolTip() const
const QSharedPointer arc = VAbstractTool::data.GeometricObject(curveCutId);
const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
- const qreal length = Visualization::FindVal(expression, VAbstractTool::data.DataVariables());
+ const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables());
const QString arcStr = tr("Arc");
const QString lengthStr = tr("length");
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp
index d030552bf..91c4866b1 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp
+++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp
@@ -250,7 +250,7 @@ QString VToolCutSpline::MakeToolTip() const
const auto spl = VAbstractTool::data.GeometricObject(curveCutId);
const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
- const qreal length = Visualization::FindVal(expression, VAbstractTool::data.DataVariables());
+ const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables());
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl->CutSpline(qApp->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3);
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp
index 7835dbc6d..58e12eea6 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp
+++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp
@@ -339,7 +339,7 @@ QString VToolCutSplinePath::MakeToolTip() const
const auto splPath = VAbstractTool::data.GeometricObject(curveCutId);
const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
- const qreal length = Visualization::FindVal(expression, VAbstractTool::data.DataVariables());
+ const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables());
VSplinePath *splPath1 = nullptr;
VSplinePath *splPath2 = nullptr;
diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp
index 2a8c537ac..96ba1f547 100644
--- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp
+++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp
@@ -103,8 +103,9 @@ void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
-void VDrawTool::SaveDialogChange()
+void VDrawTool::SaveDialogChange(const QString &undoText)
{
+ Q_UNUSED(undoText)
qCDebug(vTool, "Saving tool options after using dialog");
QDomElement oldDomElement = doc->elementById(m_id, getTagName());
if (oldDomElement.isElement())
diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h
index 370b86c5e..6f21f6f46 100644
--- a/src/libs/vtools/tools/drawTools/vdrawtool.h
+++ b/src/libs/vtools/tools/drawTools/vdrawtool.h
@@ -100,7 +100,7 @@ protected:
/** @brief SaveDialog save options into file after change in dialog. */
virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies,
QList &newDependencies)=0;
- virtual void SaveDialogChange() Q_DECL_FINAL;
+ virtual void SaveDialogChange(const QString &undoText = QString()) Q_DECL_FINAL;
virtual void AddToFile() Q_DECL_OVERRIDE;
void SaveOption(QSharedPointer &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj);
diff --git a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp
index fe175bb20..0e99b2235 100644
--- a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp
+++ b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp
@@ -102,7 +102,7 @@ VToolPlaceLabel *VToolPlaceLabel::Create(VToolPlaceLabelInitData &initData)
node->setMx(point->mx());
node->setMy(point->my());
- if (initData.typeCreation == Source::FromTool)
+ if (initData.idTool != NULL_ID)
{
QSharedPointer label = qSharedPointerDynamicCast(point);
SCASSERT(label.isNull() == false)
diff --git a/src/libs/vtools/tools/vinteractivetool.h b/src/libs/vtools/tools/vinteractivetool.h
index 820f1d98a..d5d9a4da0 100644
--- a/src/libs/vtools/tools/vinteractivetool.h
+++ b/src/libs/vtools/tools/vinteractivetool.h
@@ -46,8 +46,8 @@ public:
static bool m_suppressContextMenu;
public slots:
- void FullUpdateFromGuiOk(int result);
- void FullUpdateFromGuiApply();
+ virtual void FullUpdateFromGuiOk(int result);
+ virtual void FullUpdateFromGuiApply();
protected:
/** @brief m_dialog tool's dialog options.*/
@@ -55,7 +55,7 @@ protected:
/** @brief setDialog set dialog when user want change tool option. */
virtual void setDialog() {/*do nothing by default*/}
- virtual void SaveDialogChange()=0;
+ virtual void SaveDialogChange(const QString &undoText = QString())=0;
private:
Q_DISABLE_COPY(VInteractiveTool)
diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp
index d0937bcaa..d261adf37 100644
--- a/src/libs/vtools/tools/vtoolseamallowance.cpp
+++ b/src/libs/vtools/tools/vtoolseamallowance.cpp
@@ -71,7 +71,6 @@ const QString VToolSeamAllowance::TagIPaths = QStringLiteral("iPaths");
const QString VToolSeamAllowance::TagPins = QStringLiteral("pins");
const QString VToolSeamAllowance::TagPlaceLabels = QStringLiteral("placeLabels");
-const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version");
const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping");
const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance");
const QString VToolSeamAllowance::AttrHideMainPath = QStringLiteral("hideMainPath");
@@ -900,6 +899,12 @@ QPainterPath VToolSeamAllowance::shape() const
}
}
+//---------------------------------------------------------------------------------------------------------------------
+void VToolSeamAllowance::FullUpdateFromGuiApply()
+{
+ SaveDialogChange(tr("apply save detail options"));
+}
+
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::AddToFile()
{
@@ -935,7 +940,7 @@ void VToolSeamAllowance::RefreshDataInFile()
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 0),
"Time to refactor the code.");
- const uint version = doc->GetParametrUInt(domElement, VToolSeamAllowance::AttrVersion, "1");
+ const uint version = doc->GetParametrUInt(domElement, AttrVersion, "1");
if (version == 1)
{
const VPiece piece = VAbstractTool::data.GetPiece(m_id);
@@ -1221,10 +1226,6 @@ VToolSeamAllowance::VToolSeamAllowance(const VToolSeamAllowanceInitData &initDat
connect(this, &VToolSeamAllowance::ChoosedTool, m_sceneDetails, &VMainGraphicsScene::ChoosedItem);
ConnectOutsideSignals();
-
- UpdateDetailLabel();
- UpdatePatternInfo();
- UpdateGrainline();
}
//---------------------------------------------------------------------------------------------------------------------
@@ -1302,7 +1303,7 @@ void VToolSeamAllowance::RefreshGeometry()
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolSeamAllowance::SaveDialogChange()
+void VToolSeamAllowance::SaveDialogChange(const QString &undoText)
{
SCASSERT(not m_dialog.isNull());
DialogSeamAllowance *dialogTool = qobject_cast(m_dialog.data());
@@ -1310,8 +1311,28 @@ void VToolSeamAllowance::SaveDialogChange()
const VPiece newDet = dialogTool->GetPiece();
const VPiece oldDet = VAbstractTool::data.GetPiece(m_id);
- qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id));
- UpdateDetailLabel();
+ QVector &undocommands = dialogTool->UndoStack();
+ const bool groupChange = not undocommands.isEmpty();
+
+ SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, m_id);
+
+ if (groupChange)
+ {
+ qApp->getUndoStack()->beginMacro(undoText.isEmpty() ? saveCommand->text(): undoText);
+
+ foreach (QUndoCommand* command, undocommands)
+ {
+ qApp->getUndoStack()->push(command);
+ }
+ undocommands.clear();
+ }
+
+ qApp->getUndoStack()->push(saveCommand);
+
+ if (groupChange)
+ {
+ qApp->getUndoStack()->endMacro();
+ }
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h
index d77f2a7cc..401c2971e 100644
--- a/src/libs/vtools/tools/vtoolseamallowance.h
+++ b/src/libs/vtools/tools/vtoolseamallowance.h
@@ -73,7 +73,6 @@ public:
static const QString TagPins;
static const QString TagPlaceLabels;
- static const QString AttrVersion;
static const QString AttrForbidFlipping;
static const QString AttrSeamAllowance;
static const QString AttrHideMainPath;
@@ -106,6 +105,7 @@ public:
void DisconnectOutsideSignals();
void ConnectOutsideSignals();
void ReinitInternals(const VPiece &detail, VMainGraphicsScene *scene);
+ void RefreshGeometry();
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast(Tool::Piece)};
@@ -118,6 +118,7 @@ public:
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
virtual QPainterPath shape() const Q_DECL_OVERRIDE;
public slots:
+ virtual void FullUpdateFromGuiApply() Q_DECL_OVERRIDE;
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
void EnableToolMove(bool move);
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
@@ -153,7 +154,7 @@ protected:
virtual void DeleteToolWithConfirm(bool ask = true) Q_DECL_OVERRIDE;
virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE;
virtual void SetDialog() Q_DECL_FINAL;
- virtual void SaveDialogChange() Q_DECL_FINAL;
+ virtual void SaveDialogChange(const QString &undoText = QString()) Q_DECL_FINAL;
private:
Q_DISABLE_COPY(VToolSeamAllowance)
@@ -175,7 +176,6 @@ private:
VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr);
void UpdateExcludeState();
- void RefreshGeometry();
VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth,
qreal &labelHeight, QPointF &pos);
diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp
index 5885ba7af..8eb89fb0d 100644
--- a/src/libs/vtools/tools/vtooluniondetails.cpp
+++ b/src/libs/vtools/tools/vtooluniondetails.cpp
@@ -86,6 +86,9 @@ const QString VToolUnionDetails::AttrNodeType = QStringLiteral("nodeType");
const QString VToolUnionDetails::NodeTypeContour = QStringLiteral("Contour");
const QString VToolUnionDetails::NodeTypeModeling = QStringLiteral("Modeling");
+// Current version of union tag need for backward compatibility
+const quint8 VToolUnionDetails::unionVersion = UNION_VERSSION;
+
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
@@ -232,6 +235,37 @@ QVector GetPiece2Pins(VAbstractPattern *doc, quint32 id)
return QVector();
}
+//---------------------------------------------------------------------------------------------------------------------
+QVector GetPiece2PlaceLabels(VAbstractPattern *doc, quint32 id)
+{
+ const QDomElement tool = doc->elementById(id, VAbstractPattern::TagTools);
+ if (tool.isNull())
+ {
+ VException e(QString("Can't get tool by id='%1'.").arg(id));
+ throw e;
+ }
+
+ const QDomNodeList nodesList = tool.childNodes();
+ for (qint32 i = 0; i < nodesList.size(); ++i)
+ {
+ const QDomElement element = nodesList.at(i).toElement();
+ if (not element.isNull() && element.tagName() == VToolUnionDetails::TagDetail && i+1 == 2)
+ {
+ const QDomNodeList detList = element.childNodes();
+ for (qint32 j = 0; j < detList.size(); ++j)
+ {
+ const QDomElement element = detList.at(j).toElement();
+ if (not element.isNull() && element.tagName() == VToolSeamAllowance::TagPlaceLabels)
+ {
+ return VAbstractPattern::ParsePiecePointRecords(element);
+ }
+ }
+ }
+ }
+
+ return QVector();
+}
+
//---------------------------------------------------------------------------------------------------------------------
QString DrawName(VAbstractPattern *doc, quint32 d1id, quint32 d2id)
{
@@ -390,6 +424,7 @@ quint32 AddNodePoint(const VPieceNode &node, const VToolUnionDetailsInitData &in
initNodeData.typeCreation = Source::FromTool;
initNodeData.idTool = initData.id;
initNodeData.drawName = drawName;
+ initNodeData.scene = initData.scene;
VNodePoint::Create(initNodeData);
return id;
@@ -443,15 +478,8 @@ quint32 AddPlaceLabel(quint32 id, const VToolUnionDetailsInitData &initData, QVe
}
label->SetCorrectionAngle(label->GetCorrectionAngle() + angle);
- QScopedPointer label1(new VPlaceLabelItem(*label));
-
- const quint32 idObject = initData.data->AddGObject(label.take());
- children.append(idObject);
- const quint32 idLabel = initData.data->AddGObject(label1.take());
VToolPlaceLabelInitData initNodeData;
- initNodeData.id = idLabel;
- initNodeData.centerPoint = idObject;
initNodeData.idObject = NULL_ID;
initNodeData.doc = initData.doc;
initNodeData.data = initData.data;
@@ -459,6 +487,18 @@ quint32 AddPlaceLabel(quint32 id, const VToolUnionDetailsInitData &initData, QVe
initNodeData.typeCreation = Source::FromTool;
initNodeData.idTool = initData.id;
initNodeData.drawName = drawName;
+ initNodeData.width = label->GetWidthFormula();
+ initNodeData.height = label->GetHeightFormula();
+ initNodeData.angle = label->GetAngleFormula();
+ initNodeData.type = label->GetLabelType();
+
+ QScopedPointer label1(new VPlaceLabelItem(*label));
+
+ initNodeData.centerPoint = initData.data->AddGObject(label.take());
+ children.append(initNodeData.centerPoint);
+
+ const quint32 idLabel = initData.data->AddGObject(label1.take());
+ initNodeData.id = idLabel;
VToolPlaceLabel::Create(initNodeData);
return idLabel;
@@ -1148,7 +1188,14 @@ void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector
VToolPiecePath::Create(initNodeData);
record.path = idPath;
newDetail.GetCustomSARecords().append(record);
- nodeChildren.prepend(idPath);
+
+ if (initData.version == 1)
+ {
+ // TODO. Delete if minimal supported version is 0.7.0
+ Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 0),
+ "Time to refactor the code.");
+ nodeChildren.prepend(idPath);
+ }
}
children += nodeChildren;
}
@@ -1199,7 +1246,14 @@ void CreateUnitedDetailInternalPaths(VPiece &newDetail, const VPiece &d, QVector
VToolPiecePath::Create(initNodeData);
newDetail.GetInternalPaths().append(idPath);
- nodeChildren.prepend(idPath);
+
+ if (initData.version == 1)
+ {
+ // TODO. Delete if minimal supported version is 0.7.0
+ Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 0),
+ "Time to refactor the code.");
+ nodeChildren.prepend(idPath);
+ }
}
children += nodeChildren;
}
@@ -1230,7 +1284,6 @@ void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector
{
const quint32 id = AddPin(d.GetPins().at(i), initData, children, drawName, dx, dy, pRotate, angle);
newDetail.GetPins().append(id);
- nodeChildren.prepend(id);
}
children += nodeChildren;
}
@@ -1246,7 +1299,6 @@ void CreateUnitedDetailPlaceLabels(VPiece &newDetail, const VPiece &d, QVectorGetPiecePath(records.at(i));
- const quint32 updatedId = TakeNextId(children);
- VPiecePath updatedPath(path);
- updatedPath.Clear();
-
- for (int j=0; j < path.CountNodes(); ++j)
+ if (initData.version == 1)
{
- const VPieceNode &node = path.at(j);
- const quint32 id = TakeNextId(children);
- updatedPath.Append(VPieceNode(id, node.GetTypeTool(), node.GetReverse()));
- QVector nodeChildren = {id};
- UpdatePathNode(initData.data, path.at(j), nodeChildren, dx, dy, pRotate, angle);
+ // TODO. Delete if minimal supported version is 0.7.0
+ Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 0),
+ "Time to refactor the code.");
+ const quint32 updatedId = TakeNextId(children);
+
+ VPiecePath updatedPath(path);
+ updatedPath.Clear();
+
+ for (int j=0; j < path.CountNodes(); ++j)
+ {
+ const VPieceNode &node = path.at(j);
+ const quint32 id = TakeNextId(children);
+ updatedPath.Append(VPieceNode(id, node.GetTypeTool(), node.GetReverse()));
+ QVector nodeChildren = {id};
+ UpdatePathNode(initData.data, path.at(j), nodeChildren, dx, dy, pRotate, angle);
+ }
+ initData.data->UpdatePiecePath(updatedId, updatedPath);
+ }
+ else
+ {
+
+ for (int j=0; j < path.CountNodes(); ++j)
+ {
+ const quint32 id = TakeNextId(children);
+ QVector nodeChildren = {id};
+ UpdatePathNode(initData.data, path.at(j), nodeChildren, dx, dy, pRotate, angle);
+ }
}
- initData.data->UpdatePiecePath(updatedId, updatedPath);
}
}
@@ -1415,14 +1484,20 @@ void UpdateUnitedDetailPlaceLabels(const VToolUnionDetailsInitData &initData, qr
for (int i = 0; i < records.size(); ++i)
{
- QScopedPointer
- label(new VPlaceLabelItem(*initData.data->GeometricObject(records.at(i))));
+ QSharedPointer parentLabel = initData.data->GeometricObject(records.at(i));
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{
- BiasRotatePoint(label.data(), dx, dy,
+ BiasRotatePoint(parentLabel.data(), dx, dy,
static_cast(*initData.data->GeometricObject(pRotate)), angle);
}
- label->SetCorrectionAngle(label->GetCorrectionAngle()+angle);
+ QScopedPointer label(new VPlaceLabelItem());
+ label->setName(parentLabel->name());
+ label->setX(parentLabel->x());
+ label->setY(parentLabel->y());
+ label->setMx(parentLabel->mx());
+ label->setMy(parentLabel->my());
+
+ label->SetCorrectionAngle(parentLabel->GetCorrectionAngle()+angle);
initData.data->UpdateGObject(TakeNextId(children), label.take());
}
}
@@ -1486,7 +1561,7 @@ void UpdateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qre
UpdateUnitedDetailInternalPaths(initData, dx, dy, pRotate, angle,
GetPiece2InternalPaths(initData.doc, initData.id));
UpdateUnitedDetailPins(initData, dx, dy, pRotate, angle, GetPiece2Pins(initData.doc, initData.id));
- UpdateUnitedDetailPlaceLabels(initData, dx, dy, pRotate, angle, GetPiece2Pins(initData.doc, initData.id));
+ UpdateUnitedDetailPlaceLabels(initData, dx, dy, pRotate, angle, GetPiece2PlaceLabels(initData.doc, initData.id));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -1525,7 +1600,8 @@ VToolUnionDetails::VToolUnionDetails(const VToolUnionDetailsInitData &initData,
d1id(initData.d1id),
d2id(initData.d2id),
indexD1(initData.indexD1),
- indexD2(initData.indexD2)
+ indexD2(initData.indexD2),
+ version(initData.version)
{
_referens = 0;
ToolCreation(initData.typeCreation);
@@ -1668,6 +1744,7 @@ void VToolUnionDetails::AddToFile()
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrIndexD1, indexD1);
doc->SetAttribute(domElement, AttrIndexD2, indexD2);
+ doc->SetAttribute(domElement, AttrVersion, unionVersion);
AddDetail(domElement, data.GetPiece(d1id));
AddDetail(domElement, data.GetPiece(d2id));
@@ -1691,6 +1768,7 @@ void VToolUnionDetails::AddDetail(QDomElement &domElement, const VPiece &d) cons
VToolSeamAllowance::AddCSARecords(doc, det, d.GetCustomSARecords());
VToolSeamAllowance::AddInternalPaths(doc, det, d.GetInternalPaths());
VToolSeamAllowance::AddPins(doc, det, d.GetPins());
+ VToolSeamAllowance::AddPlaceLabels(doc, det, d.GetPlaceLabels());
domElement.appendChild(det);
}
@@ -1726,10 +1804,11 @@ QVector VToolUnionDetails::GetReferenceObjects() const
return list;
}
- const QStringList parts = QStringList() << VAbstractPattern::TagNodes /*0*/
- << VToolSeamAllowance::TagCSA /*1*/
- << VToolSeamAllowance::TagIPaths /*2*/
- << VToolSeamAllowance::TagPins; /*3*/
+ const QStringList parts = QStringList() << VAbstractPattern::TagNodes /*0*/
+ << VToolSeamAllowance::TagCSA /*1*/
+ << VToolSeamAllowance::TagIPaths /*2*/
+ << VToolSeamAllowance::TagPins /*3*/
+ << VToolSeamAllowance::TagPlaceLabels; /*4*/
const QDomNodeList nodesList = tool.childNodes();
for (qint32 i = 0; i < nodesList.size(); ++i)
@@ -1754,6 +1833,7 @@ QVector VToolUnionDetails::GetReferenceObjects() const
VAbstractPattern::AttrPath);
break;
case 3://VToolSeamAllowance::TagPins
+ case 4://VToolSeamAllowance::TagPlaceLabels
{
const QDomNodeList children = element.childNodes();
for (qint32 i = 0; i < children.size(); ++i)
diff --git a/src/libs/vtools/tools/vtooluniondetails.h b/src/libs/vtools/tools/vtooluniondetails.h
index 964415e15..63c1e9bf3 100644
--- a/src/libs/vtools/tools/vtooluniondetails.h
+++ b/src/libs/vtools/tools/vtooluniondetails.h
@@ -47,6 +47,8 @@
class DialogTool;
+#define UNION_VERSSION 2
+
struct VToolUnionDetailsInitData : VAbstractToolInitData
{
VToolUnionDetailsInitData()
@@ -55,7 +57,8 @@ struct VToolUnionDetailsInitData : VAbstractToolInitData
d2id(NULL_ID),
indexD1(NULL_ID),
indexD2(NULL_ID),
- retainPieces(false)
+ retainPieces(false),
+ version(UNION_VERSSION)
{}
quint32 d1id;
@@ -63,6 +66,7 @@ struct VToolUnionDetailsInitData : VAbstractToolInitData
quint32 indexD1;
quint32 indexD2;
bool retainPieces;
+ uint version;
};
/**
@@ -88,6 +92,8 @@ public:
static const QString NodeTypeContour;
static const QString NodeTypeModeling;
+ static const quint8 unionVersion;
+
virtual QString getTagName() const Q_DECL_OVERRIDE;
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
virtual void incrementReferens() Q_DECL_OVERRIDE;
@@ -120,6 +126,8 @@ private:
/** @brief indexD2 index edge in second detail. */
quint32 indexD2;
+ uint version;
+
VToolUnionDetails(const VToolUnionDetailsInitData &initData, QObject *parent = nullptr);
void AddDetail(QDomElement &domElement, const VPiece &d) const;
diff --git a/src/libs/vtools/undocommands/savepieceoptions.cpp b/src/libs/vtools/undocommands/savepieceoptions.cpp
index 112b3f813..b525a86ee 100644
--- a/src/libs/vtools/undocommands/savepieceoptions.cpp
+++ b/src/libs/vtools/undocommands/savepieceoptions.cpp
@@ -51,7 +51,7 @@ SavePieceOptions::SavePieceOptions(const VPiece &oldDet, const VPiece &newDet, V
m_oldDet(oldDet),
m_newDet(newDet)
{
- setText(tr("save detail option"));
+ setText(tr("save detail options"));
nodeId = id;
}
@@ -144,3 +144,38 @@ void SavePieceOptions::redo()
qCDebug(vUndo, "Can't find detail with id = %u.", nodeId);
}
}
+
+//---------------------------------------------------------------------------------------------------------------------
+bool SavePieceOptions::mergeWith(const QUndoCommand *command)
+{
+ const SavePieceOptions *saveCommand = static_cast(command);
+ SCASSERT(saveCommand != nullptr);
+
+ if (saveCommand->DetId() != nodeId)
+ {
+ return false;
+ }
+ else
+ {
+ const QSet currentSet;
+ currentSet.fromList(m_newDet.Dependencies());
+
+ const VPiece candidate = saveCommand->NewDet();
+ const QSet candidateSet;
+ candidateSet.fromList(candidate.Dependencies());
+
+ if (currentSet != candidateSet)
+ {
+ return false;
+ }
+ }
+
+ m_newDet = saveCommand->NewDet();
+ return true;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+int SavePieceOptions::id() const
+{
+ return static_cast(UndoCommand::SavePieceOptions);
+}
diff --git a/src/libs/vtools/undocommands/savepieceoptions.h b/src/libs/vtools/undocommands/savepieceoptions.h
index 2654eb7e3..3bf80ed7c 100644
--- a/src/libs/vtools/undocommands/savepieceoptions.h
+++ b/src/libs/vtools/undocommands/savepieceoptions.h
@@ -43,6 +43,10 @@ public:
virtual void undo() Q_DECL_OVERRIDE;
virtual void redo() Q_DECL_OVERRIDE;
+ virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
+ virtual int id() const Q_DECL_OVERRIDE;
+ quint32 DetId() const;
+ VPiece NewDet() const;
private:
Q_DISABLE_COPY(SavePieceOptions)
@@ -50,4 +54,16 @@ private:
VPiece m_newDet;
};
+//---------------------------------------------------------------------------------------------------------------------
+inline quint32 SavePieceOptions::DetId() const
+{
+ return nodeId;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+inline VPiece SavePieceOptions::NewDet() const
+{
+ return m_newDet;
+}
+
#endif // SAVEPIECEOPTIONS_H
diff --git a/src/libs/vtools/undocommands/savepiecepathoptions.cpp b/src/libs/vtools/undocommands/savepiecepathoptions.cpp
index a7968c9b9..2cd26a408 100644
--- a/src/libs/vtools/undocommands/savepiecepathoptions.cpp
+++ b/src/libs/vtools/undocommands/savepiecepathoptions.cpp
@@ -35,15 +35,17 @@
#include "../ifc/xml/vabstractpattern.h"
#include "../vmisc/logging.h"
#include "../tools/nodeDetails/vtoolpiecepath.h"
+#include "../tools/vtoolseamallowance.h"
//---------------------------------------------------------------------------------------------------------------------
-SavePiecePathOptions::SavePiecePathOptions(const VPiecePath &oldPath, const VPiecePath &newPath,
+SavePiecePathOptions::SavePiecePathOptions(quint32 pieceId, const VPiecePath &oldPath, const VPiecePath &newPath,
VAbstractPattern *doc, VContainer *data, quint32 id,
QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent),
m_oldPath(oldPath),
m_newPath(newPath),
- m_data(data)
+ m_data(data),
+ m_pieceId(pieceId)
{
setText(tr("save path options"));
nodeId = id;
@@ -66,6 +68,14 @@ void SavePiecePathOptions::undo()
SCASSERT(m_data);
m_data->UpdatePiecePath(nodeId, m_oldPath);
+
+ if (m_pieceId != NULL_ID)
+ {
+ if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(m_pieceId)))
+ {
+ tool->RefreshGeometry();
+ }
+ }
}
else
{
@@ -90,9 +100,46 @@ void SavePiecePathOptions::redo()
SCASSERT(m_data);
m_data->UpdatePiecePath(nodeId, m_newPath);
+
+ if (m_pieceId != NULL_ID)
+ {
+ if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(m_pieceId)))
+ {
+ tool->RefreshGeometry();
+ }
+ }
}
else
{
qCDebug(vUndo, "Can't find path with id = %u.", nodeId);
}
}
+
+//---------------------------------------------------------------------------------------------------------------------
+bool SavePiecePathOptions::mergeWith(const QUndoCommand *command)
+{
+ const SavePiecePathOptions *saveCommand = static_cast(command);
+ SCASSERT(saveCommand != nullptr);
+
+ if (saveCommand->PathId() != nodeId)
+ {
+ return false;
+ }
+ else
+ {
+ const QSet currentSet;
+ currentSet.fromList(m_newPath.Dependencies());
+
+ const VPiecePath candidate = saveCommand->NewPath();
+ const QSet candidateSet;
+ candidateSet.fromList(candidate.Dependencies());
+
+ if (currentSet != candidateSet)
+ {
+ return false;
+ }
+ }
+
+ m_newPath = saveCommand->NewPath();
+ return true;
+}
diff --git a/src/libs/vtools/undocommands/savepiecepathoptions.h b/src/libs/vtools/undocommands/savepiecepathoptions.h
index a458e35ea..160fc05e6 100644
--- a/src/libs/vtools/undocommands/savepiecepathoptions.h
+++ b/src/libs/vtools/undocommands/savepiecepathoptions.h
@@ -37,12 +37,16 @@
class SavePiecePathOptions : public VUndoCommand
{
public:
- SavePiecePathOptions(const VPiecePath &oldPath, const VPiecePath &newPath, VAbstractPattern *doc,
+ SavePiecePathOptions(quint32 pieceId, const VPiecePath &oldPath, const VPiecePath &newPath, VAbstractPattern *doc,
VContainer *data, quint32 id, QUndoCommand *parent = nullptr);
virtual ~SavePiecePathOptions() = default;
virtual void undo() Q_DECL_OVERRIDE;
virtual void redo() Q_DECL_OVERRIDE;
+ virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
+ virtual int id() const Q_DECL_OVERRIDE;
+ quint32 PathId() const;
+ VPiecePath NewPath() const;
private:
Q_DISABLE_COPY(SavePiecePathOptions)
@@ -50,6 +54,25 @@ private:
VPiecePath m_newPath;
VContainer *m_data;
+ quint32 m_pieceId;
};
+//---------------------------------------------------------------------------------------------------------------------
+inline int SavePiecePathOptions::id() const
+{
+ return static_cast(UndoCommand::SavePiecePathOptions);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+inline quint32 SavePiecePathOptions::PathId() const
+{
+ return nodeId;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+inline VPiecePath SavePiecePathOptions::NewPath() const
+{
+ return m_newPath;
+}
+
#endif // SAVEPIECEPATHOPTIONS_H
diff --git a/src/libs/vtools/undocommands/saveplacelabeloptions.cpp b/src/libs/vtools/undocommands/saveplacelabeloptions.cpp
index 4d95d8737..e2fab6a6e 100644
--- a/src/libs/vtools/undocommands/saveplacelabeloptions.cpp
+++ b/src/libs/vtools/undocommands/saveplacelabeloptions.cpp
@@ -27,14 +27,17 @@
*************************************************************************/
#include "saveplacelabeloptions.h"
#include "../tools/nodeDetails/vtoolplacelabel.h"
+#include "../tools/vtoolseamallowance.h"
//---------------------------------------------------------------------------------------------------------------------
-SavePlaceLabelOptions::SavePlaceLabelOptions(const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel,
- VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent)
+SavePlaceLabelOptions::SavePlaceLabelOptions(quint32 pieceId, const VPlaceLabelItem &oldLabel,
+ const VPlaceLabelItem &newLabel, VAbstractPattern *doc, VContainer *data,
+ quint32 id, QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent),
m_oldLabel(oldLabel),
m_newLabel(newLabel),
- m_data(data)
+ m_data(data),
+ m_pieceId(pieceId)
{
setText(tr("save place label options"));
nodeId = id;
@@ -58,6 +61,14 @@ void SavePlaceLabelOptions::undo()
SCASSERT(m_data);
m_data->UpdateGObject(nodeId, new VPlaceLabelItem(m_oldLabel));
+
+ if (m_pieceId != NULL_ID)
+ {
+ if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(m_pieceId)))
+ {
+ tool->RefreshGeometry();
+ }
+ }
}
else
{
@@ -83,9 +94,41 @@ void SavePlaceLabelOptions::redo()
SCASSERT(m_data);
m_data->UpdateGObject(nodeId, new VPlaceLabelItem(m_newLabel));
+
+ if (m_pieceId != NULL_ID)
+ {
+ if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(m_pieceId)))
+ {
+ tool->RefreshGeometry();
+ }
+ }
}
else
{
qCDebug(vUndo, "Can't find path with id = %u.", nodeId);
}
}
+
+//---------------------------------------------------------------------------------------------------------------------
+bool SavePlaceLabelOptions::mergeWith(const QUndoCommand *command)
+{
+ const SavePlaceLabelOptions *saveCommand = static_cast(command);
+ SCASSERT(saveCommand != nullptr);
+
+ if (saveCommand->LabelId() != nodeId)
+ {
+ return false;
+ }
+ else
+ {
+ const VPlaceLabelItem candidate = saveCommand->NewLabel();
+
+ if (m_newLabel.GetCenterPoint() != candidate.GetCenterPoint())
+ {
+ return false;
+ }
+ }
+
+ m_newLabel = saveCommand->NewLabel();
+ return true;
+}
diff --git a/src/libs/vtools/undocommands/saveplacelabeloptions.h b/src/libs/vtools/undocommands/saveplacelabeloptions.h
index a692816f9..828f23360 100644
--- a/src/libs/vtools/undocommands/saveplacelabeloptions.h
+++ b/src/libs/vtools/undocommands/saveplacelabeloptions.h
@@ -34,12 +34,17 @@
class SavePlaceLabelOptions : public VUndoCommand
{
public:
- SavePlaceLabelOptions(const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel, VAbstractPattern *doc,
- VContainer *data, quint32 id, QUndoCommand *parent = nullptr);
+ SavePlaceLabelOptions(quint32 pieceId, const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel,
+ VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent = nullptr);
virtual ~SavePlaceLabelOptions()=default;
virtual void undo() Q_DECL_OVERRIDE;
virtual void redo() Q_DECL_OVERRIDE;
+ virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
+ virtual int id() const Q_DECL_OVERRIDE;
+
+ quint32 LabelId() const;
+ VPlaceLabelItem NewLabel() const;
private:
Q_DISABLE_COPY(SavePlaceLabelOptions)
@@ -47,6 +52,25 @@ private:
VPlaceLabelItem m_newLabel;
VContainer *m_data;
+ quint32 m_pieceId;
};
+//---------------------------------------------------------------------------------------------------------------------
+inline int SavePlaceLabelOptions::id() const
+{
+ return static_cast(UndoCommand::SavePlaceLabelOptions);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+inline quint32 SavePlaceLabelOptions::LabelId() const
+{
+ return nodeId;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+inline VPlaceLabelItem SavePlaceLabelOptions::NewLabel() const
+{
+ return m_newLabel;
+}
+
#endif // SAVEPLACELABELOPTIONS_H
diff --git a/src/libs/vtools/undocommands/savetooloptions.cpp b/src/libs/vtools/undocommands/savetooloptions.cpp
index a4629208b..36a9b7bb1 100644
--- a/src/libs/vtools/undocommands/savetooloptions.cpp
+++ b/src/libs/vtools/undocommands/savetooloptions.cpp
@@ -98,3 +98,31 @@ QVector SaveToolOptions::Missing(const QList &list1, const QLi
QSet set2 = QSet::fromList(list2);
return set1.subtract(set2).toList().toVector();
}
+
+//---------------------------------------------------------------------------------------------------------------------
+bool SaveToolOptions::mergeWith(const QUndoCommand *command)
+{
+ const SaveToolOptions *saveCommand = static_cast(command);
+ SCASSERT(saveCommand != nullptr)
+
+ if (saveCommand->getToolId() != nodeId)
+ {
+ return false;
+ }
+ else
+ {
+ const QSet currentSet;
+ currentSet.fromList(newDependencies);
+
+ const QSet candidateSet;
+ candidateSet.fromList(saveCommand->NewDependencies());
+
+ if (currentSet != candidateSet)
+ {
+ return false;
+ }
+ }
+
+ newXml = saveCommand->getNewXml();
+ return true;
+}
diff --git a/src/libs/vtools/undocommands/savetooloptions.h b/src/libs/vtools/undocommands/savetooloptions.h
index 8235fc5c1..f97728d94 100644
--- a/src/libs/vtools/undocommands/savetooloptions.h
+++ b/src/libs/vtools/undocommands/savetooloptions.h
@@ -48,14 +48,44 @@ public:
virtual ~SaveToolOptions() = default;
virtual void undo() Q_DECL_OVERRIDE;
virtual void redo() Q_DECL_OVERRIDE;
+ virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
+ virtual int id() const Q_DECL_OVERRIDE;
+
+ QDomElement getNewXml() const;
+ quint32 getToolId() const;
+ QList NewDependencies() const;
private:
Q_DISABLE_COPY(SaveToolOptions)
const QDomElement oldXml;
- const QDomElement newXml;
+ QDomElement newXml;
const QList oldDependencies;
const QList newDependencies;
QVector Missing(const QList &list1, const QList &list2) const;
};
+//---------------------------------------------------------------------------------------------------------------------
+inline int SaveToolOptions::id() const
+{
+ return static_cast(UndoCommand::SaveToolOptions);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+inline QDomElement SaveToolOptions::getNewXml() const
+{
+ return newXml;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+inline quint32 SaveToolOptions::getToolId() const
+{
+ return nodeId;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+inline QList SaveToolOptions::NewDependencies() const
+{
+ return newDependencies;
+}
+
#endif // SAVETOOLOPTIONS_H
diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp
index e6fcc7cfd..63e485468 100644
--- a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp
+++ b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp
@@ -137,7 +137,7 @@ QString VisToolMove::Angle() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolMove::SetAngle(const QString &expression)
{
- angle = FindVal(expression, Visualization::data->DataVariables());
+ angle = FindValFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
@@ -155,7 +155,7 @@ qreal VisToolMove::LengthValue() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolMove::SetLength(const QString &expression)
{
- length = FindLength(expression, Visualization::data->DataVariables());
+ length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp
index 152ab2958..11f9fa258 100644
--- a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp
+++ b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp
@@ -207,7 +207,7 @@ QString VisToolRotation::Angle() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolRotation::SetAngle(const QString &expression)
{
- angle = FindVal(expression, Visualization::data->DataVariables());
+ angle = FindValFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/visualization/line/vistoolalongline.cpp b/src/libs/vtools/visualization/line/vistoolalongline.cpp
index 32eb95c23..c3642261f 100644
--- a/src/libs/vtools/visualization/line/vistoolalongline.cpp
+++ b/src/libs/vtools/visualization/line/vistoolalongline.cpp
@@ -66,7 +66,7 @@ void VisToolAlongLine::setObject2Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::setLength(const QString &expression)
{
- length = FindLength(expression, Visualization::data->DataVariables());
+ length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/visualization/line/vistoolbisector.cpp b/src/libs/vtools/visualization/line/vistoolbisector.cpp
index 2a669ea1a..35ac9cd5e 100644
--- a/src/libs/vtools/visualization/line/vistoolbisector.cpp
+++ b/src/libs/vtools/visualization/line/vistoolbisector.cpp
@@ -72,7 +72,7 @@ void VisToolBisector::setObject3Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolBisector::setLength(const QString &expression)
{
- length = FindLength(expression, Visualization::data->DataVariables());
+ length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp b/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp
index 831ab1c6a..749f0b9f8 100644
--- a/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp
+++ b/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp
@@ -105,7 +105,7 @@ QString VisToolCurveIntersectAxis::Angle() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolCurveIntersectAxis::SetAngle(const QString &expression)
{
- angle = FindVal(expression, Visualization::data->DataVariables());
+ angle = FindValFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/visualization/line/vistoolendline.cpp b/src/libs/vtools/visualization/line/vistoolendline.cpp
index a5ec13572..4e5924b67 100644
--- a/src/libs/vtools/visualization/line/vistoolendline.cpp
+++ b/src/libs/vtools/visualization/line/vistoolendline.cpp
@@ -96,7 +96,7 @@ QString VisToolEndLine::Angle() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolEndLine::SetAngle(const QString &expression)
{
- angle = FindVal(expression, Visualization::data->DataVariables());
+ angle = FindValFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
@@ -108,5 +108,5 @@ QString VisToolEndLine::Length() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolEndLine::setLength(const QString &expression)
{
- length = FindLength(expression, Visualization::data->DataVariables());
+ length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
diff --git a/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp b/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp
index 29cc1e898..f21da50b5 100644
--- a/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp
+++ b/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp
@@ -118,7 +118,7 @@ QString VisToolLineIntersectAxis::Angle() const
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::SetAngle(const QString &expression)
{
- angle = FindVal(expression, Visualization::data->DataVariables());
+ angle = FindValFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/visualization/line/vistoolnormal.cpp b/src/libs/vtools/visualization/line/vistoolnormal.cpp
index bb16350cc..1e718e282 100644
--- a/src/libs/vtools/visualization/line/vistoolnormal.cpp
+++ b/src/libs/vtools/visualization/line/vistoolnormal.cpp
@@ -110,7 +110,7 @@ void VisToolNormal::setObject2Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolNormal::setLength(const QString &expression)
{
- length = FindLength(expression, Visualization::data->DataVariables());
+ length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp b/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp
index 19bf5f927..843cedccb 100644
--- a/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp
+++ b/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp
@@ -92,7 +92,7 @@ void VisToolPointFromCircleAndTangent::setObject2Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromCircleAndTangent::setCRadius(const QString &value)
{
- cRadius = FindLength(value, Visualization::data->DataVariables());
+ cRadius = FindLengthFromUser(value, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp b/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp
index 2c7dc1ebe..843024a00 100644
--- a/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp
+++ b/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp
@@ -108,5 +108,5 @@ void VisToolPointOfContact::setRadiusId(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfContact::setRadius(const QString &expression)
{
- radius = FindLength(expression, Visualization::data->DataVariables());
+ radius = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp
index 7462bad81..09a80a67b 100644
--- a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp
+++ b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp
@@ -111,13 +111,13 @@ void VisToolPointOfIntersectionCircles::setObject2Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionCircles::setC1Radius(const QString &value)
{
- c1Radius = FindLength(value, Visualization::data->DataVariables());
+ c1Radius = FindLengthFromUser(value, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionCircles::setC2Radius(const QString &value)
{
- c2Radius = FindLength(value, Visualization::data->DataVariables());
+ c2Radius = FindLengthFromUser(value, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp b/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp
index 5f2a4199a..320fec06b 100644
--- a/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp
+++ b/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp
@@ -129,5 +129,5 @@ void VisToolShoulderPoint::setLineP2Id(const quint32 &value)
//---------------------------------------------------------------------------------------------------------------------
void VisToolShoulderPoint::setLength(const QString &expression)
{
- length = FindLength(expression, Visualization::data->DataVariables());
+ length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
diff --git a/src/libs/vtools/visualization/path/vistoolarc.cpp b/src/libs/vtools/visualization/path/vistoolarc.cpp
index 4976b29b8..7200d0b52 100644
--- a/src/libs/vtools/visualization/path/vistoolarc.cpp
+++ b/src/libs/vtools/visualization/path/vistoolarc.cpp
@@ -70,17 +70,17 @@ void VisToolArc::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolArc::setRadius(const QString &expression)
{
- radius = FindLength(expression, Visualization::data->DataVariables());
+ radius = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArc::setF1(const QString &expression)
{
- f1 = FindVal(expression, Visualization::data->DataVariables());
+ f1 = FindValFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArc::setF2(const QString &expression)
{
- f2 = FindVal(expression, Visualization::data->DataVariables());
+ f2 = FindValFromUser(expression, Visualization::data->DataVariables());
}
diff --git a/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp b/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp
index 35b34fb1a..5cc0f4490 100644
--- a/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp
+++ b/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp
@@ -69,17 +69,17 @@ void VisToolArcWithLength::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::setRadius(const QString &expression)
{
- radius = FindLength(expression, Visualization::data->DataVariables());
+ radius = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::setF1(const QString &expression)
{
- f1 = FindVal(expression, Visualization::data->DataVariables());
+ f1 = FindValFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::setLength(const QString &expression)
{
- length = FindLength(expression, Visualization::data->DataVariables());
+ length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
diff --git a/src/libs/vtools/visualization/path/vistoolcutarc.cpp b/src/libs/vtools/visualization/path/vistoolcutarc.cpp
index 9f2d92017..6070f97d7 100644
--- a/src/libs/vtools/visualization/path/vistoolcutarc.cpp
+++ b/src/libs/vtools/visualization/path/vistoolcutarc.cpp
@@ -82,5 +82,5 @@ void VisToolCutArc::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutArc::setLength(const QString &expression)
{
- length = FindLength(expression, Visualization::data->DataVariables());
+ length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
diff --git a/src/libs/vtools/visualization/path/vistoolcutspline.cpp b/src/libs/vtools/visualization/path/vistoolcutspline.cpp
index b22c9bb33..46c53038c 100644
--- a/src/libs/vtools/visualization/path/vistoolcutspline.cpp
+++ b/src/libs/vtools/visualization/path/vistoolcutspline.cpp
@@ -90,5 +90,5 @@ void VisToolCutSpline::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutSpline::setLength(const QString &expression)
{
- length = FindLength(expression, Visualization::data->DataVariables());
+ length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
diff --git a/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp b/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp
index 360f069ba..1f59bc17a 100644
--- a/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp
+++ b/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp
@@ -91,5 +91,5 @@ void VisToolCutSplinePath::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutSplinePath::setLength(const QString &expression)
{
- length = FindLength(expression, Visualization::data->DataVariables());
+ length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
diff --git a/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp b/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp
index b588ae68e..bc76b22ef 100644
--- a/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp
+++ b/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp
@@ -65,29 +65,29 @@ void VisToolEllipticalArc::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::setRadius1(const QString &expression)
{
- radius1 = FindLength(expression, Visualization::data->DataVariables());
+ radius1 = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::setRadius2(const QString &expression)
{
- radius2 = FindLength(expression, Visualization::data->DataVariables());
+ radius2 = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::setF1(const QString &expression)
{
- f1 = FindVal(expression, Visualization::data->DataVariables());
+ f1 = FindValFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::setF2(const QString &expression)
{
- f2 = FindVal(expression, Visualization::data->DataVariables());
+ f2 = FindValFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEllipticalArc::setRotationAngle(const QString &expression)
{
- rotationAngle = FindVal(expression, Visualization::data->DataVariables());
+ rotationAngle = FindValFromUser(expression, Visualization::data->DataVariables());
}
diff --git a/src/libs/vtools/visualization/visualization.cpp b/src/libs/vtools/visualization/visualization.cpp
index 8b8c170c7..1fcfc6ce1 100644
--- a/src/libs/vtools/visualization/visualization.cpp
+++ b/src/libs/vtools/visualization/visualization.cpp
@@ -143,15 +143,15 @@ VScaledEllipse *Visualization::InitPoint(const QColor &color, QGraphicsItem *par
}
//---------------------------------------------------------------------------------------------------------------------
-qreal Visualization::FindLength(const QString &expression,
- const QHash > *vars)
+qreal Visualization::FindLengthFromUser(const QString &expression,
+ const QHash > *vars, bool fromUser)
{
- return qApp->toPixel(FindVal(expression, vars));
+ return qApp->toPixel(FindValFromUser(expression, vars, fromUser));
}
//---------------------------------------------------------------------------------------------------------------------
-qreal Visualization::FindVal(const QString &expression,
- const QHash > *vars)
+qreal Visualization::FindValFromUser(const QString &expression,
+ const QHash > *vars, bool fromUser)
{
qreal val = 0;
if (expression.isEmpty())
@@ -165,7 +165,11 @@ qreal Visualization::FindVal(const QString &expression,
// Replace line return with spaces for calc if exist
QString formula = expression;
formula.replace("\n", " ");
- formula = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
+ if (fromUser)
+ {
+ formula = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
+ }
+
QScopedPointer cal(new Calculator());
val = cal->EvalFormula(vars, formula);
diff --git a/src/libs/vtools/visualization/visualization.h b/src/libs/vtools/visualization/visualization.h
index d48342920..5878bd9aa 100644
--- a/src/libs/vtools/visualization/visualization.h
+++ b/src/libs/vtools/visualization/visualization.h
@@ -72,8 +72,10 @@ public:
Mode GetMode() const;
void SetMode(const Mode &value);
- static qreal FindLength(const QString &expression, const QHash > *vars);
- static qreal FindVal(const QString &expression, const QHash > *vars);
+ static qreal FindLengthFromUser(const QString &expression, const QHash > *vars, bool fromUser = true);
+ static qreal FindValFromUser(const QString &expression, const QHash > *vars, bool fromUser = true);
signals:
void ToolTip(const QString &toolTip);
public slots: