]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
An improvement for the sketch operation restarting mode change.
authornds <natalia.donis@opencascade.com>
Fri, 5 Dec 2014 06:26:04 +0000 (09:26 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 5 Dec 2014 06:26:04 +0000 (09:26 +0300)
The operation should be restarted in the following cases:
1. There are no more widgets in the property panel,
2. If the vertex is selected beforehand the first case happens, the operation should not be restarted(ForbidRestarting)
3. During the operation commit the restarting flag is analized to perfrom the restart if necessary.
4. Enter button release should restart operation but the previous feature is not concidered.

src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h

index 3dec04e882402407fe5dc6fb4bbdc048974ebb22..c0875b7c103317edfaeb9cc655310baf3fa46591 100644 (file)
@@ -93,7 +93,7 @@ extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop*
 
 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   : ModuleBase_IModule(theWshop), 
-  myIsDragging(false), myRestartingMode(RM_LastFeatureUse), myDragDone(false)
+  myIsDragging(false), myRestartingMode(RM_None), myDragDone(false)
 {
   //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
   ModuleBase_IViewer* aViewer = aViewer = theWshop->viewer();
@@ -145,13 +145,13 @@ void PartSet_Module::onOperationComitted(ModuleBase_Operation* theOperation)
   FeaturePtr aFeature = theOperation->feature();
   std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
             std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-  if (aSPFeature && (myRestartingMode != RM_None)) {
+  if (aSPFeature && (myRestartingMode == RM_LastFeatureUse ||
+                     myRestartingMode == RM_LastFeatureUse)) {
     myLastOperationId = theOperation->id();
     myLastFeature = myRestartingMode == RM_LastFeatureUse ? theOperation->feature() : FeaturePtr();
     launchOperation(myLastOperationId);
-  } else {
-    breakOperationSequence();
   }
+  breakOperationSequence();
 }
 
 void PartSet_Module::breakOperationSequence()
@@ -159,7 +159,6 @@ void PartSet_Module::breakOperationSequence()
   myLastOperationId = "";
   myLastFeature = FeaturePtr();
   myRestartingMode = RM_None;
-
 }
 
 void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation)
@@ -169,7 +168,6 @@ void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation)
 
 void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
 {
-  myRestartingMode = RM_LastFeatureUse;
   if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
     // Display all sketcher sub-Objects
     myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
@@ -531,6 +529,8 @@ void PartSet_Module::onNoMoreWidgets()
     std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
               std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
     if (aSPFeature) {
+      if (myRestartingMode != RM_ForbidRestarting)
+        myRestartingMode = RM_LastFeatureUse;
       aOperation->commit();
     }
   }
@@ -560,7 +560,7 @@ void PartSet_Module::onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& t
     ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
     const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
     if (aWidgets.last() == aPanel->activeWidget()) {
-      breakOperationSequence();
+      myRestartingMode = RM_ForbidRestarting;
     }
   }
 }
index 2f981fd66755e93eb3b2356d158e9480282cbb4d..86a813d160416e9fd3bc68127554fe235c250eed 100644 (file)
@@ -31,6 +31,7 @@ Q_OBJECT
 /// Enumeration to specify the restart operation properties.
 enum RestartingMode {
   RM_None, /// the operation should not be restarted
+  RM_ForbidRestarting, /// the operation should not be restarted after there is no active widget
   RM_LastFeatureUse, /// the operation is restarted and use the previous feature for own initialization
   RM_LastFeatureEmpty /// the operation is restarted and does not use the previous feature
 };