annotate Sources/OrthancExplorer.js @ 23:c47512eb4880

fix url of nifti_clib-3.0.0.tar.gz
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Dec 2023 22:07:20 +0100
parents 8b265e711351
children dd0cd39e6259
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * SPDX-License-Identifier: GPL-3.0-or-later
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 */
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 /**
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * STL plugin for Orthanc
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 *
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * This program is free software: you can redistribute it and/or
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * modify it under the terms of the GNU General Public License as
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * published by the Free Software Foundation, either version 3 of the
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * License, or (at your option) any later version.
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 *
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful, but
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * General Public License for more details.
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 *
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 **/
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
25 const STL_PLUGIN_SOP_CLASS_UID_STL = '1.2.840.10008.5.1.4.1.1.104.3';
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
26 const STL_PLUGIN_SOP_CLASS_UID_RT_STRUCT = '1.2.840.10008.5.1.4.1.1.481.3';
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
27
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
28 function AddOpenStlViewerButton(instanceId, id, parent) {
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
29 var b = $('<a>')
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
30 .attr('id', id)
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
31 .attr('data-role', 'button')
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
32 .attr('href', '#')
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
33 .attr('data-icon', 'search')
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
34 .attr('data-theme', 'e')
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
35 .text('STL viewer')
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
36 .button();
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
37
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
38 b.insertAfter($('#' + parent));
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
39 b.click(function() {
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
40 if ($.mobile.pageData) {
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
41 window.open('../stl/app/viewer.html?instance=' + instanceId);
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
42 }
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
43 });
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
44 }
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
45
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
46
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
47 function AddGenerateFromRtStructButton(instanceId, id, parent) {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
48 if (${HAS_CREATE_DICOM_STL}) {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
49
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
50 var b = $('<a>')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
51 .attr('id', id)
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
52 .attr('data-role', 'button')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
53 .attr('href', '#')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
54 .attr('data-icon', 'search')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
55 .attr('data-theme', 'e')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
56 .text('Generate 3D model')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
57 .button();
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
58
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
59 b.insertAfter($('#' + parent));
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
60 b.click(function() {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
61
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
62 $.ajax({
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
63 url: '../stl/rt-struct/' + instanceId,
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
64 dataType: 'json',
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
65 success: function(s) {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
66
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
67 var options = $('<ul>')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
68 .attr('data-divider-theme', 'd')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
69 .attr('data-role', 'listview');
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
70
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
71 var select = $('<select>')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
72 .attr('id', id + '-structure')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
73 .attr('data-theme', 'a');
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
74
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
75 for (i = 0; i < s.length; i++) {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
76 select.append($('<option>').attr('value', s[i]).text(s[i]));
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
77 }
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
78
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
79 options.append($('<li>').text('Choose the structure:'));
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
80 options.append($('<li>').append(select));
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
81 options.append($('<li>').text('Resolution:'));
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
82 options.append($('<li>').append($('<select>')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
83 .attr('id', id + '-resolution')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
84 .attr('data-theme', 'a')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
85 .append($('<option>').attr('value', '256').text('256'))
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
86 .append($('<option>').attr('value', '128').text('128'))
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
87 .append($('<option>').attr('value', '512').text('512'))));
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
88 options.append($('<li>')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
89 .append($('<input>')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
90 .attr('id', id + '-smooth')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
91 .attr('type', 'checkbox')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
92 .attr('data-theme', 'a')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
93 .attr('checked', ''))
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
94 .append($('<label>')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
95 .attr('for', id + '-smooth')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
96 .text('Smooth volume')));
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
97
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
98 options.append($('<li>').append(
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
99 $('<a>')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
100 .attr('href', '#')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
101 .attr('rel', 'close').attr('data-theme', 'b')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
102 .text('Generate')
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
103 .click(function(e) {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
104 e.preventDefault();
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
105
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
106 var structure = $('#' + id + '-structure').val();
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
107 var resolution = $('#' + id + '-resolution').val();
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
108 var smooth = $('#' + id + '-smooth').is(':checked');
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
109
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
110 $.ajax({
8
d1267c6c33e1 added route /stl/encode-nifti
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5
diff changeset
111 url: '../stl/encode-rtstruct',
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
112 type: 'POST',
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
113 data: JSON.stringify({
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
114 'Instance' : instanceId,
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
115 'RoiNames' : [ structure ],
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
116 'Smooth' : smooth,
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
117 'Resolution' : parseInt(resolution, 10)
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
118 }),
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
119 dataType: 'json',
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
120 success: function(s) {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
121 $.mobile.changePage('#series?uuid=' + s.ParentSeries, {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
122 allowSamePageTransition: true
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
123 });
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
124 },
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
125 error: function() {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
126 alert('Error while generating the 3D model');
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
127 }
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
128 });
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
129
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
130 })));
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
131
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
132 // Launch the dialog
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
133 $('#dialog').simpledialog2({
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
134 mode: 'blank',
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
135 animate: false,
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
136 headerText: 'Generate 3D model',
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
137 headerClose: true,
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
138 forceInput: false,
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
139 width: '100%',
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
140 blankContent: options
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
141 });
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
142
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
143 }
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
144 });
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
145 });
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
146 }
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
147 }
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
148
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
149
0
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 $('#series').live('pagebeforeshow', function() {
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 var seriesId = $.mobile.pageData.uuid;
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
153 $('#stl-viewer-series').remove();
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
154 $('#stl-generate-rtstruct-series').remove();
0
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 GetResource('/series/' + seriesId, function(series) {
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
157 if (series['Instances'].length == 1) {
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
158 var instanceId = series['Instances'][0];
0
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
160 $.ajax({
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
161 url: '/instances/' + instanceId + '/metadata/SopClassUid',
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
162 success: function(sopClassUid) {
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
163
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
164 if (sopClassUid == STL_PLUGIN_SOP_CLASS_UID_STL) {
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
165 // This is an "Encapsulated STL Storage" IOD, register the button
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
166 AddOpenStlViewerButton(instanceId, 'stl-viewer-series', 'series-info');
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
167 }
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
168 else if (sopClassUid == STL_PLUGIN_SOP_CLASS_UID_RT_STRUCT) {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
169 AddGenerateFromRtStructButton(instanceId, 'stl-generate-rtstruct-series', 'series-info');
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
170 }
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
171
0
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
173 });
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
174 }
0
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 });
4e889a8e8be2 initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 });
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
177
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
178
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
179 $('#instance').live('pagebeforeshow', function() {
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
180 var instanceId = $.mobile.pageData.uuid;
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
181
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
182 $('#stl-viewer-instance').remove();
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
183 $('#stl-generate-rtstruct-instance').remove();
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
184
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
185 $.ajax({
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
186 url: '/instances/' + instanceId + '/metadata/SopClassUid',
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
187 success: function(sopClassUid) {
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
188
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
189 if (sopClassUid == STL_PLUGIN_SOP_CLASS_UID_STL) {
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
190 // This is an "Encapsulated STL Storage" IOD, register the button
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
191 AddOpenStlViewerButton(instanceId, 'stl-viewer-instance', 'instance-info');
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
192 }
5
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
193 else if (sopClassUid == STL_PLUGIN_SOP_CLASS_UID_RT_STRUCT) {
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
194 AddGenerateFromRtStructButton(instanceId, 'stl-generate-rtstruct-instance', 'instance-info');
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
195 }
1cc024bb662a added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
196
2
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
197 }
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
198 });
2bdb9acb7dcf added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
199 });
9
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
200
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
201
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
202 $('#study').live('pagebeforeshow', function() {
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
203 if (${HAS_CREATE_DICOM_STL}) {
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
204 var studyId = $.mobile.pageData.uuid;
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
205
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
206 $('#stl-attach-nifti-study').remove();
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
207
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
208 var b = $('<a>')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
209 .attr('id', 'stl-attach-nifti-study')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
210 .attr('data-role', 'button')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
211 .attr('href', '#')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
212 .attr('data-icon', 'search')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
213 .attr('data-theme', 'e')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
214 .text('Attach NIfTI 3D model')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
215 .button();
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
216
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
217 b.insertAfter($('#study-info'));
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
218 b.click(function() {
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
219
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
220 var options = $('<ul>')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
221 .attr('data-divider-theme', 'd')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
222 .attr('data-role', 'listview');
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
223
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
224 var upload = $('<input>')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
225 .attr('type', 'file')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
226 .attr('id', 'stl-attach-nifti-study-upload')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
227 .attr('data-theme', 'a');
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
228
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
229 options.append($('<li>').text('Choose the NIfTI file:'));
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
230 options.append($('<li>').append(upload));
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
231 options.append($('<li>').text('Resolution:'));
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
232 options.append($('<li>').append($('<select>')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
233 .attr('id', 'stl-attach-nifti-study-resolution')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
234 .attr('data-theme', 'a')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
235 .append($('<option>').attr('value', '256').text('256'))
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
236 .append($('<option>').attr('value', '128').text('128'))
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
237 .append($('<option>').attr('value', '512').text('512'))));
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
238 options.append($('<li>')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
239 .append($('<input>')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
240 .attr('id', 'stl-attach-nifti-study-smooth')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
241 .attr('type', 'checkbox')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
242 .attr('data-theme', 'a')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
243 .attr('checked', ''))
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
244 .append($('<label>')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
245 .attr('for', 'stl-attach-nifti-study-smooth')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
246 .text('Smooth volume')));
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
247
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
248 options.append($('<li>').append(
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
249 $('<a>')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
250 .attr('href', '#')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
251 .attr('rel', 'close').attr('data-theme', 'b')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
252 .text('Generate')
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
253 .click(function(e) {
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
254 e.preventDefault();
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
255
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
256 var fileInput = document.getElementById('stl-attach-nifti-study-upload');
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
257 var resolution = $('#stl-attach-nifti-study-resolution').val();
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
258 var smooth = $('#stl-attach-nifti-study-smooth').is(':checked');
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
259
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
260 if (fileInput.files.length == 0) {
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
261 alert('No NIfTI file was selected');
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
262 return;
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
263 }
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
264
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
265 reader = new FileReader();
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
266 reader.onload = function() {
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
267
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
268 // https://github.com/axios/axios/issues/513
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
269 var nifti = reader.result;
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
270 var niftiBase64 = btoa(new Uint8Array(nifti).reduce((data, byte) => data + String.fromCharCode(byte), ''));
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
271
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
272 $.ajax({
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
273 url: '../stl/encode-nifti',
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
274 type: 'POST',
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
275 data: JSON.stringify({
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
276 'Nifti' : 'data:application/octet-stream;base64,' + niftiBase64,
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
277 'ParentStudy' : studyId,
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
278 'Smooth' : smooth,
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
279 'Resolution' : parseInt(resolution, 10)
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
280 }),
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
281 dataType: 'json',
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
282 success: function(s) {
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
283 $.mobile.changePage('#series?uuid=' + s.ParentSeries, {
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
284 allowSamePageTransition: true
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
285 });
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
286 },
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
287 error: function() {
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
288 alert('Error while generating the 3D model');
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
289 }
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
290 });
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
291
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
292 };
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
293
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
294 reader.readAsArrayBuffer(fileInput.files[0]);
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
295 })));
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
296
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
297 // Launch the dialog
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
298 $('#dialog').simpledialog2({
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
299 mode: 'blank',
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
300 animate: false,
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
301 headerText: 'Generate 3D model',
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
302 headerClose: true,
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
303 forceInput: false,
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
304 width: '100%',
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
305 blankContent: options
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
306 });
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
307
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
308 });
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
309 }
8b265e711351 added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 8
diff changeset
310 });