Salome HOME
Merge branch 'Dev_GroupsRevision'
[modules/shaper.git] / src / XGUI / XGUI_ActiveControlMgr.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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef XGUI_ActiveControlMgr_H
22 #define XGUI_ActiveControlMgr_H
23
24 #include "XGUI.h"
25
26 #include <QList>
27 #include <QObject>
28
29
30 class XGUI_ActiveControlSelector;
31 class ModuleBase_IWorkshop;
32
33 /**
34 * Interface of providing only one active control for workshop.
35 * It has container of selectors, where only one might be active at the moment.
36 * Selection in 3D view is processed by the active selector.
37 */
38 class XGUI_ActiveControlMgr : public QObject
39 {
40   Q_OBJECT
41 public:
42   /// Constructor
43   /// \param theWorkshop the current workshop instance
44   XGUI_EXPORT XGUI_ActiveControlMgr(ModuleBase_IWorkshop* theWorkshop);
45
46   XGUI_EXPORT virtual ~XGUI_ActiveControlMgr() {};
47
48   /// Register selector to process activation of control
49   void addSelector(XGUI_ActiveControlSelector* theSelector);
50
51   /// Returns selector by type name
52   /// \param theType a selector type
53   /// \return selector instance
54   XGUI_EXPORT XGUI_ActiveControlSelector* getSelector(const QString& theType);
55
56   /// Returns the active selector
57   /// \return selector instance
58   XGUI_ActiveControlSelector* activeSelector() const { return myActiveSelector; }
59
60 protected slots:
61   /// Deactivates active selector and set the sender selector as active
62   void onSelectorActivated();
63   /// Deactivate the active selector
64   void onSelectorDeactivated();
65   /// Listens workshop selection and pass it to the active selector
66   void onSelectionChanged();
67
68 protected:
69   void activateSelector(XGUI_ActiveControlSelector* theSelector);
70
71 protected:
72   ModuleBase_IWorkshop* myWorkshop; ///< the current workshop
73
74   QList<XGUI_ActiveControlSelector*> mySelectors; ///< workshop selectors
75   XGUI_ActiveControlSelector* myActiveSelector; ///< active selector
76
77   bool myIsBlocked; ///< blocking flag to avoid cycling signals processing
78 };
79
80 #endif