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 |
27 |
|
|
28 |
from wxproj import draw_polygon_shape, draw_polygon_init |
from wxproj import draw_polygon_shape, draw_polygon_init |
29 |
|
|
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 |
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', mask = None): |
108 |
stream = cStringIO.StringIO(data) |
if format == 'RAW': |
109 |
image = wxImageFromStream(stream, raster_format_map[format]) |
image = wxEmptyImage(data[0], data[1]) |
110 |
|
image.SetData(data[2]) |
111 |
|
else: |
112 |
|
stream = cStringIO.StringIO(data[2]) |
113 |
|
image = wxImageFromStream(stream, raster_format_map[format]) |
114 |
|
|
115 |
bitmap = wxBitmapFromImage(image) |
bitmap = wxBitmapFromImage(image) |
116 |
self.dc.DrawBitmap(bitmap, 0, 0) |
|
117 |
|
if mask is None: |
118 |
|
self.dc.DrawBitmap(bitmap, int(round(x)), int(round(y)), False) |
119 |
|
else: |
120 |
|
# if we are given a mask object, try to pass it to SetMaskColour, |
121 |
|
# otherwise assume it's a mask image |
122 |
|
try: |
123 |
|
bitmap.SetMaskColour(mask); |
124 |
|
self.dc.DrawBitmap(bitmap, int(round(x)), int(round(y)), True) |
125 |
|
except (TypeError): |
126 |
|
# implement using a mask image |
127 |
|
raise NotImplementedError |
128 |
|
|
129 |
|
|
130 |
class ScreenRenderer(MapRenderer): |
class ScreenRenderer(MapRenderer): |