zoukankan      html  css  js  c++  java
  • vtk类之vtkTextSource:显示一个文本的poly data

    vtkTextSource  转换一个字符串成poly data。

    基本方法:

    SetText('Hello, welcome')  设置显示的文本内容
    SetForegroundColor(0.1, 1.0, 0.5) 设置文本的颜色
    etBackgroundColor(1.0, 0, 1.0) 设置文本的背景色

    例子:

    #-*- coding: UTF-8 -*-
    #-------------------------------------------------------------------------------
    # Name:        模块2
    # Purpose:
    #
    # Author:      ankier
    #
    # Created:     12-12-2012
    # Copyright:   (c) Ankier 2012
    # Licence:     <your licence>
    #-------------------------------------------------------------------------------
    
    from ActorFactory import ActorFactory
    
    from vtk import *
    ## @detal 显示文本的actory factory
    class TextActorFactory(ActorFactory):
        def __init__(self):
            ActorFactory.__init__(self)        
            self.__TextSource = vtkTextSource()        
            
        def _MakeActors(self):
            self.__TextSource.SetText('Hello, welcome')      
            self.__TextSource.SetForegroundColor(0.1, 1.0, 0.5)
            self.__TextSource.SetBackgroundColor(1.0, 0, 1.0)
            
            
            polyDataMapper = vtkPolyDataMapper()
            polyDataMapper.SetInput(self.__TextSource.GetOutput())
            
            actor = self._NewActor()
            actor.SetMapper(polyDataMapper)
            actor.GetProperty().SetColor((1.0, 0.7, 0.2))
            actor.SetPosition(-27.0, 0, 0)
            
            return [actor]
        
        def __del__(self):
            del self.__TextSource

    运行效果:

  • 相关阅读:
    IO库 8.5
    IO库 8.4
    标准模板库——IO库
    IO库 8.3
    IO库 8.2
    IO库 8.1
    CF 599D Spongebob and Squares(数学)
    Django入门学习(一)
    hdu 5733
    uva 11210
  • 原文地址:https://www.cnblogs.com/ankier/p/2813446.html
Copyright © 2011-2022 走看看