445 |
return ((x - offx) / self.scale, (offy - y) / self.scale) |
return ((x - offx) / self.scale, (offy - y) / self.scale) |
446 |
|
|
447 |
def FitRectToWindow(self, rect): |
def FitRectToWindow(self, rect): |
448 |
|
"""Fit the rectangular region given by rect into the window. |
449 |
|
|
450 |
|
Set scale so that rect (in projected coordinates) just fits into |
451 |
|
the window and center it. |
452 |
|
""" |
453 |
width, height = self.GetSizeTuple() |
width, height = self.GetSizeTuple() |
454 |
llx, lly, urx, ury = rect |
llx, lly, urx, ury = rect |
455 |
if llx == urx or lly == ury: |
if llx == urx or lly == ury: |
463 |
self.set_view_transform(scale, (offx, offy)) |
self.set_view_transform(scale, (offx, offy)) |
464 |
|
|
465 |
def FitMapToWindow(self): |
def FitMapToWindow(self): |
466 |
"""\ |
"""Fit the map to the window |
467 |
Set the scale and offset so that the map is centered in the |
|
468 |
window |
Set the scale so that the map fits exactly into the window and |
469 |
|
center it in the window. |
470 |
""" |
""" |
471 |
bbox = self.map.ProjectedBoundingBox() |
bbox = self.map.ProjectedBoundingBox() |
472 |
if bbox is not None: |
if bbox is not None: |
492 |
self.set_view_transform(scale, offset) |
self.set_view_transform(scale, offset) |
493 |
|
|
494 |
def ZoomOutToRect(self, rect): |
def ZoomOutToRect(self, rect): |
495 |
# rect is given in window coordinates |
"""Zoom out to fit the currently visible region into rect. |
496 |
|
|
497 |
|
The rect parameter is given in window coordinates |
498 |
|
""" |
499 |
# determine the bbox of the displayed region in projected |
# determine the bbox of the displayed region in projected |
500 |
# coordinates |
# coordinates |
501 |
width, height = self.GetSizeTuple() |
width, height = self.GetSizeTuple() |