OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
UiComponent.h
Go to the documentation of this file.
1/*
2 * UiComponent.h
3 *
4 * Created on: 10/02/2021
5 * Author: Alexander Kuester
6 * Copyright (c) 2021, OpenTwin
7 */
8
9#pragma once
10
11// OpenTwin header
12#include "OTCore/Flags.h"
13#include "OTCore/ServiceBase.h" // Base class
14#include "OTGui/GuiTypes.h"
19
20// C++ header
21#include <list>
22#include <map>
23#include <string>
24
25namespace ot {
26
27 class ApplicationBase;
28
29 namespace components {
30
32 public:
39
50
52 const std::string & _name,
53 const std::string & _type,
54 const std::string & _url,
55 serviceID_t _id,
56 ApplicationBase * _application
57 );
58
59 virtual ~UiComponent();
60
61 // #####################################################################################################################
62
63 // Element creation
64
67 void addMenuPage(
68 const std::string & _pageName
69 );
70
74 void addMenuGroup(
75 const std::string & _pageName,
76 const std::string & _groupName
77 );
78
82 void addMenuSubGroup(
83 const std::string & _pageName,
84 const std::string & _groupName,
85 const std::string & _subgroupName
86 );
87
97 void addMenuButton(
98 const std::string & _pageName,
99 const std::string & _groupName,
100 const std::string & _buttonName,
101 const std::string & _text,
102 const LockTypeFlags & _lockTypes,
103 const std::string & _iconName,
104 const std::string & _iconFolder = std::string("Default"),
105 const std::string & _keySequence = std::string("")
106 );
107
109 ot::MenuButtonDescription& _menuButtonDescription,
110 const LockTypeFlags& _lockTypes,
111 const std::string & _iconName,
112 const std::string & _iconFolder = std::string("Default"),
113 const std::string & _keySequence = std::string("")
114 );
115
116
127 void addMenuButton(
128 const std::string & _pageName,
129 const std::string & _groupName,
130 const std::string & _subgroupName,
131 const std::string & _buttonName,
132 const std::string & _text,
133 const LockTypeFlags& _lockTypes,
134 const std::string & _iconName,
135 const std::string & _iconFolder = std::string("Default"),
136 const std::string & _keySequence = std::string("")
137 );
138
145 void addMenuCheckbox(
146 const std::string & _pageName,
147 const std::string & _groupName,
148 const std::string & _checkboxName,
149 const std::string & _checkboxText,
150 bool _isChecked,
151 const LockTypeFlags& _lockTypes
152 );
153
161 void addMenuCheckbox(
162 const std::string & _pageName,
163 const std::string & _groupName,
164 const std::string & _subgroupName,
165 const std::string & _checkboxName,
166 const std::string & _checkboxText,
167 bool _isChecked,
168 const LockTypeFlags& _lockTypes
169 );
170
177 void addMenuLineEdit(
178 const std::string & _pageName,
179 const std::string & _groupName,
180 const std::string & _lineEditName,
181 const std::string & _labelText,
182 const std::string & _initialText,
183 const LockTypeFlags& _lockTypes
184 );
185
193 void addMenuLineEdit(
194 const std::string & _pageName,
195 const std::string & _groupName,
196 const std::string & _subgroupName,
197 const std::string & _lineEditName,
198 const std::string & _labelText,
199 const std::string & _initialText,
200 const LockTypeFlags& _lockTypes
201 );
202
203 void activateMenuPage(
204 const std::string & _pageName
205 );
206
210 void addShortcut(
211 const std::string & _keySequence
212 );
213
217 void createRubberband(
218 const std::string & _note,
219 const std::string & _configurationJson
220 );
221
222 // #####################################################################################################################
223
224 // Control manipulation
225
229 void setControlToolTip(
230 const std::string & _controlName,
231 const std::string & _toolTipText
232 ) const;
233
239 void setControlToolTip(
240 const std::string & _pageName,
241 const std::string & _groupName,
242 const std::string & _controlName,
243 const std::string & _toolTipText
244 ) const;
245
252 void setControlToolTip(
253 const std::string & _gepaName,
254 const std::string & _groupName,
255 const std::string & _subgroupName,
256 const std::string & _controlName,
257 const std::string & _toolTipText
258 ) const;
259
263 void setControlsEnabledState(
264 const std::list<std::string> & _enabledControls,
265 const std::list<std::string> & _disabledControls
266 ) const;
267
272 void setLineEditValues(
273 const std::string & _controlName,
274 const std::string & _text,
275 bool _errorState = false
276 ) const;
277
281 void setCheckboxValues(
282 const std::string & _controlName,
283 bool _checkedState
284 ) const;
285
288 void lockUI(
289 const LockTypeFlags& _lockTypes
290 ) const;
291
294 void unlockUI(
295 const LockTypeFlags& _lockTypes
296 ) const;
297
301 void setProgressInformation(std::string message, bool continuous);
302
305 void setProgress(int percentage);
306
308 void closeProgressInformation(void);
309
312 void switchMenuTab(
313 const std::string & _pageName
314 ) const;
315
317 void registerForModelEvents(void) const;
318
320 void deregisterForModelEvents(void) const;
321
324 void addIconSearchPath(const std::string& _iconPath);
325
327 void notifyUiSetupCompleted(void);
328
329 // #####################################################################################################################
330
331 // Information IO
332
335 void displayMessage(const std::string& _message) const;
336
339 void displayStyledMessage(const StyledTextBuilder& _builder) const;
340
343 void displayErrorPrompt(
344 const std::string & _message
345 ) const;
346
349 void displayWarningPrompt(
350 const std::string & _message
351 ) const;
352
355 void displayInformationPrompt(
356 const std::string & _message
357 ) const;
358
364 void addControlNameToList(
365 std::list<std::string> & _list,
366 const std::string & _pageName,
367 const std::string & _groupName,
368 const std::string & _controlName
369 );
370
377 void addControlNameToList(
378 std::list<std::string> & _list,
379 const std::string & _pageName,
380 const std::string & _groupName,
381 const std::string & _subgroupName,
382 const std::string & _controlName
383 );
384
385 // #####################################################################################################################
386
387 // Element deletion
388
390 void removeUIElements(const std::list<std::string> & _itemList);
391
393 void removeAllUIElements(void);
394
395 // #####################################################################################################################
396
397 // View manipulation
398
399 void enterEntitySelectionMode(
400 UID _visualizationModelUID,
401 entitySelectionType _selectionType,
402 bool _allowMultipleSelection,
403 const std::string & _filter,
404 entitySelectionAction _actionType,
405 const std::string & _message,
406 const std::map<std::string, std::string> & _options,
407 ot::serviceID_t _serviceToReplyTo
408 ) const;
409
410 // #####################################################################################################################
411
412 void freeze3DView(UID _visualizationModelUID, bool _flag);
413 void refreshSelection(UID _visualizationModelUID);
414 void refreshAllViews(UID visualizationModelID);
415 void sendUpdatedControlState(void);
416 void setControlState(const std::string controlName, bool enabled);
417
418 bool sendMessage(bool _queue, JsonDocument& _doc, std::string& _response);
419
420 protected:
421
424 bool controlNameExists(const std::string & _name) const;
426 std::list<std::string> m_uiElements;
427 std::map<std::string, bool> m_uiControlState;
428 std::map<std::string, bool> m_uiControlStateInUI;
429
430 private:
431 friend class ApplicationBase;
432 void sendSettingsData(const PropertyGridCfg& _config);
433
434 UiComponent(const UiComponent &) = delete;
435 UiComponent & operator = (const UiComponent &) = delete;
436
437 };
438
439 }
440}
#define OT_SERVICEFOUNDATION_API_EXPORT
Definition FoundationAPIExport.h:7
Definition ApplicationBase.h:45
JSON document.
Definition JSON.h:276
Definition PropertyGridCfg.h:21
General service information. The ServiceBase class is used to store the general service information.
Definition ServiceBase.h:24
Definition StyledTextBuilder.h:16
Definition UiComponent.h:31
ApplicationBase * m_application
Definition UiComponent.h:425
std::list< std::string > m_uiElements
The application base this component belings to.
Definition UiComponent.h:426
std::map< std::string, bool > m_uiControlState
List of all UI elements that werde created by this component.
Definition UiComponent.h:427
entitySelectionAction
Definition UiComponent.h:40
@ CHAMFER_EDGE
Definition UiComponent.h:47
@ BOOLEAN_INTERSECT
Definition UiComponent.h:45
@ REMOVE_FACE
Definition UiComponent.h:42
@ TRANSFORM_SHAPES
Definition UiComponent.h:46
@ BOOLEAN_SUBTRACT
Definition UiComponent.h:44
@ PORT
Definition UiComponent.h:41
@ BOOLEAN_ADD
Definition UiComponent.h:43
std::map< std::string, bool > m_uiControlStateInUI
Definition UiComponent.h:428
entitySelectionType
Definition UiComponent.h:33
@ FACE
Definition UiComponent.h:34
@ SHAPE
Definition UiComponent.h:36
@ EDGE
Definition UiComponent.h:35
void addMenuButton(ot::MenuButtonDescription &_menuButtonDescription, const LockTypeFlags &_lockTypes, const std::string &_iconName, const std::string &_iconFolder=std::string("Default"), const std::string &_keySequence=std::string(""))
Definition Connector.h:8
unsigned long UID
Unique identifier (32 bit unsigned integer)
Definition CoreTypes.h:27
unsigned short serviceID_t
ID type used to identify a service (16 bit unsigned integer).
Definition CoreTypes.h:14