Refactoring.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-05-28 13:16:59 +03:00
parent 7e490b6d60
commit 9145d4d4f1
28 changed files with 40 additions and 209 deletions

View File

@ -54,15 +54,7 @@ VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, cons
QGraphicsItem *parent)
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, 0, parent), secondPointId(secondPointId)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -60,14 +60,7 @@ VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const QString &c
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -58,14 +58,7 @@ VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const quint32 &id,
this->firstPointId = firstPointId;
this->thirdPointId = thirdPointId;
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -45,14 +45,7 @@ VToolCurveIntersectAxis::VToolCurveIntersectAxis(VPattern *doc, VContainer *data
:VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle),
curveId(curveId)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -57,14 +57,7 @@ VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, con
RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -55,14 +55,7 @@ VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &i
RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -58,14 +58,7 @@ VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const qu
RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -55,14 +55,7 @@ VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id,
:VToolLinePoint(doc, data, id, typeLine, lineColor, formulaLength, basePointId, 0, parent),
formulaAngle(formulaAngle)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -52,14 +52,7 @@ VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, con
:VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), p1LineId(p1LineId),
p2LineId(p2LineId)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -64,14 +64,7 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP
this->setAcceptHoverEvents(true);
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -53,14 +53,7 @@ VToolLineIntersect::VToolLineIntersect(VPattern *doc, VContainer *data, const qu
:VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
p2Line2(p2Line2)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -45,14 +45,7 @@ VToolLineIntersectAxis::VToolLineIntersectAxis(VPattern *doc, VContainer *data,
:VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle),
firstPointId(firstPointId), secondPointId(secondPointId)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -56,14 +56,7 @@ VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, con
secondPointId(secondPointId)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -56,14 +56,7 @@ VToolPointOfContact::VToolPointOfContact(VPattern *doc, VContainer *data, const
: VToolPoint(doc, data, id, parent), arcRadius(radius), center(center), firstPointId(firstPointId),
secondPointId(secondPointId)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -49,14 +49,7 @@ VToolPointOfIntersection::VToolPointOfIntersection(VPattern *doc, VContainer *da
const Source &typeCreation, QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -41,14 +41,7 @@ VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VPattern *doc, VConta
QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -55,14 +55,7 @@ VToolShoulderPoint::VToolShoulderPoint(VPattern *doc, VContainer *data, const qu
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, p1Line, 0, parent), p2Line(p2Line),
pShoulder(pShoulder)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -58,14 +58,7 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id,
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, false);
SetColorLabel(Qt::black);
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -85,14 +85,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QStr
ShowHandles(false);
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -87,14 +87,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
ShowHandles(false);
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -53,14 +53,7 @@ VToolTriangle::VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id,
:VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId),
secondPointId(secondPointId)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -55,14 +55,7 @@ VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, c
RefreshGeometry();
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())));
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -65,14 +65,7 @@ VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPo
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true);
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -56,14 +56,7 @@ VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 id
RefreshGeometry();
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())));
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -56,14 +56,7 @@ VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, qu
RefreshGeometry();
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())));
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -351,6 +351,19 @@ void VAbstractTool::SaveOption(QSharedPointer<VGObject> &obj)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractTool::ToolCreation(const Source &typeCreation)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Styles return list of all line styles.

View File

@ -186,6 +186,7 @@ protected:
}
virtual void SetVisualization()=0;
void ToolCreation(const Source &typeCreation);
private:
Q_DISABLE_COPY(VAbstractTool)
};

View File

@ -64,14 +64,7 @@ VToolUnionDetails::VToolUnionDetails(VPattern *doc, VContainer *data, const quin
const Source &typeCreation, QObject *parent)
:VAbstractTool(doc, data, id, parent), d1(d1), d2(d2), indexD1(indexD1), indexD2(indexD2)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------