ArVizWidgetController.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 RobotAPI::gui-plugins::ArVizWidgetController
17 * @author Fabian Paus ( fabian dot paus at kit dot edu )
18 * @date 2019
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22#pragma once
23
24#include <unordered_set>
25
27#include <ArmarXCore/interface/observers/ObserverInterface.h>
28
32
34#include <RobotAPI/gui-plugins/ArViz/ui_ArVizWidget.h>
35#include <RobotAPI/interface/ArViz/Component.h>
36
38#include "LayerInfoTree.h"
39
40namespace armarx
41{
50
51 struct ArVizWidgetBatchCallback;
52
53 /**
54 \page RobotAPI-GuiPlugins-ArViz ArViz
55 \brief The ArViz allows visualizing ...
56
57 \image html ArViz.png
58 The user can
59
60 API Documentation \ref ArVizWidgetController
61
62 \see ArVizGuiPlugin
63 */
64
65 /**
66 * \class ArVizWidgetController
67 * \brief ArVizWidgetController brief one line description
68 *
69 * Detailed description
70 */
73 {
74 Q_OBJECT
75
76 public:
77 /// Controller Constructor
78 explicit ArVizWidgetController();
79
80 /// Controller destructor
81 virtual ~ArVizWidgetController() override;
82
83 void loadSettings(QSettings* settings) override;
84 void saveSettings(QSettings* settings) override;
85
86 QPointer<QDialog> getConfigDialog(QWidget* parent) override;
87 void configured() override;
88
89 SoNode* getScene() override;
90
91 /// Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
92 static QString
94 {
95 return "Visualization.ArViz";
96 }
97
98 /// @see armarx::Component::onInitComponent()
99 void onInitComponent() override;
100 void onExitComponent() override;
101
102 void onConnectComponent() override;
103 void onDisconnectComponent() override;
104
105 void onGetBatchAsync(viz::data::RecordingBatch const& batch);
106
107
108 private slots:
109 /* QT slot declarations */
110 void updateLayers();
111 void updateLayersFromProfile();
112
113 signals:
114 /* QT signal declarations */
115
118
119
120 private:
121 void onConnectGui();
122 void onDisconnectGui();
123
124 void layersChanged(std::vector<viz::CoinLayerID> const& layers);
125 void layerTreeChanged(QTreeWidgetItem* item, int column);
126 void updateSelectedLayer(QTreeWidgetItem* current, QTreeWidgetItem* previous);
127
128 void onCollapseAll(bool);
129 void onExpandAll(bool);
130
131 void onHideAll(bool);
132 void onShowAll(bool);
133 void onHideFiltered(bool);
134 void onShowFiltered(bool);
135
136 void onFilterTextChanged(QString const& filter);
137
138 void showAllLayers(bool visible);
139 void showFilteredLayers(bool visible);
140
141 void onDeselectElement();
142 void onContextMenuClicked();
143 void onInteractiveElementSelected(QListWidgetItem* item);
144
145 void onUpdate();
146 void onTimingObserverUpdate();
147
148
149 // Record & Replay
150
151 void onStartRecording();
152 void onStopRecording();
153
154 void onRefreshRecordings();
155 void onRecordingSelectionChanged(QListWidgetItem* current, QListWidgetItem* previous);
156
157 void onReplaySpinChanged(int newValue);
158 void onReplaySliderChanged(int newValue);
159
160 void selectRecording(viz::data::Recording const& recording);
161
162 void onReplayStart(bool);
163 void onReplayStop(bool);
164 long replayToRevision(long revision);
165 long getRevisionForTimestamp(long timestamp);
166 void onReplayTimedStart(bool checked);
167 void onReplayTimerTick();
168 void exportToVRML();
169
170 void changeMode(ArVizWidgetMode newMode);
171 void enableWidgetAccordingToMode();
172
173
174 private:
175 Ui::ArVizWidget widget;
176
177 QPointer<SimpleConfigDialog> configDialog;
178
179 QTimer* updateTimer;
181 StringVariantBaseMap timingMap;
182
183 QTimer* replayTimer;
184 long replayCurrentTimestamp = 0;
185 long lastReplayRealTime = 0;
186
187 std::string storageName;
188 armarx::viz::StorageInterfacePrx storage;
189 std::string debugObserverName;
190 DebugObserverInterfacePrx debugObserver;
191
193 armarx::LayerInfoTree layerInfoTree;
194
195 viz::data::RecordingSeq allRecordings;
196
197 // Replay control
198 viz::data::Recording currentRecording;
199 long currentRevision = -1;
200 long currentTimestamp = -1;
201 bool currentRecordingSelected = false;
202
203 // Recording batch cache
204 struct TimestampedRecordingBatch
205 {
206 IceUtil::Time lastUsed;
207 viz::data::RecordingBatch data;
208 };
209
210 viz::data::RecordingBatch const& getRecordingBatch(long index);
211 void limitRecordingBatchCacheSize();
212
213 std::size_t recordingBatchCacheMaxSize = 5;
214 std::mutex recordingBatchCacheMutex;
215 std::atomic<long> recordingWaitingForBatchIndex = -1;
216 std::map<long, TimestampedRecordingBatch> recordingBatchCache;
217
219
221 armarx::viz::Callback_StorageInterface_getRecordingBatchPtr callback;
222 Ice::AsyncResultPtr callbackResult;
223
224 std::vector<double> timings;
225
226 ArvizProfileManagerWidget* arvizeProfileLayerWidget;
227
228 public:
229 static QIcon
231 {
232 return QIcon(":icons/ArViz.png");
233 }
234 };
235} // namespace armarx
std::string timestamp()
uint8_t index
#define ARMARXCOMPONENT_IMPORT_EXPORT
Manages the layer info QTreeWidget.
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
std::map< std::string, VariantBasePtr > StringVariantBaseMap
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
SoNode * getScene() override
Reimplementing this function and returning a SoNode* will show this SoNode in the 3DViewerWidget,...
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
ArVizWidgetController()
Controller Constructor.
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.