Commit d7fa8b4f2eb9e9ee0891f6c2552e64d98db8c1a9

Authored by tatiana
1 parent a3979279

ENC: Inserted frange inside utils

invesalius/data/cursor_actors.py
1 1 from math import *
2   -
3 2 import vtk
4   -
5   -def frange(start, end=None, inc=None):
6   - "A range function, that does accept float increments..."
7   -
8   - if end == None:
9   - end = start + 0.0
10   - start = 0.0
11   -
12   - if inc == None:
13   - inc = 1.0
14   -
15   - L = []
16   - while 1:
17   - next = start + len(L) * inc
18   - if inc > 0 and next >= end:
19   - break
20   - elif inc < 0 and next <= end:
21   - break
22   - L.append(next)
23   -
24   - return L
25   -
  3 +import utils
26 4  
27 5 class CursorCircle:
28 6 # TODO: Think and try to change this class to an actor
... ... @@ -51,8 +29,8 @@ class CursorCircle:
51 29 """
52 30  
53 31 disk = self.disk
54   - disk.SetInnerRadius(self.radius)
55   - disk.SetOuterRadius(0) # filled
  32 + disk.SetInnerRadius(self.radius-1) # filled = self.radius
  33 + disk.SetOuterRadius(self.radius) # filled = 0x
56 34 disk.SetRadialResolution(50)
57 35 disk.SetCircumferentialResolution(50)
58 36  
... ... @@ -84,7 +62,7 @@ class CursorCircle:
84 62 xs, ys = orientation_based_spacing[self.orientation]
85 63 self.pixel_list = []
86 64 radius = self.radius
87   - for i in frange(yc - radius, yc + radius, ys):
  65 + for i in utils.frange(yc - radius, yc + radius, ys):
88 66 # distance from the line to the circle's center
89 67 d = yc - i
90 68 # line size
... ... @@ -94,7 +72,7 @@ class CursorCircle:
94 72 # line final
95 73 xf = line/2 + xc
96 74 yi = i
97   - for k in frange(xi,xf,xs):
  75 + for k in utils.frange(xi,xf,xs):
98 76 self.pixel_list.append((k, yi))
99 77  
100 78 def SetSize(self, radius):
... ...
invesalius/data/viewer_slice.py
... ... @@ -269,7 +269,10 @@ class Viewer(wx.Panel):
269 269 def SetInput(self, imagedata):
270 270  
271 271 self.imagedata = imagedata
272   -
  272 +
  273 + print "************************************"
  274 + print "spacing:", imagedata.GetSpacing()
  275 + print "************************************"
273 276 ren = self.ren
274 277 interactor = self.interactor
275 278  
... ...
invesalius/utils.py
... ... @@ -60,4 +60,25 @@ class TwoWaysDictionary(dict):
60 60 """
61 61 Find the value given a key.
62 62 """
63   - return self[key]
64 63 \ No newline at end of file
  64 + return self[key]
  65 +
  66 +def frange(start, end=None, inc=None):
  67 + "A range function, that accepts float increments."
  68 +
  69 + if end == None:
  70 + end = start + 0.0
  71 + start = 0.0
  72 +
  73 + if inc == None:
  74 + inc = 1.0
  75 +
  76 + L = []
  77 + while 1:
  78 + next = start + len(L) * inc
  79 + if inc > 0 and next >= end:
  80 + break
  81 + elif inc < 0 and next <= end:
  82 + break
  83 + L.append(next)
  84 +
  85 + return L
65 86 \ No newline at end of file
... ...