197 |
def RenderMap(self, map, region, selected_layer, selected_shape): |
def RenderMap(self, map, region, selected_layer, selected_shape): |
198 |
"""Render the map. |
"""Render the map. |
199 |
|
|
200 |
Only the given region (a wxRect in window coordinates) needs to |
Only the given region (a tuple in window coordinates as returned |
201 |
be redrawn. Highlight the shape with id selected_shape in the |
by a wxrect's asTuple method) needs to be redrawn. Highlight the |
202 |
selected_layer. |
shape with id selected_shape in the selected_layer. |
203 |
""" |
""" |
204 |
self.update_region = region |
self.update_region = region |
205 |
self.selected_layer = selected_layer |
self.selected_layer = selected_layer |
216 |
index = self.selected_shape |
index = self.selected_shape |
217 |
if shapetype == SHAPETYPE_POLYGON: |
if shapetype == SHAPETYPE_POLYGON: |
218 |
self.draw_polygon_shape(layer, index, pen, brush) |
self.draw_polygon_shape(layer, index, pen, brush) |
219 |
|
elif shapetype == SHAPETYPE_ARC: |
220 |
|
self.draw_polygon_shape(layer, index, pen, None) |
221 |
else: |
else: |
222 |
self.dc.SetBrush(brush) |
self.dc.SetBrush(brush) |
223 |
self.dc.SetPen(pen) |
self.dc.SetPen(pen) |
224 |
if shapetype == SHAPETYPE_ARC: |
if shapetype == SHAPETYPE_POINT: |
225 |
f = self.draw_arc_shape |
self.draw_point_shape(layer, index) |
226 |
elif shapetype == SHAPETYPE_POINT: |
else: |
227 |
f = self.draw_point_shape |
raise TypeError("Unhandled shape type %s" % shapetype) |
|
f(layer, index) |
|
228 |
|
|
229 |
def layer_ids(self, layer): |
def layer_ids(self, layer): |
230 |
"""Return the shapeids covered by the region that has to be redrawn |
"""Return the shapeids covered by the region that has to be redrawn |
247 |
offx, offy = self.offset |
offx, offy = self.offset |
248 |
xs = [] |
xs = [] |
249 |
ys = [] |
ys = [] |
250 |
x, y, width, height = self.update_region.asTuple() |
x, y, width, height = self.update_region |
251 |
for winx, winy in ((x, y), (x + width, y), |
for winx, winy in ((x, y), (x + width, y), |
252 |
(x + width, y + height), (x, y + height)): |
(x + width, y + height), (x, y + height)): |
253 |
px = (winx - offx) / scale |
px = (winx - offx) / scale |