Mercurial > hg > orthanc-stl
changeset 5:1cc024bb662a
added generate model button in Orthanc Explorer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 18 Jul 2023 12:39:50 +0200 |
parents | 5ee4448a8ff8 |
children | c02d12eb34d4 |
files | Sources/OrthancExplorer.js |
diffstat | 1 files changed, 123 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Sources/OrthancExplorer.js Tue Jul 18 11:30:06 2023 +0200 +++ b/Sources/OrthancExplorer.js Tue Jul 18 12:39:50 2023 +0200 @@ -22,7 +22,8 @@ **/ -const SOP_CLASS_UID_STL = '1.2.840.10008.5.1.4.1.1.104.3'; +const STL_PLUGIN_SOP_CLASS_UID_STL = '1.2.840.10008.5.1.4.1.1.104.3'; +const STL_PLUGIN_SOP_CLASS_UID_RT_STRUCT = '1.2.840.10008.5.1.4.1.1.481.3'; function AddOpenStlViewerButton(instanceId, id, parent) { var b = $('<a>') @@ -43,10 +44,114 @@ } +function AddGenerateFromRtStructButton(instanceId, id, parent) { + if (${HAS_CREATE_DICOM_STL}) { + + var b = $('<a>') + .attr('id', id) + .attr('data-role', 'button') + .attr('href', '#') + .attr('data-icon', 'search') + .attr('data-theme', 'e') + .text('Generate 3D model') + .button(); + + b.insertAfter($('#' + parent)); + b.click(function() { + + $.ajax({ + url: '../stl/rt-struct/' + instanceId, + dataType: 'json', + success: function(s) { + + var options = $('<ul>') + .attr('data-divider-theme', 'd') + .attr('data-role', 'listview'); + + var select = $('<select>') + .attr('id', id + '-structure') + .attr('data-theme', 'a'); + + for (i = 0; i < s.length; i++) { + select.append($('<option>').attr('value', s[i]).text(s[i])); + } + + options.append($('<li>').text('Choose the structure:')); + options.append($('<li>').append(select)); + options.append($('<li>').text('Resolution:')); + options.append($('<li>').append($('<select>') + .attr('id', id + '-resolution') + .attr('data-theme', 'a') + .append($('<option>').attr('value', '256').text('256')) + .append($('<option>').attr('value', '128').text('128')) + .append($('<option>').attr('value', '512').text('512')))); + options.append($('<li>') + .append($('<input>') + .attr('id', id + '-smooth') + .attr('type', 'checkbox') + .attr('data-theme', 'a') + .attr('checked', '')) + .append($('<label>') + .attr('for', id + '-smooth') + .text('Smooth volume'))); + + options.append($('<li>').append( + $('<a>') + .attr('href', '#') + .attr('rel', 'close').attr('data-theme', 'b') + .text('Generate') + .click(function(e) { + e.preventDefault(); + + var structure = $('#' + id + '-structure').val(); + var resolution = $('#' + id + '-resolution').val(); + var smooth = $('#' + id + '-smooth').is(':checked'); + + $.ajax({ + url: '../stl/encode', + type: 'POST', + data: JSON.stringify({ + 'Instance' : instanceId, + 'RoiNames' : [ structure ], + 'Smooth' : smooth, + 'Resolution' : parseInt(resolution, 10) + }), + dataType: 'json', + success: function(s) { + $.mobile.changePage('#series?uuid=' + s.ParentSeries, { + allowSamePageTransition: true + }); + }, + error: function() { + alert('Error while generating the 3D model'); + } + }); + + }))); + + // Launch the dialog + $('#dialog').simpledialog2({ + mode: 'blank', + animate: false, + headerText: 'Generate 3D model', + headerClose: true, + forceInput: false, + width: '100%', + blankContent: options + }); + + } + }); + }); + } +} + + $('#series').live('pagebeforeshow', function() { var seriesId = $.mobile.pageData.uuid; - $('#stl-button-series').remove(); + $('#stl-viewer-series').remove(); + $('#stl-generate-rtstruct-series').remove(); // Test whether this is a whole-slide image by check the SOP Class // UID of one instance of the series @@ -57,10 +162,15 @@ $.ajax({ url: '/instances/' + instanceId + '/metadata/SopClassUid', success: function(sopClassUid) { - if (sopClassUid == SOP_CLASS_UID_STL) { + + if (sopClassUid == STL_PLUGIN_SOP_CLASS_UID_STL) { // This is an "Encapsulated STL Storage" IOD, register the button - AddOpenStlViewerButton(instanceId, 'stl-button-series', 'series-info'); + AddOpenStlViewerButton(instanceId, 'stl-viewer-series', 'series-info'); } + else if (sopClassUid == STL_PLUGIN_SOP_CLASS_UID_RT_STRUCT) { + AddGenerateFromRtStructButton(instanceId, 'stl-generate-rtstruct-series', 'series-info'); + } + } }); } @@ -71,17 +181,23 @@ $('#instance').live('pagebeforeshow', function() { var instanceId = $.mobile.pageData.uuid; - $('#stl-button-instance').remove(); + $('#stl-viewer-instance').remove(); + $('#stl-generate-rtstruct-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) { + + if (sopClassUid == STL_PLUGIN_SOP_CLASS_UID_STL) { // This is an "Encapsulated STL Storage" IOD, register the button - AddOpenStlViewerButton(instanceId, 'stl-button-instance', 'instance-info'); + AddOpenStlViewerButton(instanceId, 'stl-viewer-instance', 'instance-info'); } + else if (sopClassUid == STL_PLUGIN_SOP_CLASS_UID_RT_STRUCT) { + AddGenerateFromRtStructButton(instanceId, 'stl-generate-rtstruct-instance', 'instance-info'); + } + } }); });