From d8c5fafbc3a8b584b02f1fd24a6fb76e32ea9304 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 27 Jul 2017 17:43:10 +0300 Subject: [PATCH] Refactoring. --HG-- branch : develop --- .../operation/vabstractoperation.cpp | 39 +++++-------------- .../drawTools/operation/vabstractoperation.h | 2 +- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index 0eba8ab0c..4ca682509 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -478,7 +478,7 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag) } //--------------------------------------------------------------------------------------------------------------------- -VSimpleCurve *VAbstractOperation::InitCurve(quint32 id, VContainer *data, GOType curveType) +void VAbstractOperation::InitCurve(quint32 id, VContainer *data, GOType curveType, SceneObject sceneType) { const QSharedPointer initCurve = data->GeometricObject(id); VSimpleCurve *curve = new VSimpleCurve(id, initCurve); @@ -489,10 +489,13 @@ VSimpleCurve *VAbstractOperation::InitCurve(quint32 id, VContainer *data, GOType { contextMenuEvent(event); }); + connect(curve, &VSimpleCurve::Choosed, this, [this, sceneType](quint32 id) + { + emit ChoosedTool(id, sceneType); + }); connect(curve, &VSimpleCurve::Delete, this, &VAbstractOperation::DeleteFromLabel); curve->RefreshGeometry(VAbstractTool::data.GeometricObject(id)); operatedObjects.insert(id, curve); - return curve; } //--------------------------------------------------------------------------------------------------------------------- @@ -595,43 +598,19 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") break; } case GOType::Arc: - { - VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType()); - connect(curve, &VSimpleCurve::Choosed, this, [this](quint32 id) - { - emit ChoosedTool(id, SceneObject::Arc); - }); + InitCurve(object.id, &(VAbstractTool::data), obj->getType(), SceneObject::Arc); break; - } case GOType::EllipticalArc: - { - VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType()); - connect(curve, &VSimpleCurve::Choosed, this, [this](quint32 id) - { - emit ChoosedTool(id, SceneObject::ElArc); - }); + InitCurve(object.id, &(VAbstractTool::data), obj->getType(), SceneObject::ElArc); break; - } case GOType::Spline: case GOType::CubicBezier: - { - VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType()); - connect(curve, &VSimpleCurve::Choosed, this, [this](quint32 id) - { - emit ChoosedTool(id, SceneObject::Spline); - }); + InitCurve(object.id, &(VAbstractTool::data), obj->getType(), SceneObject::Spline); break; - } case GOType::SplinePath: case GOType::CubicBezierPath: - { - VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType()); - connect(curve, &VSimpleCurve::Choosed, this, [this](quint32 id) - { - emit ChoosedTool(id, SceneObject::SplinePath); - }); + InitCurve(object.id, &(VAbstractTool::data), obj->getType(), SceneObject::SplinePath); break; - } case GOType::Unknown: break; } diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h index fdc61dea7..a74879e68 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h @@ -126,7 +126,7 @@ protected: template void ShowToolVisualization(bool show); - VSimpleCurve *InitCurve(quint32 id, VContainer *data, GOType curveType); + void InitCurve(quint32 id, VContainer *data, GOType curveType, SceneObject sceneType); template static void InitOperationToolConnections(VMainGraphicsScene *scene, T *tool);