comparison Applications/Sdl/BasicSdlApplication.cpp @ 242:092db46c6291 am

improved SDL/Wasm unification
author am@osimis.io
date Wed, 20 Jun 2018 14:20:55 +0200
parents ce4405d98b92
children 50fb32abf85e
comparison
equal deleted inserted replaced
241:a4197519eb55 242:092db46c6291
77 77
78 options.add(sdl); 78 options.add(sdl);
79 } 79 }
80 80
81 81
82 int BasicSdlApplication::ExecuteWithSdl(BasicSdlApplication& application, 82 int BasicSdlApplication::ExecuteWithSdl(IBasicApplication& application,
83 int argc, 83 int argc,
84 char* argv[]) 84 char* argv[])
85 { 85 {
86 /****************************************************************** 86 /******************************************************************
87 * Initialize all the subcomponents of Orthanc Stone 87 * Initialize all the subcomponents of Orthanc Stone
182 { 182 {
183 /**************************************************************** 183 /****************************************************************
184 * Initialize the connection to the Orthanc server 184 * Initialize the connection to the Orthanc server
185 ****************************************************************/ 185 ****************************************************************/
186 186
187 Orthanc::WebServiceParameters webService; 187 Orthanc::WebServiceParameters webServiceParameters;
188 188
189 if (parameters.count("orthanc")) 189 if (parameters.count("orthanc"))
190 { 190 {
191 webService.SetUrl(parameters["orthanc"].as<std::string>()); 191 webServiceParameters.SetUrl(parameters["orthanc"].as<std::string>());
192 } 192 }
193 193
194 if (parameters.count("username")) 194 if (parameters.count("username"))
195 { 195 {
196 webService.SetUsername(parameters["username"].as<std::string>()); 196 webServiceParameters.SetUsername(parameters["username"].as<std::string>());
197 } 197 }
198 198
199 if (parameters.count("password")) 199 if (parameters.count("password"))
200 { 200 {
201 webService.SetPassword(parameters["password"].as<std::string>()); 201 webServiceParameters.SetPassword(parameters["password"].as<std::string>());
202 } 202 }
203 203
204 LOG(WARNING) << "URL to the Orthanc REST API: " << webService.GetUrl(); 204 LOG(WARNING) << "URL to the Orthanc REST API: " << webServiceParameters.GetUrl();
205 205
206 { 206 {
207 OrthancPlugins::OrthancHttpConnection orthanc(webService); 207 OrthancPlugins::OrthancHttpConnection orthanc(webServiceParameters);
208 if (!MessagingToolbox::CheckOrthancVersion(orthanc)) 208 if (!MessagingToolbox::CheckOrthancVersion(orthanc))
209 { 209 {
210 LOG(ERROR) << "Your version of Orthanc is incompatible with Stone of Orthanc, please upgrade"; 210 LOG(ERROR) << "Your version of Orthanc is incompatible with Stone of Orthanc, please upgrade";
211 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); 211 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
212 } 212 }
218 ****************************************************************/ 218 ****************************************************************/
219 219
220 LOG(WARNING) << "Creating the widgets of the application"; 220 LOG(WARNING) << "Creating the widgets of the application";
221 221
222 LogStatusBar statusBar; 222 LogStatusBar statusBar;
223 OrthancStone::WidgetViewport* centralViewport = new OrthancStone::WidgetViewport(); 223
224 BasicSdlApplicationContext& context = dynamic_cast<BasicSdlApplicationContext&>(application.CreateApplicationContext(webService, centralViewport)); 224 boost::mutex stoneGlobalMutex;
225 225 Oracle oracle(stoneGlobalMutex, 4); // use 4 threads to download content
226 application.Initialize(statusBar, parameters); 226 OracleWebService webService(oracle, webServiceParameters);
227 BasicSdlApplicationContext context(webService);
228
229 application.Initialize(&context, statusBar, parameters);
227 230
228 { 231 {
229 BasicSdlApplicationContext::ViewportLocker locker(context); 232 BasicSdlApplicationContext::ViewportLocker locker(context);
233 context.SetCentralWidget(application.GetCentralWidget());
230 locker.GetViewport().SetStatusBar(statusBar); 234 locker.GetViewport().SetStatusBar(statusBar);
231 } 235 }
232 236
233 std::string title = application.GetTitle(); 237 std::string title = application.GetTitle();
234 if (title.empty()) 238 if (title.empty())