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


Python vtk.vtkInteractorStyleImage函数代码示例

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


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

示例1: _createViewFrames

    def _createViewFrames(self):
        import modules.Insight.resources.python.register2DViewFrames
        reload(modules.Insight.resources.python.register2DViewFrames)

        viewerFrame = modules.Insight.resources.python.register2DViewFrames.\
                      viewerFrame
        self.viewerFrame = module_utils.instantiate_module_view_frame(
            self, self._module_manager, viewerFrame)

        self._threedRenderer = vtk.vtkRenderer()
        self._threedRenderer.SetBackground(0.5, 0.5, 0.5)
        self.viewerFrame.threedRWI.GetRenderWindow().AddRenderer(
            self._threedRenderer)

        istyle = vtk.vtkInteractorStyleImage()
        self.viewerFrame.threedRWI.SetInteractorStyle(istyle)
        

        

        # controlFrame creation
        controlFrame = modules.Insight.resources.python.\
                       register2DViewFrames.controlFrame
        self.controlFrame = module_utils.instantiate_module_view_frame(
            self, self._module_manager, controlFrame)

        # display
        self.viewerFrame.Show(True)
        self.controlFrame.Show(True)
开发者ID:fvpolpeta,项目名称:devide,代码行数:29,代码来源:register2D.py

示例2: Start

    def Start(self):
        istyle = vtk.vtkInteractorStyleImage()
        istyle.AddObserver("LeftButtonPressEvent",self.SelectRegion)
        iren = Globals.renWin.GetInteractor()
        iren.SetInteractorStyle(istyle)

        self.UpdateObservers()
开发者ID:ewong718,项目名称:freesurfer,代码行数:7,代码来源:Mode.py

示例3: main

def main():
    rwi = vtk.vtkRenderWindowInteractor()

    istyle = vtk.vtkInteractorStyleImage()
    rwi.SetInteractorStyle(istyle)

    rw = vtk.vtkRenderWindow()
    rwi.SetRenderWindow(rw)

    ren = vtk.vtkRenderer()
    ren.SetBackground(1, 1, 1)
    ren.GetActiveCamera().SetParallelProjection(1)
    rw.AddRenderer(ren)

    rwi.Initialize()

    # with the string "what gh", this will generate the following
    # error at render:

    # RuntimeError: ERROR: In ..\..\..\archive\VTK\Filtering\
    # vtkStreamingDemandDrivenPipeline.cxx, line 698
    # vtkStreamingDemandDrivenPipeline (017CF3C8): The update
    # extent specified in the information for output port 0 on
    # algorithm vtkTrivialProducer(017D2FF0) is 0 255
    # 0 63 0 0, which is outside the whole extent 0 255 0 31 0 0.

    # with the string "what h" (i.e. without the g and its downward
    # stroke, there's no error)
    ta2 = make_glyph(ren, (0, 0), "What h")

    ren.ResetCamera()
    rw.Render()

    rwi.Start()
开发者ID:zhangfangyan,项目名称:devide.sandbox,代码行数:34,代码来源:vtktextactor3d_extent_bug.py

示例4: SetInteractorStyleToImage

	def SetInteractorStyleToImage(self):
		self.interactor = self.renWin.GetInteractor()
		self.istyle = vtk.vtkInteractorStyleImage()
		self.renWin.GetInteractor().SetInteractorStyle(self.istyle)
		self.renderer.GetActiveCamera().ParallelProjectionOn()
		# self.istyle.AddObserver("MouseMoveEvent", self.MouseMoveCallback)
		self.istyle.AddObserver("LeftButtonPressEvent", self.LeftButtonPressCallback)
		self.istyle.AddObserver("LeftButtonReleaseEvent", self.LeftButtonReleaseCallback)
开发者ID:emonson,项目名称:MultiScaleSVD,代码行数:8,代码来源:icicle_noview_textured.py

示例5: Start

    def Start(self):
        self.caller.imageObservers.append(self.UpdateObserver)
        self.ResetSpline()

        istyle = vtk.vtkInteractorStyleImage()
        istyle.AddObserver("LeftButtonReleaseEvent", self.AddPoint)
        istyle.AddObserver("RightButtonPressEvent", self.AddSpline)
        iren = Globals.renWin.GetInteractor()
        iren.SetInteractorStyle(istyle)
