Commit a22006b2ce34b6980d9b8bba6fb452451e374059

Authored by tfmoraes
1 parent c799d5d1

ADD: Added a function to create the imageactor and the render in the viewer_slice

Showing 1 changed file with 17 additions and 5 deletions   Show diff stats
invesalius/data/viewer_slice.py
@@ -52,7 +52,7 @@ class Viewer(wx.Panel): @@ -52,7 +52,7 @@ class Viewer(wx.Panel):
52 self._brush_cursor_type = const.DEFAULT_BRUSH_OP 52 self._brush_cursor_type = const.DEFAULT_BRUSH_OP
53 self.cursor = None 53 self.cursor = None
54 # VTK pipeline and actors 54 # VTK pipeline and actors
55 - self.__config_interactor() 55 + #self.__config_interactor()
56 self.pick = vtk.vtkCellPicker() 56 self.pick = vtk.vtkCellPicker()
57 57
58 self.__bind_events() 58 self.__bind_events()
@@ -341,7 +341,7 @@ class Viewer(wx.Panel): @@ -341,7 +341,7 @@ class Viewer(wx.Panel):
341 def SetInput(self, imagedata): 341 def SetInput(self, imagedata):
342 self.imagedata = imagedata 342 self.imagedata = imagedata
343 343
344 - ren = self.ren 344 + #ren = self.ren
345 interactor = self.interactor 345 interactor = self.interactor
346 346
347 # Slice pipeline, to be inserted into current viewer 347 # Slice pipeline, to be inserted into current viewer
@@ -349,10 +349,14 @@ class Viewer(wx.Panel): @@ -349,10 +349,14 @@ class Viewer(wx.Panel):
349 if slice_.imagedata is None: 349 if slice_.imagedata is None:
350 slice_.SetInput(imagedata) 350 slice_.SetInput(imagedata)
351 351
352 - actor = vtk.vtkImageActor()  
353 - actor.SetInput(slice_.GetOutput()) 352 +
  353 + #actor = vtk.vtkImageActor()
  354 + #actor.SetInput(slice_.GetOutput())
  355 + ren, actor = self.add_actor(slice_.GetOutput())
354 actor_bound = actor.GetBounds() 356 actor_bound = actor.GetBounds()
355 self.actor = actor 357 self.actor = actor
  358 + self.ren = ren
  359 + self.cam = ren.GetActiveCamera()
356 360
357 colour = const.ORIENTATION_COLOUR[self.orientation] 361 colour = const.ORIENTATION_COLOUR[self.orientation]
358 362
@@ -368,7 +372,7 @@ class Viewer(wx.Panel): @@ -368,7 +372,7 @@ class Viewer(wx.Panel):
368 text_actor.SetPosition(2,2) 372 text_actor.SetPosition(2,2)
369 self.text_actor = text_actor 373 self.text_actor = text_actor
370 374
371 - ren.AddActor(actor) 375 + #ren.AddActor(actor)
372 #ren.AddActor(text_actor) 376 #ren.AddActor(text_actor)
373 self.__update_camera() 377 self.__update_camera()
374 378
@@ -406,6 +410,14 @@ class Viewer(wx.Panel): @@ -406,6 +410,14 @@ class Viewer(wx.Panel):
406 self.orientation = orientation 410 self.orientation = orientation
407 self.__update_camera() 411 self.__update_camera()
408 412
  413 + def add_actor(self, image):
  414 + render = vtk.vtkRenderer()
  415 + self.interactor.GetRenderWindow().AddRenderer(render)
  416 + actor = vtk.vtkImageActor()
  417 + actor.SetInput(image)
  418 + render.AddActor(actor)
  419 + return render, actor
  420 +
409 def __update_camera(self): 421 def __update_camera(self):
410 orientation = self.orientation 422 orientation = self.orientation
411 423