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

Python vtk.vtkCellPicker函数代码示例

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

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



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

示例1: key_press

    def key_press(self, interactor, event):
        key = interactor.GetKeySym()
        #XXX this is annoying in dwm (and probably elsewhere)
        #if self.pickerName is None:
            #error_msg('You must select the pick segment in the Picker tab')
            #return
        def checkPickerName():
            if self.pickerName is None:
                error_msg('You must select the pick segment in the Picker tab')
                return False
            return True

        if key.lower()=='q': #hehehe
            gtk.main_quit()
        if key.lower()=='i':
            if not checkPickerName():
                return
            print "Inserting Marker"
            x,y = interactor.GetEventPosition()
            picker = vtk.vtkCellPicker()
            picker.PickFromListOn()
            o = self.paramd[self.pickerName]
            picker.AddPickList(o.isoActor)
            picker.SetTolerance(0.005)
            picker.Pick(x, y, 0, self.sr.renderer)
            points = picker.GetPickedPositions()
            numPoints = points.GetNumberOfPoints()
            if numPoints<1: return
            pnt = points.GetPoint(0)

            marker = Marker(xyz=pnt,
                            rgb=EventHandler().get_default_color())

            EventHandler().add_marker(marker)
        elif key.lower()=='x':
            if not checkPickerName():
                return
            x,y = interactor.GetEventPosition()
            picker = vtk.vtkCellPicker()
            picker.PickFromListOn()
            for o in self.paramd.values():
                picker.AddPickList(o.isoActor)
            picker.SetTolerance(0.01)
            picker.Pick(x, y, 0, self.sr.renderer)
            cellId = picker.GetCellId()
            if cellId==-1:
                pass
            else:
                o = self.paramd.values()[0]
                o.remove.RemoveCell(cellId)
                interactor.Render()
        elif key.lower()=='e':
            if not checkPickerName():
                return
            o = self.paramd.values()[0]
            pw = o.planeWidget
            if pw.GetEnabled():
                pw.EnabledOff()
            else:
                pw.EnabledOn()
开发者ID:elialbert,项目名称:pbrain,代码行数:60,代码来源:surf_renderer_props.py


示例2: key_press

    def key_press(self, interactor, event):
        if shared.debug: print "key press event in SurfRenderWindow"
        key = interactor.GetKeySym()
        sas = self.surface_actors

        def checkPickerId():
            if not self.picker_id:
                error_msg('Cannot insert marker. Choose surface first.')
                return False
            return True

        if key.lower()=='q': #hehehe
            gtk.main_quit()
        if key.lower()=='i':
            if not checkPickerId():
                return
            if shared.debug: print "Inserting Marker"
            x,y = interactor.GetEventPosition()
            picker = vtk.vtkCellPicker()
            picker.PickFromListOn()
            actor = self.__get_surface_actor(self.picker_id)
            if actor==None: return
            picker.AddPickList(actor)
            picker.SetTolerance(0.005)
            picker.Pick(x, y, 0, self.renderer)
            points = picker.GetPickedPositions()
            numPoints = points.GetNumberOfPoints()
            if numPoints<1: return
            pnt = points.GetPoint(0)

            marker = Marker(xyz=pnt,
                            rgb=EventHandler().get_default_color(),
                            radius=shared.ratio*shared.marker_size)
            EventHandler().add_marker(marker)
        elif key.lower()=='x':
            #if not checkPickerIdx():
            #    return
            x,y = interactor.GetEventPosition()
            picker = vtk.vtkCellPicker()
            picker.PickFromListOn()
            for actor in sas:
                picker.AddPickList(actor)
            picker.SetTolerance(0.01)
            picker.Pick(x, y, 0, self.renderer)
            cellId = picker.GetCellId()
            if cellId==-1:
                pass
            else:
                o = self.paramd.values()[0]
                o.remove.RemoveCell(cellId)
                interactor.Render()
开发者ID:neurodebian,项目名称:PyLocator,代码行数:51,代码来源:surf_renderer.py