开发者ID:ewong718,项目名称:freesurfer,代码行数:9,代码来源:SplineMode.py

示例6: __init_vtk

    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()
开发者ID:151706061,项目名称:invesalius,代码行数:55,代码来源:dicom_preview_panel.py

示例7: SetInteractorStyleToImage

	def SetInteractorStyleToImage(self):
		self.interactor = self.window.GetInteractor()
		self.interactorStyle = vtk.vtkInteractorStyleImage()
		self.window.GetInteractor().SetInteractorStyle(self.interactorStyle)
		self.interactorStyle.AddObserver("MouseMoveEvent", self.MouseMoveCallback)
		self.interactorStyle.AddObserver("LeftButtonPressEvent", self.LeftButtonPressCallback)
		self.interactorStyle.AddObserver("LeftButtonReleaseEvent", self.LeftButtonReleaseCallback)

		self.sliderWidget.SetInteractor(self.interactor)
		self.sliderWidget.SetRepresentation(self.sliderRep)
		self.sliderWidget.SetAnimationModeToAnimate()
		self.sliderWidget.EnabledOn()

		self.sliderWidget.AddObserver("InteractionEvent", self.sliderCallback)
		self.sliderWidget.AddObserver("EndInteractionEvent", self.endSliderCallback)
开发者ID:emonson,项目名称:MultiScaleSVD,代码行数:15,代码来源:image_flow.py

示例8: SetInteractor

    def SetInteractor(self, interactor):
        
        self.interactor = interactor
        self.render = interactor.GetRenderWindow().GetRenderers().GetFirstRenderer()          

        istyle = vtk.vtkInteractorStyleImage()
        istyle.SetInteractor(interactor)
        istyle.AutoAdjustCameraClippingRangeOn()
        interactor.SetInteractorStyle(istyle)
        
        istyle.AddObserver("LeftButtonPressEvent", self.Click)
        istyle.AddObserver("LeftButtonReleaseEvent", self.Release)
        istyle.AddObserver("MouseMoveEvent",self.Moved)

        pick = self.pick = vtk.vtkCellPicker()
开发者ID:151706061,项目名称:invesalius3,代码行数:15,代码来源:editor.py

示例9: __init__

    def __init__(self, parent=None):
        logging.debug("In VTKImageView::__init__()")
        super(VTKImageView, self).__init__(parent)
        self.setWindowTitle(constant.TITLE_PROGRAM)

        self.actor = vtk.vtkImageActor()
        self.textActors = []

        self.render = vtk.vtkRenderer()
        self.render.AddActor(self.actor)

        self.interactorStyle = vtk.vtkInteractorStyleImage()
        self.SetInteractorStyle(self.interactorStyle)

        self.window = self.GetRenderWindow()
        self.window.AddRenderer(self.render)
开发者ID:aevum,项目名称:moonstone,代码行数:16,代码来源:vtkimageview.py

示例10: DisplayComponent

def DisplayComponent(source):
    renderer = vtk.vtkRenderer()
    win = vtk.vtkRenderWindow()
    win.AddRenderer(renderer)
    style = vtk.vtkInteractorStyleImage()
    intact = vtk.vtkRenderWindowInteractor()
    intact.SetInteractorStyle(style)
    intact.SetRenderWindow(win)
    planeX = vtk.vtkImagePlaneWidget()
    planeY = vtk.vtkImagePlaneWidget()
    planeZ = vtk.vtkImagePlaneWidget()

    planeX.SetInteractor(intact)
    planeY.SetInteractor(intact)
    planeZ.SetInteractor(intact)

    planeX.SetInputData(source)
    planeY.SetInputData(source)
    planeZ.SetInputData(source)

    planeX.SetPlaneOrientationToXAxes()
    planeY.SetPlaneOrientationToYAxes()
    planeZ.SetPlaneOrientationToZAxes()

    planeX.On()
    planeY.On()
    planeZ.On()

    global pos
    pos = 1

    def myCallback(obj,event):
        global pos
        #print obj.__class__.__name__," called"
        key = obj.GetKeySym() 
        if key=="Up":
            pos = pos+1
            planeX.SetSliceIndex(pos)
            print pos
            win.Render()
        else:
            pass
    intact.AddObserver(vtk.vtkCommand.KeyPressEvent,myCallback)

    intact.Start()
开发者ID:Beastmaster,项目名称:itk-python-example,代码行数:45,代码来源:vtkThreshold.py

示例11: viewVtk

def viewVtk(mat):
    import vtk

    imageData = vtk.vtkImageData()
    imageData.SetDimensions(mat.shape[0], mat.shape[1], 1)
    imageData.SetScalarTypeToUnsignedShort()
    imageData.SetNumberOfScalarComponents(1)
    imageData.AllocateScalars()

    viewer = vtk.vtkImageViewer()
    viewer.SetInput(imageData)
    viewer.SetZSlice(0)

    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(viewer.GetRenderWindow())

    iren.Initialize()
    iren.Start()

    imageData = vtk.vtkImageSinusoidSource()
    imageData.SetWholeExtent(0, 300, 0, 300, 0, 10)
    imageData.SetAmplitude(63)
    imageData.SetDirection(1, 1, 0)
    imageData.SetPeriod(25)

    viewer = vtk.vtkImageViewer()
    viewer.SetInput(imageData.GetOutput())
    viewer.SetColorWindow(126)
    viewer.SetColorLevel(0)
    viewer.SetZSlice(0)

    def hamschti(obj, event):
        print "Haam:"
        print obj
        print event

    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(viewer.GetRenderWindow())
    iren.Initialize()

    interactor = vtk.vtkInteractorStyleImage()
    ##interactor.AddObserver('LeftButtonPressEvent', hamschti)
    iren.SetInteractorStyle(interactor)

    iren.Start()
开发者ID:r35krag0th,项目名称:pysparse,代码行数:45,代码来源:spmatrix_util.py

示例12: Display

    def Display(self):

        wholeExtent = self.Image.GetWholeExtent()

        self.SliceVOI[0] = wholeExtent[0]
        self.SliceVOI[1] = wholeExtent[1]
        self.SliceVOI[2] = wholeExtent[2]
        self.SliceVOI[3] = wholeExtent[3]
        self.SliceVOI[4] = wholeExtent[4]
        self.SliceVOI[5] = wholeExtent[5]

        self.SliceVOI[self.Axis*2] = wholeExtent[self.Axis*2]
        self.SliceVOI[self.Axis*2+1] = wholeExtent[self.Axis*2]

        range = self.Image.GetScalarRange()

        imageShifter = vtk.vtkImageShiftScale()
        imageShifter.SetInput(self.Image)
        imageShifter.SetShift(-1.0*range[0])
        imageShifter.SetScale(255.0/(range[1]-range[0]))
        imageShifter.SetOutputScalarTypeToUnsignedChar()

        widgetImage = imageShifter.GetOutput()

        self.ImageActor.SetInput(widgetImage)
        self.ImageActor.SetDisplayExtent(self.SliceVOI)
        self.vmtkRenderer.Renderer.AddActor(self.ImageActor)

        self.ImageTracerWidget.SetCaptureRadius(1.5)
        self.ImageTracerWidget.SetViewProp(self.ImageActor)
        self.ImageTracerWidget.SetInput(widgetImage)
        self.ImageTracerWidget.ProjectToPlaneOn()
        self.ImageTracerWidget.SetProjectionNormal(self.Axis)
        self.ImageTracerWidget.PlaceWidget()
        self.ImageTracerWidget.SetAutoClose(self.AutoClose)
        self.ImageTracerWidget.AddObserver("StartInteractionEvent",self.SetWidgetProjectionPosition)
        self.ImageTracerWidget.AddObserver("EndInteractionEvent",self.GetLineFromWidget)

        interactorStyle = vtk.vtkInteractorStyleImage()
        self.vmtkRenderer.RenderWindowInteractor.SetInteractorStyle(interactorStyle)

        self.vmtkRenderer.Render()
开发者ID:greenHandProgramer,项目名称:LungcareEDotnet,代码行数:42,代码来源:vmtkimagelinetracer.py

示例13: main

