| 622 | } |
| 623 | |
| 624 | void mitk::Label::SetDICOMCodeSequenceAsProperties(const PropertyKeyPath& basePath, |
| 625 | const DICOMCodeSequence& code, |
| 626 | bool withModifiers) |
| 627 | { |
| 628 | PropertyKeyPath valuePath = basePath; |
| 629 | valuePath.AddElement(LabelPropertyConstants::GetValuePropertySubName()); |
| 630 | |
| 631 | PropertyKeyPath schemePath = basePath; |
| 632 | schemePath.AddElement(LabelPropertyConstants::GetSchemePropertySubName()); |
| 633 | |
| 634 | PropertyKeyPath meaningPath = basePath; |
| 635 | meaningPath.AddElement(LabelPropertyConstants::GetMeaningPropertySubName()); |
| 636 | |
| 637 | SetStringProperty(PropertyKeyPathToPropertyName(valuePath).c_str(), code.GetValue().c_str()); |
| 638 | SetStringProperty(PropertyKeyPathToPropertyName(schemePath).c_str(), code.GetScheme().c_str()); |
| 639 | SetStringProperty(PropertyKeyPathToPropertyName(meaningPath).c_str(), code.GetMeaning().c_str()); |
| 640 | |
| 641 | // Handle modifiers if requested |
| 642 | if (withModifiers) |
| 643 | { |
| 644 | const DICOMCodeSequenceWithModifiers* codeWithMods = dynamic_cast<const DICOMCodeSequenceWithModifiers*>(&code); |
| 645 | if (codeWithMods != nullptr) |
| 646 | { |
| 647 | // Remove all existing modifiers first |
| 648 | PropertyKeyPath modifierSearchPath = basePath; |
| 649 | modifierSearchPath.AddAnySelection(LabelPropertyConstants::GetModifierPropertySubName()); |
| 650 | modifierSearchPath.AddAnyElement(); |
| 651 | |
| 652 | std::string modifierPattern = PropertyKeyPathToPropertyRegEx(modifierSearchPath); |
| 653 | std::regex modifierRegex(modifierPattern); |
| 654 | |
| 655 | auto propertyKeys = this->GetPropertyKeys(); |
| 656 | for (const auto& key : propertyKeys) |
| 657 | { |
| 658 | if (std::regex_match(key, modifierRegex)) |
| 659 | { |
| 660 | this->RemoveProperty(key); |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | // Set new modifiers |
| 665 | const auto& modifiers = codeWithMods->GetModifiers(); |
| 666 | for (std::size_t i = 0; i < modifiers.size(); ++i) |
| 667 | { |
| 668 | PropertyKeyPath modifierPath = basePath; |
| 669 | modifierPath.AddSelection(LabelPropertyConstants::GetModifierPropertySubName(), i); |
| 670 | SetDICOMCodeSequenceAsProperties(modifierPath, modifiers[i], false); |
| 671 | } |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | std::optional<mitk::DICOMCodeSequence> mitk::Label::GetDICOMCodeSequenceFromProperties(const PropertyKeyPath& basePath) const |
| 677 | { |
nothing calls this directly
no test coverage detected