Method for refreshing attributes in file.

--HG--
branch : feature
This commit is contained in:
dismine 2013-12-24 13:24:29 +02:00
parent cdf2e02eef
commit 5e94742b06
45 changed files with 514 additions and 1 deletions

View File

@ -43,6 +43,10 @@ VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, c
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolAlongLine::FullUpdateFromFile() void VToolAlongLine::FullUpdateFromFile()
@ -106,6 +110,22 @@ void VToolAlongLine::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolAlongLine::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrMx, toMM(point.mx()));
domElement.setAttribute(AttrMy, toMM(point.my()));
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrTypeLine, typeLine);
domElement.setAttribute(AttrLength, formula);
domElement.setAttribute(AttrFirstPoint, basePointId);
domElement.setAttribute(AttrSecondPoint, secondPointId);
}
}
void VToolAlongLine::RemoveReferens() void VToolAlongLine::RemoveReferens()
{ {
doc->DecrementReferens(secondPointId); doc->DecrementReferens(secondPointId);

View File

@ -116,6 +116,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief RemoveReferens * @brief RemoveReferens
*/ */

View File

@ -49,6 +49,10 @@ VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::S
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolArc::setDialog() void VToolArc::setDialog()
@ -199,6 +203,19 @@ void VToolArc::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolArc::RefreshDataInFile()
{
VArc arc = VAbstractTool::data.GetArc(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrCenter, arc.GetCenter());
domElement.setAttribute(AttrRadius, arc.GetFormulaRadius());
domElement.setAttribute(AttrAngle1, arc.GetFormulaF1());
domElement.setAttribute(AttrAngle2, arc.GetFormulaF2());
}
}
void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)

View File

@ -125,6 +125,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief mouseReleaseEvent * @brief mouseReleaseEvent
* @param event * @param event

View File

@ -45,6 +45,10 @@ VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
@ -204,6 +208,23 @@ void VToolBisector::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolBisector::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrMx, toMM(point.mx()));
domElement.setAttribute(AttrMy, toMM(point.my()));
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrTypeLine, typeLine);
domElement.setAttribute(AttrLength, formula);
domElement.setAttribute(AttrFirstPoint, firstPointId);
domElement.setAttribute(AttrSecondPoint, basePointId);
domElement.setAttribute(AttrThirdPoint, thirdPointId);
}
}
void VToolBisector::RemoveReferens() void VToolBisector::RemoveReferens()
{ {
doc->DecrementReferens(firstPointId); doc->DecrementReferens(firstPointId);

View File

@ -129,6 +129,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief RemoveReferens * @brief RemoveReferens
*/ */

View File

@ -58,6 +58,10 @@ VToolCutSpline::VToolCutSpline(VDomDocument *doc, VContainer *data, const qint64
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolCutSpline::setDialog() void VToolCutSpline::setDialog()
@ -222,6 +226,20 @@ void VToolCutSpline::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolCutSpline::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrMx, toMM(point.mx()));
domElement.setAttribute(AttrMy, toMM(point.my()));
domElement.setAttribute(AttrLength, formula);
domElement.setAttribute(AttrSpline, splineId);
}
}
void VToolCutSpline::RefreshGeometry() void VToolCutSpline::RefreshGeometry()
{ {
RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint); RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint);

View File

@ -119,6 +119,13 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RefreshGeometry
*/
void RefreshGeometry(); void RefreshGeometry();
private: private:
Q_DISABLE_COPY(VToolCutSpline) Q_DISABLE_COPY(VToolCutSpline)

View File

@ -60,6 +60,10 @@ VToolCutSplinePath::VToolCutSplinePath(VDomDocument *doc, VContainer *data, cons
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolCutSplinePath::setDialog() void VToolCutSplinePath::setDialog()
@ -289,6 +293,20 @@ void VToolCutSplinePath::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolCutSplinePath::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrMx, toMM(point.mx()));
domElement.setAttribute(AttrMy, toMM(point.my()));
domElement.setAttribute(AttrLength, formula);
domElement.setAttribute(AttrSplinePath, splinePathId);
}
}
void VToolCutSplinePath::RefreshGeometry() void VToolCutSplinePath::RefreshGeometry()
{ {
RefreshSpline(firstSpline, splPath1id, SimpleSpline::ForthPoint); RefreshSpline(firstSpline, splPath1id, SimpleSpline::ForthPoint);

View File

@ -109,6 +109,13 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RefreshGeometry
*/
void RefreshGeometry(); void RefreshGeometry();
private: private:
Q_DISABLE_COPY(VToolCutSplinePath) Q_DISABLE_COPY(VToolCutSplinePath)

View File

@ -43,6 +43,10 @@ VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolEndLine::setDialog() void VToolEndLine::setDialog()
@ -166,3 +170,19 @@ void VToolEndLine::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolEndLine::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrMx, toMM(point.mx()));
domElement.setAttribute(AttrMy, toMM(point.my()));
domElement.setAttribute(AttrTypeLine, typeLine);
domElement.setAttribute(AttrLength, formula);
domElement.setAttribute(AttrAngle, angle);
domElement.setAttribute(AttrBasePoint, basePointId);
}
}

