WidgetController.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 Navigation::gui-plugins::WidgetController
17 * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18 * @date 2021
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22#pragma once
23
24#include <memory>
25#include <string>
26
27#include <qhashfunctions.h>
28#include <qicon.h>
29#include <qlist.h>
30#include <qobjectdefs.h>
31#include <qpair.h>
32#include <qpointer.h>
33#include <qsettings.h>
34#include <qwidget.h>
35
38
41
49
51#include <armarx/navigation/gui-plugins/LocationGraphEditor/ui_LocationGraphEditorWidget.h>
52
53#include "GuiGraph.h"
54#include "Visu.h"
55#include <SemanticObjectRelations/Shapes/Shape.h>
56
57
58class QDialog;
59
60namespace armarx::viz
61{
62 class Client;
63}
64
69
71{
72 class EdgeTableWidget;
73 class RobotVisuWidget;
75 class VertexDataWidget;
77
78 /**
79 \page armarx_navigation-GuiPlugins-LocationGraphEditor LocationGraphEditor
80 \brief The LocationGraphEditor allows visualizing ...
81
82 \image html LocationGraphEditor.png
83 The user can
84
85 API Documentation \ref WidgetController
86
87 \see LocationGraphEditorGuiPlugin
88 */
89
90
91 /**
92 * \class LocationGraphEditorGuiPlugin
93 * \ingroup ArmarXGuiPlugins
94 * \brief LocationGraphEditorGuiPlugin brief description
95 *
96 * Detailed description
97 */
98
99 /**
100 * \class WidgetController
101 * \brief WidgetController brief one line description
102 *
103 * Detailed description
104 */
107 {
108 Q_OBJECT
109
110 using This = WidgetController;
111
112
113 public:
114 static QString GetWidgetName();
115 static QIcon GetWidgetIcon();
116
117
118 explicit WidgetController();
119 virtual ~WidgetController() override;
120
121
122 //// @see ArmarXWidgetController::loadSettings()
123 void loadSettings(QSettings* settings) override;
124 /// @see ArmarXWidgetController::saveSettings()
125 void saveSettings(QSettings* settings) override;
126
127
128 QPointer<QDialog> getConfigDialog(QWidget* parent = nullptr) override;
129 void configured() override;
130
131
132 void onInitComponent() override;
133 void onConnectComponent() override;
134
135
136 //because the above load/save functions are *obviously* for "Save/Load Gui Config." :/
137 virtual void loadAutomaticSettings();
138 virtual void saveAutomaticSettings();
139
140
141 signals:
142
143 void connected();
144
148
150
151
152 private slots:
153
154 // Load
155 void queryMemory();
156 armem::client::QueryResult queryLocations();
157 armem::client::QueryResult queryGraphs();
158
159 void loadGraph();
160 bool loadGraphDialog();
161
162 // Commit
163 void commit();
164 armem::CommitResult commitLocations();
165 armem::EntityUpdateResult commitGraph();
166
167
168 // View & Tables
169 void updateGraphList();
170 void updateGraphView();
171 void updateVertexView(GuiGraph::Vertex vertex);
172 void updateEdgeView(GuiGraph::Edge edge);
173 void updateArViz();
174
175
176 // Selection & Highlighting
177 void selectVertex(QTableWidgetItem* vertexItem);
178 void selectVertex(GuiGraph::Vertex vertex);
179 void updateVertexHighlighting();
180 void updateEdgeHighlighting();
181
182
183 // Graph modification triggered by user interaction
184 void createVertexDialog();
185
186 void addEdges(QList<QPair<QTableWidgetItem*, QTableWidgetItem*>> vertexItems);
187 void removeEdges(QList<QTableWidgetItem*> edgeItems);
188 void removeEdgesOfVertex(QList<QTableWidgetItem*> vertexItems,
189 utils::EdgeDirection direction);
190
191 void createGraphDialog();
192
193
194 private:
195 void setGraph(const armem::MemoryID& entityID, const core::Graph& nav);
196 void setEmptyGraph(const armem::MemoryID& entityID);
197
198 GuiGraph::Vertex addVertex(semrel::ShapeID vertexID, const VertexData& defaultAttribs);
199 GuiGraph::Vertex addVertex(semrel::ShapeID vertexID,
200 const armem::wm::EntityInstance& locationInstance);
201
202 GuiGraph::Edge addEdge(GuiGraph::ConstVertex source,
203 GuiGraph::ConstVertex target,
204 const EdgeData& defaultAttribs);
205
206 void removeVertex(GuiGraph::Vertex& vertex);
207 void removeEdge(GuiGraph::Edge& edge);
208
209 void clearGraph();
210 void clearEdges();
211 void clearVertices();
212
213
214 QString getGraphDisplayName(const armem::MemoryID& entityID, bool changed = false) const;
215
216 void exportLocationGraph();
217
218 private:
219 /// Widget Form
220 Ui::LocationGraphEditorWidget widget;
221 QPointer<SimpleConfigDialog> configDialog;
222
223 struct Remote
224 {
225 std::string memoryNameSystemName = "MemoryNameSystem";
226 armem::client::MemoryNameSystem memoryNameSystem;
227
228 armem::client::Reader locationReader;
229 armem::client::Writer locationWriter;
230
231 armem::client::Reader graphReader;
232 armem::client::Writer graphWriter;
233
234 std::unique_ptr<viz::Client> arviz;
235
236 void connect(Component& parent);
237 };
238
239 Remote remote;
240
241 struct Model
242 {
243 armem::wm::Memory locationsMemory;
244
245 armem::wm::Memory graphMemory;
246 armem::MemoryID graphEntityID;
248
250 };
251
252 Model model;
253
254 struct View
255 {
256 VertexTableWidget* vertexTable = nullptr;
257 EdgeTableWidget* edgeTable = nullptr;
258 VertexDataWidget* vertexData = nullptr;
259
260 RobotVisuWidget* robotVisu = nullptr;
261 ObjectPoseClientWidget* objectPoses = nullptr;
262 };
263
264 View view;
265
266
267 private:
268 QSettings settings;
269 QString lastSelectedSceneName;
270 };
271
272} // namespace armarx::navigation::qt_plugins::location_graph_editor
273
274namespace armarx
275{
277}
#define ARMARXCOMPONENT_IMPORT_EXPORT
Component()
Protected default constructor. Used for virtual inheritance. Use createManagedIceObject() instead.
Definition Component.cpp:66
The memory name system (MNS) client.
Reads data from a memory server.
Definition Reader.h:25
Helps a memory client sending data to a memory.
Definition Writer.h:23
Client-side working entity instance.
Client-side working memory.
void onInitComponent() override
Pure virtual hook for the subclass.
QPointer< QDialog > getConfigDialog(QWidget *parent=nullptr) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
void onConnectComponent() override
Pure virtual hook for the subclass.
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
This file is part of ArmarX.
Definition Visu.h:48
This file is part of ArmarX.
This file offers overloads of toIce() and fromIce() functions for STL container types.
Result of a Commit.
Definition Commit.h:111
Result of an EntityUpdate.
Definition Commit.h:75
Result of a QueryInput.
Definition Query.h:51
The EdgeData struct holds data required for the edge.
Definition GuiGraph.h:61
The NodeData struct holds data required for the node.
Definition GuiGraph.h:45