PriorMemoryEditorPlugin.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 ArmarX::MemoryX::PriorMemoryEditorPlugin
17* @author Alexey Kozlov (kozlov at kit dot edu)
18* @copyright 2012
19* @license http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21
22*/
23
24#pragma once
25
26/* ArmarX headers */
28
31
34
35#include <MemoryX/gui-plugins/PriorMemoryEditor/ui_PriorMemoryEditorPlugin.h>
36
37/* VirtualRobot headers */
38#include <VirtualRobot/SceneObject.h>
39#include <VirtualRobot/Visualization/CoinVisualization/CoinVisualization.h>
40#include <VirtualRobot/Visualization/VisualizationFactory.h>
41
42/* MemoryX headers */
44#include <MemoryX/interface/components/PriorKnowledgeInterface.h>
46
47/* Qt headers */
48#include <memory>
49
50#include <QMainWindow>
51
52/* Coin3D/SoQt headers */
53#include <Inventor/Qt/SoQt.h>
54#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
55#include <Inventor/nodes/SoEventCallback.h>
56#include <Inventor/nodes/SoMatrixTransform.h>
57#include <Inventor/nodes/SoNode.h>
58#include <Inventor/nodes/SoSeparator.h>
59#include <Inventor/sensors/SoTimerSensor.h>
60
61namespace memoryx
62{
65
66 /**
67 * \class PriorMemoryEditorPlugin
68 * \brief The PriorMemoryEditorPlugin provides a widget that allows to view and edit data entries in the prior memory.
69 * \see PriorEditorController
70 */
72 {
73 Q_OBJECT
74 Q_INTERFACES(ArmarXGuiInterface)
75 Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
76 public:
78 };
79
80 /**
81 \page MemoryX-GuiPlugins-PriorMemoryEditor PriorMemoryEditor
82 \brief This widget allows viewing and editing data entries in the prior memory.
83
84 \image html PriorMemoryEditor.png
85 You can inspect the different collections that are stored as prior knowledge by selecting a
86 collection from the collection drop-down-menu. All object classes that are stored within a collection
87 are listed in the table in the center of the screen. You may view the visual or collision model for
88 an object class by hitting the respective buttons. Similarly, you can also add, remove and edit entries.
89
90 When you add the widget to the Gui, you need to specify the following parameters:
91
92 Parameter Name | Example Value | Required? | Description
93 :---------------- | :-------------: | :-------------- |:--------------------
94 MongoDB host | localhost:27017 | Yes | The address of the mongo database that contains the prior memory.
95 MongoDB user | username | Only if DB is remote | ?
96 Password | userPassword | Only if DB is remote | ?
97 Gui Plugin Name | PriorMemoryEditorPlugin | Yes | ?
98 PriorMemory Name | PriorKnowledge | Yes | ?
99
100 \note In order to use this Gui there must be prior knowledge within a MongoDB available.
101 PriorMemoryEditor API Documentation \ref PriorEditorController
102
103 How to use:
104
105 \li Gui->addWidget->PriorMemoryEditorPlugin
106 \li Different collection Lists (all collections need pr_ prefix so the gui can distinguish between different types)
107 \li All classes/objects are shown in list -> double click shows the 3D model in Viewer
108 \li Edit
109 -> parent classes (Food, used for queries like common places for Food),
110 -> model files via XML or separate IV files -> in /data/
111
112
113 \see PriorMemoryEditorPlugin
114 */
115
116 /**
117 * @class PriorEditorController
118 * \brief This widget allows to view and edit data entries in the prior memory.
119 *
120 * @see PriorMemoryEditorPlugin
121 */
123 public armarx::ArmarXComponentWidgetControllerTemplate<PriorEditorController>
124 {
125 Q_OBJECT
126 public:
128
130 {
131 }
132
133 // inherited from Component
134 void onInitComponent() override;
135 void onConnectComponent() override;
136 void onDisconnectComponent() override;
137 void onExitComponent() override;
138
139 // end of inherited from Component
140
141 // inherited of ArmarXWidget
142 static QString
144 {
145 return "MemoryX.PriorMemoryEditor";
146 }
147
148 static QIcon
150 {
151 return QIcon("://icons/database.svg");
152 }
153
154 static QIcon
156 {
157 return QIcon("://icons/database.svg");
158 }
159
160 void loadSettings(QSettings* settings) override;
161 void saveSettings(QSettings* settings) override;
162 QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override;
163 void configured() override;
164
165 SoNode* getScene() override;
166
168
169 signals:
170
172
173 void objectChanged(QString objectId, bool isNew);
174
175 public slots:
176
177 void reconnect();
178 void collectionChanged();
179 void addCollection();
180 void refetchData();
181
182 void showObjectClassVisu();
183 void showObjectClassColl();
184 void addObjectClass();
185 void editObjectClass();
186 void removeObjectClass();
187 void treeItemDoubleClicked(QTreeWidgetItem* item, int column);
188 void treeCurrentItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem* prev);
189
190 void clearVisualization();
191
192 protected:
193 using ObjectEntryMap = std::map<std::string, ObjectClassPtr>;
194
195 void connectSlots();
196
197 Ui::PriorMemoryEditorPlugin ui;
198
200
201 // maps entityId with data
204
205 SoSeparator* visu;
206
207 //void updateModel();
208
209 void updateObject(const memoryx::ObjectClassPtr obj, bool force = false);
210
211 // build visualization
212 void createVisualization(const ::memoryx::ObjectClassPtr obj);
213
214 void clearObjects();
215
216
217 private:
218 std::recursive_mutex mutexEntities;
219
220 CommonStorageInterfacePrx databasePrx;
221 PriorKnowledgeInterfacePrx memoryPrx;
222 PersistentObjectClassSegmentBasePrx classesSegmentPrx;
223
224 GridFileManagerPtr fileManager;
225
226 void doEditClass(bool isNew);
227
228 VirtualRobot::ManipulationObjectPtr loadManipulationObjectFile(const std::string& xmlFName);
229 VirtualRobot::ManipulationObjectPtr
230 createManipulationObjectFromIvFiles(const std::string& objName,
231 const std::string& ivFnameVis,
232 const std::string& ivFNameCollision);
233
234 void storeClassManipulationFile(memoryx::ObjectClassPtr objClass,
235 const std::string& xmlFName);
236 void storeClassManipulationObject(memoryx::ObjectClassPtr objClass,
237 const VirtualRobot::ManipulationObjectPtr mo);
238 void storeClassIVFiles(memoryx::ObjectClassPtr objClass,
239 const std::string& visuFName,
240 const std::string& collisionFName);
241
242 void findIVTextures(const std::string& ivFName, NameList& textures);
243
244 void updateObjectInTree(memoryx::ObjectClassPtr obj);
245 std::string getSelectedClassId();
246 std::string getSelectedClassName();
247
248 std::string getFilesDBName();
249
250 void showObjectClassModel(const std::string& objectId,
251 VirtualRobot::SceneObject::VisualizationType visuType);
252
253 void refreshControls();
254
255 void setCurrentCollection(const std::string& collNS);
256 void refreshCollectionList();
257
258 QPointer<PriorEditorConfigDialog> dialog;
259 QPointer<CollectionCreateDialog> collCreateDialog;
260
261 std::string settings_priorMemory;
262 std::string settings_mongoHost;
263 std::string settings_mongoUser;
264 std::string settings_mongoPass;
265 std::string settings_robotStateComponentProxyName;
266 armarx::RobotStateComponentInterfacePrx robotStateComponent;
267
268 bool connected;
269 };
270
271 using PriorEditorControllerPtr = std::shared_ptr<PriorEditorController>;
272} // namespace memoryx
The main gui interface.
void onInitComponent() override
Pure virtual hook for the subclass.
void treeItemDoubleClicked(QTreeWidgetItem *item, int column)
void objectChanged(QString objectId, bool isNew)
void onDisconnectComponent() override
Hook for subclass.
void createVisualization(const ::memoryx::ObjectClassPtr obj)
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,...
QPointer< QDialog > getConfigDialog(QWidget *parent=0) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
void onConnectComponent() override
Pure virtual hook for the subclass.
std::map< std::string, ObjectClassPtr > ObjectEntryMap
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
void treeCurrentItemChanged(QTreeWidgetItem *cur, QTreeWidgetItem *prev)
void updateObject(const memoryx::ObjectClassPtr obj, bool force=false)
void onExitComponent() override
Hook for subclass.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
VirtualRobot headers.
IceInternal::Handle< ObjectClass > ObjectClassPtr
Definition ObjectClass.h:35
std::shared_ptr< PriorEditorController > PriorEditorControllerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr