diff --git a/DicomRtImportExport/SubjectHierarchyPlugins/CMakeLists.txt b/DicomRtImportExport/SubjectHierarchyPlugins/CMakeLists.txt index 98b9151a3..089e88a16 100644 --- a/DicomRtImportExport/SubjectHierarchyPlugins/CMakeLists.txt +++ b/DicomRtImportExport/SubjectHierarchyPlugins/CMakeLists.txt @@ -7,6 +7,7 @@ set(${KIT}_EXPORT_DIRECTIVE "Q_SLICER_${MODULE_NAME_UPPER}_SUBJECT_HIERARCHY_PLU set(${KIT}_INCLUDE_DIRECTORIES ${SlicerRtCommon_INCLUDE_DIRS} ${vtkSlicerPlanarImageModuleLogic_INCLUDE_DIRS} + ${vtkSlicerBeamsModuleMRML_INCLUDE_DIRS} ${vtkSlicerSubjectHierarchyModuleLogic_INCLUDE_DIRS} ${qSlicerSubjectHierarchyModuleWidgets_INCLUDE_DIRS} ${MRMLCore_INCLUDE_DIRS} @@ -61,4 +62,4 @@ SlicerMacroBuildModuleQtLibrary( TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES} RESOURCES ${${KIT}_RESOURCES} WRAP_PYTHONQT - ) \ No newline at end of file + ) diff --git a/DicomRtImportExport/SubjectHierarchyPlugins/qSlicerSubjectHierarchyRtDoseVolumePlugin.cxx b/DicomRtImportExport/SubjectHierarchyPlugins/qSlicerSubjectHierarchyRtDoseVolumePlugin.cxx index 1bcf7bb19..8edf41985 100644 --- a/DicomRtImportExport/SubjectHierarchyPlugins/qSlicerSubjectHierarchyRtDoseVolumePlugin.cxx +++ b/DicomRtImportExport/SubjectHierarchyPlugins/qSlicerSubjectHierarchyRtDoseVolumePlugin.cxx @@ -35,6 +35,7 @@ #include #include #include +#include // VTK includes #include @@ -331,6 +332,30 @@ void qSlicerSubjectHierarchyRtDoseVolumePlugin::convertCurrentNodeToRtDoseVolume std::string doseUnitNameInStudy = shNode->GetItemAttribute(studyItemID, vtkSlicerRtCommon::DICOMRTIMPORT_DOSE_UNIT_NAME_ATTRIBUTE_NAME); std::string doseUnitValueInStudy = shNode->GetItemAttribute(studyItemID, vtkSlicerRtCommon::DICOMRTIMPORT_DOSE_UNIT_VALUE_ATTRIBUTE_NAME); + bool referencedInstanceIsSet = false; + std::vector< vtkIdType > studyChildrenIDs; + shNode->GetItemChildren(studyItemID, studyChildrenIDs); + // find RTPlan node and get InstanceUID of that plan to use it as ReferencedInstanceUID for converted RTDose + for (int childItemID : studyChildrenIDs) + { + vtkMRMLRTPlanNode* planNode = vtkMRMLRTPlanNode::SafeDownCast(shNode->GetItemDataNode(childItemID)); + if (planNode) + { + std::string planInstanceUID = shNode->GetItemUID(childItemID, vtkMRMLSubjectHierarchyConstants::GetDICOMInstanceUIDName()); + if (!planInstanceUID.empty()) + { + shNode->SetItemAttribute(currentItemID, vtkMRMLSubjectHierarchyConstants::GetDICOMReferencedInstanceUIDsAttributeName(), planInstanceUID.c_str()); + referencedInstanceIsSet = true; + } + } + } + // no RTPlan Instance UID, use Study series instance UID instead + if (!referencedInstanceIsSet) + { + std::string studyInstanceUID = shNode->GetItemAttribute(studyItemID, vtkMRMLSubjectHierarchyConstants::GetDICOMStudyInstanceUIDAttributeName()); + shNode->SetItemAttribute(currentItemID, vtkMRMLSubjectHierarchyConstants::GetDICOMReferencedInstanceUIDsAttributeName(), studyInstanceUID.c_str()); + } + // Show dialogs asking about dose unit name and value bool ok; QString defaultDoseUnitName(!doseUnitNameInStudy.empty() ? doseUnitNameInStudy.c_str() : "Gy");