--HG--
branch : develop
This commit is contained in:
dismine 2014-02-17 14:07:22 +02:00
commit ee9356207e

View File

@ -723,7 +723,16 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
Q_CHECK_PTR(scene);
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");
if (type == VToolSinglePoint::ToolType)
QStringList points;
points << VToolSinglePoint::ToolType << VToolEndLine::ToolType << VToolAlongLine::ToolType
<< VToolShoulderPoint::ToolType << VToolNormal::ToolType << VToolBisector::ToolType
<< VToolLineIntersect::ToolType << VToolPointOfContact::ToolType << VNodePoint::ToolType
<< VToolHeight::ToolType << VToolTriangle::ToolType << VToolPointOfIntersection::ToolType
<< VToolCutSpline::ToolType << VToolCutSplinePath::ToolType << VToolCutArc::ToolType;
switch(points.indexOf(type)) {
case 0: //VToolSinglePoint::ToolType
{
VToolSinglePoint *spoint = 0;
try
@ -750,7 +759,6 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
tools[id] = spoint;
}
return;
}
catch (const VExceptionBadId &e)
{
@ -760,9 +768,9 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
delete spoint;
throw excep;
}
break;
}
if (type == VToolEndLine::ToolType)
{
case 1: //VToolEndLine::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -774,9 +782,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 basePointId = GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0");
qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this, data, parse,
Tool::FromFile);
return;
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId,
mx, my, scene, this, data, parse, Tool::FromFile);
}
catch (const VExceptionBadId &e)
{
@ -784,9 +791,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolAlongLine::ToolType)
{
break;
case 2: //VToolAlongLine::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -800,7 +806,6 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, scene, this, data,
parse, Tool::FromFile);
return;
}
catch (const VExceptionBadId &e)
{
@ -808,9 +813,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolShoulderPoint::ToolType)
{
break;
case 3: //VToolShoulderPoint::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -825,7 +829,6 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this,
data, parse, Tool::FromFile);
return;
}
catch (const VExceptionBadId &e)
{
@ -833,9 +836,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolNormal::ToolType)
{
break;
case 4: //VToolNormal::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -848,9 +850,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene, this,
data, parse, Tool::FromFile);
return;
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name,
angle, mx, my, scene, this,data, parse, Tool::FromFile);
}
catch (const VExceptionBadId &e)
{
@ -858,9 +859,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolBisector::ToolType)
{
break;
case 5: //VToolBisector::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -873,9 +873,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
qint64 thirdPointId = GetParametrLongLong(domElement, VAbstractTool::AttrThirdPoint, "0");
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine, name, mx, my, scene,
this, data, parse, Tool::FromFile);
return;
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId,
typeLine, name, mx, my, scene, this, data, parse, Tool::FromFile);
}
catch (const VExceptionBadId &e)
{
@ -883,9 +882,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolLineIntersect::ToolType)
{
break;
case 6: //VToolLineIntersect::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -897,9 +895,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 p1Line2Id = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line2, "0");
qint64 p2Line2Id = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line2, "0");
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my, scene, this, data,
parse, Tool::FromFile);
return;
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name,
mx, my, scene, this, data, parse, Tool::FromFile);
}
catch (const VExceptionBadId &e)
{
@ -907,9 +904,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolPointOfContact::ToolType)
{
break;
case 7: //VToolPointOfContact::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -921,9 +917,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, scene, this,
data, parse, Tool::FromFile);
return;
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name,
mx, my, scene, this,data, parse, Tool::FromFile);
}
catch (const VExceptionBadId &e)
{
@ -931,9 +926,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VNodePoint::ToolType)
{
break;
case 8: //VNodePoint::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -942,10 +936,9 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
const VPointF *point = data->GeometricObject<const VPointF *>(idObject );
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), mx, my, idObject,
Draw::Modeling));
data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(),
mx, my, idObject,Draw::Modeling));
VNodePoint::Create(this, data, id, idObject, parse, Tool::FromFile, idTool);
return;
}
catch (const VExceptionBadId &e)
{
@ -953,9 +946,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolHeight::ToolType)
{
break;
case 9: //VToolHeight::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -967,9 +959,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 p1LineId = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line, "0");
qint64 p2LineId = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line, "0");
VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, mx, my, scene, this, data, parse,
Tool::FromFile);
return;
VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId,
mx, my, scene, this, data, parse, Tool::FromFile);
}
catch (const VExceptionBadId &e)
{
@ -977,9 +968,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolTriangle::ToolType)
{
break;
case 10: //VToolTriangle::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1001,9 +991,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolPointOfIntersection::ToolType)
{
break;
case 11: //VToolPointOfIntersection::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1013,9 +1002,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, scene, this, data, parse,
Tool::FromFile);
return;
VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId,
mx, my, scene, this, data, parse,Tool::FromFile);
}
catch (const VExceptionBadId &e)
{
@ -1023,9 +1011,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolCutSpline::ToolType)
{
break;
case 12: //VToolCutSpline::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1044,9 +1031,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolCutSplinePath::ToolType)
{
break;
case 13: //VToolCutSplinePath::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1056,9 +1042,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
qint64 splinePathId = GetParametrLongLong(domElement, VToolCutSplinePath::AttrSplinePath, "0");
VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my, scene, this, data, parse,
Tool::FromFile);
return;
VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my,
scene, this, data, parse, Tool::FromFile);
}
catch (const VExceptionBadId &e)
{
@ -1066,9 +1051,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolCutArc::ToolType)
{
break;
case 14: //VToolCutArc::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1079,7 +1063,6 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 arcId = GetParametrLongLong(domElement, VToolCutArc::AttrArc, "0");
VToolCutArc::Create(id, name, formula, arcId, mx, my, scene, this, data, parse, Tool::FromFile);
return;
}
catch (const VExceptionBadId &e)
{
@ -1087,6 +1070,10 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
break;
default:
qWarning() << "Illegal point type in VDomDocument::ParsePointElement().";
break;
}
}
@ -1118,8 +1105,11 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
Q_CHECK_PTR(scene);
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");
if (type == VToolSpline::ToolType)
{
QStringList splines;
splines << VToolSpline::ToolType << VToolSplinePath::ToolType << VNodeSpline::ToolType << VNodeSplinePath::ToolType;
switch(splines.indexOf(type)) {
case 0: //VToolSpline::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1131,9 +1121,7 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
qreal kAsm2 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm2, "1.0");
qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0");
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data, parse,
Tool::FromFile);
return;
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data, parse,Tool::FromFile);
}
catch (const VExceptionBadId &e)
{
@ -1141,9 +1129,8 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VToolSplinePath::ToolType)
{
break;
case 1: //VToolSplinePath::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1180,7 +1167,6 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
}
VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile);
return;
}
catch (const VExceptionBadId &e)
{
@ -1188,9 +1174,8 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VNodeSpline::ToolType)
{
break;
case 2: //VNodeSpline::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1202,7 +1187,6 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
spl->setMode(Draw::Modeling);
data->UpdateGObject(id, spl);
VNodeSpline::Create(this, data, id, idObject, parse, Tool::FromFile, idTool);
return;
}
catch (const VExceptionBadId &e)
{
@ -1210,9 +1194,8 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VNodeSplinePath::ToolType)
{
break;
case 3: //VNodeSplinePath::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1224,7 +1207,6 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
path->setMode(Draw::Modeling);
data->UpdateGObject(id, path);
VNodeSplinePath::Create(this, data, id, idObject, parse, Tool::FromFile, idTool);
return;
}
catch (const VExceptionBadId &e)
{
@ -1232,6 +1214,10 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
break;
default:
qWarning() << "Illegal spline type in VDomDocument::ParseSplineElement().";
break;
}
}
@ -1241,8 +1227,12 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
Q_CHECK_PTR(scene);
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");
if (type == VToolArc::ToolType)
{
QStringList arcs;
arcs << VToolArc::ToolType << VNodeArc::ToolType;
switch(arcs.indexOf(type)) {
case 0: //VToolArc::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1252,8 +1242,6 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270");
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile);
return;
}
catch (const VExceptionBadId &e)
{
@ -1261,9 +1249,8 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == VNodeArc::ToolType)
{
break;
case 1: //VNodeArc::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1275,7 +1262,6 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
arc->setMode(Draw::Modeling);
data->UpdateGObject(id, arc);
VNodeArc::Create(this, data, id, idObject, parse, Tool::FromFile, idTool);
return;
}
catch (const VExceptionBadId &e)
{
@ -1283,6 +1269,10 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
break;
default:
qWarning() << "Illegal arc type in VDomDocument::ParseArcElement().";
break;
}
}
@ -1292,8 +1282,12 @@ void VDomDocument::ParseToolsElement(VMainGraphicsScene *scene, const QDomElemen
Q_CHECK_PTR(scene);
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");
if (type == VToolUnionDetails::ToolType)
{
QStringList tools;
tools << VToolUnionDetails::ToolType;
switch(tools.indexOf(type)) {
case 0: //VToolUnionDetails::ToolType
try
{
qint64 id = GetParametrId(domElement);
@ -1304,8 +1298,6 @@ void VDomDocument::ParseToolsElement(VMainGraphicsScene *scene, const QDomElemen
VToolUnionDetails::Create(id, vector[0], vector[1], 0, 0, indexD1, indexD2, scene, this, data, parse,
Tool::FromFile);
return;
}
catch (const VExceptionBadId &e)
{
@ -1313,6 +1305,10 @@ void VDomDocument::ParseToolsElement(VMainGraphicsScene *scene, const QDomElemen
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
break;
default:
qWarning() << "Illegal tools type in VDomDocument::ParseToolsElement().";
break;
}
}