View File

@ -111,6 +111,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
private: private:
/** /**
* @brief dialogEndLine pointer to the dialog * @brief dialogEndLine pointer to the dialog

View File

@ -41,6 +41,10 @@ VToolHeight::VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id,
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolHeight::setDialog() void VToolHeight::setDialog()
@ -187,3 +191,19 @@ void VToolHeight::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolHeight::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrMx, toMM(point.mx()));
domElement.setAttribute(AttrMy, toMM(point.my()));
domElement.setAttribute(AttrTypeLine, typeLine);
domElement.setAttribute(AttrBasePoint, basePointId);
domElement.setAttribute(AttrP1Line, p1LineId);
domElement.setAttribute(AttrP2Line, p2LineId);
}
}

View File

@ -118,6 +118,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
private: private:
/** /**
* @brief dialogHeight * @brief dialogHeight

View File

@ -49,6 +49,10 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolLine::setDialog() void VToolLine::setDialog()
@ -166,6 +170,16 @@ void VToolLine::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolLine::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrFirstPoint, firstPoint);
domElement.setAttribute(AttrSecondPoint, secondPoint);
}
}
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);

View File

@ -120,6 +120,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief hoverMoveEvent * @brief hoverMoveEvent
* @param event * @param event

View File

@ -42,6 +42,10 @@ VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, cons
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolLineIntersect::setDialog() void VToolLineIntersect::setDialog()
@ -184,6 +188,22 @@ void VToolLineIntersect::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolLineIntersect::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrMx, toMM(point.mx()));
domElement.setAttribute(AttrMy, toMM(point.my()));
domElement.setAttribute(AttrP1Line1, p1Line1);
domElement.setAttribute(AttrP2Line1, p2Line1);
domElement.setAttribute(AttrP1Line2, p1Line2);
domElement.setAttribute(AttrP2Line2, p2Line2);
}
}
void VToolLineIntersect::RemoveReferens() void VToolLineIntersect::RemoveReferens()
{ {
doc->DecrementReferens(p1Line1); doc->DecrementReferens(p1Line1);

View File

@ -116,6 +116,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief RemoveReferens * @brief RemoveReferens
*/ */

View File

@ -42,7 +42,10 @@ VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolNormal::setDialog() void VToolNormal::setDialog()
@ -190,6 +193,23 @@ void VToolNormal::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolNormal::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrMx, toMM(point.mx()));
domElement.setAttribute(AttrMy, toMM(point.my()));
domElement.setAttribute(AttrTypeLine, typeLine);
domElement.setAttribute(AttrLength, formula);
domElement.setAttribute(AttrAngle, angle);
domElement.setAttribute(AttrFirstPoint, basePointId);
domElement.setAttribute(AttrSecondPoint, secondPointId);
}
}
void VToolNormal::RemoveReferens() void VToolNormal::RemoveReferens()
{ {
doc->DecrementReferens(secondPointId); doc->DecrementReferens(secondPointId);

View File

@ -130,6 +130,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief RemoveReferens * @brief RemoveReferens
*/ */

View File

@ -42,6 +42,10 @@ VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, co
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolPointOfContact::setDialog() void VToolPointOfContact::setDialog()
@ -207,6 +211,22 @@ void VToolPointOfContact::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolPointOfContact::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrMx, toMM(point.mx()));
domElement.setAttribute(AttrMy, toMM(point.my()));
domElement.setAttribute(AttrRadius, radius);
domElement.setAttribute(AttrCenter, center);
domElement.setAttribute(AttrFirstPoint, firstPointId);
domElement.setAttribute(AttrSecondPoint, secondPointId);
}
}
void VToolPointOfContact::RemoveReferens() void VToolPointOfContact::RemoveReferens()
{ {
doc->DecrementReferens(center); doc->DecrementReferens(center);

View File

@ -126,6 +126,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief RemoveReferens * @brief RemoveReferens
*/ */

View File

@ -41,6 +41,10 @@ VToolPointOfIntersection::VToolPointOfIntersection(VDomDocument *doc, VContainer
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolPointOfIntersection::setDialog() void VToolPointOfIntersection::setDialog()
@ -152,3 +156,17 @@ void VToolPointOfIntersection::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolPointOfIntersection::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrName, toMM(point.mx()));
domElement.setAttribute(AttrName, toMM(point.my()));
domElement.setAttribute(AttrFirstPoint, firstPointId);
domElement.setAttribute(AttrSecondPoint, secondPointId);
}
}

