Mercurial > hg > orthanc-stone
annotate Applications/Samples/RtViewerPlugin/Plugin.cpp @ 2135:6cc11bd11890 dicom-sr
integration mainline->dicom-sr
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 21:31:55 +0200 |
parents | 16c01cc201e7 |
children |
rev | line source |
---|---|
1527
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2124
16c01cc201e7
updated copyright, as Osimis is not active on Orthanc anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2121
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
2114
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1527
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Affero General Public License |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * the License, or (at your option) any later version. |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * Affero General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1544
diff
changeset
|
17 * |
1527
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Affero General Public License |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 **/ |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 |
1877
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
23 #include "../../../RenderingPlugin/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" |
1527
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 #include <EmbeddedResources.h> |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 |
1626 | 27 #include <Logging.h> |
1527
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 #include <SystemToolbox.h> |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 #include <Toolbox.h> |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 |
1528
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
31 OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType, |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
32 OrthancPluginResourceType resourceType, |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
33 const char* resourceId) |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
34 { |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
35 try |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
36 { |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
37 if (changeType == OrthancPluginChangeType_OrthancStarted) |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
38 { |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
39 Json::Value info; |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
40 if (!OrthancPlugins::RestApiGet(info, "/plugins/web-viewer", false)) |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
41 { |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
42 throw Orthanc::OrthancException( |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
43 Orthanc::ErrorCode_InternalError, |
1896
b3c08e607d9f
simplified signature of DicomStructureSet::ProjectStructure()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
44 "The Stone MPR RT viewer requires the Orthanc Web Viewer plugin to be installed"); |
1528
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
45 } |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
46 } |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
47 } |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
48 catch (Orthanc::OrthancException& e) |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
49 { |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
50 LOG(ERROR) << "Exception: " << e.What(); |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
51 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
52 } |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
53 |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
54 return OrthancPluginErrorCode_Success; |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
55 } |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
56 |
1527
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 template <enum Orthanc::EmbeddedResources::DirectoryResourceId folder> |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 void ServeEmbeddedFolder(OrthancPluginRestOutput* output, |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 const char* url, |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 const OrthancPluginHttpRequest* request) |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 if (request->method != OrthancPluginHttpMethod_Get) |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 OrthancPluginSendMethodNotAllowed(context, output, "GET"); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 else |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 std::string path = "/" + std::string(request->groups[0]); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 const char* mime = Orthanc::EnumerationToString(Orthanc::SystemToolbox::AutodetectMimeType(path)); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 std::string s; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 Orthanc::EmbeddedResources::GetDirectoryResource(s, folder, path.c_str()); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 const char* resource = s.size() ? s.c_str() : NULL; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 OrthancPluginAnswerBuffer(context, output, resource, s.size(), mime); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 template <enum Orthanc::EmbeddedResources::FileResourceId file> |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 void ServeEmbeddedFile(OrthancPluginRestOutput* output, |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 const char* url, |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 const OrthancPluginHttpRequest* request) |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 if (request->method != OrthancPluginHttpMethod_Get) |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 OrthancPluginSendMethodNotAllowed(context, output, "GET"); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 else |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 const char* mime = Orthanc::EnumerationToString(Orthanc::SystemToolbox::AutodetectMimeType(url)); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 std::string s; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 Orthanc::EmbeddedResources::GetFileResource(s, file); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 const char* resource = s.size() ? s.c_str() : NULL; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 OrthancPluginAnswerBuffer(context, output, resource, s.size(), mime); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 extern "C" |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 OrthancPlugins::SetGlobalContext(context); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 |
1530 | 112 #if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 7, 2) |
1527
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 Orthanc::Logging::InitializePluginContext(context); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 #else |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 Orthanc::Logging::Initialize(context); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 #endif |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 /* Check the version of the Orthanc core */ |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 if (OrthancPluginCheckVersion(context) == 0) |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 char info[1024]; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
122 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 context->orthancVersion, |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 OrthancPluginLogError(context, info); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 return -1; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
130 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 try |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 std::string explorer; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 Orthanc::EmbeddedResources::GetFileResource( |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); |
2121 | 136 OrthancPlugins::ExtendOrthancExplorer(PLUGIN_NAME, explorer); |
1527
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
138 // RtViewer files below. |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 // --------------------- |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 // we do not serve the whole directory at once (with ServeEmbeddedFolder) |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 // because it contains uppercase characters that are forbidden by the |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 // resource embedding system |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 OrthancPlugins::RegisterRestCallback |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 <ServeEmbeddedFile<Orthanc::EmbeddedResources::RT_VIEWER_WASM_JS> > |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 ("/stone-rtviewer/RtViewerWasm.js", true); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 OrthancPlugins::RegisterRestCallback |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 <ServeEmbeddedFile<Orthanc::EmbeddedResources::RT_VIEWER_WASM> > |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 ("/stone-rtviewer/RtViewerWasm.wasm", true); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
152 OrthancPlugins::RegisterRestCallback |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
153 <ServeEmbeddedFile<Orthanc::EmbeddedResources::RT_VIEWER_WASM_APP_JS> > |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 ("/stone-rtviewer/RtViewerWasmApp.js", true); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
156 OrthancPlugins::RegisterRestCallback |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
157 <ServeEmbeddedFile<Orthanc::EmbeddedResources::RT_VIEWER_INDEX_HTML> > |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 ("/stone-rtviewer/index.html", true); |
1528
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
159 |
c815ad10a10f
RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents:
1527
diff
changeset
|
160 OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); |
1527
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 catch (...) |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
163 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
164 OrthancPlugins::LogError("Exception while initializing the Stone Web viewer plugin"); |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
165 return -1; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
166 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
167 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 return 0; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
172 ORTHANC_PLUGINS_API void OrthancPluginFinalize() |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
175 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
176 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 return PLUGIN_NAME; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 { |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 return PLUGIN_VERSION; |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 } |
4c4b267e4004
RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 } |