diff --git a/source/RobotAPI/gui-plugins/CMakeLists.txt b/source/RobotAPI/gui-plugins/CMakeLists.txt index 423ec3285d801635b8d00309258cebcc9683a053..408c06b2dffd5bbd0eb9e31b583e4a0640b4bd37 100644 --- a/source/RobotAPI/gui-plugins/CMakeLists.txt +++ b/source/RobotAPI/gui-plugins/CMakeLists.txt @@ -7,3 +7,5 @@ add_subdirectory(RobotViewerPlugin) + +add_subdirectory(DebugDrawerViewer) \ No newline at end of file diff --git a/source/RobotAPI/gui-plugins/DebugDrawerViewer/CMakeLists.txt b/source/RobotAPI/gui-plugins/DebugDrawerViewer/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5842e4fbd8f0fc57c02dbd315864c9c20db1c9bd --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerViewer/CMakeLists.txt @@ -0,0 +1,40 @@ + +armarx_set_target("DebugDrawerViewerGuiPlugin") + +find_package(Qt4 COMPONENTS QtCore QtGui QtDesigner) + +armarx_build_if(QT_FOUND "Qt not available") +# ArmarXGui gets included through depends_on_armarx_package(ArmarXGui "OPTIONAL") +# in the toplevel CMakeLists.txt +armarx_build_if(ArmarXGui_FOUND "ArmarXGui not available") + + +# all include_directories must be guarded by if(Xyz_FOUND) +# for multiple libraries write: if(X_FOUND AND Y_FOUND).... +if(QT_FOUND) + include(${QT_USE_FILE}) +endif() + +set(SOURCES +./DebugDrawerViewerGuiPlugin.cpp ./DebugDrawerViewerWidgetController.cpp +#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@GuiPlugin.cpp @COMPONENT_PATH@/@COMPONENT_NAME@WidgetController.cpp +) + +set(HEADERS +./DebugDrawerViewerGuiPlugin.h ./DebugDrawerViewerWidgetController.h +#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@GuiPlugin.h @COMPONENT_PATH@/@COMPONENT_NAME@WidgetController.h +) + +set(GUI_MOC_HDRS ${HEADERS}) + +set(GUI_UIS +./DebugDrawerViewerWidget.ui +#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@Widget.ui +) + +# Add more libraries you depend on here, e.g. ${QT_LIBRARIES}. +set(COMPONENT_LIBS DebugDrawer ${QT_LIBRARIES}) + +if(ArmarXGui_FOUND) + armarx_gui_library(DebugDrawerViewerGuiPlugin "${SOURCES}" "${GUI_MOC_HDRS}" "${GUI_UIS}" "" "${COMPONENT_LIBS}") +endif() diff --git a/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerGuiPlugin.cpp b/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerGuiPlugin.cpp new file mode 100644 index 0000000000000000000000000000000000000000..741dd98a26bc14b24e45ae236c1d82d858357a63 --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerGuiPlugin.cpp @@ -0,0 +1,34 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * \package RobotAPI::gui-plugins::DebugDrawerViewerGuiPlugin + * \author Mirko Waechter ( mirko dot waechter at kit dot edu ) + * \date 2016 + * \copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "DebugDrawerViewerGuiPlugin.h" + +#include "DebugDrawerViewerWidgetController.h" + +using namespace armarx; + +DebugDrawerViewerGuiPlugin::DebugDrawerViewerGuiPlugin() +{ + addWidget < DebugDrawerViewerWidgetController > (); +} + +Q_EXPORT_PLUGIN2(armarx_gui_DebugDrawerViewerGuiPlugin, DebugDrawerViewerGuiPlugin) diff --git a/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerGuiPlugin.h b/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerGuiPlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..14d7959a43ad66ecac5223c5aa8b5bd6021a6ae8 --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerGuiPlugin.h @@ -0,0 +1,51 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * \package RobotAPI::gui-plugins::DebugDrawerViewer + * \author Mirko Waechter ( mirko dot waechter at kit dot edu ) + * \date 2016 + * \copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_RobotAPI_DebugDrawerViewer_GuiPlugin_H +#define _ARMARX_RobotAPI_DebugDrawerViewer_GuiPlugin_H + +#include <ArmarXCore/core/system/ImportExportComponent.h> +#include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h> +#include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h> + +namespace armarx +{ + /** + * \class DebugDrawerViewerGuiPlugin + * \ingroup ArmarXGuiPlugins + * \brief DebugDrawerViewerGuiPlugin brief description + * + * Detailed description + */ + class ARMARXCOMPONENT_IMPORT_EXPORT DebugDrawerViewerGuiPlugin: + public armarx::ArmarXGuiPlugin + { + public: + /** + * All widgets exposed by this plugin are added in the constructor + * via calls to addWidget() + */ + DebugDrawerViewerGuiPlugin(); + }; +} + +#endif diff --git a/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerWidget.ui b/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerWidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..9888ab71f5d6e6b6bdfdaa80a74c4f609e37e6cd --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerWidget.ui @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>DebugDrawerViewerWidget</class> + <widget class="QWidget" name="DebugDrawerViewerWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>DebugDrawerViewerWidget</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QPushButton" name="btnClearAll"> + <property name="text"> + <string>Remove All Visualizations</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerWidgetController.cpp b/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerWidgetController.cpp new file mode 100644 index 0000000000000000000000000000000000000000..df7c61710429535666e6a630e38125b830829c57 --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerWidgetController.cpp @@ -0,0 +1,116 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * \package RobotAPI::gui-plugins::DebugDrawerViewerWidgetController + * \author Mirko Waechter ( mirko dot waechter at kit dot edu ) + * \date 2016 + * \copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "DebugDrawerViewerWidgetController.h" +#include <ArmarXCore/core/ArmarXManager.h> +#include <string> + +using namespace armarx; + +DebugDrawerViewerWidgetController::DebugDrawerViewerWidgetController() +{ + rootVisu = NULL; + widget.setupUi(getWidget()); + +} + + +DebugDrawerViewerWidgetController::~DebugDrawerViewerWidgetController() +{ + +} + + +void DebugDrawerViewerWidgetController::loadSettings(QSettings* settings) +{ + +} + +void DebugDrawerViewerWidgetController::saveSettings(QSettings* settings) +{ + +} + + +void DebugDrawerViewerWidgetController::onInitComponent() +{ + rootVisu = new SoSeparator; + rootVisu->ref(); + + + enableMainWidgetAsync(false); + connect(widget.btnClearAll, SIGNAL(clicked()), this, SLOT(on_btnClearAll_clicked()), Qt::UniqueConnection); +} + + +void DebugDrawerViewerWidgetController::onConnectComponent() +{ + // create the debugdrawer component + std::string debugDrawerComponentName = "GUIDebugDrawer_" + getName(); + ARMARX_INFO << "Creating component " << debugDrawerComponentName; + debugDrawer = Component::create<DebugDrawerComponent>(properties, debugDrawerComponentName); + + if (mutex3D) + { + //ARMARX_IMPORTANT << "mutex3d:" << mutex3D.get(); + debugDrawer->setMutex(mutex3D); + } + else + { + ARMARX_ERROR << " No 3d mutex available..."; + } + + ArmarXManagerPtr m = getArmarXManager(); + m->addObject(debugDrawer, false); + + { + boost::recursive_mutex::scoped_lock lock(*mutex3D); + rootVisu->addChild(debugDrawer->getVisualization()); + } + enableMainWidgetAsync(true); +} + + +SoNode *DebugDrawerViewerWidgetController::getScene() +{ + return rootVisu; +} + + +void armarx::DebugDrawerViewerWidgetController::onExitComponent() +{ + if (rootVisu) + { + rootVisu->removeAllChildren(); + rootVisu->unref(); + rootVisu = NULL; + } +} + +void armarx::DebugDrawerViewerWidgetController::on_btnClearAll_clicked() +{ + ARMARX_INFO << "Clearing visu"; + if(debugDrawer) + { + debugDrawer->clearAll(); + } +} diff --git a/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerWidgetController.h b/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerWidgetController.h new file mode 100644 index 0000000000000000000000000000000000000000..a3ce4c6d809702e0f63b8d6daa60d2341d33e5ab --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerViewer/DebugDrawerViewerWidgetController.h @@ -0,0 +1,127 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::gui-plugins::DebugDrawerViewerWidgetController + * @author Mirko Waechter ( mirko dot waechter at kit dot edu ) + * @date 2016 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_RobotAPI_DebugDrawerViewer_WidgetController_H +#define _ARMARX_RobotAPI_DebugDrawerViewer_WidgetController_H + +#include "ui_DebugDrawerViewerWidget.h" + +#include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h> +#include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h> + +#include <RobotAPI/components/DebugDrawer/DebugDrawerComponent.h> + +#include <ArmarXCore/core/system/ImportExportComponent.h> + +namespace armarx +{ + /** + \page ArmarXGui-GuiPlugins-DebugDrawerViewer DebugDrawerViewer + \brief The DebugDrawerViewer listens on the DebugDrawer topic and visualizes all the data coming in. + This GUI only display the DebugDrawer content and nothing else. + The content is shown in the 3D Viewer Widget. + + API Documentation \ref DebugDrawerViewerWidgetController + + \see DebugDrawerViewerGuiPlugin + */ + + /** + * \class DebugDrawerViewerWidgetController + * \brief DebugDrawerViewerWidgetController + * + * Detailed description + */ + class ARMARXCOMPONENT_IMPORT_EXPORT + DebugDrawerViewerWidgetController: + public armarx::ArmarXComponentWidgetController + { + Q_OBJECT + + public: + /** + * Controller Constructor + */ + explicit DebugDrawerViewerWidgetController(); + + /** + * Controller destructor + */ + virtual ~DebugDrawerViewerWidgetController(); + + /** + * @see ArmarXWidgetController::loadSettings() + */ + virtual void loadSettings(QSettings* settings); + + /** + * @see ArmarXWidgetController::saveSettings() + */ + virtual void saveSettings(QSettings* settings); + + /** + * Returns the Widget name displayed in the ArmarXGui to create an + * instance of this class. + */ + virtual QString getWidgetName() const + { + return "DebugDrawerViewer"; + } + + /** + * \see armarx::Component::onInitComponent() + */ + virtual void onInitComponent(); + + /** + * \see armarx::Component::onConnectComponent() + */ + virtual void onConnectComponent(); + + void onExitComponent(); + + public slots: + /* QT slot declarations */ + + signals: + /* QT signal declarations */ + + private: + /** + * Widget Form + */ + Ui::DebugDrawerViewerWidget widget; + armarx::DebugDrawerComponentPtr debugDrawer; + SoSeparator* rootVisu; + + // ArmarXWidgetController interface + public: + SoNode *getScene(); + + + + private slots: + void on_btnClearAll_clicked(); + }; +} + +#endif