From 7b48180e444331a4965db681ecf872a7cb81bef8 Mon Sep 17 00:00:00 2001 From: Peter Kaiser <peter.kaiser@kit.edu> Date: Fri, 10 Jun 2016 11:33:51 +0200 Subject: [PATCH] DebugDrawer: Properly handle selections in subnodes --- .../DebugDrawer/DebugDrawerComponent.cpp | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/source/RobotAPI/components/DebugDrawer/DebugDrawerComponent.cpp b/source/RobotAPI/components/DebugDrawer/DebugDrawerComponent.cpp index 919276998..32a47f48b 100644 --- a/source/RobotAPI/components/DebugDrawer/DebugDrawerComponent.cpp +++ b/source/RobotAPI/components/DebugDrawer/DebugDrawerComponent.cpp @@ -261,29 +261,41 @@ namespace armarx { SoPath* path = selectionNode->getPath(i); - std::string name = path->getTail()->getName().getString(); - if (name.length() > 0 && name.find(SELECTION_NAME_PREFIX) == 0) + for (unsigned int j = 0; j < path->getLength(); j++) { - int index = name.rfind(SELECTION_NAME_SPLITTER); - name = name.substr(index + strlen(SELECTION_NAME_SPLITTER)); + SoNode* node = path->getNodeFromTail(j); + if (!node) + { + continue; + } - // Check if selected element is 'selectable' - for (auto& l : layers) + std::string name = node->getName().getString(); + if (name.length() > 0 && name.find(SELECTION_NAME_PREFIX) == 0) { - std::string layer = l.first; - if (layers[layer].addedBoxVisualizations.find(name) != layers[layer].addedBoxVisualizations.end() - || layers[layer].addedTextVisualizations.find(name) != layers[layer].addedTextVisualizations.end() - || layers[layer].addedSphereVisualizations.find(name) != layers[layer].addedSphereVisualizations.end() - || layers[layer].addedCylinderVisualizations.find(name) != layers[layer].addedCylinderVisualizations.end() - || layers[layer].addedPolygonVisualizations.find(name) != layers[layer].addedPolygonVisualizations.end()) - { - DebugDrawerSelectionElement e; - e.layerName = layer; - e.elementName = name; + int index = name.rfind(SELECTION_NAME_SPLITTER); + name = name.substr(index + strlen(SELECTION_NAME_SPLITTER)); - selectedElements.push_back(e); - break; + // Check if selected element is 'selectable' + for (auto& l : layers) + { + std::string layer = l.first; + if (layers[layer].addedBoxVisualizations.find(name) != layers[layer].addedBoxVisualizations.end() + || layers[layer].addedTextVisualizations.find(name) != layers[layer].addedTextVisualizations.end() + || layers[layer].addedSphereVisualizations.find(name) != layers[layer].addedSphereVisualizations.end() + || layers[layer].addedCylinderVisualizations.find(name) != layers[layer].addedCylinderVisualizations.end() + || layers[layer].addedPolygonVisualizations.find(name) != layers[layer].addedPolygonVisualizations.end()) + { + DebugDrawerSelectionElement e; + e.layerName = layer; + e.elementName = name; + + selectedElements.push_back(e); + break; + } } + + // We only process the first node that matches the naming scheme + break; } } } -- GitLab