]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2122: Unexpected Sketcher behavior when creating Coincidence : Preselection...
authornds <nds@opencascade.com>
Tue, 11 Apr 2017 13:36:35 +0000 (16:36 +0300)
committernds <nds@opencascade.com>
Tue, 11 Apr 2017 13:37:08 +0000 (16:37 +0300)
src/ModuleBase/ModuleBase_IModule.cpp
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
src/PartSet/PartSet_WidgetSketchLabel.cpp

index ad7eb2eddec5c9d13fc19560e78c13aedc2bab2f..9fad87772dcd7795f71e6c9b8faad01846a8ed10 100644 (file)
@@ -88,7 +88,7 @@ void ModuleBase_IModule::launchOperation(const QString& theCmdId,
 
   ModuleBase_OperationFeature* aCurOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                          (myWorkshop->currentOperation());
-  QString anOperationKind = aCurOperation ? aCurOperation->getDescription()->operationId() : "";
+  QString aCurOperationKind = aCurOperation ? aCurOperation->getDescription()->operationId() : "";
 
   bool isCommitted;
   if (!myWorkshop->canStartOperation(theCmdId, isCommitted))
@@ -105,7 +105,7 @@ void ModuleBase_IModule::launchOperation(const QString& theCmdId,
     if (aMessage.get()) {
       setReentrantPreSelection(aMessage);
     }
-    else if (anOperationKind.isEmpty() || anOperationKind == theCmdId) {
+    else if (canUsePreselection(aCurOperationKind, theCmdId)) {
       // restore of previous opeation is absent or new launched operation has the same kind
       aFOperation->initSelection(aPreSelected);
     }
@@ -215,6 +215,23 @@ bool ModuleBase_IModule::canDisplayObject(const ObjectPtr& theObject) const
   return true;
 }
 
+bool ModuleBase_IModule::canUsePreselection(const QString& thePreviousOperationKind,
+                                            const QString& theStartedOperationKind)
+{
+  // no previous operation
+  if (thePreviousOperationKind.isEmpty())
+    return true;
+  // edit operation
+  if (thePreviousOperationKind.endsWith(ModuleBase_OperationFeature::EditSuffix()))
+    return true;
+
+  // reentrant operation
+  if (thePreviousOperationKind == theStartedOperationKind)
+    return true;
+
+  return false;
+}
+
 bool ModuleBase_IModule::canUndo() const
 {
   SessionPtr aMgr = ModelAPI_Session::get();
index 11a32c888e23b37930f0c333e2081eb6e8aa1045..30f9d2060a0ac348cdbe09d6b16a65c00453eb44 100755 (executable)
@@ -183,6 +183,14 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param theObject a model object
   virtual bool canDisplayObject(const ObjectPtr& theObject) const;
 
+  /// Returns whether the started operation may use preselection of the previous one
+  /// Cases are: previous operation is null, edit operation, previuos and started operations
+  /// kinds are the same
+  /// \param thePreviousOperationKind a kind of previous operation
+  /// \param theStartedOperationKind a kind of a started operation
+  virtual bool canUsePreselection(const QString& thePreviousOperationKind,
+                                  const QString& theStartedOperationKind);
+
   /// Make some functionality after the objects are hidden in viewer
   /// \param theObjects a list of hidden objects
   //virtual void processHiddenObject(const std::list<ObjectPtr>& theObjects) {};
index 2b14c2506f8da83192a8b6872d3fbe5887087039..a9905b884dc62de59a87ab43aec89b36067f81bd 100755 (executable)
@@ -480,6 +480,15 @@ bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
   return mySketchMgr->canDisplayObject(theObject);
 }
 
+bool PartSet_Module::canUsePreselection(const QString& thePreviousOperationKind,
+                                        const QString& theStartedOperationKind)
+{
+  if (ModuleBase_IModule::canUsePreselection(thePreviousOperationKind, theStartedOperationKind))
+    return true;
+
+  return mySketchMgr->isNestedSketchFeature(theStartedOperationKind);
+}
+
 /*void PartSet_Module::processHiddenObject(const std::list<ObjectPtr>& theObjects)
 {
   mySketchMgr->processHiddenObject(theObjects);
index 79aa314f35fba86d399fd251dc722a375683a569..71a94e60d927aad7947bd4e8ad7a29ee3baf47f5 100755 (executable)
@@ -170,6 +170,13 @@ public:
   /// \param theObject a model object
   virtual bool canDisplayObject(const ObjectPtr& theObject) const;
 
+  /// Returns parent result if accepted, true if the started operation is a nested operation
+  /// of the previous operation
+  /// \param thePreviousOperationKind a kind of previous operation
+  /// \param theStartedOperationKind a kind of a new operation
+  virtual bool canUsePreselection(const QString& thePreviousOperationKind,
+                                  const QString& theStartedOperationKind);
+
   /// Make some functionality after the objects are hidden in viewer
   /// \param theObjects a list of hidden objects
   //virtual void processHiddenObject(const std::list<ObjectPtr>& theObjects);
index 2a5ed0d372cb0ff46d3d80f2a414f910b57e4c3a..9f8e4cf21d37471a3a9b90ce9947560c1421cb90 100755 (executable)
@@ -812,6 +812,22 @@ bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOpera
   return aNestedSketch;
 }
 
+bool PartSet_SketcherMgr::isNestedSketchFeature(const QString& theFeatureKind) const
+{
+  bool aNestedSketch = false;
+
+  FeaturePtr anActiveSketch = activeSketch();
+  if (anActiveSketch.get()) {
+    ModuleBase_Operation* aSketchOperation = operationMgr()->findOperation(
+                                                              anActiveSketch->getKind().c_str());
+    if (aSketchOperation) {
+      QStringList aGrantedOpIds = aSketchOperation->grantedOperationIds();
+      aNestedSketch = aGrantedOpIds.contains(theFeatureKind);
+    }
+  }
+  return aNestedSketch;
+}
+
 bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOperation,
                                                   const CompositeFeaturePtr& theSketch) const
 {
index 648ed988b7acbba533f3fa8b6598a25ad07ec602..b1ab8cb4c0a0f2e52cb277eacea35b683ede4d59 100644 (file)
@@ -111,6 +111,12 @@ public:
   /// \return the boolean result
   bool isNestedSketchOperation(ModuleBase_Operation* theOperation) const;
 
+  /// Returns true if the feature kind belongs to list of granted features of Sketch
+  /// operation. An operation of a sketch should be started before.
+  /// \param theOperation an operation
+  /// \return the boolean result
+  bool isNestedSketchFeature(const QString& theFeatureKind) const;
+
   /// Returns true if the operation is a create and nested sketch operationn
   /// \param theOperation a checked operation
   /// \param theSketch a sketch feature
index 2b53b2ec9ea889db0ed389ed93cbdb0de7b09a04..473f6e5d6168ae6e3dc86b236997c9ff051e84d7 100644 (file)
@@ -348,7 +348,9 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
 
   // 6. Update sketcher actions
   XGUI_ActionsMgr* anActMgr = aWorkshop->actionsMgr();
+
   myWorkshop->updateCommandStatus();
+  aWorkshop->selector()->clearSelection();
   myWorkshop->viewer()->update();
 }