comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1721:d4a8e2b19a65

new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 01 Dec 2020 12:51:57 +0100
parents b8d19f53aaca
children 802cb1272f3a
comparison
equal deleted inserted replaced
1720:b8d19f53aaca 1721:d4a8e2b19a65
1607 lock->Invalidate(); 1607 lock->Invalidate();
1608 } 1608 }
1609 } 1609 }
1610 1610
1611 1611
1612 void SaveCurrentWindowing()
1613 {
1614 // Save the current windowing (that could have been altered by
1615 // GrayscaleWindowingSceneTracker), so that it can be reused
1616 // by the next frames
1617
1618 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
1619
1620 OrthancStone::Scene2D& scene = lock->GetController().GetScene();
1621
1622 if (scene.HasLayer(LAYER_TEXTURE) &&
1623 scene.GetLayer(LAYER_TEXTURE).GetType() == OrthancStone::ISceneLayer::Type_FloatTexture)
1624 {
1625 OrthancStone::FloatTextureSceneLayer& layer =
1626 dynamic_cast<OrthancStone::FloatTextureSceneLayer&>(scene.GetLayer(LAYER_TEXTURE));
1627 layer.GetWindowing(windowingCenter_, windowingWidth_);
1628 }
1629 }
1630
1631
1632 /** 1612 /**
1633 * NB: "frame" is only used to estimate the memory size to store 1 1613 * NB: "frame" is only used to estimate the memory size to store 1
1634 * frame, in order to avoid prefetching too much data. 1614 * frame, in order to avoid prefetching too much data.
1635 **/ 1615 **/
1636 void SetupPrefetchAfterRendering(const Orthanc::ImageAccessor& frame, 1616 void SetupPrefetchAfterRendering(const Orthanc::ImageAccessor& frame,
1689 * "SeriesMetadataExtrapolatedTags" includes the "Columns" and 1669 * "SeriesMetadataExtrapolatedTags" includes the "Columns" and
1690 * "Rows" DICOM tags for performance, which make this information 1670 * "Rows" DICOM tags for performance, which make this information
1691 * unreliable if the series includes instances with varying sizes 1671 * unreliable if the series includes instances with varying sizes
1692 * (cf. LSD-479). 1672 * (cf. LSD-479).
1693 **/ 1673 **/
1694
1695 SaveCurrentWindowing();
1696 1674
1697 bool isMonochrome1 = (instance.GetImageInformation().GetPhotometricInterpretation() == 1675 bool isMonochrome1 = (instance.GetImageInformation().GetPhotometricInterpretation() ==
1698 Orthanc::PhotometricInterpretation_Monochrome1); 1676 Orthanc::PhotometricInterpretation_Monochrome1);
1699 1677
1700 std::unique_ptr<OrthancStone::TextureBaseSceneLayer> layer; 1678 std::unique_ptr<OrthancStone::TextureBaseSceneLayer> layer;
2028 emscripten_set_wheel_callback(viewport_->GetCanvasCssSelector().c_str(), this, true, OnWheel); 2006 emscripten_set_wheel_callback(viewport_->GetCanvasCssSelector().c_str(), this, true, OnWheel);
2029 2007
2030 SetWindowingPreset(); 2008 SetWindowingPreset();
2031 } 2009 }
2032 2010
2011
2012 void Handle(const OrthancStone::ViewportController::GrayscaleWindowingChanged& message)
2013 {
2014 // This event is triggered by the windowing mouse action, from class "GrayscaleWindowingSceneTracker"
2015 windowingCenter_ = message.GetWindowingCenter();
2016 windowingWidth_ = message.GetWindowingWidth();
2017
2018 if (observer_.get() != NULL)
2019 {
2020 observer_->SignalWindowingUpdated(*this, message.GetWindowingCenter(), message.GetWindowingWidth());
2021 }
2022 }
2023
2033 2024
2034 static EM_BOOL OnWheel(int eventType, 2025 static EM_BOOL OnWheel(int eventType,
2035 const EmscriptenWheelEvent *wheelEvent, 2026 const EmscriptenWheelEvent *wheelEvent,
2036 void *userData) 2027 void *userData)
2037 { 2028 {
2122 viewport->Register<OrthancStone::HttpCommand::SuccessMessage>( 2113 viewport->Register<OrthancStone::HttpCommand::SuccessMessage>(
2123 lock->GetOracleObservable(), &ViewerViewport::Handle); 2114 lock->GetOracleObservable(), &ViewerViewport::Handle);
2124 2115
2125 viewport->Register<OrthancStone::ParseDicomSuccessMessage>( 2116 viewport->Register<OrthancStone::ParseDicomSuccessMessage>(
2126 lock->GetOracleObservable(), &ViewerViewport::Handle); 2117 lock->GetOracleObservable(), &ViewerViewport::Handle);
2118 }
2119
2120 {
2121 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport->viewport_->Lock());
2122 viewport->Register<OrthancStone::ViewportController::GrayscaleWindowingChanged>(lock->GetController(), &ViewerViewport::Handle);
2127 } 2123 }
2128 2124
2129 return viewport; 2125 return viewport;
2130 } 2126 }
2131 2127
2443 } 2439 }
2444 2440
2445 void FlipX() 2441 void FlipX()
2446 { 2442 {
2447 flipX_ = !flipX_; 2443 flipX_ = !flipX_;
2448 SaveCurrentWindowing();
2449 UpdateCurrentTextureParameters(); 2444 UpdateCurrentTextureParameters();
2450 } 2445 }
2451 2446
2452 void FlipY() 2447 void FlipY()
2453 { 2448 {
2454 flipY_ = !flipY_; 2449 flipY_ = !flipY_;
2455 SaveCurrentWindowing();
2456 UpdateCurrentTextureParameters(); 2450 UpdateCurrentTextureParameters();
2457 } 2451 }
2458 2452
2459 void Invert() 2453 void Invert()
2460 { 2454 {