Skip to content
Snippets Groups Projects
Commit cca8b296 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Show objects in GUI

parent 2252ae97
No related branches found
No related tags found
1 merge request!73Updates to Object pose observer
......@@ -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}")
......
......@@ -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/>
......
......@@ -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()));
}
}
}
......@@ -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;
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment