1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_ISelection.h
4 // Created: 2 June 2014
5 // Author: Vitaly Smetannikov
7 #ifndef ModuleBase_ISelection_H
8 #define ModuleBase_ISelection_H
10 #include "ModuleBase.h"
11 #include "ModuleBase_Definitions.h"
12 #include "ModuleBase_ViewerPrs.h"
14 #include <ModelAPI_Result.h>
15 #include <GeomAPI_Shape.h>
17 #include <QModelIndexList>
18 #include <AIS_ListOfInteractive.hxx>
19 #include <NCollection_List.hxx>
20 #include <TopoDS_Shape.hxx>
24 class Handle_SelectMgr_EntityOwner;
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
31 class ModuleBase_ISelection
34 /// Types of the selection place, where the selection is obtained
35 enum SelectionPlace { Browser, Viewer, AllControls };
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;
41 /// The values are appended to the first parameter list if the first list does not contain an item
42 /// with the same object
43 /// \param theValues a list of new values
44 /// \param theValuesTo a list, that will be changed
45 static void appendSelected(const QList<ModuleBase_ViewerPrs> theValues,
46 QList<ModuleBase_ViewerPrs>& theValuesTo);
48 /// Returns a list of viewer highlited presentations
49 /// \return list of presentations
50 virtual QList<ModuleBase_ViewerPrs> getHighlighted() const = 0;
52 /// Fills the viewer presentation parameters by the parameters from the owner
53 /// \param thePrs a container for selection
54 /// \param theOwner a selection owner
55 virtual void fillPresentation(ModuleBase_ViewerPrs& thePrs,
56 const Handle_SelectMgr_EntityOwner& theOwner) const = 0;
59 * Returns list of features currently selected in object browser
61 virtual QObjectPtrList selectedObjects() const = 0;
63 virtual void setSelectedObjects( const QObjectPtrList& ) const = 0;
66 * Returns list of currently selected results
68 virtual QObjectPtrList selectedPresentations() const = 0;
70 //! Returns list of currently selected QModelIndexes
71 virtual QModelIndexList selectedIndexes() const = 0;
73 //! Returns list of currently selected AIS objects
74 //! \param theList returning list of selected AIS objects
75 virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const = 0;
77 //! Returns list of currently selected QModelIndexes
78 virtual ObjectPtr getSelectableObject(const Handle_SelectMgr_EntityOwner& theOwner) const = 0;
80 //! Returns list of currently selected shapes and their owners (objects).
81 //! Both lists are synchronized
82 //! \param theList returning list of selected AIS objects
83 //! \param theOwners list of objects
84 virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theList,
85 std::list<ObjectPtr>& theOwners) const = 0;
87 //! Return the shape from the viewer presentation.
88 //! If the shape is equal to the shape of selected object, it returns an empty shape
89 //! \param thePrs a selected object
91 MODULEBASE_EXPORT ResultPtr getResult(const ModuleBase_ViewerPrs& thePrs);
93 //! Return the shape from the viewer presentation.
94 //! If the shape is equal to the shape of selected object, it returns an empty shape
95 //! \param thePrs a selected object
97 MODULEBASE_EXPORT GeomShapePtr getShape(const ModuleBase_ViewerPrs& thePrs);
99 //! Return the IO from the viewer presentation.
100 //! \param thePrs a selected object
101 //! \return an interactive object
102 virtual MODULEBASE_EXPORT Handle(AIS_InteractiveObject) getIO(const ModuleBase_ViewerPrs& thePrs) = 0;
104 //! Wraps the object list into the viewer prs list
105 //! \param theObjects a list of objects
106 //! \return a list of prs, where only object is not empty
107 static MODULEBASE_EXPORT QList<ModuleBase_ViewerPrs> getViewerPrs(
108 const QObjectPtrList& theObjects);