Refactoring. Also read attribute color from xml.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-02-06 19:43:31 +02:00
parent b8e7cbd1ac
commit f687105905
42 changed files with 230 additions and 110 deletions

View File

@ -68,6 +68,7 @@ QString VAbstractSpline::getTagName() const
*/
void VAbstractSpline::FullUpdateFromFile()
{
ReadAttributes();
RefreshGeometry();
}
@ -212,6 +213,12 @@ QPainterPath VAbstractSpline::ToolPath(PathDirection direction) const
return path;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::ReadToolAttributes(const QDomElement &domElement)
{
lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::ShowFoot(bool show)
{

View File

@ -86,6 +86,7 @@ protected:
virtual void keyReleaseEvent(QKeyEvent * event);
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const;
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
Q_DISABLE_COPY(VAbstractSpline)
};

View File

@ -158,7 +158,7 @@ void VDrawTool::RefreshDataInFile()
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
qCDebug(vTool)<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
@ -175,6 +175,20 @@ QColor VDrawTool::CorrectColor(const QColor &color) const
}
}
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::ReadAttributes()
{
const QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
ReadToolAttributes(domElement);
}
else
{
qCDebug(vTool)<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DialogLinkDestroy removes dialog pointer

View File

@ -97,6 +97,9 @@ protected:
virtual void RefreshDataInFile();
QColor CorrectColor(const QColor &color) const;
void ReadAttributes();
virtual void ReadToolAttributes(const QDomElement &domElement)=0;
template <typename Dialog, typename Tool>
/**
* @brief ContextMenu show context menu for tool.

View File

@ -71,14 +71,7 @@ VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, cons
*/
void VToolAlongLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formulaLength = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toUInt();
secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt();
}
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
@ -168,6 +161,16 @@ void VToolAlongLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::ReadToolAttributes(const QDomElement &domElement)
{
typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
formulaLength = doc->GetParametrString(domElement, AttrLength, "");
basePointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolAlongLine::GetSecondPointId() const
{
@ -232,6 +235,7 @@ void VToolAlongLine::setDialog()
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->SetTypeLine(typeLine);
dialogTool->SetLineColor(lineColor);
dialogTool->SetFormula(formulaLength);
dialogTool->SetFirstPointId(basePointId);
dialogTool->SetSecondPointId(secondPointId);

View File

@ -64,6 +64,7 @@ protected:
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
/** @brief secondPointId id second point of line. */
quint32 secondPointId;

View File

@ -82,6 +82,7 @@ void VToolArc::setDialog()
dialogTool->SetF1(arc->GetFormulaF1());
dialogTool->SetF2(arc->GetFormulaF2());
dialogTool->SetRadius(arc->GetFormulaRadius());
dialogTool->SetColor(lineColor);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -113,6 +113,7 @@ void VToolBisector::setDialog()
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->SetTypeLine(typeLine);
dialogTool->SetLineColor(lineColor);
dialogTool->SetFormula(formulaLength);
dialogTool->SetFirstPointId(firstPointId);
dialogTool->SetSecondPointId(basePointId);
@ -221,15 +222,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
*/
void VToolBisector::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formulaLength = domElement.attribute(AttrLength, "");
firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt();
basePointId = domElement.attribute(AttrSecondPoint, "").toUInt();
thirdPointId = domElement.attribute(AttrThirdPoint, "").toUInt();
}
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
@ -322,6 +315,17 @@ void VToolBisector::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrThirdPoint, thirdPointId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolBisector::ReadToolAttributes(const QDomElement &domElement)
{
typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
formulaLength = doc->GetParametrString(domElement, AttrLength, "");
firstPointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
basePointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
thirdPointId = doc->GetParametrUInt(domElement, AttrThirdPoint, NULL_ID_STR);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolBisector::GetThirdPointId() const
{

View File

@ -72,6 +72,7 @@ protected:
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
/** @brief firstPointId id first point of angle. */
quint32 firstPointId;

View File

@ -67,6 +67,7 @@ void VToolCurveIntersectAxis::setDialog()
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->SetTypeLine(typeLine);
dialogTool->SetLineColor(lineColor);
dialogTool->SetAngle(formulaAngle);
dialogTool->SetBasePointId(basePointId);
dialogTool->setCurveId(curveId);
@ -250,14 +251,7 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show)
//---------------------------------------------------------------------------------------------------------------------
void VToolCurveIntersectAxis::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
basePointId = domElement.attribute(AttrBasePoint, "").toUInt();
curveId = domElement.attribute(AttrCurve, "").toUInt();
formulaAngle = domElement.attribute(AttrAngle, "");
}
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
@ -313,3 +307,13 @@ void VToolCurveIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObj
doc->SetAttribute(tag, AttrBasePoint, basePointId);
doc->SetAttribute(tag, AttrCurve, curveId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCurveIntersectAxis::ReadToolAttributes(const QDomElement &domElement)
{
typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
basePointId = doc->GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
curveId = doc->GetParametrUInt(domElement, AttrCurve, NULL_ID_STR);
formulaAngle = doc->GetParametrString(domElement, AttrAngle, "");
}

View File

@ -68,6 +68,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolCurveIntersectAxis)
QString formulaAngle;

View File

@ -150,5 +150,4 @@ void VToolCut::FullUpdateCurveFromFile(const QString &attrCurve)
formula = domElement.attribute(AttrLength, "");
curveCutId = domElement.attribute(attrCurve, "").toUInt();
}
RefreshGeometry();
}

