comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1677:51bab5188a13

start multiple preset windowings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 23 Nov 2020 19:24:18 +0100
parents 5e76d5e8167a
children 5b8b88e5bfd6
comparison
equal deleted inserted replaced
1676:5e76d5e8167a 1677:51bab5188a13
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 if (params.HasDefaultWindowing()) 1105 // TODO - WINDOWING
1106 if (params.GetPresetWindowingsCount() > 0)
1106 { 1107 {
1107 GetViewport().defaultWindowingCenter_ = params.GetDefaultWindowingCenter(); 1108 GetViewport().presetWindowingCenter_ = params.GetPresetWindowingCenter(0);
1108 GetViewport().defaultWindowingWidth_ = params.GetDefaultWindowingWidth(); 1109 GetViewport().presetWindowingWidth_ = params.GetPresetWindowingWidth(0);
1109 LOG(INFO) << "Default windowing: " << params.GetDefaultWindowingCenter() 1110 LOG(INFO) << "Preset windowing: " << params.GetPresetWindowingCenter(0)
1110 << "," << params.GetDefaultWindowingWidth(); 1111 << "," << params.GetPresetWindowingWidth(0);
1111 1112
1112 GetViewport().windowingCenter_ = params.GetDefaultWindowingCenter(); 1113 GetViewport().windowingCenter_ = params.GetPresetWindowingCenter(0);
1113 GetViewport().windowingWidth_ = params.GetDefaultWindowingWidth(); 1114 GetViewport().windowingWidth_ = params.GetPresetWindowingWidth(0);
1114 } 1115 }
1115 else 1116 else
1116 { 1117 {
1117 LOG(INFO) << "No default windowing"; 1118 LOG(INFO) << "No preset windowing";
1118 GetViewport().ResetDefaultWindowing(); 1119 GetViewport().ResetPresetWindowing();
1119 } 1120 }
1120 } 1121 }
1121 1122
1122 uint32_t cineRate; 1123 uint32_t cineRate;
1123 if (dicom.ParseUnsignedInteger32(cineRate, Orthanc::DICOM_TAG_CINE_RATE) && 1124 if (dicom.ParseUnsignedInteger32(cineRate, Orthanc::DICOM_TAG_CINE_RATE) &&
1359 boost::shared_ptr<FramesCache> framesCache_; 1360 boost::shared_ptr<FramesCache> framesCache_;
1360 std::unique_ptr<OrthancStone::SortedFrames> frames_; 1361 std::unique_ptr<OrthancStone::SortedFrames> frames_;
1361 std::unique_ptr<SeriesCursor> cursor_; 1362 std::unique_ptr<SeriesCursor> cursor_;
1362 float windowingCenter_; 1363 float windowingCenter_;
1363 float windowingWidth_; 1364 float windowingWidth_;
1364 float defaultWindowingCenter_; 1365 float presetWindowingCenter_;
1365 float defaultWindowingWidth_; 1366 float presetWindowingWidth_;
1366 unsigned int cineRate_; 1367 unsigned int cineRate_;
1367 bool inverted_; 1368 bool inverted_;
1368 bool flipX_; 1369 bool flipX_;
1369 bool flipY_; 1370 bool flipY_;
1370 bool fitNextContent_; 1371 bool fitNextContent_;
1408 } 1409 }
1409 } 1410 }
1410 } 1411 }
1411 1412
1412 1413
1413 void ResetDefaultWindowing() 1414 void ResetPresetWindowing()
1414 { 1415 {
1415 defaultWindowingCenter_ = 128; 1416 presetWindowingCenter_ = 128;
1416 defaultWindowingWidth_ = 256; 1417 presetWindowingWidth_ = 256;
1417 1418
1418 windowingCenter_ = defaultWindowingCenter_; 1419 windowingCenter_ = presetWindowingCenter_;
1419 windowingWidth_ = defaultWindowingWidth_; 1420 windowingWidth_ = presetWindowingWidth_;
1420 1421
1421 inverted_ = false; 1422 inverted_ = false;
1422 } 1423 }
1423 1424
1424 1425
1787 1788
1788 emscripten_set_wheel_callback(viewport_->GetCanvasCssSelector().c_str(), this, true, OnWheel); 1789 emscripten_set_wheel_callback(viewport_->GetCanvasCssSelector().c_str(), this, true, OnWheel);
1789 emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey); 1790 emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey);
1790 emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey); 1791 emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey);
1791 1792
1792 ResetDefaultWindowing(); 1793 ResetPresetWindowing();
1793 } 1794 }
1794 1795
1795 static EM_BOOL OnKey(int eventType, 1796 static EM_BOOL OnKey(int eventType,
1796 const EmscriptenKeyboardEvent *event, 1797 const EmscriptenKeyboardEvent *event,
1797 void *userData) 1798 void *userData)
1895 frames_.reset(frames); 1896 frames_.reset(frames);
1896 cursor_.reset(new SeriesCursor(frames_->GetFramesCount())); 1897 cursor_.reset(new SeriesCursor(frames_->GetFramesCount()));
1897 1898
1898 LOG(INFO) << "Number of frames in series: " << frames_->GetFramesCount(); 1899 LOG(INFO) << "Number of frames in series: " << frames_->GetFramesCount();
1899 1900
1900 ResetDefaultWindowing(); 1901 ResetPresetWindowing();
1901 ClearViewport(); 1902 ClearViewport();
1902 prefetchQueue_.clear(); 1903 prefetchQueue_.clear();
1903 1904
1904 if (observer_.get() != NULL) 1905 if (observer_.get() != NULL)
1905 { 1906 {
2124 lock->Invalidate(); 2125 lock->Invalidate();
2125 } 2126 }
2126 } 2127 }
2127 2128
2128 2129
2129 void SetDefaultWindowing() 2130 void SetPresetWindowing()
2130 { 2131 {
2131 SetWindowing(defaultWindowingCenter_, defaultWindowingWidth_); 2132 SetWindowing(presetWindowingCenter_, presetWindowingWidth_);
2132 } 2133 }
2133 2134
2134 void SetWindowing(float windowingCenter, 2135 void SetWindowing(float windowingCenter,
2135 float windowingWidth) 2136 float windowingWidth)
2136 { 2137 {
2815 EXTERN_CATCH_EXCEPTIONS; 2816 EXTERN_CATCH_EXCEPTIONS;
2816 } 2817 }
2817 2818
2818 2819
2819 EMSCRIPTEN_KEEPALIVE 2820 EMSCRIPTEN_KEEPALIVE
2820 void SetDefaultWindowing(const char* canvas) 2821 void SetPresetWindowing(const char* canvas)
2821 { 2822 {
2822 try 2823 try
2823 { 2824 {
2824 GetViewport(canvas)->SetDefaultWindowing(); 2825 GetViewport(canvas)->SetPresetWindowing();
2825 } 2826 }
2826 EXTERN_CATCH_EXCEPTIONS; 2827 EXTERN_CATCH_EXCEPTIONS;
2827 } 2828 }
2828 2829
2829 2830