/[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 849 - (hide annotations)
Fri Sep 15 07:11:55 2006 UTC (14 years, 5 months ago) by jongui
File MIME type: text/x-python
File size: 2124 byte(s)
Optimized codes and modularized functions to make it more scalable. Partially 
integrated carpet into the existing modules.  

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 839 Class that deals with data for the visualization.
14 jongui 835 """
15 gross 792
16 jongui 847 def __init__(self, scene, outline = True, cube_axes = True):
17 jongui 835 """
18     Initialize all the instance variables.
19    
20 jongui 845 @type scene: L{Scene <scene.Scene>} object
21 jongui 839 @param scene: Scene in which components are to be added to
22 jongui 835 @type outline: Boolean (I{True or False})
23     @param outline: Determines the outline for the rendered object
24     """
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     Set up the file reader and set the file name.
34    
35     @type file_name: String
36     @param file_name: Name of the file to be read.
37     """
38    
39 jongui 849 self.vtk_xml_reader.SetFileName(file_name)
40 jongui 822
41 jongui 827 if(self.outline == True):
42 jongui 828 self.setOutline()
43 jongui 847
44     if(self.cube_axes == True):
45     self.setCubeAxes()
46 jongui 835
47 jongui 828 def setOutline(self):
48 jongui 835 """
49     Set the outline for the rendered object.
50     """
51    
52 jongui 828 self.vtk_outline = vtk.vtkOutlineFilter()
53     self.vtk_outline.SetInput(self.vtk_xml_reader.GetOutput())
54 jongui 849
55     Common.setMapperInput(self, self.vtk_outline.GetOutput())
56     Common.setActorInput(self)
57     Common.addActor(self)
58     # Default outline is black color.
59     Common.setActorColor(self, BLACK)
60 jongui 822
61 jongui 847 def setCubeAxes(self):
62     vtk_cube_axes = vtk.vtkCubeAxesActor2D()
63 jongui 849 vtk_cube_axes.SetInput(self.getReader().GetOutput())
64 jongui 847 vtk_cube_axes.SetCamera(self.scene.getRenderer().GetActiveCamera())
65     vtk_cube_axes.SetLabelFormat("%6.4g")
66 jongui 849 vtk_cube_axes.SetFlyModeToOuterEdges()
67 jongui 848 vtk_cube_axes.SetFontFactor(0.9)
68 jongui 827
69 jongui 849 style = Style()
70     style.setColor(BLACK)
71     style.setShadow()
72    
73     vtk_cube_axes.SetAxisTitleTextProperty(style.getStyle())
74     vtk_cube_axes.SetAxisLabelTextProperty(style.getStyle())
75    
76 jongui 847 self.scene.getRenderer().AddActor(vtk_cube_axes)
77    
78 jongui 849 def getReader(self):
79     """
80     Return the file reader.
81 jongui 847
82 jongui 849 @rtype: vtkXMLUnstructuredGridReader
83     @return: VTK XML unstructured grid reader
84     """
85 jongui 847
86 jongui 849 return self.vtk_xml_reader
87 jongui 847

  ViewVC Help
Powered by ViewVC 1.1.26