def __init_vtk(self): actor = vtk.vtkImageActor() self.actor = actor text_image_size = vtku.Text() text_image_size.SetPosition(const.TEXT_POS_LEFT_UP) text_image_size.SetValue("") text_image_size.SetSize(const.TEXT_SIZE_SMALL) self.text_image_size = text_image_size text_image_location = vtku.Text() text_image_location.SetVerticalJustificationToBottom() text_image_location.SetPosition(const.TEXT_POS_LEFT_DOWN) text_image_location.SetValue("") text_image_location.SetSize(const.TEXT_SIZE_SMALL) self.text_image_location = text_image_location text_patient = vtku.Text() text_patient.SetJustificationToRight() text_patient.SetPosition(const.TEXT_POS_RIGHT_UP) text_patient.SetValue("") text_patient.SetSize(const.TEXT_SIZE_SMALL) self.text_patient = text_patient text_acquisition = vtku.Text() text_acquisition.SetJustificationToRight() text_acquisition.SetVerticalJustificationToBottom() text_acquisition.SetPosition(const.TEXT_POS_RIGHT_DOWN) text_acquisition.SetValue("") text_acquisition.SetSize(const.TEXT_SIZE_SMALL) self.text_acquisition = text_acquisition renderer = vtk.vtkRenderer() renderer.AddActor(actor) renderer.AddActor(text_image_size.actor) renderer.AddActor(text_image_location.actor) renderer.AddActor(text_patient.actor) renderer.AddActor(text_acquisition.actor) self.renderer = renderer style = vtk.vtkInteractorStyleImage() interactor = wxVTKRenderWindowInteractor(self.panel, -1, size=wx.Size(340, 340)) interactor.GetRenderWindow().AddRenderer(renderer) interactor.SetInteractorStyle(style) interactor.Render() self.interactor = interactor sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(interactor, 1, wx.GROW | wx.EXPAND) sizer.Fit(self.panel) self.panel.SetSizer(sizer) self.Layout() self.Update()
def EnableText(self): if not (self.wl_text): proj = project.Project() colour = const.ORIENTATION_COLOUR[self.orientation] # Window & Level text self.wl_text = vtku.Text() self.SetWLText(proj.level, proj.window) # Orientation text if self.orientation == 'AXIAL': values = [_('R'), _('L'), _('A'), _('P')] elif self.orientation == 'SAGITAL': values = [_('P'), _('A'), _('T'), _('B')] else: values = [_('R'), _('L'), _('T'), _('B')] left_text = self.left_text = vtku.TextZero() left_text.ShadowOff() left_text.SetColour(colour) left_text.SetPosition(const.TEXT_POS_VCENTRE_LEFT) left_text.SetVerticalJustificationToCentered() left_text.SetValue(values[0]) right_text = self.right_text = vtku.TextZero() right_text.ShadowOff() right_text.SetColour(colour) right_text.SetPosition(const.TEXT_POS_VCENTRE_RIGHT_ZERO) right_text.SetVerticalJustificationToCentered() right_text.SetJustificationToRight() right_text.SetValue(values[1]) up_text = self.up_text = vtku.TextZero() up_text.ShadowOff() up_text.SetColour(colour) up_text.SetPosition(const.TEXT_POS_HCENTRE_UP) up_text.SetJustificationToCentered() up_text.SetValue(values[2]) down_text = self.down_text = vtku.TextZero() down_text.ShadowOff() down_text.SetColour(colour) down_text.SetPosition(const.TEXT_POS_HCENTRE_DOWN_ZERO) down_text.SetJustificationToCentered() down_text.SetVerticalJustificationToBottom() down_text.SetValue(values[3]) self.orientation_texts = [ left_text, right_text, up_text, down_text ] self.slice_data.renderer.AddActor(self.wl_text.actor) self.slice_data.renderer.AddActor(left_text.actor) self.slice_data.renderer.AddActor(right_text.actor) self.slice_data.renderer.AddActor(up_text.actor) self.slice_data.renderer.AddActor(down_text.actor)
def __init__(self, parent): wx.Panel.__init__(self, parent, size=wx.Size(320, 320)) self.SetBackgroundColour(wx.Colour(0, 0, 0)) self.interaction_style = st.StyleStateManager() self.ball_reference = None self.initial_foco = None style = vtk.vtkInteractorStyleTrackballCamera() self.style = style interactor = wxVTKRenderWindowInteractor(self, -1, size = self.GetSize()) interactor.SetInteractorStyle(style) self.interactor = interactor sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(interactor, 1, wx.EXPAND) self.sizer = sizer self.SetSizer(sizer) self.Layout() # It would be more correct (API-wise) to call interactor.Initialize() and # interactor.Start() here, but Initialize() calls RenderWindow.Render(). # That Render() call will get through before we can setup the # RenderWindow() to render via the wxWidgets-created context; this # causes flashing on some platforms and downright breaks things on # other platforms. Instead, we call widget.Enable(). This means # that the RWI::Initialized ivar is not set, but in THIS SPECIFIC CASE, # that doesn't matter. interactor.Enable(1) ren = vtk.vtkRenderer() interactor.GetRenderWindow().AddRenderer(ren) self.ren = ren self.raycasting_volume = False self.onclick = False self.text = vtku.Text() self.text.SetValue("") self.ren.AddActor(self.text.actor) self.slice_plane = None self.view_angle = None self.__bind_events() self.__bind_events_wx() self.mouse_pressed = 0 self.on_wl = False self.picker = vtk.vtkPointPicker() interactor.SetPicker(self.picker) self.seed_points = [] self.points_reference = [] self.measure_picker = vtk.vtkPropPicker() #self.measure_picker.SetTolerance(0.005) self.measures = [] self._last_state = 0 self.repositioned_axial_plan = 0 self.repositioned_sagital_plan = 0 self.repositioned_coronal_plan = 0 self.added_actor = 0 self._mode_cross = False self._to_show_ball = 0 self._ball_ref_visibility = False # initialization of navigation variables #======aji================================================================= self.ShowAngles()