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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef XGUI_Selection_H
22 #define XGUI_Selection_H
26 #include <ModuleBase_Definitions.h>
27 #include <ModuleBase_ISelection.h>
29 #include <QModelIndexList>
30 #include <AIS_ListOfInteractive.hxx>
31 #include <NCollection_List.hxx>
32 #include <TopoDS_Shape.hxx>
34 #include <SelectMgr_IndexedMapOfOwner.hxx>
37 class SelectMgr_EntityOwner;
38 class ModuleBase_ViewerPrs;
42 * Implementation of \ref ModuleBase_ISelection interface.
44 class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
48 /// \param theWorkshop reference to workshop instance
49 XGUI_Selection(XGUI_Workshop* theWorkshop);
51 /// Returns a list of viewer selected presentations
52 /// \return list of presentations
53 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>>
54 getSelected(const SelectionPlace& thePlace = Browser) const;
56 /// Fills the viewer presentation parameters by the parameters from the owner
57 /// \param thePrs a container for selection
58 /// \param theOwner a selection owner
59 virtual void fillPresentation(std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
60 const Handle(SelectMgr_EntityOwner)& theOwner) const;
62 /// Returns a list of viewer highlited presentations
63 /// \return list of presentations
64 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getHighlighted() const;
67 * Returns list of currently selected objects in object browser
69 virtual QObjectPtrList selectedObjects() const;
71 virtual void setSelectedObjects( const QObjectPtrList& ) const;
74 * Returns list of currently selected results
76 virtual QObjectPtrList selectedPresentations() const;
78 //! Returns list of currently selected QModelIndexes
79 virtual QModelIndexList selectedIndexes() const;
81 //! Returns list of currently selected QModelIndexes
82 ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner);
84 //! Returns list of currently selected AIS objects
85 virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const;
87 //! Return a selectable object by the entity owner. It founds AIS object in the viewer
88 //! and returns the corresponded object
89 /// \param theOwner an entity owner
90 /// \return a found object or NULL
91 ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner) const;
93 //! Returns list of currently selected owners
94 /// \return list of owners
95 void selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const;
97 //! Returns a list of selection entity owners of the interactive object
98 /// It depends on the modes, in which the object is activated in the context
99 /// \param theObject an object
100 /// \param theOwners a map of entity owners
101 void entityOwners(const Handle_AIS_InteractiveObject& theObject,
102 SelectMgr_IndexedMapOfOwner& theOwners) const;
104 //! Return the IO from the viewer presentation.
105 //! \param thePrs a selected object
106 //! \return an interactive object
107 virtual Handle(AIS_InteractiveObject) getIO(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
110 /// Fills the list of presentations by objects selected in the viewer.
111 /// \param thePresentations an output list of presentation
112 void getSelectedInViewer(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& thePresentations) const;
113 /// Fills the list of presentations by objects selected in the object browser.
114 /// ViewerPrs contains only object parameter not empty.
115 /// If the given list of presentations already has a viewer presentation with the same object
116 /// as selected in the browser, a new item is not appended to the list of presentations.
117 /// \param thePresentations an output list of presentation
118 void getSelectedInBrowser(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& thePresentations) const;
120 /// Generates a vertex or edge by the give IO if it is an AIS created on trihedron
121 /// \param theIO a selected object
122 /// \return created shape or empty shape
123 #ifdef BEFORE_TRIHEDRON_PATCH
124 TopoDS_Shape findAxisShape(Handle(AIS_InteractiveObject) theIO) const;
128 XGUI_Workshop* myWorkshop;