comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1679:5b8b88e5bfd6

successfully running unit tests in WebAssembly
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 24 Nov 2020 12:59:10 +0100
parents 51bab5188a13
children 03afa09cfcf1
comparison
equal deleted inserted replaced
1678:1393e3393a0b 1679:5b8b88e5bfd6
1100 const Orthanc::DicomMap& dicom = message.GetResources()->GetResource(0); 1100 const Orthanc::DicomMap& dicom = message.GetResources()->GetResource(0);
1101 1101
1102 { 1102 {
1103 OrthancStone::DicomInstanceParameters params(dicom); 1103 OrthancStone::DicomInstanceParameters params(dicom);
1104 1104
1105 for (size_t i = 0; i < params.GetWindowingPresetsCount(); i++)
1106 {
1107 LOG(INFO) << "Preset windowing " << i << "/" << params.GetWindowingPresetsCount()
1108 << ": " << params.GetWindowingPresetCenter(i)
1109 << "," << params.GetWindowingPresetWidth(i);
1110 }
1111
1105 // TODO - WINDOWING 1112 // TODO - WINDOWING
1106 if (params.GetPresetWindowingsCount() > 0) 1113 if (params.GetWindowingPresetsCount() > 0)
1107 { 1114 {
1108 GetViewport().presetWindowingCenter_ = params.GetPresetWindowingCenter(0); 1115 GetViewport().presetWindowingCenter_ = params.GetWindowingPresetCenter(0);
1109 GetViewport().presetWindowingWidth_ = params.GetPresetWindowingWidth(0); 1116 GetViewport().presetWindowingWidth_ = params.GetWindowingPresetWidth(0);
1110 LOG(INFO) << "Preset windowing: " << params.GetPresetWindowingCenter(0) 1117
1111 << "," << params.GetPresetWindowingWidth(0); 1118 GetViewport().windowingCenter_ = params.GetWindowingPresetCenter(0);
1112 1119 GetViewport().windowingWidth_ = params.GetWindowingPresetWidth(0);
1113 GetViewport().windowingCenter_ = params.GetPresetWindowingCenter(0);
1114 GetViewport().windowingWidth_ = params.GetPresetWindowingWidth(0);
1115 } 1120 }
1116 else 1121 else
1117 { 1122 {
1118 LOG(INFO) << "No preset windowing"; 1123 LOG(INFO) << "No preset windowing";
1119 GetViewport().ResetPresetWindowing(); 1124 GetViewport().ResetWindowingPreset();
1120 } 1125 }
1121 } 1126 }
1122 1127
1123 uint32_t cineRate; 1128 uint32_t cineRate;
1124 if (dicom.ParseUnsignedInteger32(cineRate, Orthanc::DICOM_TAG_CINE_RATE) && 1129 if (dicom.ParseUnsignedInteger32(cineRate, Orthanc::DICOM_TAG_CINE_RATE) &&
1409 } 1414 }
1410 } 1415 }
1411 } 1416 }
1412 1417
1413 1418
1414 void ResetPresetWindowing() 1419 void ResetWindowingPreset()
1415 { 1420 {
1416 presetWindowingCenter_ = 128; 1421 presetWindowingCenter_ = 128;
1417 presetWindowingWidth_ = 256; 1422 presetWindowingWidth_ = 256;
1418 1423
1419 windowingCenter_ = presetWindowingCenter_; 1424 windowingCenter_ = presetWindowingCenter_;
1788 1793
1789 emscripten_set_wheel_callback(viewport_->GetCanvasCssSelector().c_str(), this, true, OnWheel); 1794 emscripten_set_wheel_callback(viewport_->GetCanvasCssSelector().c_str(), this, true, OnWheel);
1790 emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey); 1795 emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey);
1791 emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey); 1796 emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey);
1792 1797
1793 ResetPresetWindowing(); 1798 ResetWindowingPreset();
1794 } 1799 }
1795 1800
1796 static EM_BOOL OnKey(int eventType, 1801 static EM_BOOL OnKey(int eventType,
1797 const EmscriptenKeyboardEvent *event, 1802 const EmscriptenKeyboardEvent *event,
1798 void *userData) 1803 void *userData)
1896 frames_.reset(frames); 1901 frames_.reset(frames);
1897 cursor_.reset(new SeriesCursor(frames_->GetFramesCount())); 1902 cursor_.reset(new SeriesCursor(frames_->GetFramesCount()));
1898 1903
1899 LOG(INFO) << "Number of frames in series: " << frames_->GetFramesCount(); 1904 LOG(INFO) << "Number of frames in series: " << frames_->GetFramesCount();
1900 1905
1901 ResetPresetWindowing(); 1906 ResetWindowingPreset();
1902 ClearViewport(); 1907 ClearViewport();
1903 prefetchQueue_.clear(); 1908 prefetchQueue_.clear();
1904 1909
1905 if (observer_.get() != NULL) 1910 if (observer_.get() != NULL)
1906 { 1911 {
2125 lock->Invalidate(); 2130 lock->Invalidate();
2126 } 2131 }
2127 } 2132 }
2128 2133
2129 2134
2130 void SetPresetWindowing() 2135 void SetWindowingPreset()
2131 { 2136 {
2132 SetWindowing(presetWindowingCenter_, presetWindowingWidth_); 2137 SetWindowing(presetWindowingCenter_, presetWindowingWidth_);
2133 } 2138 }
2134 2139
2135 void SetWindowing(float windowingCenter, 2140 void SetWindowing(float windowingCenter,
2325 } 2330 }
2326 2331
2327 unsigned int GetCineRate() const 2332 unsigned int GetCineRate() const
2328 { 2333 {
2329 return cineRate_; 2334 return cineRate_;
2335 }
2336
2337 void FormatWindowingPresets(Json::Value& target) const
2338 {
2339 target = Json::arrayValue;
2330 } 2340 }
2331 }; 2341 };
2332 2342
2333 2343
2334 2344
2816 EXTERN_CATCH_EXCEPTIONS; 2826 EXTERN_CATCH_EXCEPTIONS;
2817 } 2827 }
2818 2828
2819 2829
2820 EMSCRIPTEN_KEEPALIVE 2830 EMSCRIPTEN_KEEPALIVE
2821 void SetPresetWindowing(const char* canvas) 2831 void SetWindowingPreset(const char* canvas)
2822 { 2832 {
2823 try 2833 try
2824 { 2834 {
2825 GetViewport(canvas)->SetPresetWindowing(); 2835 GetViewport(canvas)->SetWindowingPreset();
2826 } 2836 }
2827 EXTERN_CATCH_EXCEPTIONS; 2837 EXTERN_CATCH_EXCEPTIONS;
2828 } 2838 }
2829 2839
2830 2840
3015 { 3025 {
3016 return GetResourcesLoader().GetSeriesNumberOfFrames(seriesInstanceUid); 3026 return GetResourcesLoader().GetSeriesNumberOfFrames(seriesInstanceUid);
3017 } 3027 }
3018 EXTERN_CATCH_EXCEPTIONS; 3028 EXTERN_CATCH_EXCEPTIONS;
3019 return 0; 3029 return 0;
3020 } 3030 }
3031
3032
3033 EMSCRIPTEN_KEEPALIVE
3034 void LoadWindowingPresets(const char* canvas)
3035 {
3036 try
3037 {
3038 Json::Value v;
3039 GetViewport(canvas)->FormatWindowingPresets(v);
3040 stringBuffer_ = v.toStyledString();
3041 }
3042 EXTERN_CATCH_EXCEPTIONS;
3043 }
3021 } 3044 }