Fix bugs.
* * * Fix tool union bugs. * * * Fix preparing pieces for layout. * * * Fix bug with formulas. --HG-- branch : feature
This commit is contained in:
parent
2a3d52ba88
commit
660efa3844
|
@ -850,7 +850,7 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse
|
||||||
|
|
||||||
initData.width = GetParametrString(domElement, AttrWidth, "0.0");
|
initData.width = GetParametrString(domElement, AttrWidth, "0.0");
|
||||||
const QString w = initData.width;//need for saving fixed formula;
|
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
|
const QStringList tags = QStringList() << TagNodes
|
||||||
<< TagData
|
<< TagData
|
||||||
|
@ -1721,7 +1721,7 @@ void VPattern::ParsePlaceLabel(QDomElement &domElement, const Document &parse)
|
||||||
initData.centerPoint = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
initData.centerPoint = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
||||||
initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, 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;
|
const QString w = initData.width;//need for saving fixed formula;
|
||||||
|
|
||||||
initData.height = GetParametrString(domElement, AttrHeight, "1.0");
|
initData.height = GetParametrString(domElement, AttrHeight, "1.0");
|
||||||
|
@ -3550,6 +3550,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d
|
||||||
VToolUnionDetailsInitData initData;
|
VToolUnionDetailsInitData initData;
|
||||||
initData.indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1");
|
initData.indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1");
|
||||||
initData.indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1");
|
initData.indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1");
|
||||||
|
initData.version = GetParametrUInt(domElement, AttrVersion, "1");
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = this;
|
initData.doc = this;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
|
|
@ -43,8 +43,6 @@
|
||||||
const QString CustomMSign = QStringLiteral("@");
|
const QString CustomMSign = QStringLiteral("@");
|
||||||
const QString CustomIncrSign = QStringLiteral("#");
|
const QString CustomIncrSign = QStringLiteral("#");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const QString AttrType = QStringLiteral("type");
|
const QString AttrType = QStringLiteral("type");
|
||||||
const QString AttrMx = QStringLiteral("mx");
|
const QString AttrMx = QStringLiteral("mx");
|
||||||
const QString AttrMy = QStringLiteral("my");
|
const QString AttrMy = QStringLiteral("my");
|
||||||
|
@ -129,6 +127,7 @@ const QString AttrShowLabel2 = QStringLiteral("showLabel2");
|
||||||
const QString AttrWidth = QStringLiteral("width");
|
const QString AttrWidth = QStringLiteral("width");
|
||||||
const QString AttrHeight = QStringLiteral("height");
|
const QString AttrHeight = QStringLiteral("height");
|
||||||
const QString AttrPlaceLabelType = QStringLiteral("placeLabelType");
|
const QString AttrPlaceLabelType = QStringLiteral("placeLabelType");
|
||||||
|
const QString AttrVersion = QStringLiteral("version");
|
||||||
|
|
||||||
const QString TypeLineNone = QStringLiteral("none");
|
const QString TypeLineNone = QStringLiteral("none");
|
||||||
const QString TypeLineLine = QStringLiteral("hair");
|
const QString TypeLineLine = QStringLiteral("hair");
|
||||||
|
|
|
@ -148,6 +148,7 @@ extern const QString AttrShowLabel2;
|
||||||
extern const QString AttrWidth;
|
extern const QString AttrWidth;
|
||||||
extern const QString AttrHeight;
|
extern const QString AttrHeight;
|
||||||
extern const QString AttrPlaceLabelType;
|
extern const QString AttrPlaceLabelType;
|
||||||
|
extern const QString AttrVersion;
|
||||||
|
|
||||||
extern const QString TypeLineNone;
|
extern const QString TypeLineNone;
|
||||||
extern const QString TypeLineLine;
|
extern const QString TypeLineLine;
|
||||||
|
|
|
@ -548,6 +548,7 @@
|
||||||
<xs:attribute name="indexD1" type="xs:unsignedInt"/>
|
<xs:attribute name="indexD1" type="xs:unsignedInt"/>
|
||||||
<xs:attribute name="indexD2" type="xs:unsignedInt"/>
|
<xs:attribute name="indexD2" type="xs:unsignedInt"/>
|
||||||
<xs:attribute name="inUse" type="xs:boolean"/>
|
<xs:attribute name="inUse" type="xs:boolean"/>
|
||||||
|
<xs:attribute name="version" type="unionVersion"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:choice>
|
</xs:choice>
|
||||||
|
@ -1030,4 +1031,12 @@
|
||||||
<xs:enumeration value="8"/><!--Button-->
|
<xs:enumeration value="8"/><!--Button-->
|
||||||
</xs:restriction>
|
</xs:restriction>
|
||||||
</xs:simpleType>
|
</xs:simpleType>
|
||||||
|
<xs:simpleType name="unionVersion">
|
||||||
|
<xs:restriction base="xs:unsignedInt">
|
||||||
|
<xs:enumeration value="1"/>
|
||||||
|
<!--Old version-->
|
||||||
|
<xs:enumeration value="2"/>
|
||||||
|
<!--New version-->
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
</xs:schema>
|
</xs:schema>
|
||||||
|
|
|
@ -266,8 +266,16 @@ QVector<QPointF> VEllipticalArc::GetPoints() const
|
||||||
|
|
||||||
path = t.map(path);
|
path = t.map(path);
|
||||||
|
|
||||||
QPolygonF polygon = path.toSubpathPolygons().first();
|
QPolygonF polygon;
|
||||||
polygon.removeFirst(); // remove point (0;0)
|
const QList<QPolygonF> sub = path.toSubpathPolygons();
|
||||||
|
if (not sub.isEmpty())
|
||||||
|
{
|
||||||
|
polygon = path.toSubpathPolygons().first();
|
||||||
|
if (not polygon.isEmpty())
|
||||||
|
{
|
||||||
|
polygon.removeFirst(); // remove point (0;0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return polygon;
|
return polygon;
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const
|
||||||
|
|
||||||
QTransform t;
|
QTransform t;
|
||||||
t.translate(center->x(), center->y());
|
t.translate(center->x(), center->y());
|
||||||
t.rotate(-d->aValue+d->correctionAngle);
|
t.rotate(-(d->aValue+d->correctionAngle));
|
||||||
t.translate(-center->x(), -center->y());
|
t.translate(-center->x(), -center->y());
|
||||||
|
|
||||||
auto SegmentShape = [center, t, this]()
|
auto SegmentShape = [center, t, this]()
|
||||||
|
|
|
@ -350,8 +350,8 @@ QVector<VLayoutPlaceLabel> ConvertPlaceLabels(const VPiece &piece, const VContai
|
||||||
{
|
{
|
||||||
const auto label = pattern->GeometricObject<VPlaceLabelItem>(piece.GetPlaceLabels().at(i));
|
const auto label = pattern->GeometricObject<VPlaceLabelItem>(piece.GetPlaceLabels().at(i));
|
||||||
VLayoutPlaceLabel layoutLabel;
|
VLayoutPlaceLabel layoutLabel;
|
||||||
layoutLabel.shape = label->LabelShape(pattern);
|
layoutLabel.shape = label->LabelShape();
|
||||||
layoutLabel.center = pattern->GeometricObject<VPointF>(label->GetCenterPoint())->toQPointF();
|
layoutLabel.center = label->toQPointF();
|
||||||
layoutLabel.type = label->GetLabelType();
|
layoutLabel.type = label->GetLabelType();
|
||||||
labels.append(layoutLabel);
|
labels.append(layoutLabel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -662,6 +662,34 @@ void VPiece::SetPlaceLabels(const QVector<quint32> &labels)
|
||||||
d->m_placeLabels = labels;
|
d->m_placeLabels = labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QList<quint32> VPiece::Dependencies() const
|
||||||
|
{
|
||||||
|
QList<quint32> 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
|
* @brief MissingNodes find missing nodes in detail. When we deleted object in detail and return this detail need
|
||||||
|
|
|
@ -106,6 +106,7 @@ public:
|
||||||
QVector<quint32> &GetPlaceLabels();
|
QVector<quint32> &GetPlaceLabels();
|
||||||
void SetPlaceLabels(const QVector<quint32> &labels);
|
void SetPlaceLabels(const QVector<quint32> &labels);
|
||||||
|
|
||||||
|
QList<quint32> Dependencies() const;
|
||||||
QVector<quint32> MissingNodes(const VPiece &det) const;
|
QVector<quint32> MissingNodes(const VPiece &det) const;
|
||||||
QVector<quint32> MissingCSAPath(const VPiece &det) const;
|
QVector<quint32> MissingCSAPath(const VPiece &det) const;
|
||||||
QVector<quint32> MissingInternalPaths(const VPiece &det) const;
|
QVector<quint32> MissingInternalPaths(const VPiece &det) const;
|
||||||
|
|
|
@ -435,6 +435,17 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector<VPieceNode
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QList<quint32> VPiecePath::Dependencies() const
|
||||||
|
{
|
||||||
|
QList<quint32> list;
|
||||||
|
foreach (const VPieceNode &node, d->m_nodes)
|
||||||
|
{
|
||||||
|
list.append(node.GetId());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<quint32> VPiecePath::MissingNodes(const VPiecePath &path) const
|
QVector<quint32> VPiecePath::MissingNodes(const VPiecePath &path) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,6 +87,7 @@ public:
|
||||||
|
|
||||||
QPainterPath PainterPath(const VContainer *data) const;
|
QPainterPath PainterPath(const VContainer *data) const;
|
||||||
|
|
||||||
|
QList<quint32> Dependencies() const;
|
||||||
QVector<quint32> MissingNodes(const VPiecePath &path) const;
|
QVector<quint32> MissingNodes(const VPiecePath &path) const;
|
||||||
|
|
||||||
int indexOfNode(quint32 id) const;
|
int indexOfNode(quint32 id) const;
|
||||||
|
|
|
@ -112,6 +112,7 @@ void DialogPlaceLabel::EnbleShowMode(bool disable)
|
||||||
{
|
{
|
||||||
m_showMode = disable;
|
m_showMode = disable;
|
||||||
ui->comboBoxPiece->setDisabled(m_showMode);
|
ui->comboBoxPiece->setDisabled(m_showMode);
|
||||||
|
ui->comboBoxPoint->setDisabled(m_showMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -457,10 +457,10 @@ VSpline DialogSpline::CurrentSpline() const
|
||||||
|
|
||||||
const QHash<QString, QSharedPointer<VInternalVariable> > *vars = data->DataVariables();
|
const QHash<QString, QSharedPointer<VInternalVariable> > *vars = data->DataVariables();
|
||||||
|
|
||||||
const qreal angle1 = Visualization::FindVal(angle1F, vars);
|
const qreal angle1 = Visualization::FindValFromUser(angle1F, vars);
|
||||||
const qreal angle2 = Visualization::FindVal(angle2F, vars);
|
const qreal angle2 = Visualization::FindValFromUser(angle2F, vars);
|
||||||
const qreal length1 = Visualization::FindLength(length1F, vars);
|
const qreal length1 = Visualization::FindLengthFromUser(length1F, vars);
|
||||||
const qreal length2 = Visualization::FindLength(length2F, vars);
|
const qreal length2 = Visualization::FindLengthFromUser(length2F, vars);
|
||||||
|
|
||||||
const bool separator = qApp->Settings()->GetOsSeparator();
|
const bool separator = qApp->Settings()->GetOsSeparator();
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,7 @@ void DialogSplinePath::Angle1Changed()
|
||||||
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
const QString angle1F = ui->plainTextEditAngle1F->toPlainText().replace("\n", " ");
|
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()));
|
p.SetAngle1(angle1, VTranslateVars::TryFormulaFromUser(angle1F, qApp->Settings()->GetOsSeparator()));
|
||||||
|
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
||||||
|
@ -341,7 +341,7 @@ void DialogSplinePath::Angle2Changed()
|
||||||
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
const QString angle2F = ui->plainTextEditAngle2F->toPlainText().replace("\n", " ");
|
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()));
|
p.SetAngle2(angle2, VTranslateVars::TryFormulaFromUser(angle2F, qApp->Settings()->GetOsSeparator()));
|
||||||
|
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
||||||
|
@ -375,7 +375,7 @@ void DialogSplinePath::Length1Changed()
|
||||||
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
const QString length1F = ui->plainTextEditLength1F->toPlainText().replace("\n", " ");
|
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()));
|
p.SetLength1(length1, VTranslateVars::TryFormulaFromUser(length1F, qApp->Settings()->GetOsSeparator()));
|
||||||
|
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
||||||
|
@ -400,7 +400,7 @@ void DialogSplinePath::Length2Changed()
|
||||||
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
||||||
|
|
||||||
const QString length2F = ui->plainTextEditLength2F->toPlainText().replace("\n", " ");
|
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()));
|
p.SetLength2(length2, VTranslateVars::TryFormulaFromUser(length2F, qApp->Settings()->GetOsSeparator()));
|
||||||
|
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
||||||
|
|
|
@ -128,7 +128,10 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
|
||||||
m_timerWidthBefore(nullptr),
|
m_timerWidthBefore(nullptr),
|
||||||
m_timerWidthAfter(nullptr),
|
m_timerWidthAfter(nullptr),
|
||||||
m_saWidth(0),
|
m_saWidth(0),
|
||||||
m_templateLines()
|
m_templateLines(),
|
||||||
|
m_undoStack(),
|
||||||
|
m_newPlaceLabels(),
|
||||||
|
m_newPaths()
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -641,7 +644,7 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos)
|
||||||
else if (selectedAction == actionOption)
|
else if (selectedAction == actionOption)
|
||||||
{
|
{
|
||||||
auto *dialog = new DialogPiecePath(data, record.path, this);
|
auto *dialog = new DialogPiecePath(data, record.path, this);
|
||||||
dialog->SetPiecePath(data->GetPiecePath(record.path));
|
dialog->SetPiecePath(CurrentPath(record.path));
|
||||||
dialog->SetPieceId(toolId);
|
dialog->SetPieceId(toolId);
|
||||||
if (record.includeType == PiecePathIncludeType::AsMainPath)
|
if (record.includeType == PiecePathIncludeType::AsMainPath)
|
||||||
{
|
{
|
||||||
|
@ -681,7 +684,7 @@ void DialogSeamAllowance::ShowInternalPathsContextMenu(const QPoint &pos)
|
||||||
const quint32 pathId = qvariant_cast<quint32>(rowItem->data(Qt::UserRole));
|
const quint32 pathId = qvariant_cast<quint32>(rowItem->data(Qt::UserRole));
|
||||||
|
|
||||||
auto *dialog = new DialogPiecePath(data, pathId, this);
|
auto *dialog = new DialogPiecePath(data, pathId, this);
|
||||||
dialog->SetPiecePath(data->GetPiecePath(pathId));
|
dialog->SetPiecePath(CurrentPath(pathId));
|
||||||
dialog->SetPieceId(toolId);
|
dialog->SetPieceId(toolId);
|
||||||
dialog->EnbleShowMode(true);
|
dialog->EnbleShowMode(true);
|
||||||
m_dialog = dialog;
|
m_dialog = dialog;
|
||||||
|
@ -726,26 +729,28 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
|
||||||
QListWidgetItem *rowItem = uiTabPlaceLabels->listWidgetPlaceLabels->item(row);
|
QListWidgetItem *rowItem = uiTabPlaceLabels->listWidgetPlaceLabels->item(row);
|
||||||
SCASSERT(rowItem != nullptr);
|
SCASSERT(rowItem != nullptr);
|
||||||
const quint32 labelId = qvariant_cast<quint32>(rowItem->data(Qt::UserRole));
|
const quint32 labelId = qvariant_cast<quint32>(rowItem->data(Qt::UserRole));
|
||||||
const auto label = data->GeometricObject<VPlaceLabelItem>(labelId);
|
VPlaceLabelItem currentLabel = CurrentPlaceLabel(labelId);
|
||||||
|
|
||||||
QScopedPointer<QMenu> menu(new QMenu());
|
QScopedPointer<QMenu> 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);
|
QAction *action = menu->addAction(text);
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setChecked(label->GetLabelType() == type);
|
action->setChecked(currentLabel.GetLabelType() == type);
|
||||||
return action;
|
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);
|
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<VContainer *>(data), labelId);
|
const_cast<VContainer *>(data), labelId);
|
||||||
qApp->getUndoStack()->push(saveCommand);
|
m_undoStack.append(saveCommand);
|
||||||
UpdateCurrentPlaceLabelRecords();
|
UpdateCurrentPlaceLabelRecords();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -772,11 +777,11 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
|
||||||
else if (selectedAction == actionOption)
|
else if (selectedAction == actionOption)
|
||||||
{
|
{
|
||||||
auto *dialog = new DialogPlaceLabel(data, labelId, this);
|
auto *dialog = new DialogPlaceLabel(data, labelId, this);
|
||||||
dialog->SetCenterPoint(label->GetCenterPoint());
|
dialog->SetCenterPoint(labelId);
|
||||||
dialog->SetLabelType(label->GetLabelType());
|
dialog->SetLabelType(currentLabel.GetLabelType());
|
||||||
dialog->SetWidth(label->GetWidthFormula());
|
dialog->SetWidth(currentLabel.GetWidthFormula());
|
||||||
dialog->SetHeight(label->GetHeightFormula());
|
dialog->SetHeight(currentLabel.GetHeightFormula());
|
||||||
dialog->SetAngle(label->GetAngleFormula());
|
dialog->SetAngle(currentLabel.GetAngleFormula());
|
||||||
dialog->SetPieceId(toolId);
|
dialog->SetPieceId(toolId);
|
||||||
dialog->EnbleShowMode(true);
|
dialog->EnbleShowMode(true);
|
||||||
m_dialog = dialog;
|
m_dialog = dialog;
|
||||||
|
@ -1175,13 +1180,15 @@ void DialogSeamAllowance::PathDialogClosed(int result)
|
||||||
SCASSERT(dialogTool != nullptr);
|
SCASSERT(dialogTool != nullptr);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const VPiecePath newPath = dialogTool->GetPiecePath();
|
VPiecePath currentPath = CurrentPath(dialogTool->GetToolId());
|
||||||
const VPiecePath oldPath = data->GetPiecePath(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<VContainer *>(data),
|
const_cast<VContainer *>(data),
|
||||||
dialogTool->GetToolId());
|
dialogTool->GetToolId());
|
||||||
qApp->getUndoStack()->push(saveCommand);
|
m_undoStack.append(saveCommand);
|
||||||
UpdateCurrentCustomSARecord();
|
UpdateCurrentCustomSARecord();
|
||||||
UpdateCurrentInternalPathRecord();
|
UpdateCurrentInternalPathRecord();
|
||||||
}
|
}
|
||||||
|
@ -1204,34 +1211,35 @@ void DialogSeamAllowance::PlaceLabelDialogClosed(int result)
|
||||||
SCASSERT(dialogTool != nullptr);
|
SCASSERT(dialogTool != nullptr);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto oldLabel = data->GeometricObject<VPlaceLabelItem>(dialogTool->GetToolId());
|
VPlaceLabelItem currentLabel = CurrentPlaceLabel(dialogTool->GetToolId());
|
||||||
|
|
||||||
auto point = data->GeometricObject<VPointF>(dialogTool->GetCenterPoint());
|
|
||||||
|
|
||||||
const QHash<QString, QSharedPointer<VInternalVariable> > *vars = data->DataVariables();
|
const QHash<QString, QSharedPointer<VInternalVariable> > *vars = data->DataVariables();
|
||||||
|
|
||||||
const qreal w = qAbs(Visualization::FindLength(dialogTool->GetWidth(), vars));
|
const qreal w = qAbs(Visualization::FindLengthFromUser(dialogTool->GetWidth(), vars, false));
|
||||||
const qreal h = qAbs(Visualization::FindLength(dialogTool->GetHeight(), vars));
|
const qreal h = qAbs(Visualization::FindLengthFromUser(dialogTool->GetHeight(), vars, false));
|
||||||
const qreal a = Visualization::FindVal(dialogTool->GetAngle(), vars);
|
const qreal a = Visualization::FindValFromUser(dialogTool->GetAngle(), vars, false);
|
||||||
|
qDebug() << w << h << a;
|
||||||
|
|
||||||
VPlaceLabelItem newLabel = VPlaceLabelItem();
|
VPlaceLabelItem newLabel = VPlaceLabelItem();
|
||||||
newLabel.setName(point->name());
|
newLabel.setName(currentLabel.name());
|
||||||
newLabel.setX(point->x());
|
newLabel.setX(currentLabel.x());
|
||||||
newLabel.setY(point->y());
|
newLabel.setY(currentLabel.y());
|
||||||
newLabel.setMx(point->mx());
|
newLabel.setMx(currentLabel.mx());
|
||||||
newLabel.setMy(point->my());
|
newLabel.setMy(currentLabel.my());
|
||||||
newLabel.SetWidth(w, dialogTool->GetWidth());
|
newLabel.SetWidth(w, dialogTool->GetWidth());
|
||||||
newLabel.SetHeight(h, dialogTool->GetHeight());
|
newLabel.SetHeight(h, dialogTool->GetHeight());
|
||||||
newLabel.SetAngle(a, dialogTool->GetAngle());
|
newLabel.SetAngle(a, dialogTool->GetAngle());
|
||||||
newLabel.SetLabelType(dialogTool->GetLabelType());
|
newLabel.SetLabelType(dialogTool->GetLabelType());
|
||||||
newLabel.SetCenterPoint(dialogTool->GetCenterPoint());
|
newLabel.SetCenterPoint(currentLabel.GetCenterPoint());
|
||||||
newLabel.SetCorrectionAngle(oldLabel->GetCorrectionAngle());
|
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(),
|
qApp->getCurrentDocument(),
|
||||||
const_cast<VContainer *>(data),
|
const_cast<VContainer *>(data),
|
||||||
dialogTool->GetToolId());
|
dialogTool->GetToolId());
|
||||||
qApp->getUndoStack()->push(saveCommand);
|
m_undoStack.append(saveCommand);
|
||||||
UpdateCurrentPlaceLabelRecords();
|
UpdateCurrentPlaceLabelRecords();
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &e)
|
catch (const VExceptionBadId &e)
|
||||||
|
@ -2271,7 +2279,7 @@ QString DialogSeamAllowance::GetPathName(quint32 path, bool reverse) const
|
||||||
|
|
||||||
if (path > NULL_ID)
|
if (path > NULL_ID)
|
||||||
{
|
{
|
||||||
name = data->GetPiecePath(path).GetName();
|
name = CurrentPath(path).GetName();
|
||||||
|
|
||||||
if (reverse)
|
if (reverse)
|
||||||
{
|
{
|
||||||
|
@ -2883,6 +2891,12 @@ QString DialogSeamAllowance::GetFormulaSAWidth() const
|
||||||
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
|
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<QUndoCommand *> &DialogSeamAllowance::UndoStack()
|
||||||
|
{
|
||||||
|
return m_undoStack;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula)
|
void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula)
|
||||||
{
|
{
|
||||||
|
@ -2943,9 +2957,8 @@ void DialogSeamAllowance::UpdateCurrentPlaceLabelRecords()
|
||||||
|
|
||||||
QListWidgetItem *item = uiTabPlaceLabels->listWidgetPlaceLabels->item(row);
|
QListWidgetItem *item = uiTabPlaceLabels->listWidgetPlaceLabels->item(row);
|
||||||
SCASSERT(item != nullptr);
|
SCASSERT(item != nullptr);
|
||||||
const quint32 pointId = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
const quint32 labelId = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
||||||
auto point = data->GeometricObject<VPointF>(pointId);
|
item->setText(CurrentPlaceLabel(labelId).name());
|
||||||
item->setText(point->name());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -3131,3 +3144,15 @@ void DialogSeamAllowance::ShowPieceSpecialPoints(const QListWidget *list)
|
||||||
m_visSpecialPoints->RefreshGeometry();
|
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<VPlaceLabelItem>(id);
|
||||||
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ namespace Ui
|
||||||
|
|
||||||
class VisPieceSpecialPoints;
|
class VisPieceSpecialPoints;
|
||||||
class FancyTabBar;
|
class FancyTabBar;
|
||||||
|
class VPlaceLabelItem;
|
||||||
|
class QUndoCommand;
|
||||||
|
|
||||||
class DialogSeamAllowance : public DialogTool
|
class DialogSeamAllowance : public DialogTool
|
||||||
{
|
{
|
||||||
|
@ -64,6 +66,8 @@ public:
|
||||||
|
|
||||||
QString GetFormulaSAWidth() const;
|
QString GetFormulaSAWidth() const;
|
||||||
|
|
||||||
|
QVector<QUndoCommand*> &UndoStack();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
|
||||||
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
|
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
|
||||||
|
@ -209,6 +213,10 @@ private:
|
||||||
|
|
||||||
QVector<VLabelTemplateLine> m_templateLines;
|
QVector<VLabelTemplateLine> m_templateLines;
|
||||||
|
|
||||||
|
QVector<QUndoCommand*> m_undoStack;
|
||||||
|
QHash<quint32, VPlaceLabelItem> m_newPlaceLabels;
|
||||||
|
QHash<quint32, VPiecePath> m_newPaths;
|
||||||
|
|
||||||
VPiece CreatePiece() const;
|
VPiece CreatePiece() const;
|
||||||
|
|
||||||
void NewMainPathItem(const VPieceNode &node);
|
void NewMainPathItem(const VPieceNode &node);
|
||||||
|
@ -261,6 +269,9 @@ private:
|
||||||
void SetPLAngle(QString angleFormula);
|
void SetPLAngle(QString angleFormula);
|
||||||
|
|
||||||
void ShowPieceSpecialPoints(const QListWidget *list);
|
void ShowPieceSpecialPoints(const QListWidget *list);
|
||||||
|
|
||||||
|
VPiecePath CurrentPath(quint32 id) const;
|
||||||
|
VPlaceLabelItem CurrentPlaceLabel(quint32 id) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOGSEAMALLOWANCE_H
|
#endif // DIALOGSEAMALLOWANCE_H
|
||||||
|
|
|
@ -251,7 +251,7 @@ QString VToolCutArc::MakeToolTip() const
|
||||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(curveCutId);
|
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(curveCutId);
|
||||||
|
|
||||||
const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
|
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 arcStr = tr("Arc");
|
||||||
const QString lengthStr = tr("length");
|
const QString lengthStr = tr("length");
|
||||||
|
|
|
@ -250,7 +250,7 @@ QString VToolCutSpline::MakeToolTip() const
|
||||||
const auto spl = VAbstractTool::data.GeometricObject<VAbstractCubicBezier>(curveCutId);
|
const auto spl = VAbstractTool::data.GeometricObject<VAbstractCubicBezier>(curveCutId);
|
||||||
|
|
||||||
const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
|
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 spl1p2, spl1p3, spl2p2, spl2p3;
|
||||||
QPointF point = spl->CutSpline(qApp->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3);
|
QPointF point = spl->CutSpline(qApp->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3);
|
||||||
|
|
|
@ -339,7 +339,7 @@ QString VToolCutSplinePath::MakeToolTip() const
|
||||||
const auto splPath = VAbstractTool::data.GeometricObject<VAbstractCubicBezierPath>(curveCutId);
|
const auto splPath = VAbstractTool::data.GeometricObject<VAbstractCubicBezierPath>(curveCutId);
|
||||||
|
|
||||||
const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
|
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 *splPath1 = nullptr;
|
||||||
VSplinePath *splPath2 = nullptr;
|
VSplinePath *splPath2 = nullptr;
|
||||||
|
|
|
@ -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");
|
qCDebug(vTool, "Saving tool options after using dialog");
|
||||||
QDomElement oldDomElement = doc->elementById(m_id, getTagName());
|
QDomElement oldDomElement = doc->elementById(m_id, getTagName());
|
||||||
if (oldDomElement.isElement())
|
if (oldDomElement.isElement())
|
||||||
|
|
|
@ -100,7 +100,7 @@ protected:
|
||||||
/** @brief SaveDialog save options into file after change in dialog. */
|
/** @brief SaveDialog save options into file after change in dialog. */
|
||||||
virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,
|
virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,
|
||||||
QList<quint32> &newDependencies)=0;
|
QList<quint32> &newDependencies)=0;
|
||||||
virtual void SaveDialogChange() Q_DECL_FINAL;
|
virtual void SaveDialogChange(const QString &undoText = QString()) Q_DECL_FINAL;
|
||||||
virtual void AddToFile() Q_DECL_OVERRIDE;
|
virtual void AddToFile() Q_DECL_OVERRIDE;
|
||||||
void SaveOption(QSharedPointer<VGObject> &obj);
|
void SaveOption(QSharedPointer<VGObject> &obj);
|
||||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||||
|
|
|
@ -102,7 +102,7 @@ VToolPlaceLabel *VToolPlaceLabel::Create(VToolPlaceLabelInitData &initData)
|
||||||
node->setMx(point->mx());
|
node->setMx(point->mx());
|
||||||
node->setMy(point->my());
|
node->setMy(point->my());
|
||||||
|
|
||||||
if (initData.typeCreation == Source::FromTool)
|
if (initData.idTool != NULL_ID)
|
||||||
{
|
{
|
||||||
QSharedPointer<VPlaceLabelItem> label = qSharedPointerDynamicCast<VPlaceLabelItem>(point);
|
QSharedPointer<VPlaceLabelItem> label = qSharedPointerDynamicCast<VPlaceLabelItem>(point);
|
||||||
SCASSERT(label.isNull() == false)
|
SCASSERT(label.isNull() == false)
|
||||||
|
|
|
@ -46,8 +46,8 @@ public:
|
||||||
static bool m_suppressContextMenu;
|
static bool m_suppressContextMenu;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void FullUpdateFromGuiOk(int result);
|
virtual void FullUpdateFromGuiOk(int result);
|
||||||
void FullUpdateFromGuiApply();
|
virtual void FullUpdateFromGuiApply();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** @brief m_dialog tool's dialog options.*/
|
/** @brief m_dialog tool's dialog options.*/
|
||||||
|
@ -55,7 +55,7 @@ protected:
|
||||||
|
|
||||||
/** @brief setDialog set dialog when user want change tool option. */
|
/** @brief setDialog set dialog when user want change tool option. */
|
||||||
virtual void setDialog() {/*do nothing by default*/}
|
virtual void setDialog() {/*do nothing by default*/}
|
||||||
virtual void SaveDialogChange()=0;
|
virtual void SaveDialogChange(const QString &undoText = QString())=0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VInteractiveTool)
|
Q_DISABLE_COPY(VInteractiveTool)
|
||||||
|
|
|
@ -71,7 +71,6 @@ const QString VToolSeamAllowance::TagIPaths = QStringLiteral("iPaths");
|
||||||
const QString VToolSeamAllowance::TagPins = QStringLiteral("pins");
|
const QString VToolSeamAllowance::TagPins = QStringLiteral("pins");
|
||||||
const QString VToolSeamAllowance::TagPlaceLabels = QStringLiteral("placeLabels");
|
const QString VToolSeamAllowance::TagPlaceLabels = QStringLiteral("placeLabels");
|
||||||
|
|
||||||
const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version");
|
|
||||||
const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping");
|
const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping");
|
||||||
const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance");
|
const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance");
|
||||||
const QString VToolSeamAllowance::AttrHideMainPath = QStringLiteral("hideMainPath");
|
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()
|
void VToolSeamAllowance::AddToFile()
|
||||||
{
|
{
|
||||||
|
@ -935,7 +940,7 @@ void VToolSeamAllowance::RefreshDataInFile()
|
||||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 0),
|
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 0),
|
||||||
"Time to refactor the code.");
|
"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)
|
if (version == 1)
|
||||||
{
|
{
|
||||||
const VPiece piece = VAbstractTool::data.GetPiece(m_id);
|
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);
|
connect(this, &VToolSeamAllowance::ChoosedTool, m_sceneDetails, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
|
||||||
ConnectOutsideSignals();
|
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());
|
SCASSERT(not m_dialog.isNull());
|
||||||
DialogSeamAllowance *dialogTool = qobject_cast<DialogSeamAllowance*>(m_dialog.data());
|
DialogSeamAllowance *dialogTool = qobject_cast<DialogSeamAllowance*>(m_dialog.data());
|
||||||
|
@ -1310,8 +1311,28 @@ void VToolSeamAllowance::SaveDialogChange()
|
||||||
const VPiece newDet = dialogTool->GetPiece();
|
const VPiece newDet = dialogTool->GetPiece();
|
||||||
const VPiece oldDet = VAbstractTool::data.GetPiece(m_id);
|
const VPiece oldDet = VAbstractTool::data.GetPiece(m_id);
|
||||||
|
|
||||||
qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id));
|
QVector<QUndoCommand*> &undocommands = dialogTool->UndoStack();
|
||||||
UpdateDetailLabel();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -73,7 +73,6 @@ public:
|
||||||
static const QString TagPins;
|
static const QString TagPins;
|
||||||
static const QString TagPlaceLabels;
|
static const QString TagPlaceLabels;
|
||||||
|
|
||||||
static const QString AttrVersion;
|
|
||||||
static const QString AttrForbidFlipping;
|
static const QString AttrForbidFlipping;
|
||||||
static const QString AttrSeamAllowance;
|
static const QString AttrSeamAllowance;
|
||||||
static const QString AttrHideMainPath;
|
static const QString AttrHideMainPath;
|
||||||
|
@ -106,6 +105,7 @@ public:
|
||||||
void DisconnectOutsideSignals();
|
void DisconnectOutsideSignals();
|
||||||
void ConnectOutsideSignals();
|
void ConnectOutsideSignals();
|
||||||
void ReinitInternals(const VPiece &detail, VMainGraphicsScene *scene);
|
void ReinitInternals(const VPiece &detail, VMainGraphicsScene *scene);
|
||||||
|
void RefreshGeometry();
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Tool::Piece)};
|
enum { Type = UserType + static_cast<int>(Tool::Piece)};
|
||||||
|
@ -118,6 +118,7 @@ public:
|
||||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
||||||
virtual QPainterPath shape() const Q_DECL_OVERRIDE;
|
virtual QPainterPath shape() const Q_DECL_OVERRIDE;
|
||||||
public slots:
|
public slots:
|
||||||
|
virtual void FullUpdateFromGuiApply() Q_DECL_OVERRIDE;
|
||||||
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
|
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
|
||||||
void EnableToolMove(bool move);
|
void EnableToolMove(bool move);
|
||||||
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
||||||
|
@ -153,7 +154,7 @@ protected:
|
||||||
virtual void DeleteToolWithConfirm(bool ask = true) Q_DECL_OVERRIDE;
|
virtual void DeleteToolWithConfirm(bool ask = true) Q_DECL_OVERRIDE;
|
||||||
virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE;
|
virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE;
|
||||||
virtual void SetDialog() Q_DECL_FINAL;
|
virtual void SetDialog() Q_DECL_FINAL;
|
||||||
virtual void SaveDialogChange() Q_DECL_FINAL;
|
virtual void SaveDialogChange(const QString &undoText = QString()) Q_DECL_FINAL;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolSeamAllowance)
|
Q_DISABLE_COPY(VToolSeamAllowance)
|
||||||
|
@ -175,7 +176,6 @@ private:
|
||||||
VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr);
|
VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr);
|
||||||
|
|
||||||
void UpdateExcludeState();
|
void UpdateExcludeState();
|
||||||
void RefreshGeometry();
|
|
||||||
|
|
||||||
VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth,
|
VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth,
|
||||||
qreal &labelHeight, QPointF &pos);
|
qreal &labelHeight, QPointF &pos);
|
||||||
|
|
|
@ -86,6 +86,9 @@ const QString VToolUnionDetails::AttrNodeType = QStringLiteral("nodeType");
|
||||||
const QString VToolUnionDetails::NodeTypeContour = QStringLiteral("Contour");
|
const QString VToolUnionDetails::NodeTypeContour = QStringLiteral("Contour");
|
||||||
const QString VToolUnionDetails::NodeTypeModeling = QStringLiteral("Modeling");
|
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_PUSH
|
||||||
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
||||||
QT_WARNING_DISABLE_INTEL(1418)
|
QT_WARNING_DISABLE_INTEL(1418)
|
||||||
|
@ -232,6 +235,37 @@ QVector<quint32> GetPiece2Pins(VAbstractPattern *doc, quint32 id)
|
||||||
return QVector<quint32>();
|
return QVector<quint32>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<quint32> 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<quint32>();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DrawName(VAbstractPattern *doc, quint32 d1id, quint32 d2id)
|
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.typeCreation = Source::FromTool;
|
||||||
initNodeData.idTool = initData.id;
|
initNodeData.idTool = initData.id;
|
||||||
initNodeData.drawName = drawName;
|
initNodeData.drawName = drawName;
|
||||||
|
initNodeData.scene = initData.scene;
|
||||||
|
|
||||||
VNodePoint::Create(initNodeData);
|
VNodePoint::Create(initNodeData);
|
||||||
return id;
|
return id;
|
||||||
|
@ -443,15 +478,8 @@ quint32 AddPlaceLabel(quint32 id, const VToolUnionDetailsInitData &initData, QVe
|
||||||
}
|
}
|
||||||
|
|
||||||
label->SetCorrectionAngle(label->GetCorrectionAngle() + angle);
|
label->SetCorrectionAngle(label->GetCorrectionAngle() + angle);
|
||||||
QScopedPointer<VPlaceLabelItem> 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;
|
VToolPlaceLabelInitData initNodeData;
|
||||||
initNodeData.id = idLabel;
|
|
||||||
initNodeData.centerPoint = idObject;
|
|
||||||
initNodeData.idObject = NULL_ID;
|
initNodeData.idObject = NULL_ID;
|
||||||
initNodeData.doc = initData.doc;
|
initNodeData.doc = initData.doc;
|
||||||
initNodeData.data = initData.data;
|
initNodeData.data = initData.data;
|
||||||
|
@ -459,6 +487,18 @@ quint32 AddPlaceLabel(quint32 id, const VToolUnionDetailsInitData &initData, QVe
|
||||||
initNodeData.typeCreation = Source::FromTool;
|
initNodeData.typeCreation = Source::FromTool;
|
||||||
initNodeData.idTool = initData.id;
|
initNodeData.idTool = initData.id;
|
||||||
initNodeData.drawName = drawName;
|
initNodeData.drawName = drawName;
|
||||||
|
initNodeData.width = label->GetWidthFormula();
|
||||||
|
initNodeData.height = label->GetHeightFormula();
|
||||||
|
initNodeData.angle = label->GetAngleFormula();
|
||||||
|
initNodeData.type = label->GetLabelType();
|
||||||
|
|
||||||
|
QScopedPointer<VPlaceLabelItem> 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);
|
VToolPlaceLabel::Create(initNodeData);
|
||||||
return idLabel;
|
return idLabel;
|
||||||
|
@ -1148,7 +1188,14 @@ void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector<quint32>
|
||||||
VToolPiecePath::Create(initNodeData);
|
VToolPiecePath::Create(initNodeData);
|
||||||
record.path = idPath;
|
record.path = idPath;
|
||||||
newDetail.GetCustomSARecords().append(record);
|
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;
|
children += nodeChildren;
|
||||||
}
|
}
|
||||||
|
@ -1199,7 +1246,14 @@ void CreateUnitedDetailInternalPaths(VPiece &newDetail, const VPiece &d, QVector
|
||||||
|
|
||||||
VToolPiecePath::Create(initNodeData);
|
VToolPiecePath::Create(initNodeData);
|
||||||
newDetail.GetInternalPaths().append(idPath);
|
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;
|
children += nodeChildren;
|
||||||
}
|
}
|
||||||
|
@ -1230,7 +1284,6 @@ void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector<quint32>
|
||||||
{
|
{
|
||||||
const quint32 id = AddPin(d.GetPins().at(i), initData, children, drawName, dx, dy, pRotate, angle);
|
const quint32 id = AddPin(d.GetPins().at(i), initData, children, drawName, dx, dy, pRotate, angle);
|
||||||
newDetail.GetPins().append(id);
|
newDetail.GetPins().append(id);
|
||||||
nodeChildren.prepend(id);
|
|
||||||
}
|
}
|
||||||
children += nodeChildren;
|
children += nodeChildren;
|
||||||
}
|
}
|
||||||
|
@ -1246,7 +1299,6 @@ void CreateUnitedDetailPlaceLabels(VPiece &newDetail, const VPiece &d, QVector<q
|
||||||
const quint32 id = AddPlaceLabel(d.GetPlaceLabels().at(i), initData, children, drawName, dx, dy, pRotate,
|
const quint32 id = AddPlaceLabel(d.GetPlaceLabels().at(i), initData, children, drawName, dx, dy, pRotate,
|
||||||
angle);
|
angle);
|
||||||
newDetail.GetPlaceLabels().append(id);
|
newDetail.GetPlaceLabels().append(id);
|
||||||
nodeChildren.prepend(id);
|
|
||||||
}
|
}
|
||||||
children += nodeChildren;
|
children += nodeChildren;
|
||||||
}
|
}
|
||||||
|
@ -1351,20 +1403,37 @@ void UpdateUnitedDetailPaths(const VToolUnionDetailsInitData &initData, qreal dx
|
||||||
for (int i=0; i < records.size(); ++i)
|
for (int i=0; i < records.size(); ++i)
|
||||||
{
|
{
|
||||||
const VPiecePath path = initData.data->GetPiecePath(records.at(i));
|
const VPiecePath path = initData.data->GetPiecePath(records.at(i));
|
||||||
const quint32 updatedId = TakeNextId(children);
|
|
||||||
|
|
||||||
VPiecePath updatedPath(path);
|
if (initData.version == 1)
|
||||||
updatedPath.Clear();
|
|
||||||
|
|
||||||
for (int j=0; j < path.CountNodes(); ++j)
|
|
||||||
{
|
{
|
||||||
const VPieceNode &node = path.at(j);
|
// TODO. Delete if minimal supported version is 0.7.0
|
||||||
const quint32 id = TakeNextId(children);
|
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 0),
|
||||||
updatedPath.Append(VPieceNode(id, node.GetTypeTool(), node.GetReverse()));
|
"Time to refactor the code.");
|
||||||
QVector<quint32> nodeChildren = {id};
|
const quint32 updatedId = TakeNextId(children);
|
||||||
UpdatePathNode(initData.data, path.at(j), nodeChildren, dx, dy, pRotate, angle);
|
|
||||||
|
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<quint32> 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<quint32> 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)
|
for (int i = 0; i < records.size(); ++i)
|
||||||
{
|
{
|
||||||
QScopedPointer<VPlaceLabelItem>
|
QSharedPointer<VPlaceLabelItem> parentLabel = initData.data->GeometricObject<VPlaceLabelItem>(records.at(i));
|
||||||
label(new VPlaceLabelItem(*initData.data->GeometricObject<VPlaceLabelItem>(records.at(i))));
|
|
||||||
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
|
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
|
||||||
{
|
{
|
||||||
BiasRotatePoint(label.data(), dx, dy,
|
BiasRotatePoint(parentLabel.data(), dx, dy,
|
||||||
static_cast<QPointF>(*initData.data->GeometricObject<VPointF>(pRotate)), angle);
|
static_cast<QPointF>(*initData.data->GeometricObject<VPointF>(pRotate)), angle);
|
||||||
}
|
}
|
||||||
label->SetCorrectionAngle(label->GetCorrectionAngle()+angle);
|
QScopedPointer<VPlaceLabelItem> 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());
|
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,
|
UpdateUnitedDetailInternalPaths(initData, dx, dy, pRotate, angle,
|
||||||
GetPiece2InternalPaths(initData.doc, initData.id));
|
GetPiece2InternalPaths(initData.doc, initData.id));
|
||||||
UpdateUnitedDetailPins(initData, dx, dy, pRotate, angle, GetPiece2Pins(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),
|
d1id(initData.d1id),
|
||||||
d2id(initData.d2id),
|
d2id(initData.d2id),
|
||||||
indexD1(initData.indexD1),
|
indexD1(initData.indexD1),
|
||||||
indexD2(initData.indexD2)
|
indexD2(initData.indexD2),
|
||||||
|
version(initData.version)
|
||||||
{
|
{
|
||||||
_referens = 0;
|
_referens = 0;
|
||||||
ToolCreation(initData.typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
|
@ -1668,6 +1744,7 @@ void VToolUnionDetails::AddToFile()
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrIndexD1, indexD1);
|
doc->SetAttribute(domElement, AttrIndexD1, indexD1);
|
||||||
doc->SetAttribute(domElement, AttrIndexD2, indexD2);
|
doc->SetAttribute(domElement, AttrIndexD2, indexD2);
|
||||||
|
doc->SetAttribute(domElement, AttrVersion, unionVersion);
|
||||||
|
|
||||||
AddDetail(domElement, data.GetPiece(d1id));
|
AddDetail(domElement, data.GetPiece(d1id));
|
||||||
AddDetail(domElement, data.GetPiece(d2id));
|
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::AddCSARecords(doc, det, d.GetCustomSARecords());
|
||||||
VToolSeamAllowance::AddInternalPaths(doc, det, d.GetInternalPaths());
|
VToolSeamAllowance::AddInternalPaths(doc, det, d.GetInternalPaths());
|
||||||
VToolSeamAllowance::AddPins(doc, det, d.GetPins());
|
VToolSeamAllowance::AddPins(doc, det, d.GetPins());
|
||||||
|
VToolSeamAllowance::AddPlaceLabels(doc, det, d.GetPlaceLabels());
|
||||||
|
|
||||||
domElement.appendChild(det);
|
domElement.appendChild(det);
|
||||||
}
|
}
|
||||||
|
@ -1726,10 +1804,11 @@ QVector<quint32> VToolUnionDetails::GetReferenceObjects() const
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList parts = QStringList() << VAbstractPattern::TagNodes /*0*/
|
const QStringList parts = QStringList() << VAbstractPattern::TagNodes /*0*/
|
||||||
<< VToolSeamAllowance::TagCSA /*1*/
|
<< VToolSeamAllowance::TagCSA /*1*/
|
||||||
<< VToolSeamAllowance::TagIPaths /*2*/
|
<< VToolSeamAllowance::TagIPaths /*2*/
|
||||||
<< VToolSeamAllowance::TagPins; /*3*/
|
<< VToolSeamAllowance::TagPins /*3*/
|
||||||
|
<< VToolSeamAllowance::TagPlaceLabels; /*4*/
|
||||||
|
|
||||||
const QDomNodeList nodesList = tool.childNodes();
|
const QDomNodeList nodesList = tool.childNodes();
|
||||||
for (qint32 i = 0; i < nodesList.size(); ++i)
|
for (qint32 i = 0; i < nodesList.size(); ++i)
|
||||||
|
@ -1754,6 +1833,7 @@ QVector<quint32> VToolUnionDetails::GetReferenceObjects() const
|
||||||
VAbstractPattern::AttrPath);
|
VAbstractPattern::AttrPath);
|
||||||
break;
|
break;
|
||||||
case 3://VToolSeamAllowance::TagPins
|
case 3://VToolSeamAllowance::TagPins
|
||||||
|
case 4://VToolSeamAllowance::TagPlaceLabels
|
||||||
{
|
{
|
||||||
const QDomNodeList children = element.childNodes();
|
const QDomNodeList children = element.childNodes();
|
||||||
for (qint32 i = 0; i < children.size(); ++i)
|
for (qint32 i = 0; i < children.size(); ++i)
|
||||||
|
|
|
@ -47,6 +47,8 @@
|
||||||
|
|
||||||
class DialogTool;
|
class DialogTool;
|
||||||
|
|
||||||
|
#define UNION_VERSSION 2
|
||||||
|
|
||||||
struct VToolUnionDetailsInitData : VAbstractToolInitData
|
struct VToolUnionDetailsInitData : VAbstractToolInitData
|
||||||
{
|
{
|
||||||
VToolUnionDetailsInitData()
|
VToolUnionDetailsInitData()
|
||||||
|
@ -55,7 +57,8 @@ struct VToolUnionDetailsInitData : VAbstractToolInitData
|
||||||
d2id(NULL_ID),
|
d2id(NULL_ID),
|
||||||
indexD1(NULL_ID),
|
indexD1(NULL_ID),
|
||||||
indexD2(NULL_ID),
|
indexD2(NULL_ID),
|
||||||
retainPieces(false)
|
retainPieces(false),
|
||||||
|
version(UNION_VERSSION)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
quint32 d1id;
|
quint32 d1id;
|
||||||
|
@ -63,6 +66,7 @@ struct VToolUnionDetailsInitData : VAbstractToolInitData
|
||||||
quint32 indexD1;
|
quint32 indexD1;
|
||||||
quint32 indexD2;
|
quint32 indexD2;
|
||||||
bool retainPieces;
|
bool retainPieces;
|
||||||
|
uint version;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,6 +92,8 @@ public:
|
||||||
static const QString NodeTypeContour;
|
static const QString NodeTypeContour;
|
||||||
static const QString NodeTypeModeling;
|
static const QString NodeTypeModeling;
|
||||||
|
|
||||||
|
static const quint8 unionVersion;
|
||||||
|
|
||||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||||
virtual void incrementReferens() Q_DECL_OVERRIDE;
|
virtual void incrementReferens() Q_DECL_OVERRIDE;
|
||||||
|
@ -120,6 +126,8 @@ private:
|
||||||
/** @brief indexD2 index edge in second detail. */
|
/** @brief indexD2 index edge in second detail. */
|
||||||
quint32 indexD2;
|
quint32 indexD2;
|
||||||
|
|
||||||
|
uint version;
|
||||||
|
|
||||||
VToolUnionDetails(const VToolUnionDetailsInitData &initData, QObject *parent = nullptr);
|
VToolUnionDetails(const VToolUnionDetailsInitData &initData, QObject *parent = nullptr);
|
||||||
|
|
||||||
void AddDetail(QDomElement &domElement, const VPiece &d) const;
|
void AddDetail(QDomElement &domElement, const VPiece &d) const;
|
||||||
|
|
|
@ -51,7 +51,7 @@ SavePieceOptions::SavePieceOptions(const VPiece &oldDet, const VPiece &newDet, V
|
||||||
m_oldDet(oldDet),
|
m_oldDet(oldDet),
|
||||||
m_newDet(newDet)
|
m_newDet(newDet)
|
||||||
{
|
{
|
||||||
setText(tr("save detail option"));
|
setText(tr("save detail options"));
|
||||||
nodeId = id;
|
nodeId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,3 +144,38 @@ void SavePieceOptions::redo()
|
||||||
qCDebug(vUndo, "Can't find detail with id = %u.", nodeId);
|
qCDebug(vUndo, "Can't find detail with id = %u.", nodeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool SavePieceOptions::mergeWith(const QUndoCommand *command)
|
||||||
|
{
|
||||||
|
const SavePieceOptions *saveCommand = static_cast<const SavePieceOptions *>(command);
|
||||||
|
SCASSERT(saveCommand != nullptr);
|
||||||
|
|
||||||
|
if (saveCommand->DetId() != nodeId)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QSet<quint32> currentSet;
|
||||||
|
currentSet.fromList(m_newDet.Dependencies());
|
||||||
|
|
||||||
|
const VPiece candidate = saveCommand->NewDet();
|
||||||
|
const QSet<quint32> candidateSet;
|
||||||
|
candidateSet.fromList(candidate.Dependencies());
|
||||||
|
|
||||||
|
if (currentSet != candidateSet)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_newDet = saveCommand->NewDet();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int SavePieceOptions::id() const
|
||||||
|
{
|
||||||
|
return static_cast<int>(UndoCommand::SavePieceOptions);
|
||||||
|
}
|
||||||
|
|
|
@ -43,6 +43,10 @@ public:
|
||||||
|
|
||||||
virtual void undo() Q_DECL_OVERRIDE;
|
virtual void undo() Q_DECL_OVERRIDE;
|
||||||
virtual void redo() 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:
|
private:
|
||||||
Q_DISABLE_COPY(SavePieceOptions)
|
Q_DISABLE_COPY(SavePieceOptions)
|
||||||
|
|
||||||
|
@ -50,4 +54,16 @@ private:
|
||||||
VPiece m_newDet;
|
VPiece m_newDet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline quint32 SavePieceOptions::DetId() const
|
||||||
|
{
|
||||||
|
return nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline VPiece SavePieceOptions::NewDet() const
|
||||||
|
{
|
||||||
|
return m_newDet;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SAVEPIECEOPTIONS_H
|
#endif // SAVEPIECEOPTIONS_H
|
||||||
|
|
|
@ -35,15 +35,17 @@
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
#include "../vmisc/logging.h"
|
#include "../vmisc/logging.h"
|
||||||
#include "../tools/nodeDetails/vtoolpiecepath.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,
|
VAbstractPattern *doc, VContainer *data, quint32 id,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: VUndoCommand(QDomElement(), doc, parent),
|
: VUndoCommand(QDomElement(), doc, parent),
|
||||||
m_oldPath(oldPath),
|
m_oldPath(oldPath),
|
||||||
m_newPath(newPath),
|
m_newPath(newPath),
|
||||||
m_data(data)
|
m_data(data),
|
||||||
|
m_pieceId(pieceId)
|
||||||
{
|
{
|
||||||
setText(tr("save path options"));
|
setText(tr("save path options"));
|
||||||
nodeId = id;
|
nodeId = id;
|
||||||
|
@ -66,6 +68,14 @@ void SavePiecePathOptions::undo()
|
||||||
|
|
||||||
SCASSERT(m_data);
|
SCASSERT(m_data);
|
||||||
m_data->UpdatePiecePath(nodeId, m_oldPath);
|
m_data->UpdatePiecePath(nodeId, m_oldPath);
|
||||||
|
|
||||||
|
if (m_pieceId != NULL_ID)
|
||||||
|
{
|
||||||
|
if (VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(m_pieceId)))
|
||||||
|
{
|
||||||
|
tool->RefreshGeometry();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -90,9 +100,46 @@ void SavePiecePathOptions::redo()
|
||||||
|
|
||||||
SCASSERT(m_data);
|
SCASSERT(m_data);
|
||||||
m_data->UpdatePiecePath(nodeId, m_newPath);
|
m_data->UpdatePiecePath(nodeId, m_newPath);
|
||||||
|
|
||||||
|
if (m_pieceId != NULL_ID)
|
||||||
|
{
|
||||||
|
if (VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(m_pieceId)))
|
||||||
|
{
|
||||||
|
tool->RefreshGeometry();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Can't find path with id = %u.", nodeId);
|
qCDebug(vUndo, "Can't find path with id = %u.", nodeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool SavePiecePathOptions::mergeWith(const QUndoCommand *command)
|
||||||
|
{
|
||||||
|
const SavePiecePathOptions *saveCommand = static_cast<const SavePiecePathOptions *>(command);
|
||||||
|
SCASSERT(saveCommand != nullptr);
|
||||||
|
|
||||||
|
if (saveCommand->PathId() != nodeId)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QSet<quint32> currentSet;
|
||||||
|
currentSet.fromList(m_newPath.Dependencies());
|
||||||
|
|
||||||
|
const VPiecePath candidate = saveCommand->NewPath();
|
||||||
|
const QSet<quint32> candidateSet;
|
||||||
|
candidateSet.fromList(candidate.Dependencies());
|
||||||
|
|
||||||
|
if (currentSet != candidateSet)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_newPath = saveCommand->NewPath();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -37,12 +37,16 @@
|
||||||
class SavePiecePathOptions : public VUndoCommand
|
class SavePiecePathOptions : public VUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
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);
|
VContainer *data, quint32 id, QUndoCommand *parent = nullptr);
|
||||||
virtual ~SavePiecePathOptions() = default;
|
virtual ~SavePiecePathOptions() = default;
|
||||||
|
|
||||||
virtual void undo() Q_DECL_OVERRIDE;
|
virtual void undo() Q_DECL_OVERRIDE;
|
||||||
virtual void redo() 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:
|
private:
|
||||||
Q_DISABLE_COPY(SavePiecePathOptions)
|
Q_DISABLE_COPY(SavePiecePathOptions)
|
||||||
|
|
||||||
|
@ -50,6 +54,25 @@ private:
|
||||||
VPiecePath m_newPath;
|
VPiecePath m_newPath;
|
||||||
|
|
||||||
VContainer *m_data;
|
VContainer *m_data;
|
||||||
|
quint32 m_pieceId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline int SavePiecePathOptions::id() const
|
||||||
|
{
|
||||||
|
return static_cast<int>(UndoCommand::SavePiecePathOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline quint32 SavePiecePathOptions::PathId() const
|
||||||
|
{
|
||||||
|
return nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline VPiecePath SavePiecePathOptions::NewPath() const
|
||||||
|
{
|
||||||
|
return m_newPath;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SAVEPIECEPATHOPTIONS_H
|
#endif // SAVEPIECEPATHOPTIONS_H
|
||||||
|
|
|
@ -27,14 +27,17 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
#include "saveplacelabeloptions.h"
|
#include "saveplacelabeloptions.h"
|
||||||
#include "../tools/nodeDetails/vtoolplacelabel.h"
|
#include "../tools/nodeDetails/vtoolplacelabel.h"
|
||||||
|
#include "../tools/vtoolseamallowance.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
SavePlaceLabelOptions::SavePlaceLabelOptions(const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel,
|
SavePlaceLabelOptions::SavePlaceLabelOptions(quint32 pieceId, const VPlaceLabelItem &oldLabel,
|
||||||
VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent)
|
const VPlaceLabelItem &newLabel, VAbstractPattern *doc, VContainer *data,
|
||||||
|
quint32 id, QUndoCommand *parent)
|
||||||
: VUndoCommand(QDomElement(), doc, parent),
|
: VUndoCommand(QDomElement(), doc, parent),
|
||||||
m_oldLabel(oldLabel),
|
m_oldLabel(oldLabel),
|
||||||
m_newLabel(newLabel),
|
m_newLabel(newLabel),
|
||||||
m_data(data)
|
m_data(data),
|
||||||
|
m_pieceId(pieceId)
|
||||||
{
|
{
|
||||||
setText(tr("save place label options"));
|
setText(tr("save place label options"));
|
||||||
nodeId = id;
|
nodeId = id;
|
||||||
|
@ -58,6 +61,14 @@ void SavePlaceLabelOptions::undo()
|
||||||
|
|
||||||
SCASSERT(m_data);
|
SCASSERT(m_data);
|
||||||
m_data->UpdateGObject(nodeId, new VPlaceLabelItem(m_oldLabel));
|
m_data->UpdateGObject(nodeId, new VPlaceLabelItem(m_oldLabel));
|
||||||
|
|
||||||
|
if (m_pieceId != NULL_ID)
|
||||||
|
{
|
||||||
|
if (VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(m_pieceId)))
|
||||||
|
{
|
||||||
|
tool->RefreshGeometry();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -83,9 +94,41 @@ void SavePlaceLabelOptions::redo()
|
||||||
|
|
||||||
SCASSERT(m_data);
|
SCASSERT(m_data);
|
||||||
m_data->UpdateGObject(nodeId, new VPlaceLabelItem(m_newLabel));
|
m_data->UpdateGObject(nodeId, new VPlaceLabelItem(m_newLabel));
|
||||||
|
|
||||||
|
if (m_pieceId != NULL_ID)
|
||||||
|
{
|
||||||
|
if (VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(m_pieceId)))
|
||||||
|
{
|
||||||
|
tool->RefreshGeometry();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Can't find path with id = %u.", nodeId);
|
qCDebug(vUndo, "Can't find path with id = %u.", nodeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool SavePlaceLabelOptions::mergeWith(const QUndoCommand *command)
|
||||||
|
{
|
||||||
|
const SavePlaceLabelOptions *saveCommand = static_cast<const SavePlaceLabelOptions *>(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;
|
||||||
|
}
|
||||||
|
|
|
@ -34,12 +34,17 @@
|
||||||
class SavePlaceLabelOptions : public VUndoCommand
|
class SavePlaceLabelOptions : public VUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SavePlaceLabelOptions(const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel, VAbstractPattern *doc,
|
SavePlaceLabelOptions(quint32 pieceId, const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel,
|
||||||
VContainer *data, quint32 id, QUndoCommand *parent = nullptr);
|
VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent = nullptr);
|
||||||
virtual ~SavePlaceLabelOptions()=default;
|
virtual ~SavePlaceLabelOptions()=default;
|
||||||
|
|
||||||
virtual void undo() Q_DECL_OVERRIDE;
|
virtual void undo() Q_DECL_OVERRIDE;
|
||||||
virtual void redo() 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:
|
private:
|
||||||
Q_DISABLE_COPY(SavePlaceLabelOptions)
|
Q_DISABLE_COPY(SavePlaceLabelOptions)
|
||||||
|
|
||||||
|
@ -47,6 +52,25 @@ private:
|
||||||
VPlaceLabelItem m_newLabel;
|
VPlaceLabelItem m_newLabel;
|
||||||
|
|
||||||
VContainer *m_data;
|
VContainer *m_data;
|
||||||
|
quint32 m_pieceId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline int SavePlaceLabelOptions::id() const
|
||||||
|
{
|
||||||
|
return static_cast<int>(UndoCommand::SavePlaceLabelOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline quint32 SavePlaceLabelOptions::LabelId() const
|
||||||
|
{
|
||||||
|
return nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline VPlaceLabelItem SavePlaceLabelOptions::NewLabel() const
|
||||||
|
{
|
||||||
|
return m_newLabel;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SAVEPLACELABELOPTIONS_H
|
#endif // SAVEPLACELABELOPTIONS_H
|
||||||
|
|
|
@ -98,3 +98,31 @@ QVector<quint32> SaveToolOptions::Missing(const QList<quint32> &list1, const QLi
|
||||||
QSet<quint32> set2 = QSet<quint32>::fromList(list2);
|
QSet<quint32> set2 = QSet<quint32>::fromList(list2);
|
||||||
return set1.subtract(set2).toList().toVector();
|
return set1.subtract(set2).toList().toVector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool SaveToolOptions::mergeWith(const QUndoCommand *command)
|
||||||
|
{
|
||||||
|
const SaveToolOptions *saveCommand = static_cast<const SaveToolOptions *>(command);
|
||||||
|
SCASSERT(saveCommand != nullptr)
|
||||||
|
|
||||||
|
if (saveCommand->getToolId() != nodeId)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QSet<quint32> currentSet;
|
||||||
|
currentSet.fromList(newDependencies);
|
||||||
|
|
||||||
|
const QSet<quint32> candidateSet;
|
||||||
|
candidateSet.fromList(saveCommand->NewDependencies());
|
||||||
|
|
||||||
|
if (currentSet != candidateSet)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newXml = saveCommand->getNewXml();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -48,14 +48,44 @@ public:
|
||||||
virtual ~SaveToolOptions() = default;
|
virtual ~SaveToolOptions() = default;
|
||||||
virtual void undo() Q_DECL_OVERRIDE;
|
virtual void undo() Q_DECL_OVERRIDE;
|
||||||
virtual void redo() 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<quint32> NewDependencies() const;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(SaveToolOptions)
|
Q_DISABLE_COPY(SaveToolOptions)
|
||||||
const QDomElement oldXml;
|
const QDomElement oldXml;
|
||||||
const QDomElement newXml;
|
QDomElement newXml;
|
||||||
const QList<quint32> oldDependencies;
|
const QList<quint32> oldDependencies;
|
||||||
const QList<quint32> newDependencies;
|
const QList<quint32> newDependencies;
|
||||||
|
|
||||||
QVector<quint32> Missing(const QList<quint32> &list1, const QList<quint32> &list2) const;
|
QVector<quint32> Missing(const QList<quint32> &list1, const QList<quint32> &list2) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline int SaveToolOptions::id() const
|
||||||
|
{
|
||||||
|
return static_cast<int>(UndoCommand::SaveToolOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline QDomElement SaveToolOptions::getNewXml() const
|
||||||
|
{
|
||||||
|
return newXml;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline quint32 SaveToolOptions::getToolId() const
|
||||||
|
{
|
||||||
|
return nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline QList<quint32> SaveToolOptions::NewDependencies() const
|
||||||
|
{
|
||||||
|
return newDependencies;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SAVETOOLOPTIONS_H
|
#endif // SAVETOOLOPTIONS_H
|
||||||
|
|
|
@ -137,7 +137,7 @@ QString VisToolMove::Angle() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolMove::SetAngle(const QString &expression)
|
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)
|
void VisToolMove::SetLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->DataVariables());
|
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -207,7 +207,7 @@ QString VisToolRotation::Angle() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolRotation::SetAngle(const QString &expression)
|
void VisToolRotation::SetAngle(const QString &expression)
|
||||||
{
|
{
|
||||||
angle = FindVal(expression, Visualization::data->DataVariables());
|
angle = FindValFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -66,7 +66,7 @@ void VisToolAlongLine::setObject2Id(const quint32 &value)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolAlongLine::setLength(const QString &expression)
|
void VisToolAlongLine::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->DataVariables());
|
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -72,7 +72,7 @@ void VisToolBisector::setObject3Id(const quint32 &value)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolBisector::setLength(const QString &expression)
|
void VisToolBisector::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->DataVariables());
|
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -105,7 +105,7 @@ QString VisToolCurveIntersectAxis::Angle() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolCurveIntersectAxis::SetAngle(const QString &expression)
|
void VisToolCurveIntersectAxis::SetAngle(const QString &expression)
|
||||||
{
|
{
|
||||||
angle = FindVal(expression, Visualization::data->DataVariables());
|
angle = FindValFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -96,7 +96,7 @@ QString VisToolEndLine::Angle() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolEndLine::SetAngle(const QString &expression)
|
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)
|
void VisToolEndLine::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->DataVariables());
|
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ QString VisToolLineIntersectAxis::Angle() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolLineIntersectAxis::SetAngle(const QString &expression)
|
void VisToolLineIntersectAxis::SetAngle(const QString &expression)
|
||||||
{
|
{
|
||||||
angle = FindVal(expression, Visualization::data->DataVariables());
|
angle = FindValFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -110,7 +110,7 @@ void VisToolNormal::setObject2Id(const quint32 &value)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolNormal::setLength(const QString &expression)
|
void VisToolNormal::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->DataVariables());
|
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -92,7 +92,7 @@ void VisToolPointFromCircleAndTangent::setObject2Id(const quint32 &value)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolPointFromCircleAndTangent::setCRadius(const QString &value)
|
void VisToolPointFromCircleAndTangent::setCRadius(const QString &value)
|
||||||
{
|
{
|
||||||
cRadius = FindLength(value, Visualization::data->DataVariables());
|
cRadius = FindLengthFromUser(value, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -108,5 +108,5 @@ void VisToolPointOfContact::setRadiusId(const quint32 &value)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolPointOfContact::setRadius(const QString &expression)
|
void VisToolPointOfContact::setRadius(const QString &expression)
|
||||||
{
|
{
|
||||||
radius = FindLength(expression, Visualization::data->DataVariables());
|
radius = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,13 +111,13 @@ void VisToolPointOfIntersectionCircles::setObject2Id(const quint32 &value)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolPointOfIntersectionCircles::setC1Radius(const QString &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)
|
void VisToolPointOfIntersectionCircles::setC2Radius(const QString &value)
|
||||||
{
|
{
|
||||||
c2Radius = FindLength(value, Visualization::data->DataVariables());
|
c2Radius = FindLengthFromUser(value, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -129,5 +129,5 @@ void VisToolShoulderPoint::setLineP2Id(const quint32 &value)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolShoulderPoint::setLength(const QString &expression)
|
void VisToolShoulderPoint::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->DataVariables());
|
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,17 +70,17 @@ void VisToolArc::RefreshGeometry()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolArc::setRadius(const QString &expression)
|
void VisToolArc::setRadius(const QString &expression)
|
||||||
{
|
{
|
||||||
radius = FindLength(expression, Visualization::data->DataVariables());
|
radius = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolArc::setF1(const QString &expression)
|
void VisToolArc::setF1(const QString &expression)
|
||||||
{
|
{
|
||||||
f1 = FindVal(expression, Visualization::data->DataVariables());
|
f1 = FindValFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolArc::setF2(const QString &expression)
|
void VisToolArc::setF2(const QString &expression)
|
||||||
{
|
{
|
||||||
f2 = FindVal(expression, Visualization::data->DataVariables());
|
f2 = FindValFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,17 +69,17 @@ void VisToolArcWithLength::RefreshGeometry()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolArcWithLength::setRadius(const QString &expression)
|
void VisToolArcWithLength::setRadius(const QString &expression)
|
||||||
{
|
{
|
||||||
radius = FindLength(expression, Visualization::data->DataVariables());
|
radius = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolArcWithLength::setF1(const QString &expression)
|
void VisToolArcWithLength::setF1(const QString &expression)
|
||||||
{
|
{
|
||||||
f1 = FindVal(expression, Visualization::data->DataVariables());
|
f1 = FindValFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolArcWithLength::setLength(const QString &expression)
|
void VisToolArcWithLength::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->DataVariables());
|
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,5 +82,5 @@ void VisToolCutArc::RefreshGeometry()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolCutArc::setLength(const QString &expression)
|
void VisToolCutArc::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->DataVariables());
|
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,5 +90,5 @@ void VisToolCutSpline::RefreshGeometry()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolCutSpline::setLength(const QString &expression)
|
void VisToolCutSpline::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->DataVariables());
|
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,5 +91,5 @@ void VisToolCutSplinePath::RefreshGeometry()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolCutSplinePath::setLength(const QString &expression)
|
void VisToolCutSplinePath::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLength(expression, Visualization::data->DataVariables());
|
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,29 +65,29 @@ void VisToolEllipticalArc::RefreshGeometry()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolEllipticalArc::setRadius1(const QString &expression)
|
void VisToolEllipticalArc::setRadius1(const QString &expression)
|
||||||
{
|
{
|
||||||
radius1 = FindLength(expression, Visualization::data->DataVariables());
|
radius1 = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolEllipticalArc::setRadius2(const QString &expression)
|
void VisToolEllipticalArc::setRadius2(const QString &expression)
|
||||||
{
|
{
|
||||||
radius2 = FindLength(expression, Visualization::data->DataVariables());
|
radius2 = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolEllipticalArc::setF1(const QString &expression)
|
void VisToolEllipticalArc::setF1(const QString &expression)
|
||||||
{
|
{
|
||||||
f1 = FindVal(expression, Visualization::data->DataVariables());
|
f1 = FindValFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolEllipticalArc::setF2(const QString &expression)
|
void VisToolEllipticalArc::setF2(const QString &expression)
|
||||||
{
|
{
|
||||||
f2 = FindVal(expression, Visualization::data->DataVariables());
|
f2 = FindValFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolEllipticalArc::setRotationAngle(const QString &expression)
|
void VisToolEllipticalArc::setRotationAngle(const QString &expression)
|
||||||
{
|
{
|
||||||
rotationAngle = FindVal(expression, Visualization::data->DataVariables());
|
rotationAngle = FindValFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,15 +143,15 @@ VScaledEllipse *Visualization::InitPoint(const QColor &color, QGraphicsItem *par
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qreal Visualization::FindLength(const QString &expression,
|
qreal Visualization::FindLengthFromUser(const QString &expression,
|
||||||
const QHash<QString, QSharedPointer<VInternalVariable> > *vars)
|
const QHash<QString, QSharedPointer<VInternalVariable> > *vars, bool fromUser)
|
||||||
{
|
{
|
||||||
return qApp->toPixel(FindVal(expression, vars));
|
return qApp->toPixel(FindValFromUser(expression, vars, fromUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qreal Visualization::FindVal(const QString &expression,
|
qreal Visualization::FindValFromUser(const QString &expression,
|
||||||
const QHash<QString, QSharedPointer<VInternalVariable> > *vars)
|
const QHash<QString, QSharedPointer<VInternalVariable> > *vars, bool fromUser)
|
||||||
{
|
{
|
||||||
qreal val = 0;
|
qreal val = 0;
|
||||||
if (expression.isEmpty())
|
if (expression.isEmpty())
|
||||||
|
@ -165,7 +165,11 @@ qreal Visualization::FindVal(const QString &expression,
|
||||||
// Replace line return with spaces for calc if exist
|
// Replace line return with spaces for calc if exist
|
||||||
QString formula = expression;
|
QString formula = expression;
|
||||||
formula.replace("\n", " ");
|
formula.replace("\n", " ");
|
||||||
formula = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
|
if (fromUser)
|
||||||
|
{
|
||||||
|
formula = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
|
||||||
|
}
|
||||||
|
|
||||||
QScopedPointer<Calculator> cal(new Calculator());
|
QScopedPointer<Calculator> cal(new Calculator());
|
||||||
val = cal->EvalFormula(vars, formula);
|
val = cal->EvalFormula(vars, formula);
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,10 @@ public:
|
||||||
Mode GetMode() const;
|
Mode GetMode() const;
|
||||||
void SetMode(const Mode &value);
|
void SetMode(const Mode &value);
|
||||||
|
|
||||||
static qreal FindLength(const QString &expression, const QHash<QString, QSharedPointer<VInternalVariable> > *vars);
|
static qreal FindLengthFromUser(const QString &expression, const QHash<QString,
|
||||||
static qreal FindVal(const QString &expression, const QHash<QString, QSharedPointer<VInternalVariable> > *vars);
|
QSharedPointer<VInternalVariable> > *vars, bool fromUser = true);
|
||||||
|
static qreal FindValFromUser(const QString &expression, const QHash<QString,
|
||||||
|
QSharedPointer<VInternalVariable> > *vars, bool fromUser = true);
|
||||||
signals:
|
signals:
|
||||||
void ToolTip(const QString &toolTip);
|
void ToolTip(const QString &toolTip);
|
||||||
public slots:
|
public slots:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user