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

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

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

revision 1147 by ksteube, Wed May 16 06:39:11 2007 UTC revision 1148 by jongui, Wed May 16 22:45:33 2007 UTC
# Line 6  import vtk Line 6  import vtk
6  from mapper import DataSetMapper  from mapper import DataSetMapper
7  from lookuptable import LookupTable  from lookuptable import LookupTable
8  from actor import Actor3D  from actor import Actor3D
9  from constant import Viewport, Color, Lut, WarpMode, VizType, ColorMode  from constant import Viewport, Color, Lut, WarpMode, ColorMode
10  from warp import Warp  from warp import Warp
11  from outline import Outline  from outline import Outline
12  from transform import Transform  from transform import Transform
# Line 54  class Carpet(DataSetMapper, Actor3D, War Line 54  class Carpet(DataSetMapper, Actor3D, War
54          @param outline: Places an outline around the domain surface          @param outline: Places an outline around the domain surface
55          """          """
56    
57          # NOTE: Actor3D is inherited and there are two instances declared here.          self.__scene = scene
58          # As a result, when methods from Actor3D is invoked from the driver,          self.__data_collector = data_collector
59          # only the methods associated with the latest instance (which in this          self.__viewport = viewport
60          # case is the Actor3D for the carpet) can be executed. Actor3D          self.__warp_mode = warp_mode
61          # methods associated with Outline cannot be invoked from the driver.          self.__lut = lut
62          # They can only be called within here, which is why Outline must          self.__cell_to_point = cell_to_point
63          # be place before the carpet as there is unlikely to be any changes          self.__outline = outline
64          # made to the Outline's Actor3D.          
65            # Keeps track whether Carpet has been modified.
66            self.__modified = True
67            Transform.__init__(self)    
68            Plane.__init__(self)
69            Cutter.__init__(self)
70            Warp.__init__(self, self.__warp_mode)
71            DataSetMapper.__init__(self)
72            Actor3D.__init__(self)
73            scene._addVisualizationModules(self)
74    
75          # ----- Outline -----          # ----- Outline -----
76    
77          if(outline == True):          # NOTE: Changes cannot be made to the Outline's properties from the
78              outline = Outline(data_collector._getOutput())          # driver.
79              DataSetMapper.__init__(self, outline._getOutput())          if(self.__outline == True):
80                outline = Outline(self.__data_collector._getDataCollectorOutput())
81                mapper = DataSetMapper()
82                mapper._setupDataSetMapper(outline._getOutlineOutput())
83    
84              Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))              actor3D = Actor3D()
85                actor3D._setupActor3D(mapper._getDataSetMapper())
86              # Default outline color is black.              # Default outline color is black.
87              Actor3D.setColor(self, Color.BLACK)              actor3D.setColor(Color.BLACK)
88    
89              # Default line width is 1.              # Default line width is 1.
90              Actor3D._setLineWidth(self, 1)              actor3D._setLineWidth(1)
91              scene._addActor3D(viewport, Actor3D._getActor3D(self))              self.__scene._addActor3D(self.__viewport, actor3D._getActor3D())
92    
93          # ----- Carpet -----          # ----- Carpet -----
94    
95          # NOTE: Lookup table color mapping (color or grey scale) MUST be set          # NOTE: Lookup table color mapping (color or grey scale) MUST be set
96          # before DataSetMapper. If it is done after DataSetMapper, no effect          # before DataSetMapper. If it is done after DataSetMapper, no effect
97          # will take place.          # will take place.
98          if(lut == Lut.COLOR): # Colored lookup table.          if(self.__lut == Lut.COLOR): # Colored lookup table.
99              lookup_table = LookupTable()              lookup_table = LookupTable()
100              lookup_table._setTableValue()              lookup_table._setTableValue()
101          elif(lut == Lut.GREY_SCALE): # Grey scaled lookup table.          elif(self.__lut == Lut.GREY_SCALE): # Grey scaled lookup table.
102              lookup_table = LookupTable()              lookup_table = LookupTable()
103              lookup_table._setLookupTableToGreyScale()              lookup_table._setLookupTableToGreyScale()
104    
105          Transform.__init__(self)          self._setupPlane(self._getTransform())
         Plane.__init__(self, Transform._getTransform(self))  
106    
107          if(cell_to_point == True): # Converts cell data to point data.          if(self.__cell_to_point == True): # Converts cell data to point data.
108              c2p = CellDataToPointData(data_collector._getOutput())              c2p = CellDataToPointData(\
109              Cutter.__init__(self, c2p._getOutput(), Plane._getPlane(self))                        self.__data_collector._getDataCollectorOutput())
110          elif(cell_to_point == False): # No conversion happens.                self._setupCutter(c2p._getCellToPointOutput(), self._getPlane())    
111              Cutter.__init__(self, data_collector._getOutput(),          elif(self.__cell_to_point == False): # No conversion happens.  
112                      Plane._getPlane(self))                self._setupCutter(self.__data_collector._getDataCollectorOutput(),
113                        self._getPlane())  
114          Warp.__init__(self, Cutter._getOutput(self), warp_mode)  
115                        self._setupWarp(self._getCutterOutput())
116          DataSetMapper.__init__(self, Warp._getOutput(self),          self._setupDataSetMapper(self._getWarpOutput(),
117                  lookup_table._getLookupTable())                  lookup_table._getLookupTable())
         DataSetMapper._setScalarRange(self, data_collector._getScalarRange())  
118    
119          data_collector._paramForUpdatingMultipleSources(VizType.CARPET,          self._setupActor3D(self._getDataSetMapper())
120                  ColorMode.SCALAR, DataSetMapper._getDataSetMapper(self))          self.__scene._addActor3D(self.__viewport, self._getActor3D())
121    
122        def _isModified(self):  
123            """
124            Return whether the Carpet or DataCollector has been modified.
125    
126            @rtype: Boolean
127            @return: True or False
128            """
129    
130            return self.__modified or self.__data_collector._isModified()
131    
132        def _render(self):
133            """
134            Render the carpet.
135            """
136    
137            if (self._isModified() == True):
138                if(self.__data_collector._isScalarSet() == True):
139                    self.__data_collector._setActiveScalar()
140                self._setScalarRange(self.__data_collector._getScalarRange())
141                self.__modified = False
142    
         Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self))  
         scene._addActor3D(viewport, Actor3D._getActor3D(self))  
143    

Legend:
Removed from v.1147  
changed lines
  Added in v.1148

  ViewVC Help
Powered by ViewVC 1.1.26