Commit 2b11a51c1374830ef992b62fb3e81a8156cbad22
1 parent
4bcd447b
Exists in
master
and in
68 other branches
ENH: Corrected the cursor reference in the imagedata
Showing
1 changed file
with
21 additions
and
27 deletions
Show diff stats
invesalius/data/viewer_slice.py
@@ -222,33 +222,27 @@ class Viewer(wx.Panel): | @@ -222,33 +222,27 @@ class Viewer(wx.Panel): | ||
222 | x = float(x - bound_xi) | 222 | x = float(x - bound_xi) |
223 | y = float(y - bound_yi) | 223 | y = float(y - bound_yi) |
224 | z = float(z - bound_zi) | 224 | z = float(z - bound_zi) |
225 | + | ||
226 | + dx = bound_xf - bound_xi; | ||
227 | + dy = bound_yf - bound_yi | ||
228 | + dz = bound_zf - bound_zi | ||
229 | + | ||
230 | + dimensions = self.imagedata.GetDimensions() | ||
231 | + | ||
232 | + try: | ||
233 | + x = (x * dimensions[0]) / dx | ||
234 | + except ZeroDivisionError: | ||
235 | + x = self.slice_number | ||
236 | + try: | ||
237 | + y = (y * dimensions[1]) / dy | ||
238 | + except ZeroDivisionError: | ||
239 | + y = self.slice_number | ||
240 | + try: | ||
241 | + z = (z * dimensions[2]) / dz | ||
242 | + except ZeroDivisionError: | ||
243 | + z = self.slice_number | ||
225 | 244 | ||
226 | - # Then we fix the porpotion, based on vtkImageData spacing | ||
227 | - #spacing_x, spacing_y, spacing_z = self.imagedata.GetSpacing() | ||
228 | - #x = x/spacing_x | ||
229 | - #y = y/spacing_y | ||
230 | - #z = z/spacing_z | ||
231 | - | ||
232 | - # Based on the current orientation, we define 3D position | ||
233 | - coordinates = {"SAGITAL": [self.slice_number, y, z], | ||
234 | - "CORONAL": [x, self.slice_number, z], | ||
235 | - "AXIAL": [x, y, self.slice_number]} | ||
236 | - coord = [int(coord) for coord in coordinates[self.orientation]] | ||
237 | - | ||
238 | - # According to vtkImageData extent, we limit min and max value | ||
239 | - # If this is not done, a VTK Error occurs when mouse is pressed outside | ||
240 | - # vtkImageData extent | ||
241 | - #extent = self.imagedata.GetWholeExtent() | ||
242 | - #extent_min = extent[0], extent[2], extent[4] | ||
243 | - #extent_max = extent[1], extent[3], extent[5] | ||
244 | - #for index in xrange(3): | ||
245 | - # if coord[index] > extent_max[index]: | ||
246 | - # coord[index] = extent_max[index] | ||
247 | - # elif coord[index] < extent_min[index]: | ||
248 | - # coord[index] = extent_min[index] | ||
249 | - #print "New coordinate: ", coord | ||
250 | - | ||
251 | - return coord | 245 | + return x,y,z |
252 | 246 | ||
253 | def __bind_events(self): | 247 | def __bind_events(self): |
254 | ps.Publisher().subscribe(self.LoadImagedata, 'Load slice to viewer') | 248 | ps.Publisher().subscribe(self.LoadImagedata, 'Load slice to viewer') |
@@ -295,7 +289,7 @@ class Viewer(wx.Panel): | @@ -295,7 +289,7 @@ class Viewer(wx.Panel): | ||
295 | self.text_actor = text_actor | 289 | self.text_actor = text_actor |
296 | 290 | ||
297 | ren.AddActor(actor) | 291 | ren.AddActor(actor) |
298 | - ren.AddActor(text_actor) | 292 | + #ren.AddActor(text_actor) |
299 | self.__update_camera() | 293 | self.__update_camera() |
300 | 294 | ||
301 | max_slice_number = actor.GetSliceNumberMax() | 295 | max_slice_number = actor.GetSliceNumberMax() |