Mercurial > hg > orthanc-stone
comparison Samples/WebAssembly/BasicMPR.cpp @ 831:d71cf8504159
handling of GET arguments
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 31 May 2019 10:30:22 +0200 |
parents | 2de01660debe |
children | 0965b665c653 |
comparison
equal
deleted
inserted
replaced
830:171a486a0373 | 831:d71cf8504159 |
---|---|
316 LOG(INFO) << "STARTING"; | 316 LOG(INFO) << "STARTING"; |
317 Schedule(); | 317 Schedule(); |
318 } | 318 } |
319 }; | 319 }; |
320 | 320 |
321 static TestSleep testSleep(broker_, oracle_); | 321 //static TestSleep testSleep(broker_, oracle_); |
322 } | |
323 | |
324 | |
325 | |
326 static std::map<std::string, std::string> arguments_; | |
327 | |
328 static bool GetArgument(std::string& value, | |
329 const std::string& key) | |
330 { | |
331 std::map<std::string, std::string>::const_iterator found = arguments_.find(key); | |
332 | |
333 if (found == arguments_.end()) | |
334 { | |
335 return false; | |
336 } | |
337 else | |
338 { | |
339 value = found->second; | |
340 return true; | |
341 } | |
322 } | 342 } |
323 | 343 |
324 | 344 |
325 extern "C" | 345 extern "C" |
326 { | 346 { |
331 // Orthanc::Logging::EnableTraceLevel(true); | 351 // Orthanc::Logging::EnableTraceLevel(true); |
332 EM_ASM(window.dispatchEvent(new CustomEvent("WebAssemblyLoaded"));); | 352 EM_ASM(window.dispatchEvent(new CustomEvent("WebAssemblyLoaded"));); |
333 } | 353 } |
334 | 354 |
335 EMSCRIPTEN_KEEPALIVE | 355 EMSCRIPTEN_KEEPALIVE |
356 void SetArgument(const char* key, const char* value) | |
357 { | |
358 // This is called for each GET argument (cf. "app.js") | |
359 LOG(INFO) << "Received GET argument: [" << key << "] = [" << value << "]"; | |
360 arguments_[key] = value; | |
361 } | |
362 | |
363 EMSCRIPTEN_KEEPALIVE | |
336 void Initialize() | 364 void Initialize() |
337 { | 365 { |
338 try | 366 try |
339 { | 367 { |
368 oracle_.SetOrthancRoot(".."); | |
369 | |
340 loader_.reset(new OrthancStone::OrthancSeriesVolumeProgressiveLoader(ct_, oracle_, oracle_)); | 370 loader_.reset(new OrthancStone::OrthancSeriesVolumeProgressiveLoader(ct_, oracle_, oracle_)); |
341 | 371 |
342 widget1_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas1", OrthancStone::VolumeProjection_Axial)); | 372 widget1_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas1", OrthancStone::VolumeProjection_Axial)); |
343 widget1_->SetSlicer(0, loader_, *loader_, new OrthancStone::GrayscaleStyleConfigurator); | 373 widget1_->SetSlicer(0, loader_, *loader_, new OrthancStone::GrayscaleStyleConfigurator); |
344 widget1_->UpdateSize(); | 374 widget1_->UpdateSize(); |
360 emscripten_set_keydown_callback("#window", NULL, false, OnKeyDown); | 390 emscripten_set_keydown_callback("#window", NULL, false, OnKeyDown); |
361 emscripten_set_keyup_callback("#window", NULL, false, OnKeyUp); | 391 emscripten_set_keyup_callback("#window", NULL, false, OnKeyUp); |
362 | 392 |
363 emscripten_request_animation_frame_loop(OnAnimationFrame, NULL); | 393 emscripten_request_animation_frame_loop(OnAnimationFrame, NULL); |
364 | 394 |
365 loader_->LoadSeries("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"); | 395 |
396 std::string ct; | |
397 if (GetArgument(ct, "ct")) | |
398 { | |
399 //loader_->LoadSeries("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"); | |
400 loader_->LoadSeries(ct); | |
401 } | |
402 else | |
403 { | |
404 LOG(ERROR) << "No Orthanc identifier for the CT series was provided"; | |
405 } | |
366 } | 406 } |
367 catch (Orthanc::OrthancException& e) | 407 catch (Orthanc::OrthancException& e) |
368 { | 408 { |
369 LOG(ERROR) << "Exception during Initialize(): " << e.What(); | 409 LOG(ERROR) << "Exception during Initialize(): " << e.What(); |
370 } | 410 } |