Commit 780aa1d54bd24f2233b4a582efdf5b57c0e31a17
1 parent
f4762b06
Exists in
master
Using canvasrender on import bitmap panel
Showing
1 changed file
with
42 additions
and
26 deletions
Show diff stats
invesalius/gui/bitmap_preview_panel.py
... | ... | @@ -12,6 +12,7 @@ import invesalius.data.vtk_utils as vtku |
12 | 12 | import invesalius.data.converters as converters |
13 | 13 | import invesalius.reader.bitmap_reader as bitmap_reader |
14 | 14 | import invesalius.utils as utils |
15 | +from invesalius.gui.widgets.canvas_renderer import CanvasRendererCTX | |
15 | 16 | |
16 | 17 | NROWS = 3 |
17 | 18 | NCOLS = 6 |
... | ... | @@ -447,53 +448,68 @@ class SingleImagePreview(wx.Panel): |
447 | 448 | self.window_level = const.WINDOW_LEVEL[_("Bone")][1] |
448 | 449 | |
449 | 450 | def __init_vtk(self): |
450 | - text_image_size = vtku.Text() | |
451 | + text_image_size = vtku.TextZero() | |
451 | 452 | text_image_size.SetPosition(const.TEXT_POS_LEFT_UP) |
452 | 453 | text_image_size.SetValue("") |
453 | - text_image_size.SetSize(const.TEXT_SIZE_SMALL) | |
454 | + text_image_size.SetSymbolicSize(wx.FONTSIZE_SMALL) | |
454 | 455 | self.text_image_size = text_image_size |
455 | 456 | |
456 | - text_image_location = vtku.Text() | |
457 | - text_image_location.SetVerticalJustificationToBottom() | |
457 | + text_image_location = vtku.TextZero() | |
458 | + # text_image_location.SetVerticalJustificationToBottom() | |
458 | 459 | text_image_location.SetPosition(const.TEXT_POS_LEFT_DOWN) |
459 | 460 | text_image_location.SetValue("") |
460 | - text_image_location.SetSize(const.TEXT_SIZE_SMALL) | |
461 | + text_image_location.bottom_pos = True | |
462 | + text_image_location.SetSymbolicSize(wx.FONTSIZE_SMALL) | |
461 | 463 | self.text_image_location = text_image_location |
462 | 464 | |
463 | - text_patient = vtku.Text() | |
464 | - text_patient.SetJustificationToRight() | |
465 | + text_patient = vtku.TextZero() | |
466 | + # text_patient.SetJustificationToRight() | |
465 | 467 | text_patient.SetPosition(const.TEXT_POS_RIGHT_UP) |
466 | 468 | text_patient.SetValue("") |
467 | - text_patient.SetSize(const.TEXT_SIZE_SMALL) | |
469 | + text_patient.right_pos = True | |
470 | + text_patient.SetSymbolicSize(wx.FONTSIZE_SMALL) | |
468 | 471 | self.text_patient = text_patient |
469 | 472 | |
470 | - text_acquisition = vtku.Text() | |
471 | - text_acquisition.SetJustificationToRight() | |
472 | - text_acquisition.SetVerticalJustificationToBottom() | |
473 | + text_acquisition = vtku.TextZero() | |
474 | + # text_acquisition.SetJustificationToRight() | |
475 | + # text_acquisition.SetVerticalJustificationToBottom() | |
473 | 476 | text_acquisition.SetPosition(const.TEXT_POS_RIGHT_DOWN) |
474 | 477 | text_acquisition.SetValue("") |
475 | - text_acquisition.SetSize(const.TEXT_SIZE_SMALL) | |
478 | + text_acquisition.right_pos = True | |
479 | + text_acquisition.bottom_pos = True | |
480 | + text_acquisition.SetSymbolicSize(wx.FONTSIZE_SMALL) | |
476 | 481 | self.text_acquisition = text_acquisition |
477 | 482 | |
478 | - renderer = vtk.vtkRenderer() | |
479 | - renderer.AddActor(text_image_size.actor) | |
480 | - renderer.AddActor(text_image_location.actor) | |
481 | - renderer.AddActor(text_patient.actor) | |
482 | - renderer.AddActor(text_acquisition.actor) | |
483 | - self.renderer = renderer | |
483 | + self.renderer = vtk.vtkRenderer() | |
484 | + self.renderer.SetLayer(0) | |
485 | + | |
486 | + cam = self.renderer.GetActiveCamera() | |
487 | + | |
488 | + self.canvas_renderer = vtk.vtkRenderer() | |
489 | + self.canvas_renderer.SetLayer(1) | |
490 | + self.canvas_renderer.SetActiveCamera(cam) | |
491 | + self.canvas_renderer.SetInteractive(0) | |
492 | + self.canvas_renderer.PreserveDepthBufferOn() | |
484 | 493 | |
485 | 494 | style = vtk.vtkInteractorStyleImage() |
486 | 495 | |
487 | - interactor = wxVTKRenderWindowInteractor(self.panel, -1, | |
488 | - size=wx.Size(340,340)) | |
489 | - interactor.SetRenderWhenDisabled(True) | |
490 | - interactor.GetRenderWindow().AddRenderer(renderer) | |
491 | - interactor.SetInteractorStyle(style) | |
492 | - interactor.Render() | |
493 | - self.interactor = interactor | |
496 | + self.interactor = wxVTKRenderWindowInteractor(self.panel, -1, | |
497 | + size=wx.Size(340,340)) | |
498 | + self.interactor.SetRenderWhenDisabled(True) | |
499 | + self.interactor.GetRenderWindow().SetNumberOfLayers(2) | |
500 | + self.interactor.GetRenderWindow().AddRenderer(self.renderer) | |
501 | + self.interactor.GetRenderWindow().AddRenderer(self.canvas_renderer) | |
502 | + self.interactor.SetInteractorStyle(style) | |
503 | + self.interactor.Render() | |
504 | + | |
505 | + self.canvas = CanvasRendererCTX(self, self.renderer, self.canvas_renderer) | |
506 | + self.canvas.draw_list.append(self.text_image_size) | |
507 | + self.canvas.draw_list.append(self.text_image_location) | |
508 | + self.canvas.draw_list.append(self.text_patient) | |
509 | + self.canvas.draw_list.append(self.text_acquisition) | |
494 | 510 | |
495 | 511 | sizer = wx.BoxSizer(wx.VERTICAL) |
496 | - sizer.Add(interactor, 1, wx.GROW|wx.EXPAND) | |
512 | + sizer.Add(self.interactor, 1, wx.GROW|wx.EXPAND) | |
497 | 513 | sizer.Fit(self.panel) |
498 | 514 | self.panel.SetSizer(sizer) |
499 | 515 | self.Layout() | ... | ... |