~ubuntu-branches/ubuntu/utopic/python-chaco/utopic

« back to all changes in this revision

Viewing changes to chaco/image_plot.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2014-06-01 17:04:08 UTC
  • mfrom: (7.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20140601170408-m86xvdjd83a4qon0
Tags: 4.4.1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
 - Let the binary-predeb target work on the usr/lib/python* directory
   as we don't have usr/share/pyshared anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# (C) Copyright 2013 Enthought, Inc., Austin, TX
 
3
# All right reserved.
 
4
#
 
5
# This file is open source software distributed according to the terms in
 
6
# LICENSE.txt
 
7
#
 
8
 
1
9
""" Defines the ImagePlot class.
2
10
"""
3
11
 
28
36
 
29
37
    # The interpolation method to use when rendering an image onto the GC.
30
38
    interpolation = Enum("nearest", "bilinear", "bicubic")
31
 
 
 
39
    
32
40
    #------------------------------------------------------------------------
33
41
    # Private traits
34
42
    #------------------------------------------------------------------------
115
123
    # Private methods
116
124
    #------------------------------------------------------------------------
117
125
 
118
 
    def _compute_cached_image(self, data=None):
 
126
    def _compute_cached_image(self, data=None, mapper=None):
119
127
        """ Computes the correct sub-image coordinates and renders an image
120
128
        into self._cached_image.
121
129
 
122
130
        The parameter *data* is for subclasses that might not store an RGB(A)
123
131
        image as the value, but need to compute one to display (colormaps, etc.).
 
132
        
 
133
        The parameter *mapper* is also for subclasses that might not store an
 
134
        RGB(A) image as their value, and gives an opportunity to produce the
 
135
        values only for the visible region, rather than for the whole plot,
 
136
        at the expense of more frequent computation.
124
137
        """
125
138
 
126
 
        if data == None:
 
139
        if data is None:
127
140
            data = self.value.data
128
141
 
129
142
        (lpt, upt) = self.index.get_bounds()
159
172
 
160
173
            # Since data is row-major, j1 and j2 go first
161
174
            data = data[j1:j2, i1:i2]
 
175
        
 
176
        if mapper is not None:
 
177
            data = mapper(data)
162
178
 
163
179
        # Furthermore, the data presented to the GraphicsContextArray needs to
164
180
        # be contiguous.  If it is not, we need to make a copy.
173
189
            raise RuntimeError, "Unknown colormap depth value: %i" \
174
190
                                % data.value_depth
175
191
 
 
192
 
176
193
        self._cached_image = GraphicsContextArray(data, pix_format=kiva_depth)
177
194
        if gc_rect is not None:
178
195
            self._cached_dest_rect = gc_rect
310
327
    def _value_data_changed_fired(self):
311
328
        self._image_cache_valid = False
312
329
        self.request_redraw()
 
330