104 |
|
|
105 |
self.init_dialogs() |
self.init_dialogs() |
106 |
|
|
107 |
EVT_CLOSE(self, self._OnClose) |
EVT_CLOSE(self, self.OnClose) |
108 |
|
|
109 |
def Subscribe(self, channel, *args): |
def Subscribe(self, channel, *args): |
110 |
"""Subscribe a function to a message channel. |
"""Subscribe a function to a message channel. |
395 |
def Exit(self): |
def Exit(self): |
396 |
self.Close(False) |
self.Close(False) |
397 |
|
|
398 |
def _OnClose(self, event): |
def OnClose(self, event): |
399 |
result = self.save_modified_session(can_veto = event.CanVeto()) |
result = self.save_modified_session(can_veto = event.CanVeto()) |
400 |
if result == wxID_CANCEL: |
if result == wxID_CANCEL: |
401 |
event.Veto() |
event.Veto() |
404 |
# wx's destroy event, but that isn't implemented for wxGTK |
# wx's destroy event, but that isn't implemented for wxGTK |
405 |
# yet. |
# yet. |
406 |
self.canvas.Unsubscribe(VIEW_POSITION, self.view_position_changed) |
self.canvas.Unsubscribe(VIEW_POSITION, self.view_position_changed) |
407 |
DockFrame._OnClose(self, event) |
DockFrame.OnClose(self, event) |
408 |
self.Destroy() |
self.Destroy() |
409 |
|
|
410 |
def SetMap(self, map): |
def SetMap(self, map): |
459 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
460 |
filename = dlg.GetPath() |
filename = dlg.GetPath() |
461 |
title = os.path.splitext(os.path.basename(filename))[0] |
title = os.path.splitext(os.path.basename(filename))[0] |
|
store = self.application.Session().OpenShapefile(filename) |
|
|
layer = Layer(title, store) |
|
462 |
map = self.canvas.Map() |
map = self.canvas.Map() |
463 |
has_layers = map.HasLayers() |
has_layers = map.HasLayers() |
464 |
try: |
try: |
465 |
map.AddLayer(layer) |
store = self.application.Session().OpenShapefile(filename) |
466 |
except IOError: |
except IOError: |
467 |
# the layer couldn't be opened |
# the layer couldn't be opened |
468 |
self.RunMessageBox(_("Add Layer"), |
self.RunMessageBox(_("Add Layer"), |
469 |
_("Can't open the file '%s'.") % filename) |
_("Can't open the file '%s'.") % filename) |
470 |
else: |
else: |
471 |
|
layer = Layer(title, store) |
472 |
|
map.AddLayer(layer) |
473 |
if not has_layers: |
if not has_layers: |
474 |
# if we're adding a layer to an empty map, fit the |
# if we're adding a layer to an empty map, fit the |
475 |
# new map to the window |
# new map to the window |
482 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
483 |
filename = dlg.GetPath() |
filename = dlg.GetPath() |
484 |
title = os.path.splitext(os.path.basename(filename))[0] |
title = os.path.splitext(os.path.basename(filename))[0] |
|
layer = RasterLayer(title, filename) |
|
485 |
map = self.canvas.Map() |
map = self.canvas.Map() |
486 |
has_layers = map.HasLayers() |
has_layers = map.HasLayers() |
487 |
try: |
try: |
488 |
map.AddLayer(layer) |
layer = RasterLayer(title, filename) |
489 |
except IOError: |
except IOError: |
490 |
# the layer couldn't be opened |
# the layer couldn't be opened |
491 |
self.RunMessageBox(_("Add Image Layer"), |
self.RunMessageBox(_("Add Image Layer"), |
492 |
_("Can't open the file '%s'.") % filename) |
_("Can't open the file '%s'.") % filename) |
493 |
else: |
else: |
494 |
|
map.AddLayer(layer) |
495 |
if not has_layers: |
if not has_layers: |
496 |
# if we're adding a layer to an empty map, fit the |
# if we're adding a layer to an empty map, fit the |
497 |
# new map to the window |
# new map to the window |