+ // we should not check the appearance of this feature because there can be some selected shapes
+ // for one feature
+ Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+ if( !aBRO.IsNull() && aBRO->HasShape() ) {
+ // the located method is called in the context to obtain the shape by the SelectedShape()
+ // method, so the shape is located by the same rules
+ TopoDS_Shape aShape = aBRO->Shape().Located (aBRO->Location() * aBRO->Shape().Location());
+#ifdef BEFORE_TRIHEDRON_PATCH
+#ifndef DEBUG_DELIVERY
+ if (aShape.IsNull())
+ aShape = findAxisShape(anIO);
+#endif
+#endif
+ if (!aShape.IsNull()) {
+ std::shared_ptr<GeomAPI_Shape> aGeomShape =
+ std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aGeomShape->setImpl(new TopoDS_Shape(aShape));
+ thePrs->setShape(aGeomShape);
+ }
+ } else {
+#ifdef DEBUG_DELIVERY
+ // Fill by trihedron shapes
+#ifdef BEFORE_TRIHEDRON_PATCH
+ Handle(AIS_Axis) aAxis = Handle(AIS_Axis)::DownCast(anIO);
+ DocumentPtr aDoc = ModelAPI_Session::get()->moduleDocument();
+ int aSize = aDoc->size(ModelAPI_ResultConstruction::group());
+ ObjectPtr aObj;
+ if (!aAxis.IsNull()) {
+ // an Axis from Trihedron
+ gp_Lin aLine = aAxis->Component()->Lin();
+ gp_Dir aDir = aLine.Direction();
+ std::string aAxName;
+ if (aDir.X() == 1.)
+ aAxName = "OX";
+ else if (aDir.Y() == 1.)
+ aAxName = "OY";
+ else if (aDir.Z() == 1.)
+ aAxName = "OZ";
+ if (aAxName.length() > 0) {
+ ResultPtr aAx;
+ for (int i = 0; i < aSize; i++) {
+ aObj = aDoc->object(ModelAPI_ResultConstruction::group(), i);
+ if (aObj->data()->name() == aAxName) {
+ aAx = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ break;
+ }
+ }
+ if (aAx.get()) {
+ thePrs->setObject(aAx);
+ thePrs->setShape(aAx->shape());
+ return;
+ }
+ }
+ } else {
+ Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(anIO);
+ if (!aPoint.IsNull()) {
+ // An origin point from trihedron
+ ResultPtr aOrigin;
+ for (int i = 0; i < aSize; i++) {
+ aObj = aDoc->object(ModelAPI_ResultConstruction::group(), i);
+ if (aObj->data()->name() == "Origin") {
+ aOrigin = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ break;
+ }
+ }
+ if (aOrigin.get()) {
+ thePrs->setObject(aOrigin);
+ thePrs->setShape(aOrigin->shape());
+ return;
+ }
+ }
+ }
+#else
+ /// find axis direction
+ Handle(AIS_TrihedronOwner) aTrihedronOwner = Handle(AIS_TrihedronOwner)::DownCast(theOwner);
+ if (!aTrihedronOwner.IsNull()) {
+ const Prs3d_DatumParts& aPart = aTrihedronOwner->DatumPart();
+ std::string aName;
+ switch (aPart) {
+ case Prs3d_DP_Origin: aName = "Origin"; break;
+ case Prs3d_DP_XAxis: aName = "OX"; break;
+ case Prs3d_DP_YAxis: aName = "OY"; break;
+ case Prs3d_DP_ZAxis: aName = "OZ"; break;
+ default: break;
+ }
+ if (aName.length() > 0) {
+ DocumentPtr aDoc = ModelAPI_Session::get()->moduleDocument();
+ int aSize = aDoc->size(ModelAPI_ResultConstruction::group());
+ ObjectPtr aObj;
+ ResultPtr aResult;
+ for (int i = 0; i < aSize; i++) {
+ aObj = aDoc->object(ModelAPI_ResultConstruction::group(), i);
+ if (aObj->data()->name() == aName) {
+ aResult = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ break;
+ }
+ }
+ if (aResult.get()) {
+ thePrs->setObject(aResult);
+ thePrs->setShape(aResult->shape());
+ return;
+ }
+ }
+ }
+#endif
+#endif
+ }
+
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ ObjectPtr aFeature = aDisplayer->getObject(anIO);
+
+ Handle(ModuleBase_BRepOwner) aCompSolidBRO = Handle(ModuleBase_BRepOwner)::DownCast(theOwner);
+ if (!aCompSolidBRO.IsNull()) {
+ // If ModuleBase_BRepOwner object is created then it means that TopAbs_COMPSOLID selection mode
+ // is On and we have to use parent result which corresponds to the CompSolid shape
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aFeature);
+ if (aResult.get()) {
+ ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(aResult);
+ if (aCompSolid.get()) {
+ GeomShapePtr aShape = aCompSolid->shape();
+ if (aShape.get() && aShape->isEqual(thePrs->shape())) {
+ thePrs->setObject(aCompSolid);
+ return;
+ }
+ }
+ }
+ }
+ thePrs->setObject(aFeature);
+}
+
+QList<ModuleBase_ViewerPrsPtr> XGUI_Selection::getHighlighted() const
+{
+ QList<ModuleBase_ViewerPrsPtr> aPresentations;