Salome HOME
A fix to abort sketch operation if nothing is displayed in the viewer but values...
authornds <natalia.donis@opencascade.com>
Fri, 29 May 2015 11:32:39 +0000 (14:32 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 29 May 2015 11:33:16 +0000 (14:33 +0300)
Scenario: start line creation, click 1st point, click 2nd point, click circle feature. The line become visible(to origin) in the previous version. Currently it is aborted, nothing is shown.

src/ModuleBase/ModuleBase_IModule.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h

index 6ae486f6c72c7d8c8170be9716eb25773d2ef48e..81652a0b3011811a5d609c365593a74e70407536 100644 (file)
@@ -139,7 +139,7 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
 \r
 public slots:\r
   /// Called on call of command corresponded to a feature\r
-  void onFeatureTriggered();\r
+  virtual void onFeatureTriggered();\r
 \r
   /// Slolt called on object display\r
   /// \param theObject a data object\r
index b71077c8661da15a99bb395b772a4a1a9516c79f..e33202da32bcaeaac540061ed1cb22d94c50c938 100644 (file)
@@ -592,6 +592,30 @@ bool PartSet_Module::deleteObjects()
   return true;
 }
 
+void PartSet_Module::onFeatureTriggered()
+{
+  SessionPtr aMgr = ModelAPI_Session::get();
+  // 1. check whether the delete should be processed in the module
+  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
+  bool isNestedOp = PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
+  if (isNestedOp) {
+    // in case if in the viewer nothing is displayed, the create operation should not be
+    // comitted even if all values of the feature are initialized
+    if (!mySketchMgr->canDisplayCurrentCreatedFeature()) {
+      QAction* aCmd = dynamic_cast<QAction*>(sender());
+      //Do nothing on uncheck
+      if (aCmd->isCheckable() && !aCmd->isChecked())
+        return;
+
+      // the action information should be saved before the operation is aborted
+      // because this abort leads to update command status, which unchecks this action
+      anOperation->abort();
+
+      launchOperation(aCmd->data().toString());
+    }
+  }
+  ModuleBase_IModule::onFeatureTriggered();
+}
 
 void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) 
 {
index a215774c8f949f5073902f4c41349a159800148a..2d1786d49687061e90007341e47c4e363981b1c9 100644 (file)
@@ -137,6 +137,11 @@ public slots:
   /// Set a specific flag to restart the sketcher operation
   void onNoMoreWidgets();
 
+  /// Redefines the parent method in order to customize the next case:
+  /// If the sketch nested operation is active and the presentation is not visualized in the viewer,
+  /// the operation should be always aborted.
+  virtual void onFeatureTriggered();
+
   /// Slolt called on object display
   /// \param theObject a data object
   /// \param theAIS a presentation object
index 3ccdbf5630c3ed91d3e4eff70c317bd8886c1fc2..b128427a4e26cdd76eb3f6d38d874da9f79bd82d 100644 (file)
@@ -868,13 +868,18 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
     if (!anEditorWdg && !myIsPopupMenuActive) {
       // during a nested create operation, the feature is redisplayed only if the mouse over view
       // of there was a value modified in the property panel after the mouse left the view
-      aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow;
+      aCanDisplay = canDisplayCurrentCreatedFeature();
     }
   }
   #endif
   return aCanDisplay;
 }
 
+bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const
+{
+  return myIsPropertyPanelValueChanged || myIsMouseOverWindow;
+}
+
 bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const
 {
   bool isFoundObject = false;
index f82f450f5a16270fd21229e04b53a7566aaa0bf1..389fbf3b89c4a3acc7599f77487c88a5b0f3b5a6 100644 (file)
@@ -140,6 +140,10 @@ public:
   /// \param theObject a model object
   bool canDisplayObject(const ObjectPtr& theObject) const;
 
+  /// Returns true if the mouse is over viewer or property panel value is changed
+  /// \return boolean result
+  bool canDisplayCurrentCreatedFeature() const;
+
   /// Returns state of constraints showing flag 
   bool isConstraintsShown() const { return myIsConstraintsShown; }