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