diff --git a/etc/doxygen/images/GraphVisualizerGuiPlugin_ConfigDialog.png b/etc/doxygen/images/GraphVisualizerGuiPlugin_ConfigDialog.png deleted file mode 100644 index b00ed68c4b172381e138e94c7a75a86290d59fb6..0000000000000000000000000000000000000000 Binary files a/etc/doxygen/images/GraphVisualizerGuiPlugin_ConfigDialog.png and /dev/null differ diff --git a/etc/doxygen/images/GraphVisualizerGuiPlugin_Simulation.png b/etc/doxygen/images/GraphVisualizerGuiPlugin_Simulation.png deleted file mode 100644 index ad613cc6cb56f8556b3763ce4a50e80b8c87e32a..0000000000000000000000000000000000000000 Binary files a/etc/doxygen/images/GraphVisualizerGuiPlugin_Simulation.png and /dev/null differ diff --git a/etc/doxygen/images/GraphVisualizerGuiPlugin_Widget.png b/etc/doxygen/images/GraphVisualizerGuiPlugin_Widget.png deleted file mode 100644 index 8cc1f294caa29fed83d6f96ee5d71605991a0ada..0000000000000000000000000000000000000000 Binary files a/etc/doxygen/images/GraphVisualizerGuiPlugin_Widget.png and /dev/null differ diff --git a/source/RobotAPI/gui_plugins/CMakeLists.txt b/source/RobotAPI/gui_plugins/CMakeLists.txt index 219a7fccf138d15c2514f367e035a72326d0d867..93cb2fb67768f892662169290260168aae688f09 100644 --- a/source/RobotAPI/gui_plugins/CMakeLists.txt +++ b/source/RobotAPI/gui_plugins/CMakeLists.txt @@ -5,8 +5,6 @@ add_subdirectory(PlatformUnitPlugin) add_subdirectory(SensorActorWidgetsPlugin) add_subdirectory(HapticUnitPlugin) -add_subdirectory(GraphVisualizerPlugin) - #add_subdirectory(ObjectExaminerPlugin) diff --git a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/CMakeLists.txt b/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/CMakeLists.txt deleted file mode 100644 index 5b4469978937e06ae9082b5f38a6e8d926322d53..0000000000000000000000000000000000000000 --- a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -armarx_set_target("GraphVisualizer") - -find_package(Qt4 COMPONENTS QtCore QtGui QUIET) -armarx_build_if(QT_FOUND "Qt not available") - - -find_package(Eigen3 QUIET) -armarx_build_if(Eigen3_FOUND "Eigen3 not available") - -find_package(Simox QUIET) -armarx_build_if(Simox_FOUND "Simox not available") - -#find_package(ArmarXGui QUIET) -#armarx_build_if(ArmarXGui_FOUND "ArmarXGui not available") - -if (Eigen3_FOUND AND Simox_FOUND) - include_directories( - ${Eigen3_INCLUDE_DIR} - ${Simox_INCLUDE_DIRS} - ) -endif() - - -include(${QT_USE_FILE}) - -include(${ArmarXGui_CMAKE_DIR}/ArmarXGui.cmake) - -file(GLOB SOURCES - GraphVisualizerGuiPlugin.cpp - GraphVisualizerConfigDialog.cpp -) -file(GLOB HEADERS - GraphVisualizerGuiPlugin.h - GraphVisualizerConfigDialog.h -) - -set(GUI_MOC_HDRS - GraphVisualizerGuiPlugin.h - GraphVisualizerConfigDialog.h -) - -set(GUI_UIS - GraphVisualizerGuiPlugin.ui - GraphVisualizerConfigDialog.ui -) - -set(COMPONENT_LIBS RobotAPIUnits ArmarXInterfaces ${Simox_LIBRARIES} ${QT_LIBRARIES}) - -set(LIB_VERSION 0.1.0) -set(LIB_SOVERSION 0) - -if (ArmarXGui_FOUND) - armarx_gui_library(GraphVisualizertGuiPlugin "${SOURCES}" "${GUI_MOC_HDRS}" "${GUI_UIS}" "" "${COMPONENT_LIBS}" "${LIB_VERSION}" "${LIB_SOVERSION}") -endif() diff --git a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerConfigDialog.cpp b/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerConfigDialog.cpp deleted file mode 100644 index 36735d38c44f11eedbe0c209938c655fbd7790fb..0000000000000000000000000000000000000000 --- a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerConfigDialog.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "GraphVisualizerConfigDialog.h" -#include "ui_GraphVisualizerConfigDialog.h" - -armarx::GraphVisualizerConfigDialog::GraphVisualizerConfigDialog(QWidget *parent): - QDialog(parent), - ui{new Ui::GraphVisualizerConfigDialog} -{ - ui->setupUi(this); -} - -armarx::GraphVisualizerConfigDialog::~GraphVisualizerConfigDialog() -{ - delete ui; -} diff --git a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerConfigDialog.h b/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerConfigDialog.h deleted file mode 100644 index 52edaca411e7259b4539b9bd7e8cd86545cae20a..0000000000000000000000000000000000000000 --- a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerConfigDialog.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of ArmarX. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * 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 Lesser 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 ArmarX::RobotAPI - * @author Raphael Grimm <ufdrv at student dot kit dot edu> - * @date 2014 - * @copyright http://www.gnu.org/licenses/gpl.txt - * GNU General Public License - */ - -#ifndef ARMARXGUI_PLUGINS_GRAPHVISUALIZERCONFIGDIALOG_H -#define ARMARXGUI_PLUGINS_GRAPHVISUALIZERCONFIGDIALOG_H - -#include <QDialog> - -namespace Ui { - class GraphVisualizerConfigDialog; -} - -namespace armarx -{ - class GraphVisualizerConfigDialog : public QDialog - { - Q_OBJECT - - public: - explicit GraphVisualizerConfigDialog(QWidget *parent = nullptr); - ~GraphVisualizerConfigDialog(); - - private: - Ui::GraphVisualizerConfigDialog *ui; - - friend class GraphVisualizerWidget; - }; -} -#endif // GRAPHVISUALIZERCONFIGDIALOG_H diff --git a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerConfigDialog.ui b/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerConfigDialog.ui deleted file mode 100644 index 86617a6529e9e660aeeaf82100232c4eb2b11c67..0000000000000000000000000000000000000000 --- a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerConfigDialog.ui +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>GraphVisualizerConfigDialog</class> - <widget class="QDialog" name="GraphVisualizerConfigDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>651</width> - <height>105</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::AllNonFixedFieldsGrow</enum> - </property> - <item row="1" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Debug drawer</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="editDebugDrawerProxyName"/> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="editDebugDrawerLayerName"/> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Layer name</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>GraphVisualizerConfigDialog</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>GraphVisualizerConfigDialog</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/GraphVisualizerPlugin/GraphVisualizerGuiPlugin.cpp b/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerGuiPlugin.cpp deleted file mode 100644 index 0339b3df0c7984f604084456b2220681e1e46d3a..0000000000000000000000000000000000000000 --- a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerGuiPlugin.cpp +++ /dev/null @@ -1,610 +0,0 @@ -#include "GraphVisualizerGuiPlugin.h" -#include "GraphVisualizerConfigDialog.h" -#include "ui_GraphVisualizerConfigDialog.h" - -//armar -#include <Core/core/system/ArmarXDataPath.h> - -// Qt headers -#include <Qt> -#include <QtGlobal> -#include <QPushButton> -#include <QLabel> -#include <QLineEdit> -#include <QHBoxLayout> - -//std -#include <memory> -#include <sstream> -#include <unordered_set> - -//boost -#include <boost/current_function.hpp> - -using namespace armarx; - -using namespace VirtualRobot; - -//static values and helper functions - -/** - * @brief The default width of lines drawn onto the debug layer and scene. - */ -static const ::Ice::Float LINE_WIDTH_DEFAULT =5; -/** - * @brief The width of selected lines drawn onto the debug layer and scene. - */ -static const ::Ice::Float LINE_WIDTH_SELECTED=10; - -/** - * @brief The default color of lines drawn onto the debug layer and scene. - */ -static const ::armarx::DrawColor COLOR_DEFAULT={0.5f, 0.5f, 1.f,1.f}; -/** - * @brief The color of highlighted lines drawn onto the debug layer and scene. - */ -static const ::armarx::DrawColor COLOR_HIGHLIGHT={0.5f,1.f,0.5f,1.f}; - - -/** - * @brief The scale factor for elements drawn onto the scene. - */ -static const float SCENE_SCALE_FACTOR=2; -/** - * @brief The scale factor for nodes drawn onto the scene. - */ -static const float SCENE_NODES_SCALE_FACTOR=3*SCENE_SCALE_FACTOR; -/** - * @brief The scale factor for edges drawn onto the scene. - */ -static const float SCENE_LINE_SCALE_FACTOR=SCENE_SCALE_FACTOR; - -/** - * @brief The increment used when a rotation button is pressed. - * - * A positive rotation is counter clockwise. - * This value should be positive. - * - * rotation buttons: GraphVisualizerWidget::ui.buttonRotateClock and - * GraphVisualizerWidget::ui.buttonRotateCounterClock - */ -static const float VIEW_ROTATE_STEP_SIZE_CC=45; - -/** - * @brief Returns the name used on the debug layer. - * @param edge The edge. - * @return The name used on the debug layer. - */ -inline std::string iceName(const GraphVisualizerWidget::EdgeId& edge) -{ - std::stringstream s; - s<<"edge_"<<edge.first<<"_"<<edge.second; - return s.str(); -} - -/** - * @brief iceName Returns the name used on the debug layer. - * @param nodeName The node. - * @return The name used on the debug layer. - */ -inline std::string iceName(const GraphVisualizerWidget::NodeId& nodeName) -{ - return nodeName; -} - -//gui plugin -GraphVisualizerGuiPlugin::GraphVisualizerGuiPlugin() -{ - addWidget<GraphVisualizerWidget>(); -} - -//widget - -GraphVisualizerWidget::GraphVisualizerWidget() : - debugDrawerTopicName{"DebugDrawerUpdates"}, - viewAngle{0}, - debugDrawerLayerName{"DebugDrawerUpdates_Graph"} -{ - // init gui - ui.setupUi(getWidget()); - //add scene - std::unique_ptr<QGraphicsScene> scenePtr{new QGraphicsScene}; - scene=scenePtr.get(); - ui.graphicsViewGraph->setScene(scenePtr.release()); - //transform view - transformView(); -} - - -void GraphVisualizerWidget::onInitComponent() -{ - usingTopic(debugDrawerTopicName); -} - -void GraphVisualizerWidget::onConnectComponent() -{ - debugDrawer = getTopic<DebugDrawerInterfacePrx>(debugDrawerTopicName); - //todo remove test function - QObject::connect(ui.b,SIGNAL(clicked ()),this,SLOT(draw())); - - //tables - QObject::connect(ui.tableWidgetNodes,SIGNAL(cellDoubleClicked (int,int)),this,SLOT(nodeTableDoubleClicked(int,int))); - QObject::connect(ui.tableWidgetEdges,SIGNAL(cellDoubleClicked (int,int)),this,SLOT(edgeTableDoubleClicked(int,int))); - //zoom - QObject::connect(ui.viewZoomFactor,SIGNAL(valueChanged (double)),this,SLOT(transformView())); - //rota - QObject::connect(ui.buttonRotateClock,SIGNAL(clicked()),this,SLOT(viewRotatedClock())); - QObject::connect(ui.buttonRotateCounterClock,SIGNAL(clicked()),this,SLOT(viewRotatedCounterClock())); - //redraw - QObject::connect(ui.buttonRedraw,SIGNAL(clicked()),this,SLOT(redraw())); - //auto adjust - QObject::connect(ui.buttonAutoAdjust,SIGNAL(clicked()),this,SLOT(adjustView())); -} - -void GraphVisualizerWidget::onExitComponent() -{ -} - -QPointer<QDialog> GraphVisualizerWidget::getConfigDialog(QWidget* parent) -{ - if(!dialog) - { - dialog = new GraphVisualizerConfigDialog(parent); - } - dialog->ui->editDebugDrawerProxyName->setText(QString::fromStdString(debugDrawerTopicName)); - dialog->ui->editDebugDrawerLayerName->setText(QString::fromStdString(debugDrawerLayerName)); - return qobject_cast<GraphVisualizerConfigDialog*>(dialog); -} - - void GraphVisualizerWidget::configured() - { - debugDrawerTopicName = dialog->ui->editDebugDrawerProxyName->text().toStdString(); - debugDrawerLayerName = dialog->ui->editDebugDrawerLayerName->text().toStdString(); - } - - -void GraphVisualizerWidget::loadSettings(QSettings *settings) -{ - debugDrawerTopicName = settings->value("debugDrawerTopicName", QString::fromStdString(debugDrawerTopicName)).toString().toStdString(); - debugDrawerLayerName = settings->value("debugDrawerLayerName", QString::fromStdString(debugDrawerLayerName)).toString().toStdString(); -} - -void GraphVisualizerWidget::saveSettings(QSettings *settings) -{ - settings->setValue("debugDrawerTopicName", QString::fromStdString(debugDrawerTopicName)); - settings->setValue("debugDrawerLayerName", QString::fromStdString(debugDrawerLayerName)); -} - - -void GraphVisualizerWidget::addEdge(const std::string& node1, const std::string& node2, const Ice::Current&) -{ - if(!hasNode(node1)) - { - ARMARX_WARNING<<"Edge: "<<node1<<", "<<node2<<" can't be created! Node "<<node1<<" does not exist."; - return; - } - if(!hasNode(node2)) - { - ARMARX_WARNING<<"Edge: "<<node1<<", "<<node2<<" can't be created! Node "<<node2<<" does not exist."; - return; - } - if(hasEdge(node1,node2)) - { - //nothing needs to be updated - ARMARX_VERBOSE<<"Edge: "<<node1<<", "<<node2<<" already existed."; - return; - } - auto edgeId =toEdge(node1,node2); - auto node1dat=nodes.at(node1); - auto node2dat=nodes.at(node2); - - //add - //table - int row=ui.tableWidgetEdges->rowCount(); - ui.tableWidgetEdges->setRowCount(row+1); - ui.tableWidgetEdges->setItem(row,0,new QTableWidgetItem{QString::fromStdString(node1)}); - ui.tableWidgetEdges->setItem(row,1,new QTableWidgetItem{QString::fromStdString(node2)}); - //debug layer will be done later - //scene - QGraphicsLineItem* graphicsItem= dynamic_cast<QGraphicsLineItem*>(new GraphVisualizerGraphicsLineItem{ - *this, edgeId, - node1dat.pos->x,-node1dat.pos->y, - node2dat.pos->x,-node2dat.pos->y - }); - //auto graphicsItem= scene->addLine(node1dat.pos->x,-node1dat.pos->y, - // node2dat.pos->x,-node2dat.pos->y); - scene->addItem(graphicsItem); - //setToolTip on graphicsItem does not work - dynamic_cast<QGraphicsItem*>(graphicsItem)->setToolTip(QString{"Edge:"}+QString::fromStdString(node1)+QString{" <-> "}+QString::fromStdString(node2)); - //data - EdgeData data{graphicsItem,row,false,false}; - edges[edgeId]=data; - - updateEdge(edgeId); -} - -void GraphVisualizerWidget::addNode(const ::armarx::FramedVector3BasePtr& node, const Ice::Current&) -{ - if(hasNode(node->frame)) - { - NodeData& oldNode=nodes.at(node->frame); - ARMARX_WARNING<<"Node: "<<node->frame<<" was overwritten! Old: " - <<oldNode.pos->x<<", " <<oldNode.pos->y<<", " <<oldNode.pos->z<<"| New: " - <<node->x<<", " <<node->y<<", " <<node->z - <<" [file: "<<__FILE__<<" | line: "<<__LINE__<<" | function: "<<__PRETTY_FUNCTION__<<"]"; - //update node data - //table - ui.tableWidgetNodes->setItem(oldNode.tableWidgetNodesIndex,1,new QTableWidgetItem{QString::number(node->x)}); - ui.tableWidgetNodes->setItem(oldNode.tableWidgetNodesIndex,2,new QTableWidgetItem{QString::number(node->y)}); - ui.tableWidgetNodes->setItem(oldNode.tableWidgetNodesIndex,3,new QTableWidgetItem{QString::number(node->z)}); - //data - ::armarx::Vector3Ptr pos{new ::armarx::Vector3{Eigen::Vector3f{node->x,node->y,node->z}}}; - oldNode.pos=pos; - //update connected edges - for(const auto& edge:edges) - { - if((edge.first.first==node->frame) || (edge.first.second==node->frame)) - { - updateEdge(edge.first); - } - } - } - else - { - //add&draw node - //table - int row=ui.tableWidgetNodes->rowCount(); - ui.tableWidgetNodes->setRowCount(row+1); - ui.tableWidgetNodes->setItem(row,0,new QTableWidgetItem{QString::fromStdString(node->frame)}); - ui.tableWidgetNodes->setItem(row,1,new QTableWidgetItem{QString::number(node->x)}); - ui.tableWidgetNodes->setItem(row,2,new QTableWidgetItem{QString::number(node->y)}); - ui.tableWidgetNodes->setItem(row,3,new QTableWidgetItem{QString::number(node->z)}); - //scene - QGraphicsEllipseItem* graphicsItem= dynamic_cast<QGraphicsEllipseItem*>(new GraphVisualizerGraphicsEllipseItem{ - *this, node->frame, - node->x,-node->y,0,0 - }); - //auto graphicsItem= scene->addEllipse(node->x,-node->y,0,0); - scene->addItem(graphicsItem); - //setToolTip on graphicsItem does not work - graphicsItem->setZValue(std::numeric_limits<qreal>::max()); - dynamic_cast<QGraphicsItem*>(graphicsItem)->setToolTip(QString{"Node:"}+QString::fromStdString(node->frame)); - - //data - ::armarx::Vector3Ptr pos{new ::armarx::Vector3{Eigen::Vector3f{node->x,node->y,node->z}}}; - NodeData data{pos, nullptr, graphicsItem, row,false,false}; - nodes[node->frame]=data; - } - updateNode(node->frame); -} - -void GraphVisualizerWidget::clearEdges(const Ice::Current&) -{ - for(auto& edge:edges) - { - //remove from graphics scene - scene->removeItem(edge.second.graphicsItem); - delete edge.second.graphicsItem; - //remove from debug layer - debugDrawer->removePoseVisu(debugDrawerLayerName,iceName(edge.first)); - } - //clear table widget - ui.tableWidgetEdges->clearContents(); - ui.tableWidgetEdges->setRowCount(0); - //clear data structures - edges.clear(); -} - -void GraphVisualizerWidget::clearGraph(const Ice::Current&) -{ - //remove from debug layer - for(auto& edge:edges) - { - debugDrawer->removeLineVisu(debugDrawerLayerName,iceName(edge.first)); - } - for(auto& node:nodes) - { - debugDrawer->removePoseVisu(debugDrawerLayerName,iceName(node.first)); - } - //clear scene - scene->clear(); - //clear table widgets - ui.tableWidgetEdges->clearContents(); - ui.tableWidgetEdges->setRowCount(0); - ui.tableWidgetNodes->clearContents(); - ui.tableWidgetNodes->setRowCount(0); - //clear data structures - - edges.clear(); - nodes.clear(); -} - -void GraphVisualizerWidget::resetHilight(const Ice::Current&) -{ - for(auto& edge:edges) - { - if(edge.second.highlighted) - { - edge.second.highlighted=false; - updateEdge(edge.first); - } - } - for(auto& node:nodes) - { - if(node.second.highlighted) - { - node.second.highlighted=false; - updateNode(node.first); - } - } -} - -void GraphVisualizerWidget::updateEdge(const EdgeId& id) -{ - const EdgeData& data = edges.at(id); - auto color= (data.highlighted)?COLOR_HIGHLIGHT:COLOR_DEFAULT; - QColor qColor; - qColor.setRedF(color.r); - qColor.setGreenF(color.g); - qColor.setBlueF(color.b); - - auto lineWidth=(data.selected)?LINE_WIDTH_SELECTED:LINE_WIDTH_DEFAULT; - - //debug layer - debugDrawer->setLineVisu(debugDrawerLayerName, - iceName(id), - nodes.at(id.first).pos, - nodes.at(id.second).pos, - lineWidth, - color); - //scene - QPen pen{qColor}; - pen.setWidthF(lineWidth*SCENE_LINE_SCALE_FACTOR); - data.graphicsItem->setPen(pen); - //table - QFont font{}; - font.setBold(data.selected); - ui.tableWidgetEdges->item(data.tableWidgetEdgesIndex,0)->setData(Qt::BackgroundRole,qColor); - ui.tableWidgetEdges->item(data.tableWidgetEdgesIndex,0)->setFont(font); - ui.tableWidgetEdges->item(data.tableWidgetEdgesIndex,1)->setData(Qt::BackgroundRole,qColor); - ui.tableWidgetEdges->item(data.tableWidgetEdgesIndex,1)->setFont(font); - -} - -void GraphVisualizerWidget::updateNode(const NodeId& id) -{ - NodeData& data=nodes.at(id); - auto color= (data.highlighted)?COLOR_HIGHLIGHT:COLOR_DEFAULT; - QColor qColor; - qColor.setRedF(color.r); - qColor.setGreenF(color.g); - qColor.setBlueF(color.b); - - auto lineWidth=(data.selected)?LINE_WIDTH_SELECTED:LINE_WIDTH_DEFAULT; - - //debug layer - const Eigen::Vector3f eigPos{data.pos->x,data.pos->y,data.pos->z}; - data.pose = ::armarx::PoseBasePtr{new ::armarx::Pose{Eigen::Matrix3f::Identity(),eigPos}}; - debugDrawer->setScaledPoseVisu(debugDrawerLayerName,iceName(id),data.pose,lineWidth/2); - - //scene - data.graphicsItem->setPen(QPen{qColor}); - data.graphicsItem->setBrush(QBrush{qColor}); - data.graphicsItem->setRect(data.pos->x-lineWidth*SCENE_NODES_SCALE_FACTOR/2, - -data.pos->y-lineWidth*SCENE_NODES_SCALE_FACTOR/2, - lineWidth*SCENE_NODES_SCALE_FACTOR, - lineWidth*SCENE_NODES_SCALE_FACTOR); - //table - QFont font{}; - font.setBold(data.selected); - ui.tableWidgetNodes->item(data.tableWidgetNodesIndex,0)->setData(Qt::BackgroundRole,qColor); - ui.tableWidgetNodes->item(data.tableWidgetNodesIndex,0)->setFont(font); - ui.tableWidgetNodes->item(data.tableWidgetNodesIndex,1)->setData(Qt::BackgroundRole,qColor); - ui.tableWidgetNodes->item(data.tableWidgetNodesIndex,1)->setFont(font); - ui.tableWidgetNodes->item(data.tableWidgetNodesIndex,2)->setData(Qt::BackgroundRole,qColor); - ui.tableWidgetNodes->item(data.tableWidgetNodesIndex,2)->setFont(font); - ui.tableWidgetNodes->item(data.tableWidgetNodesIndex,3)->setData(Qt::BackgroundRole,qColor); - ui.tableWidgetNodes->item(data.tableWidgetNodesIndex,3)->setFont(font); -} - -void GraphVisualizerWidget::highlightEdge(const std::string& node1, const std::string& node2, bool highlighted, const Ice::Current&) -{ - if(!hasEdge(node1,node2)) - { - ARMARX_WARNING<<"No edge for: "<<node1<<" and "<<node2<<" [file: "<<__FILE__<<" | line: "<<__LINE__<<" | function: "<<__PRETTY_FUNCTION__<<"]"; - return; - } - EdgeId edge = toEdge(node1,node2); - if(edges.at(edge).highlighted!=highlighted) - { - edges.at(edge).highlighted=highlighted; - updateEdge(edge); - } -} - -void GraphVisualizerWidget::highlightNode(const std::string& name, bool highlighted, const Ice::Current&) -{ - if(!hasNode(name)) - { - ARMARX_WARNING<<"No node: "<<name<<" [pushBfile: "<<__FILE__<<" | line: "<<__LINE__<<" | function: "<<__PRETTY_FUNCTION__<<"]"; - return; - } - if(nodes.at(name).highlighted!=highlighted) - { - nodes.at(name).highlighted=highlighted; - updateNode(name); - } -} - - -void GraphVisualizerWidget::nodeTableDoubleClicked(int row, int) -{ - nodeDoubleClicked(ui.tableWidgetNodes->item(row,0)->text().toStdString()); -} - -void GraphVisualizerWidget::edgeTableDoubleClicked(int row, int) -{ - edgeDoubleClicked(toEdge( - ui.tableWidgetEdges->item(row,0)->text().toStdString(), - ui.tableWidgetEdges->item(row,1)->text().toStdString() - )); -} - -void GraphVisualizerWidget::nodeDoubleClicked(NodeId id) -{ - nodes.at(id).selected^=true; - updateNode(id); -} - -void GraphVisualizerWidget::edgeDoubleClicked(EdgeId id) -{ - edges.at(id).selected^=true; - updateEdge(id); -} - -void GraphVisualizerWidget::redraw(const Ice::Current&) -{ - for(const auto& edge:edges) - { - auto color =(edge.second.highlighted)?COLOR_HIGHLIGHT :COLOR_DEFAULT; - auto lineWidth=(edge.second.selected )?LINE_WIDTH_SELECTED:LINE_WIDTH_DEFAULT; - - //debug layer - debugDrawer->setLineVisu(debugDrawerLayerName, - iceName(edge.first), - nodes.at(edge.first.first).pos, - nodes.at(edge.first.second).pos, - lineWidth, - color); - } - for(const auto& node:nodes) - { - debugDrawer->setPoseVisu(debugDrawerLayerName,iceName(node.first),node.second.pose); - } -} - -void GraphVisualizerWidget::transformView() -{ - double d=ui.viewZoomFactor->value(); - ui.graphicsViewGraph->setTransform(QTransform::fromScale(d,d).rotate(viewAngle)); -} - -void GraphVisualizerWidget::viewRotatedClock() -{ - viewAngle= std::fmod(viewAngle+VIEW_ROTATE_STEP_SIZE_CC,360); - transformView(); -} - -void GraphVisualizerWidget::viewRotatedCounterClock() -{ - viewAngle= std::fmod(viewAngle+360-VIEW_ROTATE_STEP_SIZE_CC,360); - transformView(); -} - -void GraphVisualizerWidget::adjustView() -{ - float maxX=std::numeric_limits<float>::min(); - float minX=std::numeric_limits<float>::max(); - float maxY=std::numeric_limits<float>::min(); - float minY=std::numeric_limits<float>::max(); - //search bounding box - for(const auto& node:nodes) - { - maxX =(maxX<node.second.pos->x)?node.second.pos->x:maxX; - minX =(minX>node.second.pos->x)?node.second.pos->x:minX; - maxY =(maxY<node.second.pos->y)?node.second.pos->y:maxY; - minY =(minY>node.second.pos->y)?node.second.pos->y:minY; - } - auto deltaX=maxX-minX;//>=0 - auto deltaY=maxY-minY;//>=0 - - //compare ratio of graph and view. if both horizontal (vertical) ->rotate to 0 or 180 (90,270) - if(std::signbit(deltaX/deltaY -1) == std::signbit(ui.graphicsViewGraph->width()/ui.graphicsViewGraph->height() -1)) - { - //same => rotate to 0 or 180 - viewAngle= (viewAngle<std::abs(180-viewAngle))?0:180; - //set zoom => update - ui.viewZoomFactor->setValue(std::min(ui.graphicsViewGraph->width()/deltaX, - ui.graphicsViewGraph->height()/deltaY)*0.9); - } - else - { - //different rotate to 90 or 270 - viewAngle= (std::abs(90-viewAngle)<std::abs(270-viewAngle))?90:270; - //set zoom => update - ui.viewZoomFactor->setValue(std::min(ui.graphicsViewGraph->width()/deltaY, - ui.graphicsViewGraph->height()/deltaX)*0.9); - } - -} - - - -void GraphVisualizerWidget::draw() -{ - clearGraph(); - - static ::armarx::FramedVector3Ptr tableS {new ::armarx::FramedVector3{Eigen::Vector3f{3400.f,7300.f,1000.f}, "table" , "Armar3"}}; - static ::armarx::FramedVector3Ptr fridge {new ::armarx::FramedVector3{Eigen::Vector3f{2150.f,7750.f,1000.f}, "fridge" , "Armar3"}}; - static ::armarx::FramedVector3Ptr sink {new ::armarx::FramedVector3{Eigen::Vector3f{2500.f,9700.f,1000.f}, "sink" , "Armar3"}}; - static ::armarx::FramedVector3Ptr hub2fst{new ::armarx::FramedVector3{Eigen::Vector3f{3750.f,5150.f,5000.f}, "hub2" , "Armar3"}}; - static ::armarx::FramedVector3Ptr hub2snd{new ::armarx::FramedVector3{Eigen::Vector3f{3750.f,5150.f,1000.f}, "hub2" , "Armar3"}}; - static ::armarx::FramedVector3Ptr hub1 {new ::armarx::FramedVector3{Eigen::Vector3f{2900.f,8000.f,1000.f}, "hub1" , "Armar3"}}; - static ::armarx::FramedVector3Ptr hub3 {new ::armarx::FramedVector3{Eigen::Vector3f{3400.f,2200.f,1000.f}, "hub3" , "Armar3"}}; - static ::armarx::FramedVector3Ptr hub4 {new ::armarx::FramedVector3{Eigen::Vector3f{1900.f,3000.f,1000.f}, "hub4" , "Armar3"}}; - static ::armarx::FramedVector3Ptr counter{new ::armarx::FramedVector3{Eigen::Vector3f{1890.f,4050.f,1000.f}, "counter", "Armar3"}}; - - addNode(tableS); - addNode(fridge); - addNode(sink); - addNode(hub2fst); - addNode(hub1); - addNode(hub3); - addNode(hub4); - addNode(counter); - addEdge("hub1","hub2"); - addEdge("hub1","table"); - addEdge("hub1","sink"); - addEdge("hub1","fridge"); - addEdge("hub2","hub3"); - addEdge("hub3","hub4"); - addEdge("hub4","counter"); - - - highlightEdge("hub1","hub2"); - highlightNode("fridge"); - resetHilight(); - - highlightEdge("hub2","hub3"); - - highlightEdge("hub3","hub4"); - highlightEdge("hub3","hub4",false); - - highlightNode("table"); - highlightNode("counter"); - highlightNode("counter",false); - - addNode(hub2snd); - addEdge("hub2","hub3"); - /* - 3400,7300,1000,"table" - 2150,7750,1000,"fridge" - 2500,9700,1000,"sink" - 3750,5150,1000,"hub2" - 2900,8000,1000,"hub1" - 3400,2200,1000,"hub3" - 1900,3000,1000,"hub4" - 189graphicsItem0,4050,1000,"counter" - - - "hub1","hub2" - "hub1","table" - "hub1","sink" - "hub1","fridge" - "hub2","hub3" - "hub3","hub4" - "hub4","counter" - */ -} - -Q_EXPORT_PLUGIN2(armar3_gui_GraphVisualizerGuiPlugin, GraphVisualizerGuiPlugin) diff --git a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerGuiPlugin.h b/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerGuiPlugin.h deleted file mode 100644 index 8ec6b4e0b17abf1e429f86035133297fd6697568..0000000000000000000000000000000000000000 --- a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerGuiPlugin.h +++ /dev/null @@ -1,541 +0,0 @@ -/* - * This file is part of ArmarX. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * 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 Lesser 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 ArmarX::RobotAPI - * @author Raphael Grimm <ufdrv at student dot kit dot edu> - * @date 2014 - * @copyright http://www.gnu.org/licenses/gpl.txt - * GNU General Public License - */ - -#ifndef ARMARXGUI_PLUGINS_GRAPHVISUALIZERWIDGET_H -#define ARMARXGUI_PLUGINS_GRAPHVISUALIZERWIDGET_H - -// ArmarX -#include <Core/core/Component.h> -#include <Gui/ArmarXGuiLib/ArmarXGuiPlugin.h> -#include <Gui/ArmarXGuiLib/ArmarXComponentWidgetController.h> - -#include <RobotAPI/interface/visualization/DebugDrawerInterface.h> -#include <RobotAPI/interface/visualization/GraphVisualizerInterface.h> - - -#include <RobotAPI/libraries/robotstate/remote/ArmarPose.h> - -//qt -#include <QtGui/QMainWindow> -#include <QDialog> -#include <QGraphicsScene> -#include <QGraphicsLineItem> -#include <QGraphicsEllipseItem> - -//std -#include <string> -#include <map> -#include <vector> -#include <tuple> - -//boost - - -#include "ui_GraphVisualizerGuiPlugin.h" -#include "GraphVisualizerConfigDialog.h" - -namespace armarx -{ - class GraphVisualizerGraphicsEllipseItem; - class GraphVisualizerGraphicsLineItem; - - class GraphVisualizerConfigDialog; - - /** - * @brief A plugin used to visualize a undirected graph and draw it to a debug layer. - * @ingroup ArmarXGuiPlugins - * @see GraphVisualizerWidget - * - * This plugin implements the ice interface GraphVisualizerInterface and therefore - * can be provided with a undirected graph. - * - * The graph is drawn to a debug layer and a scene located in the plugin. - * The plugin has tables containing information about the nodes and edges. - * Nodes on the debug layer are visualized as coordinate systems. - * Nodes on the scene are visualized as circles. - * Edges on debug layer and scene are visualized with lines. - * - * Nodes can be added with and - * @code{.cpp} - * addNode(const ::armarx::FramedVector3BasePtr& p) - * @endcode - * are identified with the string stored in p. - * - * Edges can be added with - * @code{.cpp} - * addEdge(const ::std::string& fst, const ::std::string& snd) - * @endcode - * and are identified with {fst,snd}. - * fst and snd have to be the names of already existing nodes. - * The order of fst and snd does not matter. - * - * The existence can be checked with following methodes: - * @code{.cpp} - * hasNode(const ::std::string& name) - * hasEdge(const ::std::string& fst, const ::std::string& snd) - * @endcode - * - * All edges (the whole graph) can be deleted with: - * @code{.cpp} - * clearEdges() - * clearGraph() - * @endcode - * - * If the graph has to be redrawn to the debug layer use - * @code{.cpp} - * redraw() - * @endcode - * - * Edges and nodes have four states: {selected, not selected}X{highlighted, not highlighted} - * - * Selection affects the width of lines and the size of nodes. Selected lines are thicker and nodes have an increased size. - * Selection can be toggled by double clicking the element in the table or the scene. - * - * Highlighting affects the color. If not highlighted elements are blue. If highlighted elements are green. - * (nodes drawn on a debug layer cant change color) - * The highlight can be set and cleared with the functions - * @code{.cpp} - * highlightNode(const ::std::string& name, bool highlighted) - * highlightEdge(const ::std::string& fst, const ::std::string& snd, bool highlighted) - * resetHilight() - * @endcode - * - * - * The graph used in the following examples can be created with following code: - * @code{.cpp} - * static ::armarx::FramedVector3Ptr table {new ::armarx::FramedVector3{Eigen::Vector3f{3400.f,7300.f,1000.f}, "table" }}; - * static ::armarx::FramedVector3Ptr fridge {new ::armarx::FramedVector3{Eigen::Vector3f{2150.f,7750.f,1000.f}, "fridge" }}; - * static ::armarx::FramedVector3Ptr sink {new ::armarx::FramedVector3{Eigen::Vector3f{2500.f,9700.f,1000.f}, "sink" }}; - * static ::armarx::FramedVector3Ptr hub2 {new ::armarx::FramedVector3{Eigen::Vector3f{3750.f,5150.f,5000.f}, "hub2" }}; - * static ::armarx::FramedVector3Ptr hub1 {new ::armarx::FramedVector3{Eigen::Vector3f{2900.f,8000.f,1000.f}, "hub1" }}; - * static ::armarx::FramedVector3Ptr hub3 {new ::armarx::FramedVector3{Eigen::Vector3f{3400.f,2200.f,1000.f}, "hub3" }}; - * static ::armarx::FramedVector3Ptr hub4 {new ::armarx::FramedVector3{Eigen::Vector3f{1900.f,3000.f,1000.f}, "hub4" }}; - * static ::armarx::FramedVector3Ptr counter{new ::armarx::FramedVector3{Eigen::Vector3f{1890.f,4050.f,1000.f}, "counter"}}; - * - * //prx is a proxy passing the commands to the plugin - * //add nodes - * prx->addNode(table); - * prx->addNode(fridge); - * prx->addNode(sink); - * prx->addNode(hub2); - * prx->addNode(hub1); - * prx->addNode(hub3); - * prx->addNode(hub4); - * prx->addNode(counter); - * - * //add edges - * prx->addEdge("hub1","hub2"); - * prx->addEdge("hub1","table"); - * prx->addEdge("hub1","sink"); - * prx->addEdge("hub1","fridge"); - * prx->addEdge("hub2","hub3"); - * prx->addEdge("hub3","hub4"); - * prx->addEdge("hub4","counter"); - * - * //highlight a node and an edge - * prx->highlightEdge("hub2","hub3"); - * prx->highlightNode("table"); - * @endcode - * - * @image html GraphVisualizerGuiPlugin_ConfigDialog.png "The config dialog for the plugin." width=300px - * You can set the topic of the used debug drawer and the used debug layer. - * - * @image html GraphVisualizerGuiPlugin_Simulation.png "The graph drawn to the debug layer." width=300px - * @image html GraphVisualizerGuiPlugin_Widget.png "The plugin's ui." width=300px - * - * The ui has 5 sections - * -# Display options for the graph. - * - a. Rotate the graph clockwise - * - b. Rotate the graph counter clockwise - * - c. Zoom factor for the graph - * - d. Rotate and zoom the graph to display most of it. (The rotation is a multiple of pi/4) - * -# Is the scene containing the graph - * -# The table of nodes. - * -# The table of edges. - * -# Triggers a repaint for the debug layer. - * - * - A) Shows a highlighted and selected node - * - B) Shows a selected edge - * - C) Shows a highlighted edge - * - D) Shows a node. (no highlight or selection) - * - E) Shows the tool tip of an edge. - */ - class GraphVisualizerGuiPlugin : - public ArmarXGuiPlugin - { - public: - GraphVisualizerGuiPlugin(); - QString getPluginName() - { - return "GraphVisualizerGuiPlugin"; - } - }; - - /** - * @brief A widget used to visualize a undirected graph and draw it to a debug layer. - * @ingroup ArmarXGuiPlugins - * @see GraphVisualizerGuiPlugin - */ - class GraphVisualizerWidget : - public ArmarXComponentWidgetController, - public GraphVisualizerInterface - { - Q_OBJECT - public: - - /** - * @brief The type of node ids. (This type implies the node exists) - */ - typedef const std::string NodeId; - - /** - * @brief The type of edge ids. (This type implies the edge exists) - */ - typedef const std::pair<const std::string,const std::string> EdgeId; - - - GraphVisualizerWidget(); - ~GraphVisualizerWidget() - { - } - - // inherited from Component - /** - * @see - */ - virtual void onInitComponent(); - virtual void onConnectComponent(); - virtual void onExitComponent(); - - // inherited of ArmarXWidget - virtual QString getWidgetName() const - { - return "RobotControl.GraphVisualizerGUI"; - } - - QPointer<QDialog> getConfigDialog(QWidget* parent = 0); - virtual void loadSettings(QSettings * settings); - virtual void saveSettings(QSettings * settings); - void configured(); - - - - // slice interface implementation - virtual bool hasEdge(const std::string& node1, const std::string& node2, const Ice::Current& = ::Ice::Current()) - { - return (edges.find(toEdge(node1,node2)) != edges.end()); - } - - virtual bool hasNode(const std::string& name, const Ice::Current& = ::Ice::Current()) - { - return (nodes.find(name) != nodes.end()); - } - - public slots: - // slice interface implementation - virtual void addEdge(const std::string& node1, const std::string& node2, const Ice::Current& = ::Ice::Current()); - virtual void addNode(const ::armarx::FramedVector3BasePtr& node, const Ice::Current& = ::Ice::Current()); - - virtual void highlightEdge(const std::string& node1, const std::string& node2, bool highlighted = true, const Ice::Current& = ::Ice::Current()); - - virtual void highlightNode(const std::string &name, bool highlighted = true, const Ice::Current& = ::Ice::Current()); - - virtual void clearEdges(const Ice::Current& = ::Ice::Current()); - virtual void clearGraph(const Ice::Current& = ::Ice::Current()); - - virtual void resetHilight(const Ice::Current& = ::Ice::Current()); - - virtual void redraw(const Ice::Current& = ::Ice::Current()); - - protected: - /** - * @brief Contains the ui. - */ - Ui::GraphVisualizerGuiPlugin ui; - - private slots: - /** - * @brief draws a test graph - */ - void draw(); - - /** - * @brief Toggles the double clicked node's selection state. - * @param row Identifies the node. - */ - void nodeTableDoubleClicked(int row, int); - /** - * @brief Toggles the double clicked edge's selection state. - * @param row Identifies the edge. - */ - void edgeTableDoubleClicked(int row, int); - - /** - * @brief Toggles the double clicked node's selection state. - * @param id Identifies the node. - */ - void nodeDoubleClicked(NodeId id); - - /** - * @brief Toggles the double clicked edge's selection state. - * @param id Identifies the edge. - */ - void edgeDoubleClicked(EdgeId id); - - /** - * @brief Rotates the view clockwise. - * - * Stepsize set by VIEW_ROTATE_STEP_SIZE_CC in GraphVisualizerGuiPlugin.cpp - */ - void viewRotatedClock(); - - /** - * @brief Rotates the view counter clockwise. - * - * Stepsize set by VIEW_ROTATE_STEP_SIZE_CC in GraphVisualizerGuiPlugin.cpp - */ - void viewRotatedCounterClock(); - - /** - * @brief Applies the current transforamtion to the view. - */ - void transformView(); - - /** - * @brief Adjusts the view's zoom and rotation to display most of the graph. - */ - void adjustView(); - - private: - /** - * @brief The NodeData struct holds data required for the node. - * The name is stored in the key used in the map nodes. - */ - struct NodeData - { - /** - * @brief The node's position. Used by edges drawn to debugDrawer. - */ - ::armarx::Vector3Ptr pos; - - /** - * @brief The pose drawn to debugDrawer. - */ - ::armarx::PoseBasePtr pose; - - /** - * @brief The ellipse in the scene. - */ - QGraphicsEllipseItem* graphicsItem; - - /** - * @brief The row in the table tableWidgetNodes. - */ - int tableWidgetNodesIndex; - - /** - * @brief Whether the node is selected. - */ - bool selected; - /** - * @brief Whether the node is highlighted. - */ - bool highlighted; - }; - - /** - * @brief The EdgeData struct holds data required for the edge. - * The name is stored in the key used in the map edges. - */ - struct EdgeData - { - /** - * @brief The line in the scene. - */ - QGraphicsLineItem* graphicsItem; - /** - * @brief The row in the table tableWidgetEdges. - */ - int tableWidgetEdgesIndex; - - /** - * @brief Whether the edge is selected. - */ - bool selected; - /** - * @brief Whether the edge is highlighted. - */ - bool highlighted; - }; - - - /** - * @brief Returns the EdgeId corresponding to two nodes. - * @param node1 First node. - * @param node2 Second node. - * @return The EdgeId corresponding to two nodes. - */ - static EdgeId toEdge(const std::string& node1,const std::string&node2) - { - return (node1<node2)?EdgeId{node1,node2}:EdgeId(node2,node1); - } - - /** - * @brief Updates an edge. - * @param The edge to update. - */ - void updateEdge(const EdgeId& id); - - /** - * @brief Updates a node. - * @param The node to update. - */ - void updateNode(const NodeId& id); - - /** - * @brief The topic name used by debugDrawer. - */ - std::string debugDrawerTopicName; - - /** - * @brief Used to draw onto debug layers. - */ - DebugDrawerInterfacePrx debugDrawer; - - /** - * @brief The config dialog. - */ - QPointer<GraphVisualizerConfigDialog> dialog; - - /** - * @brief The scene displayed in the widget. - * - * For y coordinates -pos->y is used to mirror the scene on the y axis. - * If pos->y would be used the graph displayed in the scene would not - * match the graph drawn to the debug layer. - */ - QPointer<QGraphicsScene> scene; - - /** - * @brief The nodes. - */ - std::map<std::string,NodeData> nodes; - - /** - * @brief The edges. - */ - std::map<EdgeId,EdgeData> edges; - - /** - * @brief The view's rotation angle. - */ - qreal viewAngle; - - /** - * @brief The layer to draw on. - */ - std::string debugDrawerLayerName; - - friend class GraphVisualizerGraphicsEllipseItem; - friend class GraphVisualizerGraphicsLineItem; - }; - /** - * @brief Boost shared pointer to a GraphVisualizerWidget. - */ - typedef boost::shared_ptr<GraphVisualizerWidget> GraphVisualizerGuiPluginPtr; - - - /** - * @brief Required to override the double click event. This is required to toggle the select state. - */ - class GraphVisualizerGraphicsEllipseItem: public QGraphicsEllipseItem - { - public: - typedef GraphVisualizerWidget::NodeId NodeId; - - GraphVisualizerGraphicsEllipseItem(GraphVisualizerWidget& visuWidget,NodeId name, qreal x, qreal y, qreal width, qreal height, QGraphicsItem * parent = nullptr): - QGraphicsEllipseItem{x,y,width,height,parent}, - id{name}, - parentVisuWidget(visuWidget) - { - } - - virtual ~GraphVisualizerGraphicsEllipseItem() - { - } - protected: - virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) - { - parentVisuWidget.nodeDoubleClicked(id); - } - private: - /** - * @brief Required to identify the element. - */ - const NodeId id; - - /** - * @brief Required to call nodeDoubleClicked on it. (This class is no QObject so it does not support signals) - */ - GraphVisualizerWidget& parentVisuWidget; - }; - - /** - * @brief Required to override the double click event. This is required to toggle the select state. - */ - class GraphVisualizerGraphicsLineItem: public QGraphicsLineItem - { - public: - typedef GraphVisualizerWidget::EdgeId EdgeId; - - GraphVisualizerGraphicsLineItem(GraphVisualizerWidget& visuWidget,EdgeId name, qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem * parent = 0 ): - QGraphicsLineItem{x1,y1,x2,y2,parent}, - id{name}, - parentVisuWidget(visuWidget) - { - } - - virtual ~GraphVisualizerGraphicsLineItem() - { - } - signals: - protected: - virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) - { - parentVisuWidget.edgeDoubleClicked(id); - } - private: - /** - * @brief Required to identify the element. - */ - const EdgeId id; - - /** - * @brief Required to call edgeDoubleClicked on it. (This class is no QObject so it does not support signals) - */ - GraphVisualizerWidget& parentVisuWidget; - }; -} - -#endif diff --git a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerGuiPlugin.ui b/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerGuiPlugin.ui deleted file mode 100644 index b4fd587173340d04216b560df4366c8979bdc178..0000000000000000000000000000000000000000 --- a/source/RobotAPI/gui_plugins/GraphVisualizerPlugin/GraphVisualizerGuiPlugin.ui +++ /dev/null @@ -1,207 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>GraphVisualizerGuiPlugin</class> - <widget class="QWidget" name="GraphVisualizerGuiPlugin"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>429</width> - <height>798</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="b"> - <property name="text"> - <string>add testgraph</string> - </property> - </widget> - </item> - <item> - <widget class="QFrame" name="graphFrame"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <widget class="QWidget" name="graphHead" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label_graph"> - <property name="text"> - <string>Graph</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> - <item> - <widget class="QToolButton" name="buttonRotateClock"> - <property name="text"> - <string>↻</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buttonRotateCounterClock"> - <property name="text"> - <string>↺</string> - </property> - </widget> - </item> - <item> - <widget class="Line" name="line_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_zoom"> - <property name="text"> - <string>Zoom</string> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="viewZoomFactor"> - <property name="decimals"> - <number>5</number> - </property> - <property name="singleStep"> - <double>0.001000000000000</double> - </property> - <property name="value"> - <double>0.100000000000000</double> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buttonAutoAdjust"> - <property name="text"> - <string>Auto</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGraphicsView" name="graphicsViewGraph"/> - </item> - </layout> - </widget> - </item> - <item> - <widget class="Line" name="line_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="tables" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_nodes"> - <item> - <widget class="QLabel" name="label_nodes"> - <property name="text"> - <string>Nodes</string> - </property> - </widget> - </item> - <item> - <widget class="QTableWidget" name="tableWidgetNodes"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - <column> - <property name="text"> - <string>Name</string> - </property> - </column> - <column> - <property name="text"> - <string>X</string> - </property> - </column> - <column> - <property name="text"> - <string>Y</string> - </property> - </column> - <column> - <property name="text"> - <string>Z</string> - </property> - </column> - </widget> - </item> - </layout> - </item> - <item> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_edges"> - <item> - <widget class="QLabel" name="label_edges"> - <property name="text"> - <string>Edges</string> - </property> - </widget> - </item> - <item> - <widget class="QTableWidget" name="tableWidgetEdges"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - <column> - <property name="text"> - <string>Node 1</string> - </property> - </column> - <column> - <property name="text"> - <string>Node 2</string> - </property> - </column> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QPushButton" name="buttonRedraw"> - <property name="text"> - <string>Repaint</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/source/RobotAPI/gui_plugins/HandUnitPlugin/HandUnitGuiPlugin.h b/source/RobotAPI/gui_plugins/HandUnitPlugin/HandUnitGuiPlugin.h index c0500b3aef8a871533c82b6e211586fd1fd6e085..fe8b6243074cd4af6fda35768bf2adffc6a65047 100644 --- a/source/RobotAPI/gui_plugins/HandUnitPlugin/HandUnitGuiPlugin.h +++ b/source/RobotAPI/gui_plugins/HandUnitPlugin/HandUnitGuiPlugin.h @@ -64,7 +64,6 @@ namespace armarx /** \class HandUnitWidget \brief With this widget the HandUnit can be controlled. - \ingroup ArmarXGuiPlugins \see HandUnitGuiPlugin */ diff --git a/source/RobotAPI/gui_plugins/HapticUnitPlugin/HapticUnitGuiPlugin.h b/source/RobotAPI/gui_plugins/HapticUnitPlugin/HapticUnitGuiPlugin.h index 20c2919a0ca760f982253b23b9840bc502f24924..f8aaa11ea18c06bc7072f19257f764d78d83ff95 100644 --- a/source/RobotAPI/gui_plugins/HapticUnitPlugin/HapticUnitGuiPlugin.h +++ b/source/RobotAPI/gui_plugins/HapticUnitPlugin/HapticUnitGuiPlugin.h @@ -67,7 +67,6 @@ namespace armarx /** \class HapticUnitWidget \brief With this widget the HapticUnit can be controlled. - \ingroup ArmarXGuiPlugins \see HapticUnitGuiPlugin */ diff --git a/source/RobotAPI/gui_plugins/KinematicUnitPlugin/KinematicUnitGuiPlugin.h b/source/RobotAPI/gui_plugins/KinematicUnitPlugin/KinematicUnitGuiPlugin.h index fae37ae248a34d98a7085300702fc1cc4605c0fa..97e19ecf147297bec099ed8d04dc0177e988ae13 100644 --- a/source/RobotAPI/gui_plugins/KinematicUnitPlugin/KinematicUnitGuiPlugin.h +++ b/source/RobotAPI/gui_plugins/KinematicUnitPlugin/KinematicUnitGuiPlugin.h @@ -87,7 +87,6 @@ namespace armarx /** \class KinematicUnitWidget - \ingroup ArmarXGuiPlugins \see KinematicUnitGuiPlugin */ class KinematicUnitWidgetController : diff --git a/source/RobotAPI/gui_plugins/PlatformUnitPlugin/JoystickControlWidget.cpp b/source/RobotAPI/gui_plugins/PlatformUnitPlugin/JoystickControlWidget.cpp index 012939ed961b879745755dfc816bb3e137cb42b7..e48e65ffaa361935159f7b22f8511df849910b3e 100644 --- a/source/RobotAPI/gui_plugins/PlatformUnitPlugin/JoystickControlWidget.cpp +++ b/source/RobotAPI/gui_plugins/PlatformUnitPlugin/JoystickControlWidget.cpp @@ -61,6 +61,7 @@ namespace armarx void JoystickControlWidgetQGraphicsView::mouseReleaseEvent(QMouseEvent*) { emit positionChanged({0,0}); + emit released(); } JoystickControlWidget::JoystickControlWidget(bool useQuadrant3and4, QWidget *parent) : @@ -95,6 +96,7 @@ namespace armarx //connect connect(viewPtr.get(), SIGNAL(positionChanged(QPointF)), this, SLOT(setNibble(QPointF))); + connect(viewPtr.get(), SIGNAL(released()), this, SLOT(mouseReleased())); //set gui std::unique_ptr<QVBoxLayout> layout{new QVBoxLayout{}}; @@ -135,6 +137,12 @@ namespace armarx } } + void JoystickControlWidget::mouseReleased() + { + setNibble({0,0}); + emit released(); + } + void JoystickControlWidget::setNibble(QPointF pos) { if(onlyQuadrant2and1 && (pos.y()>0)) diff --git a/source/RobotAPI/gui_plugins/PlatformUnitPlugin/JoystickControlWidget.h b/source/RobotAPI/gui_plugins/PlatformUnitPlugin/JoystickControlWidget.h index 877795cbf12ffebfd1b69b80b8ddb668ac6767af..aed5a19c973c11500f12ce802dafa0651d29d680 100644 --- a/source/RobotAPI/gui_plugins/PlatformUnitPlugin/JoystickControlWidget.h +++ b/source/RobotAPI/gui_plugins/PlatformUnitPlugin/JoystickControlWidget.h @@ -75,6 +75,11 @@ namespace armarx * On mouse release (0;0) is send. */ void positionChanged(QPointF); + + /** + * @brief Emitted when the mouse was released. + */ + void released(); };//JoystickControlWidgetQGraphicsView /** @@ -158,6 +163,11 @@ namespace armarx */ void rotationChanged(double); + /** + * @brief Emitted when the nibble was released. + */ + void released(); + protected: virtual void resizeEvent(QResizeEvent * event); @@ -168,6 +178,12 @@ namespace armarx */ void setNibble(QPointF pos); + /** + * @brief Called when the nibble is released. + * Emits released() and sets the Position to 0. + */ + void mouseReleased(); + private: /** * @brief The view containing the scene. diff --git a/source/RobotAPI/gui_plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.cpp b/source/RobotAPI/gui_plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.cpp index 22387c044906d8340a29f5bdfcc27634633861f3..956cd94bed90f47fdcb568c6e4e07ca6a813bd19 100644 --- a/source/RobotAPI/gui_plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.cpp +++ b/source/RobotAPI/gui_plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.cpp @@ -104,6 +104,8 @@ void PlatformUnitWidget::connectSlots() { connect(ui.buttonMoveToPosition, SIGNAL(clicked()), this, SLOT(moveTo())); connect(&ctrlEvaluationTimer, SIGNAL(timeout()), this, SLOT(controlTimerTick())); + connect(speedCtrl,SIGNAL(released()), this, SLOT(stopPlatform())); + connect(rotaCtrl, SIGNAL(released()), this, SLOT(stopPlatform())); } void PlatformUnitWidget::moveTo() @@ -137,6 +139,11 @@ void PlatformUnitWidget::reportPlatformVelocity(::Ice::Float currentPlatformVelo } +void PlatformUnitWidget::stopPlatform() +{ + platformUnitProxy->moveRelative(0, 0, 0, 0, 0); +} + void PlatformUnitWidget::controlTimerTick() { //speed control cant be tested in the simulator: diff --git a/source/RobotAPI/gui_plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.h b/source/RobotAPI/gui_plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.h index 8290157e91447758e3808d010c81d8ae208dde68..c4db8b8a78d68e34c49037cf4e2e7d81d521f02c 100644 --- a/source/RobotAPI/gui_plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.h +++ b/source/RobotAPI/gui_plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.h @@ -51,6 +51,11 @@ namespace armarx \ingroup ArmarXGuiPlugins \see PlatformUnitWidget + + \image html PlatformUnitGuiPlugin_widgetpng.png "The plugin's ui." width=300px + -# The current position and rotation, fields to enter a new target and a button to set the platform in motion. + -# A joystick like control widget to move the platform. It has two speed level. The platform does not rotate to move in a direction. Up moves the platform forward. + -# A joystick like control widget to rotate the platform. */ class PlatformUnitGuiPlugin : public ArmarXGuiPlugin @@ -66,14 +71,8 @@ namespace armarx /** \class PlatformUnitWidget \brief With this widget the PlatformUnit can be controlled. - \ingroup ArmarXGuiPlugins \see PlatformUnitGuiPlugin - - \image html PlatformUnitGuiPlugin_widgetpng.png "The plugin's ui." width=300px - -# The current position and rotation, fields to enter a new target and a button to set the platform in motion. - -# A joystick like control widget to move the platform. It has two speed level. The platform does not rotate to move in a direction. Up moves the platform forward. - -# A joystick like control widget to rotate the platform. */ class PlatformUnitWidget : public ArmarXComponentWidgetController, @@ -116,8 +115,16 @@ namespace armarx Ui::PlatformUnitGuiPlugin ui; private slots: + /** + \brief Checks the joystick contol widgets speedCtrl and rotaCtrl and performs a move if necessary. + Activated when ctrlEvaluationTimer times out. + */ void controlTimerTick(); + /** + \brief Stops the platform + */ + void stopPlatform(); private: std::string platformUnitProxyName; std::string platformName; diff --git a/source/RobotAPI/gui_plugins/SensorActorWidgetsPlugin/ArmarXPlotter/ArmarXPlotter.h b/source/RobotAPI/gui_plugins/SensorActorWidgetsPlugin/ArmarXPlotter/ArmarXPlotter.h index 555c98923e94905cd1e9ccb53367f71d292cdce9..284446bf9e4938c163397584fd8f95ea0c2ce335 100644 --- a/source/RobotAPI/gui_plugins/SensorActorWidgetsPlugin/ArmarXPlotter/ArmarXPlotter.h +++ b/source/RobotAPI/gui_plugins/SensorActorWidgetsPlugin/ArmarXPlotter/ArmarXPlotter.h @@ -66,7 +66,6 @@ namespace armarx class ArmarXPlotterDialog; /** \class ArmarXPlotter - \ingroup ArmarXGuiPlugins */ class ARMARXCOMPONENT_IMPORT_EXPORT ArmarXPlotter: diff --git a/source/RobotAPI/gui_plugins/SensorActorWidgetsPlugin/SensorActorWidgetsPlugin.h b/source/RobotAPI/gui_plugins/SensorActorWidgetsPlugin/SensorActorWidgetsPlugin.h index 0ab65e97a7e18e296e4930a3b9c104435521f0c8..bb1db4c01b0189ccbff697586b980b1bd05ffcff 100644 --- a/source/RobotAPI/gui_plugins/SensorActorWidgetsPlugin/SensorActorWidgetsPlugin.h +++ b/source/RobotAPI/gui_plugins/SensorActorWidgetsPlugin/SensorActorWidgetsPlugin.h @@ -34,8 +34,9 @@ namespace armarx { /** * @brief The MdiPlugin class + * @ingroup ArmarXGuiPlugins * - * + * @see ArmarXPlotter */ class ARMARXCOMPONENT_IMPORT_EXPORT MdiPlugin : public ArmarXGuiPlugin diff --git a/source/RobotAPI/interface/CMakeLists.txt b/source/RobotAPI/interface/CMakeLists.txt index 6c426e75ffabb66d97dc8256dc2ddfdad1a88d04..bfa1ac0f38c8dc318d93306f4ff7f276a46f79da 100644 --- a/source/RobotAPI/interface/CMakeLists.txt +++ b/source/RobotAPI/interface/CMakeLists.txt @@ -29,8 +29,6 @@ set(SLICE_FILES units/UnitInterface.ice visualization/DebugDrawerInterface.ice - visualization/GraphVisualizerInterface.ice - ) # generate the interface library diff --git a/source/RobotAPI/interface/visualization/GraphVisualizerInterface.ice b/source/RobotAPI/interface/visualization/GraphVisualizerInterface.ice deleted file mode 100644 index b10d4940b9d97266da09a9b17af713b00515b477..0000000000000000000000000000000000000000 --- a/source/RobotAPI/interface/visualization/GraphVisualizerInterface.ice +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of ArmarX. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * 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 Lesser 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 ArmarX::RobotAPI - * @author Raphael Grimm <ufdrv at student dot kit dot edu> - * @date 2014 - * @copyright http://www.gnu.org/licenses/gpl.txt - * GNU General Public License - */ -#ifndef _ARMARX_ROBOTAPI_VISUALIZATION_GRAPHVISUALIZER_SLICE_ -#define _ARMARX_ROBOTAPI_VISUALIZATION_GRAPHVISUALIZER_SLICE_ - -#include <RobotAPI/interface/robotstate/PoseBase.ice> - -module armarx -{ - interface GraphVisualizerInterface - { - /** - * @brief returns whether an edge is in the graph. - * @param node1 The edge's first node. - * @param node2 The edge's first node. - * @return Whether an edge is in the graph. - */ - bool hasEdge(string node1, string node2); - - /** - * @brief Returns whether a node is in the graph. - * @param name The node's name. - * @return Whether a node is in the graph. - */ - bool hasNode(string name); - - /** - * @brief Adds an edge to the graph. - * @param node1 The edge's first node. - * @param node2 The edge's first node. - */ - void addEdge(string node1,string node2); - - /** - * @brief Adds a node to the graph. - * @param node The node. - */ - void addNode(FramedVector3Base node); - - /** - * @brief Highlights a edge according to highlighted. - * @param node1 The edge's first node. - * @param node2 The edge's first node. - * @param highlighted Whether the highlight will be set or reset. - */ - void highlightEdge(string node1, string node2, bool highlighted); - /** - * @brief Highlights a node according to highlighted. - * @param name The node's name. - * @param highlighted Whether the highlight will be set or reset. - */ - void highlightNode(string name, bool highlighted); - - /** - * @brief Draws the whole graph to the debug layer. - */ - void redraw(); - - /** - * @brief Removes all nodes and edges. - */ - void clearGraph(); - - /** - * @brief Removes all edges. - */ - void clearEdges(); - - /** - * @brief Resets the highlighted edges and nodes. - */ - void resetHilight(); - - - }; -}; - -#endif diff --git a/source/RobotAPI/libraries/robotstate/remote/ArmarPose.cpp b/source/RobotAPI/libraries/robotstate/remote/ArmarPose.cpp index c7e7ae0b4bbd4a9df7aabd01769fcbe6a3e84de5..69e9d37e1be841375dc0b2e2be12ff05a77a6756 100644 --- a/source/RobotAPI/libraries/robotstate/remote/ArmarPose.cpp +++ b/source/RobotAPI/libraries/robotstate/remote/ArmarPose.cpp @@ -39,6 +39,13 @@ namespace armarx z = m(2,3); } + Vector3::Vector3(::Ice::Float x, ::Ice::Float y, ::Ice::Float z) + { + this->x = x; + this->y = y; + this->z = z; + } + Vector3f Vector3::toEigen() const { Vector3f v; @@ -324,6 +331,12 @@ namespace armarx } + FramedVector3::FramedVector3(Ice::Float x, ::Ice::Float y, ::Ice::Float z, const std::string &frame) : + Vector3(x, y, z) + { + this->frame = frame; + } + string FramedVector3::getFrame() const { return frame; diff --git a/source/RobotAPI/libraries/robotstate/remote/ArmarPose.h b/source/RobotAPI/libraries/robotstate/remote/ArmarPose.h index 4754fefd828857d4f80793f2bb423dc21c5da172..5bcd3ca671da407d2345b80a6cd3c0e362ecf91f 100644 --- a/source/RobotAPI/libraries/robotstate/remote/ArmarPose.h +++ b/source/RobotAPI/libraries/robotstate/remote/ArmarPose.h @@ -69,6 +69,7 @@ namespace armarx Vector3(); Vector3(const Eigen::Vector3f &); Vector3(const Eigen::Matrix4f &); + Vector3(::Ice::Float x, ::Ice::Float y, ::Ice::Float z); virtual Eigen::Vector3f toEigen() const; @@ -372,6 +373,7 @@ namespace armarx FramedVector3(); FramedVector3(const FramedVector3& source); FramedVector3(const Eigen::Vector3f & vec, const std::string &frame, const std::string& agent ); + FramedVector3(Ice::Float x, ::Ice::Float y, ::Ice::Float z, const std::string &frame); std::string getFrame() const; static FramedVector3Ptr ChangeFrame(const VirtualRobot::RobotPtr robot, const FramedVector3& framedVec, const std::string &newFrame);