当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkRenderer函数代码示例

本文整理汇总了Python中vtk.vtkRenderer函数的典型用法代码示例。如果您正苦于以下问题:Python vtkRenderer函数的具体用法?Python vtkRenderer怎么用?Python vtkRenderer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了vtkRenderer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Render

 def Render(self):
     self.Viewport1 = [0.0, 0.0, 0.5, 0.5]
     self.Viewport2 = [0.5, 0.0, 1.0, 0.5]
     self.Viewport3 = [0.0, 0.5, 0.5, 1.0]
     self.Viewport4 = [0.5, 0.5, 1.0, 1.0]
     self.Renderer1 = vtk.vtkRenderer()
     self.Renderer2 = vtk.vtkRenderer()
     self.Renderer3 = vtk.vtkRenderer()
     self.Renderer4 = vtk.vtkRenderer()
     self.renderWindow.AddRenderer(self.Renderer1)
     self.Renderer1.SetViewport(self.Viewport1)
     self.Renderer1.SetBackground(0.6, 0.5, 0.3)
     self.renderWindow.AddRenderer(self.Renderer2)
     self.Renderer2.SetViewport(self.Viewport2)
     self.Renderer2.SetBackground(0.5, 0.5, 0.4)
     self.renderWindow.AddRenderer(self.Renderer3)
     self.Renderer3.SetViewport(self.Viewport3)
     self.Renderer3.SetBackground(0.4, 0.5, 0.5)
     self.renderWindow.AddRenderer(self.Renderer4)
     self.Renderer4.SetViewport(self.Viewport4)
     self.Renderer4.SetBackground(0.0, 0.5, 0.6)
     self.Renderer1.AddActor(self.inputActor1)
     self.Renderer2.AddActor(self.inputActor2)
     self.Renderer3.AddActor(self.inputActor3)
     self.Renderer4.AddActor(self.inputActor4)
     self.camera = vtk.vtkCamera()
     self.Renderer1.SetActiveCamera(self.camera)
     self.Renderer2.SetActiveCamera(self.camera)
     self.Renderer3.SetActiveCamera(self.camera)
     self.Renderer4.SetActiveCamera(self.camera)
     self.Renderer1.ResetCamera()
     self.renderWindow.Render()
     self.interactor.Start()
开发者ID:KaWaiTsoi,项目名称:Test,代码行数:33,代码来源:visualHierarchyCompare.py

示例2: __init__

    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        self.reader = vtk.vtkDICOMImageReader()

        #self.viewerL = vtk.vtkImageViewer2()
        #self.viewerR = vtk.vtkImageViewer2()

        self.renL = vtk.vtkRenderer()
        self.ui.leftVtk.GetRenderWindow().AddRenderer(self.renL)
        self.renR = vtk.vtkRenderer()
        self.ui.rightVtk.GetRenderWindow().AddRenderer(self.renR)

        self.mapperL = vtk.vtkImageMapper()
        self.mapperL.SetInputConnection(self.reader.GetOutputPort())
        self.mapperR = vtk.vtkImageMapper()

        self.actorL = vtk.vtkActor2D()
        self.actorL.SetMapper(self.mapperL)
        self.actorR = vtk.vtkActor2D()
        self.actorR.SetMapper(self.mapperR)

        self.renL.AddActor2D(self.actorL)
        self.renR.AddActor2D(self.actorR)

        self.importer = vtk.vtkImageImport()
        self.mapperR.SetInputConnection(self.importer.GetOutputPort())

        self.loadImage(os.path.join(STARTINGPATH, FILENAME))
        self.setWindowingAlg()
开发者ID:MKozuch,项目名称:MIEnhancer,代码行数:32,代码来源:ImagingEnhancer.py

示例3: create_slice_window

    def create_slice_window(self):
        renderer = vtk.vtkRenderer()
        renderer.SetLayer(0)
        cam = renderer.GetActiveCamera()

        overlay_renderer = vtk.vtkRenderer()
        overlay_renderer.SetLayer(1)
        overlay_renderer.SetActiveCamera(cam)
        overlay_renderer.SetInteractive(0)
        
        self.interactor.GetRenderWindow().SetNumberOfLayers(2)
        self.interactor.GetRenderWindow().AddRenderer(overlay_renderer)
        self.interactor.GetRenderWindow().AddRenderer(renderer)

        actor = vtk.vtkImageActor()
        # TODO: Create a option to let the user set if he wants to interpolate
        # the slice images.
        #actor.InterpolateOff()
        slice_data = sd.SliceData()
        slice_data.SetOrientation(self.orientation)
        slice_data.renderer = renderer
        slice_data.overlay_renderer = overlay_renderer
        slice_data.actor = actor
        slice_data.SetBorderStyle(sd.BORDER_ALL)
        renderer.AddActor(actor)
        renderer.AddActor(slice_data.text.actor)
        renderer.AddViewProp(slice_data.box_actor)
        return slice_data
