# HG changeset patch # User Sebastien Jodogne # Date 1716024244 -7200 # Node ID f9e49dc63817fa82eac9fc94e584d5c2307b7fd3 # Parent 40a093f90be6931f3b30ab8a06a37ec98efcb852 added configuration option STL.EnableNexus diff -r 40a093f90be6 -r f9e49dc63817 Sources/Plugin.cpp --- a/Sources/Plugin.cpp Sat May 18 11:14:24 2024 +0200 +++ b/Sources/Plugin.cpp Sat May 18 11:24:04 2024 +0200 @@ -1009,9 +1009,9 @@ Orthanc::InitializeFramework("", false); - const bool hasCreateDicomStl_ = OrthancPlugins::CheckMinimalOrthancVersion(1, 12, 1); + const bool hasCreateDicomStl = OrthancPlugins::CheckMinimalOrthancVersion(1, 12, 1); - if (!hasCreateDicomStl_) + if (!hasCreateDicomStl) { LOG(WARNING) << "Your version of Orthanc (" << std::string(context->orthancVersion) << ") is insufficient to create DICOM STL, it should be above 1.12.1"; @@ -1023,44 +1023,56 @@ OrthancPlugins::RegisterRestCallback("/instances/([0-9a-f-]+)/stl", true); OrthancPlugins::RegisterRestCallback("/stl/rt-struct/([0-9a-f-]+)", true); - if (hasCreateDicomStl_) + if (hasCreateDicomStl) { OrthancPlugins::RegisterRestCallback("/stl/encode-rtstruct", true); OrthancPlugins::RegisterRestCallback("/stl/encode-nifti", true); } + OrthancPlugins::OrthancConfiguration globalConfiguration; + OrthancPlugins::OrthancConfiguration configuration; + globalConfiguration.GetSection(configuration, "STL"); + #if ORTHANC_ENABLE_NEXUS == 1 - nexusCache_.SetMaximumSize(512 * 1024 * 1024); // Cache of 512MB for Nexus - OrthancPlugins::RegisterRestCallback("/instances/([0-9a-f-]+)/nexus", true); - OrthancPlugins::RegisterRestCallback("/stl/nexus/(.*)", true); + const bool enableNexus = configuration.GetBooleanValue("EnableNexus", false); - const bool hasCreateNexus_ = OrthancPlugins::CheckMinimalOrthancVersion(1, 9, 4); - - if (hasCreateNexus_) + if (enableNexus) { - OrthancPlugins::RegisterRestCallback("/stl/create-nexus", true); + LOG(INFO) << "Support for Nexus is enabled"; + nexusCache_.SetMaximumSize(512 * 1024 * 1024); // Cache of 512MB for Nexus + OrthancPlugins::RegisterRestCallback("/instances/([0-9a-f-]+)/nexus", true); + OrthancPlugins::RegisterRestCallback("/stl/nexus/(.*)", true); + + const bool hasCreateNexus_ = OrthancPlugins::CheckMinimalOrthancVersion(1, 9, 4); + + if (hasCreateNexus_) + { + OrthancPlugins::RegisterRestCallback("/stl/create-nexus", true); - if (OrthancPluginRegisterPrivateDictionaryTag( - context, ORTHANC_STL_PRIVATE_GROUP, ORTHANC_STL_CREATOR_ELEMENT, OrthancPluginValueRepresentation_LO, - "PrivateCreator", 1, 1, ORTHANC_STL_PRIVATE_CREATOR) != OrthancPluginErrorCode_Success || - OrthancPluginRegisterPrivateDictionaryTag( - context, ORTHANC_STL_PRIVATE_GROUP, ORTHANC_STL_NEXUS_ELEMENT, OrthancPluginValueRepresentation_OB, - "NexusData", 1, 1, ORTHANC_STL_PRIVATE_CREATOR) != OrthancPluginErrorCode_Success) + if (OrthancPluginRegisterPrivateDictionaryTag( + context, ORTHANC_STL_PRIVATE_GROUP, ORTHANC_STL_CREATOR_ELEMENT, OrthancPluginValueRepresentation_LO, + "PrivateCreator", 1, 1, ORTHANC_STL_PRIVATE_CREATOR) != OrthancPluginErrorCode_Success || + OrthancPluginRegisterPrivateDictionaryTag( + context, ORTHANC_STL_PRIVATE_GROUP, ORTHANC_STL_NEXUS_ELEMENT, OrthancPluginValueRepresentation_OB, + "NexusData", 1, 1, ORTHANC_STL_PRIVATE_CREATOR) != OrthancPluginErrorCode_Success) + { + LOG(ERROR) << "Cannot register the private DICOM tags for handling Nexus"; + } + } + else { - LOG(ERROR) << "Cannot register the private DICOM tags for handling Nexus"; + LOG(WARNING) << "Your version of Orthanc (" << std::string(context->orthancVersion) + << ") is insufficient to create DICOM-ize Nexus models, it should be above 1.9.4"; } } else { - LOG(WARNING) << "Your version of Orthanc (" << std::string(context->orthancVersion) - << ") is insufficient to create DICOM-ize Nexus models, it should be above 1.9.4"; + LOG(INFO) << "Support for Nexus is disabled"; } +#else + const bool enableNexus = false; #endif - OrthancPlugins::OrthancConfiguration globalConfiguration; - OrthancPlugins::OrthancConfiguration configuration; - globalConfiguration.GetSection(configuration, "STL"); - // Extend the default Orthanc Explorer with custom JavaScript for STL std::string explorer; @@ -1068,9 +1080,9 @@ Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); std::map dictionary; - dictionary["HAS_CREATE_DICOM_STL"] = (hasCreateDicomStl_ ? "true" : "false"); + dictionary["HAS_CREATE_DICOM_STL"] = (hasCreateDicomStl ? "true" : "false"); dictionary["SHOW_NIFTI_BUTTON"] = (configuration.GetBooleanValue("EnableNIfTI", false) ? "true" : "false"); - dictionary["IS_NEXUS_ENABLED"] = (ORTHANC_ENABLE_NEXUS == 1 ? "true" : "false"); + dictionary["IS_NEXUS_ENABLED"] = (enableNexus ? "true" : "false"); explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary); OrthancPlugins::ExtendOrthancExplorer(ORTHANC_PLUGIN_NAME, explorer);