]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
The local selection restore for a feature vertex (it is checked on the line feature)
authornds <natalia.donis@opencascade.com>
Fri, 26 Dec 2014 15:24:50 +0000 (18:24 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 26 Dec 2014 15:24:50 +0000 (18:24 +0300)
A fix for restore selection after manipulation close/open local context on display.

src/PartSet/PartSet_SketcherMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Selection.cpp
src/XGUI/XGUI_Selection.h
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_SelectionMgr.h

index edc27e0b7ae1e236a16dc66cbb3ee53ee70b27d8..a2303017c011a052de5755bd21540c5a0e3e3dae 100644 (file)
@@ -13,6 +13,7 @@
 #include <XGUI_Displayer.h>
 #include <XGUI_Workshop.h>
 #include <XGUI_Selection.h>
+#include <XGUI_SelectionMgr.h>
 
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_IWorkshop.h>
@@ -530,7 +531,7 @@ void PartSet_SketcherMgr::getSelectionOwners(const ObjectPtr& theObject,
 
     SelectMgr_IndexedMapOfOwner aSelectedOwners;
 
-    XGUI_Selection::entityOwners(anAISIO, aContext, aSelectedOwners);
+    aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
     for  ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
       Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
       if ( anOwner.IsNull() || !anOwner->HasShape() )
index c06aae88a7d4fbbd78c538005d9aed8ac2c77a27..bf5a0516545685504f0a484595aa68553c742673 100644 (file)
@@ -7,6 +7,8 @@
 #include "XGUI_Displayer.h"
 #include "XGUI_Workshop.h"
 #include "XGUI_ViewerProxy.h"
+#include "XGUI_SelectionMgr.h"
+#include "XGUI_Selection.h"
 
 #include <AppElements_Viewer.h>
 
@@ -131,8 +133,11 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
     myResult2AISObjectMap[theObject] = theAIS;
     bool aCanBeShaded = canBeShaded(anAISIO);
     // In order to avoid extra closing/opening context
-    if (aCanBeShaded)
+    SelectMgr_IndexedMapOfOwner aSelectedOwners;
+    if (aCanBeShaded) {
+      myWorkshop->selector()->selection()->selectedOwners(aSelectedOwners);
       closeLocalContexts(false);
+    }
     aContext->Display(anAISIO, false);
     qDebug("### Display %i", (long)anAISIO.Access());
 
@@ -147,6 +152,7 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
     if (aCanBeShaded) {
       openLocalContext();
       activateObjects(myActiveSelectionModes);
+      myWorkshop->selector()->setSelectedOwners(aSelectedOwners);
     }
   }
   if (isUpdateViewer)
index 7b4bb5ff1601e0c22f1ca481dd0fcc3c9969bd38..23b11c9fbeeb83e81414bc31e2b1a1c2cef6a3e7 100644 (file)
@@ -157,16 +157,27 @@ void XGUI_Selection::selectedShapes(NCollection_List<TopoDS_Shape>& theList,
   }
 }
 
+//**************************************************************
+void XGUI_Selection::selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const
+{
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+
+  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+    theSelectedOwners.Add(aContext->SelectedOwner());
+  }
+}
+
 //**************************************************************
 void XGUI_Selection::entityOwners(const Handle(AIS_InteractiveObject)& theObject,
-                                  const Handle(AIS_InteractiveContext)& theContext,
-                                  SelectMgr_IndexedMapOfOwner& theOwners)
+                                  SelectMgr_IndexedMapOfOwner& theOwners) const
 {
-    if (theObject.IsNull() || theContext.IsNull())
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+
+  if (theObject.IsNull() || aContext.IsNull())
     return;
 
   TColStd_ListOfInteger aModes;
-  theContext->ActivatedModes(theObject, aModes);
+  aContext->ActivatedModes(theObject, aModes);
 
   TColStd_ListIteratorOfListOfInteger anIt(aModes);
   for (; anIt.More(); anIt.Next()) {
index c411d5ff09abea1af10db7caa360b173b5d1fba1..5dcd44ee157adbb11a40f159d0425ab29682efd0 100644 (file)
@@ -57,14 +57,16 @@ class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
   virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theShapes, 
     std::list<ObjectPtr>& theOwners) const;
 
+  //! Returns list of currently selected owners
+  /// \return list of owners
+  void selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const;
+
   //! Returns a list of selection entity owners of the interactive object
   /// It depends on the modes, in which the object is activated in the context
   /// \param theObject an object
-  /// \param theContext a viewer interactive context
   /// \param theOwners a map of entity owners
-  static void entityOwners(const Handle_AIS_InteractiveObject& theObject,
-                           const Handle_AIS_InteractiveContext& theContext,
-                           SelectMgr_IndexedMapOfOwner& theOwners);
+  void entityOwners(const Handle_AIS_InteractiveObject& theObject,
+                    SelectMgr_IndexedMapOfOwner& theOwners) const;
 
  private:
   XGUI_Workshop* myWorkshop;
index bafdeda30423f348fe2e8ca03a30d978d22df891..0cdaecf9ba94fdd830f7faefff3d03f0855f22c4 100644 (file)
@@ -40,6 +40,15 @@ void XGUI_SelectionMgr::connectViewers()
   connect(myWorkshop->viewer(), SIGNAL(selectionChanged()), this, SLOT(onViewerSelection()));
 }
 
+//**************************************************************
+void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners)
+{
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  for  (Standard_Integer i = 1, n = theSelectedOwners.Extent(); i <= n; i++)  {
+    aContext->AddOrRemoveSelected(theSelectedOwners(i), false);
+  }
+}
+
 //**************************************************************
 void XGUI_SelectionMgr::onObjectBrowserSelection()
 {
index 6b45fff70adb6f2b564d602964cfd97ad3b20b79..8d74e0990a9357d1d05985cd3fb8f1b876a5e809 100644 (file)
@@ -11,6 +11,7 @@
 #include <AIS_ListOfInteractive.hxx>
 #include <NCollection_List.hxx>
 #include <TopoDS_Shape.hxx>
+#include <SelectMgr_IndexedMapOfOwner.hxx>
 
 class XGUI_Workshop;
 class XGUI_ObjectsBrowser;
@@ -36,6 +37,10 @@ Q_OBJECT
   //! Connects the manager to all viewers accessible by Workshop
   void connectViewers();
 
+  //! Selects the owners in the context.
+  //! \param theSelectedOwners a container of owners
+  void setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners);
+
 signals:
   //! Emited when selection in a one of viewers was changed
   void selectionChanged();