开发者ID:RuanAragao,项目名称:invesalius3,代码行数:28,代码来源:viewer_slice.py

示例4: __init__

    def __init__(self, interactor):
        self.interactor = interactor
        self.window = interactor.GetRenderWindow()
        self.renderer = vtk.vtkRenderer()
        self.renderer.SetViewport(0, 0, 1, 1)
        self.renderer.SetBackground(1, 1, 1)

        # Used to overlay actors above widgets
        self.actor_renderer = vtk.vtkRenderer()
        self.actor_renderer.SetViewport(0, 0, 1, 1)
        self.actor_renderer.SetBackground(1, 1, 1)

        self.window.AddRenderer(self.renderer)
        self.window.AddRenderer(self.actor_renderer)

        self.widgets = []
        self.timer_listener = self.interactor.AddObserver(
            "TimerEvent",
            self.__render)
        self.window_mod = self.window.AddObserver(
            "ModifiedEvent",
            self.__place,
            30)
        self.render_listener = self.window.AddObserver(
            "RenderEvent",
            self.__rendered)
        self.last_size = None
        self.timer = None
开发者ID:NESII,项目名称:uvcdat,代码行数:28,代码来源:manager.py

示例5: __init__

    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        self.frame = QtGui.QFrame()
        self.vl = QtGui.QGridLayout()

        self.vtkWidget_right_femur = QVTKRenderWindowInteractor(self.frame)
        self.vtkWidget_right_hip = QVTKRenderWindowInteractor(self.frame)
        self.vtkWidget_left_femur = QVTKRenderWindowInteractor(self.frame)
        self.vtkWidget_left_hip = QVTKRenderWindowInteractor(self.frame)

        title_right_femur = QtGui.QLabel('Femur derecho')
        title_right_hip = QtGui.QLabel('Cadera derecha')
        title_left_femur = QtGui.QLabel('Femur izquierdo')
        title_left_hip = QtGui.QLabel('Cadera izquierda')
        self.vl.addWidget(title_right_femur, 0, 0)
        self.vl.addWidget(self.vtkWidget_right_femur, 1, 0)
        self.vl.addWidget(title_right_hip, 0, 1)
        self.vl.addWidget(self.vtkWidget_right_hip, 1, 1)

        self.vl.addWidget(title_left_femur, 2, 0)
        self.vl.addWidget(self.vtkWidget_left_femur, 3, 0)
        self.vl.addWidget(title_left_hip, 2, 1)
        self.vl.addWidget(self.vtkWidget_left_hip, 3, 1)

        self.ren_right_femur = vtk.vtkRenderer()
        self.ren_right_hip = vtk.vtkRenderer()
        self.ren_left_femur = vtk.vtkRenderer()
        self.ren_left_hip = vtk.vtkRenderer()

        self.vtkWidget_right_femur.GetRenderWindow().AddRenderer(self.ren_right_femur)
        self.vtkWidget_right_hip.GetRenderWindow().AddRenderer(self.ren_right_hip)
        self.vtkWidget_left_femur.GetRenderWindow().AddRenderer(self.ren_left_femur)
        self.vtkWidget_left_hip.GetRenderWindow().AddRenderer(self.ren_left_hip)

        self.iren_right_femur = self.vtkWidget_right_femur.GetRenderWindow().GetInteractor()
        self.iren_right_hip = self.vtkWidget_right_hip.GetRenderWindow().GetInteractor()
        self.iren_left_femur = self.vtkWidget_left_femur.GetRenderWindow().GetInteractor()
        self.iren_left_hip = self.vtkWidget_left_hip.GetRenderWindow().GetInteractor()

        openFile = QtGui.QAction(QtGui.QIcon('open.png'), 'Open', self)
        openFile.setShortcut('Ctrl+O')
        openFile.setStatusTip('Open new File')
        openFile.triggered.connect(self.show_dialog)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(openFile)

        self.image_processing = ImageProcessing()

        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)
        self.setGeometry(50, 50, 1200, 800)
        self.show()
