+void PartSet_OperationPrs::getResultShapes(const FeaturePtr& theFeature,
+ ModuleBase_IWorkshop* theWorkshop,
+ QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
+ const bool theListShouldBeCleared)
+{
+ if (theListShouldBeCleared)
+ theObjectShapes.clear();
+
+ if (!theFeature.get())
+ return;
+
+ XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer();
+
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(theFeature, aResults);
+ std::list<ResultPtr>::const_iterator aRIt = aResults.begin(),
+ aRLast = aResults.end();
+ for (; aRIt != aRLast; aRIt++) {
+ ResultPtr aResult = *aRIt;
+ GeomShapePtr aGeomShape = aResult->shape();
+ appendShapeIfVisible(theWorkshop, aResult, aGeomShape, theObjectShapes);
+ }
+}
+
+void PartSet_OperationPrs::getPresentationShapes(const FeaturePtr& theFeature,
+ ModuleBase_IWorkshop* theWorkshop,
+ QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
+ const bool theListShouldBeCleared)
+{
+ if (theListShouldBeCleared)
+ theObjectShapes.clear();
+
+ if (!theFeature.get() || !theFeature->data()->isValid()) // if feature is already removed
+ return;
+
+ XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer();
+
+ GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theFeature);
+ if (!aPrs.get())
+ return;
+
+ AISObjectPtr anAIS = aPrs->getAISObject(aDisplayer->getAISObject(theFeature));
+ if (!anAIS.get())
+ return;
+
+ Handle(AIS_InteractiveObject) anAISPrs = anAIS->impl<Handle(AIS_InteractiveObject)>();
+ if (!anAISPrs.IsNull()) {
+ Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
+ if (!aShapePrs.IsNull()) {
+ TopoDS_Shape aShape = aShapePrs->Shape();
+ if (!aShape.IsNull()) {
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape());
+ aGeomShape->setImpl(new TopoDS_Shape(aShape));
+ appendShapeIfVisible(theWorkshop, theFeature, aGeomShape, theObjectShapes);
+ }
+ }
+ }
+}
+
+void PartSet_OperationPrs::getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
+ QMap<ObjectPtr,
+ QList<GeomShapePtr> >& theObjectShapes)
+{
+ theObjectShapes.clear();
+
+ QList<ModuleBase_ViewerPrsPtr> aValues;
+ ModuleBase_ModelWidget* anActiveWidget = theWorkshop->module()->activeWidget();
+ if (anActiveWidget)
+ anActiveWidget->getHighlighted(aValues);
+
+ QList<GeomShapePtr> aShapes;
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIIt = aValues.begin(),
+ aILast = aValues.end();
+ for (; anIIt != aILast; anIIt++) {
+ ModuleBase_ViewerPrsPtr aPrs = *anIIt;
+ ObjectPtr anObject = aPrs->object();
+
+ GeomShapePtr aGeomShape = aPrs->shape();
+ if (!aGeomShape.get() || aGeomShape->isNull()) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ if (aResult.get()) {
+ aGeomShape = aResult->shape();
+ }
+ }
+ appendShapeIfVisible(theWorkshop, anObject, aGeomShape, theObjectShapes);
+ }
+}
+
+