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

Annotation of /trunk/pyvisi/py_src/datacollector.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 860 - (hide annotations)
Thu Sep 28 08:17:29 2006 UTC (14 years, 3 months ago) by jongui
File MIME type: text/x-python
File size: 2496 byte(s)
- added sample drivers on how to use all of the currently available modules.
- completed the epydocs for all the currently available modules.
- added the rotation feature for camera and plane cutting.


1 gross 792 """
2 jongui 839 @author: John Ngui
3     @author: Lutz Gross
4 gross 792 """
5    
6 jongui 822 import vtk
7 jongui 849 from common import Common
8     from constants import *
9     from style import Style
10 gross 792
11 jongui 828 class DataCollector(Common):
12 jongui 835 """
13 jongui 860 Class that deals with data for visualization.
14 jongui 835 """
15 gross 792
16 jongui 847 def __init__(self, scene, outline = True, cube_axes = True):
17 jongui 835 """
18 jongui 845 @type scene: L{Scene <scene.Scene>} object
19 jongui 839 @param scene: Scene in which components are to be added to
20 jongui 835 @type outline: Boolean (I{True or False})
21 jongui 860 @param outline: Places or removes an outline for the rendered object
22     @type cube_axes: Boolean ({True or False})
23     @param cube_axes: Places or removes a cube axes for the rendered object
24 jongui 835 """
25    
26 jongui 849 Common.__init__(self, scene)
27 jongui 847 self.outline = outline
28     self.cube_axes = cube_axes
29 jongui 849 self.vtk_xml_reader = vtk.vtkXMLUnstructuredGridReader()
30 jongui 822
31 jongui 845 def setFileName(self, file_name):
32 jongui 835 """
33 jongui 860 Set up the file reader and file name from which data is to be read.
34 jongui 835 @type file_name: String
35     @param file_name: Name of the file to be read.
36     """
37    
38 jongui 849 self.vtk_xml_reader.SetFileName(file_name)
39 jongui 822
40 jongui 860 # Set up the outline and cube axes only if true.
41 jongui 827 if(self.outline == True):
42 jongui 828 self.setOutline()
43 jongui 847 if(self.cube_axes == True):
44     self.setCubeAxes()
45 jongui 835
46 jongui 828 def setOutline(self):
47 jongui 835 """
48 jongui 860 Set up the outline for the rendered object.
49 jongui 835 """
50    
51 jongui 828 self.vtk_outline = vtk.vtkOutlineFilter()
52     self.vtk_outline.SetInput(self.vtk_xml_reader.GetOutput())
53 jongui 849
54     Common.setMapperInput(self, self.vtk_outline.GetOutput())
55     Common.setActorInput(self)
56     Common.addActor(self)
57 jongui 860 # Default outline is black.
58 jongui 849 Common.setActorColor(self, BLACK)
59 jongui 822
60 jongui 847 def setCubeAxes(self):
61 jongui 860 """
62     Set up the cube axes for the rendered object.
63     """
64    
65 jongui 847 vtk_cube_axes = vtk.vtkCubeAxesActor2D()
66 jongui 849 vtk_cube_axes.SetInput(self.getReader().GetOutput())
67 jongui 847 vtk_cube_axes.SetCamera(self.scene.getRenderer().GetActiveCamera())
68 jongui 860 # Formats the labes on the axes.
69 jongui 847 vtk_cube_axes.SetLabelFormat("%6.4g")
70 jongui 860 # Use the outer edges of the bounding box to draw the axes.
71 jongui 849 vtk_cube_axes.SetFlyModeToOuterEdges()
72 jongui 848 vtk_cube_axes.SetFontFactor(0.9)
73 jongui 827
74 jongui 860 # Style for the axes title and label.
75 jongui 849 style = Style()
76     style.setColor(BLACK)
77 jongui 860 style.shadowOn()
78 jongui 849
79     vtk_cube_axes.SetAxisTitleTextProperty(style.getStyle())
80     vtk_cube_axes.SetAxisLabelTextProperty(style.getStyle())
81    
82 jongui 847 self.scene.getRenderer().AddActor(vtk_cube_axes)
83    
84 jongui 849 def getReader(self):
85     """
86     Return the file reader.
87 jongui 847
88 jongui 849 @rtype: vtkXMLUnstructuredGridReader
89 jongui 860 @return: VTK XML unstructured grid reader that is used to read files.
90 jongui 849 """
91 jongui 847
92 jongui 849 return self.vtk_xml_reader
93 jongui 847

  ViewVC Help
Powered by ViewVC 1.1.26