diff --git a/source/RobotAPI/gui-plugins/ObjectPoseGui/CMakeLists.txt b/source/RobotAPI/gui-plugins/ObjectPoseGui/CMakeLists.txt index faf1e6180e072b4e4299fc0e2441969e93257ecf..d4d29bd3e4181aa055f7dee976a778f75d42a877 100644 --- a/source/RobotAPI/gui-plugins/ObjectPoseGui/CMakeLists.txt +++ b/source/RobotAPI/gui-plugins/ObjectPoseGui/CMakeLists.txt @@ -23,7 +23,10 @@ set(GUI_UIS ) # Add more libraries you depend on here, e.g. ${QT_LIBRARIES}. -set(COMPONENT_LIBS ) +set(COMPONENT_LIBS + SimpleConfigDialog + ObjectPoseObserver +) if(ArmarXGui_FOUND) armarx_gui_library(ObjectPoseGuiPlugin "${SOURCES}" "${GUI_MOC_HDRS}" "${GUI_UIS}" "" "${COMPONENT_LIBS}") diff --git a/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidget.ui b/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidget.ui index 39b421458e3d9bfd2633be4a4a89af8c329ec480..83f77d3ae4886eaced3509fa4c1af1c62a21d80f 100644 --- a/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidget.ui +++ b/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidget.ui @@ -13,6 +13,51 @@ <property name="windowTitle"> <string>ObjectPoseGuiWidget</string> </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="objectsGroupBox"> + <property name="title"> + <string>Objects</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QPushButton" name="updateObjectsButton"> + <property name="text"> + <string>Update</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="autoUpdateCheckBox"> + <property name="text"> + <string>Auto Update</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <widget class="QTableWidget" name="objectsTable"/> + </item> + </layout> + </widget> + </item> + </layout> </widget> <resources/> <connections/> diff --git a/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidgetController.cpp b/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidgetController.cpp index bafffb7caa8dd3be506936e39d5aa5ec5183aee8..816e797f42714e8da58658d7bde649241fac6cf8 100644 --- a/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidgetController.cpp +++ b/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidgetController.cpp @@ -24,6 +24,11 @@ #include <string> +#include <QTimer> + +#include <RobotAPI/components/ObjectPoseObserver/ice_conversions.h> +#include <RobotAPI/components/ObjectPoseObserver/ObjectPose.h> + namespace armarx { @@ -31,6 +36,15 @@ namespace armarx ObjectPoseGuiWidgetController::ObjectPoseGuiWidgetController() { widget.setupUi(getWidget()); + + QStringList header = {"Dataset", "Name", "Provider", "Type"}; + widget.objectsTable->setColumnCount(header.size()); + widget.objectsTable->setHorizontalHeaderLabels(header); + + using This = ObjectPoseGuiWidgetController; + + connect(widget.updateObjectsButton, &QPushButton::clicked, this, &This::updateObjects); + // QTimer* timer = new QTimer(this,); } @@ -42,10 +56,12 @@ namespace armarx void ObjectPoseGuiWidgetController::loadSettings(QSettings* settings) { + (void) settings; } void ObjectPoseGuiWidgetController::saveSettings(QSettings* settings) { + (void) settings; } QString ObjectPoseGuiWidgetController::GetWidgetName() @@ -53,14 +69,72 @@ namespace armarx return "ObjectPoseGui"; } + static const std::string CONFIG_KEY_OBJECT_POSE_OBSERVER = "ObjectPoseObserver"; - void ObjectPoseGuiWidgetController::onInitComponent() + QPointer<QDialog> ObjectPoseGuiWidgetController::getConfigDialog(QWidget* parent) { + if (!configDialog) + { + configDialog = new SimpleConfigDialog(parent); + configDialog->addProxyFinder<armarx::objpose::ObjectPoseObserverInterfacePrx>({CONFIG_KEY_OBJECT_POSE_OBSERVER, "Object pose observer.", "ObjectPoseObserver"}); + } + return qobject_cast<QDialog*>(configDialog); + } + void ObjectPoseGuiWidgetController::configured() + { + if (configDialog) + { + objectPoseObserverName = configDialog->getProxyName(CONFIG_KEY_OBJECT_POSE_OBSERVER); + } + } + + void ObjectPoseGuiWidgetController::onInitComponent() + { + if (!objectPoseObserverName.empty()) + { + usingProxy(objectPoseObserverName); + } } void ObjectPoseGuiWidgetController::onConnectComponent() { + if (!objectPoseObserverName.empty()) + { + getProxy(objectPoseObserver, objectPoseObserverName); + } + } + void ObjectPoseGuiWidgetController::updateObjects() + { + if (!objectPoseObserver) + { + return; + } + + ARMARX_INFO << "Get object poses..."; + // const objpose::ObjectPoseSeq objectPoses = objpose::fromIce(objectPoseObserver->getObjectPoses()); + + const objpose::data::ObjectPoseSeq objectPoses = objectPoseObserver->getObjectPoses(); + ARMARX_INFO << "Got " << objectPoses.size() << " object poses."; + + widget.objectsTable->setRowCount(int(objectPoses.size())); + + for (int i = 0; i < int(objectPoses.size()); ++i) + { + const objpose::data::ObjectPose& pose = objectPoses.at(size_t(i)); + int col = 0; + + widget.objectsTable->setItem( + i, col++, new QTableWidgetItem(pose.objectID.dataset.c_str())); + widget.objectsTable->setItem( + i, col++, new QTableWidgetItem(pose.objectID.name.c_str())); + widget.objectsTable->setItem( + i, col++, new QTableWidgetItem(pose.providerName.c_str())); + widget.objectsTable->setItem( + i, col++, new QTableWidgetItem(objpose::ObjectTypeEnumNames.to_name(pose.objectType).c_str())); + + } } + } diff --git a/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidgetController.h b/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidgetController.h index 4c71bdab143101fb4b8339025c7e30ed003dfcde..d9b716d7cc4186cbbff58858aaf25088726fa283 100644 --- a/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidgetController.h +++ b/source/RobotAPI/gui-plugins/ObjectPoseGui/ObjectPoseGuiWidgetController.h @@ -25,9 +25,13 @@ #include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h> #include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h> +#include <ArmarXGui/libraries/SimpleConfigDialog/SimpleConfigDialog.h> #include <ArmarXCore/core/system/ImportExportComponent.h> +#include <RobotAPI/interface/objectpose/ObjectPoseObserver.h> + + namespace armarx { /** @@ -59,7 +63,10 @@ namespace armarx explicit ObjectPoseGuiWidgetController(); /// Controller destructor - virtual ~ObjectPoseGuiWidgetController(); + virtual ~ObjectPoseGuiWidgetController() override; + + /// Returns the Widget name displayed in the ArmarXGui to create an instance of this class. + static QString GetWidgetName(); /// @see ArmarXWidgetController::loadSettings() @@ -67,8 +74,9 @@ namespace armarx /// @see ArmarXWidgetController::saveSettings() void saveSettings(QSettings* settings) override; - /// Returns the Widget name displayed in the ArmarXGui to create an instance of this class. - static QString GetWidgetName(); + + QPointer<QDialog> getConfigDialog(QWidget* parent) override; + void configured() override; /// @see armarx::Component::onInitComponent() @@ -81,6 +89,9 @@ namespace armarx public slots: /* QT slot declarations */ + void updateObjects(); + + signals: /* QT signal declarations */ @@ -89,6 +100,12 @@ namespace armarx /// Widget Form Ui::ObjectPoseGuiWidget widget; + QPointer<SimpleConfigDialog> configDialog; + + + std::string objectPoseObserverName; + armarx::objpose::ObjectPoseObserverInterfacePrx objectPoseObserver; + }; }