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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 848 by jongui, Thu Sep 14 22:30:00 2006 UTC revision 849 by jongui, Fri Sep 15 07:11:55 2006 UTC
# Line 4  Line 4 
4  """  """
5    
6  import vtk  import vtk
7  from common import *  from common import Common
8  from colormap import ColorMap  from constants import *
9    from style import Style
10    
11  class DataCollector(Common):  class DataCollector(Common):
12      """      """
# Line 22  class DataCollector(Common): Line 23  class DataCollector(Common):
23          @param outline: Determines the outline for the rendered object          @param outline: Determines the outline for the rendered object
24          """          """
25    
26          self.scene = scene            Common.__init__(self, scene)
27          self.outline = outline          self.outline = outline
28          self.cube_axes = cube_axes          self.cube_axes = cube_axes
29          self.file_name = None          self.vtk_xml_reader = vtk.vtkXMLUnstructuredGridReader()
         self.vtk_outline = None  
         self.vtk_xml_reader = None  
         self.vtk_xml_reader_output = None  
30    
31      def setFileName(self, file_name):      def setFileName(self, file_name):
32          """          """
# Line 38  class DataCollector(Common): Line 36  class DataCollector(Common):
36          @param file_name: Name of the file to be read.          @param file_name: Name of the file to be read.
37          """          """
38    
39          self.file_name = file_name          self.vtk_xml_reader.SetFileName(file_name)
         self.vtk_xml_reader = vtk.vtkXMLUnstructuredGridReader()  
         self.vtk_xml_reader.SetFileName(self.file_name)  
40    
41          if(self.outline == True):          if(self.outline == True):
42              self.setOutline()              self.setOutline()
             Common.setMapper(self, "self.vtk_outline.GetOutput()")  
             Common.setActor(self)  
             Common.addActor(self)    
             Common.setColor(self, 0, 0, 0) # Default outline is black  
43    
44          if(self.cube_axes == True):          if(self.cube_axes == True):
45              self.setCubeAxes()              self.setCubeAxes()
       
     def getReader(self):  
         """  
         Return the file reader.  
   
         @rtype: vtkXMLUnstructuredGridReader  
         @return: VTK XML unstructured grid reader  
         """  
   
         return self.vtk_xml_reader  
46    
47      def setOutline(self):      def setOutline(self):
48          """          """
# Line 69  class DataCollector(Common): Line 51  class DataCollector(Common):
51    
52          self.vtk_outline = vtk.vtkOutlineFilter()          self.vtk_outline = vtk.vtkOutlineFilter()
53          self.vtk_outline.SetInput(self.vtk_xml_reader.GetOutput())            self.vtk_outline.SetInput(self.vtk_xml_reader.GetOutput())  
54        
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    
61      def setCubeAxes(self):      def setCubeAxes(self):
62          vtk_cube_axes = vtk.vtkCubeAxesActor2D()          vtk_cube_axes = vtk.vtkCubeAxesActor2D()
63          vtk_cube_axes.SetInput(self.vtk_xml_reader.GetOutput())          vtk_cube_axes.SetInput(self.getReader().GetOutput())
64          vtk_cube_axes.SetCamera(self.scene.getRenderer().GetActiveCamera())          vtk_cube_axes.SetCamera(self.scene.getRenderer().GetActiveCamera())
65          vtk_cube_axes.SetLabelFormat("%6.4g")          vtk_cube_axes.SetLabelFormat("%6.4g")
66          vtk_cube_axes.SetFlyModeToClosestTriad()          vtk_cube_axes.SetFlyModeToOuterEdges()
67          vtk_cube_axes.SetFontFactor(0.9)          vtk_cube_axes.SetFontFactor(0.9)
68    
69            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          self.scene.getRenderer().AddActor(vtk_cube_axes)          self.scene.getRenderer().AddActor(vtk_cube_axes)
               
77    
78        def getReader(self):
79            """
80            Return the file reader.
81    
82            @rtype: vtkXMLUnstructuredGridReader
83            @return: VTK XML unstructured grid reader
84            """
85    
86            return self.vtk_xml_reader
87    

Legend:
Removed from v.848  
changed lines
  Added in v.849

  ViewVC Help
Powered by ViewVC 1.1.26