开发者ID:elpisco,项目名称:hip-dysplasia,代码行数:55,代码来源:main.py

示例6: __init__

	def __init__(self):
		super(RenderWidget, self).__init__()

		# Default volume renderer
		self.renderer = vtkRenderer()
		self.renderer.SetBackground2(0.4, 0.4, 0.4)
		self.renderer.SetBackground(0.1, 0.1, 0.1)
		self.renderer.SetGradientBackground(True)
		self.renderer.SetLayer(0)

		# Overlay renderer which is synced with the default renderer
		self.rendererOverlay = vtkRenderer()
		self.rendererOverlay.SetLayer(1)
		self.rendererOverlay.SetInteractive(0)
		self.renderer.GetActiveCamera().AddObserver("ModifiedEvent", self._syncCameras)

		self.rwi = QVTKRenderWindowInteractor(parent=self)
		self.rwi.SetInteractorStyle(vtkInteractorStyleTrackballCamera())
		self.rwi.GetRenderWindow().AddRenderer(self.renderer)
		self.rwi.GetRenderWindow().AddRenderer(self.rendererOverlay)
		self.rwi.GetRenderWindow().SetNumberOfLayers(2)
		self.rwi.SetDesiredUpdateRate(0)

		self.imagePlaneWidgets = [vtkImagePlaneWidget() for i in range(3)]
		for index in range(3):
			self.imagePlaneWidgets[index].DisplayTextOn()
			self.imagePlaneWidgets[index].SetInteractor(self.rwi)
			# Disable the margin for free rotation
			self.imagePlaneWidgets[index].SetMarginSizeX(0.0)
			self.imagePlaneWidgets[index].SetMarginSizeY(0.0)

		self.mapper = vtkOpenGLGPUVolumeRayCastMapper()
		self.mapper.SetAutoAdjustSampleDistances(1)
		self.volume = None
		self.imageData = None
		self.VolumeVisualization = None
		self.shouldResetCamera = False
		self.gridItems = []
		self.orientationGridItems = []

		self.clippingBox = ClippingBox()
		self.clippingBox.setWidget(self)

		# Keep track of the base and user transforms
		self.baseTransform = vtkTransform()
		self.userTransform = vtkTransform()

		self.setMinimumWidth(340)
		self.setMinimumHeight(340)

		layout = QGridLayout(self)
		layout.setSpacing(0)
		layout.setContentsMargins(0, 0, 0, 0)
		layout.addWidget(self.rwi, 0, 0)
		self.setLayout(layout)
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:55,代码来源:RenderWidget.py

示例7: renderers

def renderers(window, rows=1, cols=1):
    renderer = vtk.vtkRenderer()
    rows = np.linspace(0,1,rows+1)
    cols = np.linspace(0,1,cols+1)
    rows, cols = np.meshgrid(rows, cols)
    renderers = []
    for r, c in zip(range(rows.shape[0]-1), range(cols.shape[1]-1)):
        viewport = rows[r, r], cols[c, c], rows[r+1, r+1], cols[c+1, c+1]
        renderers.append(vtk.vtkRenderer())
        window.AddRenderer(renderers[-1])
        renderers[-1].SetViewport(viewport)
        renderers[-1].SetBackground(1., 1., 1.)
    return renderers
开发者ID:pfernique,项目名称:wanda,代码行数:13,代码来源:frame.py

示例8: clean_gui

    def clean_gui(self):
        self.ren_right_femur = vtk.vtkRenderer()
        self.ren_right_hip = vtk.vtkRenderer()
        self.ren_left_femur = vtk.vtkRenderer()
        self.ren_left_hip = vtk.vtkRenderer()

        self.vtkWidget_right_femur.GetRenderWindow().AddRenderer(self.ren_right_femur)
        self.vtkWidget_right_hip.GetRenderWindow().AddRenderer(self.ren_right_hip)
        self.vtkWidget_left_femur.GetRenderWindow().AddRenderer(self.ren_left_femur)
        self.vtkWidget_left_hip.GetRenderWindow().AddRenderer(self.ren_left_hip)

        self.iren_right_femur = self.vtkWidget_right_femur.GetRenderWindow().GetInteractor()
        self.iren_right_hip = self.vtkWidget_right_hip.GetRenderWindow().GetInteractor()
        self.iren_left_femur = self.vtkWidget_left_femur.GetRenderWindow().GetInteractor()
        self.iren_left_hip = self.vtkWidget_left_hip.GetRenderWindow().GetInteractor()
