diff --git a/source/RobotAPI/gui-plugins/CMakeLists.txt b/source/RobotAPI/gui-plugins/CMakeLists.txt index a7264e2efb9dec80834ffa301388c0bad7153801..311ff3c807afda29b6cbf0c8b80e7466c0063546 100644 --- a/source/RobotAPI/gui-plugins/CMakeLists.txt +++ b/source/RobotAPI/gui-plugins/CMakeLists.txt @@ -11,4 +11,5 @@ add_subdirectory(RobotUnitPlugin) add_subdirectory(HomogeneousMatrixCalculator) add_subdirectory(GuiHealthClient) -add_subdirectory(CartesianWaypointControlGui) \ No newline at end of file +add_subdirectory(CartesianWaypointControlGui) +add_subdirectory(DebugDrawerGuiPlugin) \ No newline at end of file diff --git a/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/CMakeLists.txt b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..bc2da5ffec146fb2df2aa055ccd66fa3c0071738 --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/CMakeLists.txt @@ -0,0 +1,19 @@ +armarx_set_target("DebugDrawerGuiPluginGuiPlugin") +armarx_build_if(ArmarXGui_FOUND "ArmarXGui not available") + +set(SOURCES DebugDrawerGuiPluginGuiPlugin.cpp DebugDrawerGuiPluginWidgetController.cpp) +set(HEADERS DebugDrawerGuiPluginGuiPlugin.h DebugDrawerGuiPluginWidgetController.h) + +set(GUI_MOC_HDRS ${HEADERS}) +set(GUI_UIS DebugDrawerGuiPluginWidget.ui) + +# Add more libraries you depend on here, e.g. ${QT_LIBRARIES}. +set(COMPONENT_LIBS + DebugDrawer + RobotAPIInterfaces + SimpleConfigDialog +) + +if(ArmarXGui_FOUND) + armarx_gui_library(DebugDrawerGuiPluginGuiPlugin "${SOURCES}" "${GUI_MOC_HDRS}" "${GUI_UIS}" "" "${COMPONENT_LIBS}") +endif() diff --git a/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginGuiPlugin.cpp b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginGuiPlugin.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cb25e8c75ea94d59c26c88d2e4e5bcf16b264163 --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginGuiPlugin.cpp @@ -0,0 +1,33 @@ +/* + * 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::DebugDrawerGuiPluginGuiPlugin + * \author Raphael Grimm ( raphael dot grimm at kit dot edu ) + * \date 2019 + * \copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "DebugDrawerGuiPluginGuiPlugin.h" + +#include "DebugDrawerGuiPluginWidgetController.h" + +namespace armarx +{ + DebugDrawerGuiPluginGuiPlugin::DebugDrawerGuiPluginGuiPlugin() + { + addWidget < DebugDrawerGuiPluginWidgetController > (); + } +} diff --git a/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginGuiPlugin.h b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginGuiPlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..762c61fc88303d0d627de2b37164ef9b9bd1e6b1 --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginGuiPlugin.h @@ -0,0 +1,50 @@ +/* + * 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::DebugDrawerGuiPlugin + * \author Raphael Grimm ( raphael dot grimm at kit dot edu ) + * \date 2019 + * \copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#pragma once + +#include <ArmarXCore/core/system/ImportExportComponent.h> +#include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h> +#include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h> + +namespace armarx +{ + /** + * \class DebugDrawerGuiPluginGuiPlugin + * \ingroup ArmarXGuiPlugins + * \brief DebugDrawerGuiPluginGuiPlugin brief description + * + * Detailed description + */ + class ARMARXCOMPONENT_IMPORT_EXPORT DebugDrawerGuiPluginGuiPlugin: + public armarx::ArmarXGuiPlugin + { + Q_OBJECT + Q_INTERFACES(ArmarXGuiInterface) + Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00") + public: + /** + * All widgets exposed by this plugin are added in the constructor + * via calls to addWidget() + */ + DebugDrawerGuiPluginGuiPlugin(); + }; +} diff --git a/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginWidget.ui b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginWidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..3f0c005d6fff99611b8136ec6ca9b345f2b2a6b0 --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginWidget.ui @@ -0,0 +1,432 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>DebugDrawerGuiPluginWidget</class> + <widget class="QWidget" name="DebugDrawerGuiPluginWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>DebugDrawerGuiPluginWidget</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="1"> + <widget class="QComboBox" name="comboBoxLayer"> + <item> + <property name="text"> + <string>Debug</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0" colspan="3"> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Pose</string> + </attribute> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="1" column="3"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxPoseTY"> + <property name="minimum"> + <double>-10000.000000000000000</double> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + <property name="singleStep"> + <double>100.000000000000000</double> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Scale</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxPoseTX"> + <property name="minimum"> + <double>-10000.000000000000000</double> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + <property name="singleStep"> + <double>100.000000000000000</double> + </property> + </widget> + </item> + <item row="3" column="4"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxPoseRZ"> + <property name="minimum"> + <double>-360.000000000000000</double> + </property> + <property name="maximum"> + <double>360.000000000000000</double> + </property> + <property name="singleStep"> + <double>3.600000000000000</double> + </property> + </widget> + </item> + <item row="5" column="5"> + <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> + <item row="3" column="3"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxPoseRY"> + <property name="minimum"> + <double>-360.000000000000000</double> + </property> + <property name="maximum"> + <double>360.000000000000000</double> + </property> + <property name="singleStep"> + <double>3.600000000000000</double> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>XYZ</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>RPY [°]</string> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxPoseScale"> + <property name="maximum"> + <double>100.000000000000000</double> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + <item row="1" column="4"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxPoseTZ"> + <property name="minimum"> + <double>-10000.000000000000000</double> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + <property name="singleStep"> + <double>100.000000000000000</double> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxPoseRX"> + <property name="minimum"> + <double>-360.000000000000000</double> + </property> + <property name="maximum"> + <double>360.000000000000000</double> + </property> + <property name="singleStep"> + <double>3.600000000000000</double> + </property> + </widget> + </item> + <item row="5" column="2"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Name</string> + </property> + </widget> + </item> + <item row="0" column="2" colspan="2"> + <widget class="QLineEdit" name="lineEditPoseName"> + <property name="text"> + <string>Pose</string> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QPushButton" name="pushButtonPoseDelete"> + <property name="text"> + <string>Delete</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>Arrow</string> + </attribute> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="2" column="1"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowTX"> + <property name="minimum"> + <double>-10000.000000000000000</double> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + <property name="singleStep"> + <double>100.000000000000000</double> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowClrG"> + <property name="maximum"> + <double>1.000000000000000</double> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>From</string> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowFZ"> + <property name="minimum"> + <double>-10000.000000000000000</double> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + <property name="singleStep"> + <double>100.000000000000000</double> + </property> + </widget> + </item> + <item row="3" column="4"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowClrA"> + <property name="maximum"> + <double>1.000000000000000</double> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowClrR"> + <property name="maximum"> + <double>1.000000000000000</double> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>To</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowFX"> + <property name="minimum"> + <double>-10000.000000000000000</double> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + <property name="singleStep"> + <double>100.000000000000000</double> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowClrB"> + <property name="maximum"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + <item row="5" column="5"> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="2"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowFY"> + <property name="minimum"> + <double>-10000.000000000000000</double> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + <property name="singleStep"> + <double>100.000000000000000</double> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowTY"> + <property name="minimum"> + <double>-10000.000000000000000</double> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + <property name="singleStep"> + <double>100.000000000000000</double> + </property> + </widget> + </item> + <item row="5" column="0"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="3"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowTZ"> + <property name="minimum"> + <double>-10000.000000000000000</double> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + <property name="singleStep"> + <double>100.000000000000000</double> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Name</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxArrowWidth"/> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>Width</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>RGBA</string> + </property> + </widget> + </item> + <item row="0" column="1" colspan="3"> + <widget class="QLineEdit" name="lineEditArrowName"> + <property name="text"> + <string>Arrow</string> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QPushButton" name="pushButtonArrowDelete"> + <property name="text"> + <string>Delete</string> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item row="0" column="2"> + <widget class="QPushButton" name="pushButtonLayerClear"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Clear</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Layer</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginWidgetController.cpp b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginWidgetController.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5aac5e0f7192f3d87fb9b9fd15fc9eadef546b9c --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginWidgetController.cpp @@ -0,0 +1,178 @@ +/* + * 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::DebugDrawerGuiPluginWidgetController + * \author Raphael Grimm ( raphael dot grimm at kit dot edu ) + * \date 2019 + * \copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include <string> + +#include <Ice/UUID.h> + +#include <VirtualRobot/MathTools.h> + +#include <ArmarXCore/util/CPPUtility/trace.h> + +#include "DebugDrawerGuiPluginWidgetController.h" + +namespace armarx +{ + DebugDrawerGuiPluginWidgetController::DebugDrawerGuiPluginWidgetController(): + _layerName{Ice::generateUUID()}, + _debugDrawer{_layerName} + { + ARMARX_TRACE; + _ui.setupUi(getWidget()); + connect(_ui.pushButtonLayerClear, SIGNAL(clicked()), this, SLOT(on_pushButtonLayerClear_clicked())); + connect(_ui.pushButtonPoseDelete, SIGNAL(clicked()), this, SLOT(on_pushButtonPoseDelete_clicked())); + connect(_ui.pushButtonArrowDelete, SIGNAL(clicked()), this, SLOT(on_pushButtonArrowDelete_clicked())); + + connect(_ui.doubleSpinBoxPoseTX, SIGNAL(valueChanged(double)), this, SLOT(updatePose())); + connect(_ui.doubleSpinBoxPoseTY, SIGNAL(valueChanged(double)), this, SLOT(updatePose())); + connect(_ui.doubleSpinBoxPoseTZ, SIGNAL(valueChanged(double)), this, SLOT(updatePose())); + connect(_ui.doubleSpinBoxPoseRX, SIGNAL(valueChanged(double)), this, SLOT(updatePose())); + connect(_ui.doubleSpinBoxPoseRY, SIGNAL(valueChanged(double)), this, SLOT(updatePose())); + connect(_ui.doubleSpinBoxPoseRZ, SIGNAL(valueChanged(double)), this, SLOT(updatePose())); + connect(_ui.doubleSpinBoxPoseScale, SIGNAL(valueChanged(double)), this, SLOT(updatePose())); + + connect(_ui.doubleSpinBoxArrowFX, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + connect(_ui.doubleSpinBoxArrowFY, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + connect(_ui.doubleSpinBoxArrowFZ, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + connect(_ui.doubleSpinBoxArrowTX, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + connect(_ui.doubleSpinBoxArrowTY, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + connect(_ui.doubleSpinBoxArrowTZ, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + connect(_ui.doubleSpinBoxArrowClrR, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + connect(_ui.doubleSpinBoxArrowClrG, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + connect(_ui.doubleSpinBoxArrowClrB, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + connect(_ui.doubleSpinBoxArrowClrA, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + connect(_ui.doubleSpinBoxArrowWidth, SIGNAL(valueChanged(double)), this, SLOT(updateArrow())); + } + + + DebugDrawerGuiPluginWidgetController::~DebugDrawerGuiPluginWidgetController() + { + + } + + + void DebugDrawerGuiPluginWidgetController::loadSettings(QSettings* settings) + { + } + + void DebugDrawerGuiPluginWidgetController::saveSettings(QSettings* settings) + { + } + + + void DebugDrawerGuiPluginWidgetController::onInitComponent() + { + ARMARX_TRACE; + offeringTopic(_debugDrawerTopicName); + } + + + void DebugDrawerGuiPluginWidgetController::onConnectComponent() + { + ARMARX_TRACE; + _debugDrawer.setDebugDrawer(getTopic<DebugDrawerInterfacePrx>(_debugDrawerTopicName)); + } + + void DebugDrawerGuiPluginWidgetController::onDisconnectComponent() + { + _debugDrawer.clearLayer(); + } + + void DebugDrawerGuiPluginWidgetController::on_pushButtonArrowDelete_clicked() + { + const auto name = _ui.lineEditArrowName->text().toStdString(); + ARMARX_INFO << "Delete arrow " << name; + _debugDrawer.getDebugDrawer()->removePoseVisu(_layerName, name); + } + + void DebugDrawerGuiPluginWidgetController::on_pushButtonPoseDelete_clicked() + { + const auto name = _ui.lineEditPoseName->text().toStdString(); + ARMARX_INFO << "Delete pose " << name; + _debugDrawer.getDebugDrawer()->removePoseVisu(_layerName, name); + } + + void DebugDrawerGuiPluginWidgetController::on_pushButtonLayerClear_clicked() + { + _debugDrawer.clearLayer(); + } + + void DebugDrawerGuiPluginWidgetController::updatePose() + { + const auto name = _ui.lineEditPoseName->text().toStdString(); + ARMARX_INFO << "Updated pose " << name; + + const float deg2rad = M_PI / 360; + + _debugDrawer.drawPose( + name, + VirtualRobot::MathTools::posrpy2eigen4f( + _ui.doubleSpinBoxPoseTX->value(), + _ui.doubleSpinBoxPoseTY->value(), + _ui.doubleSpinBoxPoseTZ->value(), + _ui.doubleSpinBoxPoseRX->value() * deg2rad, + _ui.doubleSpinBoxPoseRY->value() * deg2rad, + _ui.doubleSpinBoxPoseRZ->value() * deg2rad + ), + _ui.doubleSpinBoxPoseScale->value()); + } + + void DebugDrawerGuiPluginWidgetController::updateArrow() + { + const Eigen::Vector3f from + { + static_cast<float>(_ui.doubleSpinBoxArrowFX->value()), + static_cast<float>(_ui.doubleSpinBoxArrowFY->value()), + static_cast<float>(_ui.doubleSpinBoxArrowFZ->value()) + }; + + const Eigen::Vector3f to + { + static_cast<float>(_ui.doubleSpinBoxArrowTX->value()), + static_cast<float>(_ui.doubleSpinBoxArrowTY->value()), + static_cast<float>(_ui.doubleSpinBoxArrowTZ->value()) + }; + + const Eigen::Vector3f dir = to - from; + + const float len = dir.norm(); + + const auto name = _ui.lineEditArrowName->text().toStdString(); + ARMARX_INFO << "Updated arrow " << name; + + _debugDrawer.drawArrow( + name, + from, + dir.normalized(), + { + static_cast<float>(_ui.doubleSpinBoxArrowClrR->value()), + static_cast<float>(_ui.doubleSpinBoxArrowClrG->value()), + static_cast<float>(_ui.doubleSpinBoxArrowClrB->value()), + static_cast<float>(_ui.doubleSpinBoxArrowClrA->value()) + }, + len, + static_cast<float>(_ui.doubleSpinBoxArrowWidth->value())); + } +} + + + diff --git a/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginWidgetController.h b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginWidgetController.h new file mode 100644 index 0000000000000000000000000000000000000000..0e94de05075e4ec5074068cb46733a59d3df99b2 --- /dev/null +++ b/source/RobotAPI/gui-plugins/DebugDrawerGuiPlugin/DebugDrawerGuiPluginWidgetController.h @@ -0,0 +1,106 @@ +/* + * 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::DebugDrawerGuiPluginWidgetController + * @author Raphael Grimm ( raphael dot grimm at kit dot edu ) + * @date 2019 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#pragma once + +#include <RobotAPI/gui-plugins/DebugDrawerGuiPlugin/ui_DebugDrawerGuiPluginWidget.h> + +#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/components/DebugDrawer/DebugDrawerHelper.h> + +namespace armarx +{ + /** + \page RobotAPI-GuiPlugins-DebugDrawerGuiPlugin DebugDrawerGuiPlugin + \brief The DebugDrawerGuiPlugin allows visualizing ... + + \image html DebugDrawerGuiPlugin.png + The user can + + API Documentation \ref DebugDrawerGuiPluginWidgetController + + \see DebugDrawerGuiPluginGuiPlugin + */ + + /** + * \class DebugDrawerGuiPluginWidgetController + * \brief DebugDrawerGuiPluginWidgetController brief one line description + * + * Detailed description + */ + class ARMARXCOMPONENT_IMPORT_EXPORT + DebugDrawerGuiPluginWidgetController: + public armarx::ArmarXComponentWidgetControllerTemplate < DebugDrawerGuiPluginWidgetController > + { + Q_OBJECT + + public: + explicit DebugDrawerGuiPluginWidgetController(); + virtual ~DebugDrawerGuiPluginWidgetController(); + + void loadSettings(QSettings* settings) override; + void saveSettings(QSettings* settings) override; + + /** + * Returns the Widget name displayed in the ArmarXGui to create an + * instance of this class. + */ + static QString GetWidgetName() + { + return "Visualization.DebugDrawerGuiPlugin"; + } + + void onInitComponent() override; + void onConnectComponent() override; + void onDisconnectComponent() override; + + // QPointer<QDialog> getConfigDialog(QWidget* parent) override; + // void configured() override; + + private slots: + void on_pushButtonLayerClear_clicked(); + void on_pushButtonPoseDelete_clicked(); + void on_pushButtonArrowDelete_clicked(); + void updateArrow(); + void updatePose(); + + private: + /** + * Widget Form + */ + Ui::DebugDrawerGuiPluginWidget _ui; + + std::string _layerName; + + std::string _debugDrawerTopicName{"DebugDrawerUpdates"}; + DebugDrawerHelper _debugDrawer; + + QPointer<SimpleConfigDialog> _dialog; + + }; +} + +