]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Selection.h
Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / XGUI / XGUI_Selection.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
18 //
19
20 #ifndef XGUI_Selection_H
21 #define XGUI_Selection_H
22
23 #include "XGUI.h"
24
25 #include <ModuleBase_Definitions.h>
26 #include <ModuleBase_ISelection.h>
27
28 #include <QModelIndexList>
29 #include <AIS_ListOfInteractive.hxx>
30 #include <NCollection_List.hxx>
31 #include <TopoDS_Shape.hxx>
32
33 #include <SelectMgr_IndexedMapOfOwner.hxx>
34
35 class XGUI_Workshop;
36 class SelectMgr_EntityOwner;
37 class ModuleBase_ViewerPrs;
38
39 /**
40 * \ingroup GUI
41 * Implementation of \ref ModuleBase_ISelection interface.
42 */
43 class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
44 {
45  public:
46    /// Constructor
47    /// \param theWorkshop reference to workshop instance
48   XGUI_Selection(XGUI_Workshop* theWorkshop);
49
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;
54
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;
60
61   /// Returns a list of viewer highlited presentations
62   /// \return list of presentations
63   virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getHighlighted() const;
64
65   /**
66    * Returns list of currently selected objects in object browser
67    */
68   virtual QObjectPtrList selectedObjects() const;
69
70   virtual void setSelectedObjects( const QObjectPtrList& ) const;
71
72   /**
73    * Returns list of currently selected results
74    */
75   virtual QObjectPtrList selectedPresentations() const;
76
77   //! Returns list of currently selected QModelIndexes
78   virtual QModelIndexList selectedIndexes() const;
79
80   //! Returns list of currently selected QModelIndexes
81   ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner);
82
83   //! Returns list of currently selected AIS objects
84   virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const;
85
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;
91
92   //! Returns list of currently selected owners
93   /// \return list of owners
94   void selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const;
95
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;
102
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);
107
108 protected:
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;
118
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;
124 #endif
125
126 private:
127   XGUI_Workshop* myWorkshop;
128 };
129
130 #endif