Mercurial > hg > orthanc-stone
diff 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 |
line wrap: on
line diff
--- a/Samples/WebAssembly/BasicMPR.cpp Fri May 31 09:12:05 2019 +0200 +++ b/Samples/WebAssembly/BasicMPR.cpp Fri May 31 10:30:22 2019 +0200 @@ -318,7 +318,27 @@ } }; - static TestSleep testSleep(broker_, oracle_); + //static TestSleep testSleep(broker_, oracle_); +} + + + +static std::map<std::string, std::string> arguments_; + +static bool GetArgument(std::string& value, + const std::string& key) +{ + std::map<std::string, std::string>::const_iterator found = arguments_.find(key); + + if (found == arguments_.end()) + { + return false; + } + else + { + value = found->second; + return true; + } } @@ -333,10 +353,20 @@ } EMSCRIPTEN_KEEPALIVE + void SetArgument(const char* key, const char* value) + { + // This is called for each GET argument (cf. "app.js") + LOG(INFO) << "Received GET argument: [" << key << "] = [" << value << "]"; + arguments_[key] = value; + } + + EMSCRIPTEN_KEEPALIVE void Initialize() { try { + oracle_.SetOrthancRoot(".."); + loader_.reset(new OrthancStone::OrthancSeriesVolumeProgressiveLoader(ct_, oracle_, oracle_)); widget1_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas1", OrthancStone::VolumeProjection_Axial)); @@ -362,7 +392,17 @@ emscripten_request_animation_frame_loop(OnAnimationFrame, NULL); - loader_->LoadSeries("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"); + + std::string ct; + if (GetArgument(ct, "ct")) + { + //loader_->LoadSeries("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"); + loader_->LoadSeries(ct); + } + else + { + LOG(ERROR) << "No Orthanc identifier for the CT series was provided"; + } } catch (Orthanc::OrthancException& e) {