Commit c64e6b6cf3ce5b3574fd1784d421ddaf5ea6c9d1

Authored by Paulo Henrique Junqueira Amorim
1 parent 36379e6d

FIX: slices of the same size, when more than one.

Showing 1 changed file with 19 additions and 16 deletions   Show diff stats
invesalius/data/viewer_slice.py
@@ -47,7 +47,7 @@ class Viewer(wx.Panel): @@ -47,7 +47,7 @@ class Viewer(wx.Panel):
47 self.slice_data_list = [] 47 self.slice_data_list = []
48 # The layout from slice_data, the first is number of cols, the second 48 # The layout from slice_data, the first is number of cols, the second
49 # is the number of rows 49 # is the number of rows
50 - self.layout = (1, 1) 50 + self.layout = (2, 2)
51 51
52 self.__init_gui() 52 self.__init_gui()
53 53
@@ -274,9 +274,13 @@ class Viewer(wx.Panel): @@ -274,9 +274,13 @@ class Viewer(wx.Panel):
274 evt.StartDolly() 274 evt.StartDolly()
275 275
276 def OnUnZoom(self, evt, obj): 276 def OnUnZoom(self, evt, obj):
277 - self.ren.ResetCamera()  
278 - self.ren.ResetCameraClippingRange()  
279 - self.Reposition() 277 + mouse_x, mouse_y = self.interactor.GetLastEventPosition()
  278 + ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y)
  279 + slice_data = self.get_slice_data(ren)
  280 + ren.ResetCamera()
  281 + ren.ResetCameraClippingRange()
  282 + self.Reposition(slice_data)
  283 + self.interactor.Render()
280 284
281 def OnSpinMove(self, evt, obj): 285 def OnSpinMove(self, evt, obj):
282 if (self.mouse_pressed): 286 if (self.mouse_pressed):
@@ -299,23 +303,24 @@ class Viewer(wx.Panel): @@ -299,23 +303,24 @@ class Viewer(wx.Panel):
299 slice_data.cursor.Show(0) 303 slice_data.cursor.Show(0)
300 self.interactor.Render() 304 self.interactor.Render()
301 305
302 - def Reposition(self): 306 + def Reposition(self, slice_data):
303 """ 307 """
304 Based on code of method Zoom in the 308 Based on code of method Zoom in the
305 vtkInteractorStyleRubberBandZoom, the of 309 vtkInteractorStyleRubberBandZoom, the of
306 vtk 5.4.3 310 vtk 5.4.3
307 """ 311 """
308 - size = self.ren.GetSize() 312 + ren = slice_data.renderer
  313 + size = ren.GetSize()
309 314
310 if (size[0] <= size[1] + 100): 315 if (size[0] <= size[1] + 100):
311 316
312 - bound = self.actor.GetBounds() 317 + bound = slice_data.actor.GetBounds()
313 318
314 width = abs((bound[3] - bound[2]) * -1) 319 width = abs((bound[3] - bound[2]) * -1)
315 height = abs((bound[1] - bound[0]) * -1) 320 height = abs((bound[1] - bound[0]) * -1)
316 321
317 - origin = self.ren.GetOrigin()  
318 - cam = self.ren.GetActiveCamera() 322 + origin = ren.GetOrigin()
  323 + cam = ren.GetActiveCamera()
319 324
320 min = [] 325 min = []
321 min.append(bound[0]) 326 min.append(bound[0])
@@ -344,11 +349,11 @@ class Viewer(wx.Panel): @@ -344,11 +349,11 @@ class Viewer(wx.Panel):
344 winCenter.append(origin[1] + 0.5 * size[1]) 349 winCenter.append(origin[1] + 0.5 * size[1])
345 winCenter.append(0) 350 winCenter.append(0)
346 351
347 - self.ren.SetDisplayPoint(winCenter)  
348 - self.ren.DisplayToView()  
349 - self.ren.ViewToWorld() 352 + ren.SetDisplayPoint(winCenter)
  353 + ren.DisplayToView()
  354 + ren.ViewToWorld()
350 355
351 - worldWinCenter = list(self.ren.GetWorldPoint()) 356 + worldWinCenter = list(ren.GetWorldPoint())
352 invw = 1.0/worldWinCenter[3] 357 invw = 1.0/worldWinCenter[3]
353 worldWinCenter[0] *= invw 358 worldWinCenter[0] *= invw
354 worldWinCenter[1] *= invw 359 worldWinCenter[1] *= invw
@@ -364,7 +369,6 @@ class Viewer(wx.Panel): @@ -364,7 +369,6 @@ class Viewer(wx.Panel):
364 else: 369 else:
365 cam.Zoom(size[1] / height) 370 cam.Zoom(size[1] / height)
366 371
367 - self.interactor.Render()  
368 372
369 def ChangeBrushSize(self, pubsub_evt): 373 def ChangeBrushSize(self, pubsub_evt):
370 size = pubsub_evt.data 374 size = pubsub_evt.data
@@ -688,6 +692,7 @@ class Viewer(wx.Panel): @@ -688,6 +692,7 @@ class Viewer(wx.Panel):
688 #ren.AddActor(text_actor) 692 #ren.AddActor(text_actor)
689 for slice_data in self.slice_data_list: 693 for slice_data in self.slice_data_list:
690 self.__update_camera(slice_data) 694 self.__update_camera(slice_data)
  695 + self.Reposition(slice_data)
691 696
692 number_of_slices = self.layout[0] * self.layout[1] 697 number_of_slices = self.layout[0] * self.layout[1]
693 max_slice_number = actor.GetSliceNumberMax() / \ 698 max_slice_number = actor.GetSliceNumberMax() / \
@@ -703,8 +708,6 @@ class Viewer(wx.Panel): @@ -703,8 +708,6 @@ class Viewer(wx.Panel):
703 # Insert cursor 708 # Insert cursor
704 self.append_mode('EDITOR') 709 self.append_mode('EDITOR')
705 710
706 - self.Reposition()  
707 -  
708 def __update_cursor_position(self, slice_data, position): 711 def __update_cursor_position(self, slice_data, position):
709 x, y, z = position 712 x, y, z = position
710 if (slice_data.cursor): 713 if (slice_data.cursor):