New template InitTool.
--HG-- branch : develop
This commit is contained in:
parent
2d12b35e78
commit
04140824cd
|
@ -38,8 +38,6 @@ public slots:
|
||||||
void ChangedNameDraw(const QString oldName, const QString newName);
|
void ChangedNameDraw(const QString oldName, const QString newName);
|
||||||
virtual void FullUpdateFromGui(int result)=0;
|
virtual void FullUpdateFromGui(int result)=0;
|
||||||
virtual void SetFactor(qreal factor);
|
virtual void SetFactor(qreal factor);
|
||||||
signals:
|
|
||||||
void RemoveTool(QGraphicsItem *tool);
|
|
||||||
protected:
|
protected:
|
||||||
bool ignoreContextMenuEvent;
|
bool ignoreContextMenuEvent;
|
||||||
bool ignoreFullUpdate;
|
bool ignoreFullUpdate;
|
||||||
|
|
|
@ -34,8 +34,6 @@ public:
|
||||||
inline void ignoreContextMenu(bool enable) {ignoreContextMenuEvent = enable;}
|
inline void ignoreContextMenu(bool enable) {ignoreContextMenuEvent = enable;}
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromGui(int result)=0;
|
virtual void FullUpdateFromGui(int result)=0;
|
||||||
signals:
|
|
||||||
void RemoveTool(QGraphicsItem *tool);
|
|
||||||
protected:
|
protected:
|
||||||
bool ignoreContextMenuEvent;
|
bool ignoreContextMenuEvent;
|
||||||
bool ignoreFullUpdate;
|
bool ignoreFullUpdate;
|
||||||
|
|
|
@ -78,6 +78,7 @@ signals:
|
||||||
void toolhaveChange();
|
void toolhaveChange();
|
||||||
void ChoosedTool(qint64 id, Scene::Scenes type);
|
void ChoosedTool(qint64 id, Scene::Scenes type);
|
||||||
void FullUpdateTree();
|
void FullUpdateTree();
|
||||||
|
void RemoveTool(QGraphicsItem *tool);
|
||||||
protected:
|
protected:
|
||||||
VDomDocument *doc;
|
VDomDocument *doc;
|
||||||
const qint64 id;
|
const qint64 id;
|
||||||
|
|
|
@ -38,150 +38,73 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
VMainGraphicsScene *scene, QGraphicsItem *parent) :VAbstractTool(doc, data, id),
|
VMainGraphicsScene *scene, QGraphicsItem *parent) :VAbstractTool(doc, data, id),
|
||||||
QGraphicsPathItem(parent), dialogDetail(QSharedPointer<DialogDetail>()), sceneDetails(scene){
|
QGraphicsPathItem(parent), dialogDetail(QSharedPointer<DialogDetail>()), sceneDetails(scene){
|
||||||
VDetail detail = data->GetDetail(id);
|
VDetail detail = data->GetDetail(id);
|
||||||
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
|
||||||
Q_ASSERT(tools != 0);
|
|
||||||
for(qint32 i = 0; i< detail.CountNode(); ++i){
|
for(qint32 i = 0; i< detail.CountNode(); ++i){
|
||||||
switch(detail[i].getTypeTool()){
|
switch(detail[i].getTypeTool()){
|
||||||
case(Tool::NodePoint):{
|
case(Tool::NodePoint):{
|
||||||
VNodePoint *point = qobject_cast<VNodePoint*>(tools->value(detail[i].getId()));
|
InitTool<VNodePoint>(scene, detail[i]);
|
||||||
Q_ASSERT(point != 0);
|
|
||||||
connect(point, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
point->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::NodeArc):{
|
case(Tool::NodeArc):{
|
||||||
VNodeArc *arc = qobject_cast<VNodeArc*>(tools->value(detail[i].getId()));
|
InitTool<VNodeArc>(scene, detail[i]);
|
||||||
Q_ASSERT(arc != 0);
|
|
||||||
connect(arc, &VNodeArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
arc->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::NodeSpline):{
|
case(Tool::NodeSpline):{
|
||||||
VNodeSpline *spl = qobject_cast<VNodeSpline*>(tools->value(detail[i].getId()));
|
InitTool<VNodeSpline>(scene, detail[i]);
|
||||||
Q_ASSERT(spl != 0);
|
|
||||||
connect(spl, &VNodeSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
spl->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::NodeSplinePath):{
|
case(Tool::NodeSplinePath):{
|
||||||
VNodeSplinePath *splPath = qobject_cast<VNodeSplinePath*>(tools->value(detail[i].getId()));
|
InitTool<VNodeSplinePath>(scene, detail[i]);
|
||||||
Q_ASSERT(splPath != 0);
|
|
||||||
connect(splPath, &VNodeSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
splPath->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::AlongLineTool):{
|
case(Tool::AlongLineTool):{
|
||||||
VModelingAlongLine *tool = qobject_cast<VModelingAlongLine*>(tools->value(detail[i].getId()));
|
InitTool<VModelingAlongLine>(scene, detail[i]);
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::ArcTool):{
|
case(Tool::ArcTool):{
|
||||||
VModelingArc *tool = qobject_cast<VModelingArc*>(tools->value(detail[i].getId()));
|
InitTool<VModelingArc>(scene, detail[i]);
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::BisectorTool):{
|
case(Tool::BisectorTool):{
|
||||||
VModelingBisector *tool = qobject_cast<VModelingBisector*>(tools->value(detail[i].getId()));
|
InitTool<VModelingBisector>(scene, detail[i]);
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::EndLineTool):{
|
case(Tool::EndLineTool):{
|
||||||
VModelingEndLine *tool = qobject_cast<VModelingEndLine*>(tools->value(detail[i].getId()));
|
InitTool<VModelingEndLine>(scene, detail[i]);
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingEndLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingEndLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::LineIntersectTool):{
|
case(Tool::LineIntersectTool):{
|
||||||
VModelingLineIntersect *tool = qobject_cast<VModelingLineIntersect*>(tools->value(detail[i].getId()));
|
InitTool<VModelingLineIntersect>(scene, detail[i]);
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingLineIntersect::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::LineTool):{
|
case(Tool::LineTool):{
|
||||||
VModelingLine *tool = qobject_cast<VModelingLine*>(tools->value(detail[i].getId()));
|
InitTool<VModelingLine>(scene, detail[i]);
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::NormalTool):{
|
case(Tool::NormalTool):{
|
||||||
VModelingNormal *tool = qobject_cast<VModelingNormal*>(tools->value(detail[i].getId()));
|
InitTool<VModelingNormal>(scene, detail[i]);
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(Tool::PointOfContact):{
|
case(Tool::PointOfContact):
|
||||||
VModelingPointOfContact *tool = qobject_cast<VModelingPointOfContact*>(tools->value(detail[i].getId()));
|
InitTool<VModelingPointOfContact>(scene, detail[i]);
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
case(Tool::ShoulderPointTool):
|
||||||
case(Tool::ShoulderPointTool):{
|
InitTool<VModelingShoulderPoint>(scene, detail[i]);
|
||||||
VModelingShoulderPoint *tool = qobject_cast<VModelingShoulderPoint*>(tools->value(detail[i].getId()));
|
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
case(Tool::SplinePathTool):
|
||||||
case(Tool::SplinePathTool):{
|
InitTool<VModelingSplinePath>(scene, detail[i]);
|
||||||
VModelingSplinePath *tool = qobject_cast<VModelingSplinePath*>(tools->value(detail[i].getId()));
|
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
case(Tool::SplineTool):
|
||||||
case(Tool::SplineTool):{
|
InitTool<VModelingSpline>(scene, detail[i]);
|
||||||
VModelingSpline *tool = qobject_cast<VModelingSpline*>(tools->value(detail[i].getId()));
|
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
case(Tool::Height):
|
||||||
case(Tool::Height):{
|
InitTool<VModelingHeight>(scene, detail[i]);
|
||||||
VModelingHeight *tool = qobject_cast<VModelingHeight*>(tools->value(detail[i].getId()));
|
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingHeight::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingHeight::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
case(Tool::Triangle):
|
||||||
case(Tool::Triangle):{
|
InitTool<VModelingTriangle>(scene, detail[i]);
|
||||||
VModelingTriangle *tool = qobject_cast<VModelingTriangle*>(tools->value(detail[i].getId()));
|
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingTriangle::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
case(Tool::PointOfIntersection):
|
||||||
case(Tool::PointOfIntersection):{
|
InitTool<VModelingPointOfIntersection>(scene, detail[i]);
|
||||||
VModelingPointOfIntersection *tool = qobject_cast<VModelingPointOfIntersection*>(tools->value(detail[i].getId()));
|
|
||||||
Q_ASSERT(tool != 0);
|
|
||||||
connect(tool, &VModelingPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
||||||
connect(tool, &VModelingPointOfIntersection::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
||||||
tool->setParentItem(this);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
qWarning()<<"Get wrong tool type. Ignore.";
|
qWarning()<<"Get wrong tool type. Ignore.";
|
||||||
break;
|
break;
|
||||||
|
@ -484,3 +407,14 @@ void VToolDetail::RefreshGeometry(){
|
||||||
QPainterPath path = VAbstractTool::data.ContourPath(id);
|
QPainterPath path = VAbstractTool::data.ContourPath(id);
|
||||||
this->setPath(path);
|
this->setPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Tool>
|
||||||
|
void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node){
|
||||||
|
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
Q_ASSERT(tools != 0);
|
||||||
|
Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
|
||||||
|
Q_ASSERT(tool != 0);
|
||||||
|
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
connect(tool, &Tool::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
||||||
|
tool->setParentItem(this);
|
||||||
|
}
|
||||||
|
|
|
@ -77,6 +77,8 @@ private:
|
||||||
VMainGraphicsScene *sceneDetails;
|
VMainGraphicsScene *sceneDetails;
|
||||||
void RefreshGeometry ();
|
void RefreshGeometry ();
|
||||||
void AddNode(QDomElement &domElement, VNodeDetail &node);
|
void AddNode(QDomElement &domElement, VNodeDetail &node);
|
||||||
|
template <typename Tool>
|
||||||
|
void InitTool(VMainGraphicsScene *scene, const VNodeDetail &node);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLDETAIL_H
|
#endif // VTOOLDETAIL_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user