diff --git a/fsl/fslview/gl/globject.py b/fsl/fslview/gl/globject.py index abc16f3ed8fa5e5776f806f582dad4c7e6cac7ce..ded626cc318913de7e258713c01825fc30c8a683 100644 --- a/fsl/fslview/gl/globject.py +++ b/fsl/fslview/gl/globject.py @@ -53,25 +53,16 @@ def createGLObject(image, display): class GLObject(object): """The :class:`GLObject` class is a superclass for all 2D OpenGL - representations of :class:`~fsl.data.image.Image` instances. + objects. """ - def __init__(self, image, display): - """Create a :class:`GLObject`. The constructor adds three - attributes to this instance: - - ``image``: A reference to the image. - - ``display``: A reference to the display. - - ``displayOpts``: A reference to the image type-specific display - options. - - :arg image: The :class:`~fsl.data.image.Image` instance - :arg display: An associated - :class:`~fsl.fslview.displaycontext.Display` instance. + def __init__(self): + """Create a :class:`GLObject`. The constructor adds one attribute to + this instance, ``name``, which is simply a unique name for this + instance. """ - self.image = image - self.display = display - self.displayOpts = display.getDisplayOpts() - self.name = '{}_{}'.format(type(self).__name__, id(self)) + + self.name = '{}_{}'.format(type(self).__name__, id(self)) def init(self): @@ -82,8 +73,8 @@ class GLObject(object): def ready(self): - """This method should return ``False`` if this :class:`GLObject` is not yet - ready to be displayed, ``True`` otherwise. + """This method should return ``False`` if this :class:`GLObject` is + not yet ready to be displayed, ``True`` otherwise. """ raise NotImplementedError() @@ -137,12 +128,38 @@ class GLObject(object): raise NotImplementedError() +class GLImageObject(GLObject): + """The ``GLImageObject` class is the superclass for all GL representations + of :class:`~fsl.data.image.Image` instances. + """ + + def __init__(self, image, display): + """Create a ``GLImageObject``. + + This constructor adds the following attributes to this instance: + + - ``image``: A reference to the image. + - ``display``: A reference to the display. + - ``displayOpts``: A reference to the image type-specific display + options. + + :arg image: The :class:`~fsl.data.image.Image` instance + :arg display: An associated + :class:`~fsl.fslview.displaycontext.Display` instance. + """ + + GLObject.__init__(self) + self.image = image + self.display = display + self.displayOpts = display.getDisplayOpts() + def calculateSamplePoints(image, display, xax, yax): - """Calculates a uniform grid of points, in the display coordinate system (as - specified by the given :class:`~fsl.fslview.displaycontext.ImageDisplay` - object properties) along the x-y plane (as specified by the xax/yax - indices), at which the given image should be sampled for display purposes. + """Calculates a uniform grid of points, in the display coordinate system + (as specified by the given + :class:`~fsl.fslview.displaycontext.ImageDisplay` object properties) along + the x-y plane (as specified by the xax/yax indices), at which the given + image should be sampled for display purposes. This function returns a tuple containing: @@ -246,8 +263,8 @@ def samplePointsToTriangleStrip(coords, ylen, xax, yax): - """Given a regular 2D grid of points at which an image is to be sampled (for - example, that generated by the :func:`calculateSamplePoints` function + """Given a regular 2D grid of points at which an image is to be sampled + (for example, that generated by the :func:`calculateSamplePoints` function above), converts those points into an OpenGL vertex triangle strip. A grid of M*N points is represented by M*2*(N + 1) vertices. For example, diff --git a/fsl/fslview/gl/glvector.py b/fsl/fslview/gl/glvector.py index 3b5b2d965dee43d180feb1892e49bbf7218dd6b6..454b646ff465ccbc21e8451542abb8c7f3b64b71 100644 --- a/fsl/fslview/gl/glvector.py +++ b/fsl/fslview/gl/glvector.py @@ -98,7 +98,7 @@ def _rgbModePrefilter(data): return np.abs(data.transpose((3, 0, 1, 2))) -class GLVector(globject.GLObject): +class GLVector(globject.GLImageObject): """The :class:`GLVector` class encapsulates the data and logic required to render 2D slices of a ``X*Y*Z*3`` image as vectors. """ @@ -118,7 +118,7 @@ class GLVector(globject.GLObject): raise ValueError('Image must be 4 dimensional, with 3 volumes ' 'representing the XYZ vector angles') - globject.GLObject.__init__(self, image, display) + globject.GLImageObject.__init__(self, image, display) self._ready = False diff --git a/fsl/fslview/gl/glvolume.py b/fsl/fslview/gl/glvolume.py index 28a8fb981c3879c07939ec9cef3bea2dc0ece3ec..2ae2f42cfea80871d8e74bfa8a7c57eb53f5184e 100644 --- a/fsl/fslview/gl/glvolume.py +++ b/fsl/fslview/gl/glvolume.py @@ -59,7 +59,7 @@ import fsl.fslview.gl.textures as fsltextures import fsl.fslview.gl.globject as globject -class GLVolume(globject.GLObject): +class GLVolume(globject.GLImageObject): """The :class:`GLVolume` class encapsulates the data and logic required to render 2D slices of a 3D image. """ @@ -75,7 +75,7 @@ class GLVolume(globject.GLObject): displayed. """ - globject.GLObject.__init__(self, image, display) + globject.GLImageObject.__init__(self, image, display) self._ready = False