View File

@ -111,6 +111,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
private: private:
Q_DISABLE_COPY(VToolPointOfIntersection) Q_DISABLE_COPY(VToolPointOfIntersection)
/** /**

View File

@ -42,6 +42,10 @@ VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, cons
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolShoulderPoint::setDialog() void VToolShoulderPoint::setDialog()
@ -211,6 +215,23 @@ void VToolShoulderPoint::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolShoulderPoint::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrName, toMM(point.mx()));
domElement.setAttribute(AttrName, toMM(point.my()));
domElement.setAttribute(AttrTypeLine, typeLine);
domElement.setAttribute(AttrLength, formula);
domElement.setAttribute(AttrP1Line, basePointId);
domElement.setAttribute(AttrP2Line, p2Line);
domElement.setAttribute(AttrPShoulder, pShoulder);
}
}
void VToolShoulderPoint::RemoveReferens() void VToolShoulderPoint::RemoveReferens()
{ {
doc->DecrementReferens(p2Line); doc->DecrementReferens(p2Line);

View File

@ -128,6 +128,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief RemoveReferens * @brief RemoveReferens
*/ */

View File

@ -41,6 +41,10 @@ VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolSinglePoint::setDialog() void VToolSinglePoint::setDialog()
@ -66,6 +70,20 @@ void VToolSinglePoint::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolSinglePoint::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrX, QString().setNum(toMM(point.x())));
domElement.setAttribute(AttrY, QString().setNum(toMM(point.y())));
domElement.setAttribute(AttrMx, QString().setNum(toMM(point.mx())));
domElement.setAttribute(AttrMy, QString().setNum(toMM(point.my())));
}
}
QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
if (change == ItemPositionChange && scene()) if (change == ItemPositionChange && scene())

View File

@ -92,6 +92,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief itemChange * @brief itemChange
* @param change * @param change

View File

@ -68,6 +68,10 @@ VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, const T
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolSpline::setDialog() void VToolSpline::setDialog()
@ -222,6 +226,22 @@ void VToolSpline::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolSpline::RefreshDataInFile()
{
VSpline spl = VAbstractTool::data.GetSpline(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrPoint1, QString().setNum(spl.GetP1()));
domElement.setAttribute(AttrPoint4, QString().setNum(spl.GetP4()));
domElement.setAttribute(AttrAngle1, QString().setNum(spl.GetAngle1()));
domElement.setAttribute(AttrAngle2, QString().setNum(spl.GetAngle2()));
domElement.setAttribute(AttrKAsm1, QString().setNum(spl.GetKasm1()));
domElement.setAttribute(AttrKAsm2, QString().setNum(spl.GetKasm2()));
domElement.setAttribute(AttrKCurve, QString().setNum(spl.GetKcurve()));
}
}
void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)

View File

@ -153,6 +153,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile (); virtual void AddToFile ();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief mouseReleaseEvent * @brief mouseReleaseEvent
* @param event * @param event

View File

@ -69,6 +69,10 @@ VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolSplinePath::setDialog() void VToolSplinePath::setDialog()
@ -271,6 +275,39 @@ void VToolSplinePath::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolSplinePath::RefreshDataInFile()
{
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
for (qint32 i = 1; i<=splPath.Count(); ++i)
{
VSpline spl = splPath.GetSpline(i);
qint32 j = i*2;
disconnect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
disconnect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
controlPoints[j-2]->setPos(spl.GetP2());
controlPoints[j-1]->setPos(spl.GetP3());
connect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
spl = VSpline (VAbstractTool::data.DataPoints(), spl.GetP1(), controlPoints[j-2]->pos(),
controlPoints[j-1]->pos(), spl.GetP4(), splPath.getKCurve());
CorectControlPoints(spl, splPath, i);
CorectControlPoints(spl, splPath, i);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrKCurve, QString().setNum(splPath.getKCurve()));
UpdatePathPoint(domElement, splPath);
}
}
}
void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint) void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint)
{ {
QDomElement pathPoint = doc->createElement(AttrPathPoint); QDomElement pathPoint = doc->createElement(AttrPathPoint);

View File

@ -145,6 +145,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief mouseReleaseEvent * @brief mouseReleaseEvent
* @param event * @param event

View File

@ -41,6 +41,10 @@ VToolTriangle::VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VToolTriangle::setDialog() void VToolTriangle::setDialog()
@ -212,3 +216,19 @@ void VToolTriangle::AddToFile()
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolTriangle::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point.name());
domElement.setAttribute(AttrMx, toMM(point.mx()));
domElement.setAttribute(AttrMy, toMM(point.my()));
domElement.setAttribute(AttrAxisP1, QString().setNum(axisP1Id));
domElement.setAttribute(AttrAxisP2, QString().setNum(axisP2Id));
domElement.setAttribute(AttrFirstPoint, QString().setNum(firstPointId));
domElement.setAttribute(AttrSecondPoint, QString().setNum(secondPointId));
}
}

