#include <AIS_Axis.hxx>
#include <AIS_Plane.hxx>
#include <AIS_Point.hxx>
+#include <AIS_Selection.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <SelectMgr_ListOfFilter.hxx>
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
//#define DEBUG_COMPOSILID_DISPLAY
// Workaround for bug #25637
+
+//#define DEBUG_OCCT_SHAPE_SELECTION
+
void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
{
// Get from null point
if (aContext->HasOpenedContext()) {
aContext->UnhilightSelected(false);
aContext->ClearSelected(false);
+ NCollection_Map<TopoDS_Shape> aShapesToBeSelected;
+
foreach (ModuleBase_ViewerPrsPtr aPrs, theValues) {
const GeomShapePtr& aGeomShape = aPrs->shape();
if (aGeomShape.get() && !aGeomShape->isNull()) {
const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
+#ifdef DEBUG_OCCT_SHAPE_SELECTION
aContext->AddOrRemoveSelected(aShape, false);
+#else
+ aShapesToBeSelected.Add(aShape);
+#endif
} else {
ObjectPtr anObject = aPrs->object();
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
}
}
}
+ if (!aShapesToBeSelected.IsEmpty())
+ XGUI_Displayer::AddOrRemoveSelectedShapes(aContext, aShapesToBeSelected);
} else {
aContext->UnhilightCurrents(false);
aContext->ClearCurrents(false);
}
return aModes;
}
+
+void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext,
+ const NCollection_Map<TopoDS_Shape>& theShapesToBeSelected)
+{
+ Handle(AIS_LocalContext) aLContext = theContext->LocalContext();
+ TCollection_AsciiString aSelectionName = aLContext->SelectionName();
+ aLContext->UnhilightPicked(Standard_False);
+
+ NCollection_Map<TopoDS_Shape> aShapesSelected;
+
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
+ aLContext->MainSelector()->ActiveOwners(anActiveOwners);
+ NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
+ Handle(SelectMgr_EntityOwner) anOwner;
+ for (; anOwnersIt.More(); anOwnersIt.Next()) {
+ anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
+ if (!BROwnr.IsNull() && BROwnr->HasShape() && theShapesToBeSelected.Contains(BROwnr->Shape())) {
+ if (aShapesSelected.Contains(BROwnr->Shape()))
+ continue;
+ AIS_Selection::Selection(aSelectionName.ToCString())->Select(anOwner);
+ anOwner->SetSelected (Standard_True);
+ aShapesSelected.Add(BROwnr->Shape());
+ }
+ }
+ aLContext->HilightPicked(Standard_False);
+}
/// \return a string representation
std::string getResult2AISObjectMapInfo() const;
+ /// Sets the shapes selected in the context. It contains logic of the similar method
+ /// in OCCT but improved for performance. The modification is to iterates by a list
+ /// of owners in the context only once.
+ /// \param theContext a viewer context. It has opened local context
+ /// \param theShapesToBeSelected a map of shapes. Owner's shape is searched in the map and the owner
+ /// is selected if it is found there. Only first owner is processed(according to OCCT logic)
+ static void AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext,
+ const NCollection_Map<TopoDS_Shape>& theShapesToBeSelected);
+
protected:
/// Reference to workshop
XGUI_Workshop* myWorkshop;