MCPcopy Create free account
hub / github.com/MITK/MITK / DecorateNodeWithProperties

Method DecorateNodeWithProperties

Modules/SceneSerialization/src/mitkSceneReaderV1.cpp:403–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401}
402
403bool mitk::SceneReaderV1::DecorateNodeWithProperties(DataNode *node,
404 const tinyxml2::XMLElement *nodeElement,
405 const std::string &workingDirectory)
406{
407 assert(node);
408 assert(nodeElement);
409 bool error(false);
410
411 for (auto *properties = nodeElement->FirstChildElement("properties"); properties != nullptr;
412 properties = properties->NextSiblingElement("properties"))
413 {
414 const char *propertiesfilea(properties->Attribute("file"));
415 std::string propertiesfile(propertiesfilea ? propertiesfilea : "");
416
417 const char *renderwindowa(properties->Attribute("renderwindow"));
418 std::string renderwindow(renderwindowa ? renderwindowa : "");
419
420 PropertyList::Pointer propertyList =
421 node->GetPropertyList(renderwindow); // DataNode implementation always returns a propertylist
422 ClearNodePropertyListWithExceptions(*node, *propertyList);
423
424 // use deserializer to construct new properties
425 PropertyListDeserializer::Pointer deserializer = PropertyListDeserializer::New();
426
427 deserializer->SetFilename(workingDirectory + Poco::Path::separator() + propertiesfile);
428 bool success = deserializer->Deserialize();
429 error |= !success;
430 PropertyList::Pointer readProperties = deserializer->GetOutput();
431
432 if (readProperties.IsNotNull())
433 {
434 // Drop transient properties (e.g. the "selected" UI flag) that may be
435 // present in older scene files, so reloading does not resurrect runtime
436 // or UI state. Transience is decided per the node's BaseData type.
437 mitk::SceneReaderHelpers::StripTransientProperties(*readProperties, node->GetData());
438
439 propertyList->ConcatenatePropertyList(readProperties, true); // true = replace
440 }
441 else
442 {
443 MITK_ERROR << "Property list reader did not return a property list. This is an implementation error. Please tell "
444 "your developer.";
445 error = true;
446 }
447 }
448
449 return !error;
450}

Callers

nothing calls this directly

Calls 8

StripTransientPropertiesFunction · 0.85
IsNotNullMethod · 0.80
NewFunction · 0.50
GetPropertyListMethod · 0.45
DeserializeMethod · 0.45
GetOutputMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected