/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/renderer.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/renderer.py

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

revision 144 by bh, Tue May 7 14:54:02 2002 UTC revision 362 by jonathan, Mon Jan 27 11:39:03 2003 UTC
# Line 63  class MapRenderer: Line 63  class MapRenderer:
63          scale = self.scale          scale = self.scale
64          offx, offy = self.offset          offx, offy = self.offset
65    
         fill = layer.fill  
         if fill is None:  
             brush = wxTRANSPARENT_BRUSH  
         else:  
             color = wxColour(fill.red * 255,  
                              fill.green * 255,  
                              fill.blue * 255)  
             brush = wxBrush(color, wxSOLID)  
         stroke = layer.stroke  
         stroke_width = layer.stroke_width  
         if stroke is None:  
             pen = wxTRANSPARENT_PEN  
         else:  
             color = wxColour(stroke.red * 255,  
                              stroke.green * 255,  
                              stroke.blue * 255)  
             pen = wxPen(color, stroke_width, wxSOLID)  
   
66          map_proj = self.map.projection          map_proj = self.map.projection
67          layer_proj = layer.projection          layer_proj = layer.projection
68    
69          shapetype = layer.ShapeType()          shapetype = layer.ShapeType()
70    
71          if shapetype == SHAPETYPE_POLYGON:          brush = wxTRANSPARENT_BRUSH
72              for i in self.layer_ids(layer):          pen   = wxTRANSPARENT_PEN
73    
74            old_prop = None
75            for i in self.layer_ids(layer):
76                value = None
77                shape = layer.Shape(i)
78                field = layer.classification.field
79    
80                if field is not None:
81                    record = layer.table.read_record(i)
82                    if record is not None:
83                        value = record[field]
84    
85                #
86                # if the above statements fail 'value' should
87                # be null, at which point this call will
88                # at least retreive the NullData
89                #
90                prop = layer.classification.getProperties(value)
91    
92                if prop != old_prop:
93                    old_prop = prop
94    
95                    if shapetype == SHAPETYPE_ARC:
96                        fill = None
97                    else:
98                        fill = prop['fill']
99        
100                    if fill is None:
101                        brush = wxTRANSPARENT_BRUSH
102                    else:
103                        color = wxColour(fill.red * 255,
104                                         fill.green * 255,
105                                         fill.blue * 255)
106                        brush = wxBrush(color, wxSOLID)
107        
108                    stroke = prop['stroke']
109                    stroke_width = prop['stroke_width']
110                    if stroke is None:
111                        pen = wxTRANSPARENT_PEN
112                    else:
113                        color = wxColour(stroke.red * 255,
114                                         stroke.green * 255,
115                                         stroke.blue * 255)
116                        pen = wxPen(color, stroke_width, wxSOLID)
117        
118                if shapetype == SHAPETYPE_POINT:
119                    self.dc.SetBrush(brush)
120                    self.dc.SetPen(pen)
121                    self.draw_point_shape(layer, i)
122                else:
123                  self.draw_polygon_shape(layer, i, pen, brush)                  self.draw_polygon_shape(layer, i, pen, brush)
         elif shapetype == SHAPETYPE_ARC:  
             for i in self.layer_ids(layer):  
                 self.draw_polygon_shape(layer, i, pen, None)  
         else:  
             self.dc.SetBrush(brush)  
             self.dc.SetPen(pen)  
             if shapetype == SHAPETYPE_ARC:  
                 f = self.draw_arc_shape  
             elif shapetype == SHAPETYPE_POINT:  
                 f = self.draw_point_shape  
             for i in self.layer_ids(layer):  
                 f(layer, i)  
124    
125      def layer_ids(self, layer):      def layer_ids(self, layer):
126          """Return the shape ids of the given layer that have to be drawn.          """Return the shape ids of the given layer that have to be drawn.
# Line 197  class ScreenRenderer(MapRenderer): Line 217  class ScreenRenderer(MapRenderer):
217      def RenderMap(self, map, region, selected_layer, selected_shape):      def RenderMap(self, map, region, selected_layer, selected_shape):
218          """Render the map.          """Render the map.
219    
220          Only the given region (a wxRect in window coordinates) needs to          Only the given region (a tuple in window coordinates as returned
221          be redrawn. Highlight the shape with id selected_shape in the          by a wxrect's asTuple method) needs to be redrawn. Highlight the
222          selected_layer.          shape with id selected_shape in the selected_layer.
223          """          """
224          self.update_region = region          self.update_region = region
225          self.selected_layer = selected_layer          self.selected_layer = selected_layer
# Line 216  class ScreenRenderer(MapRenderer): Line 236  class ScreenRenderer(MapRenderer):
236              index = self.selected_shape              index = self.selected_shape
237              if shapetype == SHAPETYPE_POLYGON:              if shapetype == SHAPETYPE_POLYGON:
238                  self.draw_polygon_shape(layer, index, pen, brush)                  self.draw_polygon_shape(layer, index, pen, brush)
239                elif shapetype == SHAPETYPE_ARC:
240                    self.draw_polygon_shape(layer, index, pen, None)
241              else:              else:
242                  self.dc.SetBrush(brush)                  self.dc.SetBrush(brush)
243                  self.dc.SetPen(pen)                  self.dc.SetPen(pen)
244                  if shapetype == SHAPETYPE_ARC:                  if shapetype == SHAPETYPE_POINT:
245                      f = self.draw_arc_shape                      self.draw_point_shape(layer, index)
246                  elif shapetype == SHAPETYPE_POINT:                  else:
247                      f = self.draw_point_shape                      raise TypeError("Unhandled shape type %s" % shapetype)
                 f(layer, index)  
248    
249      def layer_ids(self, layer):      def layer_ids(self, layer):
250          """Return the shapeids covered by the region that has to be redrawn          """Return the shapeids covered by the region that has to be redrawn
# Line 246  class ScreenRenderer(MapRenderer): Line 267  class ScreenRenderer(MapRenderer):
267          offx, offy = self.offset          offx, offy = self.offset
268          xs = []          xs = []
269          ys = []          ys = []
270          x, y, width, height = self.update_region.asTuple()          x, y, width, height = self.update_region
271          for winx, winy in ((x, y), (x + width, y),          for winx, winy in ((x, y), (x + width, y),
272                             (x + width, y + height), (x, y + height)):                             (x + width, y + height), (x, y + height)):
273              px = (winx - offx) / scale              px = (winx - offx) / scale

Legend:
Removed from v.144  
changed lines
  Added in v.362

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26