# HG changeset patch # User Sebastien Jodogne # Date 1689666091 -7200 # Node ID 2bdb9acb7dcfeaff70f0810f6d58b8cdc0e671de # Parent 0f03a8a0bd6f3d6f3024d4c5b0a03ae53ef76e23 added STL viewer button at instance level too diff -r 0f03a8a0bd6f -r 2bdb9acb7dcf Sources/OrthancExplorer.js --- a/Sources/OrthancExplorer.js Mon Jul 17 18:54:31 2023 +0200 +++ b/Sources/OrthancExplorer.js Tue Jul 18 09:41:31 2023 +0200 @@ -22,39 +22,66 @@ **/ +const SOP_CLASS_UID_STL = '1.2.840.10008.5.1.4.1.1.104.3'; + +function AddOpenStlViewerButton(instanceId, id, parent) { + var b = $('') + .attr('id', id) + .attr('data-role', 'button') + .attr('href', '#') + .attr('data-icon', 'search') + .attr('data-theme', 'e') + .text('STL viewer') + .button(); + + b.insertAfter($('#' + parent)); + b.click(function() { + if ($.mobile.pageData) { + window.open('../stl/app/viewer.html?instance=' + instanceId); + } + }); +} + + $('#series').live('pagebeforeshow', function() { var seriesId = $.mobile.pageData.uuid; - $('#stl-button').remove(); + $('#stl-button-series').remove(); // Test whether this is a whole-slide image by check the SOP Class // UID of one instance of the series GetResource('/series/' + seriesId, function(series) { - var instanceId = series['Instances'][0]; - - $.ajax({ - url: '/instances/' + instanceId + '/metadata/SopClassUid', - success: function(sopClassUid) { - if (sopClassUid == '1.2.840.10008.5.1.4.1.1.104.3') { + if (series['Instances'].length == 1) { + var instanceId = series['Instances'][0]; - // This is an "Encapsulated STL Storage" IOD, register the button - var b = $('') - .attr('id', 'stl-button') - .attr('data-role', 'button') - .attr('href', '#') - .attr('data-icon', 'search') - .attr('data-theme', 'e') - .text('STL viewer') - .button(); - - b.insertAfter($('#series-info')); - b.click(function() { - if ($.mobile.pageData) { - window.open('../stl/app/viewer.html?instance=' + instanceId); - } - }); + $.ajax({ + url: '/instances/' + instanceId + '/metadata/SopClassUid', + success: function(sopClassUid) { + if (sopClassUid == SOP_CLASS_UID_STL) { + // This is an "Encapsulated STL Storage" IOD, register the button + AddOpenStlViewerButton(instanceId, 'stl-button-series', 'series-info'); + } } - } - }); + }); + } }); }); + + +$('#instance').live('pagebeforeshow', function() { + var instanceId = $.mobile.pageData.uuid; + + $('#stl-button-instance').remove(); + + // Test whether this is a whole-slide image by check the SOP Class + // UID of one instance of the series + $.ajax({ + url: '/instances/' + instanceId + '/metadata/SopClassUid', + success: function(sopClassUid) { + if (sopClassUid == SOP_CLASS_UID_STL) { + // This is an "Encapsulated STL Storage" IOD, register the button + AddOpenStlViewerButton(instanceId, 'stl-button-instance', 'instance-info'); + } + } + }); +}); diff -r 0f03a8a0bd6f -r 2bdb9acb7dcf Sources/Plugin.cpp --- 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::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("/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("/stl/rt-struct/([0-9a-f-]+)", true); if (hasCreateDicomStl_) @@ -1292,6 +1301,19 @@ OrthancPlugins::RegisterRestCallback("/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 dictionary; + dictionary["HAS_CREATE_DICOM_STL"] = (hasCreateDicomStl_ ? "true" : "false"); + explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary); + + OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str()); + } + return 0; }