1 |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
# Copyright (c) 2001-2004 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> (2001-2003) |
4 |
# Jonathan Coles <[email protected]> |
# Jonathan Coles <[email protected]> (2003) |
5 |
# Frank Koormann <[email protected]> |
# Frank Koormann <[email protected]> (2003) |
6 |
|
# Jan-Oliver Wagner <[email protected]> (2003, 2004) |
7 |
# |
# |
8 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
9 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
21 |
from wxPython.wx import wxPoint, wxRect, wxPen, wxBrush, wxFont, \ |
from wxPython.wx import wxPoint, wxRect, wxPen, wxBrush, wxFont, \ |
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, wxBITMAP_TYPE_JPEG |
wxBitmapFromImage, wxImageFromStream, wxBITMAP_TYPE_BMP, \ |
25 |
|
wxBITMAP_TYPE_JPEG, wxBITMAP_TYPE_PNG, wxBITMAP_TYPE_TIF, wxBITMAP_TYPE_GIF |
26 |
|
|
27 |
from wxproj import draw_polygon_shape, draw_polygon_init |
from wxproj import draw_polygon_shape, draw_polygon_init |
28 |
|
|
44 |
raster_format_map = { |
raster_format_map = { |
45 |
"BMP": wxBITMAP_TYPE_BMP, |
"BMP": wxBITMAP_TYPE_BMP, |
46 |
"JPEG": wxBITMAP_TYPE_JPEG, |
"JPEG": wxBITMAP_TYPE_JPEG, |
47 |
|
"PNG": wxBITMAP_TYPE_PNG, |
48 |
|
"TIFF": wxBITMAP_TYPE_TIF, |
49 |
|
"GIF": wxBITMAP_TYPE_GIF, |
50 |
} |
} |
51 |
|
|
52 |
class MapRenderer(BaseRenderer): |
class MapRenderer(BaseRenderer): |
134 |
return self.render_map_incrementally() |
return self.render_map_incrementally() |
135 |
|
|
136 |
def draw_selection_incrementally(self, layer, selected_shapes): |
def draw_selection_incrementally(self, layer, selected_shapes): |
137 |
|
"""Draw the selected shapes in a emphasized way (i.e. |
138 |
|
with a special pen and brush. |
139 |
|
The drawing is performed incrementally, that means every |
140 |
|
n shapes, the user can have interactions with the map. |
141 |
|
n is currently fixed to 500. |
142 |
|
|
143 |
|
layer -- the layer where the shapes belong to. |
144 |
|
selected_shapes -- a list of the shape-ids representing the |
145 |
|
selected shapes for the given layer. |
146 |
|
""" |
147 |
pen = wxPen(wxBLACK, 3, wxSOLID) |
pen = wxPen(wxBLACK, 3, wxSOLID) |
148 |
brush = wxBrush(wxBLACK, wxCROSS_HATCH) |
brush = wxBrush(wxBLACK, wxCROSS_HATCH) |
149 |
|
|
150 |
shapetype = layer.ShapeType() |
shapetype = layer.ShapeType() |
151 |
useraw, func, param = self.low_level_renderer(layer) |
useraw, func, param = self.low_level_renderer(layer) |
152 |
args = (pen, brush) |
args = (pen, brush) |
153 |
|
|
154 |
|
# for point shapes we need to find out the properties |
155 |
|
# to determine the size. Based on table and field, |
156 |
|
# we can find out the properties for object - see below. |
157 |
|
if shapetype == SHAPETYPE_POINT: |
158 |
|
lc = layer.GetClassification() |
159 |
|
field = layer.GetClassificationColumn() |
160 |
|
table = layer.ShapeStore().Table() |
161 |
|
|
162 |
count = 0 |
count = 0 |
163 |
for index in selected_shapes: |
for index in selected_shapes: |
164 |
count += 1 |
count += 1 |
165 |
shape = layer.Shape(index) |
shape = layer.Shape(index) |
166 |
|
|
167 |
|
# Get the size of the specific property for this |
168 |
|
# point |
169 |
|
if shapetype == SHAPETYPE_POINT and field is not None: |
170 |
|
value = table.ReadValue(shape.ShapeID(), field) |
171 |
|
group = lc.FindGroup(value) |
172 |
|
size = group.GetProperties().GetSize() |
173 |
|
args = (pen, brush, size) |
174 |
|
|
175 |
if useraw: |
if useraw: |
176 |
data = shape.RawData() |
data = shape.RawData() |
177 |
else: |
else: |
268 |
self.shifty = (mmaxy - mminy)*0.5 - (ury - lly)*0.5 |
self.shifty = (mmaxy - mminy)*0.5 - (ury - lly)*0.5 |
269 |
|
|
270 |
self.offset = (offx+self.shiftx, offy+self.shifty) |
self.offset = (offx+self.shiftx, offy+self.shifty) |
271 |
|
self.region = (llx + self.shiftx, lly + self.shifty, urx, ury) |
272 |
|
|
273 |
# Draw the map |
# Draw the map |
274 |
self.dc.BeginDrawing() |
self.dc.BeginDrawing() |