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 47 self.slice_data_list = []
48 48 # The layout from slice_data, the first is number of cols, the second
49 49 # is the number of rows
50   - self.layout = (1, 1)
  50 + self.layout = (2, 2)
51 51  
52 52 self.__init_gui()
53 53  
... ... @@ -274,9 +274,13 @@ class Viewer(wx.Panel):
274 274 evt.StartDolly()
275 275  
276 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 285 def OnSpinMove(self, evt, obj):
282 286 if (self.mouse_pressed):
... ... @@ -299,23 +303,24 @@ class Viewer(wx.Panel):
299 303 slice_data.cursor.Show(0)
300 304 self.interactor.Render()
301 305  
302   - def Reposition(self):
  306 + def Reposition(self, slice_data):
303 307 """
304 308 Based on code of method Zoom in the
305 309 vtkInteractorStyleRubberBandZoom, the of
306 310 vtk 5.4.3
307 311 """
308   - size = self.ren.GetSize()
  312 + ren = slice_data.renderer
  313 + size = ren.GetSize()
309 314  
310 315 if (size[0] <= size[1] + 100):
311 316  
312   - bound = self.actor.GetBounds()
  317 + bound = slice_data.actor.GetBounds()
313 318  
314 319 width = abs((bound[3] - bound[2]) * -1)
315 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 325 min = []
321 326 min.append(bound[0])
... ... @@ -344,11 +349,11 @@ class Viewer(wx.Panel):
344 349 winCenter.append(origin[1] + 0.5 * size[1])
345 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 357 invw = 1.0/worldWinCenter[3]
353 358 worldWinCenter[0] *= invw
354 359 worldWinCenter[1] *= invw
... ... @@ -364,7 +369,6 @@ class Viewer(wx.Panel):
364 369 else:
365 370 cam.Zoom(size[1] / height)
366 371  
367   - self.interactor.Render()
368 372  
369 373 def ChangeBrushSize(self, pubsub_evt):
370 374 size = pubsub_evt.data
... ... @@ -688,6 +692,7 @@ class Viewer(wx.Panel):
688 692 #ren.AddActor(text_actor)
689 693 for slice_data in self.slice_data_list:
690 694 self.__update_camera(slice_data)
  695 + self.Reposition(slice_data)
691 696  
692 697 number_of_slices = self.layout[0] * self.layout[1]
693 698 max_slice_number = actor.GetSliceNumberMax() / \
... ... @@ -703,8 +708,6 @@ class Viewer(wx.Panel):
703 708 # Insert cursor
704 709 self.append_mode('EDITOR')
705 710  
706   - self.Reposition()
707   -
708 711 def __update_cursor_position(self, slice_data, position):
709 712 x, y, z = position
710 713 if (slice_data.cursor):
... ...