diff --git a/fsl/fslview/orthopanel.py b/fsl/fslview/orthopanel.py index df468189617b38d77de491d7716166071f3813f8..0c774506846048b1d40870ac0574904eea610e2b 100644 --- a/fsl/fslview/orthopanel.py +++ b/fsl/fslview/orthopanel.py @@ -7,8 +7,6 @@ # Author: Paul McCarthy <pauldmccarthy@gmail.com> # -import sys - if True: import logging logging.basicConfig( @@ -154,26 +152,3 @@ class OrthoFrame(wx.Frame): wx.Frame.__init__(self, parent, title=title) self.panel = OrthoPanel(self, imageList) self.Layout() - - -def main(): - """ - Test program, displays the image specified on the command line. - """ - - if len(sys.argv) != 2: - print 'usage: orthopanel.py filename' - sys.exit(1) - - app = wx.App() - image = fslimage.Image(sys.argv[1]) - imageList = fslimage.ImageList([image]) - - frame = OrthoFrame(None, imageList, title=sys.argv[1]) - frame.Show() - - app.MainLoop() - - -if __name__ == '__main__': - main() diff --git a/fsl/fslview/slicecanvas.py b/fsl/fslview/slicecanvas.py index a2b6707a2e7f255e1070c4f45d07d6d435826c6e..5071bbde76093f56c070841e1c165c4c148b3d6d 100644 --- a/fsl/fslview/slicecanvas.py +++ b/fsl/fslview/slicecanvas.py @@ -455,26 +455,12 @@ class SliceCanvas(wxgl.GLCanvas): self.yax = dims[1] self.zax = zax - # These attributes define the current location - # of the cursor, and the displayed slice. They - # are initialised in the _imageListChanged - # method. + # Current cursor location, initialised + # in _imageListChanged self._xpos = None self._ypos = None self._zpos = None - # These attributes define the spatial data - # limits of all displayed images. They are - # set by the _imageListChanged method, and - # updated whenever an image is added/removed - # from the list. - self.xmin = 0 - self.ymin = 0 - self.zmin = 0 - self.xmax = 1 - self.ymax = 1 - self.zmax = 1 - # This flag is set by the _initGLData method # when it has finished initialising the OpenGL # shaders @@ -499,18 +485,43 @@ class SliceCanvas(wxgl.GLCanvas): """ if len(self.imageList) == 0: - self. xmin = 0 - self. ymin = 0 - self. zmin = 0 - self. xmax = 1 - self. ymax = 1 - self. zmax = 1 - self._xpos = None - self._ypos = None - self._zpos = None - self.Refresh() - return - + # These attributes define the current location + # of the cursor, and the current depth, in real + # world coordinates. + self._xpos = 0.5 + self._ypos = 0.5 + self._zpos = 0.5 + + # These attributes define the spatial data + # limits of all displayed images, in real world + # coordinates. They are updated whenever an + # image is added/removed from the list. + self.xmin = 0 + self.ymin = 0 + self.zmin = 0 + self.xmax = 1 + self.ymax = 1 + self.zmax = 1 + + else: + + # Update the minimum/maximum + # image bounds along each axis + self.xmin = self.imageList.minBounds[self.xax] + self.ymin = self.imageList.minBounds[self.yax] + self.zmin = self.imageList.minBounds[self.zax] + + self.xmax = self.imageList.maxBounds[self.xax] + self.ymax = self.imageList.maxBounds[self.yax] + self.zmax = self.imageList.maxBounds[self.zax] + + # initialise the cursor location and displayed + # slice if they do not yet have values + if not all((self._xpos, self._ypos, self._zpos)): + self.xpos = (abs(self.xmax) - abs(self.xmin)) / 2.0 + self.ypos = (abs(self.ymax) - abs(self.ymin)) / 2.0 + self.zpos = (abs(self.zmax) - abs(self.zmin)) / 2.0 + # Create a GLImageData object # for any new images for image in self.imageList: @@ -519,24 +530,7 @@ class SliceCanvas(wxgl.GLCanvas): except: glData = GLImageData(image, self) image.setAttribute(self.name, glData) - - # Update the minimum/maximum - # image bounds along each axis - self.xmin = self.imageList.minBounds[self.xax] - self.ymin = self.imageList.minBounds[self.yax] - self.zmin = self.imageList.minBounds[self.zax] - - self.xmax = self.imageList.maxBounds[self.xax] - self.ymax = self.imageList.maxBounds[self.yax] - self.zmax = self.imageList.maxBounds[self.zax] - - # initialise the cursor location and displayed - # slice if they do not yet have values - if not all((self._xpos, self._ypos, self._zpos)): - self.xpos = (abs(self.xmax) - abs(self.xmin)) / 2.0 - self.ypos = (abs(self.ymax) - abs(self.ymin)) / 2.0 - self.zpos = (abs(self.zmax) - abs(self.zmin)) / 2.0 - + self.Refresh() @@ -612,10 +606,6 @@ class SliceCanvas(wxgl.GLCanvas): # clear the canvas gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) - # no images to draw - if len(self.imageList) == 0: - return - gl.glUseProgram(self.shaders) # enable transparency diff --git a/fsl/props/build.py b/fsl/props/build.py index e708f61c52464d329009d5b609132de667e92585..935f2dc17e50b8687496c2be792a4e3b58008e16 100644 --- a/fsl/props/build.py +++ b/fsl/props/build.py @@ -256,7 +256,7 @@ def _configureVisibleWhen(viewItem, guiObj, hasProps): if viewItem.visibleWhen is None: return None if isinstance(guiObj.GetParent(), wxnb.FlatNotebook): - raise TypeError('Visibility of notebook pages is not '\ + raise TypeError('Visibility of notebook pages is not ' 'configurable - use enabledWhen instead.') def _toggleVis(): @@ -337,9 +337,10 @@ def _makeGroupBorder(parent, group, ctr, *args, **kwargs): label.SetFont(font) borderSizer.Add(label, border=5, flag=wx.ALL) - borderSizer.Add(line, border=5, flag=wx.EXPAND|wx.ALL) + borderSizer.Add(line, border=5, flag=wx.EXPAND | wx.ALL) - borderSizer.Add(groupObject, border=5, flag=wx.EXPAND|wx.ALL, proportion=1) + borderSizer.Add( + groupObject, border=5, flag=wx.EXPAND | wx.ALL, proportion=1) borderPanel.SetSizer(borderSizer) borderSizer.Layout() borderSizer.Fit(borderPanel) @@ -365,7 +366,7 @@ def _createNotebookGroup(parent, group, hasProps, propGui): else: notebook = wxnb.FlatNotebook(parent, agwStyle=nbStyle) - for i,child in enumerate(group.children): + for i, child in enumerate(group.children): if child.label is None: pageLabel = '{}'.format(i) else: pageLabel = child.label @@ -421,8 +422,8 @@ def _layoutVGroup(group, parent, children, labels): given VGroup object. Parameters the same as _layoutHGroup. """ - sizer = wx.GridBagSizer(1,1) - sizer.SetEmptyCellSize((0,0)) + sizer = wx.GridBagSizer(1, 1) + sizer.SetEmptyCellSize((0, 0)) for cidx in range(len(children)): @@ -443,7 +444,7 @@ def _layoutVGroup(group, parent, children, labels): label = None childParams['pos'] = (cidx, 0) - childParams['span'] = (1,2) + childParams['span'] = (1, 2) childParams['border'] = 20 childParams['flag'] = wx.EXPAND | wx.ALL @@ -466,7 +467,7 @@ def _layoutVGroup(group, parent, children, labels): childParams['flag'] = wx.EXPAND | wx.BOTTOM if label is not None: - sizer.Add(labels[cidx], pos=(cidx,0), flag=wx.EXPAND) + sizer.Add(labels[cidx], pos=(cidx, 0), flag=wx.EXPAND) sizer.Add(child, **childParams) @@ -492,7 +493,7 @@ def _createGroup(parent, group, hasProps, propGui): childObjs = [] labelObjs = [] - for i,child in enumerate(group.children): + for i, child in enumerate(group.children): childObj = _create(panel, child, hasProps, propGui) @@ -605,7 +606,7 @@ def _prepareView(viewItem, labels, tooltips): viewItem.children = list(viewItem.children) viewItem.childLabels = [] - for i,child in enumerate(viewItem.children): + for i, child in enumerate(viewItem.children): viewItem.children[i] = _prepareView(child, labels, tooltips) # Create a Label object for each @@ -620,7 +621,8 @@ def _prepareView(viewItem, labels, tooltips): mkLabel = mkLabel and (child.label is not None) # or this child is a group with a border - mkLabel = mkLabel and not (isinstance(child, Group) and child.border) + mkLabel = mkLabel and \ + not (isinstance(child, Group) and child.border) # unless there is no label specified if mkLabel: viewItem.childLabels.append(Label(child)) @@ -654,7 +656,7 @@ def _prepareEvents(hasProps, propGui): onChange() # add a callback listener to every property - for propObj,propName in zip(propObjs,propNames): + for propObj, propName in zip(propObjs, propNames): lName = 'ChangeEvent_{}'.format(propName) propObj.addListener(hasProps, lName, onChange)