Commit d7fa8b4f2eb9e9ee0891f6c2552e64d98db8c1a9
1 parent
a3979279
Exists in
master
and in
68 other branches
ENC: Inserted frange inside utils
Showing
3 changed files
with
31 additions
and
29 deletions
Show diff stats
invesalius/data/cursor_actors.py
| 1 | from math import * | 1 | from math import * |
| 2 | - | ||
| 3 | import vtk | 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 | class CursorCircle: | 5 | class CursorCircle: |
| 28 | # TODO: Think and try to change this class to an actor | 6 | # TODO: Think and try to change this class to an actor |
| @@ -51,8 +29,8 @@ class CursorCircle: | @@ -51,8 +29,8 @@ class CursorCircle: | ||
| 51 | """ | 29 | """ |
| 52 | 30 | ||
| 53 | disk = self.disk | 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 | disk.SetRadialResolution(50) | 34 | disk.SetRadialResolution(50) |
| 57 | disk.SetCircumferentialResolution(50) | 35 | disk.SetCircumferentialResolution(50) |
| 58 | 36 | ||
| @@ -84,7 +62,7 @@ class CursorCircle: | @@ -84,7 +62,7 @@ class CursorCircle: | ||
| 84 | xs, ys = orientation_based_spacing[self.orientation] | 62 | xs, ys = orientation_based_spacing[self.orientation] |
| 85 | self.pixel_list = [] | 63 | self.pixel_list = [] |
| 86 | radius = self.radius | 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 | # distance from the line to the circle's center | 66 | # distance from the line to the circle's center |
| 89 | d = yc - i | 67 | d = yc - i |
| 90 | # line size | 68 | # line size |
| @@ -94,7 +72,7 @@ class CursorCircle: | @@ -94,7 +72,7 @@ class CursorCircle: | ||
| 94 | # line final | 72 | # line final |
| 95 | xf = line/2 + xc | 73 | xf = line/2 + xc |
| 96 | yi = i | 74 | yi = i |
| 97 | - for k in frange(xi,xf,xs): | 75 | + for k in utils.frange(xi,xf,xs): |
| 98 | self.pixel_list.append((k, yi)) | 76 | self.pixel_list.append((k, yi)) |
| 99 | 77 | ||
| 100 | def SetSize(self, radius): | 78 | def SetSize(self, radius): |
invesalius/data/viewer_slice.py
| @@ -269,7 +269,10 @@ class Viewer(wx.Panel): | @@ -269,7 +269,10 @@ class Viewer(wx.Panel): | ||
| 269 | def SetInput(self, imagedata): | 269 | def SetInput(self, imagedata): |
| 270 | 270 | ||
| 271 | self.imagedata = imagedata | 271 | self.imagedata = imagedata |
| 272 | - | 272 | + |
| 273 | + print "************************************" | ||
| 274 | + print "spacing:", imagedata.GetSpacing() | ||
| 275 | + print "************************************" | ||
| 273 | ren = self.ren | 276 | ren = self.ren |
| 274 | interactor = self.interactor | 277 | interactor = self.interactor |
| 275 | 278 |
invesalius/utils.py
| @@ -60,4 +60,25 @@ class TwoWaysDictionary(dict): | @@ -60,4 +60,25 @@ class TwoWaysDictionary(dict): | ||
| 60 | """ | 60 | """ |
| 61 | Find the value given a key. | 61 | Find the value given a key. |
| 62 | """ | 62 | """ |
| 63 | - return self[key] | ||
| 64 | \ No newline at end of file | 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 | \ No newline at end of file | 86 | \ No newline at end of file |