]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Debug the selection restore on the Full Salome mode. There is a bug there, that enabl...
authornds <natalia.donis@opencascade.com>
Mon, 29 Dec 2014 15:56:44 +0000 (18:56 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 29 Dec 2014 15:56:44 +0000 (18:56 +0300)
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h

index 5869900b1cb94c9184aa55cc162e901099ae0b6d..434d98c9086693dc70031db173af59ceacfbb016 100644 (file)
@@ -240,8 +240,14 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
   if (myIsDragging) {
-    // the selection should be switched off in order to do not deselect moved objects by the 
-    // mouse release
+    ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+    // 1. it is necessary to save current selection in order to restore it after the features moving
+    FeatureToSelectionMap aCurrentSelection;
+    getCurrentSelection(myFeature2AttributeMap, myCurrentSketch, aWorkshop, aCurrentSelection);
+
+    // 2. the enable selection in the viewer should be temporary switched off in order to ignore
+    // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are
+    // deselected). This flag should be restored in the slot, processed the mouse release signal.
     ModuleBase_IViewer* aViewer = myModule->workshop()->viewer();
     aViewer->enableSelection(false);
 
@@ -256,9 +262,11 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     double dX =  aX - myCurX;
     double dY =  aY - myCurY;
 
-    ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
     XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
     XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+    // 3. the flag to disable the update viewer should be set in order to avoid blinking in the 
+    // viewer happens by deselect/select the modified objects. The flag should be restored after
+    // the selection processing. The update viewer should be also called.
     bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
 
     static Events_ID aMoveEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
@@ -266,7 +274,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
 
     FeatureToAttributesMap::const_iterator anIt = myFeature2AttributeMap.begin(),
                                            aLast = myFeature2AttributeMap.end();
-    FeatureToSelectionMap aCurrentSelection;
+    // 4. the features and attributes modification(move)
     for (; anIt != aLast; anIt++) {
       FeaturePtr aFeature = anIt.key();
       AttributePtr anAttr;
@@ -275,11 +283,6 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
       if (!anAttributes.empty()) {
         anAttr = anAttributes.first();
       }
-
-      // save the previous selection
-      getCurrentSelection(aFeature, myCurrentSketch, aWorkshop, aCurrentSelection);
-      // save the previous selection: end
-
       // Process selection by attribute: the priority to the attribute
       if (anAttr.get() != NULL) {
         std::string aAttrId = anAttr->id();
@@ -307,7 +310,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
     //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
 
-    // restore the previous selection
+    // 5. it is necessary to save current selection in order to restore it after the features moving
     FeatureToSelectionMap::const_iterator aSIt = aCurrentSelection.begin(),
                                           aSLast = aCurrentSelection.end();
     SelectMgr_IndexedMapOfOwner anOwnersToSelect;
@@ -317,8 +320,8 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
                          anOwnersToSelect);
       aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
     }
-    // restore the previous selection: end
 
+    // 6. restore the update viewer flag and call this update
     aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
     aDisplayer->updateViewer();
     myDragDone = true;
@@ -475,12 +478,23 @@ void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& th
   myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
 }
 
+void PartSet_SketcherMgr::getCurrentSelection(const FeatureToAttributesMap& theFeatureToAttributes,
+                                              const FeaturePtr& theSketch,
+                                              ModuleBase_IWorkshop* theWorkshop,
+                                              FeatureToSelectionMap& theSelection)
+{
+  FeatureToAttributesMap::const_iterator anIt = theFeatureToAttributes.begin(),
+                                         aLast = theFeatureToAttributes.end();
+  for (; anIt != aLast; anIt++) {
+    FeaturePtr aFeature = anIt.key();
+    getCurrentSelection(aFeature, theSketch, theWorkshop, theSelection);
+  }
+}
+
 void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
                                               const FeaturePtr& theSketch,
                                               ModuleBase_IWorkshop* theWorkshop,
                                               FeatureToSelectionMap& theSelection)
-                                              //std::set<AttributePtr>& theSelectedAttributes,
-                                              //std::set<ResultPtr>& theSelectedResults)
 {
   if (theFeature.get() == NULL)
     return;
index 4ae85671c21518196dada35958f240f0128b642f..bc976ded351740487be91d8b47afc34c153a08c5 100644 (file)
@@ -71,8 +71,21 @@ private:
                   double& theX, double& theY);
 
 
+  typedef QList<AttributePtr> AttributeList;
+  typedef QMap<FeaturePtr, AttributeList> FeatureToAttributesMap;
   typedef std::map<FeaturePtr, std::pair<std::set<AttributePtr>, std::set<ResultPtr> > >
                                                                        FeatureToSelectionMap;
+  /// Obtains the current selection of the object in the workshop viewer by a map of feature to attributes
+  /// It calls the next method for each feature
+  /// \param theFeatureToAttributes a map of feature to attributes
+  /// \param theSketch a current sketch feature
+  /// \param theWorkshop a workshop to have an access to AIS context and displayer
+  /// \param theSelection a container for the selection, to save results and attributres for a feature
+  static void getCurrentSelection(const FeatureToAttributesMap& theFeatureToAttributes,
+                                  const FeaturePtr& theSketch,
+                                  ModuleBase_IWorkshop* theWorkshop,
+                                  FeatureToSelectionMap& theSelection);
+
   /// Obtains the current selection of the object in the workshop viewer 
   /// It includes the selection in all modes of activation, even local context - vertices, edges
   /// It gets all results of the feature, find an AIS object in the viewer and takes all BRep
@@ -115,8 +128,6 @@ private:
 
   CompositeFeaturePtr myCurrentSketch;
 
-  typedef QList<AttributePtr> AttributeList;
-  typedef QMap<FeaturePtr, AttributeList> FeatureToAttributesMap;
   FeatureToAttributesMap myFeature2AttributeMap; /// a map of a feature to attributes
 
   Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;