Refactoring. Delete repetitive code.
--HG-- branch : feature
This commit is contained in:
parent
95422546b6
commit
717fabed9a
|
@ -96,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails);
|
doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails);
|
||||||
connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear);
|
connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear);
|
||||||
|
connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified);
|
||||||
connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile);
|
connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile);
|
||||||
|
|
||||||
connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified);
|
connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified);
|
||||||
|
|
|
@ -214,7 +214,7 @@ bool VPattern::SetNameDraw(const QString &name)
|
||||||
{
|
{
|
||||||
nameActivDraw = name;
|
nameActivDraw = name;
|
||||||
element.setAttribute(AttrName, nameActivDraw);
|
element.setAttribute(AttrName, nameActivDraw);
|
||||||
emit patternChanged();
|
emit patternChanged(false);
|
||||||
emit ChangedNameDraw(oldName, nameActivDraw);
|
emit ChangedNameDraw(oldName, nameActivDraw);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ void VPattern::SetPath(const QString &path)
|
||||||
if (element.isElement())
|
if (element.isElement())
|
||||||
{
|
{
|
||||||
SetAttribute(element, AttrPath, path);
|
SetAttribute(element, AttrPath, path);
|
||||||
emit patternChanged();
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -706,7 +706,7 @@ void VPattern::LiteParseTree()
|
||||||
*/
|
*/
|
||||||
void VPattern::haveLiteChange()
|
void VPattern::haveLiteChange()
|
||||||
{
|
{
|
||||||
emit patternChanged();
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -936,6 +936,29 @@ void VPattern::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my,
|
||||||
|
QString &typeLine)
|
||||||
|
{
|
||||||
|
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||||
|
typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my)
|
||||||
|
{
|
||||||
|
PointsCommonAttributes(domElement, id, mx, my);
|
||||||
|
name = GetParametrString(domElement, VAbstractTool::AttrName, "A");
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my)
|
||||||
|
{
|
||||||
|
ToolsCommonAttributes(domElement, id);
|
||||||
|
mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
||||||
|
my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief ParsePointElement parse point tag.
|
* @brief ParsePointElement parse point tag.
|
||||||
|
@ -951,6 +974,11 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
||||||
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty");
|
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty");
|
||||||
|
|
||||||
|
quint32 id = 0;
|
||||||
|
QString name;
|
||||||
|
qreal mx = 0;
|
||||||
|
qreal my = 0;
|
||||||
|
QString typeLine;
|
||||||
|
|
||||||
QStringList points{VToolSinglePoint::ToolType, VToolEndLine::ToolType, VToolAlongLine::ToolType,
|
QStringList points{VToolSinglePoint::ToolType, VToolEndLine::ToolType, VToolAlongLine::ToolType,
|
||||||
VToolShoulderPoint::ToolType, VToolNormal::ToolType, VToolBisector::ToolType,
|
VToolShoulderPoint::ToolType, VToolNormal::ToolType, VToolBisector::ToolType,
|
||||||
|
@ -964,12 +992,9 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
VToolSinglePoint *spoint = 0;
|
VToolSinglePoint *spoint = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "A");
|
|
||||||
const qreal x = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrX, "10.0"));
|
const qreal x = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrX, "10.0"));
|
||||||
const qreal y = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrY, "10.0"));
|
const qreal y = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrY, "10.0"));
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
|
|
||||||
data->UpdateGObject(id, new VPointF(x, y, name, mx, my));
|
data->UpdateGObject(id, new VPointF(x, y, name, mx, my));
|
||||||
VDrawTool::AddRecord(id, Tool::SinglePointTool, this);
|
VDrawTool::AddRecord(id, Tool::SinglePointTool, this);
|
||||||
|
@ -999,12 +1024,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 1: //VToolEndLine::ToolType
|
case 1: //VToolEndLine::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
||||||
VAbstractTool::TypeLineLine);
|
|
||||||
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
||||||
QString f = formula;//need for saving fixed formula;
|
QString f = formula;//need for saving fixed formula;
|
||||||
|
|
||||||
|
@ -1036,12 +1056,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 2: //VToolAlongLine::ToolType
|
case 2: //VToolAlongLine::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
||||||
VAbstractTool::TypeLineLine);
|
|
||||||
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
||||||
QString f = formula;//need for saving fixed formula;
|
QString f = formula;//need for saving fixed formula;
|
||||||
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||||
|
@ -1072,12 +1087,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 3: //VToolShoulderPoint::ToolType
|
case 3: //VToolShoulderPoint::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
||||||
VAbstractTool::TypeLineLine);
|
|
||||||
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
||||||
QString f = formula;//need for saving fixed formula;
|
QString f = formula;//need for saving fixed formula;
|
||||||
const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
|
const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
|
||||||
|
@ -1109,12 +1119,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 4: //VToolNormal::ToolType
|
case 4: //VToolNormal::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
||||||
VAbstractTool::TypeLineLine);
|
|
||||||
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
||||||
QString f = formula;//need for saving fixed formula;
|
QString f = formula;//need for saving fixed formula;
|
||||||
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||||
|
@ -1146,12 +1151,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 5: //VToolBisector::ToolType
|
case 5: //VToolBisector::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
||||||
VAbstractTool::TypeLineLine);
|
|
||||||
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
||||||
QString f = formula;//need for saving fixed formula;
|
QString f = formula;//need for saving fixed formula;
|
||||||
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||||
|
@ -1183,10 +1183,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 6: //VToolLineIntersect::ToolType
|
case 6: //VToolLineIntersect::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const quint32 p1Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0");
|
const quint32 p1Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0");
|
||||||
const quint32 p2Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0");
|
const quint32 p2Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0");
|
||||||
const quint32 p1Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0");
|
const quint32 p1Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0");
|
||||||
|
@ -1205,10 +1202,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 7: //VToolPointOfContact::ToolType
|
case 7: //VToolPointOfContact::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0");
|
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0");
|
||||||
QString f = radius;//need for saving fixed formula;
|
QString f = radius;//need for saving fixed formula;
|
||||||
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
|
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
|
||||||
|
@ -1240,12 +1234,10 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 8: //VNodePoint::ToolType
|
case 8: //VNodePoint::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, mx, my);
|
||||||
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
||||||
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
||||||
const VPointF *point = data->GeometricObject<const VPointF *>(idObject );
|
const VPointF *point = data->GeometricObject<const VPointF *>(idObject );
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), mx, my, idObject,
|
data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), mx, my, idObject,
|
||||||
Draw::Modeling));
|
Draw::Modeling));
|
||||||
VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
|
VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
|
||||||
|
@ -1260,12 +1252,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 9: //VToolHeight::ToolType
|
case 9: //VToolHeight::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
||||||
VAbstractTool::TypeLineLine);
|
|
||||||
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
|
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
|
||||||
const quint32 p1LineId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
|
const quint32 p1LineId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
|
||||||
const quint32 p2LineId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
|
const quint32 p2LineId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
|
||||||
|
@ -1283,10 +1270,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 10: //VToolTriangle::ToolType
|
case 10: //VToolTriangle::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const quint32 axisP1Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0");
|
const quint32 axisP1Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0");
|
||||||
const quint32 axisP2Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0");
|
const quint32 axisP2Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0");
|
||||||
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||||
|
@ -1305,10 +1289,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 11: //VToolPointOfIntersection::ToolType
|
case 11: //VToolPointOfIntersection::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||||
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
||||||
|
|
||||||
|
@ -1325,10 +1306,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 12: //VToolCutSpline::ToolType
|
case 12: //VToolCutSpline::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
||||||
QString f = formula;//need for saving fixed formula;
|
QString f = formula;//need for saving fixed formula;
|
||||||
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0");
|
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0");
|
||||||
|
@ -1357,10 +1335,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 13: //VToolCutSplinePath::ToolType
|
case 13: //VToolCutSplinePath::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
||||||
QString f = formula;//need for saving fixed formula;
|
QString f = formula;//need for saving fixed formula;
|
||||||
const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0");
|
const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0");
|
||||||
|
@ -1390,10 +1365,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
||||||
case 14: //VToolCutArc::ToolType
|
case 14: //VToolCutArc::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||||
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
||||||
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
||||||
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
||||||
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
||||||
QString f = formula;//need for saving fixed formula;
|
QString f = formula;//need for saving fixed formula;
|
||||||
const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0");
|
const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0");
|
||||||
|
@ -1437,9 +1409,10 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do
|
||||||
{
|
{
|
||||||
SCASSERT(scene != nullptr);
|
SCASSERT(scene != nullptr);
|
||||||
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
||||||
|
quint32 id = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
ToolsCommonAttributes(domElement, id);
|
||||||
const quint32 firstPoint = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
const quint32 firstPoint = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||||
const quint32 secondPoint = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
const quint32 secondPoint = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
||||||
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
||||||
|
@ -1455,6 +1428,14 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPattern::SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool)
|
||||||
|
{
|
||||||
|
ToolsCommonAttributes(domElement, id);
|
||||||
|
idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
||||||
|
idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief ParseSplineElement parse spline tag.
|
* @brief ParseSplineElement parse spline tag.
|
||||||
|
@ -1470,6 +1451,10 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
|
||||||
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
||||||
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
|
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
|
||||||
|
|
||||||
|
quint32 id = 0;
|
||||||
|
quint32 idObject = 0;
|
||||||
|
quint32 idTool = 0;
|
||||||
|
|
||||||
QStringList splines{VToolSpline::ToolType, VToolSplinePath::ToolType, VNodeSpline::ToolType,
|
QStringList splines{VToolSpline::ToolType, VToolSplinePath::ToolType, VNodeSpline::ToolType,
|
||||||
VNodeSplinePath::ToolType};
|
VNodeSplinePath::ToolType};
|
||||||
switch (splines.indexOf(type))
|
switch (splines.indexOf(type))
|
||||||
|
@ -1477,7 +1462,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
|
||||||
case 0: //VToolSpline::ToolType
|
case 0: //VToolSpline::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
ToolsCommonAttributes(domElement, id);
|
||||||
const quint32 point1 = GetParametrUInt(domElement, VAbstractTool::AttrPoint1, "0");
|
const quint32 point1 = GetParametrUInt(domElement, VAbstractTool::AttrPoint1, "0");
|
||||||
const quint32 point4 = GetParametrUInt(domElement, VAbstractTool::AttrPoint4, "0");
|
const quint32 point4 = GetParametrUInt(domElement, VAbstractTool::AttrPoint4, "0");
|
||||||
const qreal angle1 = GetParametrDouble(domElement, VAbstractTool::AttrAngle1, "270.0");
|
const qreal angle1 = GetParametrDouble(domElement, VAbstractTool::AttrAngle1, "270.0");
|
||||||
|
@ -1499,7 +1484,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
|
||||||
case 1: //VToolSplinePath::ToolType
|
case 1: //VToolSplinePath::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
ToolsCommonAttributes(domElement, id);
|
||||||
const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0");
|
const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0");
|
||||||
VSplinePath *path = new VSplinePath(kCurve);
|
VSplinePath *path = new VSplinePath(kCurve);
|
||||||
|
|
||||||
|
@ -1543,9 +1528,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
|
||||||
case 2: //VNodeSpline::ToolType
|
case 2: //VNodeSpline::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
SplinesCommonAttributes(domElement, id, idObject, idTool);
|
||||||
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
|
||||||
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
|
||||||
VSpline *spl = new VSpline(*data->GeometricObject<const VSpline *>(idObject));
|
VSpline *spl = new VSpline(*data->GeometricObject<const VSpline *>(idObject));
|
||||||
spl->setIdObject(idObject);
|
spl->setIdObject(idObject);
|
||||||
spl->setMode(Draw::Modeling);
|
spl->setMode(Draw::Modeling);
|
||||||
|
@ -1562,9 +1545,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
|
||||||
case 3: //VNodeSplinePath::ToolType
|
case 3: //VNodeSplinePath::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
SplinesCommonAttributes(domElement, id, idObject, idTool);
|
||||||
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
|
||||||
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
|
||||||
VSplinePath *path = new VSplinePath(*data->GeometricObject<const VSplinePath *>(idObject));
|
VSplinePath *path = new VSplinePath(*data->GeometricObject<const VSplinePath *>(idObject));
|
||||||
path->setIdObject(idObject);
|
path->setIdObject(idObject);
|
||||||
path->setMode(Draw::Modeling);
|
path->setMode(Draw::Modeling);
|
||||||
|
@ -1599,6 +1580,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen
|
||||||
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
||||||
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
|
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
|
||||||
|
|
||||||
|
quint32 id = 0;
|
||||||
QStringList arcs{VToolArc::ToolType, VNodeArc::ToolType};
|
QStringList arcs{VToolArc::ToolType, VNodeArc::ToolType};
|
||||||
|
|
||||||
switch (arcs.indexOf(type))
|
switch (arcs.indexOf(type))
|
||||||
|
@ -1606,7 +1588,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen
|
||||||
case 0: //VToolArc::ToolType
|
case 0: //VToolArc::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
ToolsCommonAttributes(domElement, id);
|
||||||
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
|
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
|
||||||
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10");
|
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10");
|
||||||
QString r = radius;//need for saving fixed formula;
|
QString r = radius;//need for saving fixed formula;
|
||||||
|
@ -1641,7 +1623,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen
|
||||||
case 1: //VNodeArc::ToolType
|
case 1: //VNodeArc::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
ToolsCommonAttributes(domElement, id);
|
||||||
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
||||||
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
||||||
VArc *arc = new VArc(*data->GeometricObject<const VArc *>(idObject));
|
VArc *arc = new VArc(*data->GeometricObject<const VArc *>(idObject));
|
||||||
|
@ -1678,6 +1660,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d
|
||||||
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
||||||
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
|
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
|
||||||
|
|
||||||
|
quint32 id = 0;
|
||||||
QStringList tools{VToolUnionDetails::ToolType};
|
QStringList tools{VToolUnionDetails::ToolType};
|
||||||
|
|
||||||
switch (tools.indexOf(type))
|
switch (tools.indexOf(type))
|
||||||
|
@ -1685,7 +1668,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d
|
||||||
case 0: //VToolUnionDetails::ToolType
|
case 0: //VToolUnionDetails::ToolType
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const quint32 id = GetParametrId(domElement);
|
ToolsCommonAttributes(domElement, id);
|
||||||
const quint32 indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1");
|
const quint32 indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1");
|
||||||
const quint32 indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1");
|
const quint32 indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1");
|
||||||
|
|
||||||
|
@ -1863,6 +1846,12 @@ void VPattern::GarbageCollector()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPattern::ToolsCommonAttributes(const QDomElement &domElement, quint32 &id)
|
||||||
|
{
|
||||||
|
id = GetParametrId(domElement);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QDomElement VPattern::GetPPElement(const QString &name)
|
QDomElement VPattern::GetPPElement(const QString &name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -130,7 +130,7 @@ signals:
|
||||||
/**
|
/**
|
||||||
* @brief patternChanged emit if we have unsaved change.
|
* @brief patternChanged emit if we have unsaved change.
|
||||||
*/
|
*/
|
||||||
void patternChanged();
|
void patternChanged(bool saved);
|
||||||
/**
|
/**
|
||||||
* @brief ShowTool highlight tool.
|
* @brief ShowTool highlight tool.
|
||||||
* @param id tool id.
|
* @param id tool id.
|
||||||
|
@ -199,6 +199,14 @@ private:
|
||||||
void PrepareForParse(const Document &parse);
|
void PrepareForParse(const Document &parse);
|
||||||
void UpdateMeasurements();
|
void UpdateMeasurements();
|
||||||
void GarbageCollector();
|
void GarbageCollector();
|
||||||
|
void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id);
|
||||||
|
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx,
|
||||||
|
qreal &my, QString &typeLine);
|
||||||
|
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx,
|
||||||
|
qreal &my);
|
||||||
|
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my);
|
||||||
|
void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject,
|
||||||
|
quint32 &idTool);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user