13 |
|
|
14 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
15 |
|
|
16 |
__ThubanVersion__ = "0.2" #"$THUBAN_0_2$" |
__ThubanVersion__ = "0.8" #"$THUBAN_0_2$" |
17 |
#__BuildDate__ = "$Date$" |
#__BuildDate__ = "$Date$" |
18 |
|
|
19 |
import os |
import os |
43 |
|
|
44 |
from context import Context |
from context import Context |
45 |
from command import registry, Command, ToolCommand |
from command import registry, Command, ToolCommand |
46 |
from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION |
from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION, \ |
47 |
|
MAP_REPLACED |
48 |
|
from about import About |
49 |
|
|
50 |
from Thuban.UI.dock import DockFrame |
from Thuban.UI.dock import DockFrame |
51 |
from Thuban.UI.join import JoinDialog |
from Thuban.UI.join import JoinDialog |
55 |
|
|
56 |
import projdialog |
import projdialog |
57 |
|
|
58 |
|
|
59 |
class MainWindow(DockFrame): |
class MainWindow(DockFrame): |
60 |
|
|
61 |
# Some messages that can be subscribed/unsubscribed directly through |
# Some messages that can be subscribed/unsubscribed directly through |
64 |
# actually come from. This delegation is implemented in the |
# actually come from. This delegation is implemented in the |
65 |
# Subscribe and unsubscribed methods |
# Subscribe and unsubscribed methods |
66 |
delegated_messages = {LAYER_SELECTED: "canvas", |
delegated_messages = {LAYER_SELECTED: "canvas", |
67 |
SHAPES_SELECTED: "canvas"} |
SHAPES_SELECTED: "canvas", |
68 |
|
MAP_REPLACED: "canvas"} |
69 |
|
|
70 |
# Methods delegated to some instance variables. The delegation is |
# Methods delegated to some instance variables. The delegation is |
71 |
# implemented in the __getattr__ method. |
# implemented in the __getattr__ method. |
366 |
result = wxID_NO |
result = wxID_NO |
367 |
return result |
return result |
368 |
|
|
|
def prepare_new_session(self): |
|
|
for d in self.dialogs.values(): |
|
|
if not isinstance(d, tree.SessionTreeView): |
|
|
d.Close() |
|
|
|
|
369 |
def NewSession(self): |
def NewSession(self): |
370 |
if self.save_modified_session() != wxID_CANCEL: |
if self.save_modified_session() != wxID_CANCEL: |
|
self.prepare_new_session() |
|
371 |
self.application.SetSession(create_empty_session()) |
self.application.SetSession(create_empty_session()) |
372 |
|
|
373 |
def OpenSession(self): |
def OpenSession(self): |
376 |
"Thuban Session File (*.thuban)|*.thuban", |
"Thuban Session File (*.thuban)|*.thuban", |
377 |
wxOPEN) |
wxOPEN) |
378 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
|
self.prepare_new_session() |
|
379 |
self.application.OpenSession(dlg.GetPath()) |
self.application.OpenSession(dlg.GetPath()) |
380 |
dlg.Destroy() |
dlg.Destroy() |
381 |
|
|
441 |
return self.get_open_dialog("session_tree") is not None |
return self.get_open_dialog("session_tree") is not None |
442 |
|
|
443 |
def About(self): |
def About(self): |
444 |
self.RunMessageBox(_("About"), |
dlg = About(self) |
445 |
_("Thuban %s\n" |
dlg.ShowModal() |
446 |
#"Build Date: %s\n" |
dlg.Destroy() |
|
"using:\n" |
|
|
" %s\n" |
|
|
" %s\n\n" |
|
|
"Thuban is a program for\n" |
|
|
"exploring geographic data.\n" |
|
|
"Copyright (C) 2001-2003 Intevation GmbH.\n" |
|
|
"Thuban is licensed under the GNU GPL" |
|
|
% (Thuban.version.longversion, |
|
|
"wxPython %s" % wxPython_version, |
|
|
"Python %d.%d.%d" % sys.version_info[:3] |
|
|
)), |
|
|
# % __ThubanVersion__), #__BuildDate__)), |
|
|
wxOK | wxICON_INFORMATION) |
|
447 |
|
|
448 |
def AddLayer(self): |
def AddLayer(self): |
449 |
dlg = wxFileDialog(self, _("Select a data file"), ".", "", "*.*", |
dlg = wxFileDialog(self, _("Select a data file"), ".", "", "*.*", |
658 |
else: |
else: |
659 |
dialog.Show(not dialog.IsShown()) |
dialog.Show(not dialog.IsShown()) |
660 |
|
|
|
self.canvas.FitMapToWindow() |
|
|
|
|
661 |
def LegendShown(self): |
def LegendShown(self): |
662 |
"""Return true iff the legend is currently open""" |
"""Return true iff the legend is currently open""" |
663 |
dialog = self.FindRegisteredDock("legend") |
dialog = self.FindRegisteredDock("legend") |
733 |
table) |
table) |
734 |
self.add_dialog(name, dialog) |
self.add_dialog(name, dialog) |
735 |
dialog.Show(True) |
dialog.Show(True) |
736 |
# FIXME: else bring dialog to front |
dialog.Raise() |
737 |
|
|
738 |
def TableRename(self): |
def TableRename(self): |
739 |
"""Let the user rename a table""" |
"""Let the user rename a table""" |
1124 |
"selected_full_extent", |
"selected_full_extent", |
1125 |
None, |
None, |
1126 |
"map_identify_tool", "map_label_tool"]) |
"map_identify_tool", "map_label_tool"]) |
1127 |
|
|