Ejemplo n.º 1
0
    def Initialize(self):

        if not self.Renderer:
            self.Renderer = vtk.vtkRenderer()
            self.Renderer.SetBackground(self.Background)
            self.RenderWindow = vtk.vtkRenderWindow()
            self.RenderWindow.AddRenderer(self.Renderer)
            self.RenderWindow.SetSize(self.WindowSize[0],self.WindowSize[1])
            self.RenderWindow.SetPointSmoothing(self.PointSmoothing)
            self.RenderWindow.SetLineSmoothing(self.LineSmoothing)
            self.RenderWindow.SetPolygonSmoothing(self.PolygonSmoothing)
            self.RenderWindowInteractor = vtk.vtkRenderWindowInteractor()
            if 'vtkCocoaRenderWindowInteractor' in dir(vtk) and vtk.vtkCocoaRenderWindowInteractor.SafeDownCast(self.RenderWindowInteractor):
                self.RenderWindowInteractor = vtkvmtk.vtkvmtkCocoaRenderWindowInteractor()
            self.RenderWindow.SetInteractor(self.RenderWindowInteractor)
            self.RenderWindowInteractor.SetInteractorStyle(vtkvmtk.vtkvmtkInteractorStyleTrackballCamera())
            self.RenderWindowInteractor.GetInteractorStyle().KeyPressActivationOff()
            self.RenderWindowInteractor.GetInteractorStyle().AddObserver("CharEvent",self.CharCallback)
            self.RenderWindowInteractor.GetInteractorStyle().AddObserver("KeyPressEvent",self.KeyPressCallback)

            self.AddKeyBinding('x','Take screenshot.',self.ScreenshotCallback,'0')
            self.AddKeyBinding('r','Reset camera.',self.ResetCameraCallback,'0')
            #self.AddKeyBinding('w','Show wireframe.',None,'0')
            #self.AddKeyBinding('r','Reset camera.',self.ResetCameraCallback, '0')
            #self.AddKeyBinding('s','Show surface.', None,'0')
            #self.AddKeyBinding('e','Quit renderer.',self.QuitRendererCallback,'0')
            self.AddKeyBinding('q','Quit renderer/proceed.',self.QuitRendererCallback,'0')
            #self.AddKeyBinding('3','3D.', None,'0')

            #self.TextActorStd = vtk.vtkTextActor()
            #self.TextActorStd.SetPosition(self.PositionStd)
            #self.Renderer.AddActor(self.TextActorStd)

            self.TextActor = vtk.vtkTextActor()
            self.TextActor.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()
            self.TextActor.GetPosition2Coordinate().SetCoordinateSystemToNormalizedViewport()
            self.TextActor.SetPosition(self.Position)
            self.Renderer.AddActor(self.TextActor)

            #self.TextActorOpmode = vtk.vtkTextActor()
            #self.TextActorOpmode.SetPosition(self.PositionOpmode)
            #self.Renderer.AddActor(self.TextActorOpmode)

            self.TextInputActor = vtk.vtkTextActor()
            self.TextInputActor.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()
            self.TextInputActor.GetPosition2Coordinate().SetCoordinateSystemToNormalizedViewport()
            self.TextInputActor.SetPosition(self.InputPosition)
 
        if self.UseRendererInputStream:
            self.InputStream = vmtkRendererInputStream(self)
Ejemplo n.º 2
0
    def Initialize(self):

        if not self.Renderer:
            self.Renderer = vtk.vtkRenderer()
            self.Renderer.SetBackground(self.Background)
            self.RenderWindow = vtk.vtkRenderWindow()
            self.RenderWindow.AddRenderer(self.Renderer)
            self.RenderWindow.SetSize(self.WindowSize[0],self.WindowSize[1])
            self.RenderWindow.SetPointSmoothing(self.PointSmoothing)
            self.RenderWindow.SetLineSmoothing(self.LineSmoothing)
            self.RenderWindow.SetPolygonSmoothing(self.PolygonSmoothing)
            self.RenderWindowInteractor = vtk.vtkRenderWindowInteractor()
            if 'vtkCocoaRenderWindowInteractor' in dir(vtk) and vtk.vtkCocoaRenderWindowInteractor.SafeDownCast(self.RenderWindowInteractor):
                self.RenderWindowInteractor = vtkvmtk.vtkvmtkCocoaRenderWindowInteractor()
            self.RenderWindowInteractor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
            self.RenderWindow.SetInteractor(self.RenderWindowInteractor)