]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
SetCurrentFeature in resumeOperation(). It should be improved by moving this call...
authornds <nds@opencascade.com>
Thu, 8 Oct 2015 13:48:43 +0000 (16:48 +0300)
committernds <nds@opencascade.com>
Thu, 8 Oct 2015 13:49:13 +0000 (16:49 +0300)
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/ModuleBase/ModuleBase_OperationFeature.h

index a6829d1bc3a256591b7c899b1e54f5a3c7a2d34f..82f6db270ae09966b8bd19e8afebe9fb66d37598 100755 (executable)
@@ -26,6 +26,7 @@
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Session.h>
+#include <ModelAPI_Tools.h>
 
 #include <GeomAPI_Pnt2d.h>
 
@@ -119,6 +120,16 @@ void ModuleBase_OperationFeature::stopOperation()
     Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
 }
 
+void ModuleBase_OperationFeature::resumeOperation()
+{
+  ModuleBase_Operation::resumeOperation();
+  //if (!myIsEditing)
+    setCurrentFeature(feature());
+  //SessionPtr aMgr = ModelAPI_Session::get();
+  //DocumentPtr aDoc = aMgr->activeDocument();
+  //aDoc->setCurrentFeature(feature(), false);
+}
+
 FeaturePtr ModuleBase_OperationFeature::createFeature(const bool theFlushMessage)
 {
   if (myParentFeature.get()) {
@@ -238,7 +249,7 @@ void ModuleBase_OperationFeature::abort()
     bool aIsOp = aMgr->isOperation();
     if (!aIsOp)
       aMgr->startOperation();
-    aDoc->setCurrentFeature(myPreviousCurrentFeature, true);
+    aDoc->setCurrentFeature(myPreviousCurrentFeature, false);//true);
     if (!aIsOp)
       aMgr->finishOperation();
     myPreviousCurrentFeature = FeaturePtr();
@@ -273,16 +284,25 @@ bool ModuleBase_OperationFeature::commit()
 
     SessionPtr aMgr = ModelAPI_Session::get();
     /// Set current feature and remeber old current feature
+
     if (myIsEditing) {
-      DocumentPtr aDoc = aMgr->activeDocument();
+      setCurrentFeature(myPreviousCurrentFeature);
+      /*DocumentPtr aDoc = aMgr->activeDocument();
       bool aIsOp = aMgr->isOperation();
       if (!aIsOp)
         aMgr->startOperation();
       aDoc->setCurrentFeature(myPreviousCurrentFeature, true);
       if (!aIsOp)
-        aMgr->finishOperation();
+        aMgr->finishOperation();*/
       myPreviousCurrentFeature = FeaturePtr();
     }
+    else {
+      /*CompositeFeaturePtr aCompositeFeature = ModelAPI_Tools::compositeOwner(feature());
+      if (aCompositeFeature.get())
+        setCurrentFeature(aCompositeFeature);//myPreviousCurrentFeature);
+      //else
+      //  setCurrentFeature(feature());*/
+    }
     commitOperation();
     aMgr->finishOperation();
 
@@ -296,6 +316,18 @@ bool ModuleBase_OperationFeature::commit()
   return false;
 }
 
+void ModuleBase_OperationFeature::setCurrentFeature(const FeaturePtr& theFeature)
+{
+  SessionPtr aMgr = ModelAPI_Session::get();
+  DocumentPtr aDoc = aMgr->activeDocument();
+  bool aIsOp = aMgr->isOperation();
+  if (!aIsOp)
+    aMgr->startOperation();
+  aDoc->setCurrentFeature(theFeature, false);//true);
+  if (!aIsOp)
+    aMgr->finishOperation();
+}
+
 void ModuleBase_OperationFeature::activateByPreselection()
 {
   if (myPreSelection.empty())
index f9d850fb8ac4e351ad63dd316b8f09e6b24aa90b..3e5da99146947bf83248bbfba91056d814163556 100755 (executable)
@@ -96,6 +96,8 @@ Q_OBJECT
   /// \return Currently installed property panel
   //ModuleBase_IPropertyPanel* propertyPanel() const { return myPropertyPanel; }
 
+  void setCurrentFeature(const FeaturePtr& theFeature);
+
   /// Activates widgets by preselection if it is accepted. Emits signal if the activation is correct
   virtual void activateByPreselection();
 
@@ -137,6 +139,9 @@ signals:
   /// Hide feature/results if they were hided on start
   virtual void stopOperation();
 
+  /// Virtual method called after operation resume (see resume() method for more description)
+  virtual void resumeOperation();
+
   /// Creates an operation new feature
   /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature