/[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 2431 by joey, Sun Dec 5 15:05:02 2004 UTC revision 2552 by jonathan, Fri Jan 28 15:54:00 2005 UTC
# Line 22  from wxPython.wx import wxPoint, wxRect, Line 22  from wxPython.wx import wxPoint, wxRect,
22      wxTRANSPARENT_PEN, wxTRANSPARENT_BRUSH, \      wxTRANSPARENT_PEN, wxTRANSPARENT_BRUSH, \
23      wxBLACK_PEN, wxBLACK, wxSOLID, wxCROSS_HATCH, wxSWISS, wxNORMAL, \      wxBLACK_PEN, wxBLACK, wxSOLID, wxCROSS_HATCH, wxSWISS, wxNORMAL, \
24      wxBitmapFromImage, wxImageFromStream, wxBITMAP_TYPE_BMP, \      wxBitmapFromImage, wxImageFromStream, wxBITMAP_TYPE_BMP, \
25      wxBITMAP_TYPE_JPEG, wxBITMAP_TYPE_PNG, wxBITMAP_TYPE_TIF, wxBITMAP_TYPE_GIF      wxBITMAP_TYPE_JPEG, wxBITMAP_TYPE_PNG, wxBITMAP_TYPE_TIF, \
26        wxBITMAP_TYPE_GIF, wxEmptyImage, wxMask, wxBitmapFromBits
27    
28  from wxproj import draw_polygon_shape, draw_polygon_init  from wxproj import draw_polygon_shape, draw_polygon_init
29    
# Line 38  import Thuban.Model.resource Line 39  import Thuban.Model.resource
39    
40  from baserenderer import BaseRenderer  from baserenderer import BaseRenderer
41    
42    from math import floor
43    
44    from types import StringType
45    
46    
47  # Map the strings used for the format parameter of the draw_raster_data  # Map the strings used for the format parameter of the draw_raster_data
48  # method to the appropriate wxWindows constants  # method to the appropriate wxWindows constants
# Line 99  class MapRenderer(BaseRenderer): Line 104  class MapRenderer(BaseRenderer):
104          return wxFont(int(round(self.resolution * 10)), wxSWISS, wxNORMAL,          return wxFont(int(round(self.resolution * 10)), wxSWISS, wxNORMAL,
105                        wxNORMAL)                        wxNORMAL)
106    
107      def draw_raster_data(self, data, format = 'BMP'):      def draw_raster_data(self, x,y, data, format = 'BMP'):
108          stream = cStringIO.StringIO(data)  
109          image = wxImageFromStream(stream, raster_format_map[format])          mask = None
110    
111            if format == 'RAW':
112                image = wxEmptyImage(data[0], data[1])
113                image.SetData(data[2][0])
114                if data[2][1] is not None:
115                    mask = wxBitmapFromBits(data[2][1], data[0], data[1], 1)
116                    mask = wxMask(mask)
117            else:
118                stream = cStringIO.StringIO(data[2][0])
119                image = wxImageFromStream(stream, raster_format_map[format])
120                if data[2][1] is not None:
121                    stream = cStringIO.StringIO(data[2][1])
122                    mask = wxImageFromStream(stream, raster_format_map[format])
123                    mask = wxMask(wxBitmapFromImage(mask, 1))
124    
125          bitmap = wxBitmapFromImage(image)          bitmap = wxBitmapFromImage(image)
126          self.dc.DrawBitmap(bitmap, 0, 0)          bitmap.SetMask(mask)
127    
128            self.dc.DrawBitmap(bitmap, int(round(x)), int(round(y)), True)
129    
130    
131  class ScreenRenderer(MapRenderer):  class ScreenRenderer(MapRenderer):
# Line 166  class ScreenRenderer(MapRenderer): Line 188  class ScreenRenderer(MapRenderer):
188    
189              # Get the size of the specific property for this              # Get the size of the specific property for this
190              # point              # point
191              if shapetype == SHAPETYPE_POINT:              if shapetype == SHAPETYPE_POINT and field is not None:
192                  value = table.ReadValue(shape.ShapeID(), field)                  value = table.ReadValue(shape.ShapeID(), field)
193                  group = lc.FindGroup(value)                  group = lc.FindGroup(value)
194                  size = group.GetProperties().GetSize()                  size = group.GetProperties().GetSize()
# Line 268  class ExportRenderer(ScreenRenderer): Line 290  class ExportRenderer(ScreenRenderer):
290          self.shifty = (mmaxy - mminy)*0.5 - (ury - lly)*0.5          self.shifty = (mmaxy - mminy)*0.5 - (ury - lly)*0.5
291    
292          self.offset = (offx+self.shiftx, offy+self.shifty)          self.offset = (offx+self.shiftx, offy+self.shifty)
293            self.region = (llx + self.shiftx, lly + self.shifty, urx, ury)
294    
295          # Draw the map          # Draw the map
296          self.dc.BeginDrawing()          self.dc.BeginDrawing()

Legend:
Removed from v.2431  
changed lines
  Added in v.2552

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26