/[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 965 by jonathan, Wed May 21 17:24:22 2003 UTC revision 1298 by jonathan, Tue Jun 24 18:00:26 2003 UTC
# Line 22  from wxPython.wx import wxMemoryDC, wxEm Line 22  from wxPython.wx import wxMemoryDC, wxEm
22      wxImageFromStream, wxBITMAP_TYPE_BMP      wxImageFromStream, wxBITMAP_TYPE_BMP
23    
24  from wxproj import draw_polygon_shape, draw_polygon_init  from wxproj import draw_polygon_shape, draw_polygon_init
 from gdalwarp import ProjectRasterFile  
25    
26  from Thuban.UI.common import Color2wxColour  from Thuban.UI.common import Color2wxColour
27  from Thuban.UI.classifier import ClassDataPreviewer  from Thuban.UI.classifier import ClassDataPreviewer
# Line 35  from Thuban.Model.label import ALIGN_CEN Line 34  from Thuban.Model.label import ALIGN_CEN
34    
35  from Thuban.Model.classification import Classification  from Thuban.Model.classification import Classification
36  from Thuban.Model.color import Color  from Thuban.Model.color import Color
37    import Thuban.Model.resource
38    
39    if Thuban.Model.resource.has_gdal_support():
40        from gdalwarp import ProjectRasterFile
41    
42  class MapRenderer:  class MapRenderer:
43    
# Line 78  class MapRenderer: Line 81  class MapRenderer:
81          #          #
82          # This is only a good optimization if there is only one          # This is only a good optimization if there is only one
83          # raster layer and the image covers the entire window (as          # raster layer and the image covers the entire window (as
84          # it currently does).          # it currently does). We note if there is a raster layer
85            # and only begin drawing layers once we have drawn it.
86            # That way we avoid drawing layers that won't be seen.
87          #          #
88          for layer in map.Layers():          if Thuban.Model.resource.has_gdal_support():
89              if isinstance(layer, RasterLayer):              for layer in map.Layers():
90                  seenRaster = False                  if isinstance(layer, RasterLayer) and layer.Visible():
91                  break                      seenRaster = False
92                        break
93    
94          for layer in map.Layers():          for layer in map.Layers():
95              # if honor_visibility is true, only draw visible layers,              # if honor_visibility is true, only draw visible layers,
# Line 91  class MapRenderer: Line 97  class MapRenderer:
97              if not self.honor_visibility or layer.Visible():              if not self.honor_visibility or layer.Visible():
98                  if isinstance(layer, Layer) and seenRaster:                  if isinstance(layer, Layer) and seenRaster:
99                      self.draw_shape_layer(layer)                      self.draw_shape_layer(layer)
100                  elif isinstance(layer, RasterLayer):                  elif isinstance(layer, RasterLayer) \
101                        and Thuban.Model.resource.has_gdal_support():
102                      self.draw_raster_layer(layer)                      self.draw_raster_layer(layer)
103                      seenRaster = True                      seenRaster = True
104    
# Line 125  class MapRenderer: Line 132  class MapRenderer:
132          else:          else:
133              draw_func = lambda i: \              draw_func = lambda i: \
134                     self.draw_polygon_shape(polygon_render_param, i, pen, brush)                     self.draw_polygon_shape(polygon_render_param, i, pen, brush)
135                
136            table = layer.ShapeStore().Table()
137          for i in self.layer_ids(layer):          for i in self.layer_ids(layer):
138    
139              if field is None:              if field is None:
140                  group = defaultGroup                  group = defaultGroup
141              else:              else:
142                  record = layer.table.ReadRowAsDict(i)                  record = table.ReadRowAsDict(i)
143                  assert record is not None                  assert record is not None
144                  group = lc.FindGroup(record[field])                  group = lc.FindGroup(record[field])
145    
# Line 202  class MapRenderer: Line 210  class MapRenderer:
210                  layer.GetImageFilename(),                  layer.GetImageFilename(),
211                  inProj,                  inProj,
212                  outProj,                  outProj,
213                  str(xmin), str(ymin), str(xmax), str(ymax),                  (xmin, ymin, xmax, ymax),
214                  "", str(width), str(height));                  "", (width, height))
215          except IOError, (strerr):          except IOError, (strerr):
216              print strerr              print strerr
217          except (AttributeError, ValueError):          except (AttributeError, ValueError):
# Line 228  class MapRenderer: Line 236  class MapRenderer:
236      def polygon_render_param(self, layer):      def polygon_render_param(self, layer):
237          """Return the low-lever render parameter for the layer"""          """Return the low-lever render parameter for the layer"""
238          offx, offy = self.offset          offx, offy = self.offset
239          return draw_polygon_init(layer.shapefile, self.dc,          return draw_polygon_init(layer.ShapeStore().Shapefile(), self.dc,
240                                   self.map.projection,                                   self.map.projection,
241                                   layer.projection,                                   layer.projection,
242                                   self.scale, -self.scale,                                   self.scale, -self.scale,
# Line 512  class ExportRenderer(ScreenRenderer): Line 520  class ExportRenderer(ScreenRenderer):
520                      # Render title                      # Render title
521                      dc.DrawText(l.Title(), posx, posy)                      dc.DrawText(l.Title(), posx, posy)
522                      posy+=stepy                      posy+=stepy
523                      # Render classification                      if l.HasClassification():
524                      clazz = l.GetClassification()                          # Render classification
525                      shapeType = l.ShapeType()                          clazz = l.GetClassification()
526                      for g in clazz:                          shapeType = l.ShapeType()
527                          if g.IsVisible():                          for g in clazz:
528                              previewer.Draw(dc,                              if g.IsVisible():
529                                  wxRect(posx+dx, posy, iconwidth, iconheight),                                  previewer.Draw(dc,
530                                  g.GetProperties(), shapeType)                                      wxRect(posx+dx, posy,
531                              dc.DrawText(g.GetDisplayText(),                                             iconwidth, iconheight),
532                                          posx+2*dx+iconwidth, posy)                                      g.GetProperties(), shapeType)
533                              posy+=stepy                                  dc.DrawText(g.GetDisplayText(),
534                                                posx+2*dx+iconwidth, posy)
535                                    posy+=stepy
536                    
537      def render_scalebar(self, map):      def render_scalebar(self, map):
538          """Render the scalebar."""          """Render the scalebar."""

Legend:
Removed from v.965  
changed lines
  Added in v.1298

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26