From: vsv Date: Thu, 24 Jul 2014 08:15:23 +0000 (+0400) Subject: Provide editing of geometry X-Git-Tag: V_0.4.4~155 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8587c5429aceac2d943a177dd36fe8bf50d047cf;p=modules%2Fshaper.git Provide editing of geometry --- diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 3f0069eca..8c0471d95 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -5,6 +5,7 @@ #include "ModuleBase_Tools.h" #include #include +#include namespace ModuleBase_Tools { @@ -23,4 +24,19 @@ boost::shared_ptr shape(ResultPtr theResult) return boost::shared_ptr(); } +//****************************************************************** +FeaturePtr feature(ObjectPtr theObject) +{ + FeaturePtr aFeature = boost::dynamic_pointer_cast(theObject); + if (!aFeature) { + ResultPtr aResult = boost::dynamic_pointer_cast(theObject); + if (aResult) { + PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + DocumentPtr aDoc = aMgr->rootDocument(); + return aDoc->feature(aResult); + } + } + return aFeature; +} + } \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index f326a9e57..3a2dbacff 100644 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -9,6 +9,7 @@ #include "ModuleBase.h" #include +#include class GeomAPI_Shape; @@ -20,6 +21,8 @@ namespace ModuleBase_Tools */ MODULEBASE_EXPORT boost::shared_ptr shape(ResultPtr theResult); + MODULEBASE_EXPORT FeaturePtr feature(ObjectPtr theObject); + }; #endif \ No newline at end of file diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 4cea1a7bf..74debe864 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -3,22 +3,24 @@ #include #include #include -#include -#include -#include #include #include #include #include +#include #include +#include +#include +#include +#include + #include #include #include - #include + #include -#include #include #include @@ -275,17 +277,10 @@ void PartSet_Module::onFitAllView() void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject) { - FeaturePtr aFeature = boost::dynamic_pointer_cast(theObject); + FeaturePtr aFeature = ModuleBase_Tools::feature(theObject); if (!aFeature) { - ResultPtr aResult = boost::dynamic_pointer_cast(theObject); - if (aResult) { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); - DocumentPtr aDoc = aMgr->rootDocument(); - aFeature = aDoc->feature(aResult); - } else { - qDebug("Warning! Restart operation without feature!"); - return; - } + qDebug("Warning! Restart operation without feature!"); + return; } ModuleBase_Operation* anOperation = createOperation(theName.c_str(), aFeature ? aFeature->getKind() : ""); diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index 7975baa65..409adcd75 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -73,11 +74,13 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3 const std::list& theSelected, const std::list& theHighlighted) { - ObjectPtr aFeature; + ObjectPtr aObject; if (!theHighlighted.empty()) - aFeature = theHighlighted.front().object(); - if (!aFeature && !theSelected.empty()) // changed for a constrain - aFeature = theSelected.front().object(); + aObject = theHighlighted.front().object(); + if (!aObject && !theSelected.empty()) // changed for a constrain + aObject = theSelected.front().object(); + + FeaturePtr aFeature = ModuleBase_Tools::feature(aObject); if (!aFeature || aFeature != feature()) { commit(); emit featureConstructed(feature(), FM_Deactivation);