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

Python vtk.vtkTextMapper函数代码示例

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

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



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

示例1: InitiateScreenText

 def InitiateScreenText(self):
   '''
   self.tpropScren = vtk.vtkTextProperty()
   size = self.GetSize()
   self.text_screen = vtk.vtkTextActor()
   self.text_screen.SetPosition(10, 10)
   self.text_screen.SetInput(' ') 
   
   self.tpropScren.SetFontSize(10)
   self.tpropScren.SetFontFamilyToArial()
   self.tpropScren.SetJustificationToLeft()
   #self.tprop.BoldOn()
   #self.tprop.ItalicOn()
   #self.tpropScren.ShadowOn()
   self.tpropScren.SetColor(0.9, 0.8, 0.8)
   self.text_screen.SetTextProperty(self.tpropScren)
   '''
   #self.scree_text_offset = 10
   self.textMapper = vtk.vtkTextMapper()
   tprop = self.textMapper.GetTextProperty()
   tprop.SetFontFamilyToArial()
   tprop.SetFontSize(10)
   #tprop.BoldOn()
   #tprop.ShadowOn()
   tprop.SetColor(0.5, 0.9, 0.5)
   self.textActor = vtk.vtkActor2D()
   self.textActor.VisibilityOff()
   self.textActor.SetMapper(self.textMapper)
   self.AddActor2D(self.textActor)                                 
开发者ID:rbulha,项目名称:scopevtk,代码行数:29,代码来源:vtkScopeView.py


示例2: addText

    def addText(self, text, x=0.03, y=0.97, size=12, orientation="left"):
        property = vtk.vtkTextProperty()
        property.SetFontSize(size)
        property.SetFontFamilyToArial()
        property.BoldOff()
        property.ItalicOff()
        # property.ShadowOn()
        if orientation == "left":
            property.SetJustificationToLeft()
        elif orientation == "right":
            property.SetJustificationToRight()
        elif orientation == "center":
            property.SetJustificationToCenter()

        property.SetVerticalJustificationToTop()
        property.SetColor(1, 1, 1)

        mapper = vtk.vtkTextMapper()
        mapper.SetTextProperty(property)
        mapper.SetInput(str(text))

        textActor = vtk.vtkActor2D()
        self.textActors.append(textActor)
        textActor.SetMapper(mapper)
        textActor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay()
        textActor.GetPositionCoordinate().SetValue(x, y)
        textActor.VisibilityOn()

        self.render.AddActor(textActor)
        self.Render()
开发者ID:aevum,项目名称:moonstone,代码行数:30,代码来源:vtkimageview.py


示例3: __init__

    def __init__(self):
        self.layer = 99
        self.children = []
        property = vtk.vtkTextProperty()
        property.SetFontSize(const.TEXT_SIZE)
        property.SetFontFamilyToArial()
        property.BoldOff()
        property.ItalicOff()
        property.ShadowOn()
        property.SetJustificationToLeft()
        property.SetVerticalJustificationToTop()
        property.SetColor(const.TEXT_COLOUR)
        self.property = property

        mapper = vtk.vtkTextMapper()
        mapper.SetTextProperty(property)
        self.mapper = mapper

        actor = vtk.vtkActor2D()
        actor.SetMapper(mapper)
        actor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay()
        actor.PickableOff()
        self.actor = actor

        self.SetPosition(const.TEXT_POS_LEFT_UP)
开发者ID:invesalius,项目名称:invesalius3,代码行数:25,代码来源:vtk_utils.py


示例4: __init__

 def __init__(self, id):
     # Create text mapper and 2d actor to display finger position.
     self.textMapper = vtk.vtkTextMapper()
     self.textMapper.SetInput(id)  
     self.tprop = self.textMapper.GetTextProperty()
     self.tprop.SetFontFamilyToArial()
     self.tprop.SetFontSize(30)
     self.tprop.BoldOn()
     self.tprop.ShadowOn()
     self.tprop.SetColor(1, 0, 0)
     self.textActor = vtk.vtkActor2D()
     self.textActor.VisibilityOff()
     self.textActor.SetMapper(self.textMapper)
开发者ID:hnieto,项目名称:python-vtk-tuio,代码行数:13,代码来源:MultiTouchTest.py


示例5: addPicker

 def addPicker(self):
     self.textMapper = vtk.vtkTextMapper()
     tprop = self.textMapper.GetTextProperty()
     tprop.SetFontFamilyToArial()
     tprop.SetFontSize(10)
     tprop.BoldOn()
     tprop.ShadowOn()
     tprop.SetColor(1, 0, 0)
     self.textActor.VisibilityOff()
     self.textActor.SetMapper(self.textMapper)
                 
     self.picker = vtk.vtkCellPicker()
                 
     def annotatePick(object, event):
         print("pick")
         if self.picker.GetCellId() < 0:
             self.textActor.VisibilityOff()
         else:
             selPt = self.picker.GetSelectionPoint()
             pickPos = self.picker.GetPickPosition()
             pickPosInt = (round(pickPos[0]), round(pickPos[1]),round(pickPos[2]))
             pickPosIntStr = str(pickPosInt)
             pickPosIntQStr = Qt.QString(pickPosIntStr)
         
         i = self.materialControl.currentIndex()
         j = self.controlTypeTab[i].currentIndex()
         if j == 0:
             if self.firstPlanePt[i].isChecked():
                 self.firstPlanePtValueRecord[i] = pickPos
                 self.firstPlanePtValue[i].setText(pickPosIntQStr)
             if self.secondPlanePt[i].isChecked():
                 self.secondPlanePtValueRecord[i] = pickPos
                 self.secondPlanePtValue[i].setText(pickPosIntQStr)
             if self.thirdPlanePt[i].isChecked():
                 self.thirdPlanePtValueRecord[i] = pickPos
                 self.thirdPlanePtValue[i].setText(pickPosIntQStr)
         else:
             if self.controlPt[i].isChecked():
                 self.controlPtValueRecord[i] = pickPos
                 self.controlPtValue[i].setText(pickPosIntQStr)
         pickValue = self.data_matrix_red[round(pickPos[2]),round(pickPos[1]),round(pickPos[0])]
         self.textMapper.SetInput("(%.3i, %.3i, %.3i)"%pickPosInt)
         print pickValue
         self.textActor.SetPosition(selPt[:2])
         self.textActor.VisibilityOn()
                 
     # Now at the end of the pick event call the above function.
     self.picker.AddObserver("EndPickEvent", annotatePick)
     self.iren.SetPicker(self.picker)
     # Add the actors to the renderer, set the background and size
     self.ren.AddActor2D(self.textActor)
开发者ID:JonathanWang1,项目名称:somethingMyOwn,代码行数:51,代码来源:gui.py


示例6: display_info

 def display_info(self, info):
     self.infotxt_mapper = vtk.vtkTextMapper()
     tprops = self.infotxt_mapper.GetTextProperty()
     tprops.SetFontSize(14)
     tprops.SetFontFamilyToTimes()
     tprops.SetColor(0, 0, 1)
     tprops.BoldOn()
     tprops.SetVerticalJustificationToTop()
     self.infotxt = "INFO : {}".format(info)
     self.infotxt_actor = vtk.vtkActor2D()
     self.infotxt_actor.VisibilityOn()
     self.infotxt_actor.SetMapper(self.infotxt_mapper)
     self.ren.AddActor(self.infotxt_actor)
     self.infotxt_mapper.SetInput(self.infotxt)
     winsize = self.ren_win.GetSize()
     self.infotxt_actor.SetPosition(10, winsize[1]-10)
     self.infotxt_actor.VisibilityOn()
开发者ID:blondegeek,项目名称:pymatgen,代码行数:17,代码来源:structure_vtk.py


示例7: display_warning

 def display_warning(self, warning):
     self.warningtxt_mapper = vtk.vtkTextMapper()
     tprops = self.warningtxt_mapper.GetTextProperty()
     tprops.SetFontSize(14)
     tprops.SetFontFamilyToTimes()
     tprops.SetColor(1, 0, 0)
     tprops.BoldOn()
     tprops.SetJustificationToRight()
     self.warningtxt = "WARNING : {}".format(warning)
     self.warningtxt_actor = vtk.vtkActor2D()
     self.warningtxt_actor.VisibilityOn()
     self.warningtxt_actor.SetMapper(self.warningtxt_mapper)
     self.ren.AddActor(self.warningtxt_actor)
     self.warningtxt_mapper.SetInput(self.warningtxt)
     winsize = self.ren_win.GetSize()
     self.warningtxt_actor.SetPosition(winsize[0]-10, 10)
     self.warningtxt_actor.VisibilityOn()
开发者ID:blondegeek,项目名称:pymatgen,代码行数:17,代码来源:structure_vtk.py


示例8: display_pick

    def display_pick(self, images, image_pos_pat, image_ori_pat, postS, LesionZslice):
        '''Display a z-slice and use picker to pick coordinates with a mouse right-click'''
        #subtract volumes based on indicated postS            
        # define image based on subtraction of postS -preS
        image = self.subImage(images, postS)    

        # Proceed to build reference frame for display objects based on DICOM coords   
        [transformed_image, transform_cube] = self.dicomTransform(image, image_pos_pat, image_ori_pat)
                
        # Calculate the center of the volume
        transformed_image.UpdateInformation() 
    
        # Set up ortogonal planes
        self.xImagePlaneWidget.SetInput( transformed_image )
        self.yImagePlaneWidget.SetInput( transformed_image )
        self.zImagePlaneWidget.SetInput( transformed_image )
        
        self.zImagePlaneWidget.SetSliceIndex( LesionZslice )
        self.xImagePlaneWidget.On()
        self.yImagePlaneWidget.On()
        self.zImagePlaneWidget.On()
        
        ############
        self.textMapper = vtk.vtkTextMapper()
        tprop = self.textMapper.GetTextProperty()
        tprop.SetFontFamilyToArial()
        tprop.SetFontSize(10)
        tprop.BoldOn()
        tprop.ShadowOn()
        tprop.SetColor(1, 0, 0)
           
        # initialize 
        self.seeds = vtk.vtkPoints()  
        self.textActor = vtk.vtkActor2D()
        self.textActor.VisibilityOff() 
        self.textActor.SetMapper(self.textMapper)

        # Initizalize
        self.iren1.SetPicker(self.picker)
        self.picker.AddObserver("EndPickEvent", self.annotatePick)
        self.renWin1.Render()
        self.renderer1.Render()
        self.iren1.Start()
                
        return self.seeds
开发者ID:xieyanfu,项目名称:extractFeatures,代码行数:45,代码来源:display.py


示例9: setTitle

    def setTitle(self):
        """Put a text at the top of the figure."""
        tprop = self.textProperty(fontsize = self.opt.title_fontsize)
        tprop.SetVerticalJustificationToTop()
        tprop.SetJustificationToCentered()
        mapper = vtk.vtkTextMapper()
        mapper.SetInput(self.opt.title)
        mapper.SetTextProperty(tprop)
        actor = vtk.vtkActor2D()
        actor.SetMapper(mapper)
        actor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay()
        if self.opt.title_coord:
            actor.GetPositionCoordinate().SetValue(self.opt.title_coord[0],
                                                   self.opt.title_coord[1])
        else:
            actor.GetPositionCoordinate().SetValue(0.5, 0.99)

        return actor
