diff Sources/Plugin.cpp @ 2:2bdb9acb7dcf

added STL viewer button at instance level too
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 18 Jul 2023 09:41:31 +0200
parents 0f03a8a0bd6f
children 0fb06c6a6c87
line wrap: on
line diff
--- a/Sources/Plugin.cpp	Mon Jul 17 18:54:31 2023 +0200
+++ b/Sources/Plugin.cpp	Tue Jul 18 09:41:31 2023 +0200
@@ -1212,9 +1212,24 @@
       else
       {
         std::string description;
+
+        if (parsed.GetTagValue(description, Orthanc::DICOM_TAG_SERIES_DESCRIPTION))
+        {
+          description += ": ";
+        }
+        else
+        {
+          description.clear();
+        }
+
+        bool first = true;
         for (std::set<std::string>::const_iterator it = roiNames.begin(); it != roiNames.end(); ++it)
         {
-          if (!description.empty())
+          if (first)
+          {
+            first = false;
+          }
+          else
           {
             description += ", ";
           }
@@ -1279,12 +1294,6 @@
     OrthancPluginSetDescription(context, "STL plugin for Orthanc.");
 
     OrthancPlugins::RegisterRestCallback<ServeFile>("/stl/app/(.*)", true);
-
-    // Extend the default Orthanc Explorer with custom JavaScript for STL
-    std::string explorer;
-    Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER);
-    OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str());
-
     OrthancPlugins::RegisterRestCallback<ListStructures>("/stl/rt-struct/([0-9a-f-]+)", true);
 
     if (hasCreateDicomStl_)
@@ -1292,6 +1301,19 @@
       OrthancPlugins::RegisterRestCallback<Encode>("/stl/encode", true);
     }
 
+    // Extend the default Orthanc Explorer with custom JavaScript for STL
+    std::string explorer;
+
+    {
+      Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER);
+
+      std::map<std::string, std::string> dictionary;
+      dictionary["HAS_CREATE_DICOM_STL"] = (hasCreateDicomStl_ ? "true" : "false");
+      explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary);
+
+      OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str());
+    }
+
     return 0;
   }