]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
An empty feature add/remove for sketch reentrant operation. The widget has not been...
authornds <nds@opencascade.com>
Thu, 5 Nov 2015 05:03:59 +0000 (08:03 +0300)
committernds <nds@opencascade.com>
Thu, 5 Nov 2015 05:03:59 +0000 (08:03 +0300)
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.h

index b095ff9c4c13e2ea55f9aacc2bdc99bd97e1f1c0..a7418714813f12a3975cf8019a36e8d01e786e29 100755 (executable)
@@ -180,16 +180,14 @@ void PartSet_SketcherReetntrantMgr::onNoMoreWidgets(const std::string& thePrevio
   if (!myWorkshop->module()->getFeatureError(aFOperation->feature(), false).isEmpty())
     return;
 
-  if (aFOperation) {
-    if (PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
-      if (myRestartingMode != RM_Forbided) {
-        myRestartingMode = RM_LastFeatureUsed;
-        startInternalEdit(thePreviousAttributeID);
-      }
-      else {
-        aFOperation->commit();
-      }
+  if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
+    bool isStarted = false;
+    if (myRestartingMode != RM_Forbided) {
+      myRestartingMode = RM_LastFeatureUsed;
+      isStarted = startInternalEdit(thePreviousAttributeID);
     }
+    if (!isStarted)
+      aFOperation->commit();
   }
 }
 
@@ -206,8 +204,7 @@ bool PartSet_SketcherReetntrantMgr::processEnter(const std::string& thePreviousA
     return isDone;
 
   myRestartingMode = RM_EmptyFeatureUsed;
-  startInternalEdit(thePreviousAttributeID);
-  isDone = true;
+  isDone = startInternalEdit(thePreviousAttributeID);
 
   return isDone;
 }
@@ -267,16 +264,21 @@ bool PartSet_SketcherReetntrantMgr::isActiveMgr() const
   return anActive;
 }
 
-void PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePreviousAttributeID)
+bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePreviousAttributeID)
 {
+  bool isDone = false;
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                      (myWorkshop->currentOperation());
 
-  aFOperation->setEditOperation(true);
-  FeaturePtr anOperationFeature = aFOperation->feature();
-  if (anOperationFeature.get() != NULL) {
+  if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
+    aFOperation->setEditOperation(true);
+    FeaturePtr anOperationFeature = aFOperation->feature();
+
+    CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
+    myInternalFeature = aSketch->addFeature(anOperationFeature->getKind());
 
     myIsInternalEditOperation = true;
+    isDone = true;
     connect(aFOperation, SIGNAL(beforeCommitted()), this, SLOT(onBeforeStopped()));
     connect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
 
@@ -300,6 +302,7 @@ void PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev
       }
     }
   }
+  return isDone;
 }
 
 void PartSet_SketcherReetntrantMgr::beforeStopInternalEdit()
@@ -311,6 +314,10 @@ void PartSet_SketcherReetntrantMgr::beforeStopInternalEdit()
     disconnect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
   }
 
+  QObjectPtrList anObjects;
+  anObjects.append(myInternalFeature);
+  workshop()->deleteFeatures(anObjects);
+
   PartSet_Module* aModule = module();
   ModuleBase_ModelWidget* aFirstWidget = aModule->activeWidget();
   ModuleBase_IPropertyPanel* aPanel = aModule->currentOperation()->propertyPanel();
index 2bdeb8617b18635a05c104bd28e8baeb8b7045ac..1f8d2e5fd24e9840e1e3839c73d7454de0401007 100755 (executable)
@@ -120,7 +120,8 @@ private:
   /// Sets the focus to the last control of the property panel and activates selection
   /// of the first widget to can select first value of the next create operation
   /// \param thePreviousAttributeID an index of the previous attribute to set focus to this widget
-  void startInternalEdit(const std::string& thePreviousAttributeID);
+  /// \return true if it is started
+  bool startInternalEdit(const std::string& thePreviousAttributeID);
 
   /// Disconnects this manager from operation signals, deactivate selection of the first control
   /// in the viewer.
@@ -144,6 +145,8 @@ private:
   RestartingMode myRestartingMode;  /// automatical restarting mode flag
   bool myIsFlagsBlocked; /// true when reset of flags should not be perfromed
   bool myIsInternalEditOperation; /// true when the 'internal' edit is started
+
+  FeaturePtr myInternalFeature;
 };
 
 #endif