开发者ID:paulochon8616,项目名称:CS4.0-EDL,代码行数:18,代码来源:PlotVTK.py


示例10: display_rottra

	def display_rottra(self,mod):
		tm = vtk.vtkTextMapper()
		tp = tm.GetTextProperty()
		#tp.SetFontFamilyToArial()
		tp.SetFontSize(10)
		#tp.BoldOff()
		tp.ShadowOff()
		tp.SetColor(1, 1, 1)
		tp.SetOpacity(1)
		label = vtk.vtkActor2D()
		label.VisibilityOn()
		label.SetMapper(tm)
		v=[0,15]
		label.SetPosition(v)
		rottra = mod.rottra
		tm.SetInput("R:[%.3f,%.3f,%.3f]  T:[%.3f,%.3f,%.3f]"%(rottra[0],rottra[1],rottra[2],rottra[3],rottra[4],rottra[5]))
		self.renderer.AddActor2D(label)
		self.renwin.Render()
开发者ID:ggoret,项目名称:VEDA,代码行数:18,代码来源:mod.py


示例11: text

def text(text, font_size=10, position=(0, 0), color=(0, 0, 0), is_visible=True):
    """ Generate a 2d text actor.
    """
    mapper = vtk.vtkTextMapper()
    mapper.SetInput(text)
    properties = mapper.GetTextProperty()
    properties.SetFontFamilyToArial()
    properties.SetFontSize(font_size)
    properties.BoldOn()
    properties.ShadowOn()
    properties.SetColor(color)

    actor = vtk.vtkActor2D()
    actor.SetPosition(position)
    if not is_visible:
        actor.VisibilityOff()
    actor.SetMapper(mapper)

    return actor
开发者ID:dgoyard,项目名称:caps-clindmri,代码行数:19,代码来源:pvtk.py


示例12: __setupPicking

 def __setupPicking(self):
     # Create a text mapper and actor to display the results of picking.
     textMapper = vtk.vtkTextMapper()
     tprop = textMapper.GetTextProperty()
     tprop.SetFontFamilyToArial()
     tprop.SetFontSize(10)
     tprop.BoldOn()
     tprop.ShadowOn()
     tprop.SetColor(1, 0, 0)
     self.textActor = vtk.vtkActor2D()
     self.textActor.VisibilityOff()
     self.textActor.SetMapper(textMapper)
     
     # Create a cell picker.
     self.pick_opacity_init = 0.5
     self._picker = vtk.vtkVolumePicker()
     self._picker.SetTolerance(0.00005)
     self._picker.SetVolumeOpacityIsovalue(self.pick_opacity_init)
     self._picker.PickCroppingPlanesOff()
开发者ID:behollis,项目名称:DBSViewer,代码行数:19,代码来源:dbsMainWindow.py


示例13: redraw

    def redraw(self, reset_camera=False):
        """
        Redraw the render window.

        Args:
            reset_camera: Set to True to reset the camera to a
                pre-determined default for each structure.  Defaults to False.
        """
        self.ren.RemoveAllViewProps()
        self.picker = None
        self.add_picker_fixed()
        self.helptxt_mapper = vtk.vtkTextMapper()
        tprops = self.helptxt_mapper.GetTextProperty()
        tprops.SetFontSize(14)
        tprops.SetFontFamilyToTimes()
        tprops.SetColor(0, 0, 0)

        if self.structure is not None:
            self.set_structure(self.structure, reset_camera)

        self.ren_win.Render()
开发者ID:AtlasL,项目名称:pymatgen,代码行数:21,代码来源:structure_vtk.py


