Refactoring. Method VDrawTool::AddRecord has sense to call only when do

Document::FullParse.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-02-13 08:55:42 +02:00
parent 8814c07d14
commit a8bd44b63a
42 changed files with 71 additions and 42 deletions

View File

@ -132,9 +132,9 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(const quint32 _id, quint32 orig
quint32 id = _id;
CreateDestination(typeCreation, id, dest, source, fPoint, sPoint, suffix, doc, data, parse);
VDrawTool::AddRecord(id, Tool::FlippingByAxis, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::FlippingByAxis, doc);
VToolFlippingByAxis *tool = new VToolFlippingByAxis(doc, data, id, originPointId, axisType, suffix, source,
dest, typeCreation);
scene->addItem(tool);

View File

@ -126,9 +126,9 @@ VToolFlippingByLine *VToolFlippingByLine::Create(const quint32 _id, quint32 firs
quint32 id = _id;
CreateDestination(typeCreation, id, dest, source, fPoint, sPoint, suffix, doc, data, parse);
VDrawTool::AddRecord(id, Tool::FlippingByLine, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::FlippingByLine, doc);
VToolFlippingByLine *tool = new VToolFlippingByLine(doc, data, id, firstLinePointId, secondLinePointId, suffix,
source, dest, typeCreation);
scene->addItem(tool);

View File

@ -227,9 +227,9 @@ QT_WARNING_POP
}
}
VDrawTool::AddRecord(id, Tool::Move, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::Move, doc);
VToolMove *tool = new VToolMove(doc, data, id, formulaAngle, formulaLength, suffix, source, dest,
typeCreation);
scene->addItem(tool);

View File

@ -238,9 +238,9 @@ QT_WARNING_POP
}
}
VDrawTool::AddRecord(id, Tool::Rotation, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::Rotation, doc);
VToolRotation *tool = new VToolRotation(doc, data, id, origin, angle, suffix, source, dest, typeCreation);
scene->addItem(tool);
InitOperationToolConnections(scene, tool);

View File

@ -170,9 +170,10 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::Arc, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::Arc, doc);
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
scene->addItem(toolArc);
InitArcToolConnections(scene, toolArc);

View File

@ -140,9 +140,10 @@ VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::ArcWithLength, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::ArcWithLength, doc);
VToolArcWithLength *toolArc = new VToolArcWithLength(doc, data, id, typeCreation);
scene->addItem(toolArc);
InitArcToolConnections(scene, toolArc);

View File

@ -128,9 +128,10 @@ VToolCubicBezier *VToolCubicBezier::Create(const quint32 _id, VCubicBezier *spli
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::CubicBezier, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::CubicBezier, doc);
auto _spl = new VToolCubicBezier(doc, data, id, typeCreation);
scene->addItem(_spl);
InitSplineToolConnections(scene, _spl);

View File

@ -133,9 +133,10 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(const quint32 _id, VCubicBezi
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::CubicBezierPath, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::CubicBezierPath, doc);
VToolCubicBezierPath *spl = new VToolCubicBezierPath(doc, data, id, typeCreation);
scene->addItem(spl);
InitSplinePathToolConnections(scene, spl);

View File

@ -184,9 +184,10 @@ VToolEllipticalArc* VToolEllipticalArc::Create(const quint32 _id, const quint32
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::EllipticalArc, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::EllipticalArc, doc);
VToolEllipticalArc *toolEllipticalArc = new VToolEllipticalArc(doc, data, id, typeCreation);
scene->addItem(toolEllipticalArc);
InitElArcToolConnections(scene, toolEllipticalArc);

View File

@ -207,9 +207,10 @@ VToolSpline* VToolSpline::Create(const quint32 _id, VSpline *spline, const QStri
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::Spline, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::Spline, doc);
auto _spl = new VToolSpline(doc, data, id, typeCreation);
scene->addItem(_spl);
InitSplineToolConnections(scene, _spl);

View File

@ -218,9 +218,10 @@ VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, c
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::SplinePath, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::SplinePath, doc);
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation);
scene->addItem(spl);
InitSplinePathToolConnections(scene, spl);

View File

@ -189,9 +189,10 @@ VToolTrueDarts *VToolTrueDarts::Create(quint32 _id,
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::TrueDarts, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::TrueDarts, doc);
VToolTrueDarts *points = new VToolTrueDarts(doc, data, id, p1id, p2id, baseLineP1Id, baseLineP2Id,
dartP1Id, dartP2Id, dartP3Id, typeCreation);
scene->addItem(points);

View File

@ -170,9 +170,9 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
}
}
VDrawTool::AddRecord(id, Tool::CutArc, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::CutArc, doc);
VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, typeCreation);
scene->addItem(point);
InitToolConnections(scene, point);

View File

