# HG changeset patch # User Alain Mazy # Date 1563529245 -7200 # Node ID 912cc77be3b411e98632615a4933730a63a624f3 # Parent e4ac54cb8771bc652b08e1aef2d73bf3dd7f3ea0# Parent 4d1f57773b5be15414885de20d9ada99c0392052 merge diff -r e4ac54cb8771 -r 912cc77be3b4 Applications/Generic/GuiAdapter.cpp --- a/Applications/Generic/GuiAdapter.cpp Thu Jul 18 10:57:59 2019 +0200 +++ b/Applications/Generic/GuiAdapter.cpp Fri Jul 19 11:40:45 2019 +0200 @@ -725,7 +725,7 @@ // SDL ONLY void GuiAdapter::Run() { -#if 0 +#if 1 // TODO: MAKE THIS DYNAMIC !!! See SdlOpenGLViewport vs Cairo in ViewportWrapper # if ORTHANC_ENABLE_OPENGL == 1 && !defined(__APPLE__) glEnable(GL_DEBUG_OUTPUT); diff -r e4ac54cb8771 -r 912cc77be3b4 Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp --- a/Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Thu Jul 18 10:57:59 2019 +0200 +++ b/Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Fri Jul 19 11:40:45 2019 +0200 @@ -264,7 +264,10 @@ if (quality == BEST_QUALITY) { std::auto_ptr tmp(new GetOrthancImageCommand); - tmp->SetHttpHeader("Accept-Encoding", "gzip"); + // TODO: review the following comment. Commented out by bgo on 2019-07-19 + // reason: Alain has seen cases where gzipping the uint16 image took 11 sec + // to produce 5mb. The unzipped request was much much faster. + //tmp->SetHttpHeader("Accept-Encoding", "gzip"); tmp->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam))); tmp->SetInstanceUri(instance, slice.GetExpectedPixelFormat()); tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); @@ -273,7 +276,9 @@ else { std::auto_ptr tmp(new GetOrthancWebViewerJpegCommand); - tmp->SetHttpHeader("Accept-Encoding", "gzip"); + // TODO: review the following comment. Commented out by bgo on 2019-07-19 + // (gzip for jpeg seems overkill) + //tmp->SetHttpHeader("Accept-Encoding", "gzip"); tmp->SetInstance(instance); tmp->SetQuality((quality == 0 ? 50 : 90)); tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); diff -r e4ac54cb8771 -r 912cc77be3b4 Framework/Scene2D/FloatTextureSceneLayer.cpp --- a/Framework/Scene2D/FloatTextureSceneLayer.cpp Thu Jul 18 10:57:59 2019 +0200 +++ b/Framework/Scene2D/FloatTextureSceneLayer.cpp Fri Jul 19 11:40:45 2019 +0200 @@ -93,7 +93,6 @@ IncrementRevision(); } - void FloatTextureSceneLayer::FitRange() { float minValue, maxValue; diff -r e4ac54cb8771 -r 912cc77be3b4 Framework/Scene2D/GrayscaleStyleConfigurator.cpp --- a/Framework/Scene2D/GrayscaleStyleConfigurator.cpp Thu Jul 18 10:57:59 2019 +0200 +++ b/Framework/Scene2D/GrayscaleStyleConfigurator.cpp Fri Jul 19 11:40:45 2019 +0200 @@ -34,6 +34,19 @@ revision_++; } + void GrayscaleStyleConfigurator::SetCustomWindowing(float windowCenter, float windowWidth) + { + SetWindowing(ImageWindowing_Custom); + customWindowCenter_ = windowCenter; + customWindowWidth_ = windowWidth; + } + + + void GrayscaleStyleConfigurator::SetInverted(bool inverted) + { + inverted_ = inverted; + revision_++; + } void GrayscaleStyleConfigurator::SetLinearInterpolation(bool enabled) { @@ -41,14 +54,12 @@ revision_++; } - TextureBaseSceneLayer* GrayscaleStyleConfigurator::CreateTextureFromImage( const Orthanc::ImageAccessor& image) const { throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); } - TextureBaseSceneLayer* GrayscaleStyleConfigurator::CreateTextureFromDicom( const Orthanc::ImageAccessor& frame, const DicomInstanceParameters& parameters) const @@ -66,7 +77,6 @@ } } - void GrayscaleStyleConfigurator::ApplyStyle(ISceneLayer& layer) const { FloatTextureSceneLayer& l = dynamic_cast(layer); @@ -75,7 +85,15 @@ if (hasWindowing_) { - l.SetWindowing(windowing_); + if (windowing_ != ImageWindowing_Custom) + { + l.SetWindowing(windowing_); + } + else + { + l.SetCustomWindowing(customWindowCenter_, customWindowWidth_); + } } + l.SetInverted(inverted_); } } diff -r e4ac54cb8771 -r 912cc77be3b4 Framework/Scene2D/GrayscaleStyleConfigurator.h --- a/Framework/Scene2D/GrayscaleStyleConfigurator.h Thu Jul 18 10:57:59 2019 +0200 +++ b/Framework/Scene2D/GrayscaleStyleConfigurator.h Fri Jul 19 11:40:45 2019 +0200 @@ -36,19 +36,27 @@ bool linearInterpolation_; bool hasWindowing_; ImageWindowing windowing_; - - // TODO - Add custom windowing + float customWindowWidth_; + float customWindowCenter_; + bool inverted_; public: GrayscaleStyleConfigurator() : revision_(0), linearInterpolation_(false), - hasWindowing_(false) + hasWindowing_(false), + customWindowWidth_(0), + customWindowCenter_(0), + inverted_(false) { } void SetWindowing(ImageWindowing windowing); + void SetCustomWindowing(float windowWidth, float windowCenter); + + void SetInverted(bool inverted); + void SetLinearInterpolation(bool enabled); bool IsLinearInterpolation() const diff -r e4ac54cb8771 -r 912cc77be3b4 Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp --- a/Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp Thu Jul 18 10:57:59 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp Fri Jul 19 11:40:45 2019 +0200 @@ -33,6 +33,7 @@ "uniform float u_slope; \n" "uniform float u_windowCenter; \n" "uniform float u_windowWidth; \n" + "uniform bool u_invert; \n" "uniform sampler2D u_texture; \n" "varying vec2 v_texcoord; \n" "void main() \n" @@ -50,6 +51,8 @@ " if (v >= 1.0) \n" " v = 1.0; \n" " } \n" + " if (u_invert) \n" + " v = 1.0 - v; \n" " gl_FragColor = vec4(v, v, v, 1); \n" "}"; @@ -133,7 +136,8 @@ void OpenGLFloatTextureProgram::Apply(Data& data, const AffineTransform2D& transform, float windowCenter, - float windowWidth) + float windowWidth, + bool invert) { OpenGLTextureProgram::Execution execution(program_, data.GetTexture(), transform); @@ -141,6 +145,7 @@ glUniform1f(execution.GetUniformLocation("u_offset"), data.GetOffset()); glUniform1f(execution.GetUniformLocation("u_windowCenter"), windowCenter); glUniform1f(execution.GetUniformLocation("u_windowWidth"), windowWidth); + glUniform1f(execution.GetUniformLocation("u_invert"), invert); execution.DrawTriangles(); } diff -r e4ac54cb8771 -r 912cc77be3b4 Framework/Scene2D/Internals/OpenGLFloatTextureProgram.h --- a/Framework/Scene2D/Internals/OpenGLFloatTextureProgram.h Thu Jul 18 10:57:59 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLFloatTextureProgram.h Fri Jul 19 11:40:45 2019 +0200 @@ -66,7 +66,8 @@ void Apply(Data& data, const AffineTransform2D& transform, float windowCenter, - float windowWidth); + float windowWidth, + bool invert); }; } } diff -r e4ac54cb8771 -r 912cc77be3b4 Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.cpp --- a/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.cpp Thu Jul 18 10:57:59 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.cpp Fri Jul 19 11:40:45 2019 +0200 @@ -36,6 +36,7 @@ layerTransform_ = layer.GetTransform(); layer.GetWindowing(windowCenter_, windowWidth_); + invert_ = layer.IsInverted(); } @@ -56,7 +57,7 @@ if (texture_.get() != NULL) { program_.Apply(*texture_, AffineTransform2D::Combine(transform, layerTransform_), - windowCenter_, windowWidth_); + windowCenter_, windowWidth_, invert_); } } diff -r e4ac54cb8771 -r 912cc77be3b4 Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.h --- a/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.h Thu Jul 18 10:57:59 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.h Fri Jul 19 11:40:45 2019 +0200 @@ -38,6 +38,7 @@ AffineTransform2D layerTransform_; float windowCenter_; float windowWidth_; + bool invert_; void UpdateInternal(const FloatTextureSceneLayer& layer, bool loadTexture);