27 #include <SimoxUtility/algorithm/string/string_tools.h>
28 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualization.h>
29 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
31 #include <Inventor/nodes/SoCube.h>
32 #include <Inventor/nodes/SoMaterial.h>
33 #include <Inventor/nodes/SoUnits.h>
41 static const std::string DEBUG_LAYER_NAME{
"debug"};
43 EntityDrawerComponent::EntityDrawerComponent() : DebugDrawerComponent()
94 <<
" at layer " << d.layerName;
105 SoSeparator* sep = layer.addedCustomVisualizations[d.name];
107 if (!sep || sep->getNumChildren() < 2)
113 SoMaterial* m =
dynamic_cast<SoMaterial*
>(sep->getChild(0));
121 if (d.
color.isNone())
123 m->setOverride(
false);
130 if (d.
color.transparency == 1)
132 m->diffuseColor.setIgnored(FALSE);
133 m->setOverride(FALSE);
137 m->transparency = d.
color.transparency;
138 m->diffuseColor.setIgnored(TRUE);
139 m->setOverride(TRUE);
146 m->ambientColor = SbColor(0, 0, 0);
148 m->setOverride(
true);
160 std::string entryName =
"__" + layerName +
"__" + name +
"__";
173 auto& layer =
layers.at(layerName);
175 if (layer.addedCustomVisualizations.find(name) == layer.addedCustomVisualizations.end())
180 layer.mainNode->removeChild(layer.addedCustomVisualizations[name]);
181 layer.addedCustomVisualizations.erase(name);
187 DebugDrawerComponent::onInitComponent();
189 std::string commonStorageName = getProperty<std::string>(
"CommonStorageName").getValue();
192 std::string priorKnowledgeName = getProperty<std::string>(
"PriorKnowledgeName").getValue();
199 DebugDrawerComponent::onConnectComponent();
201 std::string commonStorageName = getProperty<std::string>(
"CommonStorageName").getValue();
202 CommonStorageInterfacePrx commonStoragePrx =
203 getProxy<CommonStorageInterfacePrx>(commonStorageName);
205 if (commonStoragePrx)
214 std::string priorKnowledgeName = getProperty<std::string>(
"PriorKnowledgeName").getValue();
215 ARMARX_INFO <<
"Connecting to prior knowldege with name:" << priorKnowledgeName;
223 DebugDrawerComponent::onDisconnectComponent();
229 DebugDrawerComponent::onExitComponent();
234 const std::string& objectName,
235 const Ice::Current&
c)
238 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
240 d.layerName = layerName;
247 const std::string& objectName,
248 const armarx::DrawColor& color,
249 const Ice::Current&
c)
252 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
258 d.layerName = layerName;
261 if (color.a == 0 && color.b == 0 && color.r == 0 && color.g == 0)
263 d.
color = VirtualRobot::VisualizationFactory::Color::None();
276 const std::string& objectName,
278 const Ice::Current&
c)
281 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
296 d.layerName = layerName;
304 const std::string& objectName,
305 const armarx::PoseBasePtr& globalPose,
306 const Ice::Current&
c)
309 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
315 d.
globalPose = armarx::PosePtr::dynamicCast(globalPose)->toEigen();
317 d.layerName = layerName;
324 const std::string& objectName,
325 const ObjectClassBasePtr& objectClassBase,
326 const armarx::PoseBasePtr& globalPose,
327 const Ice::Current&
c)
330 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
333 d.
objectClass = ObjectClassPtr::dynamicCast(objectClassBase);
334 d.
globalPose = armarx::PosePtr::dynamicCast(globalPose)->toEigen();
335 d.layerName = layerName;
344 const std::string& customObjectName,
345 const std::string& objectClassName,
346 const armarx::PoseBasePtr& globalPose,
347 const Ice::Current&
c)
350 if (!objectClassBase)
352 ARMARX_WARNING <<
"An object with class name '" << objectClassName
353 <<
"' does not exist!";
357 std::string entryName =
"__" + layerName +
"__" + customObjectName +
"__";
360 d.
objectClass = ObjectClassPtr::dynamicCast(objectClassBase);
361 d.
globalPose = armarx::PosePtr::dynamicCast(globalPose)->toEigen();
362 d.layerName = layerName;
363 d.name = customObjectName;
375 std::string entryName =
"__" + d.layerName +
"__" + d.name +
"__";
391 ARMARX_ERROR <<
"Invalid object class; could not create object with instance name "
400 VirtualRobot::ManipulationObjectPtr mo = sw->getManipulationObject();
404 ARMARX_ERROR <<
"Could not retrieve manipulation object of object class "
405 << objectClass->getName();
415 ARMARX_LOG <<
"Loaded manipulation object " << mo->getName() <<
" of class "
416 << objectClass->getName();
420 result =
objectCache[objectClass->getId()]->clone(d.name);
421 ARMARX_LOG <<
"Using manipulation object " << result->getName() <<
" of class "
422 << objectClass->getName() <<
" from cache";
434 SoSeparator* sep =
new SoSeparator;
435 layer.mainNode->addChild(sep);
437 SoMaterial* m =
new SoMaterial;
438 m->setOverride(
false);
441 auto objVisu = result->getVisualization<CoinVisualization>(VirtualRobot::SceneObject::Full);
442 SoNode* sepo = objVisu->getCoinVisualization();
446 layer.addedCustomVisualizations[d.name] = sep;
455 std::string entryName =
"__" + layerName +
"__";