]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide editing of geometry
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 24 Jul 2014 08:15:23 +0000 (12:15 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 24 Jul 2014 08:15:23 +0000 (12:15 +0400)
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureEdit.cpp

index 3f0069eca9640597f7c35a9033f82e48a6bc7d1d..8c0471d9503f8b3f5cfee81a9c47754f2f151740 100644 (file)
@@ -5,6 +5,7 @@
 #include "ModuleBase_Tools.h"
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Document.h>
 
 namespace ModuleBase_Tools
 {
@@ -23,4 +24,19 @@ boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult)
   return boost::shared_ptr<GeomAPI_Shape>();
 }
 
+//******************************************************************
+FeaturePtr feature(ObjectPtr theObject)
+{
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  if (!aFeature) {
+    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult) {
+      PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+      DocumentPtr aDoc = aMgr->rootDocument();
+      return aDoc->feature(aResult);
+    }
+  }
+  return aFeature;
+}
+
 }
\ No newline at end of file
index f326a9e5782211565f8dc80d358eca4eb9c2d4c9..3a2dbacfffacbc88b11387e7bffbb6d3183d5ff9 100644 (file)
@@ -9,6 +9,7 @@
 #include "ModuleBase.h"
 
 #include <ModelAPI_Result.h>
+#include <ModelAPI_Feature.h>
 
 class GeomAPI_Shape;
 
@@ -20,6 +21,8 @@ namespace ModuleBase_Tools
   */
   MODULEBASE_EXPORT boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult);
 
+  MODULEBASE_EXPORT FeaturePtr feature(ObjectPtr theObject);
+
 };
 
 #endif
\ No newline at end of file
index 4cea1a7bf62bd349bb79d047ca87f9a28540947b..74debe86406ce079ae87c9cdceed536b294ae680 100644 (file)
@@ -3,22 +3,24 @@
 #include <PartSet_OperationFeatureCreate.h>
 #include <PartSet_OperationFeatureEditMulti.h>
 #include <PartSet_OperationFeatureEdit.h>
-#include <ModuleBase_Operation.h>
-#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_WidgetFactory.h>
 #include <PartSet_Listener.h>
 #include <PartSet_TestOCC.h>
 #include <PartSet_WidgetSketchLabel.h>
 #include <PartSet_Validators.h>
+#include <PartSet_Tools.h>
 
 #include <ModuleBase_Operation.h>
+#include <ModuleBase_OperationDescription.h>
+#include <ModuleBase_WidgetFactory.h>
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_Tools.h>
+
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Validator.h>
-
 #include <ModelAPI_Data.h>
+
 #include <GeomDataAPI_Point2D.h>
-#include <PartSet_Tools.h>
 
 #include <XGUI_MainWindow.h>
 #include <XGUI_Displayer.h>
@@ -275,17 +277,10 @@ void PartSet_Module::onFitAllView()
 
 void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
 {
-  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  FeaturePtr aFeature = ModuleBase_Tools::feature(theObject);
   if (!aFeature) {
-    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(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() : "");
index 7975baa652d223a39a1765023498965bc8b29277..409adcd75adc9eeb40326fdd7874426b6173f241 100644 (file)
@@ -11,6 +11,7 @@
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetEditor.h>
 #include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
 
 #include <ModelAPI_Events.h>
 
@@ -73,11 +74,13 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3
                                              const std::list<ModuleBase_ViewerPrs>& theSelected,
                                              const std::list<ModuleBase_ViewerPrs>& 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);