267 |
# if the mouse is outside the window. |
# if the mouse is outside the window. |
268 |
self.current_position = None |
self.current_position = None |
269 |
|
|
|
|
|
270 |
# If true, OnIdle will call do_redraw to do the actual |
# If true, OnIdle will call do_redraw to do the actual |
271 |
# redrawing. Set by OnPaint to avoid some unnecessary redraws. |
# redrawing. Set by OnPaint to avoid some unnecessary redraws. |
272 |
# To force a redraw call full_redraw(). |
# To force a redraw call full_redraw(). |
273 |
self.redraw_on_idle = 0 |
self.redraw_on_idle = 0 |
274 |
|
|
275 |
|
# The region to update when idle |
276 |
|
self.update_region = wx.wxRegion() |
277 |
|
|
278 |
# the bitmap serving as backing store |
# the bitmap serving as backing store |
279 |
self.bitmap = None |
self.bitmap = None |
280 |
|
|
300 |
if self.map is not None and self.map.HasLayers(): |
if self.map is not None and self.map.HasLayers(): |
301 |
# We have a non-empty map. Redraw it in idle time |
# We have a non-empty map. Redraw it in idle time |
302 |
self.redraw_on_idle = 1 |
self.redraw_on_idle = 1 |
303 |
|
# update the region that has to be redrawn |
304 |
|
self.update_region.UnionRegion(self.GetUpdateRegion()) |
305 |
else: |
else: |
306 |
# If we've got no map or if the map is empty, simply clear |
# If we've got no map or if the map is empty, simply clear |
307 |
# the screen. |
# the screen. |
314 |
dc.Clear() |
dc.Clear() |
315 |
dc.EndDrawing() |
dc.EndDrawing() |
316 |
|
|
317 |
|
# clear the region |
318 |
|
self.update_region = wx.wxRegion() |
319 |
|
|
320 |
def do_redraw(self): |
def do_redraw(self): |
321 |
# This should only be called if we have a non-empty map. We draw |
# This should only be called if we have a non-empty map. |
|
# it into a memory DC and then blit it to the screen. |
|
322 |
|
|
323 |
|
# get the update region and reset it. We're not actually using |
324 |
|
# it anymore, though. |
325 |
|
update_box = self.update_region.GetBox() |
326 |
|
self.update_region = wx.wxRegion() |
327 |
|
|
328 |
|
# Get the window size. |
329 |
width, height = self.GetSizeTuple() |
width, height = self.GetSizeTuple() |
330 |
|
|
331 |
# If self.bitmap's still there, reuse it. Otherwise redraw it |
# If self.bitmap's still there, reuse it. Otherwise redraw it |
351 |
|
|
352 |
# draw the map into the bitmap |
# draw the map into the bitmap |
353 |
renderer = ScreenRenderer(dc, self.scale, self.offset) |
renderer = ScreenRenderer(dc, self.scale, self.offset) |
354 |
renderer.RenderMap(self.map, selected_layer, selected_shape) |
|
355 |
|
# Pass the entire bitmap as update_region to the renderer. |
356 |
|
# We're redrawing the whole bitmap, after all. |
357 |
|
renderer.RenderMap(self.map, (0, 0, width, height), |
358 |
|
selected_layer, selected_shape) |
359 |
|
|
360 |
dc.EndDrawing() |
dc.EndDrawing() |
361 |
dc.SelectObject(wx.wxNullBitmap) |
dc.SelectObject(wx.wxNullBitmap) |