From 7c23a80140963fbbc6463e1ef09f6a82879c948d Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Fri, 15 May 2015 16:46:23 +0100 Subject: [PATCH] Updated getDisplayBounds methods for GLObject types, and moved globject <-> overlay type map to a module-level attribute. --- fsl/fslview/gl/glmodel.py | 2 +- fsl/fslview/gl/globject.py | 36 +++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/fsl/fslview/gl/glmodel.py b/fsl/fslview/gl/glmodel.py index 0607762f9..6daa9d9a7 100644 --- a/fsl/fslview/gl/glmodel.py +++ b/fsl/fslview/gl/glmodel.py @@ -30,7 +30,7 @@ class GLModel(globject.GLObject): def getDisplayBounds(self): - return self.overlay.getBounds() + return self.opts.getDisplayBounds() def setAxes(self, xax, yax): diff --git a/fsl/fslview/gl/globject.py b/fsl/fslview/gl/globject.py index 021de69c6..b0eb49031 100644 --- a/fsl/fslview/gl/globject.py +++ b/fsl/fslview/gl/globject.py @@ -15,6 +15,25 @@ representation. import numpy as np +import glvolume +import glmask +import glrgbvector +import gllinevector +import glmodel + + +GLOBJECT_OVERLAY_TYPE_MAP = { + 'volume' : glvolume .GLVolume, + 'mask' : glmask .GLMask, + 'rgbvector' : glrgbvector .GLRGBVector, + 'linevector' : gllinevector.GLLineVector, + 'model' : glmodel .GLModel +} +"""This dictionary provides a mapping between all available overlay types (see +the :attr:`.Display.overlayType` property), and the :class:`GLObject` subclass +used to represent them. +""" + def createGLObject(overlay, display): """Create :class:`GLObject` instance for the given overlay, as specified @@ -25,20 +44,7 @@ def createGLObject(overlay, display): :arg display: A :class:`.Display` instance describing how the overlay should be displayed. """ - - import fsl.fslview.gl.glvolume as glvolume - import fsl.fslview.gl.glmask as glmask - import fsl.fslview.gl.glrgbvector as glrgbvector - import fsl.fslview.gl.gllinevector as gllinevector - - _objectmap = { - 'volume' : glvolume .GLVolume, - 'mask' : glmask .GLMask, - 'rgbvector' : glrgbvector .GLRGBVector, - 'linevector' : gllinevector.GLLineVector - } - - ctr = _objectmap.get(display.overlayType, None) + ctr = GLOBJECT_OVERLAY_TYPE_MAP.get(display.overlayType, None) if ctr is not None: return ctr(overlay, display) else: return None @@ -225,7 +231,7 @@ class GLImageObject(GLObject): def getDisplayBounds(self): - return self.display.getDisplayBounds() + return self.displayOpts.getDisplayBounds() def getDataResolution(self, xax, yax): -- GitLab