]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_SelectionMgr.h
Salome HOME
1ea33bf756a78b6def43272f5a1cb167f7b07cb8
[modules/shaper.git] / src / XGUI / XGUI_SelectionMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 #ifndef XGUI_SelectionMgr_H
4 #define XGUI_SelectionMgr_H
5
6 #include "XGUI.h"
7 #include <ModuleBase_Definitions.h>
8 #include <ModuleBase_ISelection.h>
9 #include <QObject>
10 #include <QModelIndexList>
11
12 #include <AIS_ListOfInteractive.hxx>
13 #include <NCollection_List.hxx>
14 #include <TopoDS_Shape.hxx>
15 #include <SelectMgr_IndexedMapOfOwner.hxx>
16
17 class XGUI_Workshop;
18 class XGUI_ObjectsBrowser;
19 class XGUI_Selection;
20
21 /**\class XGUI_SelectionMgr
22  * \ingroup GUI
23  * \brief Selection manager. Provides selection event on selection in 
24  * Object Browser and Viewer
25  */
26 class XGUI_EXPORT XGUI_SelectionMgr : public QObject
27 {
28 Q_OBJECT
29  public:
30    /// Constructor
31    /// \param theParent a parent workshop
32   XGUI_SelectionMgr(XGUI_Workshop* theParent);
33   virtual ~XGUI_SelectionMgr();
34
35   /// Returns current selection
36   XGUI_Selection* selection() const
37   {
38     return mySelection;
39   }
40
41   //! Connects the manager to all viewers accessible by Workshop
42   void connectViewers();
43
44   //! Selects the owners in the context.
45   //! \param theSelectedOwners a container of owners
46   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
47   void setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners,
48                          bool isUpdateViewer);
49
50   //! Clears selection in Viewer and object Browser
51   void clearSelection();
52
53   //! Sets values selected in both, ObjectBrowser and V3d viewer
54   //! Selection is not synchronized between these controls.
55   //! \param theValues a container of values to be selected.
56   void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs> >& theValues);
57
58   /// Updates selection, which are depend on the selection in the given place
59   /// \param thePlace a widget where selection has happened.
60   void updateSelectionBy(const ModuleBase_ISelection::SelectionPlace& thePlace);
61
62 signals:
63   //! Emited when selection in a one of viewers was changed
64   void selectionChanged();
65
66  public slots:
67    /// Reaction on selectio0n in Object browser
68   void onObjectBrowserSelection();
69
70    /// Reaction on selectio0n in Viewer
71   void onViewerSelection();
72
73 private:
74   /// Interates through the values to prepare container of objects that may be selected in OB
75   /// \param theValues selection information
76   /// \param theObjecs an output container
77   void convertToObjectBrowserSelection(
78        const QList<std::shared_ptr<ModuleBase_ViewerPrs> >& theValues, QObjectPtrList& theObjects);
79
80 private:
81    /// Reference to workshop
82   XGUI_Workshop* myWorkshop;
83
84   /// Current selection object
85   XGUI_Selection* mySelection;
86 };
87
88 #endif