OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ControlsManager.h
Go to the documentation of this file.
1/*
2 * ControlsManager.h
3 *
4 * Created on: February 20, 2021
5 * Author: Alexander Kuester
6 * Copyright (c) 2020 openTwin
7 */
8
9#pragma once
10
11// AK header
13
14// Open twin header
15#include "OTCore/Flags.h"
17#include "OTGui/GuiTypes.h"
18
19// C++ header
20#include <string>
21#include <map>
22#include <vector>
23
25class AppBase;
26namespace ak { class aTreeWidget; }
27namespace ot { class PropertyGrid; }
28namespace ot { class GraphicsView; }
29namespace ot { class WidgetView; }
30namespace ot { class TextEditor; }
31
33public:
35 virtual ~ControlsManager();
36
41 void uiElementCreated(const ot::BasicServiceInformation& _serviceInfo, ak::UID _controlUid, bool _elementHasEvents = true);
42
44 bool destroyUiControl(ak::UID _controlUid);
45 void destroyUiControls(const std::vector<ak::UID> & _controlUids);
46 void uiControlWasDestroyed(ak::UID _controlUid);
47 void serviceDisconnected(const ot::BasicServiceInformation& _serviceInfo);
49
50private:
51 std::map<ot::BasicServiceInformation, std::vector<ak::UID> * > m_creatorMap;
52 std::map<ak::UID, ot::BasicServiceInformation> m_uiToCreatorMap;
53
54 ControlsManager(const ControlsManager &) = delete;
55 ControlsManager& operator = (const ControlsManager &) = delete;
56};
57
60public:
62 virtual ~LockableWidget() {};
63
64 virtual void setWidgetLocked(bool _isLocked) = 0;
65};
66
68public:
69 LockManager(AppBase* _owner);
70 virtual ~LockManager();
71
74 void uiElementCreated(const ot::BasicServiceInformation& _serviceInfo, ak::UID _uid, const ot::LockTypeFlags & _typeFlags);
75 void uiElementCreated(const ot::BasicServiceInformation& _serviceInfo, ak::aTreeWidget* _tree, const ot::LockTypeFlags & _typeFlags);
76 void uiElementCreated(const ot::BasicServiceInformation& _serviceInfo, ot::PropertyGrid* _propertyGrid, const ot::LockTypeFlags & _typeFlags);
77 void uiElementCreated(const ot::BasicServiceInformation& _serviceInfo, ot::GraphicsView* _graphicsView, const ot::LockTypeFlags & _typeFlags);
78 void uiElementCreated(const ot::BasicServiceInformation& _serviceInfo, ot::TextEditor* _text, const ot::LockTypeFlags & _typeFlags);
79 void uiViewCreated(const ot::BasicServiceInformation& _serviceInfo, ot::WidgetView* _view, const ot::LockTypeFlags & _typeFlags);
80 void registerLockable(const ot::BasicServiceInformation& _serviceInfo, LockableWidget* _lockable, const ot::LockTypeFlags & _typeFlags);
81
84 void uiElementDestroyed(ak::UID _uid);
86 void uiElementDestroyed(ot::PropertyGrid* _propertyGrid);
87 void uiElementDestroyed(ot::GraphicsView* _graphicsView);
90 void deregisterLockable(LockableWidget* _lockable);
91
92 void lock(const ot::BasicServiceInformation& _serviceInfo, ot::LockTypeFlag _type);
93 void lock(const ot::BasicServiceInformation& _serviceInfo, const ot::LockTypeFlags & _typeFlags);
94
95 void unlock(const ot::BasicServiceInformation& _serviceInfo);
96 void unlock(const ot::BasicServiceInformation& _serviceInfo, ot::LockTypeFlag _type);
97 void unlock(const ot::BasicServiceInformation& _serviceInfo, const ot::LockTypeFlags & _typeFlags);
98
99 void disable(const ot::BasicServiceInformation& _serviceInfo, ak::UID _element);
100 void enable(const ot::BasicServiceInformation& _serviceInfo, ak::UID _element, bool _resetCounter = false);
101
102 void cleanService(const ot::BasicServiceInformation& _serviceInfo, bool _reenableElement = true, bool _eraseUiElement = false);
103
104 int lockLevel(ot::LockTypeFlag _type);
105
106private:
107 std::map<ot::LockTypeFlag, int> * generateDefaultLockMap(void) const;
108 LockManagerElement * uiElement(ak::UID _uid);
109 std::map<ot::LockTypeFlag, int> * serviceLockLevel(const ot::BasicServiceInformation& _serviceInfo);
110 std::map<ak::UID, int> * serviceEnabledLevel(const ot::BasicServiceInformation& _serviceInfo);
111 void removeSpeciaElement(LockManagerElement* _element);
112
113 AppBase * m_owner;
114 std::list<LockManagerElement*> m_specials;
115
116 std::map<ot::BasicServiceInformation, std::map<ot::LockTypeFlag, int> *> m_serviceToUiLockLevel; // Contains a overview of sender to UI elements lock levels
117
118 std::map<ot::BasicServiceInformation, std::map<ak::UID, int> *> m_serviceToUiEnabledLevel; // Contains all enbaled levels for every UI element related to a service
119
120 std::map<ak::UID, LockManagerElement *> m_uiElements;
121
122 LockManager(const LockManager &) = delete;
123 LockManager& operator = (const LockManager &) = delete;
124};
125
129public:
130 ScopedLockManagerLock(LockManager* _manager, const ot::BasicServiceInformation& _serviceInfo, const ot::LockTypeFlags& _typeFlags);
132
134 void setNoUnlock(void);
135
136private:
137 bool m_skipUnlock;
138 LockManager* m_manager;
140 ot::LockTypeFlags m_flags;
141};
142
144public:
145 LockManagerElement(ak::UID _uid, const ot::LockTypeFlags & _flags);
148 LockManagerElement(ot::GraphicsView* _graphics, const ot::LockTypeFlags & _flags);
151 LockManagerElement(LockableWidget* _lockable, const ot::LockTypeFlags & _flags);
152
153 void enable(int _value);
154 void disable(int _value);
155
156 void lock(int _value, ot::LockTypeFlag _lockType);
157 void unlock(int _value, ot::LockTypeFlag _lockType);
158
159 ak::aTreeWidget* getTree(void) const { return m_tree; };
160 ot::PropertyGrid* getProp(void) const { return m_prop; };
161 ot::GraphicsView* getGraphics(void) const { return m_graphics; };
162 ot::TextEditor* getText(void) const { return m_text; };
163 ot::WidgetView* getView(void) const { return m_view; };
164 LockableWidget* getLockable(void) const { return m_lockable; };
165
166private:
167
168 ak::aTreeWidget* m_tree;
169 ot::PropertyGrid* m_prop;
170 ot::GraphicsView* m_graphics;
171 ot::TextEditor* m_text;
172 ot::WidgetView* m_view;
173 LockableWidget* m_lockable;
174 ak::UID m_uid;
175 ot::LockTypeFlags m_lockTypes;
176 int m_disabledCount;
177 int m_lockCount;
178
179 LockManagerElement() = delete;
180 LockManagerElement(const LockManagerElement &) = delete;
181 LockManagerElement & operator = (const LockManagerElement &) = delete;
182};
#define OT_DECL_NODEFAULT(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:22
#define OT_DECL_NOCOPY(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:14
The API manager is used to manage the global objects required for this API to work.
Definition AppBase.h:21
Definition ControlsManager.h:32
void uiControlWasDestroyed(ak::UID _controlUid)
Definition ControlsManager.cpp:80
void destroyUiControls(const std::vector< ak::UID > &_controlUids)
Definition ControlsManager.cpp:67
void uiElementCreated(const ot::BasicServiceInformation &_serviceInfo, ak::UID _controlUid, bool _elementHasEvents=true)
Will store the control information.
Definition ControlsManager.cpp:28
ControlsManager()
Definition ControlsManager.h:34
virtual ~ControlsManager()
Definition ControlsManager.cpp:24
bool destroyUiControl(ak::UID _controlUid)
Will destroy an UI control. Return false if failed to destroy (object still has child objects),...
Definition ControlsManager.cpp:51
void serviceDisconnected(const ot::BasicServiceInformation &_serviceInfo)
Definition ControlsManager.cpp:93
ot::BasicServiceInformation objectCreator(ak::UID)
Definition ControlsManager.cpp:104
Definition ControlsManager.h:143
ot::PropertyGrid * getProp(void) const
Definition ControlsManager.h:160
void unlock(int _value, ot::LockTypeFlag _lockType)
Definition ControlsManager.cpp:743
ak::aTreeWidget * getTree(void) const
Definition ControlsManager.h:159
ot::GraphicsView * getGraphics(void) const
Definition ControlsManager.h:161
LockableWidget * getLockable(void) const
Definition ControlsManager.h:164
ot::WidgetView * getView(void) const
Definition ControlsManager.h:163
ot::TextEditor * getText(void) const
Definition ControlsManager.h:162
void lock(int _value, ot::LockTypeFlag _lockType)
Definition ControlsManager.cpp:711
void disable(int _value)
Definition ControlsManager.cpp:683
void enable(int _value)
Definition ControlsManager.cpp:648
Definition ControlsManager.h:67
void unlock(const ot::BasicServiceInformation &_serviceInfo)
Definition ControlsManager.cpp:361
void disable(const ot::BasicServiceInformation &_serviceInfo, ak::UID _element)
Definition ControlsManager.cpp:436
LockManager(AppBase *_owner)
Definition ControlsManager.cpp:119
int lockLevel(ot::LockTypeFlag _type)
Definition ControlsManager.cpp:520
void uiElementDestroyed(ak::UID _uid)
Will remove all the stored information about the UI element This function will be called from the con...
Definition ControlsManager.cpp:240
void uiElementCreated(const ot::BasicServiceInformation &_serviceInfo, ak::UID _uid, const ot::LockTypeFlags &_typeFlags)
Will create a new entry for this This function will be called from the controls manager automatically...
Definition ControlsManager.cpp:127
virtual ~LockManager()
Definition ControlsManager.cpp:123
void enable(const ot::BasicServiceInformation &_serviceInfo, ak::UID _element, bool _resetCounter=false)
Definition ControlsManager.cpp:451
void uiViewCreated(const ot::BasicServiceInformation &_serviceInfo, ot::WidgetView *_view, const ot::LockTypeFlags &_typeFlags)
Definition ControlsManager.cpp:210
void registerLockable(const ot::BasicServiceInformation &_serviceInfo, LockableWidget *_lockable, const ot::LockTypeFlags &_typeFlags)
Definition ControlsManager.cpp:225
void uiViewDestroyed(ot::WidgetView *_view)
Definition ControlsManager.cpp:292
void cleanService(const ot::BasicServiceInformation &_serviceInfo, bool _reenableElement=true, bool _eraseUiElement=false)
Definition ControlsManager.cpp:478
void deregisterLockable(LockableWidget *_lockable)
Definition ControlsManager.cpp:301
void lock(const ot::BasicServiceInformation &_serviceInfo, ot::LockTypeFlag _type)
Definition ControlsManager.cpp:310
Definition ControlsManager.h:58
virtual void setWidgetLocked(bool _isLocked)=0
LockableWidget()
Definition ControlsManager.h:61
virtual ~LockableWidget()
Definition ControlsManager.h:62
Definition ControlsManager.h:126
ScopedLockManagerLock(LockManager *_manager, const ot::BasicServiceInformation &_serviceInfo, const ot::LockTypeFlags &_typeFlags)
Definition ControlsManager.cpp:596
~ScopedLockManagerLock()
Definition ControlsManager.cpp:603
void setNoUnlock(void)
If set the lock flags won't be unset when destroying.
Definition ControlsManager.cpp:610
Definition aTreeWidget.h:50
The BasicServiceInformation class is used to hold a service name and type. The BasicServiceInformatio...
Definition BasicServiceInformation.h:21
View widget used to display GraphicsItems Note that the View creates its own scene.
Definition GraphicsView.h:37
Definition PropertyGrid.h:29
Definition TextEditor.h:47
The WidgetView class is used to integrate the Qt-ADS functionallity into open twin.
Definition WidgetView.h:33
Definition uiAPI.h:45
unsigned long long UID
The UID datatype used for objects.
Definition globalDataTypes.h:65
Definition Connector.h:8
LockTypeFlag
Describes the object type to lock in the UI.
Definition GuiTypes.h:156