380 |
wxBeginBusyCursor() |
wxBeginBusyCursor() |
381 |
|
|
382 |
if not clear: |
if not clear: |
383 |
|
self.do_redraw() |
384 |
try: |
try: |
385 |
self.do_redraw() |
pass |
386 |
except: |
except: |
387 |
print "Error during drawing:", sys.exc_info()[0] |
print "Error during drawing:", sys.exc_info()[0] |
388 |
clear = True |
clear = True |
447 |
clientdc.EndDrawing() |
clientdc.EndDrawing() |
448 |
|
|
449 |
def Export(self): |
def Export(self): |
450 |
|
if self.scale == 0: |
451 |
|
return |
452 |
|
|
453 |
if hasattr(self, "export_path"): |
if hasattr(self, "export_path"): |
454 |
export_path = self.export_path |
export_path = self.export_path |
455 |
else: |
else: |
532 |
|
|
533 |
def set_view_transform(self, scale, offset): |
def set_view_transform(self, scale, offset): |
534 |
self.scale = scale |
self.scale = scale |
|
if self.scale < 0.0001: |
|
|
self.scale = 0.0001 |
|
535 |
|
|
536 |
self.offset = offset |
self.offset = offset |
537 |
self.full_redraw() |
self.full_redraw() |
541 |
"""\ |
"""\ |
542 |
Return the point in window coords given by projected coordinates x y |
Return the point in window coords given by projected coordinates x y |
543 |
""" |
""" |
544 |
|
if self.scale == 0: |
545 |
|
return (0, 0) |
546 |
|
|
547 |
offx, offy = self.offset |
offx, offy = self.offset |
548 |
return (self.scale * x + offx, -self.scale * y + offy) |
return (self.scale * x + offx, -self.scale * y + offy) |
549 |
|
|
551 |
"""\ |
"""\ |
552 |
Return the point in projected coordinates given by window coords x y |
Return the point in projected coordinates given by window coords x y |
553 |
""" |
""" |
554 |
|
if self.scale == 0: |
555 |
|
return (0, 0) |
556 |
|
|
557 |
offx, offy = self.offset |
offx, offy = self.offset |
558 |
return ((x - offx) / self.scale, (offy - y) / self.scale) |
return ((x - offx) / self.scale, (offy - y) / self.scale) |
559 |
|
|
573 |
scale = min(scalex, scaley) |
scale = min(scalex, scaley) |
574 |
offx = 0.5 * (width - (urx + llx) * scale) |
offx = 0.5 * (width - (urx + llx) * scale) |
575 |
offy = 0.5 * (height + (ury + lly) * scale) |
offy = 0.5 * (height + (ury + lly) * scale) |
|
print "scalex:", scalex, "scaley:", scaley |
|
576 |
self.set_view_transform(scale, (offx, offy)) |
self.set_view_transform(scale, (offx, offy)) |
577 |
|
|
578 |
def FitMapToWindow(self): |
def FitMapToWindow(self): |
621 |
that should be centered. If it is omitted, it defaults to the |
that should be centered. If it is omitted, it defaults to the |
622 |
center of the window |
center of the window |
623 |
""" |
""" |
624 |
width, height = self.GetSizeTuple() |
if self.scale > 0: |
625 |
scale = self.scale * factor |
width, height = self.GetSizeTuple() |
626 |
offx, offy = self.offset |
scale = self.scale * factor |
627 |
if center is not None: |
offx, offy = self.offset |
628 |
cx, cy = center |
if center is not None: |
629 |
else: |
cx, cy = center |
630 |
cx = width / 2 |
else: |
631 |
cy = height / 2 |
cx = width / 2 |
632 |
offset = (factor * (offx - cx) + width / 2, |
cy = height / 2 |
633 |
factor * (offy - cy) + height / 2) |
offset = (factor * (offx - cx) + width / 2, |
634 |
self.set_view_transform(scale, offset) |
factor * (offy - cy) + height / 2) |
635 |
|
self.set_view_transform(scale, offset) |
636 |
|
|
637 |
def ZoomOutToRect(self, rect): |
def ZoomOutToRect(self, rect): |
638 |
"""Zoom out to fit the currently visible region into rect. |
"""Zoom out to fit the currently visible region into rect. |
818 |
forward = None |
forward = None |
819 |
|
|
820 |
scale = self.scale |
scale = self.scale |
821 |
|
|
822 |
|
if scale == 0: |
823 |
|
return None, None |
824 |
|
|
825 |
offx, offy = self.offset |
offx, offy = self.offset |
826 |
|
|
827 |
if select_labels: |
if select_labels: |