示例3: __init__

	def __init__(self, parent, visualizer, **kws):
		"""
		Initialization
		"""		
		self.x, self.y, self.z = -1, -1, -1
		VisualizationModule.__init__(self, parent, visualizer, **kws)	

		self.on = 0
		self.renew = 1
	
		self.distanceWidget = vtk.vtkDistanceWidget()
		self.obsTag = self.distanceWidget.AddObserver("EndInteractionEvent", self.onPlacePoint)
		self.representation = vtkbxd.vtkDistanceRepresentationScaled2D()
		self.representation.SetScaleX(1.0)
		self.representation.SetScaleZ(1.0)
		self.distanceWidget.SetRepresentation(self.representation)
		self.renderer = self.parent.getRenderer()
		iactor = self.wxrenwin.GetRenderWindow().GetInteractor()
		self.distanceWidget.SetInteractor(iactor)
		self.picker = vtk.vtkCellPicker()
		self.currentPlane = None

		#self.picker.SetTolerance(0.05)
		#self.updateRendering()
		self.filterDesc = "Measure distance in 3D view"
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:25,代码来源:Distance.py


示例4: __init__

    def __init__(self, imageData=None):
        MarkerWindowInteractor.__init__(self) #does this really just control the markers or is it for the other frames too?

        print "PlaneWidgetsXYZ.__init__()"

        self.vtksurface = None

        self.interactButtons = (1,2,3)
        self.sharedPicker = vtk.vtkCellPicker()
        #self.sharedPicker.SetTolerance(0.005)
        self.SetPicker(self.sharedPicker)
        #initialize all three axes slice objects on the bottom of the window
        self.pwX = vtk.vtkImagePlaneWidget()
        self.pwY = vtk.vtkImagePlaneWidget()
        self.pwZ = vtk.vtkImagePlaneWidget()

        
        self.textActors = {}
        self.boxes = {}

        self.set_image_data(imageData)
        self.Render()

        self.vtk_translation = zeros(3, 'd')
        self.vtk_rotation = zeros(3, 'd')
开发者ID:ashwinashok9111993,项目名称:pbrain,代码行数:25,代码来源:plane_widgets_xyz.py


示例5: __init__

    def __init__(self, *args, **kwargs):
        VtkRenderArea.__init__(self, *args, **kwargs)
        
        self._CurrentRenderer = None
        self._CurrentCamera = None
        self._CurrentZoom = 1.0
        self._CurrentLight = None

        self._ViewportCenterX = 0
        self._ViewportCenterY = 0
        
        self._Picker = vtk.vtkCellPicker()
        self._PickedAssembly = None
        self._PickedProperty = vtk.vtkProperty()
        self._PickedProperty.SetColor(1, 0, 0)
        self._PrePickedProperty = None
        
        self._OldFocus = None

        # need this to be able to handle key_press events.
        self.set_flags(gtk.CAN_FOCUS)

        # these record the previous mouse position
        self._LastX = 0
        self._LastY = 0

        self.connect('button_press_event', self.OnButtonDown)
        self.connect('button_release_event', self.OnButtonUp)
        self.connect('motion_notify_event', self.OnMouseMove)
        self.connect('key_press_event', self.OnKeyPress)
        self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
                        gtk.gdk.BUTTON_RELEASE_MASK |
                        gtk.gdk.KEY_PRESS_MASK |
                        gtk.gdk.POINTER_MOTION_MASK |
                        gtk.gdk.POINTER_MOTION_HINT_MASK)
开发者ID:arcoslab,项目名称:roboview,代码行数:35,代码来源:gtkvtk.py


示例6: add_picker_fixed

    def add_picker_fixed(self):
        # Create a cell picker.
        picker = vtk.vtkCellPicker()
        # Create a Python function to create the text for the text mapper used
        # to display the results of picking.

        def annotate_pick(obj, event):
            if picker.GetCellId() < 0 and not self.show_help:
                self.helptxt_actor.VisibilityOff()
            else:
                mapper = picker.GetMapper()
                if mapper in self.mapper_map:
                    output = []
                    for site in self.mapper_map[mapper]:
                        row = ["{} - ".format(site.species_string),
                               ", ".join(["{:.3f}".format(c)
                                          for c in site.frac_coords]),
                               "[" + ", ".join(["{:.3f}".format(c)
                                                for c in site.coords]) +
                               "]"]
                        output.append("".join(row))
                    self.helptxt_mapper.SetInput("\n".join(output))
                    self.helptxt_actor.SetPosition(10, 10)
                    self.helptxt_actor.VisibilityOn()
                    self.show_help = False
        self.picker = picker
        picker.AddObserver("EndPickEvent", annotate_pick)
        self.iren.SetPicker(picker)
开发者ID:akashneo,项目名称:pymatgen,代码行数:28,代码来源:structure_vtk.py


示例7: SpaceCallback

 def SpaceCallback(self,obj):
     picker = vtk.vtkCellPicker()
     picker.SetTolerance(1E-4 * self.Surface.GetLength())
     eventPosition = self.vmtkRenderer.RenderWindowInteractor.GetEventPosition()
     #eventPosition = obj.GetEventPosition()
     result = picker.Pick(float(eventPosition[0]),float(eventPosition[1]),0.0,self.vmtkRenderer.Renderer)
     if result == 0:
         return
     pickPosition = picker.GetPickPosition()
     pickedCellPointIds = self.Surface.GetCell(picker.GetCellId()).GetPointIds()
     minDistance = 1E10
     pickedSeedId = -1
     for i in range(pickedCellPointIds.GetNumberOfIds()):
         distance = vtk.vtkMath.Distance2BetweenPoints(pickPosition,self.Surface.GetPoint(pickedCellPointIds.GetId(i)))
         if distance < minDistance:
             minDistance = distance
             pickedSeedId = pickedCellPointIds.GetId(i)
     if pickedSeedId == -1:
         pickedSeedId = pickedCellPointIds.GetId(0)
     if (self.InteractionMode==0):
         self.SeedIds.InsertNextId(pickedSeedId)
         point = self.Surface.GetPoint(pickedSeedId)
         self.SeedPoints.GetPoints().InsertNextPoint(point)
         self.SeedPoints.Modified()
     else:
         point = self.Surface.GetPoint(pickedSeedId)
         self.ExamineSpheres.GetPoints().InsertNextPoint(point)
         length = 0.
         array = self.ExamineSurface.GetPointData().GetArray(self.DijkstraDistanceToPointsArrayName)
         if array:
             length = array.GetComponent(pickedSeedId,0)
         self.ExamineSpheres.GetPointData().GetScalars().InsertNextValue(length)
         self.ExamineSpheres.Modified()
     self.vmtkRenderer.RenderWindow.Render()
开发者ID:ChaliZhg,项目名称:vmtk,代码行数:34,代码来源:vmtkdijkstradistancetopoints.py


示例8: __init__

    def __init__(self, slice3dVWRThingy, sliceGrid):
        self.slice3dVWR = slice3dVWRThingy
        self._grid = sliceGrid
        self._sliceDirectionsDict = {}

        # this same picker is used on all new IPWS of all sliceDirections
        self.ipwPicker = vtk.vtkCellPicker()

        self.currentCursor = None

        # configure the grid from scratch
        self._initialiseGrid()

        self._initUI()

        # bind all events
        self._bindEvents()

        # fill out our drop-down menu
        self._disableMenuItems = self._appendGridCommandsToMenu(
            self.slice3dVWR.controlFrame.slicesMenu,
            self.slice3dVWR.controlFrame, disable=True)

        self.overlayMode = 'greenOpacityRange'
        self.fusionAlpha = 0.4

        # this will make all ipw slice polydata available at the output
        self.ipwAppendPolyData = vtk.vtkAppendPolyData()

        # this append filter will make all slice data available at the output
        self.ipwAppendFilter = vtk.vtkAppendFilter()

        # create the first slice
        self._createSlice('Axial')
开发者ID:fvpolpeta,项目名称:devide,代码行数:34,代码来源:sliceDirections.py


示例9: leftButtonDown

    def leftButtonDown(self, *arg):
        inter1 = self.GetInteractor()
        click_pos = inter1.GetEventPosition()
        s = imageViewer.GetSlice()
#        print imageViewer.GetSize()
#        print imageViewer.GetImageActor().GetBounds()
#        image_data.SetScalarComponentFromFloat(click_pos[0], click_pos[1], s, 0, 255.0)
#        image_data.SetScalarComponentFromFloat(click_pos[0] + 1, click_pos[1], s, 0, 255.0)
#        image_data.SetScalarComponentFromFloat(click_pos[0], click_pos[1] + 1, s, 0, 255.0)
#        image_data.SetScalarComponentFromFloat(click_pos[0] - 1, click_pos[1], s, 0, 255.0)
#        image_data.SetScalarComponentFromFloat(click_pos[0], click_pos[1] - 1, s, 0, 255.0)
#        image_import.Modified()
#        image_import.Update()
#        imageViewer.SetInput(image_import.GetOutput())
#        imageViewer.Render()
        picker = vtk.vtkCellPicker()
        picker.Pick(click_pos[0], click_pos[1], s, imageViewer.GetRenderer())
        pos = picker.GetPickPosition()
        print pos
        sphereSource = vtk.vtkSphereSource()
        sphereSource.SetCenter(pos[0], pos[1], pos[2])
        sphereSource.SetRadius(1)
        sphereMapper = vtk.vtkPolyDataMapper()
        sphereMapper.SetInputConnection(sphereSource.GetOutputPort())
        sphereActor = vtk.vtkActor()
        sphereActor.SetMapper(sphereMapper)
        sphereActor.GetProperty().SetColor(255.0, 0.0, 0.0)
        imageViewer.GetRenderer().AddActor(sphereActor)
        imageViewer.Render()
开发者ID:sulei1324,项目名称:lab_codes,代码行数:29,代码来源:test.py


示例10: KeyPressed

 def KeyPressed(self,obj,event):
     key = obj.GetKeySym()
     if key == 'u':
         self.InitializeSeeds()
         self.PickedSeeds.Modified()
         self.vmtkRenderer.RenderWindow.Render()
         return
     elif key == 'space':
         picker = vtk.vtkCellPicker()
         picker.SetTolerance(1E-4 * self._Surface.GetLength())
         eventPosition = obj.GetEventPosition()
         result = picker.Pick(float(eventPosition[0]),float(eventPosition[1]),0.0,self.vmtkRenderer.Renderer)
         if result == 0:
             return
         pickPosition = picker.GetPickPosition()
         pickedCellPointIds = self._Surface.GetCell(picker.GetCellId()).GetPointIds()
         minDistance = 1E10
         pickedSeedId = -1
         for i in range(pickedCellPointIds.GetNumberOfIds()):
             distance = vtk.vtkMath.Distance2BetweenPoints(pickPosition,self._Surface.GetPoint(pickedCellPointIds.GetId(i)))
             if distance < minDistance:
                 minDistance = distance
                 pickedSeedId = pickedCellPointIds.GetId(i)
         if pickedSeedId == -1:
             pickedSeedId = pickedCellPointIds.GetId(0)
         self.PickedSeedIds.InsertNextId(pickedSeedId)
         point = self._Surface.GetPoint(pickedSeedId)
         self.PickedSeeds.GetPoints().InsertNextPoint(point)
         self.PickedSeeds.Modified()
         self.vmtkRenderer.RenderWindow.Render()
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:30,代码来源:vmtkcenterlines.py


示例11: __init__

    def __init__(self, imageData=None):
        MarkerWindowInteractor.__init__(self)

        print "PlaneWidgetsXYZ.__init__()"

        self.vtksurface = None

        self.interactButtons = (1,2,3)
        self.sharedPicker = vtk.vtkCellPicker()
        #self.sharedPicker.SetTolerance(0.005)
        self.SetPicker(self.sharedPicker)
        
        self.pwX = vtk.vtkImagePlaneWidget()
        self.pwY = vtk.vtkImagePlaneWidget()
        self.pwZ = vtk.vtkImagePlaneWidget()

        
        self.textActors = {}
        self.boxes = {}

        self.set_image_data(imageData)
        self.Render()

        self.vtk_translation = zeros(3, 'd')
        self.vtk_rotation = zeros(3, 'd')
开发者ID:alexsavio,项目名称:nidoodles,代码行数:25,代码来源:plane_widgets_xyz.py