def main():
    rwi = vtk.vtkRenderWindowInteractor()

    istyle = vtk.vtkInteractorStyleImage()
    rwi.SetInteractorStyle(istyle)

    rw = vtk.vtkRenderWindow()
    rwi.SetRenderWindow(rw)

    ren = vtk.vtkRenderer()
    ren.SetBackground(1,1,1)
    ren.GetActiveCamera().SetParallelProjection(1)
    rw.AddRenderer(ren)

    rwi.Initialize()


    ta1 = make_glyph(ren, (0,0), 'Hello thereTTT\nHoo you too')

    ta2 = make_glyph(ren, (0,100), 'What ghte')

    ta3 = make_glyph(ren, (-100, -100), 'To the left and below')

    ren.ResetCamera()
    rw.Render()

    b = ta1.GetBounds()
    b = [0,0,0,0]
    ta1.GetBoundingBox(b)
    print b

    ss = vtk.vtkSphereSource()
    ss.SetRadius(32)
    sm = vtk.vtkPolyDataMapper()
    sm.SetInput(ss.GetOutput())
    sa = vtk.vtkActor()
    sa.SetMapper(sm)
    sa.SetPosition((b[1] - b[0],b[3] - b[2],0))
    ren.AddActor(sa)

    rwi.Start()
开发者ID:zhangfangyan,项目名称:devide.sandbox,代码行数:41,代码来源:glyph_font_experiments.py

示例14: Visualize

    def Visualize(self):
        renderSize = 300;
        numberOfImages = 1;   #implement only one image visulization

        # Setup the render window and interactor
        renderWindow = vtk.vtkRenderWindow()
        renderWindow.SetSize(renderSize * numberOfImages, renderSize)

        interactor = vtk.vtkRenderWindowInteractor()
        interactor.SetRenderWindow(renderWindow)

        style = vtk.vtkInteractorStyleImage()
        interactor.SetInteractorStyle(style)

        # Render all of the images
        background = [0.4,0.5,0.6]

        sharedCamera = vtk.vtkCamera()
        actor = vtk.vtkImageActor()

        #connect itk image to vtk image
        connector = self.i2vConnector.New()
        connector.SetInput(self.m_Image)

        actor.SetInput(connector.GetOutput())

        renderer = vtk.vtkRenderer()
        renderWindow.AddRenderer(renderer)
        #renderer.SetViewpint()
        renderer.SetBackground(background)


        # start visualization
        renderer.AddActor(actor)
        renderer.ResetCamera()

        renderWindow.Render()

        # start interactor
        interactor.Start()
开发者ID:Beastmaster,项目名称:itk-python-example,代码行数:40,代码来源:QuickView.py

示例15: createOrthoView

    def createOrthoView(self):
        """Create an accompanying orthographic view of the sliceDirection
        encapsulated by this object.
        """

        # there can be only one orthoPipeline
        if not self._orthoPipeline:

            import modules.resources.python.slice3dVWRFrames            
            # import our wxGlade-generated frame
            ovf = modules.resources.python.slice3dVWRFrames.orthoViewFrame
            self._orthoViewFrame = ovf(
                self.sliceDirections.slice3dVWR.threedFrame, id=-1,
                title='dummy')

            self._orthoViewFrame.SetIcon(module_utils.get_module_icon())

            self._renderer = vtk.vtkRenderer()
            self._renderer.SetBackground(0.5, 0.5, 0.5)
            self._orthoViewFrame.RWI.GetRenderWindow().AddRenderer(
                self._renderer)
            istyle = vtk.vtkInteractorStyleImage()
            self._orthoViewFrame.RWI.SetInteractorStyle(istyle)

            wx.EVT_CLOSE(self._orthoViewFrame,
                         lambda e, s=self: s.destroyOrthoView)

            wx.EVT_BUTTON(self._orthoViewFrame,
                          self._orthoViewFrame.closeButtonId,
                          lambda e, s=self: s.destroyOrthoView)

            for ipw in self._ipws:
                self._createOrthoPipelineForNewIPW(ipw)

            if self._ipws:
                self._resetOrthoView()

            self._orthoViewFrame.Show(True)
开发者ID:fvpolpeta,项目名称:devide,代码行数:38,代码来源:sliceDirection.py


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