comparison OrthancStone/Sources/StoneInitialization.cpp @ 1591:5887a4f8594b

moving platform-specific files out of the "OrthancStone" folder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 23 Oct 2020 13:15:03 +0200
parents 244ad1e4e76a
children 4fb8fdf03314
comparison
equal deleted inserted replaced
1590:7b963bccafef 1591:5887a4f8594b
19 **/ 19 **/
20 20
21 21
22 #include "StoneInitialization.h" 22 #include "StoneInitialization.h"
23 23
24 #if !defined(ORTHANC_ENABLE_SDL)
25 # error Macro ORTHANC_ENABLE_SDL must be defined
26 #endif
27
28 #if !defined(ORTHANC_ENABLE_SSL) 24 #if !defined(ORTHANC_ENABLE_SSL)
29 # error Macro ORTHANC_ENABLE_SSL must be defined 25 # error Macro ORTHANC_ENABLE_SSL must be defined
30 #endif 26 #endif
31 27
32 #if !defined(ORTHANC_ENABLE_CURL) 28 #if !defined(ORTHANC_ENABLE_CURL)
38 # if !defined(DCMTK_VERSION_NUMBER) 34 # if !defined(DCMTK_VERSION_NUMBER)
39 # error Macro DCMTK_VERSION_NUMBER must be defined 35 # error Macro DCMTK_VERSION_NUMBER must be defined
40 # endif 36 # endif
41 #endif 37 #endif
42 38
43 #if ORTHANC_ENABLE_SDL == 1
44 # include "Viewport/SdlWindow.h"
45 #endif
46
47 #if ORTHANC_ENABLE_CURL == 1 39 #if ORTHANC_ENABLE_CURL == 1
48 # include <HttpClient.h> 40 # include <HttpClient.h>
49 #endif 41 #endif
50 42
51 #if ORTHANC_ENABLE_DCMTK == 1 43 #if ORTHANC_ENABLE_DCMTK == 1
52 # include <DicomParsing/FromDcmtkBridge.h> 44 # include <DicomParsing/FromDcmtkBridge.h>
53 #endif
54
55 #if ORTHANC_ENABLE_WASM == 1
56 static double viewportsTimeout_ = 1000;
57 static std::unique_ptr<OrthancStone::WebGLViewportsRegistry> viewportsRegistry_;
58 #endif 45 #endif
59 46
60 #include "Toolbox/LinearAlgebra.h" 47 #include "Toolbox/LinearAlgebra.h"
61 48
62 #include <Logging.h> 49 #include <Logging.h>
148 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, 135 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
149 "Error in the locale settings, giving up"); 136 "Error in the locale settings, giving up");
150 } 137 }
151 } 138 }
152 } 139 }
153
154 #if ORTHANC_ENABLE_SDL == 1
155 OrthancStone::SdlWindow::GlobalInitialize();
156 #endif
157 } 140 }
158 141
159 142
160 void StoneFinalize() 143 void StoneFinalize()
161 { 144 {
162 #if ORTHANC_ENABLE_WASM == 1
163 viewportsRegistry_.reset();
164 #endif
165
166 #if ORTHANC_ENABLE_SDL == 1
167 OrthancStone::SdlWindow::GlobalFinalize();
168 #endif
169
170 #if ORTHANC_ENABLE_DCMTK == 1 145 #if ORTHANC_ENABLE_DCMTK == 1
171 Orthanc::FromDcmtkBridge::FinalizeCodecs(); 146 Orthanc::FromDcmtkBridge::FinalizeCodecs();
172 #endif 147 #endif
173 148
174 #if ORTHANC_ENABLE_CURL == 1 149 #if ORTHANC_ENABLE_CURL == 1
179 Orthanc::Toolbox::FinalizeOpenSsl(); 154 Orthanc::Toolbox::FinalizeOpenSsl();
180 #endif 155 #endif
181 156
182 Orthanc::Logging::Finalize(); 157 Orthanc::Logging::Finalize();
183 } 158 }
184
185
186 #if ORTHANC_ENABLE_WASM == 1
187 void SetWebGLViewportsRegistryTimeout(double timeout)
188 {
189 if (viewportsRegistry_.get())
190 {
191 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
192 }
193 else
194 {
195 viewportsTimeout_ = timeout;
196 }
197 }
198 #endif
199
200
201 #if ORTHANC_ENABLE_WASM == 1
202 WebGLViewportsRegistry& GetWebGLViewportsRegistry()
203 {
204 if (viewportsRegistry_.get() == NULL)
205 {
206 viewportsRegistry_.reset(new WebGLViewportsRegistry(viewportsTimeout_));
207 }
208
209 return *viewportsRegistry_;
210 }
211 #endif
212 } 159 }