开发者ID:elpisco,项目名称:hip-dysplasia,代码行数:15,代码来源:main.py

示例9: view

def view(stlfilename):
    reader = vtk.vtkSTLReader()
    reader.SetFileName(stlfilename)

    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(reader.GetOutputPort())

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)

    # Create a rendering window and renderer
    ren = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)

    # Create a renderwindowinteractor
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)

    # Assign actor to the renderer
    ren.AddActor(actor)

    # Enable user interface interactor
    iren.Initialize()
    renWin.Render()
    iren.Start()
开发者ID:Mouse-Imaging-Centre,项目名称:minc-stuffs,代码行数:26,代码来源:vtk_meshconvert.py

示例10: initialize

    def initialize(self):
        global renderer, renderWindow, renderWindowInteractor, cone, mapper, actor

        # Bring used components
        self.registerVtkWebProtocol(protocols.vtkWebMouseHandler())
        self.registerVtkWebProtocol(protocols.vtkWebViewPort())
        self.registerVtkWebProtocol(protocols.vtkWebViewPortImageDelivery())
        self.registerVtkWebProtocol(protocols.vtkWebViewPortGeometryDelivery())

        # Create default pipeline (Only once for all the session)
        if not _WebCone.view:
            # VTK specific code
            renderer = vtk.vtkRenderer()
            renderWindow = vtk.vtkRenderWindow()
            renderWindow.AddRenderer(renderer)

            renderWindowInteractor = vtk.vtkRenderWindowInteractor()
            renderWindowInteractor.SetRenderWindow(renderWindow)
            renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()

            cone = vtk.vtkConeSource()
            mapper = vtk.vtkPolyDataMapper()
            actor = vtk.vtkActor()

            mapper.SetInputConnection(cone.GetOutputPort())
            actor.SetMapper(mapper)

            renderer.AddActor(actor)
            renderer.ResetCamera()
            renderWindow.Render()

            # VTK Web application specific
            _WebCone.view = renderWindow
            self.Application.GetObjectIdMap().SetActiveObject("VIEW", renderWindow)
开发者ID:berendkleinhaneveld,项目名称:VTK,代码行数:34,代码来源:vtk_web_cone.py

示例11: testStyleJoystickActor

    def testStyleJoystickActor(self):

        ren = vtk.vtkRenderer()
        renWin = vtk.vtkRenderWindow()
        iRen = vtk.vtkRenderWindowInteractor()
        iRen.SetRenderWindow(renWin)

        testStyleBaseSpike = TestStyleBaseSpike.StyleBaseSpike(ren, renWin, iRen)

        # Set interactor style
        inStyle = vtk.vtkInteractorStyleSwitch()
        iRen.SetInteractorStyle(inStyle)

        # Switch to Joystick+Actor mode

        iRen.SetKeyEventInformation(0, 0, "j", 0)
        iRen.InvokeEvent("CharEvent")

        iRen.SetKeyEventInformation(0, 0, "a", 0)
        iRen.InvokeEvent("CharEvent")
        # Test style
        testStyleBase = TestStyleBase.TestStyleBase(ren)
        testStyleBase.test_style(inStyle.GetCurrentStyle())

        # render and interact with data

        img_file = "TestStyleJoystickActor.png"
        vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
        vtk.test.Testing.interact()
开发者ID:jlec,项目名称:VTK,代码行数:29,代码来源:TestStyleJoystickActor.py

示例12: __init__

    def __init__(self):
        GtkGLExtVTKRenderWindowInteractor.__init__(self)
        EventHandler().attach(self)
        self.interactButtons = (1,2,3)
        self.renderOn = 1
        self.Initialize()
        self.Start()

        self.renderer = vtk.vtkRenderer()
        self.renWin = self.GetRenderWindow()
        self.renWin.AddRenderer(self.renderer)
        self.interactor = self.renWin.GetInteractor()
        #self.camera = self.renderer.GetActiveCamera()

        
        self.pressFuncs = {1 : self._Iren.LeftButtonPressEvent,
                           2 : self._Iren.MiddleButtonPressEvent,
                           3 : self._Iren.RightButtonPressEvent}
        self.releaseFuncs = {1 : self._Iren.LeftButtonReleaseEvent,
                             2 : self._Iren.MiddleButtonReleaseEvent,
                             3 : self._Iren.RightButtonReleaseEvent}

        self.pressHooks = {}
        self.releaseHooks = {}
        self.lastLabel = None

        self.vtk_interact_mode = False
