Template CreateNode.

--HG--
branch : feature
This commit is contained in:
dismine 2013-12-31 10:28:53 +02:00
parent a9dfc45f99
commit 8e82a80463
3 changed files with 14 additions and 17 deletions

View File

@ -97,37 +97,25 @@ void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScen
{ {
case (Tool::NodePoint): case (Tool::NodePoint):
{ {
VPointF *point = new VPointF(*data->GeometricObject<const VPointF *>(detail[i].getId())); id = CreateNode<VPointF>(data, detail[i].getId());
Q_ASSERT(point != 0);
point->setMode(Draw::Modeling);
id = data->AddGObject(point);
VNodePoint::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui); VNodePoint::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui);
} }
break; break;
case (Tool::NodeArc): case (Tool::NodeArc):
{ {
VArc *arc = new VArc(*data->GeometricObject<const VArc *>(detail[i].getId())); id = CreateNode<VArc>(data, detail[i].getId());
Q_ASSERT(arc != 0);
arc->setMode(Draw::Modeling);
id = data->AddGObject(arc);
VNodeArc::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui); VNodeArc::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui);
} }
break; break;
case (Tool::NodeSpline): case (Tool::NodeSpline):
{ {
VSpline *spline = new VSpline(*data->GeometricObject<const VSpline *>(detail[i].getId())); id = CreateNode<VSpline>(data, detail[i].getId());
Q_ASSERT(spline != 0);
spline->setMode(Draw::Modeling);
id = data->AddGObject(spline);
VNodeSpline::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui); VNodeSpline::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui);
} }
break; break;
case (Tool::NodeSplinePath): case (Tool::NodeSplinePath):
{ {
VSplinePath *splinePath = new VSplinePath(*data->GeometricObject<const VSplinePath *>(detail[i].getId())); id = CreateNode<VSplinePath>(data, detail[i].getId());
Q_ASSERT(splinePath != 0);
splinePath->setMode(Draw::Modeling);
id = data->AddGObject(splinePath);
VNodeSplinePath::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui); VNodeSplinePath::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui);
} }
break; break;

View File

@ -56,6 +56,15 @@ public:
* @brief setDialog * @brief setDialog
*/ */
virtual void setDialog(); virtual void setDialog();
template<typename T>
static qint64 CreateNode(VContainer *data, const qint64 &id)
{
T *node = new T(*data->GeometricObject<const T *>(id));
Q_ASSERT(node != 0);
node->setMode(Draw::Modeling);
return data->AddGObject(node);
}
/** /**
* @brief Create * @brief Create
* @param dialog * @param dialog

View File

@ -234,7 +234,7 @@ signals:
* @param oldName * @param oldName
* @param newName * @param newName
*/ */
void ChangedNameDraw(const QString oldName, const QString newName); void ChangedNameDraw(const QString &oldName, const QString &newName);
/** /**
* @brief FullUpdateFromFile * @brief FullUpdateFromFile
*/ */