/[escript]/trunk/pyvisi/py_src/text.py
ViewVC logotype

Contents of /trunk/pyvisi/py_src/text.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1197 - (show annotations)
Mon Jun 18 02:08:34 2007 UTC (13 years, 10 months ago) by jongui
File MIME type: text/x-python
File size: 3006 byte(s)
Update the way movies are generated. Please refer to the examples. 

The user can now either specify the image range(first and last images inclusive):
mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
        first_image = IMAGE_NAME + "000938.jpg",
		last_image = IMAGE_NAME + "000948.jpg")
mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))

or the user can specify a list of images:

lst = ['image1.jpg', 'image5.jpg', 'image7.jpg]
mov.imageList(input_directory = PYVISI_EXAMPLE_IMAGES_PATH, image_list = lst)
mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))


1 """
2 @var __author__: name of author
3 @var __copyright__: copyrights
4 @var __license__: licence agreement
5 @var __url__: url entry point on documentation
6 @var __version__: version
7 @var __date__: date of the version
8 """
9
10 __author__="John Ngui, john.ngui@uq.edu.au"
11 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
12 http://www.access.edu.au
13 Primary Business: Queensland, Australia"""
14 __license__="""Licensed under the Open Software License version 3.0
15 http://www.opensource.org/licenses/osl-3.0.php"""
16 __url__="http://www.iservo.edu.au/esys"
17 __version__="$Revision$"
18 __date__="$Date$"
19
20
21 import vtk
22 from actor import Actor2D
23 from constant import Viewport, Color
24
25 # NOTE: Actor2D was inherited to allow access to its public methods from
26 # the driver.
27 class Text2D(Actor2D):
28 """
29 Class that defines a 2D text actor. A two-dimensional text is used to
30 annotate the rendered object (i.e. inserting titles, authors and labels).
31 """
32
33 def __init__(self, scene, text, viewport = Viewport.SOUTH_WEST):
34 """
35 Initialise the 2D text actor.
36
37 @type scene: L{Scene <scene.Scene>} object
38 @param scene: Scene in which objects are to be rendered on
39 @type text: String
40 @param text: 2D text to be displayed
41 @type viewport: L{Viewport <constant.Viewport>} constant
42 @param viewport: Viewport in which objects are to be rendered on
43 """
44
45 self.__text = text
46 self.__viewport = viewport
47 self._vtk_actor2D = vtk.vtkTextActor()
48
49 self.__setupText2D(scene)
50
51 def __setupText2D(self, scene):
52 """
53 Setup the 2D text.
54
55 @type scene: L{Scene <scene.Scene>} object
56 @param scene: Scene in which objects are to be rendered on
57 """
58
59 self.__setInput()
60 self.setColor(Color.BLACK)
61 # Add the 2D text to the appropriate renderer.
62 scene._addActor2D(self.__viewport, self._vtk_actor2D)
63
64 def __setInput(self):
65 """
66 Set the input for the 2D text.
67 """
68
69 self._vtk_actor2D.SetInput(self.__text)
70
71 def setFontSize(self, size):
72 """
73 Set the 2D text size.
74
75 @type size: Number
76 @param size: Size of the 2D text
77 """
78
79 self._vtk_actor2D.GetTextProperty().SetFontSize(size)
80
81 def setFontToTimes(self):
82 """
83 Set the 2D text font type to Times New Roman.
84 """
85
86 self._vtk_actor2D.GetTextProperty().SetFontFamilyToTimes()
87
88 def setFontToArial(self):
89 """
90 Set the 2D text font type to Arial.
91 """
92
93 self._vtk_actor2D.GetTextProperty().SetFontFamilyToArial()
94
95 def setFontToCourier(self):
96 """
97 Set the 2D text front type to Courier.
98 """
99
100 self._vtk_actor2D.GetTextProperty().SetFontFamilyToCourier()
101
102 def boldOn(self):
103 """
104 Bold the 2D text.
105 """
106
107 self._vtk_actor2D.GetTextProperty().BoldOn()
108
109 def shadowOn(self):
110 """
111 Apply shadow onto the 2D text to ease visibility.
112 """
113
114 self._vtk_actor2D.GetTextProperty().ShadowOn()
115
116 def setColor(self, color):
117 """
118 Set the color of the 2D text.
119
120 @type color: L{Color <constant.Color>} constant
121 @param color: 2D text color
122 """
123
124 self._vtk_actor2D.GetTextProperty().SetColor(color)
125

  ViewVC Help
Powered by ViewVC 1.1.26