]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1701 Preselecting before calling constraints does not put objects in the input...
authornds <nds@opencascade.com>
Thu, 1 Sep 2016 16:30:42 +0000 (19:30 +0300)
committernds <nds@opencascade.com>
Thu, 1 Sep 2016 16:30:59 +0000 (19:30 +0300)
Issue #1655(checked) In the Sketcher, automatically unselect eventuel selected objects when returning to the neutral point
Code improvement to store selection before commit of previous operation

src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/ModuleBase/ModuleBase_OperationFeature.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.cpp

index 424260dcb89d5921991948e06550a0c22b040d30..73ab7d3105b7002112fd784f543509a4a3fbbf9e 100644 (file)
@@ -71,15 +71,20 @@ void ModuleBase_IModule::launchModal(const QString& theCmdId)
 
 void ModuleBase_IModule::launchOperation(const QString& theCmdId)
 {
+  /// selection should be obtained from workshop before ask if the operation can be started as
+  /// the canStartOperation method performs commit/abort of previous operation. Sometimes commit/abort
+  /// may cause selection clear(Sketch operation) as a result it will be lost and is not used for preselection.
+  ModuleBase_ISelection* aSelection = myWorkshop->selection();
+  QList<ModuleBase_ViewerPrsPtr> aPreSelected = aSelection->getSelected(ModuleBase_ISelection::AllControls);
+
   if (!myWorkshop->canStartOperation(theCmdId))
     return;
 
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                              (createOperation(theCmdId.toStdString()));
   if (aFOperation) {
-    ModuleBase_ISelection* aSelection = myWorkshop->selection();
-    // Initialise operation with preliminary selection
-    aFOperation->initSelection(aSelection, myWorkshop->viewer());
+    aFOperation->initSelection(aPreSelected);
+
     workshop()->processLaunchOperation(aFOperation);
   }
 }
index 9745c5fe0c72d6d103027f1d9dc7aaa7f63b501c..450e52399e20a9af5b0c8a22471538df6adeb997 100755 (executable)
@@ -448,30 +448,30 @@ FeaturePtr ModuleBase_OperationFeature::previousCurrentFeature()
   return myPreviousCurrentFeature;
 }
 
-void ModuleBase_OperationFeature::initSelection(ModuleBase_ISelection* theSelection,
-                                         ModuleBase_IViewer* theViewer)
+void ModuleBase_OperationFeature::initSelection(const QList<ModuleBase_ViewerPrsPtr>& thePreSelected)
 {
-  QList<ModuleBase_ViewerPrsPtr> aPreSelected;
+  QObjectPtrList aCurrentFeatureResults;
+
   // Check that the selected result are not results of operation feature
   FeaturePtr aFeature = feature();
   if (aFeature) {
-    QList<ModuleBase_ViewerPrsPtr> aSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls);
-
     std::list<ResultPtr> aResults;
     ModelAPI_Tools::allResults(aFeature, aResults);
-    QObjectPtrList aResList;
     std::list<ResultPtr>::const_iterator aIt;
     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
-      aResList.append(*aIt);
-
-    foreach (ModuleBase_ViewerPrsPtr aPrs, aSelected) {
-      if ((!aResList.contains(aPrs->object())) && (aPrs->object() != aFeature))
+      aCurrentFeatureResults.append(*aIt);
+  }
+  
+  if (aCurrentFeatureResults.empty()) /// filtering of selection is not necessary
+    setPreselection(thePreSelected);
+  else { // create preselection list without results of current feature
+    QList<ModuleBase_ViewerPrsPtr> aPreSelected;
+    foreach (ModuleBase_ViewerPrsPtr aPrs, thePreSelected) {
+      if ((!aCurrentFeatureResults.contains(aPrs->object())) && (aPrs->object() != aFeature))
         aPreSelected.append(aPrs);
     }
-  } else
-    aPreSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls);
-
-  setPreselection(aPreSelected);
+    setPreselection(aPreSelected);
+  }
 }
 
 void ModuleBase_OperationFeature::setPreselection(const QList<ModuleBase_ViewerPrsPtr>& theValues)
index 268b1d7590bb633b5a2e60d14f97afa35a42159a..7e1ffb291a4d600b7787bbd7a392810f5eaab918 100755 (executable)
@@ -93,10 +93,9 @@ Q_OBJECT
   virtual bool isDisplayedOnStart(ObjectPtr theObject);
 
   /// Initialisation of operation with preliminary selection
-  /// \param theSelection an instance of Selection class
-  /// \param theViewer a viewer to have the viewer the eye position
-  virtual void initSelection(ModuleBase_ISelection* theSelection,
-                             ModuleBase_IViewer* theViewer);
+  /// \param thePreSelected a container of selected presentations
+  virtual void initSelection(
+                  const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& thePreSelected);
 
   /// Fill internal map by preselection
   /// \param theValues a list of preselection
index 03781cb7acd0925e0b94556a6ccf5e2cea934281..abe3a586f304be5be4cfbcd41208c8dda4f30b44 100755 (executable)
@@ -1017,9 +1017,7 @@ void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOperation)
   //}
   /// improvement to deselect automatically all eventual selected objects, when
   // returning to the neutral point of the Sketcher
-  // if the operation is restarted, the previous selection is used to initialize started operation
-  if (!myModule->sketchReentranceMgr()->isInternalEditStarted())
-    workshop()->selector()->clearSelection();
+  workshop()->selector()->clearSelection();
 }
 
 void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
index 2c6dee25f13ea2090925d95c487b27549e0e8447..95a68cf42f054cc7f186305f12054787aa28e29f 100755 (executable)
@@ -458,8 +458,6 @@ void PartSet_SketcherReetntrantMgr::restartOperation()
     if (aFOperation) {
       myNoMoreWidgetsAttribute = "";
       myIsFlagsBlocked = true;
-      FeaturePtr aPrevFeature = aFOperation->feature();
-      aFOperation->commit();
       module()->launchOperation(aFOperation->id());
       myIsFlagsBlocked = false;
       resetFlags();