Commit 74706f4e642b423c4bac41279797154251f246c0

Authored by tfmoraes
1 parent dd3709f6

ENH: The gaps in the RectangleCursor was filled

Showing 1 changed file with 16 additions and 9 deletions   Show diff stats
invesalius/data/cursor_actors.py
@@ -31,16 +31,16 @@ class CursorCircle: @@ -31,16 +31,16 @@ class CursorCircle:
31 """ 31 """
32 Function to plot the circle 32 Function to plot the circle
33 """ 33 """
34 - 34 +
35 disk = self.disk 35 disk = self.disk
36 disk.SetInnerRadius(self.radius-1) # filled = self.radius 36 disk.SetInnerRadius(self.radius-1) # filled = self.radius
37 disk.SetOuterRadius(self.radius) # filled = 0x 37 disk.SetOuterRadius(self.radius) # filled = 0x
38 disk.SetRadialResolution(50) 38 disk.SetRadialResolution(50)
39 disk.SetCircumferentialResolution(50) 39 disk.SetCircumferentialResolution(50)
40 - 40 +
41 mapper = self.mapper 41 mapper = self.mapper
42 mapper.SetInput(disk.GetOutput()) 42 mapper.SetInput(disk.GetOutput())
43 - 43 +
44 actor = self.actor 44 actor = self.actor
45 actor.SetMapper(mapper) 45 actor.SetMapper(mapper)
46 actor.GetProperty().SetOpacity(self.opacity) 46 actor.GetProperty().SetOpacity(self.opacity)
@@ -48,7 +48,7 @@ class CursorCircle: @@ -48,7 +48,7 @@ class CursorCircle:
48 actor.SetPosition(self.position) 48 actor.SetPosition(self.position)
49 actor.SetVisibility(1) 49 actor.SetVisibility(1)
50 actor.PickableOff() 50 actor.PickableOff()
51 - 51 +
52 def __calculate_area_pixels(self): 52 def __calculate_area_pixels(self):
53 """ 53 """
54 Return the cursor's pixels. 54 Return the cursor's pixels.
@@ -62,7 +62,7 @@ class CursorCircle: @@ -62,7 +62,7 @@ class CursorCircle:
62 xs, ys, zs = self.spacing 62 xs, ys, zs = self.spacing
63 orientation_based_spacing = {"AXIAL" : (xs, ys), 63 orientation_based_spacing = {"AXIAL" : (xs, ys),
64 "SAGITAL" : (ys, zs), 64 "SAGITAL" : (ys, zs),
65 - "CORONAL" : (xs, zs) } 65 + "CORONAL" : (xs, zs)}
66 xs, ys = orientation_based_spacing[self.orientation] 66 xs, ys = orientation_based_spacing[self.orientation]
67 self.pixel_list = [] 67 self.pixel_list = []
68 radius = self.radius 68 radius = self.radius
@@ -149,6 +149,8 @@ class CursorRectangle: @@ -149,6 +149,8 @@ class CursorRectangle:
149 149
150 self.dimension = (self.x_length, self.y_length) 150 self.dimension = (self.x_length, self.y_length)
151 self.position = (0 ,0) 151 self.position = (0 ,0)
  152 + self.orientation = "AXIAL"
  153 + self.spacing = (1, 1, 1)
152 154
153 self.mapper = vtk.vtkPolyDataMapper() 155 self.mapper = vtk.vtkPolyDataMapper()
154 156
@@ -229,7 +231,7 @@ class CursorRectangle: @@ -229,7 +231,7 @@ class CursorRectangle:
229 retangle = self.retangle 231 retangle = self.retangle
230 retangle.SetXLength(self.x_length) 232 retangle.SetXLength(self.x_length)
231 retangle.SetYLength(self.y_length) 233 retangle.SetYLength(self.y_length)
232 - 234 +
233 seeds_yi = self.seeds_yi 235 seeds_yi = self.seeds_yi
234 seeds_yi.SetPoint1(0, 0, 0) 236 seeds_yi.SetPoint1(0, 0, 0)
235 seeds_yi.SetPoint2(0, self.y_length, 0) 237 seeds_yi.SetPoint2(0, self.y_length, 0)
@@ -270,9 +272,14 @@ class CursorRectangle: @@ -270,9 +272,14 @@ class CursorRectangle:
270 xc = 0 272 xc = 0
271 yc = 0 273 yc = 0
272 z = 0 274 z = 0
  275 + xs, ys, zs = self.spacing
  276 + orientation_based_spacing = {"AXIAL" : (xs, ys),
  277 + "SAGITAL" : (ys, zs),
  278 + "CORONAL" : (xs, zs)}
  279 + xs, ys = orientation_based_spacing[self.orientation]
273 self.pixel_list = [] 280 self.pixel_list = []
274 - for i in xrange(int(yc - self.y_length/2), int(yc + self.y_length/2)):  
275 - for k in xrange(xc - self.x_length/2, xc + self.x_length/2): 281 + for i in utils.frange(yc - self.y_length/2, yc + self.y_length/2, ys):
  282 + for k in utils.frange(xc - self.x_length/2, xc + self.x_length/2, xs):
276 self.pixel_list.append((k, i)) 283 self.pixel_list.append((k, i))
277 284
278 285
@@ -292,4 +299,4 @@ class CursorRectangle: @@ -292,4 +299,4 @@ class CursorRectangle:
292 "CORONAL": [px+(pixel_0/xs), py, pz+(pixel_1/zs)], 299 "CORONAL": [px+(pixel_0/xs), py, pz+(pixel_1/zs)],
293 "SAGITAL": [px, py+(pixel_0/ys), pz+(pixel_1/zs)]} 300 "SAGITAL": [px, py+(pixel_0/ys), pz+(pixel_1/zs)]}
294 yield abs_pixel[orient] 301 yield abs_pixel[orient]
295 -  
296 \ No newline at end of file 302 \ No newline at end of file
  303 +