RemoteGuiExample2.h
Go to the documentation of this file.
1
/*
2
* This file is part of ArmarX.
3
*
4
* ArmarX is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation.
7
*
8
* ArmarX is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
*
16
* @package ArmarXGui::ArmarXObjects::RemoteGuiExample2
17
* @author Fabian Paus ( fabian dot paus at kit dot edu )
18
* @date 2018
19
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20
* GNU General Public License
21
*/
22
23
#pragma once
24
25
#include <
ArmarXCore/core/Component.h
>
26
27
#include <
ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h
>
28
#include <
ArmarXGui/libraries/RemoteGui/Client/Tab.h
>
29
#include <
ArmarXGui/libraries/RemoteGui/Client/Widgets.h
>
30
31
namespace
armarx
32
{
33
using namespace
armarx::RemoteGui::Client
;
34
35
struct
WidgetsTab
:
Tab
36
{
37
LineEdit
lineEdit
;
38
ComboBox
combo
;
39
CheckBox
checkBox
;
40
ToggleButton
toggle
;
41
42
IntSpinBox
intSpin
;
43
IntSlider
intSlider
;
44
45
FloatSpinBox
floatSpin
;
46
FloatSlider
floatSlider
;
47
48
Button
button
;
49
};
50
51
struct
EventsTab
:
Tab
52
{
53
IntSpinBox
spinInt
;
54
Button
buttonUp
;
55
Button
buttonDown
;
56
};
57
58
/**
59
* @defgroup Component-RemoteGuiExample2 RemoteGuiExample2
60
* @ingroup ArmarXGui-Components
61
*
62
* An example for how to use the remote gui framework for building simple
63
* user interfaces over ice.
64
*
65
* Often, you want to allow simple user interactions with an ArmarX
66
* component, e.g. to tweak a parameter, enable a feature or visualization
67
* or trigger an action. Building a dedicated, full-blown gui plugin can
68
* be very tedious for simple cases.
69
* For this use case, ArmarX offers a remote gui framework for building
70
* user interfaces over ice.
71
*
72
* This component demonstrates how to do this based on two examples:
73
* \li A *widgets* tab focusing on how to add different widget types,
74
* such as sliders, spinners, check boxes and buttons.
75
* \li An *events* tab showing how you can change the remote gui as a
76
* reaction to events triggered by the user via the remote gui.
77
*
78
* To run the example:
79
* \li Start the component `RemoteGuiProvider`
80
* \li Open the gui plugin `RemoteGui`
81
* \li Start the component `RemoteGuiExample2`
82
* \li Observe and interact with the created tabs in the `RemoteGui` widget.
83
*
84
* The scenario `RemoteGuiTest` starts the necessary components,
85
* including the example component.
86
*
87
* A component which wants to offer a remote gui needs to:
88
* \li `#include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h>`
89
* \li Inherit from the `armarx::LightweightRemoteGuiComponentPluginUser`
90
* \li Build and create a `armarx::RemoteGui::Client::Tab` in its
91
* `onConnectComponent()` using `RemoteGui_createTab()`
92
* \li Start the update processing thread in `onConnectComponent()`
93
* using `RemoteGui_startRunningTask()`
94
* \li Implement the virtual function `RemoteGui_update()` to process gui
95
* events (e.g. changed values, pressed buttons)
96
*
97
* `RemoteGui_createTab()` can be called once by the component to create
98
* a tab in the `RemoteGui` widget. In can be called again later to
99
* rebuild the tab, e.g. if the gui's structure should change.
100
*
101
* `RemoteGui_update()` is called by a processing thread at a regular
102
* interval. There, you can check the widgets for whether their value has
103
* changed (`.hasValueChanged()`) or whether a button was pressed
104
* (`.wasClicked()`).
105
*
106
* **Important note:** `RemoteGui_update()` is called from a separate thread,
107
* so you have to use synchronization mechanisms such as `std::mutex` and
108
* `std::scoped_lock` to synchronize access to variables which are
109
* accessed by different threads.
110
*
111
* \see RemoteGuiExample2
112
*
113
*
114
* @class RemoteGuiExample2
115
* @ingroup Component-RemoteGuiExample2
116
*
117
* @brief Brief description of class RemoteGuiExample2.
118
*
119
* @see @ref Component-RemoteGuiExample2
120
*/
121
class
RemoteGuiExample2
:
122
virtual
public
armarx::Component
,
123
virtual
public
armarx::LightweightRemoteGuiComponentPluginUser
124
{
125
public
:
126
RemoteGuiExample2
();
127
128
/// @see armarx::ManagedIceObject::getDefaultName()
129
std::string getDefaultName()
const override
;
130
static
std::string GetDefaultName();
131
132
133
protected
:
134
/// @see PropertyUser::createPropertyDefinitions()
135
armarx::PropertyDefinitionsPtr
createPropertyDefinitions()
override
;
136
137
/// @see armarx::ManagedIceObject::onInitComponent()
138
void
onInitComponent()
override
;
139
140
/// @see armarx::ManagedIceObject::onConnectComponent()
141
void
onConnectComponent()
override
;
142
143
/// @see armarx::ManagedIceObject::onDisconnectComponent()
144
void
onDisconnectComponent()
override
;
145
146
/// @see armarx::ManagedIceObject::onExitComponent()
147
void
onExitComponent()
override
;
148
149
150
private
:
151
void
RemoteGui_update()
override
;
152
153
void
createTab_Widgets();
154
void
updateTab_Widgets();
155
156
void
createTab_Events();
157
void
updateTab_Events();
158
159
160
private
:
161
EventsTab
eventsTab;
162
WidgetsTab
widgetsTab;
163
};
164
}
// namespace armarx
armarx::WidgetsTab::lineEdit
LineEdit lineEdit
Definition:
RemoteGuiExample2.h:37
armarx::RemoteGui::Client::ToggleButton
Definition:
Widgets.h:139
armarx::WidgetsTab::floatSpin
FloatSpinBox floatSpin
Definition:
RemoteGuiExample2.h:45
armarx::WidgetsTab::checkBox
CheckBox checkBox
Definition:
RemoteGuiExample2.h:39
armarx::EventsTab
Definition:
RemoteGuiExample2.h:51
armarx::WidgetsTab
Definition:
RemoteGuiExample2.h:35
armarx::RemoteGui::Client::Tab
Definition:
Tab.h:15
armarx::WidgetsTab::toggle
ToggleButton toggle
Definition:
RemoteGuiExample2.h:40
armarx::WidgetsTab::combo
ComboBox combo
Definition:
RemoteGuiExample2.h:38
Tab.h
LightweightRemoteGuiComponentPlugin.h
armarx::WidgetsTab::intSpin
IntSpinBox intSpin
Definition:
RemoteGuiExample2.h:42
armarx::EventsTab::buttonDown
Button buttonDown
Definition:
RemoteGuiExample2.h:55
armarx::RemoteGui::Client::FloatSlider
Definition:
Widgets.h:107
armarx::RemoteGui::Client::IntSlider
Definition:
Widgets.h:81
armarx::WidgetsTab::button
Button button
Definition:
RemoteGuiExample2.h:48
armarx::RemoteGui::Client::LineEdit
Definition:
Widgets.h:40
armarx::RemoteGui::Client::ComboBox
Definition:
Widgets.h:50
armarx::LightweightRemoteGuiComponentPluginUser
Definition:
LightweightRemoteGuiComponentPlugin.h:72
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition:
Component.h:91
armarx::WidgetsTab::intSlider
IntSlider intSlider
Definition:
RemoteGuiExample2.h:43
armarx::RemoteGuiExample2
Brief description of class RemoteGuiExample2.
Definition:
RemoteGuiExample2.h:121
armarx::EventsTab::buttonUp
Button buttonUp
Definition:
RemoteGuiExample2.h:54
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::RemoteGui::Client::IntSpinBox
Definition:
Widgets.h:69
armarx::RemoteGui::Client::CheckBox
Definition:
Widgets.h:129
Widgets.h
armarx::RemoteGui::Client::Button
Definition:
Widgets.h:120
armarx::RemoteGui::Client
Definition:
EigenWidgets.cpp:8
armarx::WidgetsTab::floatSlider
FloatSlider floatSlider
Definition:
RemoteGuiExample2.h:46
armarx::RemoteGui::Client::FloatSpinBox
Definition:
Widgets.h:93
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition:
ArmarXTimeserver.cpp:27
armarx::EventsTab::spinInt
IntSpinBox spinInt
Definition:
RemoteGuiExample2.h:53
ArmarXGui
applications
RemoteGuiExample
RemoteGuiExample2.h
Generated on Sat Apr 12 2025 09:13:29 for armarx_documentation by
1.8.17