27 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
28 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualization.h>
29 #include <Inventor/nodes/SoUnits.h>
30 #include <Inventor/nodes/SoCube.h>
31 #include <Inventor/nodes/SoMaterial.h>
34 #include <SimoxUtility/algorithm/string/string_tools.h>
41 static const std::string DEBUG_LAYER_NAME
46 EntityDrawerComponent::EntityDrawerComponent():
47 DebugDrawerComponent()
107 SoSeparator* sep = layer.addedCustomVisualizations[d.name];
109 if (!sep || sep->getNumChildren() < 2)
115 SoMaterial* m =
dynamic_cast<SoMaterial*
>(sep->getChild(0));
123 if (d.
color.isNone())
125 m->setOverride(
false);
132 if (d.
color.transparency == 1)
134 m->diffuseColor.setIgnored(FALSE);
135 m->setOverride(FALSE);
139 m->transparency = d.
color.transparency;
140 m->diffuseColor.setIgnored(TRUE);
141 m->setOverride(TRUE);
148 m->ambientColor = SbColor(0, 0, 0);
150 m->setOverride(
true);
161 std::string entryName =
"__" + layerName +
"__" + name +
"__";
174 auto& layer =
layers.at(layerName);
176 if (layer.addedCustomVisualizations.find(name) == layer.addedCustomVisualizations.end())
181 layer.mainNode->removeChild(layer.addedCustomVisualizations[name]);
182 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();
198 DebugDrawerComponent::onConnectComponent();
200 std::string commonStorageName = getProperty<std::string>(
"CommonStorageName").getValue();
201 CommonStorageInterfacePrx commonStoragePrx = getProxy<CommonStorageInterfacePrx>(commonStorageName);
203 if (commonStoragePrx)
212 std::string priorKnowledgeName = getProperty<std::string>(
"PriorKnowledgeName").getValue();
213 ARMARX_INFO <<
"Connecting to prior knowldege with name:" << priorKnowledgeName;
220 DebugDrawerComponent::onDisconnectComponent();
225 DebugDrawerComponent::onExitComponent();
231 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
233 d.layerName = layerName;
241 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
247 d.layerName = layerName;
250 if (color.a == 0 && color.b == 0 && color.r == 0 && color.g == 0)
252 d.
color = VirtualRobot::VisualizationFactory::Color::None();
265 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
280 d.layerName = layerName;
289 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
295 d.
globalPose = armarx::PosePtr::dynamicCast(globalPose)->toEigen();
297 d.layerName = layerName;
302 void EntityDrawerComponent::setObjectVisu(
const std::string& layerName,
const std::string& objectName,
const ObjectClassBasePtr& objectClassBase,
const armarx::PoseBasePtr& globalPose,
const Ice::Current&
c)
305 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
308 d.
objectClass = ObjectClassPtr::dynamicCast(objectClassBase);
309 d.
globalPose = armarx::PosePtr::dynamicCast(globalPose)->toEigen();
310 d.layerName = layerName;
320 if (!objectClassBase)
322 ARMARX_WARNING <<
"An object with class name '" << objectClassName <<
"' does not exist!";
326 std::string entryName =
"__" + layerName +
"__" + customObjectName +
"__";
329 d.
objectClass = ObjectClassPtr::dynamicCast(objectClassBase);
330 d.
globalPose = armarx::PosePtr::dynamicCast(globalPose)->toEigen();
331 d.layerName = layerName;
332 d.name = customObjectName;
343 std::string entryName =
"__" + d.layerName +
"__" + d.name +
"__";
359 ARMARX_ERROR <<
"Invalid object class; could not create object with instance name " << d.name;
366 VirtualRobot::ManipulationObjectPtr mo = sw->getManipulationObject();
370 ARMARX_ERROR <<
"Could not retrieve manipulation object of object class " << objectClass->getName();
380 ARMARX_LOG <<
"Loaded manipulation object " << mo->getName() <<
" of class " << objectClass->getName();
384 result =
objectCache[objectClass->getId()]->clone(d.name);
385 ARMARX_LOG <<
"Using manipulation object " << result->getName() <<
" of class " << objectClass->getName() <<
" from cache";
399 SoSeparator* sep =
new SoSeparator;
400 layer.mainNode->addChild(sep);
402 SoMaterial* m =
new SoMaterial;
403 m->setOverride(
false);
406 auto objVisu = result->getVisualization<CoinVisualization>(VirtualRobot::SceneObject::Full);
407 SoNode* sepo = objVisu->getCoinVisualization();
411 layer.addedCustomVisualizations[d.name] = sep;
420 std::string entryName =
"__" + layerName +
"__";