Static attribute name.

--HG--
branch : feature
This commit is contained in:
dismine 2013-12-23 22:14:45 +02:00
parent 5ac6302130
commit 7d0611004a
2 changed files with 51 additions and 50 deletions

View File

@ -31,6 +31,7 @@
#include "../geometry/varc.h" #include "../geometry/varc.h"
#include "../geometry/vspline.h" #include "../geometry/vspline.h"
#include "../geometry/vsplinepath.h" #include "../geometry/vsplinepath.h"
#include "../tools/vabstracttool.h"
#include <QDebug> #include <QDebug>
#include <QPushButton> #include <QPushButton>
@ -178,7 +179,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement()) if (domElement.isElement())
{ {
basePointId = domElement.attribute("basePoint", "").toLongLong(); basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0");
} }
record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(basePointId).name(), record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(basePointId).name(),
data->GetPoint(tool.getId()).name()); data->GetPoint(tool.getId()).name());
@ -187,8 +188,8 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement()) if (domElement.isElement())
{ {
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
} }
record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(firstPointId).name(), record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(firstPointId).name(),
data->GetPoint(secondPointId).name()); data->GetPoint(secondPointId).name());
@ -197,8 +198,8 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement()) if (domElement.isElement())
{ {
basePointId = domElement.attribute("firstPoint", "").toLongLong(); basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
} }
record = QString(tr("%3 - Point along line %1_%2")).arg(data->GetPoint(basePointId).name(), record = QString(tr("%3 - Point along line %1_%2")).arg(data->GetPoint(basePointId).name(),
data->GetPoint(secondPointId).name(), data->GetPoint(secondPointId).name(),
@ -211,8 +212,8 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement()) if (domElement.isElement())
{ {
basePointId = domElement.attribute("firstPoint", "").toLongLong(); basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
} }
record = QString(tr("%3 - normal to line %1_%2")).arg(data->GetPoint(basePointId).name(), record = QString(tr("%3 - normal to line %1_%2")).arg(data->GetPoint(basePointId).name(),
data->GetPoint(secondPointId).name(), data->GetPoint(secondPointId).name(),
@ -222,9 +223,9 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement()) if (domElement.isElement())
{ {
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
basePointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
thirdPointId = domElement.attribute("thirdPoint", "").toLongLong(); thirdPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrThirdPoint, "0");
} }
record = QString(tr("%4 - bisector of angle %1_%2_%3")).arg(data->GetPoint(firstPointId).name(), record = QString(tr("%4 - bisector of angle %1_%2_%3")).arg(data->GetPoint(firstPointId).name(),
data->GetPoint(basePointId).name(), data->GetPoint(basePointId).name(),
@ -235,10 +236,10 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement()) if (domElement.isElement())
{ {
p1Line1 = domElement.attribute("p1Line1", "").toLongLong(); p1Line1 = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP1Line1, "0");
p2Line1 = domElement.attribute("p2Line1", "").toLongLong(); p2Line1 = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP2Line1, "0");
p1Line2 = domElement.attribute("p1Line2", "").toLongLong(); p1Line2 = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP1Line2, "0");
p2Line2 = domElement.attribute("p2Line2", "").toLongLong(); p2Line2 = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP2Line2, "0");
} }
record = QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(data->GetPoint(p1Line1).name(), record = QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(data->GetPoint(p1Line1).name(),
data->GetPoint(p2Line1).name(), data->GetPoint(p2Line1).name(),
@ -278,9 +279,9 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement()) if (domElement.isElement())
{ {
center = domElement.attribute("center", "").toLongLong(); center = doc->GetParametrLongLong(domElement, VAbstractTool::AttrCenter, "0");
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
} }
record = QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3")).arg( record = QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3")).arg(
data->GetPoint(center).name(), data->GetPoint(firstPointId).name(), data->GetPoint(center).name(), data->GetPoint(firstPointId).name(),
@ -293,9 +294,9 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement()) if (domElement.isElement())
{ {
basePointId = domElement.attribute("basePoint", "").toLongLong(); basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0");
p1LineId = domElement.attribute("p1Line", "").toLongLong(); p1LineId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP1Line, "0");
p2LineId = domElement.attribute("p2Line", "").toLongLong(); p2LineId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP2Line, "0");
} }
record = QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg( record = QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg(
data->GetPoint(basePointId).name(), data->GetPoint(p1LineId).name(), data->GetPoint(basePointId).name(), data->GetPoint(p1LineId).name(),
@ -309,10 +310,10 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement()) if (domElement.isElement())
{ {
axisP1Id = domElement.attribute("axisP1", "").toLongLong(); axisP1Id = doc->GetParametrLongLong(domElement, VAbstractTool::AttrAxisP1, "0");
axisP2Id = domElement.attribute("axisP2", "").toLongLong(); axisP2Id = doc->GetParametrLongLong(domElement, VAbstractTool::AttrAxisP2, "0");
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
} }
record = QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg( record = QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg(
data->GetPoint(axisP1Id).name(), data->GetPoint(axisP2Id).name(), data->GetPoint(axisP1Id).name(), data->GetPoint(axisP2Id).name(),

View File

@ -200,6 +200,28 @@ public:
* @brief TestUniqueId * @brief TestUniqueId
*/ */
void TestUniqueId() const; void TestUniqueId() const;
/**
* @brief GetParametrLongLong
* @param domElement
* @param name
* @return
*/
qint64 GetParametrLongLong(const QDomElement& domElement, const QString &name,
const QString &defValue) const;
/**
* @brief GetParametrString
* @param domElement
* @param name
* @return
*/
QString GetParametrString(const QDomElement& domElement, const QString &name, const QString &defValue) const;
/**
* @brief GetParametrDouble
* @param domElement
* @param name
* @return
*/
qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const;
signals: signals:
/** /**
* @brief ChangedActivDraw * @brief ChangedActivDraw
@ -392,28 +414,6 @@ private:
* @return * @return
*/ */
qint64 GetParametrId(const QDomElement& domElement) const; qint64 GetParametrId(const QDomElement& domElement) const;
/**
* @brief GetParametrLongLong
* @param domElement
* @param name
* @return
*/
qint64 GetParametrLongLong(const QDomElement& domElement, const QString &name,
const QString &defValue) const;
/**
* @brief GetParametrString
* @param domElement
* @param name
* @return
*/
QString GetParametrString(const QDomElement& domElement, const QString &name, const QString &defValue) const;
/**
* @brief GetParametrDouble
* @param domElement
* @param name
* @return
*/
qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const;
/** /**
* @brief CollectId * @brief CollectId
* @param node * @param node