annotate Applications/Samples/RtViewerPlugin/Plugin.cpp @ 1739:9ac2a65d4172

upgrade to year 2021
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 06 Jan 2021 17:50:00 +0100
parents 58abe9e13ee3
children 3889ae96d2e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1739
9ac2a65d4172 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1626
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
1527
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 *
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 * 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
8 * 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
9 * 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
10 * 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
11 *
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 * 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
13 * 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
14 * 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
15 * Affero General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1544
diff changeset
16 *
1527
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 * 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
18 * 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
19 **/
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
1544
8ddf77198ed7 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
22 #include "../../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
23
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 #include <EmbeddedResources.h>
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25
1626
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
26 #include <Logging.h>
1527
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 #include <SystemToolbox.h>
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28 #include <Toolbox.h>
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29
1528
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
30 OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType,
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
31 OrthancPluginResourceType resourceType,
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
32 const char* resourceId)
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
33 {
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
34 try
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
35 {
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
36 if (changeType == OrthancPluginChangeType_OrthancStarted)
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
37 {
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
38 Json::Value info;
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
39 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
40 {
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
41 throw Orthanc::OrthancException(
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
42 Orthanc::ErrorCode_InternalError,
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
43 "The Stone MPR RT viewer requires the Web Viewer plugin to be installed");
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
44 }
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 catch (Orthanc::OrthancException& e)
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
48 {
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
49 LOG(ERROR) << "Exception: " << e.What();
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
50 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
51 }
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 return OrthancPluginErrorCode_Success;
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
54 }
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
55
1527
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 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
57 void ServeEmbeddedFolder(OrthancPluginRestOutput* output,
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 const char* url,
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 const OrthancPluginHttpRequest* request)
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 OrthancPluginContext* context = OrthancPlugins::GetGlobalContext();
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 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
64 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 OrthancPluginSendMethodNotAllowed(context, output, "GET");
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 }
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 else
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 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
70 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
71
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 std::string s;
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 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
74
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 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
76 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
77 }
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 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
82 void ServeEmbeddedFile(OrthancPluginRestOutput* output,
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 const char* url,
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 const OrthancPluginHttpRequest* request)
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 OrthancPluginContext* context = OrthancPlugins::GetGlobalContext();
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 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
89 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 OrthancPluginSendMethodNotAllowed(context, output, "GET");
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 }
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 else
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 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
95
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96 std::string s;
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 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
98
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99 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
100 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
101 }
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 extern "C"
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 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
108 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109 OrthancPlugins::SetGlobalContext(context);
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110
1530
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1528
diff changeset
111 #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
112 Orthanc::Logging::InitializePluginContext(context);
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113 #else
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
114 Orthanc::Logging::Initialize(context);
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115 #endif
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
116
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 /* 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
118 if (OrthancPluginCheckVersion(context) == 0)
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 char info[1024];
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 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
122 context->orthancVersion,
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 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
124 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
125 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
126 OrthancPluginLogError(context, info);
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 return -1;
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
128 }
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 try
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 std::string explorer;
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
133 Orthanc::EmbeddedResources::GetFileResource(
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134 explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER);
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str());
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 // RtViewer files below.
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 // ---------------------
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139 // 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
140 // 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
141 // resource embedding system
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143 OrthancPlugins::RegisterRestCallback
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 <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
145 ("/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
146
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 OrthancPlugins::RegisterRestCallback
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 <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
149 ("/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
150
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
151 OrthancPlugins::RegisterRestCallback
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152 <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
153 ("/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
154
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
155 OrthancPlugins::RegisterRestCallback
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 <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
157 ("/stone-rtviewer/index.html", true);
1528
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
158
c815ad10a10f RtViewerPlugin : added detection of web-viewer plugin
Benjamin Golinvaux <bgo@osimis.io>
parents: 1527
diff changeset
159 OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback);
1527
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 }
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
161 catch (...)
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
162 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163 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
164 return -1;
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
165 }
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 return 0;
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
168 }
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 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
172 {
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 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
177 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
178 return PLUGIN_NAME;
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
179 }
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 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
183 {
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
184 return PLUGIN_VERSION;
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
185 }
4c4b267e4004 RtViewerPlugin : similar to the StoneWebPlugin, but for the sole RtViewer sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
186 }