示例12: do_trace

 def do_trace(self, obj, e):             
     global im_view, trace_mode, cur_picked_point, trace_mode, traced_lines, color_red, color_green, traced_tree
     cur_slice = im_view.GetSlice()
     click_pos = self.GetInteractor().GetEventPosition()
     if trace_mode == True and choose_mode == False:
         if cur_picked_point == [] and len(traced_lines) != 0:
             print "Must Choose a Point to Start!"
         else:
             trace_picker = vtk.vtkCellPicker()
             trace_picker.Pick(click_pos[0], click_pos[1], cur_slice, im_view.GetRenderer())
             picked_pos = trace_picker.GetPickPosition()
             traced_point = np.require(picked_pos, dtype=np.uint16)
             self.save2lines(traced_point)
             self.ShowPoint(traced_point, color_red)
             if cur_picked_point != []:
                 self.ShowLine(cur_picked_point.tolist(), traced_point.tolist())
             self.changeColor(traced_point, color_green, color_red)
             cur_picked_point = traced_point
     if choose_mode == True and trace_mode == False:
         if traced_tree.size() == 0:
             print "No Point to Choose, Please Trace First!"
         else:    
             choose_picker = vtk.vtkPropPicker()
             choose_picker.Pick(click_pos[0], click_pos[1], cur_slice, im_view.GetRenderer())
             if choose_picker.GetActor() != None:
                 choosen_point = choose_picker.GetActor().GetMapper().GetInput().GetCenter()
                 choosen_point = np.array(choosen_point, dtype=np.uint16)
                 self.changeColor(choosen_point, color_green, color_red)                  
                 cur_picked_point = choosen_point
             else:
                     print "Please Choose a Point"
开发者ID:sulei1324,项目名称:lab_codes,代码行数:31,代码来源:vtk_ui.py


示例13: __init__

 def __init__(self, interactor, key_callback, mouse_callback):
     self.interactor = interactor
     self.picker = vtk.vtkCellPicker()
     self.key_callback = key_callback
     self.mouse_callback = mouse_callback
     self.AddObserver("KeyPressEvent", self.key_pressed)
     self.AddObserver("MouseMoveEvent", self.mouse_moved)
开发者ID:ohinds,项目名称:sv,代码行数:7,代码来源:sv.py


示例14: add_picker

    def add_picker(self):
        # Create a cell picker.
        picker = vtk.vtkCellPicker()
        # Create a Python function to create the text for the text mapper used
        # to display the results of picking.
        source = vtk.vtkVectorText()
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(source.GetOutputPort())
        follower = vtk.vtkFollower()
        follower.SetMapper(mapper)
        follower.GetProperty().SetColor((0, 0, 0))
        follower.SetScale(0.2)
        self.ren.AddActor(follower)
        follower.SetCamera(self.ren.GetActiveCamera())
        follower.VisibilityOff()

        def annotate_pick(obj, event):
            if picker.GetCellId() < 0:
                follower.VisibilityOff()
            else:
                pick_pos = picker.GetPickPosition()
                mapper = picker.GetMapper()
                if mapper in self.mapper_map:
                    site = self.mapper_map[mapper]
                    output = [site.species_string, "Frac. coords: " +
                                                   " ".join(["{:.4f}".format(c)
                                                             for c in
                                                             site.frac_coords])]
                    source.SetText("\n".join(output))
                    follower.SetPosition(pick_pos)
                    follower.VisibilityOn()
        picker.AddObserver("EndPickEvent", annotate_pick)
        self.picker = picker
        self.iren.SetPicker(picker)
开发者ID:akashneo,项目名称:pymatgen,代码行数:34,代码来源:structure_vtk.py


示例15: __init__

    def __init__(self, parent=None, fix_camera=True,
        background=None, size=None):
        '''
        fix_camera : more sensible default
        '''
        if parent is not None:
            self.renWin = parent.GetRenderWindow()
            self.iren = self.renWin.GetInteractor()
        else:
            self.renWin = vtk.vtkRenderWindow()
            if size is None:
                self.renWin.SetSize(800, 600)
            self.iren = vtk.vtkRenderWindowInteractor()
            self.iren.SetRenderWindow(self.renWin)

        self.ren = vtk.vtkRenderer()
        if background == 'white':
            self.ren.SetBackground(1, 1, 1)
        self.renWin.AddRenderer(self.ren)

        if fix_camera:
            camera = vtk.vtkInteractorStyleTrackballCamera()
            camera.SetCurrentRenderer(self.ren)
            self.iren.SetInteractorStyle(camera)

        self.picker = vtk.vtkCellPicker()
        self.iren.SetPicker(self.picker)
        self.picker.AddObserver("EndPickEvent", self.handle_pick)
开发者ID:RodericDay,项目名称:MiniPNM,代码行数:28,代码来源:graphics.py


示例16: __init__

    def __init__(self, imageData=None):
        MarkerWindowInteractor.__init__(self)
        ThreeDimRenderWindow.__init__(self)

        if shared.debug: print "PlaneWidgetsXYZ.__init__()"

        self.vtksurface = None

        self.interactButtons = (1,2,3)
        self.sharedPicker = vtk.vtkCellPicker()
        #self.sharedPicker.SetTolerance(0.005)
        self.SetPicker(self.sharedPicker)
        
        self.pwX = vtk.vtkImagePlaneWidget()
        self.pwY = vtk.vtkImagePlaneWidget()
        self.pwZ = vtk.vtkImagePlaneWidget()

        
        self.axes_labels = []

        self.set_image_data(imageData)
        self.Render()

        self.vtk_translation = np.zeros(3, 'd')
        self.vtk_rotation = np.zeros(3, 'd')
开发者ID:neurodebian,项目名称:PyLocator,代码行数:25,代码来源:plane_widgets_xyz.py


示例17: _setup_slices

    def _setup_slices(self):
        """Create the slices. No actor required in this case"""
        picker = vtk.vtkCellPicker()
        picker_tolerance = 0.005
        picker.SetTolerance(picker_tolerance)
        text_color = (0., 0., 0.)

        self._planes.append(vtk.vtkImagePlaneWidget())
        self._planes[0].SetInputData(self._volume)
        self._planes[0].UserControlledLookupTableOn()
        self._planes[0].SetLookupTable(self._lut)
        self._planes[0].SetPlaneOrientationToXAxes()
        self._planes[0].SetSliceIndex(self._volume.GetExtent()[1]/2) # GetExtent returns a six length array, begin-end pairs
        self._planes[0].DisplayTextOn()
        self._planes[0].GetTextProperty().SetColor(text_color)
        self._planes[0].SetPicker(picker)
        self._planes[0].SetLeftButtonAction(1)
        self._planes[0].SetMiddleButtonAction(2)
        self._planes[0].SetRightButtonAction(0)
        self._planes[0].SetInteractor(self._vtk_widget)
        # self._planes[0].On()

        self._planes.append(vtk.vtkImagePlaneWidget())
        self._planes[1].SetInputData(self._volume)
        self._planes[1].UserControlledLookupTableOn()
        self._planes[1].SetLookupTable(self._lut)
        self._planes[1].SetPlaneOrientationToZAxes()
        self._planes[1].SetSliceIndex(self._volume.GetExtent()[5]/2) # GetExtent returns a six length array, begin-end pairs
        self._planes[1].DisplayTextOn()
        self._planes[1].GetTextProperty().SetColor(text_color)
        self._planes[1].SetPicker(picker)
        self._planes[1].SetLeftButtonAction(1)
        self._planes[1].SetMiddleButtonAction(2)
        self._planes[1].SetRightButtonAction(0)
        self._planes[1].SetInteractor(self._vtk_widget)
开发者ID:FilipeMaia,项目名称:emc,代码行数:35,代码来源:modelmap_module.py


示例18: __init__

    def __init__(self, rwi, renderer):
        # nnsmit-edit
        self.overlay_active = 0;
        # end edit
        self.rwi = rwi
        self.renderer = renderer

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

        # we unbind the existing mousewheel handler so it doesn't
        # interfere
        rwi.Unbind(wx.EVT_MOUSEWHEEL)
        rwi.Bind(wx.EVT_MOUSEWHEEL, self._handler_mousewheel)

        self.ipws = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        lut = self.ipws[0].GetLookupTable()
        for ipw in self.ipws:
            ipw.SetInteractor(rwi)
            ipw.SetLookupTable(lut)

	    # nnsmit-edit
    	self.overlay_ipws = [vtk.vtkImagePlaneWidget() for _ in range(3)]
        lut2 = self.overlay_ipws[0].GetLookupTable()
        lut2.SetNumberOfTableValues(3)
        lut2.SetTableValue(0,0,0,0,0)
        lut2.SetTableValue(1,0.5,0,1,1)
        lut2.SetTableValue(2,1,0,0,1)
        lut2.Build()
        for ipw_overlay in self.overlay_ipws:
            ipw_overlay.SetInteractor(rwi)
            ipw_overlay.SetLookupTable(lut2)
            ipw_overlay.AddObserver('InteractionEvent', wx.EVT_MOUSEWHEEL)

        # now actually connect the sync_overlay observer
        for i,ipw in enumerate(self.ipws):
            ipw.AddObserver('InteractionEvent',lambda vtk_o, vtk_e, i=i: self.observer_sync_overlay(self.ipws,i))
        # end edit

        # we only set the picker on the visible IPW, else the
        # invisible IPWs block picking!
        self.picker = vtk.vtkCellPicker()
        self.picker.SetTolerance(0.005)
        self.ipws[0].SetPicker(self.picker)

        self.outline_source = vtk.vtkOutlineCornerFilter()
        m = vtk.vtkPolyDataMapper()
        m.SetInput(self.outline_source.GetOutput())
        a = vtk.vtkActor()
        a.SetMapper(m)
        a.PickableOff()
        self.outline_actor = a

        self.dv_orientation_widget = DVOrientationWidget(rwi)

        # this can be used by clients to store the current world
        # position
        self.current_world_pos = (0,0,0)
        self.current_index_pos = (0,0,0)
