Salome HOME
Porting to SALOME_8.2.0
[modules/shaper.git] / src / XGUI / XGUI_Selection.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        XGUI_Selection.h
4 // Created:     8 July 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef XGUI_Selection_H
8 #define XGUI_Selection_H
9
10 #include "XGUI.h"
11
12 #include <ModuleBase_Definitions.h>
13 #include <ModuleBase_ISelection.h>
14
15 #include <QModelIndexList>
16 #include <AIS_ListOfInteractive.hxx>
17 #include <NCollection_List.hxx>
18 #include <TopoDS_Shape.hxx>
19
20 #include <SelectMgr_IndexedMapOfOwner.hxx>
21
22 class XGUI_Workshop;
23 class SelectMgr_EntityOwner;
24 class ModuleBase_ViewerPrs;
25
26 /**
27 * \ingroup GUI
28 * Implementation of \ref ModuleBase_ISelection interface.
29 */
30 class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
31 {
32  public:
33    /// Constructor
34    /// \param theWorkshop reference to workshop instance
35   XGUI_Selection(XGUI_Workshop* theWorkshop);
36
37   /// Returns a list of viewer selected presentations
38   /// \return list of presentations
39   virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>>
40     getSelected(const SelectionPlace& thePlace = Browser) const;
41
42   /// Fills the viewer presentation parameters by the parameters from the owner
43   /// \param thePrs a container for selection
44   /// \param theOwner a selection owner
45   virtual void fillPresentation(std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
46                                 const Handle(SelectMgr_EntityOwner)& theOwner) const;
47
48   /// Returns a list of viewer highlited presentations
49   /// \return list of presentations
50   virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getHighlighted() const;
51
52   /**
53    * Returns list of currently selected objects in object browser
54    */
55   virtual QObjectPtrList selectedObjects() const;
56
57   virtual void setSelectedObjects( const QObjectPtrList& ) const;
58
59   /**
60    * Returns list of currently selected results
61    */
62   virtual QObjectPtrList selectedPresentations() const;
63
64   //! Returns list of currently selected QModelIndexes
65   virtual QModelIndexList selectedIndexes() const;
66
67   //! Returns list of currently selected QModelIndexes
68   ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner);
69
70   //! Returns list of currently selected AIS objects
71   virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const;
72
73   //! Return a selectable object by the entity owner. It founds AIS object in the viewer
74   //! and returns the corresponded object
75   /// \param theOwner an entity owner
76   /// \return a found object or NULL
77   ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner) const;
78
79   //! Returns list of currently selected owners
80   /// \return list of owners
81   void selectedOwners(SelectMgr_IndexedMapOfOwner& theSelectedOwners) const;
82
83   //! Returns a list of selection entity owners of the interactive object
84   /// It depends on the modes, in which the object is activated in the context
85   /// \param theObject an object
86   /// \param theOwners a map of entity owners
87   void entityOwners(const Handle_AIS_InteractiveObject& theObject,
88                     SelectMgr_IndexedMapOfOwner& theOwners) const;
89
90   //! Return the IO from the viewer presentation.
91   //! \param thePrs a selected object
92   //! \return an interactive object
93   virtual Handle(AIS_InteractiveObject) getIO(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
94
95 protected:
96   /// Fills the list of presentations by objects selected in the viewer.
97   /// \param thePresentations an output list of presentation
98   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;
105
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   TopoDS_Shape findAxisShape(Handle(AIS_InteractiveObject) theIO) const;
110
111 private:
112   XGUI_Workshop* myWorkshop;
113 };
114
115 #endif