]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_ISelection.cpp
Salome HOME
SkethMgr - to avoid big arrows in gzy_reactor file
[modules/shaper.git] / src / ModuleBase / ModuleBase_ISelection.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 #include "ModuleBase_ISelection.h"
4
5 //********************************************************************
6 ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrs& thePrs)
7 {
8   ResultPtr aResult;
9
10   if (!thePrs.owner().IsNull()) {
11     ObjectPtr anObject = getSelectableObject(thePrs.owner());
12     aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
13   }
14   else {
15     aResult = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
16   }
17
18   return aResult;
19 }
20
21 //********************************************************************
22 GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrs& thePrs)
23 {
24   GeomShapePtr aShape;
25
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()) {
29   }
30   else {
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();
37   }
38   return aShape;
39 }
40
41 //********************************************************************
42 QList<ModuleBase_ViewerPrs> ModuleBase_ISelection::getViewerPrs(const QObjectPtrList& theObjects)
43 {
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));
50     }
51   }
52   return aSelectedPrs;
53 }