From 6a54a16573e7ab420c0ba88034af52ca1de8f5f7 Mon Sep 17 00:00:00 2001 From: Markus Grotz <markus.grotz@kit.edu> Date: Tue, 16 Aug 2016 17:38:17 +0200 Subject: [PATCH] added config dialog for ViewSelection gui plugin --- .../gui-plugins/ViewSelection/CMakeLists.txt | 5 +- .../ViewSelectionConfigDialog.cpp | 61 ++++++++++++++ .../ViewSelection/ViewSelectionConfigDialog.h | 55 +++++++++++++ .../ViewSelectionConfigDialog.ui | 79 +++++++++++++++++++ .../ViewSelectionWidgetController.cpp | 27 +++++-- .../ViewSelectionWidgetController.h | 14 ++++ 6 files changed, 233 insertions(+), 8 deletions(-) create mode 100644 source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.cpp create mode 100644 source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.h create mode 100644 source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.ui diff --git a/source/RobotAPI/gui-plugins/ViewSelection/CMakeLists.txt b/source/RobotAPI/gui-plugins/ViewSelection/CMakeLists.txt index 1110c902b..5d034f30e 100644 --- a/source/RobotAPI/gui-plugins/ViewSelection/CMakeLists.txt +++ b/source/RobotAPI/gui-plugins/ViewSelection/CMakeLists.txt @@ -16,12 +16,12 @@ if(QT_FOUND) endif() set(SOURCES -./ViewSelectionGuiPlugin.cpp ./ViewSelectionWidgetController.cpp +./ViewSelectionGuiPlugin.cpp ./ViewSelectionWidgetController.cpp ./ViewSelectionConfigDialog.cpp #@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@GuiPlugin.cpp @COMPONENT_PATH@/@COMPONENT_NAME@WidgetController.cpp ) set(HEADERS -./ViewSelectionGuiPlugin.h ./ViewSelectionWidgetController.h +./ViewSelectionGuiPlugin.h ./ViewSelectionWidgetController.h ./ViewSelectionConfigDialog.h #@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@GuiPlugin.h @COMPONENT_PATH@/@COMPONENT_NAME@WidgetController.h ) @@ -29,6 +29,7 @@ set(GUI_MOC_HDRS ${HEADERS}) set(GUI_UIS ./ViewSelectionWidget.ui +./ViewSelectionConfigDialog.ui #@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@Widget.ui ) diff --git a/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.cpp b/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.cpp new file mode 100644 index 000000000..248c260f2 --- /dev/null +++ b/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.cpp @@ -0,0 +1,61 @@ +#include "ViewSelectionConfigDialog.h" +#include "ui_ViewSelectionConfigDialog.h" + +#include <RobotAPI/interface/components/ViewSelectionInterface.h> + +#include <QPushButton> +#include <QMessageBox> +#include <IceUtil/UUID.h> + +using namespace armarx; + +ViewSelectionConfigDialog::ViewSelectionConfigDialog(QWidget* parent) : + QDialog(parent), + ui(new Ui::ViewSelectionConfigDialog), + uuid(IceUtil::generateUUID()) +{ + ui->setupUi(this); + ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); + connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(verifyConfig())); + + viewSelectionProxyFinder = new IceProxyFinder<ViewSelectionInterfacePrx>(this); + viewSelectionProxyFinder->setSearchMask("*ViewSelection"); + //ui->verticalLayout->addWidget(viewSelectionProxyFinder); +} + +ViewSelectionConfigDialog::~ViewSelectionConfigDialog() +{ + delete ui; +} + + +void ViewSelectionConfigDialog::onInitComponent() +{ +} + +void ViewSelectionConfigDialog::onConnectComponent() +{ + viewSelectionProxyFinder->setIceManager(getIceManager()); +} + +void ViewSelectionConfigDialog::onExitComponent() +{ + QObject::disconnect(); +} + +std::string ViewSelectionConfigDialog::getDefaultName() const +{ + return "ViewSelectionConfigDialog" + uuid; +} + +void ViewSelectionConfigDialog::verifyConfig() +{ + + if (!viewSelectionProxyFinder->getSelectedProxyName().trimmed().length()) + { + QMessageBox::critical(this, "Invalid Configuration", "The proxy names must not be empty"); + return; + } + + this->accept(); +} diff --git a/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.h b/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.h new file mode 100644 index 000000000..c940226dd --- /dev/null +++ b/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.h @@ -0,0 +1,55 @@ +#ifndef VIEWSELECTIONCONFIGDIALOG_H +#define VIEWSELECTIONCONFIGDIALOG_H + + +#include <QDialog> + +#include <ArmarXCore/core/ManagedIceObject.h> + + +#include <ArmarXGui/libraries/ArmarXGuiBase/widgets/IceProxyFinder.h> + +using namespace armarx; + +namespace Ui +{ + class ViewSelectionConfigDialog; +} + +class ViewSelectionConfigDialog : public QDialog, + virtual public armarx::ManagedIceObject +{ + Q_OBJECT + +public: + explicit ViewSelectionConfigDialog(QWidget* parent = 0); + ~ViewSelectionConfigDialog(); + + std::string getViewSelectionName() + { + return viewSelectionProxyFinder->getSelectedProxyName().toStdString(); + } + +signals: + +public slots: + void verifyConfig(); + + // ManagedIceObject interface +protected: + void onInitComponent(); + void onConnectComponent(); + void onExitComponent(); + std::string getDefaultName() const; + +private: + + Ui::ViewSelectionConfigDialog* ui; + + IceProxyFinderBase* viewSelectionProxyFinder; + + std::string uuid; + +}; + +#endif // VIEWSELECTIONCONFIGDIALOG_H diff --git a/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.ui b/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.ui new file mode 100644 index 000000000..0224d10c5 --- /dev/null +++ b/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionConfigDialog.ui @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ViewSelectionConfigDialog</class> + <widget class="QDialog" name="ViewSelectionConfigDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>369</width> + <height>179</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="geometry"> + <rect> + <x>20</x> + <y>140</y> + <width>341</width> + <height>32</height> + </rect> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + <widget class="QWidget" name="verticalLayoutWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>351</width> + <height>80</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"/> + </widget> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>ViewSelectionConfigDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>ViewSelectionConfigDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionWidgetController.cpp b/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionWidgetController.cpp index 79f47ec42..9ee4739c7 100644 --- a/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionWidgetController.cpp +++ b/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionWidgetController.cpp @@ -33,7 +33,6 @@ ViewSelectionWidgetController::ViewSelectionWidgetController() connect(widget.pushButton, SIGNAL(clicked()), this, SLOT(triggerSaliencyMapVisualization())); connect(widget.checkBox, SIGNAL(toggled(bool)), this, SLOT(toggleViewSelection(bool))); - } @@ -43,28 +42,39 @@ ViewSelectionWidgetController::~ViewSelectionWidgetController() } -void ViewSelectionWidgetController::loadSettings(QSettings* settings) + +QPointer<QDialog> ViewSelectionWidgetController::getConfigDialog(QWidget* parent) { + if (!configDialog) + { + configDialog = new ViewSelectionConfigDialog(parent); + } + + return qobject_cast<ViewSelectionConfigDialog*>(configDialog); +} +void ViewSelectionWidgetController::loadSettings(QSettings* settings) +{ + viewSelectionName = settings->value("viewSelectionName", "").toString().toStdString(); } void ViewSelectionWidgetController::saveSettings(QSettings* settings) { - + viewSelectionName = settings->value("viewSelectionName", QString::fromStdString(viewSelectionName)).toString().toStdString(); } void ViewSelectionWidgetController::onInitComponent() { - usingProxy("ViewSelection"); - usingTopic("ViewSelectionObserver"); + usingProxy(viewSelectionName); + usingTopic(viewSelectionName + "Observer"); } void ViewSelectionWidgetController::onConnectComponent() { - viewSelection = getProxy<ViewSelectionInterfacePrx>("ViewSelection"); + viewSelection = getProxy<ViewSelectionInterfacePrx>(viewSelectionName); widget.checkBox->setChecked(viewSelection->isEnabledAutomaticViewSelection()); } @@ -103,3 +113,8 @@ void ViewSelectionWidgetController::triggerSaliencyMapVisualization() { viewSelection->drawSaliencyMap(); } + +void armarx::ViewSelectionWidgetController::configured() +{ + viewSelectionName = configDialog->getViewSelectionName(); +} diff --git a/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionWidgetController.h b/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionWidgetController.h index d0b8f36d6..c62ed0072 100644 --- a/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionWidgetController.h +++ b/source/RobotAPI/gui-plugins/ViewSelection/ViewSelectionWidgetController.h @@ -32,8 +32,14 @@ #include <RobotAPI/interface/components/ViewSelectionInterface.h> +#include "ViewSelectionConfigDialog.h" + namespace armarx { + + //class ViewSelectionConfigDialog; + + /** \page ArmarXGui-GuiPlugins-ViewSelection ViewSelection \brief The ViewSelection allows visualizing ... @@ -80,6 +86,7 @@ namespace armarx */ virtual void saveSettings(QSettings* settings); + void configured(); void onActivateAutomaticViewSelection(const Ice::Current& c = Ice::Current()); void onDeactivateAutomaticViewSelection(const Ice::Current& c = Ice::Current()); @@ -104,6 +111,9 @@ namespace armarx */ virtual void onConnectComponent(); + + virtual QPointer<QDialog> getConfigDialog(QWidget* parent); + public slots: void triggerSaliencyMapVisualization(); @@ -119,8 +129,12 @@ namespace armarx */ Ui::ViewSelectionWidget widget; + QPointer<ViewSelectionConfigDialog> configDialog; + ViewSelectionInterfacePrx viewSelection; + std::string viewSelectionName; + }; } -- GitLab