- ObjectPtr aFeature = myWorkshop->displayer()->getObject(anIO);
- if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
- continue;
- Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
- aPresentations.push_back(ModuleBase_ViewerPrs(aFeature, aShape, anOwner));
- aPrsFeatures.insert(aFeature);
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ if (aContext->HasOpenedContext()) {
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+ ModuleBase_ViewerPrs aPrs;
+ Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+ if (aSelectedIds.contains((long)anIO.Access()))
+ continue;
+
+ aSelectedIds.append((long)anIO.Access());
+ aPrs.setInteractive(anIO);
+
+ ObjectPtr aFeature = aDisplayer->getObject(anIO);
+ // we should not check the appearance of this feature because there can be some selected shapes
+ // for one feature
+ TopoDS_Shape aShape = aContext->SelectedShape();
+ if (!aShape.IsNull() && (aShape.ShapeType() != theShapeTypeToSkip))
+ aPrs.setShape(aShape);
+ Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
+ aPrs.setOwner(anOwner);
+ aPrs.setFeature(aFeature);
+ aPresentations.append(aPrs);
+ }
+ } else {
+ for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent()) {
+ ModuleBase_ViewerPrs aPrs;
+ Handle(AIS_InteractiveObject) anIO = aContext->Current();
+ if (aSelectedIds.contains((long)anIO.Access()))
+ continue;
+
+ aSelectedIds.append((long)anIO.Access());
+ aPrs.setInteractive(anIO);
+
+ ObjectPtr aFeature = aDisplayer->getObject(anIO);
+ aPrs.setFeature(aFeature);
+ aPresentations.append(aPrs);
+ }