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

Method SavePropertyList

Modules/SceneSerialization/src/mitkSceneIO.cpp:586–652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

584}
585
586tinyxml2::XMLElement *mitk::SceneIO::SavePropertyList(tinyxml2::XMLDocument &doc, const IPropertyTransience *transience, PropertyList *propertyList, const BaseData *nodeData, const std::string &filenamehint)
587{
588 assert(propertyList);
589
590 // Drop transient DataNode properties (e.g. the "selected" UI flag) so they are
591 // not written to the scene file. Transience is decided per the node's BaseData
592 // type; data-less nodes (nodeData == nullptr) still match rules registered for
593 // mitk::BaseData. Only build a filtered copy when at least one property is
594 // actually transient, so the common case serializes the list as-is.
595 PropertyList::Pointer persistable;
596 if (transience != nullptr)
597 {
598 bool anyTransient = false;
599 for (const auto &property : *propertyList->GetMap())
600 {
601 if (transience->IsTransient(nodeData, property.first))
602 {
603 anyTransient = true;
604 break;
605 }
606 }
607
608 if (anyTransient)
609 {
610 persistable = PropertyList::New();
611
612 for (const auto &property : *propertyList->GetMap())
613 {
614 if (!transience->IsTransient(nodeData, property.first))
615 persistable->SetProperty(property.first, property.second);
616 }
617
618 if (persistable->IsEmpty())
619 return nullptr;
620
621 propertyList = persistable;
622 }
623 }
624
625 // - TODO what to do about shared properties (same object in two lists or behind several keys)?
626 auto *element = doc.NewElement("properties");
627
628 // construct name of serializer class
629 PropertyListSerializer::Pointer serializer = PropertyListSerializer::New();
630
631 serializer->SetPropertyList(propertyList);
632 serializer->SetFilenameHint(filenamehint);
633 std::string defaultLocale_WorkingDirectory = Poco::Path::transcode( m_WorkingDirectory );
634 serializer->SetWorkingDirectory(defaultLocale_WorkingDirectory);
635 try
636 {
637 std::string writtenfilename = serializer->Serialize();
638 element->SetAttribute("file", writtenfilename.c_str());
639 PropertyList::Pointer failedProperties = serializer->GetFailedProperties();
640 if (failedProperties.IsNotNull())
641 {
642 // move failed properties to global list
643 m_FailedProperties->ConcatenatePropertyList(failedProperties, true);

Callers

nothing calls this directly

Calls 11

IsTransientMethod · 0.80
IsNotNullMethod · 0.80
whatMethod · 0.80
NewFunction · 0.50
SetPropertyMethod · 0.45
IsEmptyMethod · 0.45
SetPropertyListMethod · 0.45
SerializeMethod · 0.45
GetFailedPropertiesMethod · 0.45
GetNameOfClassMethod · 0.45

Tested by

no test coverage detected