示例14: setText

 def setText(self, text):
     logging.debug("In TextWidget::setText()")
     self.text = text
     if self.scene:
         self.property.SetJustificationToLeft()
         self.property.SetVerticalJustificationToBottom()
         self.property.SetColor(self.fontColor)
 
         self.mapper = vtk.vtkTextMapper()
         self.mapper.SetTextProperty(self.property)
         self.mapper.SetInput(self.text)
         if self.textActor:
             self.scene.renderer.RemoveActor(self.textActor)
         self.textActor = vtk.vtkActor2D()
         self.textActor.SetMapper(self.mapper)
         self.textActor.PickableOff()
         self.textActor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay()
         self.textActor.GetPositionCoordinate().SetValue(self.position[0], self.position[1])
         self.textActor.VisibilityOn()
         self.scene.renderer.AddActor(self.textActor)   
         self.autoResizeBox()
         self.scene.window.Render()
开发者ID:aevum,项目名称:moonstone,代码行数:22,代码来源:textwidget.py


示例15: set_open_text_on_off

	def set_open_text_on_off(self):
		if not self.islabelon:
			tm = vtk.vtkTextMapper()
			tp = tm.GetTextProperty()
			tp.SetFontFamilyToArial()
			tp.SetFontSize(20)
			tp.BoldOff()
			tp.ShadowOff()
			tp.SetColor(1, 1, 1)
			tp.SetOpacity(0.8)
			self.label = vtk.vtkActor2D()
			self.label.VisibilityOn()
			self.label.SetMapper(tm)
			v=[200,100]
			self.label.SetPosition(v)
			tm.SetInput("VEDA - Visual Environment for Docking Algorithms - Version (%s)\n \nDevelopped by Gael Goret and Jorge Navaza"%self.version)
			self.renderer.AddActor2D(self.label)
			self.renwin.Render()
			self.islabelon=1
		else :
			self.label.VisibilityOff()
			self.renderer.RemoveActor2D(self.label)
			self.renwin.Render()
			self.islabelon=0
开发者ID:ggoret,项目名称:VEDA,代码行数:24,代码来源:gfx.py


示例16: in

# We create the render window which will show up on the screen
# We put our renderer into the render window using AddRenderer.
# Do not set the size of the window here.
renWin = vtk.vtkRenderWindow()
ren = vtk.vtkRenderer()
ren.SetBackground(bg_color)
renWin.AddRenderer(ren)

# We create text actors for each font family and several combinations
# of bold, italic and shadowed style.
text_actors = []
for family in ("Arial", "Courier", "Times"):
    for (bold, italic, shadow) in ((0, 0, 0), (0, 0, 1), (1, 0, 0),
                                   (0, 1, 0), (1, 1, 0)):
        mapper = vtk.vtkTextMapper()
        attribs = []
        if bold:
            attribs.append("b")
        if italic:
            attribs.append("i")
        if shadow:
            attribs.append("s")

        face_name = family
        if len(attribs):
            face_name = face_name + "(" + \
                        string.join(attribs, ",") + ")"

        mapper.SetInput(face_name + ": " + default_text)
        tprop = mapper.GetTextProperty()
开发者ID:timkrentz,项目名称:SunTracker,代码行数:30,代码来源:DispAllFonts.py


