Salome HOME
Merge branch 'master' of newgeom:newgeom.git into BR_PYTHON_PLUGIN
[modules/shaper.git] / src / XGUI / XGUI_Selection.cpp
index 1b91cb3dccad3b2dc905d617c40f91ebf8b16474..265fb9029145f05e8a63370042d921408ef64bff 100644 (file)
@@ -19,10 +19,10 @@ XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop)
 {
 }
 
-std::list<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip) const
+QList<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip) const
 {
-  std::set<ObjectPtr> aPrsFeatures;
-  std::list<ModuleBase_ViewerPrs> aPresentations;
+  //std::set<ObjectPtr> aPrsFeatures;
+  QList<ModuleBase_ViewerPrs> aPresentations;
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
@@ -33,10 +33,12 @@ std::list<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSk
     aPrs.setInteractive(anIO);
 
     ObjectPtr aFeature = aDisplayer->getObject(anIO);
-    if (aPrsFeatures.find(aFeature) == aPrsFeatures.end()) {
+    // we should not check the appearance of this feature because there can be some selected shapes
+    // for one feature
+    //if (aPrsFeatures.find(aFeature) == aPrsFeatures.end()) {
       aPrs.setFeature(aFeature);
-      aPrsFeatures.insert(aFeature);
-    }
+      //aPrsFeatures.insert(aFeature);
+    //}
     if (aContext->HasOpenedContext()) {
       TopoDS_Shape aShape = aContext->SelectedShape();
       if (!aShape.IsNull() && (aShape.ShapeType() != theShapeTypeToSkip))
@@ -44,15 +46,15 @@ std::list<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSk
     }
     Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
     aPrs.setOwner(anOwner);
-    aPresentations.push_back(aPrs);
+    aPresentations.append(aPrs);
   }
   return aPresentations;
 }
 
-std::list<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const
+QList<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const
 {
-  std::set<ObjectPtr> aPrsFeatures;
-  std::list<ModuleBase_ViewerPrs> aPresentations;
+  //std::set<ObjectPtr> aPrsFeatures;
+  QList<ModuleBase_ViewerPrs> aPresentations;
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
@@ -62,10 +64,12 @@ std::list<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeT
     aPrs.setInteractive(anIO);
 
     ObjectPtr aResult = aDisplayer->getObject(anIO);
-    if (aPrsFeatures.find(aResult) == aPrsFeatures.end()) {
+    // we should not check the appearance of this feature because there can be some selected shapes
+    // for one feature
+    //if (aPrsFeatures.find(aResult) == aPrsFeatures.end()) {
       aPrs.setFeature(aResult);
-      aPrsFeatures.insert(aResult);
-    }
+      //aPrsFeatures.insert(aResult);
+    //}
     if (aContext->HasOpenedContext()) {
       TopoDS_Shape aShape = aContext->DetectedShape();
       if (!aShape.IsNull() && aShape.ShapeType() != theShapeTypeToSkip)
@@ -121,10 +125,12 @@ void XGUI_Selection::selectedShapes(NCollection_List<TopoDS_Shape>& theList,
     if (!aShape.IsNull()) {
       theList.Append(aShape);
       Handle(SelectMgr_EntityOwner) aEO = aContext->SelectedOwner();
-      Handle(AIS_InteractiveObject) anObj = 
-        Handle(AIS_InteractiveObject)::DownCast(aEO->Selectable());
-      ObjectPtr anObject = myWorkshop->displayer()->getObject(anObj);
-      theOwners.push_back(anObject);
+      if (!aEO.IsNull()) {
+        Handle(AIS_InteractiveObject) anObj = 
+          Handle(AIS_InteractiveObject)::DownCast(aEO->Selectable());
+        ObjectPtr anObject = myWorkshop->displayer()->getObject(anObj);
+        theOwners.push_back(anObject);
+      }
     }
   }
 }