Commit a22006b2ce34b6980d9b8bba6fb452451e374059
1 parent
c799d5d1
Exists in
master
and in
68 other branches
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 | 52 | self._brush_cursor_type = const.DEFAULT_BRUSH_OP |
| 53 | 53 | self.cursor = None |
| 54 | 54 | # VTK pipeline and actors |
| 55 | - self.__config_interactor() | |
| 55 | + #self.__config_interactor() | |
| 56 | 56 | self.pick = vtk.vtkCellPicker() |
| 57 | 57 | |
| 58 | 58 | self.__bind_events() |
| ... | ... | @@ -341,7 +341,7 @@ class Viewer(wx.Panel): |
| 341 | 341 | def SetInput(self, imagedata): |
| 342 | 342 | self.imagedata = imagedata |
| 343 | 343 | |
| 344 | - ren = self.ren | |
| 344 | + #ren = self.ren | |
| 345 | 345 | interactor = self.interactor |
| 346 | 346 | |
| 347 | 347 | # Slice pipeline, to be inserted into current viewer |
| ... | ... | @@ -349,10 +349,14 @@ class Viewer(wx.Panel): |
| 349 | 349 | if slice_.imagedata is None: |
| 350 | 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 | 356 | actor_bound = actor.GetBounds() |
| 355 | 357 | self.actor = actor |
| 358 | + self.ren = ren | |
| 359 | + self.cam = ren.GetActiveCamera() | |
| 356 | 360 | |
| 357 | 361 | colour = const.ORIENTATION_COLOUR[self.orientation] |
| 358 | 362 | |
| ... | ... | @@ -368,7 +372,7 @@ class Viewer(wx.Panel): |
| 368 | 372 | text_actor.SetPosition(2,2) |
| 369 | 373 | self.text_actor = text_actor |
| 370 | 374 | |
| 371 | - ren.AddActor(actor) | |
| 375 | + #ren.AddActor(actor) | |
| 372 | 376 | #ren.AddActor(text_actor) |
| 373 | 377 | self.__update_camera() |
| 374 | 378 | |
| ... | ... | @@ -406,6 +410,14 @@ class Viewer(wx.Panel): |
| 406 | 410 | self.orientation = orientation |
| 407 | 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 | 421 | def __update_camera(self): |
| 410 | 422 | orientation = self.orientation |
| 411 | 423 | ... | ... |