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

« back to all changes in this revision

Viewing changes to enthought/chaco/contour_line_plot.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-04-06 19:03:54 UTC
  • mfrom: (7.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110406190354-rwd55l2ezjecfo41
Tags: 3.4.0-2
d/rules: fix pyshared directory path (Closes: #621116)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
""" Defines the ContourLinePlot class.
2
2
"""
3
3
 
 
4
from __future__ import with_statement
 
5
 
4
6
# Major library imports
5
7
from numpy import array, linspace, meshgrid, transpose
6
8
 
7
9
# Enthought library imports
8
10
from enthought.enable.api import LineStyle
 
11
from enthought.kiva import constants
9
12
from enthought.traits.api import Bool, Dict, Float, List, Str, Trait
10
13
 
11
14
# Local relative imports
12
15
from base_contour_plot import BaseContourPlot
13
 
from color_mapper import ColorMapper
14
16
from contour.contour import Cntr
15
17
 
16
18
 
84
86
        if not self._colors_cache_valid:
85
87
            self._update_colors()
86
88
 
87
 
        gc.save_state()
88
 
        gc.set_antialias(True)
89
 
        gc.clip_to_rect(self.x, self.y, self.width, self.height)
90
 
        gc.set_alpha(self.alpha)
91
 
        
92
 
        for i in range(len(self._levels)):
93
 
            gc.set_stroke_color(self._colors[i])
94
 
            gc.set_line_width(self._widths[i])
95
 
            gc.set_line_dash(self._styles[i])
96
 
            for trace in self._cached_contours[self._levels[i]]:
97
 
                if self.orientation == "h":
98
 
                    strace = self.index_mapper.map_screen(trace)
99
 
                else:
100
 
                    strace = array(self.index_mapper.map_screen(trace))[:,::-1]
101
 
                gc.begin_path()
102
 
                gc.lines(strace)
103
 
                gc.stroke_path()
104
 
 
105
 
        gc.restore_state()
 
89
        with gc:
 
90
            gc.set_antialias(True)
 
91
            gc.clip_to_rect(self.x, self.y, self.width, self.height)
 
92
            gc.set_alpha(self.alpha)
 
93
            gc.set_line_join(constants.JOIN_BEVEL)
 
94
            gc.set_line_cap(constants.CAP_ROUND)
 
95
            
 
96
            for i in range(len(self._levels)):
 
97
                gc.set_stroke_color(self._colors[i])
 
98
                gc.set_line_width(self._widths[i])
 
99
                gc.set_line_dash(self._styles[i])
 
100
                for trace in self._cached_contours[self._levels[i]]:
 
101
                    if self.orientation == "h":
 
102
                        strace = self.index_mapper.map_screen(trace)
 
103
                    else:
 
104
                        strace = array(self.index_mapper.map_screen(trace))[:,::-1]
 
105
                    gc.begin_path()
 
106
                    gc.lines(strace)
 
107
                    gc.stroke_path()
106
108
 
107
109
    def _update_contours(self):
108
110
        """ Updates the cache of contour lines """