示例17: BindTkImageViewer

    def BindTkImageViewer(self):
        imager = self._ImageViewer.GetRenderer()
        
        # stuff for window level text.
        mapper = vtk.vtkTextMapper()
        mapper.SetInput("none")
        t_prop = mapper.GetTextProperty()
        t_prop.SetFontFamilyToTimes()
        t_prop.SetFontSize(18)
        t_prop.BoldOn()
        t_prop.ShadowOn()
        
        self._LevelMapper = mapper

        actor = vtk.vtkActor2D()
        actor.SetMapper(mapper)
        actor.SetLayerNumber(1)
        actor.GetPositionCoordinate().SetValue(4,22)
        actor.GetProperty().SetColor(1,1,0.5)
        actor.SetVisibility(0)
        imager.AddActor2D(actor)

        self._LevelActor = actor
                
        mapper = vtk.vtkTextMapper()
        mapper.SetInput("none")
        t_prop = mapper.GetTextProperty()
        t_prop.SetFontFamilyToTimes()
        t_prop.SetFontSize(18)
        t_prop.BoldOn()
        t_prop.ShadowOn()
        
        self._WindowMapper = mapper

        actor = vtk.vtkActor2D()
        actor.SetMapper(mapper)
        actor.SetLayerNumber(1)
        actor.GetPositionCoordinate().SetValue(4,4)
        actor.GetProperty().SetColor(1,1,0.5)
        actor.SetVisibility(0)
        imager.AddActor2D(actor)

        self._WindowActor = actor

        self._LastX = 0
        self._LastY = 0
        self._OldFocus = 0
        self._InExpose = 0
        
        # bindings
        # window level
        self.bind("<ButtonPress-1>",
                  lambda e,s=self: s.StartWindowLevelInteraction(e.x,e.y))
        self.bind("<B1-Motion>",
                  lambda e,s=self: s.UpdateWindowLevelInteraction(e.x,e.y))
        self.bind("<ButtonRelease-1>",
                  lambda e,s=self: s.EndWindowLevelInteraction()) 
        
        # Get the value
        self.bind("<ButtonPress-3>",
                  lambda e,s=self: s.StartQueryInteraction(e.x,e.y))
        self.bind("<B3-Motion>",
                  lambda e,s=self: s.UpdateQueryInteraction(e.x,e.y))
        self.bind("<ButtonRelease-3>",
                  lambda e,s=self: s.EndQueryInteraction()) 

        self.bind("<Expose>",
                  lambda e,s=self: s.ExposeTkImageViewer())
        self.bind("<Enter>",
                  lambda e,s=self: s.EnterTkViewer())
        self.bind("<Leave>",
                  lambda e,s=self: s.LeaveTkViewer())
        self.bind("<KeyPress-e>",
                  lambda e,s=self: s.quit())
        self.bind("<KeyPress-r>",
                  lambda e,s=self: s.ResetTkImageViewer())
开发者ID:SRabbelier,项目名称:Casam,代码行数:76,代码来源:vtkTkImageViewerWidget.py


示例18:

liverFilter.SetValue(0, 255.0)

liverMapper = vtk.vtkPolyDataMapper()
liverMapper.SetInputConnection(liverFilter.GetOutputPort())
liverMapper.SetScalarRange(0.0, 255.0)

lut = vtk.vtkLookupTable()
liverMapper.SetLookupTable(lut)
lut.SetHueRange(0.10,0.10)
lut.Build()

liverActor = vtk.vtkActor()
liverActor.SetMapper(liverMapper)

#Info Text 1
showInfoText = vtk.vtkTextMapper()
showInfoText.SetInput("Press the following keys to move the planes\nNormal to X: G ; B \nNormal to Y: H ; N\nNormal to Z: J ; M")
tprop = showInfoText.GetTextProperty()
tprop.SetFontSize(14)
tprop.SetJustificationToCentered()
tprop.SetVerticalJustificationToBottom()
tprop.SetColor(1, 1, 1)

showInfoTextActor = vtk.vtkActor2D()
showInfoTextActor.SetMapper(showInfoText)
showInfoTextActor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay()
showInfoTextActor.GetPositionCoordinate().SetValue(0.5, 0.01)

#Info Text 2
showInfoText2 = vtk.vtkTextMapper()
showInfoText2.SetInput("Toggle MPR: K\nToggle Individual Planes: 6 ; 7 ; 8\nToggle Segmentation: L")
开发者ID:IMagicianI,项目名称:ComputationalScience,代码行数:31,代码来源:ctscan2.py