View File

@ -220,7 +220,8 @@ void VToolCutArc::ShowVisualization(bool show)
*/
void VToolCutArc::FullUpdateFromFile()
{
FullUpdateCurveFromFile(AttrArc);
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
{
@ -315,3 +316,10 @@ void VToolCutArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrArc, curveCutId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutArc::ReadToolAttributes(const QDomElement &domElement)
{
formula = doc->GetParametrString(domElement, AttrLength, "");
curveCutId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
}

View File

@ -61,6 +61,7 @@ protected:
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolCutArc)
};

View File

@ -231,7 +231,8 @@ void VToolCutSpline::ShowVisualization(bool show)
*/
void VToolCutSpline::FullUpdateFromFile()
{
FullUpdateCurveFromFile(AttrSpline);
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
{
@ -326,3 +327,10 @@ void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrSpline, curveCutId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSpline::ReadToolAttributes(const QDomElement &domElement)
{
formula = doc->GetParametrString(domElement, AttrLength, "");
curveCutId = doc->GetParametrUInt(domElement, AttrSpline, NULL_ID_STR);
}

View File

@ -62,6 +62,7 @@ protected:
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolCutSpline)
};

View File

@ -280,7 +280,8 @@ void VToolCutSplinePath::ShowVisualization(bool show)
*/
void VToolCutSplinePath::FullUpdateFromFile()
{
FullUpdateCurveFromFile(AttrSplinePath);
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
{
@ -377,3 +378,10 @@ void VToolCutSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrSplinePath, curveCutId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSplinePath::ReadToolAttributes(const QDomElement &domElement)
{
formula = doc->GetParametrString(domElement, AttrLength, "");
curveCutId = doc->GetParametrUInt(domElement, AttrSplinePath, NULL_ID_STR);
}

View File

@ -64,6 +64,7 @@ protected:
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolCutSplinePath)
};

View File

@ -80,6 +80,7 @@ void VToolEndLine::setDialog()
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->SetTypeLine(typeLine);
dialogTool->SetLineColor(lineColor);
dialogTool->SetFormula(formulaLength);
dialogTool->SetAngle(formulaAngle);
dialogTool->SetBasePointId(basePointId);
@ -181,14 +182,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
*/
void VToolEndLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formulaLength = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrBasePoint, "").toUInt();
formulaAngle = domElement.attribute(AttrAngle, "");
}
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
@ -233,6 +227,7 @@ void VToolEndLine::SaveDialog(QDomElement &domElement)
SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId()));
@ -251,11 +246,22 @@ void VToolEndLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLineColor, lineColor);
doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrAngle, formulaAngle);
doc->SetAttribute(tag, AttrBasePoint, basePointId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::ReadToolAttributes(const QDomElement &domElement)
{
typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
formulaLength = doc->GetParametrString(domElement, AttrLength, "");
basePointId = doc->GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
formulaAngle = doc->GetParametrString(domElement, AttrAngle, "");
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolEndLine::GetFormulaAngle() const
{

View File

@ -63,6 +63,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
QString formulaAngle;
};

View File

@ -73,6 +73,7 @@ void VToolHeight::setDialog()
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->SetTypeLine(typeLine);
dialogTool->SetLineColor(lineColor);
dialogTool->SetBasePointId(basePointId);
dialogTool->SetP1LineId(p1LineId);
dialogTool->SetP2LineId(p2LineId);
@ -193,14 +194,7 @@ QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point)
*/
void VToolHeight::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
basePointId = domElement.attribute(AttrBasePoint, "").toUInt();
p1LineId = domElement.attribute(AttrP1Line, "").toUInt();
p2LineId = domElement.attribute(AttrP2Line, "").toUInt();
}
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
@ -268,6 +262,16 @@ void VToolHeight::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrP2Line, p2LineId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolHeight::ReadToolAttributes(const QDomElement &domElement)
{
typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
basePointId = doc->GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
p1LineId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
p2LineId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolHeight::GetP2LineId() const
{

View File

@ -67,6 +67,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
/** @brief p1LineId id first point of line. */
quint32 p1LineId;

View File

@ -85,6 +85,7 @@ void VToolLine::setDialog()
dialogTool->SetFirstPoint(firstPoint);
dialogTool->SetSecondPoint(secondPoint);
dialogTool->SetTypeLine(typeLine);
dialogTool->SetLineColor(lineColor);
}
//---------------------------------------------------------------------------------------------------------------------
@ -189,6 +190,7 @@ QString VToolLine::getTagName() const
*/
void VToolLine::FullUpdateFromFile()
{
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
@ -384,6 +386,15 @@ void VToolLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrTypeLine, typeLine);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::ReadToolAttributes(const QDomElement &domElement)
{
firstPoint = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
secondPoint = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLine::GetSecondPoint() const
{
@ -469,13 +480,6 @@ void VToolLine::SetFirstPoint(const quint32 &value)
*/
void VToolLine::RefreshGeometry()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
firstPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR);
secondPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR);
typeLine = doc->GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
}
const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(firstPoint);
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(secondPoint);
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));

