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
26
30
31namespace armarx
32{
33 using namespace armarx::RemoteGui::Client;
34
50
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 */
122 virtual public armarx::Component,
124 {
125 public:
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()
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
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
void onDisconnectComponent() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
static std::string GetDefaultName()
std::string getDefaultName() const override
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.