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

Python vtk.vtkBoxWidget函数代码示例

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

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



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

示例1: createRenderer

 def createRenderer(self, **args ):
     background_color = args.get( 'background_color', VTK_BACKGROUND_COLOR )
     self.renderer.SetBackground(*background_color)   
     self.textDisplayMgr = TextDisplayMgr( self.renderer ) 
     self.renderWindowInitSize = args.get( 'window_size', None ) 
     if self.renderWindowInitSize <> None:
         self.renderWindow.SetSize( self.renderWindowInitSize )                             
     self.pointPicker = vtk.vtkPointPicker()
     self.pointPicker.PickFromListOn()   
     try:        self.pointPicker.SetUseCells(True)  
     except:     print>>sys.stderr,  "Warning, vtkPointPicker patch not installed, picking will not work properly."
     self.pointPicker.InitializePickList()             
     self.renderWindowInteractor.SetPicker(self.pointPicker) 
     self.addObserver( self.renderer, 'ModifiedEvent', self.activateEvent )
     self.clipper = vtk.vtkBoxWidget()
     self.clipper.RotationEnabledOff()
     self.clipper.SetPlaceFactor( 1.0 ) 
     self.clipper.KeyPressActivationOff()
     self.clipper.SetInteractor( self.renderWindowInteractor )    
     self.clipper.SetHandleSize( 0.005 )
     self.clipper.SetEnabled( True )
     self.clipper.InsideOutOn()  
     self.clipper.AddObserver( 'StartInteractionEvent', self.startClip )
     self.clipper.AddObserver( 'EndInteractionEvent', self.endClip )
     self.clipper.AddObserver( 'InteractionEvent', self.executeClip )           
     self.clipOff() 
开发者ID:arulalant,项目名称:uvcdat,代码行数:26,代码来源:DV3DPlot.py


示例2: Execute

    def Execute(self):

        if self.Image == None:
            self.PrintError('Error: no Image.')

        if self.Interactive == 1:
            
            if not self.vmtkRenderer:
                self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
                self.vmtkRenderer.Initialize()
                self.OwnRenderer = 1

            self.vmtkRenderer.RegisterScript(self)                 

            self.PlaneWidgetX = vtkvmtk.vtkvmtkImagePlaneWidget()
            self.PlaneWidgetX.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.PlaneWidgetY = vtkvmtk.vtkvmtkImagePlaneWidget()
            self.PlaneWidgetY.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.PlaneWidgetZ = vtkvmtk.vtkvmtkImagePlaneWidget()
            self.PlaneWidgetZ.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.BoxWidget = vtk.vtkBoxWidget()
            self.BoxWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.vmtkRenderer.AddKeyBinding('i','Interact.', self.InteractCallback)

            self.Display()
            while (self.BoxActive == 1):
                self.PaintVOI()
                self.Display()
        else:
            self.PaintVOI()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
开发者ID:vmtk,项目名称:vmtk,代码行数:33,代码来源:vmtkimagevoipainter.py


示例3: Execute

    def Execute(self):

        if self.Image == None:
            self.PrintError('Error: no Image.')

        self.CroppedImage.DeepCopy(self.Image)

        if self.Interactive == 1:
            
            if not self.vmtkRenderer:
                self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
                self.vmtkRenderer.Initialize()
                self.OwnRenderer = 1
                
            self.PlaneWidgetX = vtk.vtkImagePlaneWidget()
            self.PlaneWidgetX.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.PlaneWidgetY = vtk.vtkImagePlaneWidget()
            self.PlaneWidgetY.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.PlaneWidgetZ = vtk.vtkImagePlaneWidget()
            self.PlaneWidgetZ.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.BoxWidget = vtk.vtkBoxWidget()
            self.BoxWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)

            self.Display()
            while (self.BoxActive == 1):
                self.ExtractVOI()
                self.Image = self.CroppedImage
                self.Display()
        else:
            self.ExtractVOI()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()

        self.Image = self.CroppedImage
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:35,代码来源:vmtkimagevoiselector.py


示例4: Execute

    def Execute(self):

        if self.Surface == None:
            self.PrintError('Error: no Surface.')

        if self.WidgetType == "box":
            self.ClipFunction = vtk.vtkPlanes()
        elif self.WidgetType == "sphere":
            self.ClipFunction = vtk.vtkSphere()

        self.Clipper = vtk.vtkClipPolyData()
        self.Clipper.SetInput(self.Surface)
        self.Clipper.SetClipFunction(self.ClipFunction)
        self.Clipper.GenerateClippedOutputOn()
        self.Clipper.InsideOutOn()
        
        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInput(self.Surface)
        mapper.ScalarVisibilityOff()
        self.Actor = vtk.vtkActor()
        self.Actor.SetMapper(mapper)
        self.vmtkRenderer.Renderer.AddActor(self.Actor)

        if self.WidgetType == "box":
            self.ClipWidget = vtk.vtkBoxWidget()
            self.ClipWidget.GetFaceProperty().SetColor(0.6,0.6,0.2)
            self.ClipWidget.GetFaceProperty().SetOpacity(0.25)
        elif self.WidgetType == "sphere":
            self.ClipWidget = vtk.vtkSphereWidget()
            self.ClipWidget.GetSphereProperty().SetColor(0.6,0.6,0.2)
            self.ClipWidget.GetSphereProperty().SetOpacity(0.25)
            self.ClipWidget.GetSelectedSphereProperty().SetColor(0.6,0.0,0.0)
            self.ClipWidget.GetSelectedSphereProperty().SetOpacity(0.75)
            self.ClipWidget.SetRepresentationToSurface()
            self.ClipWidget.SetPhiResolution(20)
            self.ClipWidget.SetThetaResolution(20)

        self.ClipWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        self.Display()

        self.Transform = vtk.vtkTransform()
        self.ClipWidget.GetTransform(self.Transform)

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()

        if self.CleanOutput == 1:
            cleaner = vtk.vtkCleanPolyData()
            cleaner.SetInput(self.Surface)
            cleaner.Update()
            self.Surface = cleaner.GetOutput()

        if self.Surface.GetSource():
            self.Surface.GetSource().UnRegisterAllOutputs()
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:59,代码来源:vmtksurfaceclipper.py


示例5: createContent

 def createContent( self ):
     input =  self.module.inputModule.getOutput()  
     self.boxWidget = vtk.vtkBoxWidget()
     self.boxWidget.SetRotationEnabled(0)
     self.boxWidget.SetPlaceFactor(1.0)
     self.boxWidget.SetInput( input )
     self.planes = vtk.vtkPlanes()
     self.boxWidget.AddObserver("StartInteractionEvent", self.startConfiguration )
     self.boxWidget.AddObserver("InteractionEvent",      self.updateConfiguration )
     self.boxWidget.AddObserver("EndInteractionEvent",   self.endConfiguration ) 
开发者ID:imclab,项目名称:vistrails,代码行数:10,代码来源:ResampleModule.py


示例6: __init__

	def __init__(self):
		super(ClippingBox, self).__init__()
		self.widget = None

		self.clippingBox = vtkBoxWidget()
		self.planes = [vtkImagePlaneWidget() for _ in range(6)]
		self.transform = vtkTransform()  # For future functionality

		self._clippingBoxState = False
		self._clippingPlanesState = False
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:10,代码来源:ClippingBox.py


示例7: __init__

    def __init__( self, parent, imode_callback, rmode_callback, ppos_callback, ao, **kwargs ):
        # initialize Panel
        if 'id' not in kwargs:
            kwargs['id'] = wx.ID_ANY
        wx.Panel.__init__( self, parent, **kwargs )

        self.setInteractionMode = imode_callback
        self.setInteractionMode(True)
        
        self.recordingMode = False
        self.setRecordingMode = rmode_callback
        self.setRecordingMode(False)
        
        self.setPickerPos = ppos_callback
        
        self.ao = ao
        self.aa = False
        self.firstRender = True

        self.vtkWidget = wxVTKRenderWindowInteractor(self, wx.ID_ANY)
        self.iren = self.vtkWidget._Iren
        self.iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
        
        self.renderer = vtk.vtkRenderer()
        self.renderer.SetBackground(0,0,0)
        self.imageLayer = {}
        self.CISID = -1  # Current Image Set ID
        self.imageLayer[self.CISID] = IBCRenderer(self.renderer, self.iren.Render)
        self.bacteriaLayer = BacteriaLayer(self.renderer, self.iren.Render)
        
        self.viewCamActive = True
        
        # for interactive clipping
        self.planes = vtk.vtkPlanes()
        
        self.ellipsoid = None
        self.ellipsoidTextActor = None
        
        # The SetInteractor method is how 3D widgets are associated with the
        # render window interactor. Internally, SetInteractor sets up a bunch
        # of callbacks using the Command/Observer mechanism (AddObserver()).
        self.boxWidget = vtk.vtkBoxWidget()
        self.boxWidget.SetInteractor(self.iren)
        self.boxWidget.SetPlaceFactor(1.0)

        # init vtk window
        self.vtkWidget.Enable(1)
        self.vtkWidget.AddObserver("ExitEvent", lambda o,e,f=parent: f.Close())
        self.vtkWidget.GetRenderWindow().AddRenderer(self.renderer)
        
        # Bind VTK events
        self.iren.AddObserver("KeyPressEvent", self.OnKeyDown)
        
        self.Sizer = wx.BoxSizer()
        self.Sizer.Add(self.vtkWidget, 1, wx.EXPAND)
开发者ID:smdabdoub,项目名称:ProkaryMetrics,代码行数:55,代码来源:vtkRender.py


示例8: processVerticalScalingCommand

    def processVerticalScalingCommand( self, args, config_function ):
#        print "processVerticalScalingCommand: ", str(args)
        verticalScale = config_function.value
        if args and args[0] == "StartConfig":
            ispec = self.inputSpecs[ 0 ]
            wbounds = ispec.getDataBounds()
            self.zscaleBoxWidget = vtk.vtkBoxWidget()
            self.zscaleBoxWidget.SetInteractor( self.renderWindowInteractor )
            self.zscaleBoxWidget.SetPlaceFactor(1.0)
            self.zscaleBoxWidget.HandlesOff()
            self.zscaleBoxWidget.SetEnabled(1)
            oprop = self.zscaleBoxWidget.GetOutlineProperty()
            oprop.SetColor( 0.0, 0.0, 0.0 )
            oprop.SetLineWidth( 2.0 )
            self.zscaleBoxWidget.On()
            self.zscaleBoxWidget.PlaceWidget(wbounds)
#            print "  >>>>>>>>>>>>>>>>>>>>> Place box widget: ", str( wbounds )
        elif args and args[0] == "Init":
            self.parameter_initializing = True
            ispec = self.inputSpecs[ 0 ]
            zsval = config_function.initial_value
#             plotType = ispec.getMetadata('plotType')
#             if plotType == 'xyt':
#                 tval = ispec.getMetadata('time')
#                 if tval: zsval = 10.0 / len( tval )
#             else:
#                 lval = ispec.getMetadata('lev')
#                 if tval: zsval = 10.0 / len( lval )
#             verticalScale.setValues( [ zsval ] )
            self.setZScale( zsval  )
            verticalScale.setValue( 'count', 1 )
            self.parameter_initializing = False
        elif args and args[0] == "EndConfig":
            vscale = verticalScale.getValues()
            self.setZScale( vscale )
            self.zscaleBoxWidget.Off()
            self.zscaleBoxWidget.SetEnabled(0)
            self.zscaleBoxWidget = None
            self.processConfigParameterChange( verticalScale )
        elif args and args[0] == "InitConfig":
            self.updateTextDisplay( config_function.label )
            bbar = self.getInteractionButtons()
            self.skipIndex = 2
            for islider in range(4): bbar.setSliderVisibility(  islider, islider < len(config_function.sliderLabels)  )
        elif args and args[0] == "Open":
            pass
        elif args and args[0] == "Close":
            pass
        elif args and args[0] == "UpdateConfig":
            ispec = self.inputSpecs[ 0 ]
            vscale = args[2].GetValue()
            verticalScale.setValues( [ vscale ] )
            wbounds = ispec.getDataBounds( zscale=vscale )
            self.zscaleBoxWidget.PlaceWidget( wbounds )
开发者ID:NESII,项目名称:uvcdat,代码行数:54,代码来源:StructuredGridPlot.py


示例9: setImageData

	def setImageData(self, imageData):
		self.transformBox = vtkBoxWidget()
		self.transformBox.SetInteractor(self.widget.rwi)
		self.transformBox.SetPlaceFactor(1.01)
		self.transformBox.SetInputData(imageData)
		self.transformBox.SetDefaultRenderer(self.widget.rendererOverlay)
		self.transformBox.InsideOutOn()
		self.transformBox.PlaceWidget()

		self.AddObserver(self.transformBox, "InteractionEvent", self.transformCallback)
		self.transformBox.GetSelectedFaceProperty().SetOpacity(0.3)
		self.transformBox.EnabledOn()
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:12,代码来源:TransformBox.py


示例10: __init__

    def __init__(self):
        '''
        Constructor
        '''
        vtkPythonViewImage.__init__(self)
        
#        texture mapper in 3D: vtkVolumeMapper
        self.__VolumeMapper = None
#        texture mapper in 3D: vtkVolumeTextureMapper3D
        self.__VolumeTextureMapper = vtk.vtkVolumeTextureMapper3D()
#        volume ray cast mapper vtkFixedPointVolumeRayCastMapper
        self.__VolumeRayCastMapper = vtk.vtkFixedPointVolumeRayCastMapper()
#        volume property: vtkVolumeProperty
        self.__VolumeProperty = vtk.vtkVolumeProperty()
#        volume actor: vtkVolume
        self.__VolumeActor = vtk.vtkVolume()
#        opacity transfer function: vtkPiecewiseFunction
        self.__OpacityFunction = vtk.vtkPiecewiseFunction()
#        color transfer function: vtkColorTransferFunction
        self.__ColorFunction = vtk.vtkColorTransferFunction()
        
#        vtkProp3DCollection
        self.__PhantomCollection = vtk.vtkProp3DCollection()
#        blender: vtkImageBlend
        self.__Blender = None
        
#        image 3D cropping box callback: vtkImage3DCroppingBoxCallback
        self.__Callback = vtkPythonImage3DCroppingBoxCallback()
#        box widget: vtkOrientedBoxWidget
#        self.__BoxWidget = vtkOrientedBoxWidget()    # Now I could not wrap vtkOrientedBoxWidget
        self.__BoxWidget = vtk.vtkBoxWidget()
#        vtkPlane widget: vtkPlaneWidget
        self.__PlaneWidget = vtk.vtkPlaneWidget()
#        annotated cube actor: vtkAnnotatedCubeActor, vtkOrientationMarkerWidget
        self.__Cube = vtk.vtkAnnotatedCubeActor()
        self.__Marker = vtk.vtkOrientationMarkerWidget()
        
        self.SetupVolumeRendering()
        self.SetupWidgets()
        
        self.ShowAnnotationsOn()
        self.getTextProperty().SetColor(0, 0, 0)
        self.SetBackground(0.9, 0.9, 0.9) # white
        
        self.__FirstRender = 1
        self.__RenderingMode = self.PLANAR_RENDERING
        self.__VRQuality = 1
        
        self.__InteractorStyleSwitcher = None
开发者ID:jackyko1991,项目名称:vtkpythonext,代码行数:49,代码来源:vtkPythonViewImage3D.py


示例11: Execute

    def Execute(self):

        if (self.Mesh == None):
            self.PrintError('Error: no Mesh.')

        self.Planes = vtk.vtkPlanes()
        self.Clipper = vtk.vtkClipDataSet()
        self.Clipper.SetInput(self.Mesh)
        self.Clipper.SetClipFunction(self.Planes)
        self.Clipper.GenerateClippedOutputOn()
        self.Clipper.InsideOutOn()
        
        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        self.vmtkRenderer.RegisterScript(self) 

        mapper = vtk.vtkDataSetMapper()
        mapper.SetInput(self.Mesh)
        mapper.ScalarVisibilityOff()
        self.Actor = vtk.vtkActor()
        self.Actor.SetMapper(mapper)
        self.vmtkRenderer.Renderer.AddActor(self.Actor)

        self.BoxWidget = vtk.vtkBoxWidget()
        self.BoxWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        self.BoxWidget.GetFaceProperty().SetColor(0.6,0.6,0.2)
        self.BoxWidget.GetFaceProperty().SetOpacity(0.25)

        self.vmtkRenderer.AddKeyBinding('i','Interact.', self.InteractCallback)
        self.vmtkRenderer.AddKeyBinding('space','Clip.', self.ClipCallback)

        self.Display()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
        
        if self.Mesh.GetSource():
            self.Mesh.GetSource().UnRegisterAllOutputs()
开发者ID:SaraZanchi,项目名称:vmtk,代码行数:41,代码来源:vmtkmeshclipper.py


示例12: OnBox

 def OnBox(self, event):
     boxWidget = vtk.vtkBoxWidget()
     # change handle properties
     boxWidget.SetHandleSize(0.005) # default is 0.01
     boxWidget.SetInteractor(self.widget)
     boxWidget.SetPlaceFactor(1.25)
     boxWidget.SetInput(self.normals.GetOutput())
     boxWidget.PlaceWidget()
     boxCallback = self.BoxSelectPolygons()
     boxWidget.AddObserver("EndInteractionEvent", boxCallback)
     boxWidget.KeyPressActivationOff()
     plane = vtk.vtkPlanes()
     self.boxes.append(boxWidget)
     self.planes[boxWidget.GetAddressAsString('')] = plane
     self.region.AddFunction(plane)
     newId = self.GateMenu.AppendCheckItem(-1, "Box #" + str(self.boxCount))
     self.boxCount = self.boxCount + 1
     self.boxIds[newId.GetId()] = boxWidget.GetAddressAsString('')
     newId.Check(True)
     self.Bind(wx.EVT_MENU, self.OnBoxSelect, newId)
     boxWidget.On()
开发者ID:cliburn,项目名称:flow,代码行数:21,代码来源:Main.py


示例13: __init__

	def __init__(self, parent, visualizer, **kws):
		"""
		Initialization
		"""
		self.boxWidget = None
		VisualizationModule.__init__(self, parent, visualizer, **kws)   

		self.descs = {"ShowControls": "Show controls",
					  "ClippedModule": "Module to clip",
					  "AllModules": "Clip all modules",
					  "InsideOut": "Clip from outside"}
		boxWidget = self.boxWidget = vtk.vtkBoxWidget()
		self.cut = 0
	  
		self.clippedMappers = []

		self.renderer = self.parent.getRenderer()
		iactor = parent.wxrenwin.GetRenderWindow().GetInteractor()
		self.boxWidget.SetInteractor(iactor)
		self.boxWidget.SetPlaceFactor(1.0)
		
		outlineProperty = boxWidget.GetOutlineProperty()
		outlineProperty.SetRepresentationToWireframe()
		outlineProperty.SetAmbient(1.0)
		outlineProperty.SetAmbientColor(1, 1, 1)
		outlineProperty.SetLineWidth(3)
		
		selectedOutlineProperty = boxWidget.GetSelectedOutlineProperty()
		selectedOutlineProperty.SetRepresentationToWireframe()
		selectedOutlineProperty.SetAmbient(1.0)
		selectedOutlineProperty.SetAmbientColor(1, 0, 0)
		selectedOutlineProperty.SetLineWidth(3)
#        iactor = self.wxrenwin.GetRenderWindow().GetInteractor()
		boxWidget.AddObserver("InteractionEvent", self.clipVolumeRender)
		self.renew = 0
		self.filterDesc = "Clip rendering using a box"
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:36,代码来源:CutWidget.py


示例14: __init__

    def __init__(self, module_manager):
        # call base constructor
        ModuleBase.__init__(self, module_manager)
        ColourDialogMixin.__init__(
            self, module_manager.get_module_view_parent_window())
        self._numDataInputs = self.NUM_INPUTS
        # use list comprehension to create list keeping track of inputs
        self._inputs = [{'Connected' : None, 'inputData' : None,
                         'vtkActor' : None, 'ipw' : None}
                       for i in range(self._numDataInputs)]
        # then the window containing the renderwindows
        self.threedFrame = None

        # the renderers corresponding to the render windows
        self._threedRenderer = None

        self._outline_source = vtk.vtkOutlineSource()
        om = vtk.vtkPolyDataMapper()
        om.SetInputConnection(self._outline_source.GetOutputPort())
        self._outline_actor = vtk.vtkActor()
        self._outline_actor.SetMapper(om)
        self._cube_axes_actor2d = vtk.vtkCubeAxesActor2D()
        self._cube_axes_actor2d.SetFlyModeToOuterEdges()
        #self._cube_axes_actor2d.SetFlyModeToClosestTriad()


        # use box widget for VOI selection
        self._voi_widget = vtk.vtkBoxWidget()
        # we want to keep it aligned with the cubic volume, thanks
        self._voi_widget.SetRotationEnabled(0)
        self._voi_widget.AddObserver('InteractionEvent',
                                     self.voiWidgetInteractionCallback)
        self._voi_widget.AddObserver('EndInteractionEvent',
                                     self.voiWidgetEndInteractionCallback)
        self._voi_widget.NeedsPlacement = True

        # also create the VTK construct for actually extracting VOI from data
        #self._extractVOI = vtk.vtkExtractVOI()
        self._currentVOI = 6 * [0]

        # set the whole UI up!
        self._create_window()

        # our interactor styles (we could add joystick or something too)
        self._cInteractorStyle = vtk.vtkInteractorStyleTrackballCamera()


        # set the default
        self.threedFrame.threedRWI.SetInteractorStyle(self._cInteractorStyle)
        
        rwi = self.threedFrame.threedRWI
        rwi.Unbind(wx.EVT_MOUSEWHEEL)
        rwi.Bind(wx.EVT_MOUSEWHEEL, self._handler_mousewheel)        

        # initialise our sliceDirections, this will also setup the grid and
        # bind all slice UI events
        self.sliceDirections = sliceDirections(
            self, self.controlFrame.sliceGrid)

        self.selectedPoints = selectedPoints(
            self, self.controlFrame.pointsGrid)

        # we now have a wx.ListCtrl, let's abuse it
        self._tdObjects = tdObjects(self,
                                    self.controlFrame.objectsListGrid)

        self._implicits = implicits(self,
                                    self.controlFrame.implicitsGrid)


        # setup orientation widget stuff
        # NB NB NB: we switch interaction with this off later
        # (InteractiveOff()), thus disabling direct translation and
        # scaling.  If we DON'T do this, interaction with software 
        # raycasters are greatly slowed down.
        self._orientation_widget = vtk.vtkOrientationMarkerWidget()
        
        self._annotated_cube_actor = aca = vtk.vtkAnnotatedCubeActor()
        #aca.TextEdgesOff()

        aca.GetXMinusFaceProperty().SetColor(1,0,0)
        aca.GetXPlusFaceProperty().SetColor(1,0,0)
        aca.GetYMinusFaceProperty().SetColor(0,1,0)
        aca.GetYPlusFaceProperty().SetColor(0,1,0)
        aca.GetZMinusFaceProperty().SetColor(0,0,1)
        aca.GetZPlusFaceProperty().SetColor(0,0,1)
        
        self._axes_actor = vtk.vtkAxesActor()

        self._orientation_widget.SetInteractor(
            self.threedFrame.threedRWI)
        self._orientation_widget.SetOrientationMarker(
            self._axes_actor)
        self._orientation_widget.On()
       
        # make sure interaction is off; when on, interaction with
        # software raycasters is greatly slowed down!
        self._orientation_widget.InteractiveOff()
开发者ID:sanguinariojoe,项目名称:devide,代码行数:98,代码来源:slice3dVWR.py


示例15: Execute

    def Execute(self):

        if self.Mesh == None:
            self.PrintError("Error: no Mesh.")

        self.Clipper = vtk.vtkClipDataSet()
        self.Clipper.SetInput(self.Mesh)
        self.Clipper.GenerateClippedOutputOn()
        self.Clipper.SetInsideOut(self.InsideOut)

        if self.Interactive:

            self.Planes = vtk.vtkPlanes()
            self.Clipper.SetClipFunction(self.Planes)

            self.Cutter = vtk.vtkCutter()
            self.Cutter.SetInput(self.Mesh)
            self.Cutter.SetCutFunction(self.Planes)

            self.ClippedMesh = vtk.vtkUnstructuredGrid()
            self.Surface = vtk.vtkPolyData()

            if not self.vmtkRenderer:
                self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
                self.vmtkRenderer.Initialize()
                self.OwnRenderer = 1

            self.vmtkRenderer.RegisterScript(self)

            mapper = vtk.vtkDataSetMapper()
            mapper.SetInput(self.Mesh)
            mapper.ScalarVisibilityOff()
            self.Actor = vtk.vtkActor()
            self.Actor.SetMapper(mapper)
            self.vmtkRenderer.Renderer.AddActor(self.Actor)

            self.BoxWidget = vtk.vtkBoxWidget()
            self.BoxWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.BoxWidget.GetFaceProperty().SetColor(0.6, 0.6, 0.2)
            self.BoxWidget.GetFaceProperty().SetOpacity(0.25)

            self.vmtkRenderer.AddKeyBinding("i", "Interact.", self.InteractCallback)
            self.vmtkRenderer.AddKeyBinding("space", "Clip.", self.ClipCallback)

            self.Display()

            if self.OwnRenderer:
                self.vmtkRenderer.Deallocate()

        else:

            self.Mesh.GetPointData().SetActiveScalars(self.ClipArrayName)

            self.Clipper.GenerateClipScalarsOff()
            self.Clipper.SetValue(self.ClipValue)
            self.Clipper.Update()

            self.Cutter = vtk.vtkContourFilter()
            self.Cutter.SetInput(self.Mesh)
            self.Cutter.SetValue(0, self.ClipValue)
            self.Cutter.Update()

            self.Mesh = self.Clipper.GetOutput()
            self.Surface = self.Cutter.GetOutput()
            self.ClippedMesh = self.Clipper.GetClippedOutput()

        if self.Mesh.GetSource():
            self.Mesh.GetSource().UnRegisterAllOutputs()
开发者ID:abhishek101hi,项目名称:vmtk,代码行数:68,代码来源:vmtkmeshclipper.py


示例16:

coneMapper.SetInputConnection(cone.GetOutputPort())
coneActor = vtk.vtkActor()
coneActor.SetMapper(coneMapper)

# A renderer and render window
renderer = vtk.vtkRenderer()
renderer.SetBackground(0, 0, 1)
renderer.AddActor(coneActor)

renwin = vtk.vtkRenderWindow()
renwin.AddRenderer(renderer)
 
# An interactor
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renwin)

# A Box widget
boxWidget = vtk.vtkBoxWidget()
boxWidget.SetInteractor(interactor)
boxWidget.SetProp3D(coneActor)
boxWidget.SetPlaceFactor( 1.25 ) # Make the box 1.25x larger than the actor
boxWidget.PlaceWidget()
boxWidget.On()

# Connect the event to a function
boxWidget.AddObserver("InteractionEvent", boxCallback)
 
# Start
interactor.Initialize()
interactor.Start()
开发者ID:lorensen,项目名称:VTKWikiExamples,代码行数:30,代码来源:BoxWidget.py


示例17: testBoxWidget

    def testBoxWidget(self):

        # Demonstrate how to use the vtkBoxWidget.
        # This script uses a 3D box widget to define a "clipping box" to clip some
        # simple geometry (a mace). Make sure that you hit the "W" key to activate the widget.

        # create a sphere source
        #
        sphere = vtk.vtkSphereSource()
        cone = vtk.vtkConeSource()
        glyph = vtk.vtkGlyph3D()
        glyph.SetInputConnection(sphere.GetOutputPort())
        glyph.SetSourceConnection(cone.GetOutputPort())
        glyph.SetVectorModeToUseNormal()
        glyph.SetScaleModeToScaleByVector()
        glyph.SetScaleFactor(0.25)
        apd = vtk.vtkAppendPolyData()
        apd.AddInputConnection(glyph.GetOutputPort())
        apd.AddInputConnection(sphere.GetOutputPort())
        maceMapper = vtk.vtkPolyDataMapper()
        maceMapper.SetInputConnection(apd.GetOutputPort())
        maceActor = vtk.vtkLODActor()
        maceActor.SetMapper(maceMapper)
        maceActor.VisibilityOn()

        planes = vtk.vtkPlanes()
        clipper = vtk.vtkClipPolyData()
        clipper.SetInputConnection(apd.GetOutputPort())
        clipper.SetClipFunction(planes)
        clipper.InsideOutOn()
        selectMapper = vtk.vtkPolyDataMapper()
        selectMapper.SetInputConnection(clipper.GetOutputPort())
        selectActor = vtk.vtkLODActor()
        selectActor.SetMapper(selectMapper)
        selectActor.GetProperty().SetColor(0, 1, 0)
        selectActor.VisibilityOff()
        selectActor.SetScale(1.01, 1.01, 1.01)

        # Create the RenderWindow, Renderer and both Actors
        #
        ren = vtk.vtkRenderer()
        renWin = vtk.vtkRenderWindow()
        renWin.AddRenderer(ren)

        iRen = vtk.vtkRenderWindowInteractor()
        iRen.SetRenderWindow(renWin);
        boxWidget = vtk.vtkBoxWidget()
        boxWidget.SetInteractor(iRen)

        ren.AddActor(maceActor)
        ren.AddActor(selectActor)

        # Add the actors to the renderer, set the background and size
        #
        ren.SetBackground(0.1, 0.2, 0.4)
        renWin.SetSize(300, 300)

        def SelectPolygons(widget, event_string):
            '''
            The callback takes two parameters.
            Parameters:
              widget - the object that generates the event.
              event_string - the event name (which is a string).
            '''
            boxWidget, selectActor
            boxWidget.GetPlanes(planes)
            selectActor.VisibilityOn()

        # place the interactor initially
        boxWidget.SetInputConnection(glyph.GetOutputPort())
        boxWidget.PlaceWidget()
        boxWidget.AddObserver("EndInteractionEvent", SelectPolygons)

        # render and interact with data

        renWin.Render()

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


示例18: segmentFromSeeds

    def segmentFromSeeds(self, images,  image_pos_pat, image_ori_pat, seeds, iren, xplane, yplane, zplane):
        """ segmentFromSeeds: Extracts VOI from seeds
        
        INPUTS:
        =======        
        images: (vtkImageData)   list of Input image to Transform
        seeds: vtkPoints    list of seeded coordinates from picker
        OUTPUTS:
        =======
        transformed_image (vtkImageData)    Transformed imaged mapped to dicom coords frame
        transform (vtkTransform)            Transform used
        
        """
        for postS in range(1,len(images)):
            print "\n Segmenting image post no : %s " % str(postS)
            
            subimage = self.loadDisplay.subImage(images, postS)            
            
            # Proceed to build reference frame for display objects based on DICOM coords   
            [transformed_image, transform_cube] = self.loadDisplay.dicomTransform(subimage, image_pos_pat, image_ori_pat)
            
            # Calculate the center of the volume
            transformed_image.UpdateInformation() 
                    
            print "\nBoxwidget placed..."
            #################################################################
            # The box widget observes the events invoked by the render window
            # interactor.  These events come from user interaction in the render
            # window.
            # Place the interactor initially. The output of the reader is used to
            # place the box widget.
            self.boxWidget = vtk.vtkBoxWidget()
            self.boxWidget.SetInteractor(iren)
            self.boxWidget.SetPlaceFactor(1)
            self.boxWidget.SetInput(transformed_image)
            if( self.boundsPlane_presel != []):
                self.boxWidget.PlaceWidget( self.boundsPlane_presel )
            
            # Construct a bounding box around the seeds  
            init_seedsBounds = [0,0,0,0,0,0]
            seeds.GetBounds( init_seedsBounds )
            
            if postS == 1:        
                # polygonal data --> image stencil:
                # create a simple box VOI mask shape using previously found boundsPlane_preselected
                VOIStencil = vtk.vtkROIStencilSource()
                VOIStencil.SetShapeToBox()
                VOIStencil.SetBounds( init_seedsBounds )    
                VOIStencil.SetInformationInput(transformed_image)
                VOIStencil.Update()
            
                # cut the corresponding VOI region and set the background:
                extractVOI_imgstenc = vtk.vtkImageStencil()
                extractVOI_imgstenc.SetInput(transformed_image)
                extractVOI_imgstenc.SetStencil(VOIStencil.GetOutput())
                extractVOI_imgstenc.ReverseStencilOff()
                extractVOI_imgstenc.SetBackgroundValue(0.0)
                extractVOI_imgstenc.Update()
                
                allSeededIm = vtk.vtkImageData()
                allSeededIm.DeepCopy( extractVOI_imgstenc.GetOutput() )
        
                # Add some bounding box radius
                self.boxWidget.PlaceWidget( init_seedsBounds )
                self.boundsPlane_presel = init_seedsBounds
                print "seeds.GetBounds"
                print init_seedsBounds
                        
                self.boxWidget.AddObserver("InteractionEvent", self.SelectPolygons)
                self.boxWidget.On()
            
                # turn off planes
                xplane.Off()
                yplane.Off()
                iren.Start()
                self.boxWidget.Off()
            
            # polygonal data --> image stencil:
            print "\n Create vtkPolyDataToImageStencil with bounds:"
            print self.boundsPlane_presel
            
            # create a simple box VOI mask shape using previously found boundsPlane_preselected
            VOIStencil = vtk.vtkROIStencilSource()
            VOIStencil.SetShapeToBox()
            VOIStencil.SetBounds( self.boundsPlane_presel )    
            VOIStencil.SetInformationInput(transformed_image)
            VOIStencil.Update()
                                    
            # cut the corresponding VOI region and set the background:
            extractVOI_imgstenc = vtk.vtkImageStencil()
            extractVOI_imgstenc.SetInput(transformed_image)
            extractVOI_imgstenc.SetStencil(VOIStencil.GetOutput())
            extractVOI_imgstenc.ReverseStencilOff()
            extractVOI_imgstenc.SetBackgroundValue(0.0)
            extractVOI_imgstenc.Update()
                
            # add subsecuent VOI stencils
            addsegROI = vtk.vtkImageMathematics()
            addsegROI.SetInput(0, allSeededIm)
            addsegROI.SetInput(1, extractVOI_imgstenc.GetOutput())
#.........这里部分代码省略.........
开发者ID:cgallego,项目名称:segmentLesion,代码行数:101,代码来源:segment.py


示例19: addVol

	def addVol(self, data, header=None):
		pix_diag = 5.0/10.0

		img = vtkImageImportFromArray()
		img.SetArray(data)
		img.ConvertIntToUnsignedShortOn()
		'''
		Origin and Data spacing setting are essential for a normalized volume rendering of
		the DWI image volumes
		------- dawdling for a long time for addressing the problem that the volume is too thin
		and even resorted to pre-resampling of the DWI volumes
		'''
		#img.GetImport().SetDataSpacing(0.9375, 0.9375, 4.5200)
		img.GetImport().SetDataSpacing(header['pixdim'][1:4])
		#img.GetImport().SetDataOrigin(128.0, 128.0, 68.50)
		img.GetImport().SetDataOrigin( 
				header['dim'][0]*header['pixdim'][0],
				header['dim'][1]*header['pixdim'][1],
				header['dim'][2]*header['pixdim'][2])
		print img.GetDataExtent()
 
		volMapper = vtk.vtkGPUVolumeRayCastMapper()
		compositeFunction = vtk.vtkVolumeRayCastCompositeFunction()
		compositeFunction.SetCompositeMethodToInterpolateFirst()
		#compositeFunction.SetCompositeMethodToClassifyFirst()
		#volMapper.SetVolumeRayCastFunction(compositeFunction)

		#volMapper.SetSampleDistance(pix_diag / 5.0)
		volMapper.SetImageSampleDistance( .5 )
		volMapper.SetSampleDistance(1.0)
		volMapper.SetInputConnection( img.GetOutputPort() )
		volMapper.SetBlendModeToComposite()

		# The property describes how the data will look
		self.volProperty = volProperty = vtk.vtkVolumeProperty()
		volProperty.SetColor(self.color_tf)
		volProperty.SetScalarOpacity(self.opacity_tf)
		volProperty.SetGradientOpacity(self.opacity_tf)
		if self.parent.lighting:
			volProperty.ShadeOn()
		#volProperty.SetInterpolationTypeToLinear()
		volProperty.SetInterpolationTypeToNearest()
		volProperty.SetScalarOpacityUnitDistance(pix_diag/5.0)

		vol = vtk.vtkVolume()
		vol.SetMapper(volMapper)
		vol.SetProperty(volProperty)

		self.ren.AddVolume(vol)

		boxWidget = vtk.vtkBoxWidget()
		boxWidget.SetInteractor(self.parent.m_ui.renderView)
		boxWidget.SetPlaceFactor(1.0)

		planes = vtk.vtkPlanes()
		def ClipVolumeRender(obj, event):
			obj.GetPlanes(planes)
			volMapper.SetClippingPlanes(planes)
         
		boxWidget.SetInput(img.GetOutput())
		boxWidget.PlaceWidget(img.GetOutput().GetBounds())
		boxWidget.InsideOutOn()
		boxWidget.AddObserver("InteractionEvent", ClipVolumeRender)

		outlineProperty = boxWidget.GetOutlineProperty()
		outlineProperty.SetRepresentationToWireframe()
		outlineProperty.SetAmbient(1.0)
		outlineProperty.SetAmbientColor(1, 1, 1)
		outlineProperty.SetLineWidth(3)

		selectedOutlineProperty = boxWidget.GetSelectedOutlineProperty()
		selectedOutlineProperty.SetRepresentationToWireframe()
		selectedOutlineProperty.SetAmbient(1.0)
		selectedOutlineProperty.SetAmbientColor(1, 0, 0)
		selectedOutlineProperty.SetLineWidth(1)

		outline = vtk.vtkOutlineFilter()
		outline.SetInputConnection(img.GetOutputPort())
		outlineMapper = vtk.vtkPolyDataMapper()
		outlineMapper.SetInputConnection(outline.GetOutputPort())
		outlineActor = vtk.vtkActor()
		outlineActor.SetMapper(outlineMapper)

		self.ren.AddActor(outlineActor)
		self.volnum += 1
开发者ID:Hanbusy,项目名称:PyVolRender,代码行数:85,代码来源:imgVolRender_GPU.py


示例20: buildPipeline

 
                       
                    
                    

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkCamera函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkBMPReader函数代码示例发布时间: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