Mercurial > hg > orthanc-stl
annotate Sources/OrthancExplorer.js @ 42:c0d5dcefe26f
back to mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 06 Apr 2024 10:25:55 +0200 |
parents | b6910092bcca |
children | 967f947014ac |
rev | line source |
---|---|
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
24 | 2 * SPDX-FileCopyrightText: 2023-2024 Sebastien Jodogne, UCLouvain, Belgium |
0
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 |
24 | 8 * Copyright (C) 2023-2024 Sebastien Jodogne, UCLouvain, Belgium |
0
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 |
39
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
28 |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
29 function AddStlViewer(target, name, callback) { |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
30 var li = $('<li>', { |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
31 name: name, |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
32 }).click(callback); |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
33 |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
34 li.append($('<a>', { |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
35 href: '#', |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
36 rel: 'close', |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
37 text: name |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
38 })); |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
39 |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
40 target.append(li); |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
41 } |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
42 |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
43 |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
44 function AddOpenStlViewerButton(instanceId, id, parent) { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
45 var b = $('<a>') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
46 .attr('id', id) |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
47 .attr('data-role', 'button') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
48 .attr('href', '#') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
49 .attr('data-icon', 'search') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
50 .attr('data-theme', 'e') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
51 .text('STL viewer') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
52 .button(); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
53 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
54 b.insertAfter($('#' + parent)); |
39
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
55 |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
56 b.click(function() { |
39
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
57 var viewers = $('<ul>') |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
58 .attr('data-divider-theme', 'd') |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
59 .attr('data-role', 'listview'); |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
60 |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
61 AddStlViewer(viewers, 'Basic viewer built using Three.js', function() { |
36
13698d34e059
preparing to include O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
31
diff
changeset
|
62 window.open('../stl/app/three.html?instance=' + instanceId); |
39
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
63 }); |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
64 |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
65 AddStlViewer(viewers, 'Online3DViewer', function() { |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
66 window.open('../stl/app/o3dv.html?instance=' + instanceId); |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
67 }); |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
68 |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
69 // Launch the dialog |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
70 $('#dialog').simpledialog2({ |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
71 mode: 'blank', |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
72 animate: false, |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
73 headerText: 'Choose STL viewer', |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
74 headerClose: true, |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
75 forceInput: false, |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
76 width: '100%', |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
77 blankContent: viewers |
b6910092bcca
added button to open O3DV
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
36
diff
changeset
|
78 }); |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
79 }); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
80 } |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
81 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
82 |
5
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
83 function AddGenerateFromRtStructButton(instanceId, id, parent) { |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
84 if (${HAS_CREATE_DICOM_STL}) { |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
85 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
86 var b = $('<a>') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
87 .attr('id', id) |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
88 .attr('data-role', 'button') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
89 .attr('href', '#') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
90 .attr('data-icon', 'search') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
91 .attr('data-theme', 'e') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
92 .text('Generate 3D model') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
93 .button(); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
94 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
95 b.insertAfter($('#' + parent)); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
96 b.click(function() { |
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 $.ajax({ |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
99 url: '../stl/rt-struct/' + instanceId, |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
100 dataType: 'json', |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
101 success: function(s) { |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
102 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
103 var options = $('<ul>') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
104 .attr('data-divider-theme', 'd') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
105 .attr('data-role', 'listview'); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
106 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
107 var select = $('<select>') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
108 .attr('id', id + '-structure') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
109 .attr('data-theme', 'a'); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
110 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
111 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
|
112 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
|
113 } |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
114 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
115 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
|
116 options.append($('<li>').append(select)); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
117 options.append($('<li>').text('Resolution:')); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
118 options.append($('<li>').append($('<select>') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
119 .attr('id', id + '-resolution') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
120 .attr('data-theme', 'a') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
121 .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
|
122 .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
|
123 .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
|
124 options.append($('<li>') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
125 .append($('<input>') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
126 .attr('id', id + '-smooth') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
127 .attr('type', 'checkbox') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
128 .attr('data-theme', 'a') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
129 .attr('checked', '')) |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
130 .append($('<label>') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
131 .attr('for', id + '-smooth') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
132 .text('Smooth volume'))); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
133 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
134 options.append($('<li>').append( |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
135 $('<a>') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
136 .attr('href', '#') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
137 .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
|
138 .text('Generate') |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
139 .click(function(e) { |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
140 e.preventDefault(); |
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 var structure = $('#' + id + '-structure').val(); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
143 var resolution = $('#' + id + '-resolution').val(); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
144 var smooth = $('#' + id + '-smooth').is(':checked'); |
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 $.ajax({ |
8
d1267c6c33e1
added route /stl/encode-nifti
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
147 url: '../stl/encode-rtstruct', |
5
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
148 type: 'POST', |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
149 data: JSON.stringify({ |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
150 'Instance' : instanceId, |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
151 'RoiNames' : [ structure ], |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
152 'Smooth' : smooth, |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
153 'Resolution' : parseInt(resolution, 10) |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
154 }), |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
155 dataType: 'json', |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
156 success: function(s) { |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
157 $.mobile.changePage('#series?uuid=' + s.ParentSeries, { |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
158 allowSamePageTransition: true |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
159 }); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
160 }, |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
161 error: function() { |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
162 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
|
163 } |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
164 }); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
165 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
166 }))); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
167 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
168 // Launch the dialog |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
169 $('#dialog').simpledialog2({ |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
170 mode: 'blank', |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
171 animate: false, |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
172 headerText: 'Generate 3D model', |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
173 headerClose: true, |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
174 forceInput: false, |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
175 width: '100%', |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
176 blankContent: options |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
177 }); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
178 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
179 } |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
180 }); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
181 }); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
182 } |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
183 } |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
184 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
185 |
31
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
186 function AddGenerateFromNIfTIButton(studyId) { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
187 if (${HAS_CREATE_DICOM_STL} && |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
188 ${SHOW_NIFTI_BUTTON}) { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
189 $('#stl-attach-nifti').remove(); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
190 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
191 var nifti = $('<a>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
192 .attr('id', 'stl-attach-nifti') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
193 .attr('data-role', 'button') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
194 .attr('href', '#') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
195 .attr('data-icon', 'search') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
196 .attr('data-theme', 'e') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
197 .text('Attach NIfTI 3D model') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
198 .button(); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
199 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
200 nifti.insertAfter($('#study-info')); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
201 nifti.click(function() { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
202 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
203 var options = $('<ul>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
204 .attr('data-divider-theme', 'd') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
205 .attr('data-role', 'listview'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
206 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
207 var upload = $('<input>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
208 .attr('type', 'file') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
209 .attr('id', 'stl-attach-nifti-upload') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
210 .attr('data-theme', 'a'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
211 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
212 options.append($('<li>').text('Choose the NIfTI file:')); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
213 options.append($('<li>').append(upload)); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
214 options.append($('<li>').text('Resolution:')); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
215 options.append($('<li>').append($('<select>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
216 .attr('id', 'stl-attach-nifti-resolution') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
217 .attr('data-theme', 'a') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
218 .append($('<option>').attr('value', '256').text('256')) |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
219 .append($('<option>').attr('value', '128').text('128')) |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
220 .append($('<option>').attr('value', '512').text('512')))); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
221 options.append($('<li>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
222 .append($('<input>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
223 .attr('id', 'stl-attach-nifti-smooth') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
224 .attr('type', 'checkbox') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
225 .attr('data-theme', 'a') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
226 .attr('checked', '')) |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
227 .append($('<label>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
228 .attr('for', 'stl-attach-nifti-smooth') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
229 .text('Smooth volume'))); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
230 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
231 options.append($('<li>').append( |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
232 $('<a>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
233 .attr('href', '#') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
234 .attr('rel', 'close').attr('data-theme', 'b') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
235 .text('Generate') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
236 .click(function(e) { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
237 e.preventDefault(); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
238 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
239 var fileInput = document.getElementById('stl-attach-nifti-upload'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
240 var resolution = $('#stl-attach-nifti-resolution').val(); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
241 var smooth = $('#stl-attach-nifti-smooth').is(':checked'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
242 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
243 if (fileInput.files.length == 0) { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
244 alert('No NIfTI file was selected'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
245 return; |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
246 } |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
247 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
248 reader = new FileReader(); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
249 reader.onload = function() { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
250 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
251 // https://github.com/axios/axios/issues/513 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
252 var nifti = reader.result; |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
253 var niftiBase64 = btoa(new Uint8Array(nifti).reduce((data, byte) => data + String.fromCharCode(byte), '')); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
254 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
255 $.ajax({ |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
256 url: '../stl/encode-nifti', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
257 type: 'POST', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
258 data: JSON.stringify({ |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
259 'Nifti' : 'data:application/octet-stream;base64,' + niftiBase64, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
260 'ParentStudy' : studyId, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
261 'Smooth' : smooth, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
262 'Resolution' : parseInt(resolution, 10) |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
263 }), |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
264 dataType: 'json', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
265 success: function(s) { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
266 $.mobile.changePage('#series?uuid=' + s.ParentSeries, { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
267 allowSamePageTransition: true |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
268 }); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
269 }, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
270 error: function() { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
271 alert('Error while generating the 3D model'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
272 } |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
273 }); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
274 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
275 }; |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
276 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
277 reader.readAsArrayBuffer(fileInput.files[0]); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
278 }))); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
279 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
280 // Launch the dialog |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
281 $('#dialog').simpledialog2({ |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
282 mode: 'blank', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
283 animate: false, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
284 headerText: 'Generate 3D model', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
285 headerClose: true, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
286 forceInput: false, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
287 width: '100%', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
288 blankContent: options |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
289 }); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
290 }); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
291 } |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
292 } |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
293 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
294 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
295 function AddImportSTLButton(studyId) { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
296 if (${HAS_CREATE_DICOM_STL}) { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
297 $('#stl-attach-instance').remove(); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
298 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
299 var instance = $('<a>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
300 .attr('id', 'stl-attach-instance') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
301 .attr('data-role', 'button') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
302 .attr('href', '#') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
303 .attr('data-icon', 'search') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
304 .attr('data-theme', 'e') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
305 .text('Attach STL model') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
306 .button(); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
307 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
308 instance.insertAfter($('#study-info')); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
309 instance.click(function() { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
310 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
311 var options = $('<ul>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
312 .attr('data-divider-theme', 'd') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
313 .attr('data-role', 'listview'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
314 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
315 var upload = $('<input>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
316 .attr('type', 'file') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
317 .attr('id', 'stl-attach-instance-upload') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
318 .attr('data-theme', 'a'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
319 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
320 options.append($('<li>').text('Choose the STL file:')); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
321 options.append($('<li>').append(upload)); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
322 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
323 options.append($('<li>').text('Series description:')); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
324 options.append($('<li>').append($('<input>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
325 .attr('type', 'text') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
326 .attr('id', 'stl-attach-instance-description') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
327 .attr('data-theme', 'b') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
328 .val('Imported STL'))); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
329 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
330 options.append($('<li>').append( |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
331 $('<a>') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
332 .attr('href', '#') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
333 .attr('rel', 'close').attr('data-theme', 'b') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
334 .text('Import') |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
335 .click(function(e) { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
336 e.preventDefault(); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
337 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
338 var fileInput = document.getElementById('stl-attach-instance-upload'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
339 var description = $('#stl-attach-instance-description').val(); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
340 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
341 if (fileInput.files.length == 0) { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
342 alert('No Instance file was selected'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
343 return; |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
344 } |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
345 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
346 reader = new FileReader(); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
347 reader.onload = function() { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
348 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
349 // https://github.com/axios/axios/issues/513 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
350 var stl = reader.result; |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
351 var stlBase64 = btoa(new Uint8Array(stl).reduce((data, byte) => data + String.fromCharCode(byte), '')); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
352 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
353 $.ajax({ |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
354 url: '../tools/create-dicom', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
355 type: 'POST', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
356 data: JSON.stringify({ |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
357 'Content' : 'data:model/stl;base64,' + stlBase64, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
358 'Parent' : studyId, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
359 'Tags' : { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
360 'SeriesDescription' : description |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
361 } |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
362 }), |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
363 dataType: 'json', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
364 success: function(s) { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
365 $.mobile.changePage('#series?uuid=' + s.ParentSeries, { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
366 allowSamePageTransition: true |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
367 }); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
368 }, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
369 error: function() { |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
370 alert('Error while generating the 3D model'); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
371 } |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
372 }); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
373 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
374 }; |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
375 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
376 reader.readAsArrayBuffer(fileInput.files[0]); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
377 }))); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
378 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
379 // Launch the dialog |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
380 $('#dialog').simpledialog2({ |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
381 mode: 'blank', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
382 animate: false, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
383 headerText: 'Attach STL', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
384 headerClose: true, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
385 forceInput: false, |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
386 width: '100%', |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
387 blankContent: options |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
388 }); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
389 }); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
390 } |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
391 } |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
392 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
393 |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
394 |
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 $('#series').live('pagebeforeshow', function() { |
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 var seriesId = $.mobile.pageData.uuid; |
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 |
5
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
398 $('#stl-viewer-series').remove(); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
399 $('#stl-generate-rtstruct-series').remove(); |
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 |
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 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
|
402 if (series['Instances'].length == 1) { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
403 var instanceId = series['Instances'][0]; |
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
405 $.ajax({ |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
406 url: '/instances/' + instanceId + '/metadata/SopClassUid', |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
407 success: function(sopClassUid) { |
5
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
408 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
409 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
|
410 // 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
|
411 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
|
412 } |
5
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
413 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
|
414 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
|
415 } |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
416 |
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 } |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
418 }); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
419 } |
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 }); |
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 }); |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
422 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
423 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
424 $('#instance').live('pagebeforeshow', function() { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
425 var instanceId = $.mobile.pageData.uuid; |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
426 |
5
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
427 $('#stl-viewer-instance').remove(); |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
428 $('#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
|
429 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
430 $.ajax({ |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
431 url: '/instances/' + instanceId + '/metadata/SopClassUid', |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
432 success: function(sopClassUid) { |
5
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
433 |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
434 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
|
435 // 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
|
436 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
|
437 } |
5
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
438 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
|
439 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
|
440 } |
1cc024bb662a
added generate model button in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2
diff
changeset
|
441 |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
442 } |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
443 }); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
444 }); |
9
8b265e711351
added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
445 |
8b265e711351
added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
446 |
8b265e711351
added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
447 $('#study').live('pagebeforeshow', function() { |
31
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
448 var studyId = $.mobile.pageData.uuid; |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
449 AddImportSTLButton(studyId); |
ab231760799d
added button to import STL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
450 AddGenerateFromNIfTIButton(studyId); |
9
8b265e711351
added button "Attach NIfTI 3D model" in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
8
diff
changeset
|
451 }); |