示例19: __init__

    def __init__(self, parent = None):
        super(VTKFrame, self).__init__(parent)

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
        vl = QtGui.QVBoxLayout(self)
        vl.addWidget(self.vtkWidget)
        vl.setContentsMargins(0, 0, 0, 0)
 
        # Create source
        # Each face has a different cell scalar
        # So create a lookup table with a different colour
        # for each face.
        lut = vtk.vtkLookupTable()
        lut.SetNumberOfTableValues(20)
        lut.SetTableRange(0.0, 19.0)
        lut.Build()
        lut.SetTableValue(0, 0, 0, 0)
        lut.SetTableValue(1, 0, 0, 1)
        lut.SetTableValue(2, 0, 1, 0)
        lut.SetTableValue(3, 0, 1, 1)
        lut.SetTableValue(4, 1, 0, 0)
        lut.SetTableValue(5, 1, 0, 1)
        lut.SetTableValue(6, 1, 1, 0)
        lut.SetTableValue(7, 1, 1, 1)
        lut.SetTableValue(8, 0.7, 0.7, 0.7)
        lut.SetTableValue(9, 0, 0, 0.7)
        lut.SetTableValue(10, 0, 0.7, 0)
        lut.SetTableValue(11, 0, 0.7, 0.7)
        lut.SetTableValue(12, 0.7, 0, 0)
        lut.SetTableValue(13, 0.7, 0, 0.7)
        lut.SetTableValue(14, 0.7, 0.7, 0)
        lut.SetTableValue(15, 0, 0, 0.4)
        lut.SetTableValue(16, 0, 0.4, 0)
        lut.SetTableValue(17, 0, 0.4, 0.4)
        lut.SetTableValue(18, 0.4, 0, 0)
        lut.SetTableValue(19, 0.4, 0, 0.4)
        
        platonicSolids = list()
        # There are five Platonic solids.
        platonicSolids.append(vtk.vtkPlatonicSolidSource())
        platonicSolids.append(vtk.vtkPlatonicSolidSource())
        platonicSolids.append(vtk.vtkPlatonicSolidSource())
        platonicSolids.append(vtk.vtkPlatonicSolidSource())
        platonicSolids.append(vtk.vtkPlatonicSolidSource())
        # Specify the Platonic Solid to create.
        for idx, item in enumerate(platonicSolids):
            platonicSolids[idx].SetSolidType(idx)
        names = ["Tetrahedron","Cube","Octahedron","Icosahedron", "Dodecahedron"]
        
        renderers = list()
        mappers = list()
        actors = list()
        textmappers = list()
        textactors = list()
        
        # Create a common text property.
        textProperty = vtk.vtkTextProperty()
        textProperty.SetFontSize(10)
        textProperty.SetJustificationToCentered()
        
        # Create a parametric function source, renderer, mapper 
        # and actor for each object.
        for idx, item in enumerate(platonicSolids):
            platonicSolids[idx].Update()
        
            mappers.append(vtk.vtkPolyDataMapper())
            mappers[idx].SetInputConnection(platonicSolids[idx].GetOutputPort())
            mappers[idx].SetLookupTable(lut)
            mappers[idx].SetScalarRange(0, 20)
        
            actors.append(vtk.vtkActor())
            actors[idx].SetMapper(mappers[idx])
        
            textmappers.append(vtk.vtkTextMapper())
            textmappers[idx].SetInput(names[idx])
            textmappers[idx].SetTextProperty(textProperty)
        
            textactors.append(vtk.vtkActor2D())
            textactors[idx].SetMapper(textmappers[idx])
            textactors[idx].SetPosition(120, 16)
        
            renderers.append(vtk.vtkRenderer())
        
        rowDimensions = 3
        colDimensions = 2
        
        for idx in range(rowDimensions * colDimensions):
            if idx >= len(platonicSolids):
                renderers.append(vtk.vtkRenderer)
        
        rendererSize = 300
        
        # Setup the RenderWindow
        self.vtkWidget.GetRenderWindow().SetSize(rendererSize * rowDimensions / colDimensions, rendererSize * colDimensions )
        
        # Add and position the renders to the render window.
        viewport = list()
        idx = -1
        for row in range(rowDimensions):
