From ab094ecfc49dbb5b371e2754018741f5065a3be2 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauld.mccarthy@gmail.com>
Date: Mon, 7 Dec 2015 09:52:48 +0000
Subject: [PATCH] Hacky way to get the displayRange sliders to have the data
 range as their limits.

---
 fsl/fsleyes/controls/overlaydisplaypanel.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/fsl/fsleyes/controls/overlaydisplaypanel.py b/fsl/fsleyes/controls/overlaydisplaypanel.py
index aa01a05c8..ff4e9ac3c 100644
--- a/fsl/fsleyes/controls/overlaydisplaypanel.py
+++ b/fsl/fsleyes/controls/overlaydisplaypanel.py
@@ -226,6 +226,23 @@ class OverlayDisplayPanel(fslpanel.FSLEyesPanel):
             if isinstance(target, displayctx.VolumeOpts) and \
                p.key == 'cmap':
                 widget = self.__buildColourMapWidget(widget)
+
+            if isinstance(target, displayctx.VolumeOpts) and \
+               p.key == 'displayRange':
+                
+                # This is a big hack. The VolumeOpts displayRange
+                # has limits which are much bigger than the data
+                # range, due to the relationship between display
+                # range and brightness/contrast. But we want the
+                # display range sliders to have the data range as
+                # their limits. You should think of a nicer way
+                # to do this.
+                log.debug('Forcing displayRange slider range to data '
+                          'range: [{:0.3f}, {:0.3f}]'.format(
+                              target.dataMin, target.dataMax))
+                
+                widget.GetChildren()[0].SetLimits(target.dataMin,
+                                                  target.dataMax)
                 
             widgets.append(widget)
 
-- 
GitLab