Mercurial > hg > orthanc-stl
annotate Sources/OrthancExplorer.js @ 2:2bdb9acb7dcf
added STL viewer button at instance level too
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 18 Jul 2023 09:41:31 +0200 |
parents | 0f03a8a0bd6f |
children | 1cc024bb662a |
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 |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
25 const SOP_CLASS_UID_STL = '1.2.840.10008.5.1.4.1.1.104.3'; |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
26 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
27 function AddOpenStlViewerButton(instanceId, id, parent) { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
28 var b = $('<a>') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
29 .attr('id', id) |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
30 .attr('data-role', 'button') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
31 .attr('href', '#') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
32 .attr('data-icon', 'search') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
33 .attr('data-theme', 'e') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
34 .text('STL viewer') |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
35 .button(); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
36 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
37 b.insertAfter($('#' + parent)); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
38 b.click(function() { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
39 if ($.mobile.pageData) { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
40 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
|
41 } |
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 |
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 $('#series').live('pagebeforeshow', function() { |
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 var seriesId = $.mobile.pageData.uuid; |
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
49 $('#stl-button-series').remove(); |
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 // Test whether this is a whole-slide image by check the SOP Class |
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 // UID of one instance of the series |
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 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
|
54 if (series['Instances'].length == 1) { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
55 var instanceId = series['Instances'][0]; |
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
57 $.ajax({ |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
58 url: '/instances/' + instanceId + '/metadata/SopClassUid', |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
59 success: function(sopClassUid) { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
60 if (sopClassUid == SOP_CLASS_UID_STL) { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
61 // This is an "Encapsulated STL Storage" IOD, register the button |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
62 AddOpenStlViewerButton(instanceId, 'stl-button-series', 'series-info'); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
63 } |
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 } |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
65 }); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
66 } |
0
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 }); |
4e889a8e8be2
initial commit of the viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 }); |
2
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
69 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
70 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
71 $('#instance').live('pagebeforeshow', function() { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
72 var instanceId = $.mobile.pageData.uuid; |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
73 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
74 $('#stl-button-instance').remove(); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
75 |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
76 // Test whether this is a whole-slide image by check the SOP Class |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
77 // UID of one instance of the series |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
78 $.ajax({ |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
79 url: '/instances/' + instanceId + '/metadata/SopClassUid', |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
80 success: function(sopClassUid) { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
81 if (sopClassUid == SOP_CLASS_UID_STL) { |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
82 // This is an "Encapsulated STL Storage" IOD, register the button |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
83 AddOpenStlViewerButton(instanceId, 'stl-button-instance', 'instance-info'); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
84 } |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
85 } |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
86 }); |
2bdb9acb7dcf
added STL viewer button at instance level too
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1
diff
changeset
|
87 }); |