#.........这里部分代码省略.........
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:101,代码来源:platonicsolidobjects.py


示例20: _CreateButton

    def _CreateButton(self):
        borderwidth = self._Config['borderwidth']
        width, height = self._DisplaySize
        x, y = self._DisplayOrigin
        x0, y0 = self._Renderer.GetOrigin()

        self._Points = vtk.vtkPoints()
        self._SetPoints()

        cells = vtk.vtkCellArray()
        cells.InsertNextCell(4)
        cells.InsertCellPoint(1)
        cells.InsertCellPoint(3)
        cells.InsertCellPoint(5)
        cells.InsertCellPoint(7)

        if borderwidth > 0:
            cells.InsertNextCell(4)
            cells.InsertCellPoint(0)
            cells.InsertCellPoint(1)
            cells.InsertCellPoint(3)
            cells.InsertCellPoint(2)
            cells.InsertNextCell(4)
            cells.InsertCellPoint(2)
            cells.InsertCellPoint(3)
            cells.InsertCellPoint(5)
            cells.InsertCellPoint(4)
            cells.InsertNextCell(4)
            cells.InsertCellPoint(4)
            cells.InsertCellPoint(5)
            cells.InsertCellPoint(7)
            cells.InsertCellPoint(6)
            cells.InsertNextCell(4)
            cells.InsertCellPoint(6)
            cells.InsertCellPoint(7)
            cells.InsertCellPoint(1)
            cells.InsertCellPoint(0)

        scalars = vtk.vtkUnsignedCharArray()
        scalars.InsertTuple1(0, 0)
        scalars.InsertTuple1(1, 2)
        scalars.InsertTuple1(2, 2)
        scalars.InsertTuple1(3, 3)
        scalars.InsertTuple1(4, 3)

        data = vtk.vtkPolyData()
        data.SetPoints(self._Points)
        data.SetPolys(cells)
        data.GetCellData().SetScalars(scalars)

        mapper = vtk.vtkPolyDataMapper2D()
        mapper.SetInput(data)
        mapper.SetLookupTable(self._LookupTable)
        mapper.SetColorModeToMapScalars()
        mapper.SetScalarRange(0, 3)

        actor = vtk.vtkActor2D()
        actor.SetMapper(mapper)
        actor.SetPosition(x - x0, y - y0)

        self._Scalars = scalars
        self._Actors.append(actor)
        if self._Renderer:
            self._Renderer.AddActor2D(actor)

        mapper = vtk.vtkTextMapper()
        mapper.SetInput(self._Config['text'])
        try:
            property = mapper.GetTextProperty()
        except AttributeError:
            property = mapper
        property.SetFontSize(self._Config['fontsize'])
        if self._Config['font'] in ('courier', 'Courier'):
            property.SetFontFamilyToCourier()
        elif self._Config['font'] in ('arial', 'Arial'):
            property.SetFontFamilyToArial()
        elif self._Config['font'] in ('times', 'Times'):
            property.SetFontFamilyToTimes()
        property.SetJustificationToCentered()
        property.SetVerticalJustificationToCentered()
        property.BoldOn()
        self._TextMapper = mapper

        actor = vtk.vtkActor2D()
        actor.GetProperty().SetColor(*self._Config['foreground'])

        actor.SetMapper(mapper)
        if "FreeType" in mapper.GetClassName():
            actor.SetPosition(x + old_div(width, 2) - x0,
                              y + old_div(height, 2) - y0)
        else:  # not a FreeType font, needs position correction
            actor.SetPosition(x + old_div(width, 2) - x0 + 1,
                              y + old_div(height, 2) - y0 + 1)

        self._Actors.append(actor)
        if self._Renderer:
            self._Renderer.AddActor2D(actor)
开发者ID:parallaxinnovations,项目名称:vtkAtamai,代码行数:97,代码来源:Button.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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