1 // Copyright (C) 2014-2019 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
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;
40 /// Implementation of \ref ModuleBase_ISelection interface.
41 class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
45 /// \param theWorkshop reference to workshop instance
46 XGUI_Selection(XGUI_Workshop* theWorkshop);
48 /// Returns a list of viewer selected presentations
49 /// \return list of presentations
50 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>>
51 getSelected(const SelectionPlace& thePlace = Browser) const;
53 /// Fills the viewer presentation parameters by the parameters from the owner
54 /// \param thePrs a container for selection
55 /// \param theOwner a selection owner
56 virtual void fillPresentation(std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
57 const Handle(SelectMgr_EntityOwner)& theOwner) const;
59 /// Returns a list of viewer highlited presentations
60 /// \return list of presentations
61 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getHighlighted() const;
63 /// Returns list of currently selected objects in object browser
64 virtual QObjectPtrList selectedObjects() const;
66 /// Returns list of currently selected results
67 virtual QObjectPtrList selectedPresentations() const;
69 /// Returns list of currently selected QModelIndexes
70 virtual QModelIndexList selectedIndexes() const;
72 /// Returns list of currently selected owners
73 /// \return list of owners
74 void selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const;
76 /// Returns a list of selection entity owners of the interactive object
77 /// It depends on the modes, in which the object is activated in the context
78 /// \param theObject an object
79 /// \param theOwners a map of entity owners
80 void entityOwners(const Handle(AIS_InteractiveObject)& theObject,
81 SelectMgr_IndexedMapOfOwner& theOwners) const;
83 /// Return the IO from the viewer presentation.
84 /// \param thePrs a selected object
85 /// \return an interactive object
86 virtual Handle(AIS_InteractiveObject) getIO(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
89 /// Return a selectable object by the entity owner. It founds AIS object in the viewer
90 /// and returns the corresponded object
91 /// \param theOwner an entity owner
92 /// \return a found object or NULL
93 ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner) const;
95 /// Fills the list of presentations by objects selected in the viewer.
96 /// \param thePresentations an output list of presentation
97 void getSelectedInViewer(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& thePresentations) const;
99 /// Fills the list of presentations by objects selected in the object browser.
100 /// ViewerPrs contains only object parameter not empty.
101 /// If the given list of presentations already has a viewer presentation with the same object
102 /// as selected in the browser, a new item is not appended to the list of presentations.
103 /// \param thePresentations an output list of presentation
104 void getSelectedInBrowser(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& thePresentations) const;
106 /// Generates a vertex or edge by the give IO if it is an AIS created on trihedron
107 /// \param theIO a selected object
108 /// \return created shape or empty shape
109 #ifdef BEFORE_TRIHEDRON_PATCH
110 TopoDS_Shape findAxisShape(Handle(AIS_InteractiveObject) theIO) const;
114 XGUI_Workshop* myWorkshop; ///< current workshop