From 4b78b339cc64e6016083ff57a4a2e4b7d59a76dc Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauld.mccarthy@gmail.com>
Date: Mon, 2 Nov 2015 09:51:44 +0000
Subject: [PATCH] PlotPanel sub-classes now need to override/implement a method
 called 'getDataSeries'. Am planning to consolidate shared functionality
 between time series/histogram/power spectrum panels.

---
 .../controls/timeseriescontrolpanel.py        |  2 +-
 fsl/fsleyes/controls/timeserieslistpanel.py   |  4 ++--
 fsl/fsleyes/views/plotpanel.py                | 19 ++++++++++++++++++-
 fsl/fsleyes/views/timeseriespanel.py          |  7 ++++---
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/fsl/fsleyes/controls/timeseriescontrolpanel.py b/fsl/fsleyes/controls/timeseriescontrolpanel.py
index 9787fc16f..b8c26c6f6 100644
--- a/fsl/fsleyes/controls/timeseriescontrolpanel.py
+++ b/fsl/fsleyes/controls/timeseriescontrolpanel.py
@@ -203,7 +203,7 @@ class TimeSeriesControlPanel(fslpanel.FSLEyesPanel):
         if overlay is None:
             return
 
-        ts = self.__tsPanel.getTimeSeries(overlay)
+        ts = self.__tsPanel.getDataSeries(overlay)
 
         if ts is None:
             return
diff --git a/fsl/fsleyes/controls/timeserieslistpanel.py b/fsl/fsleyes/controls/timeserieslistpanel.py
index 76d469d76..b8c176af0 100644
--- a/fsl/fsleyes/controls/timeserieslistpanel.py
+++ b/fsl/fsleyes/controls/timeserieslistpanel.py
@@ -134,7 +134,7 @@ class TimeSeriesListPanel(fslpanel.FSLEyesPanel):
 
         overlay = self._displayCtx.getSelectedOverlay()
 
-        ts = self.__tsPanel.getTimeSeries(overlay)
+        ts = self.__tsPanel.getDataSeries(overlay)
 
         if ts is None:
             self.__currentLabel.SetLabel('')
@@ -157,7 +157,7 @@ class TimeSeriesListPanel(fslpanel.FSLEyesPanel):
         if overlay is None:
             return
         
-        ts = self.__tsPanel.getTimeSeries(overlay)
+        ts = self.__tsPanel.getDataSeries(overlay)
 
         if ts is None:
             return
diff --git a/fsl/fsleyes/views/plotpanel.py b/fsl/fsleyes/views/plotpanel.py
index e80aa4b78..6e04dd227 100644
--- a/fsl/fsleyes/views/plotpanel.py
+++ b/fsl/fsleyes/views/plotpanel.py
@@ -58,7 +58,10 @@ class PlotPanel(viewpanel.ViewPanel):
       3. Override the :meth:`draw` method, so it calls the
          :meth:`drawDataSeries` method.
 
-      4. If necessary, override the :meth:`destroy` method, but make
+      4. Override the :meth:`getDataSeries` method, so it returns a
+         :class:`.DataSeries` instance associated with a given overlay.
+
+      5. If necessary, override the :meth:`destroy` method, but make
          sure that the base-class implementation is called.
 
     
@@ -275,6 +278,20 @@ class PlotPanel(viewpanel.ViewPanel):
         raise NotImplementedError('The draw method must be '
                                   'implemented by PlotPanel subclasses')
 
+
+    def getDataSeries(self, overlay):
+        """This method must be overridden by ``PlotPanel`` sub-classes.
+
+        It may be called by the :class:`.PlotControlPanel` and
+        :class:`.PlotListPanel` to display controls allowing the user
+        to change :class:`.DataSeries` display properties.
+
+        It should return the :class:`.DataSeries` instance associated with
+        the given overlay, or ``None`` if there is no ``DataSeries`` instance.
+        """
+        raise NotImplementedError('The getDataSeries method must be '
+                                  'implemented by PlotPanel subclasses')
+
         
     def destroy(self):
         """Removes some property listeners, and then calls
diff --git a/fsl/fsleyes/views/timeseriespanel.py b/fsl/fsleyes/views/timeseriespanel.py
index 4dc883895..4271c6528 100644
--- a/fsl/fsleyes/views/timeseriespanel.py
+++ b/fsl/fsleyes/views/timeseriespanel.py
@@ -291,9 +291,10 @@ class TimeSeriesPanel(plotpanel.PlotPanel):
                             preproc=self.__prepareTimeSeriesData)
 
 
-    def getTimeSeries(self, overlay):
-        """Returns the :class:`.TimeSeries` instance for the specified
-        overlay, or ``None`` if there is none.
+    def getDataSeries(self, overlay):
+        """Overrides :meth:`.PlotPanel.getDataSeries`. Returns the
+        :class:`.TimeSeries` instance for the specified overlay, or ``None``
+        if there is none.
         """
         return self.__currentTss.get(overlay)
 
-- 
GitLab