View File

@ -76,6 +76,7 @@ protected:
virtual void keyReleaseEvent(QKeyEvent * event);
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
/** @brief firstPoint id first line point. */
quint32 firstPoint;

View File

@ -193,14 +193,7 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32
*/
void VToolLineIntersect::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
p1Line1 = domElement.attribute(AttrP1Line1, "").toUInt();
p2Line1 = domElement.attribute(AttrP2Line1, "").toUInt();
p1Line2 = domElement.attribute(AttrP1Line2, "").toUInt();
p2Line2 = domElement.attribute(AttrP2Line2, "").toUInt();
}
ReadAttributes();
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
if (vis != nullptr)
@ -291,6 +284,15 @@ void VToolLineIntersect::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
doc->SetAttribute(tag, AttrP2Line2, p2Line2);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::ReadToolAttributes(const QDomElement &domElement)
{
p1Line1 = doc->GetParametrUInt(domElement, AttrP1Line1, NULL_ID_STR);
p2Line1 = doc->GetParametrUInt(domElement, AttrP2Line1, NULL_ID_STR);
p1Line2 = doc->GetParametrUInt(domElement, AttrP1Line2, NULL_ID_STR);
p2Line2 = doc->GetParametrUInt(domElement, AttrP2Line2, NULL_ID_STR);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersect::GetP2Line2() const
{

View File

@ -73,6 +73,7 @@ protected:
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
/** @brief p1Line1 id first point first line. */
quint32 p1Line1;

View File

@ -68,6 +68,7 @@ void VToolLineIntersectAxis::setDialog()
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->SetTypeLine(typeLine);
dialogTool->SetLineColor(lineColor);
dialogTool->SetAngle(formulaAngle);
dialogTool->SetBasePointId(basePointId);
dialogTool->SetFirstPointId(firstPointId);
@ -266,15 +267,7 @@ void VToolLineIntersectAxis::ShowVisualization(bool show)
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
basePointId = domElement.attribute(AttrBasePoint, "").toUInt();
firstPointId = domElement.attribute(AttrP1Line, "").toUInt();
secondPointId = domElement.attribute(AttrP2Line, "").toUInt();
formulaAngle = domElement.attribute(AttrAngle, "");
}
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
@ -333,3 +326,14 @@ void VToolLineIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObje
doc->SetAttribute(tag, AttrP1Line, firstPointId);
doc->SetAttribute(tag, AttrP2Line, secondPointId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::ReadToolAttributes(const QDomElement &domElement)
{
typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
basePointId = doc->GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
firstPointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
secondPointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
formulaAngle = doc->GetParametrString(domElement, AttrAngle, "");
}

View File

@ -72,6 +72,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolLineIntersectAxis)
QString formulaAngle;

View File

@ -200,15 +200,7 @@ QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondP
*/
void VToolNormal::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formulaLength = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toUInt();
secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt();
angle = domElement.attribute(AttrAngle, "").toDouble();
}
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
@ -300,6 +292,17 @@ void VToolNormal::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolNormal::ReadToolAttributes(const QDomElement &domElement)
{
typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
formulaLength = doc->GetParametrString(domElement, AttrLength, "");
basePointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
angle = doc->GetParametrDouble(domElement, AttrAngle, "0");
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolNormal::GetSecondPointId() const
{

View File

@ -66,6 +66,7 @@ protected:
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
/** @brief secondPointId id second line point. */
quint32 secondPointId;

View File

@ -225,14 +225,7 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad
*/
void VToolPointOfContact::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
arcRadius = domElement.attribute(AttrRadius, "");
center = domElement.attribute(AttrCenter, "").toUInt();
firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt();
secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt();
}
ReadAttributes();
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
if (vis != nullptr)
@ -322,6 +315,15 @@ void VToolPointOfContact::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfContact::ReadToolAttributes(const QDomElement &domElement)
{
arcRadius = doc->GetParametrString(domElement, AttrRadius, "");
center = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
firstPointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolPointOfContact::GetSecondPointId() const
{

View File

@ -78,6 +78,7 @@ protected:
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
/** @brief radius string with formula radius arc. */
QString arcRadius;

View File

@ -165,12 +165,7 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, co
*/
void VToolPointOfIntersection::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt();
secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt();
}
ReadAttributes();
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
if (vis != nullptr)
@ -242,6 +237,13 @@ void VToolPointOfIntersection::SaveOptions(QDomElement &tag, QSharedPointer<VGOb
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersection::ReadToolAttributes(const QDomElement &domElement)
{
firstPointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolPointOfIntersection::GetSecondPointId() const
{

View File

@ -67,6 +67,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolPointOfIntersection)
/** @brief firstPointId id first line point. */

View File

@ -75,6 +75,7 @@ void VToolShoulderPoint::setDialog()
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->SetTypeLine(typeLine);
dialogTool->SetLineColor(lineColor);
dialogTool->SetFormula(formulaLength);
dialogTool->SetP1Line(basePointId);
dialogTool->SetP2Line(p2Line);
@ -225,15 +226,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu
*/
void VToolShoulderPoint::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formulaLength = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrP1Line, "").toUInt();
p2Line = domElement.attribute(AttrP2Line, "").toUInt();
pShoulder = domElement.attribute(AttrPShoulder, "").toUInt();
}
ReadAttributes();
RefreshGeometry();
if (vis != nullptr)
@ -326,6 +319,17 @@ void VToolShoulderPoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
doc->SetAttribute(tag, AttrPShoulder, pShoulder);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolShoulderPoint::ReadToolAttributes(const QDomElement &domElement)
{
typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
formulaLength = doc->GetParametrString(domElement, AttrLength, "");
basePointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
p2Line = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
pShoulder = doc->GetParametrUInt(domElement, AttrPShoulder, NULL_ID_STR);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolShoulderPoint::getPShoulder() const
{

View File

@ -70,6 +70,7 @@ protected:
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
/** @brief p2Line id second line point. */
quint32 p2Line;

View File

@ -264,6 +264,13 @@ void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &o
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::ReadToolAttributes(const QDomElement &domElement)
{
Q_UNUSED(domElement);
// This tool doesn't need read attributes from file.
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.

View File

@ -67,6 +67,7 @@ protected:
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
QString namePP;
QString mPath;

View File

@ -105,6 +105,7 @@ void VToolSpline::setDialog()
dialogTool->SetKAsm1(spl->GetKasm1());
dialogTool->SetKAsm2(spl->GetKasm2());
dialogTool->SetKCurve(spl->GetKcurve());
dialogTool->SetColor(lineColor);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -98,6 +98,7 @@ void VToolSplinePath::setDialog()
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
dialogTool->SetPath(*splPath);
dialogTool->SetColor(lineColor);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -220,14 +220,7 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c
*/
void VToolTriangle::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
axisP1Id = domElement.attribute(AttrAxisP1, "").toUInt();
axisP2Id = domElement.attribute(AttrAxisP2, "").toUInt();
firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt();
secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt();
}
ReadAttributes();
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
if (vis != nullptr)
@ -307,6 +300,15 @@ void VToolTriangle::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolTriangle::ReadToolAttributes(const QDomElement &domElement)
{
axisP1Id = doc->GetParametrUInt(domElement, AttrAxisP1, NULL_ID_STR);
axisP2Id = doc->GetParametrUInt(domElement, AttrAxisP2, NULL_ID_STR);
firstPointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolTriangle::GetSecondPointId() const
{

View File

@ -75,6 +75,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private:
Q_DISABLE_COPY(VToolTriangle)
/** @brief axisP1Id id first axis point. */