开发者ID:alexsavio,项目名称:nidoodles,代码行数:27,代码来源:marker_window_interactor.py

示例13: vtkRenderWindowInteractorConeExample

def vtkRenderWindowInteractorConeExample():
    """Like it says, just a simple example
    """
    # create root window
    root = Tkinter.Tk()

    # create vtkTkRenderWidget
    pane = vtkTkRenderWindowInteractor(root, width=300, height=300)
    pane.Initialize()

    def quit(obj=root):
        obj.quit()

    pane.AddObserver("ExitEvent", lambda o,e,q=quit: q())

    ren = vtk.vtkRenderer()
    pane.GetRenderWindow().AddRenderer(ren)

    cone = vtk.vtkConeSource()
    cone.SetResolution(8)
    
    coneMapper = vtk.vtkPolyDataMapper()
    coneMapper.SetInput(cone.GetOutput())
    
    coneActor = vtk.vtkActor()
    coneActor.SetMapper(coneMapper)

    ren.AddActor(coneActor)

    # pack the pane into the tk root
    pane.pack(fill='both', expand=1)
    pane.Start()

    # start the tk mainloop
    root.mainloop()
开发者ID:SRabbelier,项目名称:Casam,代码行数:35,代码来源:vtkTkRenderWindowInteractor.py

示例14: __init__

    def __init__(self, volume):
        super(InteractiveIsosurface, self).__init__()
        self._default_size = (600, 600)
        self.resize(*self._default_size)

        #self._volume = numpy.ascontiguousarray(volume, dtype="float32")
        self._surface_object = IsoSurface(volume)

        self._central_widget = QtGui.QWidget(self)
        self._vtk_widget = QVTKRenderWindowInteractor(self._central_widget)
        self._vtk_widget.SetInteractorStyle(_vtk.vtkInteractorStyleRubberBandPick())
    
        self._renderer = _vtk.vtkRenderer()
        self._renderer.SetBackground(0., 0., 0.)

        self._surface_object.set_renderer(self._renderer)

        self._THRESHOLD_SLIDER_MAXIMUM = 1000
        self._THRESHOLD_SLIDER_INIT = self._THRESHOLD_SLIDER_MAXIMUM/2
        self._threshold_table = self._adaptive_slider_values(volume, self._THRESHOLD_SLIDER_MAXIMUM, volume.min(), volume.max())
        self._threshold_slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self._threshold_slider.setMaximum(self._THRESHOLD_SLIDER_MAXIMUM)

        self._layout = QtGui.QVBoxLayout()
        self._layout.addWidget(self._vtk_widget)
        self._layout.addWidget(self._threshold_slider)

        self._central_widget.setLayout(self._layout)
        self.setCentralWidget(self._central_widget)
开发者ID:ekeberg,项目名称:Python-tools,代码行数:29,代码来源:vtk_tools.py

示例15: notebookviz

def notebookviz(output):
        width,height = 400, 300
        demMapper = vtkPolyDataMapper()
        demMapper.SetInputConnection(output.GetOutputPort())

        surfaceActor = vtkActor()
        surfaceActor.SetMapper(demMapper)
        surfaceActor.GetProperty().SetDiffuseColor(1.0000, 0.3882, 0.2784)
        surfaceActor.GetProperty().SetSpecularColor(1, 1, 1)
        surfaceActor.GetProperty().SetSpecular(.4)
        surfaceActor.GetProperty().SetSpecularPower(50)

        VtkRenderer = vtkRenderer()
        VtkRenderer.SetBackground(1.0, 1.0, 1.0)
        VtkRenderer.AddActor(surfaceActor)

        renderWindow = vtkRenderWindow()
        renderWindow.SetOffScreenRendering(1)
        renderWindow.AddRenderer(VtkRenderer)
        renderWindow.SetSize(width, height)
        renderWindow.Render()

        windowToImageFilter = vtkWindowToImageFilter()
        windowToImageFilter.SetInput(renderWindow)
        windowToImageFilter.Update()

        writer = vtkPNGWriter()
        writer.SetWriteToMemory(1)
        writer.SetInputConnection(windowToImageFilter.GetOutputPort())
        writer.Write()
        data = str(buffer(writer.GetResult()))

        return Image(data)
开发者ID:kezilu,项目名称:pextant,代码行数:33,代码来源:utils.py


注:本文中的vtk.vtkRenderer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。