View File

@ -125,6 +125,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
private: private:
Q_DISABLE_COPY(VToolTriangle) Q_DISABLE_COPY(VToolTriangle)
/** /**

View File

@ -44,6 +44,10 @@ VNodeArc::VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc,
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, const Document::Documents &parse, void VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, const Document::Documents &parse,
@ -78,6 +82,15 @@ void VNodeArc::AddToFile()
AddToModeling(domElement); AddToModeling(domElement);
} }
void VNodeArc::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrIdObject, QString().setNum(idNode));
}
}
void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)

View File

@ -79,6 +79,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief mouseReleaseEvent * @brief mouseReleaseEvent
* @param event * @param event

View File

@ -51,6 +51,10 @@ VNodePoint::VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 id
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, void VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint,
@ -88,6 +92,18 @@ void VNodePoint::AddToFile()
AddToModeling(domElement); AddToModeling(domElement);
} }
void VNodePoint::RefreshDataInFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrIdObject, QString().setNum(idNode));
domElement.setAttribute(AttrMx, QString().setNum(toMM(point.mx())));
domElement.setAttribute(AttrMy, QString().setNum(toMM(point.my())));
}
}
void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)

View File

@ -96,6 +96,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief mouseReleaseEvent * @brief mouseReleaseEvent
* @param event * @param event

View File

@ -44,6 +44,10 @@ VNodeSpline::VNodeSpline(VDomDocument *doc, VContainer *data, qint64 id, qint64
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
VNodeSpline *VNodeSpline::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, VNodeSpline *VNodeSpline::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
@ -79,6 +83,15 @@ void VNodeSpline::AddToFile()
AddToModeling(domElement); AddToModeling(domElement);
} }
void VNodeSpline::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrIdObject, QString().setNum(idNode));
}
}
void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)

View File

@ -80,6 +80,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile (); virtual void AddToFile ();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief mouseReleaseEvent * @brief mouseReleaseEvent
* @param event * @param event

View File

@ -44,6 +44,10 @@ VNodeSplinePath::VNodeSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
{ {
AddToFile(); AddToFile();
} }
else
{
RefreshDataInFile();
}
} }
void VNodeSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, void VNodeSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
@ -83,6 +87,15 @@ void VNodeSplinePath::AddToFile()
AddToModeling(domElement); AddToModeling(domElement);
} }
void VNodeSplinePath::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrIdObject, QString().setNum(idNode));
}
}
void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)

View File

@ -79,6 +79,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief mouseReleaseEvent * @brief mouseReleaseEvent
* @param event * @param event

View File

@ -285,6 +285,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile()=0; virtual void AddToFile()=0;
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile()=0;
/** /**
* @brief getData * @brief getData
* @return * @return

View File

@ -215,6 +215,24 @@ void VToolDetail::AddToFile()
} }
} }
void VToolDetail::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
VDetail det = VAbstractTool::data.GetDetail(id);
domElement.setAttribute(AttrName, det.getName());
domElement.setAttribute(AttrSupplement, QString().setNum(det.getSupplement()));
domElement.setAttribute(AttrClosed, QString().setNum(det.getClosed()));
domElement.setAttribute(AttrWidth, QString().setNum(det.getWidth()));
RemoveAllChild(domElement);
for (ptrdiff_t i = 0; i < det.CountNode(); ++i)
{
AddNode(domElement, det[i]);
}
}
}
QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
if (change == ItemPositionHasChanged && scene()) if (change == ItemPositionHasChanged && scene())

View File

@ -156,6 +156,10 @@ protected:
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile (); virtual void AddToFile ();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/** /**
* @brief itemChange * @brief itemChange
* @param change * @param change