• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python vtk.vtkInteractorStyleImage函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: display


#.........这里部分代码省略.........
	
	# Map the image through the lookup table
	color = vtk.vtkImageMapToColors()
	color.SetLookupTable(table)
	color.SetInputConnection(reslice.GetOutputPort())

	# Display the image
	actor = vtk.vtkImageActor()
	actor.GetMapper().SetInputConnection(color.GetOutputPort())

	renderer1 = vtk.vtkRenderer()
	renderer1.AddActor(actor)
	################
	    
	
	# set up cube actor with Orientation(R-L, A-P, S-O) using transform_cube
	# Set up to ALS (+X=A, +Y=S, +Z=L) source:
	cube = vtk.vtkAnnotatedCubeActor()
	cube.SetXPlusFaceText( "S" );
	cube.SetXMinusFaceText( "I" );
	cube.SetYPlusFaceText( "L" );
	cube.SetYMinusFaceText( "R" );
	cube.SetZPlusFaceText( "A" );
	cube.SetZMinusFaceText( "P" );
	cube.SetFaceTextScale( 0.5 );
	cube.GetAssembly().SetUserTransform( transform_cube );
		
	# Set UP the axes
	axes2 = vtk.vtkAxesActor()
	axes2.SetShaftTypeToCylinder();
	#axes2.SetUserTransform( transform_cube );		 
	axes2.SetTotalLength( 1.5, 1.5, 1.5 );
	axes2.SetCylinderRadius( 0.500 * axes2.GetCylinderRadius() );
	axes2.SetConeRadius( 1.025 * axes2.GetConeRadius() );
	axes2.SetSphereRadius( 1.500 * axes2.GetSphereRadius() );

	tprop2 = axes2.GetXAxisCaptionActor2D()
	tprop2.GetCaptionTextProperty();

	assembly = vtk.vtkPropAssembly();
	assembly.AddPart( axes2 );
	assembly.AddPart( cube );
	
	widget = vtk.vtkOrientationMarkerWidget();
	widget.SetOutlineColor( 0.9300, 0.5700, 0.1300 );
	widget.SetOrientationMarker( assembly );
	widget.SetInteractor( iren1 );
	widget.SetViewport( 0.0, 0.0, 0.4, 0.4 );
	widget.SetEnabled( 1 );
	widget.InteractiveOff();
			
	# Set Up Camera view
	renderer1.SetBackground(0.0, 0.0, 0.0)
	camera = renderer1.GetActiveCamera()

	# bounds and initialize camera
	b = image.GetBounds()
	renderer1.ResetCamera(b)	
	renderer1.ResetCameraClippingRange()
	camera.SetViewUp(0.0,-1.0,0.0)
	camera.Azimuth(315)
	
	# Create a text property for both cube axes
	tprop = vtk.vtkTextProperty()
	tprop.SetColor(1, 1, 1)
	tprop.ShadowOff()
	
	# Create a vtkCubeAxesActor2D.  Use the outer edges of the bounding box to
	# draw the axes.  Add the actor to the renderer.
	axes = vtk.vtkCubeAxesActor2D()
	axes.SetInput(image)
	axes.SetCamera(renderer1.GetActiveCamera())
	axes.SetLabelFormat("%6.4g")
	axes.SetFlyModeToOuterEdges()
	axes.SetFontFactor(1.2)
	axes.SetAxisTitleTextProperty(tprop)
	axes.SetAxisLabelTextProperty(tprop)      
	renderer1.AddViewProp(axes)
	
	############
	# Place the interactor initially. The input to a 3D widget is used to
	# initially position and scale the widget. The "EndInteractionEvent" is
  	# observed which invokes the SelectPolygons callback.
    	# boxWidget.SetInput(image)
	# boxWidget.PlaceWidget()
	# boxWidget.AddObserver("InteractionEvent", SelectPolygons)
	# boxWidget.On()
	# Initizalize
	# Set up the interaction
	interactorStyle = vtk.vtkInteractorStyleImage()
	interactor = vtk.vtkRenderWindowInteractor()
	interactor.SetInteractorStyle(interactorStyle)
	renWin1.SetInteractor(interactor)
	renWin1.Render()
	
	renderer1.Render()
	interactor.Start()
	renderer1.RemoveViewProp(axes)
						
	return transform_cube, zImagePlaneWidget.GetSliceIndex()
开发者ID:cgallego,项目名称:Sunny,代码行数:101,代码来源:test.py


示例17: set_interactor_style_image

 def set_interactor_style_image(self):
     self.vtkWidget.set_interactor_style(vtkInteractorStyleImage())
开发者ID:mmolero,项目名称:pcloudpy,代码行数:2,代码来源:ViewWidget.py