开发者ID:fvpolpeta,项目名称:devide,代码行数:59,代码来源:comedi_utils.py


示例19: __init__

	def __init__(self, parent, visualizer, **kws):
		"""
		Initialization
		"""     
		self.x, self.y, self.z = -1, -1, -1
		VisualizationModule.__init__(self, parent, visualizer, **kws)
		self.on = 0
		self.renew = 1
		self.mapper = vtk.vtkPolyDataMapper()
		self.eventDesc = "Rendering orthogonal slices"
		self.outline = vtk.vtkOutlineFilter()
		self.outlineMapper = vtk.vtkPolyDataMapper()
		self.outlineActor = vtk.vtkActor()
		self.outlineActor.SetMapper(self.outlineMapper)
		
		self.picker = vtk.vtkCellPicker()
		self.picker.SetTolerance(0.005)
		
		self.planeWidgetX = vtk.vtkImagePlaneWidget()
		self.planeWidgetX.DisplayTextOn()
		self.planeWidgetX.SetPicker(self.picker)
		self.planeWidgetX.SetKeyPressActivationValue("x")
		#self.planeWidgetX.UserControlledLookupTableOn()
		self.prop1 = self.planeWidgetX.GetPlaneProperty()
		#self.prop1.SetColor(1, 0, 0)
		self.planeWidgetX.SetResliceInterpolateToCubic()

		self.planeWidgetY = vtk.vtkImagePlaneWidget()
		self.planeWidgetY.DisplayTextOn()
		self.planeWidgetY.SetPicker(self.picker)
		self.planeWidgetY.SetKeyPressActivationValue("y")
		self.prop2 = self.planeWidgetY.GetPlaneProperty()
		self.planeWidgetY.SetResliceInterpolateToCubic()
		#self.planeWidgetY.UserControlledLookupTableOn()
		#self.prop2.SetColor(1, 1, 0)


		# for the z-slice, turn off texture interpolation:
		# interpolation is now nearest neighbour, to demonstrate
		# cross-hair cursor snapping to pixel centers
		self.planeWidgetZ = vtk.vtkImagePlaneWidget()
		self.planeWidgetZ.DisplayTextOn()
		self.planeWidgetZ.SetPicker(self.picker)
		self.planeWidgetZ.SetKeyPressActivationValue("z")
		self.prop3 = self.planeWidgetZ.GetPlaneProperty()
		#self.prop3.SetColor(1, 0, 1)
		#self.planeWidgetZ.UserControlledLookupTableOn()
		self.planeWidgetZ.SetResliceInterpolateToCubic()
		self.renderer = self.parent.getRenderer()
		self.renderer.AddActor(self.outlineActor)
		self.useOutline = 1
		
		iactor = self.wxrenwin.GetRenderWindow().GetInteractor()
		self.planeWidgetX.SetInteractor(iactor)
		self.planeWidgetY.SetInteractor(iactor)
		self.planeWidgetZ.SetInteractor(iactor)
		
		lib.messenger.connect(None, "zslice_changed", self.setZ)
		self.filterDesc = "View orthogonal slices"
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:59,代码来源:Orthogonal.py


示例20: __init__

 def __init__(self):
     # FIXME: the idea is not using Slice from here...!
     #self.slice_ = slc.Slice()
     
     self.picker = vtk.vtkCellPicker() # define position where user clicked
     
     self.mouse_pressed = 0 # define if operation will executed run or not
     
     self.style = const.OP_ADD # define brush operation .OP_DEL, .OP_THRESH
开发者ID:151706061,项目名称:invesalius,代码行数:9,代码来源:styles.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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