@ -170,9 +170,10 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::CutSpline, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::CutSpline, doc);
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, typeCreation);
scene->addItem(point);
InitToolConnections(scene, point);

View File

@ -182,9 +182,9 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
}
}
VDrawTool::AddRecord(id, Tool::CutSplinePath, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::CutSplinePath, doc);
VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, typeCreation);
scene->addItem(point);
InitToolConnections(scene, point);

View File

@ -299,10 +299,11 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::AlongLine, doc);
VToolAlongLine *point = nullptr;
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::AlongLine, doc);
point = new VToolAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine, lineColor,
typeCreation);
scene->addItem(point);

View File

@ -217,9 +217,10 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::Bisector, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::Bisector, doc);
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, lineColor, formula, firstPointId,
secondPointId, thirdPointId, typeCreation);
scene->addItem(point);

View File

@ -167,9 +167,10 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, cons
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::CurveIntersectAxis, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::CurveIntersectAxis, doc);
VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle,
basePointId, curveId, typeCreation);
scene->addItem(point);

View File

@ -181,9 +181,10 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::EndLine, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::EndLine, doc);
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, lineColor, formulaLength, formulaAngle,
basePointId, typeCreation);
scene->addItem(point);

View File

@ -174,9 +174,10 @@ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, co
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::Height, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::Height, doc);
VToolHeight *point = new VToolHeight(doc, data, id, typeLine, lineColor, basePointId, p1LineId, p2LineId,
typeCreation);
scene->addItem(point);

View File

@ -154,9 +154,10 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::LineIntersectAxis, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::LineIntersectAxis, doc);
VToolLineIntersectAxis *point = new VToolLineIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle,
basePointId, firstPointId, secondPointId,
typeCreation);

View File

@ -177,9 +177,10 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::Normal, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::Normal, doc);
VToolNormal *point = new VToolNormal(doc, data, id, typeLine, lineColor, formula, angle, firstPointId,
secondPointId, typeCreation);
scene->addItem(point);

View File

@ -222,9 +222,10 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::ShoulderPoint, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::ShoulderPoint, doc);
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, lineColor, formula,
p1Line, p2Line, pShoulder,
typeCreation);

View File

@ -136,9 +136,10 @@ VToolBasePoint *VToolBasePoint::Create(quint32 _id, const QString &nameActivPP,
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::BasePoint, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::BasePoint, doc);
VToolBasePoint *spoint = new VToolBasePoint(doc, data, id, typeCreation, nameActivPP);
scene->addItem(spoint);
InitToolConnections(scene, spoint);

View File

@ -182,9 +182,10 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::LineIntersect, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::LineIntersect, doc);
VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id,
p2Line2Id, typeCreation);
scene->addItem(point);

View File

@ -125,9 +125,10 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(const quint32 _
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::PointFromArcAndTangent, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::PointFromArcAndTangent, doc);
VToolPointFromArcAndTangent *point = new VToolPointFromArcAndTangent(doc, data, id, arcId, tangentPointId,
crossPoint, typeCreation);
scene->addItem(point);

View File

@ -134,9 +134,10 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const qui
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::PointFromCircleAndTangent, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::PointFromCircleAndTangent, doc);
VToolPointFromCircleAndTangent *point = new VToolPointFromCircleAndTangent(doc, data, id, circleCenterId,
circleRadius, tangentPointId,
crossPoint, typeCreation);

View File

@ -239,9 +239,10 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::PointOfContact, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::PointOfContact, doc);
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center,
firstPointId, secondPointId, typeCreation);
scene->addItem(point);

View File

@ -157,9 +157,10 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, co
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::PointOfIntersection, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::PointOfIntersection, doc);
VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId,
secondPointId, typeCreation);
scene->addItem(point);

View File

@ -125,9 +125,10 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::PointOfIntersectionArcs, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::PointOfIntersectionArcs, doc);
VToolPointOfIntersectionArcs *point = new VToolPointOfIntersectionArcs(doc, data, id, firstArcId,
secondArcId, pType, typeCreation);
scene->addItem(point);

View File

@ -144,9 +144,10 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(const q
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::PointOfIntersectionCircles, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::PointOfIntersectionCircles, doc);
VToolPointOfIntersectionCircles *point = new VToolPointOfIntersectionCircles(doc, data, id, firstCircleCenterId,
secondCircleCenterId,
firstCircleRadius,

View File

@ -135,9 +135,10 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(const qui
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::PointOfIntersectionCurves, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::PointOfIntersectionCurves, doc);
auto point = new VToolPointOfIntersectionCurves(doc, data, id, firstCurveId, secondCurveId, vCrossPoint,
hCrossPoint, typeCreation);
scene->addItem(point);

View File

@ -168,9 +168,10 @@ VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::Triangle, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::Triangle, doc);
VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId,
secondPointId, typeCreation);
scene->addItem(point);

View File

@ -169,9 +169,10 @@ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, con
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::Line, doc);
if (parse == Document::FullParse)
{
VDrawTool::AddRecord(id, Tool::Line, doc);
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, lineColor, typeCreation);
scene->addItem(line);
InitDrawToolConnections(scene, line);

View File

@ -73,9 +73,9 @@ VNodeArc::VNodeArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32
void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc,
const Document &parse, const Source &typeCreation, const QString &drawName, const quint32 &idTool)
{
VAbstractTool::AddRecord(id, Tool::NodeArc, doc);
if (parse == Document::FullParse)
{
VAbstractTool::AddRecord(id, Tool::NodeArc, doc);
VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeCreation, drawName, idTool, doc);
doc->AddTool(id, arc);

View File

@ -46,9 +46,9 @@ void VNodeEllipticalArc::Create(VAbstractPattern *doc, VContainer *data, quint32
const Document &parse, const Source &typeCreation, const QString &drawName,
const quint32 &idTool)
{
VAbstractTool::AddRecord(id, Tool::NodeElArc, doc);
if (parse == Document::FullParse)
{
VAbstractTool::AddRecord(id, Tool::NodeElArc, doc);
VNodeEllipticalArc *arc = new VNodeEllipticalArc(doc, data, id, idArc, typeCreation, drawName, idTool, doc);
doc->AddTool(id, arc);

View File

@ -112,9 +112,9 @@ void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsSc
quint32 id, quint32 idPoint, const Document &parse,
const Source &typeCreation, const QString &drawName, const quint32 &idTool)
{
VAbstractTool::AddRecord(id, Tool::NodePoint, doc);
if (parse == Document::FullParse)
{
VAbstractTool::AddRecord(id, Tool::NodePoint, doc);
//TODO Need create garbage collector and remove all nodes, what we don't use.
//Better check garbage before each saving file. Check only modeling tags.
VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, drawName, idTool, doc);

View File

@ -77,10 +77,10 @@ VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, quint3
quint32 idSpline, const Document &parse,
const Source &typeCreation, const QString &drawName, const quint32 &idTool)
{
VAbstractTool::AddRecord(id, Tool::NodeSpline, doc);
VNodeSpline *spl = nullptr;
if (parse == Document::FullParse)
{
VAbstractTool::AddRecord(id, Tool::NodeSpline, doc);
spl = new VNodeSpline(doc, data, id, idSpline, typeCreation, drawName, idTool, doc);
doc->AddTool(id, spl);

View File

@ -77,9 +77,9 @@ void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, quint32 id
quint32 idSpline, const Document &parse, const Source &typeCreation,
const QString &drawName, const quint32 &idTool)
{
VAbstractTool::AddRecord(id, Tool::NodeSplinePath, doc);
if (parse == Document::FullParse)
{
VAbstractTool::AddRecord(id, Tool::NodeSplinePath, doc);
VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeCreation, drawName, idTool, doc);
doc->AddTool(id, splPath);

View File

@ -68,9 +68,9 @@ VToolPiecePath *VToolPiecePath::Create(quint32 _id, const VPiecePath &path, quin
}
}
VAbstractTool::AddRecord(id, Tool::PiecePath, doc);
if (parse == Document::FullParse)
{
VAbstractTool::AddRecord(id, Tool::PiecePath, doc);
//TODO Need create garbage collector and remove all nodes, that we don't use.
//Better check garbage before each saving file. Check only modeling tags.
VToolPiecePath *pathTool = new VToolPiecePath(doc, data, id, pieceId, typeCreation, drawName, idTool, doc);

View File

@ -127,10 +127,11 @@ VToolSeamAllowance *VToolSeamAllowance::Create(quint32 id, VPiece newPiece, QStr
doc->UpdateToolData(id, data);
}
}
VAbstractTool::AddRecord(id, Tool::Piece, doc);
VToolSeamAllowance *piece = nullptr;
if (parse == Document::FullParse)
{
VAbstractTool::AddRecord(id, Tool::Piece, doc);
piece = new VToolSeamAllowance(doc, data, id, typeCreation, scene, drawName);
scene->addItem(piece);
connect(piece, &VToolSeamAllowance::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);

View File

@ -1375,9 +1375,9 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VToolUnion
}
//First add tool to file
VAbstractTool::AddRecord(id, Tool::UnionDetails, initData.doc);
if (initData.parse == Document::FullParse)
{
VAbstractTool::AddRecord(id, Tool::UnionDetails, initData.doc);
//Scene doesn't show this tool, so doc will destroy this object.
unionDetails = new VToolUnionDetails(id, initData);
initData.doc->AddTool(id, unionDetails);