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

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

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

revision 838 by jongui, Tue Sep 5 07:23:50 2006 UTC revision 839 by jongui, Wed Sep 6 04:53:50 2006 UTC
# Line 1  Line 1 
1  """  """
2  Class that defines the mapping of colors.  @var RED: Constant representing red
3    @type RED: RGB color
4    @var GREEN: Constant representing green
5    @type GREEN: RGB color
6    @var BLUE: Constant representing blue
7    @type BLUE: RGB color
8    @var BLACK: Constant representing black
9    @type BLACK: RBG color
10    @var WHITE: Constant representing white
11    @type WHITE: RGB color
12    @var YELLOW: Constant representing yellow
13    @type YELLOW: RGB color
14    @var PINK: Constant represnting pink
15    @type PINK: RGB color
16    @var ORANGE: Constant representing orange
17    @type ORANGE: RGB color
18    @var PURPLE: Constant representing purple
19    @type PURPLE: RGB color
20    @var GREY: Constant representing grey
21    @type GREY: RGB color
22    @var BROWN: Constant representing brown
23    @type BROWN: RGB color
24    
25    @author: John Ngui
26    @author: Lutz Gross
27  """  """
28    
29  class ColorMap:  class ColorMap:
30      """      """
31      @author: John Ngui      Class that defines the mapping of colors.
     @author: Lutz Gross  
32      """      """
33    
34      def __init__(self, color_name):      def __init__(self, color_name):
# Line 60  class ColorMap: Line 83  class ColorMap:
83          Return the blue(B) value from the RGB.          Return the blue(B) value from the RGB.
84    
85          @rtype: Number          @rtype: Number
86          @return Blue(B) value from the RGB          @return: Blue(B) value from the RGB
87          """          """
88    
89          return self.colorMap[self.color_name][2]          return self.colorMap[self.color_name][2]
# Line 87  ORANGE = ColorMap("Orange") Line 110  ORANGE = ColorMap("Orange")
110  PURPLE = ColorMap("Purple")  PURPLE = ColorMap("Purple")
111  GREY = ColorMap("Grey")  GREY = ColorMap("Grey")
112  BROWN = ColorMap("Brown")  BROWN = ColorMap("Brown")
113        
114    import vtk  
115    
116    class Lut:
117        """
118        Class that provides the functions to create a map spectrum.
119        """
120    
121        def __init__(self):
122            self.vtk_lut = vtk.vtkLookupTable()
123                    
124        def setHue(self, lower_range, upper_range):
125            """
126            Set the upper and lower hue(color) range.
127    
128            @type lower_range: Number
129            @param lower_range: Lower range of the hue
130            @type upper_range: Number
131            @param upper_range: Upper range of the hue
132            """
133    
134            self.vtk_lut.SetHueRange(lower_range, upper_range)
135    
136        def setSaturation(self, lower_range, upper_range):
137            """
138            Set the upper and lower saturation(vibrancy) range.
139        
140            @type lower_range: Number
141            @param lower_range: Lower range of the saturation
142            @type upper_range: Number
143            @param upper_range: Higher range of the saturation
144            """
145    
146            self.vtk_lut.SetSaturationRange(lower_range, upper_range)
147    
148        def setValue(self, lower_range, upper_range):
149            """
150            Set the upper and lower value(brightness) range.
151    
152            @type lower_range: Number
153            @param lower_range: Lower range of the value
154            @type upper_range: Number
155            @param upper_range: Upper range of the value
156            """
157        
158            self.vtk_lut.SetValueRange(lower_range, upper_range)
159            
160        def getLut(self):
161            """
162            Return the VTK lookup table.
163    
164            @rtype: vtkLookupTable
165            @return: VTK Lookup table
166            """
167    
168            return self.vtk_lut
169    
170    class BlueToRed(Lut):
171        """
172        Class that creates a map with spectrum from blue to red.
173        """
174    
175        def __init__(self):
176            Lut.__init__(self)
177            self.setHue(0.667, 0.0)
178    
179    class RedToBlue(Lut):
180        """
181        Class that creates a map with spectrum from red to blue.
182        """
183    
184        def __init__(self):
185            Lut.__init__(self)
186            self.setHue(0.0, 0.667)
187    
188    
189    
 class BlueRed:  
    """  
    color map with spectrum from blue to red  
    """  
    pass  
   
 class RedBlue:  
    """  
    color map with spectrum from red to blue  
    """  
    pass  

Legend:
Removed from v.838  
changed lines
  Added in v.839

  ViewVC Help
Powered by ViewVC 1.1.26