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) QGraphicsItem *parent)
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, 0, parent), secondPointId(secondPointId) :VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, 0, parent), secondPointId(secondPointId)
{ {
ToolCreation(typeCreation);
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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), :VToolLinePoint(doc, data, id, typeLine, lineColor, formulaLength, basePointId, 0, parent),
formulaAngle(formulaAngle) formulaAngle(formulaAngle)
{ {
if (typeCreation == Source::FromGui) ToolCreation(typeCreation);
{
AddToFile();
}
else
{
RefreshDataInFile();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

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), :VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), p1LineId(p1LineId),
p2LineId(p2LineId) p2LineId(p2LineId)
{ {
if (typeCreation == Source::FromGui) ToolCreation(typeCreation);
{
AddToFile();
}
else
{
RefreshDataInFile();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

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

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), :VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
p2Line2(p2Line2) p2Line2(p2Line2)
{ {
if (typeCreation == Source::FromGui) ToolCreation(typeCreation);
{
AddToFile();
}
else
{
RefreshDataInFile();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

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

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), :VToolLinePoint(doc, data, id, typeLine, lineColor, formula, p1Line, 0, parent), p2Line(p2Line),
pShoulder(pShoulder) pShoulder(pShoulder)
{ {
if (typeCreation == Source::FromGui) ToolCreation(typeCreation);
{
AddToFile();
}
else
{
RefreshDataInFile();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

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

View File

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

View File

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

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), :VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId),
secondPointId(secondPointId) secondPointId(secondPointId)
{ {
if (typeCreation == Source::FromGui) ToolCreation(typeCreation);
{
AddToFile();
}
else
{
RefreshDataInFile();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

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. * @brief Styles return list of all line styles.

View File

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

View File

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