Salome HOME
0f653f6315cea3b78cf421fca135b259f45e9365
[modules/shaper.git] / src / ModuleBase / ModuleBase_ISelection.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_ISelection.h
4 // Created:     2 June 2014
5 // Author:      Vitaly Smetannikov
6
7 #ifndef ModuleBase_ISelection_H
8 #define ModuleBase_ISelection_H
9
10 #include "ModuleBase.h"
11 #include "ModuleBase_Definitions.h"
12 #include "ModuleBase_ViewerPrs.h"
13
14 #include <ModelAPI_Result.h>
15 #include <GeomAPI_Shape.h>
16
17 #include <QModelIndexList>
18 #include <AIS_ListOfInteractive.hxx>
19 #include <NCollection_List.hxx>
20 #include <TopoDS_Shape.hxx>
21
22 #include <QList>
23
24 class Handle_SelectMgr_EntityOwner;
25
26 /**
27 * \ingroup GUI
28 * A class which provides access to selection.
29 * A selection can be obtained as from a viewer as from Object browser in various forms
30 */
31 class ModuleBase_ISelection
32 {
33  public:
34    /// Types of the selection place, where the selection is obtained
35    enum SelectionPlace { Browser, Viewer, AllControls };
36
37   /// Returns a list of viewer selected presentations
38   /// \return list of presentations
39   virtual QList<ModuleBase_ViewerPrs> getSelected(const SelectionPlace& thePlace = Browser) const = 0;
40
41   /// Returns a list of viewer highlited presentations
42   /// \return list of presentations
43   virtual QList<ModuleBase_ViewerPrs> getHighlighted() const = 0;
44
45   /// Fills the viewer presentation parameters by the parameters from the owner
46   /// \param thePrs a container for selection
47   /// \param theOwner a selection owner
48   virtual void fillPresentation(ModuleBase_ViewerPrs& thePrs,
49                                 const Handle_SelectMgr_EntityOwner& theOwner) const = 0;
50
51   /**
52    * Returns list of features currently selected in object browser
53    */
54   virtual QObjectPtrList selectedObjects() const = 0;
55
56   /**
57    * Returns list of currently selected results
58    */
59   virtual QObjectPtrList selectedPresentations() const = 0;
60
61   //! Returns list of currently selected QModelIndexes
62   virtual QModelIndexList selectedIndexes() const = 0;
63
64   //! Returns list of currently selected AIS objects
65   //! \param theList returning list of selected AIS objects
66   virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const = 0;
67
68   //! Returns list of currently selected QModelIndexes
69   virtual ObjectPtr getSelectableObject(const Handle_SelectMgr_EntityOwner& theOwner) const = 0;
70
71   //! Returns list of currently selected shapes and their owners (objects).
72   //! Both lists are synchronized
73   //! \param theList returning list of selected AIS objects
74   //! \param theOwners list of objects
75   virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theList, 
76     std::list<ObjectPtr>& theOwners) const = 0;
77
78   //! Return the shape from the viewer presentation.
79   //! If the shape is equal to the shape of selected object, it returns an empty shape
80   //! \param thePrs a selected object
81   //! \return a shape
82   MODULEBASE_EXPORT ResultPtr getResult(const ModuleBase_ViewerPrs& thePrs);
83
84   //! Return the shape from the viewer presentation.
85   //! If the shape is equal to the shape of selected object, it returns an empty shape
86   //! \param thePrs a selected object
87   //! \return a shape
88   MODULEBASE_EXPORT GeomShapePtr getShape(const ModuleBase_ViewerPrs& thePrs);
89
90   //! Wraps the object list into the viewer prs list
91   //! \param theObjects a list of objects
92   //! \return a list of prs, where only object is not empty
93   static MODULEBASE_EXPORT QList<ModuleBase_ViewerPrs> getViewerPrs(
94                                                        const QObjectPtrList& theObjects);
95 };
96
97 #endif