34 |
|
|
35 |
from wxproj import point_in_polygon_shape, shape_centroid |
from wxproj import point_in_polygon_shape, shape_centroid |
36 |
|
|
|
|
|
37 |
from Thuban.Model.messages import MAP_PROJECTION_CHANGED, \ |
from Thuban.Model.messages import MAP_PROJECTION_CHANGED, \ |
38 |
MAP_LAYERS_CHANGED, LAYER_CHANGED, LAYER_VISIBILITY_CHANGED |
MAP_LAYERS_CHANGED, LAYER_CHANGED, LAYER_VISIBILITY_CHANGED |
39 |
from Thuban.Model.layer import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \ |
from Thuban.Model.layer import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \ |
377 |
dc = wxPaintDC(self) |
dc = wxPaintDC(self) |
378 |
clear = self.map is None or not self.map.HasLayers() |
clear = self.map is None or not self.map.HasLayers() |
379 |
|
|
380 |
#wxBeginBusyCursor() |
wxBeginBusyCursor() |
381 |
|
|
382 |
if not clear: |
if not clear: |
383 |
try: |
try: |
398 |
dc.Clear() |
dc.Clear() |
399 |
dc.EndDrawing() |
dc.EndDrawing() |
400 |
|
|
401 |
#wxEndBusyCursor() |
wxEndBusyCursor() |
402 |
|
|
403 |
def do_redraw(self): |
def do_redraw(self): |
404 |
# This should only be called if we have a non-empty map. |
# This should only be called if we have a non-empty map. |
458 |
dc = wxMetaFileDC(dlg.GetPath()) |
dc = wxMetaFileDC(dlg.GetPath()) |
459 |
|
|
460 |
scale, offset, mapregion = OutputTransform(self.scale, |
scale, offset, mapregion = OutputTransform(self.scale, |
461 |
self.canvas.offset, |
self.offset, |
462 |
self.GetSizeTuple(), |
self.GetSizeTuple(), |
463 |
dc.GetSizeTuple()) |
dc.GetSizeTuple()) |
464 |
|
|
528 |
|
|
529 |
def set_view_transform(self, scale, offset): |
def set_view_transform(self, scale, offset): |
530 |
self.scale = scale |
self.scale = scale |
531 |
|
if self.scale < 0.0001: |
532 |
|
self.scale = 0.0001 |
533 |
|
|
534 |
self.offset = offset |
self.offset = offset |
535 |
self.full_redraw() |
self.full_redraw() |
536 |
self.issue(SCALE_CHANGED, scale) |
self.issue(SCALE_CHANGED, scale) |
565 |
scale = min(scalex, scaley) |
scale = min(scalex, scaley) |
566 |
offx = 0.5 * (width - (urx + llx) * scale) |
offx = 0.5 * (width - (urx + llx) * scale) |
567 |
offy = 0.5 * (height + (ury + lly) * scale) |
offy = 0.5 * (height + (ury + lly) * scale) |
568 |
|
print "scalex:", scalex, "scaley:", scaley |
569 |
self.set_view_transform(scale, (offx, offy)) |
self.set_view_transform(scale, (offx, offy)) |
570 |
|
|
571 |
def FitMapToWindow(self): |
def FitMapToWindow(self): |