示例18: Display

    def Display(self):

        wholeExtent = self.Image.GetExtent()

        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)

        if self.Type == "freehand":
            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)
        elif self.Type == "contour":
            self.ImageTracerWidget.AddObserver("EndInteractionEvent", self.GetLineFromWidget)
            self.ImageTracerWidget.ContinuousDrawOff()

        sliderRep = vtk.vtkSliderRepresentation2D()
        sliderRep.SetValue(0.5 * (wholeExtent[self.Axis * 2] + wholeExtent[self.Axis * 2 + 1]))
        sliderRep.SetMinimumValue(wholeExtent[self.Axis * 2])
        sliderRep.SetMaximumValue(wholeExtent[self.Axis * 2 + 1])
        sliderRep.SetTitleText("Slice")
        sliderRep.GetPoint1Coordinate().SetCoordinateSystemToNormalizedDisplay()
        sliderRep.GetPoint1Coordinate().SetValue(0.2, 0.9)
        sliderRep.GetPoint2Coordinate().SetCoordinateSystemToNormalizedDisplay()
        sliderRep.GetPoint2Coordinate().SetValue(0.8, 0.9)
        sliderRep.SetSliderLength(0.02)
        sliderRep.SetSliderWidth(0.03)
        sliderRep.SetEndCapLength(0.01)
        sliderRep.SetEndCapWidth(0.03)
        sliderRep.SetTubeWidth(0.005)
        sliderRep.SetLabelFormat("%.0f")

        self.SliderWidget.AddObserver("InteractionEvent", self.ChangeSlice)
        self.SliderWidget.SetRepresentation(sliderRep)
        self.SliderWidget.EnabledOn()

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

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


示例19: initView

    def initView(self, data, widget):
        super(SingleDataView, self).initView(data, widget)
        
        shapeList = data.getData().shape
        y, x = shapeList[-2], shapeList[-1]
        self.dimension = len(shapeList) == 2
        
        self.reslice_mapper = vtk.vtkImageResliceMapper()
        self.reslice_mapper.SetInput(self.image_resample.GetOutput())
        self.reslice_mapper.SliceFacesCameraOn()
        self.reslice_mapper.SliceAtFocalPointOn()
        self.reslice_mapper.JumpToNearestSliceOn()
        self.reslice_mapper.BorderOff()
        self.reslice_mapper.BackgroundOn()
        
        array = data.getData()
        self.minI = array.min()
        self.maxI = array.max()
#        self.minI = 0
#        self.maxI = 255
        image_property = vtk.vtkImageProperty()
        image_property.SetColorWindow(self.maxI - self.minI)
        image_property.SetColorLevel((self.maxI + self.minI) / 2.0)
        image_property.SetAmbient(0.0)
        image_property.SetDiffuse(1.0)
        image_property.SetOpacity(1.0)
        image_property.SetInterpolationTypeToLinear()
        
        self.image_slice = vtk.vtkImageSlice()
        self.image_slice.SetMapper(self.reslice_mapper)
        self.image_slice.SetProperty(image_property)
        
        self.renderer.AddViewProp(self.image_slice)
        
        self.window_interactor = vtk.vtkRenderWindowInteractor()
        self.interactor_style = vtk.vtkInteractorStyleImage()
        self.interactor_style.SetInteractionModeToImage3D()
        self.window_interactor.SetInteractorStyle(self.interactor_style)
        self.render_window.SetInteractor(self.window_interactor)
        point_picker = vtk.vtkPointPicker()
        self.window_interactor.SetPicker(point_picker)
        
        self.render_window.GlobalWarningDisplayOff()
        self.render_window.Render()
        self.camera = self.renderer.GetActiveCamera()
        self.camera.ParallelProjectionOn()
        w, h = self.window_interactor.GetSize()
        if h * x * self.space[0] < w * y * self.space[1]:
            scale = y / 2.0 * self.space[1]
        else:
            scale = h * x  * self.space[0] / 2.0 / w
        self.camera.SetParallelScale(scale)
        point = self.camera.GetFocalPoint()
        dis = self.camera.GetDistance()
        self.camera.SetViewUp(0, -1, 0)
        self.camera.SetPosition(point[0], point[1], point[2] - dis)
        self.renderer.ResetCameraClippingRange()
        
        # View of image
        self.view = 2
                
        self.interactor_style.AddObserver("MouseMoveEvent", self.MouseMoveCallback)
        self.interactor_style.AddObserver("LeftButtonReleaseEvent", self.LeftButtonReleaseCallback)
        self.interactor_style.AddObserver("LeftButtonPressEvent", self.LeftButtonPressCallback)
        self.interactor_style.AddObserver("MiddleButtonPressEvent", self.MiddleButtonPressCallback)
        self.interactor_style.AddObserver("RightButtonPressEvent", self.RightButtonPressCallback)
        self.interactor_style.AddObserver("RightButtonReleaseEvent", self.RightButtonReleaseCallback)
        self.interactor_style.AddObserver("KeyPressEvent", self.KeyPressCallback)
        self.interactor_style.AddObserver("CharEvent", self.CharCallback)
        
        #self.plugin[0].enable(self)
        self.updateAfter()
        
        self.render_window.Render()
开发者ID:guohengkai,项目名称:MIRVAP,代码行数:74,代码来源:WidgetViewBase.py


示例20: createInteractorStyle

 def createInteractorStyle(self):
     return vtk.vtkInteractorStyleImage()
开发者ID:aevum,项目名称:moonstone,代码行数:2,代码来源:scene.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkInteractorStyleTrackballCamera函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkIntArray函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap