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
运行效果: