1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
20 #ifndef XGUI_Selection_H
21 #define XGUI_Selection_H
25 #include <ModuleBase_Definitions.h>
26 #include <ModuleBase_ISelection.h>
28 #include <QModelIndexList>
29 #include <AIS_ListOfInteractive.hxx>
30 #include <NCollection_List.hxx>
31 #include <TopoDS_Shape.hxx>
33 #include <SelectMgr_IndexedMapOfOwner.hxx>
36 class SelectMgr_EntityOwner;
37 class ModuleBase_ViewerPrs;
41 * Implementation of \ref ModuleBase_ISelection interface.
43 class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
47 /// \param theWorkshop reference to workshop instance
48 XGUI_Selection(XGUI_Workshop* theWorkshop);
50 /// Returns a list of viewer selected presentations
51 /// \return list of presentations
52 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>>
53 getSelected(const SelectionPlace& thePlace = Browser) const;
55 /// Fills the viewer presentation parameters by the parameters from the owner
56 /// \param thePrs a container for selection
57 /// \param theOwner a selection owner
58 virtual void fillPresentation(std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
59 const Handle(SelectMgr_EntityOwner)& theOwner) const;
61 /// Returns a list of viewer highlited presentations
62 /// \return list of presentations
63 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getHighlighted() const;
66 * Returns list of currently selected objects in object browser
68 virtual QObjectPtrList selectedObjects() const;
70 virtual void setSelectedObjects( const QObjectPtrList& ) const;
73 * Returns list of currently selected results
75 virtual QObjectPtrList selectedPresentations() const;
77 //! Returns list of currently selected QModelIndexes
78 virtual QModelIndexList selectedIndexes() const;
80 //! Returns list of currently selected QModelIndexes
81 ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner);
83 //! Returns list of currently selected AIS objects
84 virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const;
86 //! Return a selectable object by the entity owner. It founds AIS object in the viewer
87 //! and returns the corresponded object
88 /// \param theOwner an entity owner
89 /// \return a found object or NULL
90 ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner) const;
92 //! Returns list of currently selected owners
93 /// \return list of owners
94 void selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const;
96 //! Returns a list of selection entity owners of the interactive object
97 /// It depends on the modes, in which the object is activated in the context
98 /// \param theObject an object
99 /// \param theOwners a map of entity owners
100 void entityOwners(const Handle_AIS_InteractiveObject& theObject,
101 SelectMgr_IndexedMapOfOwner& theOwners) const;
103 //! Return the IO from the viewer presentation.
104 //! \param thePrs a selected object
105 //! \return an interactive object
106 virtual Handle(AIS_InteractiveObject) getIO(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
109 /// Fills the list of presentations by objects selected in the viewer.
110 /// \param thePresentations an output list of presentation
111 void getSelectedInViewer(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& thePresentations) const;
112 /// Fills the list of presentations by objects selected in the object browser.
113 /// ViewerPrs contains only object parameter not empty.
114 /// If the given list of presentations already has a viewer presentation with the same object
115 /// as selected in the browser, a new item is not appended to the list of presentations.
116 /// \param thePresentations an output list of presentation
117 void getSelectedInBrowser(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& thePresentations) const;
119 /// Generates a vertex or edge by the give IO if it is an AIS created on trihedron
120 /// \param theIO a selected object
121 /// \return created shape or empty shape
122 #ifdef BEFORE_TRIHEDRON_PATCH
123 TopoDS_Shape findAxisShape(Handle(AIS_InteractiveObject) theIO) const;
127 XGUI_Workshop* myWorkshop;