1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #include "ModuleBase_ISelection.h"
5 //********************************************************************
6 ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrs& thePrs)
10 if (!thePrs.owner().IsNull()) {
11 ObjectPtr anObject = getSelectableObject(thePrs.owner());
12 aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
15 aResult = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
21 //********************************************************************
22 GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrs& thePrs)
26 const TopoDS_Shape& aTDSShape = thePrs.shape();
27 // if only result is selected, an empty shape is set to the model
28 if (aTDSShape.IsNull()) {
31 aShape = GeomShapePtr(new GeomAPI_Shape());
32 aShape->setImpl(new TopoDS_Shape(aTDSShape));
33 // If the result object is built on the same shape, the result shape here is empty one
34 ResultPtr aResult = getResult(thePrs);
35 if (aResult.get() && aShape->isEqual(aResult->shape()))
36 aShape = GeomShapePtr();
41 //********************************************************************
42 QList<ModuleBase_ViewerPrs> ModuleBase_ISelection::getViewerPrs(const QObjectPtrList& theObjects)
44 QList<ModuleBase_ViewerPrs> aSelectedPrs;
45 QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
46 for (; anIt != aLast; anIt++) {
47 ObjectPtr anObject = *anIt;
48 if (anObject.get() != NULL) {
49 aSelectedPrs.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));