1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: XGUI_Selection.h
4 // Created: 8 July 2014
5 // Author: Vitaly SMETANNIKOV
7 #ifndef XGUI_Selection_H
8 #define XGUI_Selection_H
12 #include <ModuleBase_ViewerPrs.h>
13 #include <ModuleBase_Definitions.h>
14 #include <ModuleBase_ISelection.h>
16 #include <QModelIndexList>
17 #include <AIS_ListOfInteractive.hxx>
18 #include <NCollection_List.hxx>
19 #include <TopoDS_Shape.hxx>
21 #include <SelectMgr_IndexedMapOfOwner.hxx>
24 class Handle_SelectMgr_EntityOwner;
28 * Implementation of \ref ModuleBase_ISelection interface.
30 class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
34 /// \param theWorkshop reference to workshop instance
35 XGUI_Selection(XGUI_Workshop* theWorkshop);
37 /// Returns a list of viewer selected presentations
38 /// \return list of presentations
39 virtual QList<ModuleBase_ViewerPrs> getSelected(const SelectionPlace& thePlace = Browser) const;
41 /// Fills the viewer presentation parameters by the parameters from the owner
42 /// \param thePrs a container for selection
43 /// \param theOwner a selection owner
44 virtual void fillPresentation(ModuleBase_ViewerPrs& thePrs,
45 const Handle_SelectMgr_EntityOwner& theOwner) const;
47 /// Returns a list of viewer highlited presentations
48 /// \return list of presentations
49 virtual QList<ModuleBase_ViewerPrs> getHighlighted() const;
52 * Returns list of currently selected objects in object browser
54 virtual QObjectPtrList selectedObjects() const;
56 virtual void setSelectedObjects( const QObjectPtrList& ) const;
59 * Returns list of currently selected results
61 virtual QObjectPtrList selectedPresentations() const;
63 //! Returns list of currently selected QModelIndexes
64 virtual QModelIndexList selectedIndexes() const;
66 //! Returns list of currently selected QModelIndexes
67 ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner);
69 //! Returns list of currently selected AIS objects
70 virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const;
72 //! Return a selectable object by the entity owner. It founds AIS object in the viewer
73 //! and returns the corresponded object
74 /// \param theOwner an entity owner
75 /// \return a found object or NULL
76 ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner) const;
78 //! Returns list of currently selected shapes
79 virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theShapes,
80 std::list<ObjectPtr>& theOwners) const;
82 //! Returns list of currently selected owners
83 /// \return list of owners
84 void selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const;
86 //! Returns a list of selection entity owners of the interactive object
87 /// It depends on the modes, in which the object is activated in the context
88 /// \param theObject an object
89 /// \param theOwners a map of entity owners
90 void entityOwners(const Handle_AIS_InteractiveObject& theObject,
91 SelectMgr_IndexedMapOfOwner& theOwners) const;
93 //! Return the IO from the viewer presentation.
94 //! \param thePrs a selected object
95 //! \return an interactive object
96 virtual Handle(AIS_InteractiveObject) getIO(const ModuleBase_ViewerPrs& thePrs);
99 /// Fills the list of presentations by objects selected in the viewer.
100 /// \param thePresentations an output list of presentation
101 void getSelectedInViewer(QList<ModuleBase_ViewerPrs>& thePresentations) const;
102 /// Fills the list of presentations by objects selected in the object browser.
103 /// ViewerPrs contains only object parameter not empty.
104 /// If the given list of presentations already has a viewer presentation with the same object
105 /// as selected in the browser, a new item is not appended to the list of presentations.
106 /// \param thePresentations an output list of presentation
107 void getSelectedInBrowser(QList<ModuleBase_ViewerPrs>& thePresentations) const;
110 XGUI_Workshop* myWorkshop;