GraphVisualizerGuiPlugin.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #include <VirtualRobot/MathTools.h>
26 
29 
30 
31 //armar
33 
35 
36 // Qt headers
37 #include <Qt>
38 #include <QtGlobal>
39 #include <QPushButton>
40 #include <QLabel>
41 #include <QLineEdit>
42 #include <QHBoxLayout>
43 #include <QMenu>
44 
45 
46 //std
47 #include <memory>
48 #include <sstream>
49 #include <unordered_set>
50 #include <tuple>
51 #include <filesystem>
52 #include <fstream>
53 
54 #include <MemoryX/gui-plugins/GraphVisualizerPlugin/ui_GraphVisualizerConfigDialog.h>
55 
56 //#include <VirtualRobot/VirtualRobotCommon.h>
57 
58 using namespace memoryx;
59 
60 using namespace VirtualRobot;
61 
62 //static values and helper functions
63 #define DEFAULT_PRIOR_KNOWLEDGE_NAME "PriorKnowledge"
64 #define DEFAULT_DEBUG_DRAWER_NAME "DebugDrawerUpdates"
65 #define DEFAULT_DEBUG_DRAWER_LAYER_NAME "DebugDrawerUpdates_Graph"
66 
67 /**
68  * @brief The default width of lines drawn onto the debug layer and scene.
69  */
70 static const ::Ice::Float LINE_WIDTH_DEFAULT = 5;
71 /**
72  * @brief The width of selected lines drawn onto the debug layer and scene.
73  */
74 static const ::Ice::Float LINE_WIDTH_SELECTED = 10;
75 
76 /**
77  * @brief The default color of lines drawn onto the debug layer and scene.
78  */
79 static const ::armarx::DrawColor COLOR_DEFAULT = {0.5f, 0.5f, 1.f, 0.2f};
80 /**
81  * @brief The color of highlighted lines drawn onto the debug layer and scene.
82  */
83 static const ::armarx::DrawColor COLOR_HIGHLIGHT = {1.f, 0.0f, 0.f, 1.f};
84 
85 /**
86  * @brief The scale factor for elements drawn onto the scene.
87  */
88 static const float SCENE_SCALE_FACTOR = 2;
89 /**
90  * @brief The scale factor for nodes drawn onto the scene.
91  */
92 static const float SCENE_NODES_SCALE_FACTOR = 3 * SCENE_SCALE_FACTOR;
93 /**
94  * @brief The scale factor for edges drawn onto the scene.
95  */
96 static const float SCENE_LINE_SCALE_FACTOR = SCENE_SCALE_FACTOR;
97 
98 /**
99  * @brief The increment used when a rotation button is pressed.
100  *
101  * A positive rotation is counter clockwise.
102  * This value should be positive.
103  *
104  * rotation buttons: GraphVisualizerWidget::ui.buttonRotateClock and
105  * GraphVisualizerWidget::ui.buttonRotateCounterClock
106  */
107 static const float VIEW_ROTATE_STEP_SIZE_CC = 45;
108 
109 static const QString SETTING_LAST_SCENE = "lastScene";
110 
111 /**
112  * @brief Returns the name used on the debug layer.
113  * @param edge The edge.
114  * @return The name used on the debug layer.
115  */
116 inline std::string iceName(const GraphVisualizerWidget::EdgeId& edge)
117 {
118  std::stringstream s;
119  s << "edge_" << edge.first << "_" << edge.second;
120  return s.str();
121 }
122 
123 /**
124  * @brief iceName Returns the name used on the debug layer.
125  * @param nodeName The node.
126  * @return The name used on the debug layer.
127  */
128 inline std::string iceName(const GraphVisualizerWidget::NodeId& nodeName)
129 {
130  return nodeName;
131 }
132 
133 //gui plugin
135 {
136  addWidget<GraphVisualizerWidget>();
137 }
138 
139 //widget
140 
142  debugDrawerTopicName {DEFAULT_DEBUG_DRAWER_NAME},
143  viewAngle {0},
144  debugDrawerLayerName {DEFAULT_DEBUG_DRAWER_LAYER_NAME},
145  priorKnowledgeProxyName {DEFAULT_PRIOR_KNOWLEDGE_NAME},
146  settings {"KIT", "GraphVisualizerGuiPlugin"}
147 {
148  loadAutomaticSettings();
149  editStartNodeNext = true;
150 
151  // init gui
152  ui.setupUi(getWidget());
153  //add scene
154  std::unique_ptr<QGraphicsScene> scenePtr{new QGraphicsScene};
155  scene = scenePtr.get();
156  ui.graphicsViewGraph->setScene(scenePtr.release());
157  MouseEventProcessor* mep = new MouseEventProcessor(this);
158  ui.graphicsViewGraph->installEventFilter(mep);
159  //transform view
160  transformView();
161 }
162 
164 {
166 }
167 
169 {
170  ARMARX_VERBOSE << "init start";
171  usingProxy(priorKnowledgeProxyName);
172  usingProxy("GraphNodePoseResolver");
173  offeringTopic(debugDrawerTopicName);
174  ARMARX_VERBOSE << "init done";
175 }
176 
178 {
179  ARMARX_VERBOSE << "connecting";
180  debugDrawer = getTopic<armarx::DebugDrawerInterfacePrx>(debugDrawerTopicName);
181  priorKnowledgePrx = getProxy<memoryx::PriorKnowledgeInterfacePrx>(priorKnowledgeProxyName);
182  getProxy(gnpr, "GraphNodePoseResolver");
183 
184  if (priorKnowledgePrx->hasGraphSegment())
185  {
186  ARMARX_VERBOSE << "get Proxy to graph segment";
187  graphSeg = priorKnowledgePrx->getGraphSegment();
188  ui.sceneGroupBox->setEnabled(true);
189  ui.sceneGroupBox->setTitle("Scenes from graph memory segment");
190 
191  ui.b->setEnabled(true);
192  }
193  else
194  {
195  ui.sceneGroupBox->setEnabled(false);
196  ui.sceneGroupBox->setTitle("Scenes from graph memory segment (No graph memory segment available)");
197 
198  ui.b->setEnabled(false);
199  }
200 
201  ui.tableWidgetNodes->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
202  ui.tableWidgetEdges->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
203 
204  ui.tableWidgetNodes->setContextMenuPolicy(Qt::CustomContextMenu);
205  ui.tableWidgetEdges->setContextMenuPolicy(Qt::CustomContextMenu);
206 
207  //todo remove test function
208  QObject::connect(ui.b, SIGNAL(clicked()), this, SLOT(addKitchenGraph()), Qt::UniqueConnection);
209 
210  //tables
211  QObject::connect(ui.tableWidgetNodes, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(nodeTableDoubleClicked(int, int)), Qt::UniqueConnection);
212  QObject::connect(ui.tableWidgetNodes, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(tableWidgetNodesCustomContextMenu(QPoint)), Qt::UniqueConnection);
213  QObject::connect(ui.tableWidgetEdges, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(edgeTableDoubleClicked(int, int)), Qt::UniqueConnection);
214  QObject::connect(ui.tableWidgetEdges, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(tableWidgetEdgesCustomContextMenu(QPoint)), Qt::UniqueConnection);
215 
216  QObject::connect(ui.btnAdd, SIGNAL(clicked()), this, SLOT(addNewGraphNode()), Qt::UniqueConnection);
217  QObject::connect(ui.btnAddEdge, SIGNAL(clicked()), this, SLOT(addNewEdgeBoth()), Qt::UniqueConnection);
218  QObject::connect(ui.btnAddEdgeStartEnd, SIGNAL(clicked()), this, SLOT(addNewEdgeStartEnd()), Qt::UniqueConnection);
219  QObject::connect(ui.btnAddEdgeEndStart, SIGNAL(clicked()), this, SLOT(addNewEdgeEndStart()), Qt::UniqueConnection);
220  QObject::connect(ui.btnEdit, SIGNAL(clicked()), this, SLOT(editGraphNode()), Qt::UniqueConnection);
221 
222  //zoom
223  QObject::connect(ui.viewZoomFactor, SIGNAL(valueChanged(double)), this, SLOT(transformView()), Qt::UniqueConnection);
224  //rota
225  QObject::connect(ui.buttonRotateClock, SIGNAL(clicked()), this, SLOT(viewRotatedClock()), Qt::UniqueConnection);
226  QObject::connect(ui.buttonRotateCounterClock, SIGNAL(clicked()), this, SLOT(viewRotatedCounterClock()), Qt::UniqueConnection);
227  //redraw+clear
228  QObject::connect(ui.buttonRedraw, SIGNAL(clicked()), this, SLOT(redraw()), Qt::UniqueConnection);
229  QObject::connect(ui.buttonClear, SIGNAL(clicked()), this, SLOT(clearGraph()), Qt::UniqueConnection);
230  //auto adjust
231  QObject::connect(ui.buttonAutoAdjust, SIGNAL(clicked()), this, SLOT(adjustView()), Qt::UniqueConnection);
232  //memory
233  QObject::connect(ui.refreshScenesButton, SIGNAL(clicked()), this, SLOT(updateSceneList()), Qt::UniqueConnection);
234  QObject::connect(ui.drawSceneButton, SIGNAL(clicked()), this, SLOT(drawScene()), Qt::UniqueConnection); //BUTTON LOAD
235  QObject::connect(ui.scenesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectedSceneChanged(int)), Qt::UniqueConnection);
236 
237  ARMARX_VERBOSE << "connected";
238 
239  updateSceneList();
240 }
241 
243 {
244 }
245 
246 QPointer<QDialog> GraphVisualizerWidget::getConfigDialog(QWidget* parent)
247 {
248  if (!dialog)
249  {
250  dialog = new GraphVisualizerConfigDialog(parent);
251  }
252 
253  dialog->ui->editDebugDrawerProxyName->setText(QString::fromStdString(debugDrawerTopicName));
254  dialog->ui->editDebugDrawerLayerName->setText(QString::fromStdString(debugDrawerLayerName));
255  dialog->ui->editPriorKnowledgeProxyName->setText(QString::fromStdString(priorKnowledgeProxyName));
256  return qobject_cast<GraphVisualizerConfigDialog*>(dialog);
257 }
258 
260 {
261  debugDrawerTopicName = dialog->ui->editDebugDrawerProxyName->text().toStdString();
262  debugDrawerLayerName = dialog->ui->editDebugDrawerLayerName->text().toStdString();
263  priorKnowledgeProxyName = dialog->ui->editPriorKnowledgeProxyName->text().toStdString();
264 }
265 
266 
267 void GraphVisualizerWidget::loadSettings(QSettings* settings)
268 {
269  debugDrawerTopicName = settings->value("debugDrawerTopicName", QString::fromStdString(debugDrawerTopicName)).toString().toStdString();
270  debugDrawerLayerName = settings->value("debugDrawerLayerName", QString::fromStdString(debugDrawerLayerName)).toString().toStdString();
271 }
272 
273 void GraphVisualizerWidget::saveSettings(QSettings* settings)
274 {
275  settings->setValue("debugDrawerTopicName", QString::fromStdString(debugDrawerTopicName));
276  settings->setValue("debugDrawerLayerName", QString::fromStdString(debugDrawerLayerName));
277 }
278 
280 {
281  lastSelectedSceneName = settings.value(SETTING_LAST_SCENE, lastSelectedSceneName).toString();
282 }
283 
285 {
286  settings.setValue(SETTING_LAST_SCENE, lastSelectedSceneName);
287 }
288 
289 void GraphVisualizerWidget::addEdge(const std::string& node1Id, const std::string& node2Id, const Ice::Current&)
290 {
291  if (!hasNode(node1Id))
292  {
293  ARMARX_WARNING << "Edge: " << node1Id << ", " << node2Id << " can't be created! Node " << node1Id << " does not exist.";
294  return;
295  }
296 
297  if (!hasNode(node2Id))
298  {
299  ARMARX_WARNING << "Edge: " << node1Id << ", " << node2Id << " can't be created! Node " << node2Id << " does not exist.";
300  return;
301  }
302 
303  auto node1dat = nodes.at(node1Id);
304  auto node2dat = nodes.at(node2Id);
305 
306  if (hasEdge(node1Id, node2Id))
307  {
308  //nothing needs to be updated
309  ARMARX_WARNING << "Edge: '" << node1dat.node->getName() << "' -> '" << node2dat.node->getName() << "' already exists.";
310  return;
311  }
312 
313  auto edgeId = toEdge(node1Id, node2Id);
314 
315  //add
316  //table
317  int row = ui.tableWidgetEdges->rowCount();
318  ui.tableWidgetEdges->setRowCount(row + 1);
319  ui.tableWidgetEdges->setItem(row, 0, new QTableWidgetItem {QString::fromStdString(node1dat.node->getName())});
320  ui.tableWidgetEdges->setItem(row, 1, new QTableWidgetItem {QString::fromStdString(node2dat.node->getName())});
321  //debug layer will be done later
322  //scene
323  QGraphicsLineItem* graphicsItem = dynamic_cast<QGraphicsLineItem*>(new GraphVisualizerGraphicsLineItem
324  {
325  *this, edgeId,
326  node1dat.pose->position->x, -node1dat.pose->position->y,
327  node2dat.pose->position->x, -node2dat.pose->position->y
328  });
329  //auto graphicsItem= scene->addLine(node1dat.pos->x,-node1dat.pos->y,
330  // node2dat.pos->x,-node2dat.pos->y);
331  scene->addItem(graphicsItem);
332  //setToolTip on graphicsItem does not work
333  dynamic_cast<QGraphicsItem*>(graphicsItem)->setToolTip(QString {"Edge:"} +QString::fromStdString(node1dat.node->getName()) +
334  QString {" <-> "} +QString::fromStdString(node2dat.node->getName()));
335  //data
336  EdgeData data {graphicsItem, row, false};
337  edges[edgeId] = data;
338 
339  updateEdge(edgeId);
340 }
341 
342 void GraphVisualizerWidget::addNode(const GraphNodeBasePtr& node, const Ice::Current&)
343 {
345  auto nodeId = node->getId();
346 
347  armarx::FramedPosePtr globalNodePose;
348  try
349  {
350  globalNodePose = armarx::FramedPosePtr::dynamicCast(gnpr->resolveToGlobalPose(node));
351  }
352  catch (...)
353  {
354  return;
355  }
356 
357  if (hasNode(nodeId))
358  {
359  NodeData& oldNode = nodes.at(nodeId);
360  ARMARX_VERBOSE << "Node: " << nodeId << " was overwritten! Old: "
361  << oldNode.pose->position->x << ", " << oldNode.pose->position->y << ", " << getYawAngle(oldNode.pose) << "| New: "
362  << globalNodePose->position->x << ", " << globalNodePose->position->y << ", " << getYawAngle(globalNodePose);
363  //update node data
364  //table
365  ui.tableWidgetNodes->setItem(oldNode.tableWidgetNodesIndex, 1, new QTableWidgetItem {QString::number(globalNodePose->position->x)});
366  ui.tableWidgetNodes->setItem(oldNode.tableWidgetNodesIndex, 2, new QTableWidgetItem {QString::number(globalNodePose->position->y)});
367  ui.tableWidgetNodes->setItem(oldNode.tableWidgetNodesIndex, 3, new QTableWidgetItem {QString::number(getYawAngle(globalNodePose))});
368 
369  //data
370  oldNode.pose = globalNodePose;
371 
372  //update connected edges
373  for (const auto& edge : edges)
374  {
375  if ((edge.first.first == nodeId) || (edge.first.second == nodeId))
376  {
377  updateEdge(edge.first);
378  }
379  }
380  }
381  else
382  {
383  //add&draw node
384  //table
385  int row = ui.tableWidgetNodes->rowCount();
386  ui.tableWidgetNodes->setRowCount(row + 1);
387  ui.tableWidgetNodes->setItem(row, 0, new QTableWidgetItem {QString::fromStdString(node->getName())});
388  ui.tableWidgetNodes->setItem(row, 1, new QTableWidgetItem {QString::number(globalNodePose->position->x)});
389  ui.tableWidgetNodes->setItem(row, 2, new QTableWidgetItem {QString::number(globalNodePose->position->y)});
390  ui.tableWidgetNodes->setItem(row, 3, new QTableWidgetItem {QString::number(getYawAngle(globalNodePose))});
391  //scene
392  QGraphicsEllipseItem* graphicsItem = dynamic_cast<QGraphicsEllipseItem*>(new GraphVisualizerGraphicsEllipseItem
393  {
394  *this, node->getName(),
395  globalNodePose->position->x, -globalNodePose->position->y, 0, 0
396  });
397  //auto graphicsItem= scene->addEllipse(node->x,-node->y,0,0);
398  scene->addItem(graphicsItem);
399  //setToolTip on graphicsItem does not work
400  graphicsItem->setZValue(std::numeric_limits<qreal>::max());
401  dynamic_cast<QGraphicsItem*>(graphicsItem)->setToolTip(QString {"Node:"} +QString::fromStdString(node->getName()));
402 
403  //data
404  NodeData data {node, globalNodePose, graphicsItem, row, false};
405  nodes.insert({nodeId, data});
406  }
407 
408  updateNode(nodeId);
409 }
410 
411 void GraphVisualizerWidget::clearEdges(const Ice::Current&)
412 {
413  for (auto& edge : edges)
414  {
415  //remove from graphics scene
416  scene->removeItem(edge.second.graphicsItem);
417  delete edge.second.graphicsItem;
418  //remove from debug layer
419  debugDrawer->removePoseVisu(debugDrawerLayerName, iceName(edge.first));
420  }
421 
422  //clear table widget
423  ui.tableWidgetEdges->clearContents();
424  ui.tableWidgetEdges->setRowCount(0);
425  //clear data structures
426  edges.clear();
427 }
428 
429 void GraphVisualizerWidget::clearGraph(const Ice::Current&)
430 {
431  //remove from debug layer
432  for (auto& edge : edges)
433  {
434  debugDrawer->removeLineVisu(debugDrawerLayerName, iceName(edge.first));
435  }
436 
437  for (auto& node : nodes)
438  {
439  debugDrawer->removeArrowVisu(debugDrawerLayerName, iceName(node.first));
440  debugDrawer->removeTextVisu(debugDrawerLayerName, iceName(node.first) + "text");
441  debugDrawer->removePoseVisu(debugDrawerLayerName, iceName(node.first));
442  }
443 
444  //clear scene
445  scene->clear();
446  //clear table widgets
447  ui.tableWidgetEdges->clearContents();
448  ui.tableWidgetEdges->setRowCount(0);
449  ui.tableWidgetNodes->clearContents();
450  ui.tableWidgetNodes->setRowCount(0);
451  //clear data structures
452 
453  edges.clear();
454  nodes.clear();
455 }
456 
457 void GraphVisualizerWidget::resetHighlight(const Ice::Current&)
458 {
459  for (auto& edge : edges)
460  {
461  if (edge.second.highlighted)
462  {
463  edge.second.highlighted = false;
464  updateEdge(edge.first);
465  }
466  }
467 
468  for (auto& node : nodes)
469  {
470  if (node.second.highlighted)
471  {
472  node.second.highlighted = false;
473  updateNode(node.first);
474  }
475  }
476 }
477 
478 void GraphVisualizerWidget::updateEdge(const EdgeId& id)
479 {
480  const EdgeData& data = edges.at(id);
481  auto color = (data.highlighted) ? COLOR_HIGHLIGHT : COLOR_DEFAULT;
482  QColor qColor;
483  qColor.setRedF(color.r);
484  qColor.setGreenF(color.g);
485  qColor.setBlueF(color.b);
486 
487  auto lineWidth = (data.highlighted) ? LINE_WIDTH_SELECTED : LINE_WIDTH_DEFAULT;
488  armarx::Vector3Ptr posStart = new armarx::Vector3(armarx::Vector3Ptr::dynamicCast(nodes.at(id.first).pose->position)->toEigen());
489  posStart->z += posStart->z < 1 ? 10 : 0;
490  armarx::Vector3Ptr posEnd = new armarx::Vector3(armarx::Vector3Ptr::dynamicCast(nodes.at(id.second).pose->position)->toEigen());
491  posEnd->z += posEnd->z < 1 ? 10 : 0;
492  //debug layer
493  debugDrawer->setLineVisu(debugDrawerLayerName,
494  iceName(id),
495  posStart,
496  posEnd,
497  lineWidth,
498  color);
499 
500  data.graphicsItem->setLine(nodes[id.first].pose->position->x, -nodes[id.first].pose->position->y,
501  nodes[id.second].pose->position->x, -nodes[id.second].pose->position->y);
502 
503  //scene
504  QPen pen {qColor};
505  pen.setWidthF(lineWidth * SCENE_LINE_SCALE_FACTOR);
506  data.graphicsItem->setPen(pen);
507  //table
508  QFont font {};
509  font.setBold(data.highlighted);
510  ui.tableWidgetEdges->item(data.tableWidgetEdgesIndex, 0)->setData(Qt::BackgroundRole, qColor);
511  ui.tableWidgetEdges->item(data.tableWidgetEdgesIndex, 0)->setFont(font);
512  ui.tableWidgetEdges->item(data.tableWidgetEdgesIndex, 1)->setData(Qt::BackgroundRole, qColor);
513  ui.tableWidgetEdges->item(data.tableWidgetEdgesIndex, 1)->setFont(font);
514 }
515 
516 void GraphVisualizerWidget::updateNode(const NodeId& id)
517 {
518  NodeData& data = nodes.at(id);
519 
520  if (editStartNodeNext)
521  {
522  ui.editStartNodeId->setText(QString::fromStdString(data.node->getId()));
523  ui.editStartNodeName->setText(QString::fromStdString(data.node->getName()));
524  }
525  else
526  {
527  ui.editEndNodeId->setText(QString::fromStdString(data.node->getId()));
528  ui.editEndNodeName->setText(QString::fromStdString(data.node->getName()));
529  }
530 
531  setEditFields(data);
532 
533  editStartNodeNext = !editStartNodeNext;
534 
535  auto color = (data.highlighted) ? COLOR_HIGHLIGHT : COLOR_DEFAULT;
536  QColor qColor;
537  qColor.setRedF(color.r);
538  qColor.setGreenF(color.g);
539  qColor.setBlueF(color.b);
540 
541  auto lineWidth = (data.highlighted) ? LINE_WIDTH_SELECTED : LINE_WIDTH_DEFAULT;
542 
543  //debug layer
544  float yaw = getYawAngle(data.pose) / 180 * M_PI;
545  Eigen::AngleAxisf aa(yaw, Eigen::Vector3f(0, 0, 1));
546  Eigen::Vector3f dir {0, 1, 0};
547  dir = aa.toRotationMatrix() * dir;
548  debugDrawer->setArrowVisu(debugDrawerLayerName, iceName(id), data.pose->position,
549  new armarx::Vector3(dir),
550  armarx::DrawColor {0, 0, 1, 1},
551  100,
552  lineWidth);
553  debugDrawer->setTextVisu(debugDrawerLayerName, iceName(id) + "text", data.node->getName(), data.pose->position, armarx::DrawColor {0, 0, 1, 1}, 10);
554 
555  //scene
556  data.graphicsItem->setPen(QPen {qColor});
557  data.graphicsItem->setBrush(QBrush {qColor});
558  data.graphicsItem->setRect(data.pose->position->x - lineWidth * SCENE_NODES_SCALE_FACTOR / 2,
559  -data.pose->position->y - lineWidth * SCENE_NODES_SCALE_FACTOR / 2,
560  lineWidth * SCENE_NODES_SCALE_FACTOR,
561  lineWidth * SCENE_NODES_SCALE_FACTOR);
562  //table
563  QFont font {};
564  font.setBold(data.highlighted);
565  ui.tableWidgetNodes->item(data.tableWidgetNodesIndex, 0)->setData(Qt::BackgroundRole, qColor);
566  ui.tableWidgetNodes->item(data.tableWidgetNodesIndex, 0)->setFont(font);
567  ui.tableWidgetNodes->item(data.tableWidgetNodesIndex, 1)->setData(Qt::BackgroundRole, qColor);
568  ui.tableWidgetNodes->item(data.tableWidgetNodesIndex, 1)->setFont(font);
569  ui.tableWidgetNodes->item(data.tableWidgetNodesIndex, 2)->setData(Qt::BackgroundRole, qColor);
570  ui.tableWidgetNodes->item(data.tableWidgetNodesIndex, 2)->setFont(font);
571  ui.tableWidgetNodes->item(data.tableWidgetNodesIndex, 3)->setData(Qt::BackgroundRole, qColor);
572  ui.tableWidgetNodes->item(data.tableWidgetNodesIndex, 3)->setFont(font);
573 
574  //highlight all edges between highlighted nodes
575  std::vector<GraphNodeBasePtr> highlightedNodes;
576  for (const auto& nodeData : nodes)
577  {
578  if (nodeData.second.highlighted)
579  {
580  highlightedNodes.push_back(nodeData.second.node);
581  }
582  }
583 
584  for (auto& edge : edges)
585  {
586  if (edge.second.highlighted)
587  {
588  edge.second.highlighted = false;
589  updateEdge(edge.first);
590  }
591  }
592 
593  for (const auto& nodeFrom : highlightedNodes)
594  {
595  for (const auto& nodeTo : highlightedNodes)
596  {
597  const auto nodeFromId = nodeFrom->getId();
598  const auto nodeToId = nodeTo->getId();
599  if (hasEdge(nodeFromId, nodeToId))
600  {
601  auto edgeId = toEdge(nodeFromId, nodeToId);
602  auto& edge = edges[edgeId];
603  edge.highlighted = true;
604  updateEdge(edgeId);
605  }
606  }
607  }
608 }
609 
610 float GraphVisualizerWidget::getYawAngle(const armarx::PoseBasePtr& pose) const
611 {
612  Eigen::Vector3f rpy;
613  armarx::PosePtr p = armarx::PosePtr::dynamicCast(pose);
614  VirtualRobot::MathTools::eigen4f2rpy(p->toEigen(), rpy);
615  return VirtualRobot::MathTools::rad2deg(rpy[2]);
616 }
617 
618 void GraphVisualizerWidget::highlightEdge(const std::string& node1Id, const std::string& node2Id, bool highlighted, const Ice::Current&)
619 {
620  if (!hasEdge(node1Id, node2Id))
621  {
622  ARMARX_WARNING << "No edge for: " << node1Id << " and " << node2Id << " [file: " << __FILE__ << " | line: " << __LINE__ << " | function: " << __PRETTY_FUNCTION__ << "]";
623  return;
624  }
625 
626  EdgeId edge = toEdge(node1Id, node2Id);
627 
628  if (edges.at(edge).highlighted != highlighted)
629  {
630  edges.at(edge).highlighted = highlighted;
631  updateEdge(edge);
632  }
633 }
634 
635 void GraphVisualizerWidget::highlightNode(const std::string& nodeId, bool highlighted, const Ice::Current&)
636 {
637  if (!hasNode(nodeId))
638  {
639  ARMARX_WARNING << "No node: " << nodeId << " [pushBfile: " << __FILE__ << " | line: " << __LINE__ << " | function: " << __PRETTY_FUNCTION__ << "]";
640  return;
641  }
642 
643  if (nodes.at(nodeId).highlighted != highlighted)
644  {
645  nodes.at(nodeId).highlighted = highlighted;
646  updateNode(nodeId);
647  }
648 }
649 
650 
651 void GraphVisualizerWidget::nodeTableDoubleClicked(int row, int)
652 {
653  auto nodeIt = std::find_if(nodes.cbegin(), nodes.cend(), [&](const std::pair<std::string, NodeData>& d)
654  {
655  // return d.second.node->getName() == ui.tableWidgetNodes->item(row, 0)->text().toStdString();
656  return d.second.tableWidgetNodesIndex == row;
657  });
658  auto nodeId = nodeIt->second.node->getId();
659  nodeDoubleClicked(nodeId);
660 }
661 
662 void GraphVisualizerWidget::edgeTableDoubleClicked(int row, int)
663 {
664  auto edgeIt = std::find_if(edges.cbegin(), edges.cend(), [&](const std::pair<EdgeId, EdgeData>& d)
665  {
666  return d.second.tableWidgetEdgesIndex == row;
667  });
668 
669  edgeDoubleClicked(edgeIt->first);
670 }
671 
672 void GraphVisualizerWidget::nodeDoubleClicked(NodeId id)
673 {
674  nodes.at(id).highlighted ^= true;
675  updateNode(id);
676 }
677 
678 void GraphVisualizerWidget::edgeDoubleClicked(EdgeId id)
679 {
680  // edges.at(id).highlighted ^= true;
681  // updateEdge(id);
682  bool highlight = !nodes.at(id.first).highlighted && !nodes.at(id.second).highlighted;
683  nodes.at(id.first).highlighted = highlight;
684  nodes.at(id.second).highlighted = highlight;
685  updateNode(id.first);
686  updateNode(id.second);
687 }
688 
689 void GraphVisualizerWidget::redraw(const Ice::Current&)
690 {
691  drawScene();
692 }
693 
694 void GraphVisualizerWidget::setEditFields(const NodeData& nodeData)
695 {
696  ui.editNodeId->setText(QString::fromStdString(nodeData.node->getId()));
697  ui.editSceneName->setText(QString::fromStdString(nodeData.node->getScene()));
698  ui.editNodeName->setText(QString::fromStdString(nodeData.node->getName()));
699  ui.editFrameName->setText(QString::fromStdString(nodeData.pose->frame));
700  ui.editAgentName->setText(QString::fromStdString(nodeData.pose->agent));
701 
702  Eigen::Vector3f rpy;
703  VirtualRobot::MathTools::eigen4f2rpy(nodeData.pose->toEigen(), rpy);
704  ui.spinBoxX->setValue(nodeData.pose->position->x);
705  ui.spinBoxY->setValue(nodeData.pose->position->y);
706  ui.spinBoxZ->setValue(nodeData.pose->position->z);
707 
708  ui.spinBoxRoll->setValue(VirtualRobot::MathTools::rad2deg(rpy[0]));
709  ui.spinBoxPitch->setValue(VirtualRobot::MathTools::rad2deg(rpy[1]));
710  ui.spinBoxYaw->setValue(VirtualRobot::MathTools::rad2deg(rpy[2]));
711 }
712 
714 {
715  clearGraph();
716  drawScene();
717 }
718 
719 void GraphVisualizerWidget::transformView()
720 {
721  double d = ui.viewZoomFactor->value();
722  ui.graphicsViewGraph->setTransform(QTransform::fromScale(d, d).rotate(viewAngle));
723 }
724 
725 void GraphVisualizerWidget::viewRotatedClock()
726 {
727  viewAngle = std::fmod(viewAngle + VIEW_ROTATE_STEP_SIZE_CC, 360);
728  transformView();
729 }
730 
731 void GraphVisualizerWidget::viewRotatedCounterClock()
732 {
733  viewAngle = std::fmod(viewAngle + 360 - VIEW_ROTATE_STEP_SIZE_CC, 360);
734  transformView();
735 }
736 
737 void GraphVisualizerWidget::adjustView()
738 {
739  float maxX = std::numeric_limits<float>::min();
740  float minX = std::numeric_limits<float>::max();
741  float maxY = std::numeric_limits<float>::min();
742  float minY = std::numeric_limits<float>::max();
743 
744  //search bounding box
745  for (const auto& node : nodes)
746  {
747  maxX = (maxX < node.second.pose->position->x) ? node.second.pose->position->x : maxX;
748  minX = (minX > node.second.pose->position->x) ? node.second.pose->position->x : minX;
749  maxY = (maxY < node.second.pose->position->y) ? node.second.pose->position->y : maxY;
750  minY = (minY > node.second.pose->position->y) ? node.second.pose->position->y : minY;
751  }
752 
753  auto deltaX = maxX - minX; //>=0
754  auto deltaY = maxY - minY; //>=0
755 
756  //compare ratio of graph and view. if both horizontal (vertical) ->rotate to 0 or 180 (90,270)
757  if (std::signbit(deltaX / deltaY - 1) == std::signbit(ui.graphicsViewGraph->width() / ui.graphicsViewGraph->height() - 1))
758  {
759  //same => rotate to 0 or 180
760  viewAngle = (viewAngle < std::abs(180 - viewAngle)) ? 0 : 180;
761  //set zoom => update
762  ui.viewZoomFactor->setValue(std::min(ui.graphicsViewGraph->width() / deltaX,
763  ui.graphicsViewGraph->height() / deltaY) * 0.9);
764  }
765  else
766  {
767  //different rotate to 90 or 270
768  viewAngle = (std::abs(90 - viewAngle) < std::abs(270 - viewAngle)) ? 90 : 270;
769  //set zoom => update
770  ui.viewZoomFactor->setValue(std::min(ui.graphicsViewGraph->width() / deltaY,
771  ui.graphicsViewGraph->height() / deltaX) * 0.9);
772  }
773 
774 }
775 
776 bool GraphVisualizerWidget::addNewEdge(const std::string& fromId, const std::string& toId)
777 {
778  std::string errorMsg;
779 
780  if (!graphSeg->hasEntityById(fromId))
781  {
782  errorMsg = "start node with Id '" + fromId + "' not found in segment";
783  }
784  else if (!graphSeg->hasEntityById(toId))
785  {
786  errorMsg = "end node with Id '" + toId + "' not found in segment";
787 
788  }
789  else if (fromId == toId)
790  {
791  errorMsg = "starting and ending node are the same";
792  }
793  else
794  {
795  auto fromNode = graphSeg->getNodeById(fromId);
796  for (const auto& adjacent : fromNode->getAdjacentNodes())
797  {
798  if (toId == adjacent->getId())
799  {
800  errorMsg = "edge '" + fromNode->getName() + "' -> '" + adjacent->getName() + "' already exists";
801  break;
802  }
803  }
804  }
805 
806  if (errorMsg.empty())
807  {
808  ui.labelAddEdgeStatus->setText(QString::fromStdString("Ok"));
809  graphSeg->addEdge(fromId, toId);
810  gnpr->forceRefetch(fromId);
811  gnpr->forceRefetch(toId);
812  addEdge(fromId, toId);
813  updateNode(fromId);
814  updateNode(toId);
815  ui.labelAddEdgeStatus->setStyleSheet("QLabel { background-color : lime; }");
816  }
817  else
818  {
819  ARMARX_WARNING << errorMsg;
820  ui.labelAddEdgeStatus->setText(QString::fromStdString(errorMsg));
821  ui.labelAddEdgeStatus->setStyleSheet("QLabel { background-color : orange; }");
822  }
823 
824  return errorMsg.empty();
825 }
826 
827 void GraphVisualizerWidget::addNewEdgeBoth()
828 {
829  std::string startId = ui.editStartNodeId->text().toStdString();
830  std::string endId = ui.editEndNodeId->text().toStdString();
831  addNewEdge(startId, endId);
832  addNewEdge(endId, startId);
833 }
834 
835 void GraphVisualizerWidget::addNewEdgeStartEnd()
836 {
837  std::string startId = ui.editStartNodeId->text().toStdString();
838  std::string endId = ui.editEndNodeId->text().toStdString();
839  addNewEdge(startId, endId);
840 }
841 
842 void GraphVisualizerWidget::addNewEdgeEndStart()
843 {
844  std::string startId = ui.editEndNodeId->text().toStdString();
845  std::string endId = ui.editStartNodeId->text().toStdString();
846  addNewEdge(startId, endId);
847 }
848 
849 void GraphVisualizerWidget::selectedSceneChanged(int i)
850 {
851  const auto current = ui.scenesComboBox->currentText();
852  if (!current.isEmpty())
853  {
854  lastSelectedSceneName = current;
855  }
856 }
857 
858 void GraphVisualizerWidget::updateSceneList()
859 {
860  auto scenes = graphSeg->getScenes();
861  ui.scenesComboBox->clear();
862  int idx = -1;
863 
864  for (std::size_t i = 0; i < scenes.size(); i++)
865  {
866  const auto currentScene = QString::fromStdString(scenes[i]);
867  ui.scenesComboBox->addItem(currentScene);
868 
869  if (currentScene == lastSelectedSceneName)
870  {
871  idx = i;
872  }
873  }
874 
875  ui.scenesComboBox->setCurrentIndex(idx);
876 }
877 
878 void GraphVisualizerWidget::drawScene()
879 {
880  std::vector<std::string> highlightedNodes;
881  for (const auto& nodeData : nodes)
882  {
883  bool sameScene = ui.scenesComboBox->currentText().toStdString() == nodeData.second.node->getScene();
884  if (nodeData.second.highlighted && sameScene)
885  {
886  highlightedNodes.push_back(nodeData.first);
887  }
888  }
889 
890  clearGraph();
891  auto graphNodes = graphSeg->getNodesByScene(ui.scenesComboBox->currentText().toStdString());
892 
893  //add nodes
894  for (auto& node : graphNodes)
895  {
896  auto pos = armarx::FramedPosePtr::dynamicCast(node->getPose());
897 
898  if (!pos || node->isMetaEntity())
899  {
900  continue;
901  }
902 
903  addNode(node);
904  }
905 
906  //add edges
907  for (auto& node : graphNodes)
908  {
909  auto nodeId = node->getId();
910 
911  for (int i = 0; i < node->getOutdegree(); i++)
912  {
913  auto adjacent = memoryx::GraphNodeBasePtr::dynamicCast(node->getAdjacentNode(i)->getEntity());
914  ARMARX_CHECK_EXPRESSION(adjacent);
915  auto adjacentId = adjacent->getId();
916 
917  addEdge(nodeId, adjacentId);
918  }
919  }
920 
921  for (const auto& nodeId : highlightedNodes)
922  {
923  auto nodeIt = std::find_if(nodes.begin(), nodes.end(), [&](const std::pair<std::string, NodeData>& d)
924  {
925  return d.first == nodeId;
926  });
927 
928  if (nodeIt != nodes.end())
929  {
930  nodeIt->second.highlighted = true;
931  updateNode(nodeIt->first);
932  }
933  }
934 
935  adjustView();
936 }
937 
938 void GraphVisualizerWidget::selectScene()
939 {
940  //QString fi = QFileDialog::getOpenFileName(this, tr("Open Scene File"), QString(), tr("XML Files (*.xml)"));
941  // std::string xmlSceneFile = std::string(fi.toLatin1());
942  // loadScene(xmlSceneFile);
943 }
944 
945 void GraphVisualizerWidget::loadScene(const std::string& xmlFile)
946 {
947  // VirtualRobot::ScenePtr SceneIO::loadScene(const std::string& xmlFile)
948  // {
949  // load file
950  std::ifstream in(xmlFile.c_str());
951 
952  if (!in.is_open())
953  {
954  ARMARX_WARNING << "Could not open XML file:" << xmlFile;
955  return;
956  }
957 
958  std::stringstream buffer;
959  buffer << in.rdbuf();
960  std::string sceneXML(buffer.str());
961  std::filesystem::path filenameBaseComplete(xmlFile);
962  std::filesystem::path filenameBasePath = filenameBaseComplete.parent_path();
963  std::string basePath = filenameBasePath.string();
964 
965  in.close();
966 
967  // VirtualRobot::ScenePtr res = createSceneFromString(robotXML, basePath);
968  // THROW_VR_EXCEPTION_IF(!res, "Error while parsing file " << xmlFile);
969 
970  // return res;
971  // }
972 }
973 
974 void GraphVisualizerWidget::addKitchenGraph()
975 {
976  std::string scene {"GraphKitchen"};
977  graphSeg->clearScene(scene);
978 
979  //if you insist on hardcoding scenes, use these convenience functions for improved readability:
980  auto addNode = [&](const std::string & name, float x, float y, float angle)
981  {
982  graphSeg->addNode(new ::memoryx::GraphNode {x, y, angle, name, scene});
983  ARMARX_INFO_S << "added node '" << name << "' at (" << x << ", " << y << ", " << angle << "rad)";
984  };
985 
986  auto addEdges = [&](const std::string & nodeFromName, const std::string & nodeToName, bool bidirectional)
987  {
988  auto nodeFrom = graphSeg->getNodeFromSceneByName(scene, nodeFromName);
989  auto nodeTo = graphSeg->getNodeFromSceneByName(scene, nodeToName);
990  ARMARX_CHECK_EXPRESSION(nodeFrom);
991  ARMARX_CHECK_EXPRESSION(nodeTo);
992  ARMARX_INFO_S << "'" << nodeFrom->getName() << "' -> '" << nodeTo->getName() << "', status: " << graphSeg->addEdge(nodeFrom->getId(), nodeTo->getId());
993  if (bidirectional)
994  {
995  ARMARX_INFO_S << "'" << nodeTo->getName() << "' -> '" << nodeFrom->getName() << "', status: " << graphSeg->addEdge(nodeTo->getId(), nodeFrom->getId());
996  }
997  };
998 
999  //ex
1000  addNode("initialnode", 2900, 7000, 0);
1001  addNode("sideboard", 3400, 7000, 0);
1002  addEdges("initialnode", "sideboard", true);
1003 }
1004 
1005 void GraphVisualizerWidget::addNewGraphNode()
1006 {
1007  Eigen::Matrix4f mat;
1008  Eigen::Vector3f rpy;
1009  Eigen::Vector3f pos;
1010  rpy << VirtualRobot::MathTools::deg2rad(ui.spinBoxRoll->value()),
1011  VirtualRobot::MathTools::deg2rad(ui.spinBoxPitch->value()),
1012  VirtualRobot::MathTools::deg2rad(ui.spinBoxYaw->value());
1013  pos << ui.spinBoxX->value(),
1014  ui.spinBoxY->value(),
1015  ui.spinBoxZ->value();
1016  VirtualRobot::MathTools::posrpy2eigen4f(pos, rpy, mat);
1018  ui.editFrameName->text().toStdString(),
1019  ui.editAgentName->text().toStdString());
1020  GraphNodePtr node = new GraphNode(pose,
1021  ui.editNodeName->text().toStdString(),
1022  ui.editSceneName->text().toStdString());
1023  auto entityId = graphSeg->addNode(node);
1024  gnpr->forceRefetch(entityId);
1025  node->setId(entityId);
1026  if (ui.scenesComboBox->currentText().toStdString() == ui.editSceneName->text().toStdString())
1027  {
1028  ui.editNodeId->setText(QString::fromStdString(entityId));
1029  addNode(node);
1030  }
1031 }
1032 
1033 void GraphVisualizerWidget::editGraphNode()
1034 {
1035  Eigen::Matrix4f mat;
1036  Eigen::Vector3f rpy;
1037  Eigen::Vector3f pos;
1038  rpy << VirtualRobot::MathTools::deg2rad(ui.spinBoxRoll->value()),
1039  VirtualRobot::MathTools::deg2rad(ui.spinBoxPitch->value()),
1040  VirtualRobot::MathTools::deg2rad(ui.spinBoxYaw->value());
1041  pos << ui.spinBoxX->value(),
1042  ui.spinBoxY->value(),
1043  ui.spinBoxZ->value();
1044  VirtualRobot::MathTools::posrpy2eigen4f(pos, rpy, mat);
1046  ui.editFrameName->text().toStdString(),
1047  ui.editAgentName->text().toStdString());
1048  GraphNodePtr node = new GraphNode(pose,
1049  ui.editNodeName->text().toStdString(),
1050  ui.editSceneName->text().toStdString());
1051  auto id = ui.editNodeId->text().toStdString();
1052 
1053  node->setId(id);
1054  graphSeg->updateEntity(id, node);
1055  gnpr->forceRefetch(id);
1056  if (ui.scenesComboBox->currentText().toStdString() == ui.editSceneName->text().toStdString())
1057  {
1058  addNode(node);
1059  }
1060 }
1061 
1063 {
1064  int row = ui.tableWidgetNodes->rowAt(pos.y());
1065  auto nodeIt = std::find_if(nodes.begin(), nodes.end(), [&](const std::pair<std::string, NodeData>& d)
1066  {
1067  return d.second.tableWidgetNodesIndex == row;
1068  });
1069  QMenu menu;
1070  QAction* deleteAction = menu.addAction("Delete Node");
1071 
1072  if (menu.exec(QCursor::pos()) == deleteAction)
1073  {
1074  ARMARX_CHECK_EXPRESSION(nodeIt != nodes.end());
1075  graphSeg->removeNode(nodeIt->second.node->getId());
1076  drawScene();
1077  }
1078 }
1079 
1081 {
1082  int row = ui.tableWidgetEdges->rowAt(pos.y());
1083  auto edgeIt = std::find_if(edges.begin(), edges.end(), [&](const std::pair<EdgeId, EdgeData>& d)
1084  {
1085  return d.second.tableWidgetEdgesIndex == row;
1086  });
1087  QMenu menu;
1088  QAction* deleteAction = menu.addAction("Delete Edge");
1089 
1090  if (menu.exec(QCursor::pos()) == deleteAction)
1091  {
1092  ARMARX_CHECK_EXPRESSION(edgeIt != edges.end());
1093  graphSeg->removeEdge(edgeIt->first.first, edgeIt->first.second);
1094  drawScene();
1095  }
1096 }
1097 
1098 bool MouseEventProcessor::eventFilter(QObject* obj, QEvent* event)
1099 {
1100  if (obj == gvw->ui.graphicsViewGraph && event->type() == QEvent::MouseButtonPress)
1101  {
1102  QMouseEvent* me = static_cast<QMouseEvent*>(event);
1103  if (me->button() == Qt::LeftButton)
1104  {
1105  QPointF scenePoint = gvw->ui.graphicsViewGraph->mapToScene(me->pos());
1106  scenePoint.setY(-scenePoint.y()); //not sure why
1107 
1108  float minDist = std::numeric_limits<float>::max();
1109  auto bestIt = gvw->nodes.cend();
1110 
1111  for (auto it = gvw->nodes.cbegin(); it != gvw->nodes.cend(); ++it)
1112  {
1113  float deltaX = it->second.pose->position->x - scenePoint.x();
1114  float deltaY = it->second.pose->position->y - scenePoint.y();
1115  float dist = std::sqrt(deltaX * deltaX + deltaY * deltaY);
1116 
1117  if (dist < minDist)
1118  {
1119  minDist = dist;
1120  bestIt = it;
1121  }
1122  }
1123 
1124  if (bestIt != gvw->nodes.cend())
1125  {
1126  gvw->nodeDoubleClicked(bestIt->first);
1127  }
1128  }
1129  }
1130  else if (event->type() == QEvent::Resize)
1131  {
1132  gvw->adjustView();
1133  }
1134  return QObject::eventFilter(obj, event);
1135 }
GfxTL::sqrt
VectorXD< D, T > sqrt(const VectorXD< D, T > &a)
Definition: VectorXD.h:662
memoryx::GraphVisualizerWidget::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: GraphVisualizerGuiPlugin.cpp:168
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
memoryx::GraphVisualizerWidget::ui
Ui::GraphVisualizerGuiPlugin ui
Contains the ui.
Definition: GraphVisualizerGuiPlugin.h:295
DEFAULT_DEBUG_DRAWER_NAME
#define DEFAULT_DEBUG_DRAWER_NAME
Definition: GraphVisualizerGuiPlugin.cpp:64
memoryx::GraphVisualizerGraphicsEllipseItem
Required to override the double click event.
Definition: GraphVisualizerGuiPlugin.h:522
armarx::VariantType::FramedPose
const VariantTypeId FramedPose
Definition: FramedPose.h:37
VirtualRobot
Definition: FramedPose.h:43
memoryx::GraphVisualizerWidget::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent=0) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: GraphVisualizerGuiPlugin.cpp:246
memoryx::GraphVisualizerGraphicsLineItem
Required to override the double click event.
Definition: GraphVisualizerGuiPlugin.h:557
memoryx::MouseEventProcessor
Definition: GraphVisualizerGuiPlugin.h:590
memoryx::GraphVisualizerWidget::resetHighlight
void resetHighlight(const Ice::Current &=Ice::emptyCurrent) override
Definition: GraphVisualizerGuiPlugin.cpp:457
memoryx::GraphVisualizerWidget::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: GraphVisualizerGuiPlugin.cpp:273
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
DEFAULT_DEBUG_DRAWER_LAYER_NAME
#define DEFAULT_DEBUG_DRAWER_LAYER_NAME
Definition: GraphVisualizerGuiPlugin.cpp:65
memoryx::GraphVisualizerWidget::GraphVisualizerWidget
GraphVisualizerWidget()
Definition: GraphVisualizerGuiPlugin.cpp:141
GraphVisualizerGuiPlugin.h
memoryx::GraphVisualizerWidget::addNode
void addNode(const GraphNodeBasePtr &node, const Ice::Current &=Ice::emptyCurrent) override
Definition: GraphVisualizerGuiPlugin.cpp:342
memoryx::GraphVisualizerWidget::NodeId
const std::string NodeId
The type of node ids.
Definition: GraphVisualizerGuiPlugin.h:225
IceInternal::Handle< FramedPose >
memoryx::VariantType::GraphNode
const armarx::VariantTypeId GraphNode
Definition: GraphNode.h:39
GraphVisualizerConfigDialog.h
armarx::abs
std::vector< T > abs(const std::vector< T > &v)
Definition: VectorHelpers.h:253
memoryx::GraphVisualizerWidget::highlightEdge
void highlightEdge(const std::string &node1Id, const std::string &node2Id, bool highlighted=true, const Ice::Current &=Ice::emptyCurrent) override
Definition: GraphVisualizerGuiPlugin.cpp:618
M_PI
#define M_PI
Definition: MathTools.h:17
DEFAULT_PRIOR_KNOWLEDGE_NAME
#define DEFAULT_PRIOR_KNOWLEDGE_NAME
Definition: GraphVisualizerGuiPlugin.cpp:63
memoryx::GraphVisualizerWidget::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: GraphVisualizerGuiPlugin.cpp:267
memoryx::GraphVisualizerWidget::hasNode
bool hasNode(const std::string &id, const Ice::Current &=Ice::emptyCurrent) override
Definition: GraphVisualizerGuiPlugin.h:267
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
memoryx::GraphVisualizerWidget::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: GraphVisualizerGuiPlugin.cpp:259
iceName
std::string iceName(const GraphVisualizerWidget::EdgeId &edge)
Returns the name used on the debug layer.
Definition: GraphVisualizerGuiPlugin.cpp:116
memoryx::GraphVisualizerWidget::clearGraph
void clearGraph(const Ice::Current &=Ice::emptyCurrent) override
Definition: GraphVisualizerGuiPlugin.cpp:429
armarx::Vector3
The Vector3 class.
Definition: Pose.h:112
GraphNode.h
memoryx::GraphVisualizerWidget::highlightNode
void highlightNode(const std::string &nodeId, bool highlighted=true, const Ice::Current &=Ice::emptyCurrent) override
Definition: GraphVisualizerGuiPlugin.cpp:635
memoryx::GraphVisualizerWidget::redraw
void redraw(const Ice::Current &=Ice::emptyCurrent) override
Definition: GraphVisualizerGuiPlugin.cpp:689
max
T max(T t1, T t2)
Definition: gdiam.h:48
memoryx::GraphVisualizerWidget::saveAutomaticSettings
virtual void saveAutomaticSettings()
Definition: GraphVisualizerGuiPlugin.cpp:284
memoryx::GraphVisualizerWidget::hasEdge
bool hasEdge(const std::string &node1, const std::string &node2, const Ice::Current &=Ice::emptyCurrent) override
Definition: GraphVisualizerGuiPlugin.h:262
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
memoryx::GraphVisualizerWidget::loadAutomaticSettings
virtual void loadAutomaticSettings()
Definition: GraphVisualizerGuiPlugin.cpp:279
memoryx::GraphVisualizerWidget::refreshGraph
void refreshGraph()
Definition: GraphVisualizerGuiPlugin.cpp:713
armarx::ManagedIceObject::offeringTopic
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
Definition: ManagedIceObject.cpp:290
memoryx::GraphVisualizerWidget::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: GraphVisualizerGuiPlugin.cpp:242
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:41
memoryx::GraphVisualizerWidget::tableWidgetEdgesCustomContextMenu
void tableWidgetEdgesCustomContextMenu(QPoint pos)
Definition: GraphVisualizerGuiPlugin.cpp:1080
memoryx::GraphVisualizerGuiPlugin::GraphVisualizerGuiPlugin
GraphVisualizerGuiPlugin()
Definition: GraphVisualizerGuiPlugin.cpp:134
angle
double angle(const Point &a, const Point &b, const Point &c)
Definition: point.hpp:100
memoryx::GraphVisualizerConfigDialog
Definition: GraphVisualizerConfigDialog.h:37
memoryx::MouseEventProcessor::gvw
GraphVisualizerWidget * gvw
Definition: GraphVisualizerGuiPlugin.h:596
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:195
memoryx::GraphVisualizerWidget::tableWidgetNodesCustomContextMenu
void tableWidgetNodesCustomContextMenu(QPoint pos)
Definition: GraphVisualizerGuiPlugin.cpp:1062
min
T min(T t1, T t2)
Definition: gdiam.h:42
memoryx::GraphVisualizerWidget::~GraphVisualizerWidget
~GraphVisualizerWidget() override
Definition: GraphVisualizerGuiPlugin.cpp:163
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
memoryx::MouseEventProcessor::eventFilter
bool eventFilter(QObject *obj, QEvent *event) override
Definition: GraphVisualizerGuiPlugin.cpp:1098
armarx::ManagedIceObject::getProxy
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
Definition: ManagedIceObject.cpp:393
memoryx::GraphVisualizerWidget::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: GraphVisualizerGuiPlugin.cpp:177
ArmarXDataPath.h
armarx::EdgeId
boost::graph_traits< Graph >::edge_descriptor EdgeId
Definition: Common.h:66
armarx::ManagedIceObject::usingProxy
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Definition: ManagedIceObject.cpp:151
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
memoryx::GraphVisualizerWidget::clearEdges
void clearEdges(const Ice::Current &=Ice::emptyCurrent) override
Definition: GraphVisualizerGuiPlugin.cpp:411
memoryx::GraphVisualizerWidget::addEdge
void addEdge(const std::string &node1Id, const std::string &node2Id, const Ice::Current &=Ice::emptyCurrent) override
Definition: GraphVisualizerGuiPlugin.cpp:289
memoryx::GraphVisualizerWidget::EdgeId
const std::pair< const std::string, const std::string > EdgeId
The type of edge ids.
Definition: GraphVisualizerGuiPlugin.h:230