29 |
from Thuban import _ |
from Thuban import _ |
30 |
from Thuban.Model.session import create_empty_session |
from Thuban.Model.session import create_empty_session |
31 |
from Thuban.Model.layer import Layer, RasterLayer |
from Thuban.Model.layer import Layer, RasterLayer |
|
from Thuban.Model.color import Color |
|
|
from Thuban.Model.proj import Projection |
|
32 |
|
|
33 |
import view |
import view |
34 |
import tree |
import tree |
|
import proj4dialog |
|
35 |
import tableview, identifyview |
import tableview, identifyview |
36 |
from Thuban.UI.classifier import Classifier |
from Thuban.UI.classifier import Classifier |
37 |
import legend |
import legend |
64 |
# implemented in the __getattr__ method. |
# implemented in the __getattr__ method. |
65 |
delegated_methods = {"SelectLayer": "canvas", |
delegated_methods = {"SelectLayer": "canvas", |
66 |
"SelectShapes": "canvas", |
"SelectShapes": "canvas", |
67 |
|
"SelectedLayer": "canvas", |
68 |
"SelectedShapes": "canvas", |
"SelectedShapes": "canvas", |
69 |
} |
} |
70 |
|
|
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 |
|
for dlg in self.dialogs.values(): |
409 |
|
dlg.Destroy() |
410 |
|
self.canvas.Destroy() |
411 |
self.Destroy() |
self.Destroy() |
412 |
|
|
413 |
def SetMap(self, map): |
def SetMap(self, map): |
620 |
dialog.Raise() |
dialog.Raise() |
621 |
|
|
622 |
def LayerJoinTable(self): |
def LayerJoinTable(self): |
623 |
print "LayerJoinTable: Not implemented." |
layer = self.canvas.SelectedLayer() |
624 |
|
if layer is not None: |
625 |
|
dlg = JoinDialog(self, _("Join Layer with Table"), |
626 |
|
self.application.session, |
627 |
|
layer = layer) |
628 |
|
dlg.ShowModal() |
629 |
|
|
630 |
def LayerUnjoinTable(self): |
def LayerUnjoinTable(self): |
631 |
print "LayerUnjoinTable: Not implemented." |
layer = self.canvas.SelectedLayer() |
632 |
|
if layer is not None: |
633 |
|
orig_store = layer.ShapeStore().OrigShapeStore() |
634 |
|
if orig_store: |
635 |
|
layer.SetShapeStore(orig_store) |
636 |
|
|
637 |
def ShowLegend(self): |
def ShowLegend(self): |
638 |
if not self.LegendShown(): |
if not self.LegendShown(): |
664 |
_("All Files (*.*)") + "|*.*", |
_("All Files (*.*)") + "|*.*", |
665 |
wxOPEN) |
wxOPEN) |
666 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
667 |
self.application.session.OpenTableFile(dlg.GetPath()) |
filename = dlg.GetPath() |
668 |
|
dlg.Destroy() |
669 |
dlg.Destroy() |
try: |
670 |
|
table = self.application.session.OpenTableFile(filename) |
671 |
|
except IOError: |
672 |
|
# the layer couldn't be opened |
673 |
|
self.RunMessageBox(_("Open Table"), |
674 |
|
_("Can't open the file '%s'.") % filename) |
675 |
|
else: |
676 |
|
self.ShowTableView(table) |
677 |
|
|
678 |
def TableClose(self): |
def TableClose(self): |
679 |
print "TableClose: not implemented" |
tables = self.application.session.UnreferencedTables() |
680 |
|
|
681 |
|
dlg = wxMultipleChoiceDialog(self, _("Pick the tables to close:"), |
682 |
|
_("Close Table"), |
683 |
|
[t.Title() for t in tables], |
684 |
|
size = (400, 300), style=wxRESIZE_BORDER) |
685 |
|
if dlg.ShowModal() == wxID_OK: |
686 |
|
for i in dlg.GetValue(): |
687 |
|
self.application.session.RemoveTable(tables[i]) |
688 |
|
|
689 |
|
|
690 |
def TableShow(self): |
def TableShow(self): |
691 |
"""Offer a multi-selection dialog for tables to be displayed |
"""Offer a multi-selection dialog for tables to be displayed |
692 |
|
|
693 |
The windows for the selected tables are opened or brought to |
The windows for the selected tables are opened or brought to |
694 |
the front. |
the front. |
695 |
""" |
""" |
696 |
tables = self.application.session.Tables() |
tables = self.application.session.Tables() |
|
table_list = [] |
|
|
for table in tables: |
|
|
table_list.append(table.Title()) |
|
697 |
|
|
698 |
dlg = wxMultipleChoiceDialog(self, _("Pick the table to show:"), |
dlg = wxMultipleChoiceDialog(self, _("Pick the table to show:"), |
699 |
_("Show Table"), table_list, |
_("Show Table"), |
700 |
|
[t.Title() for t in tables], |
701 |
size = (400,300), style = wxRESIZE_BORDER) |
size = (400,300), style = wxRESIZE_BORDER) |
702 |
if (dlg.ShowModal() == wxID_OK): |
if (dlg.ShowModal() == wxID_OK): |
703 |
for i in dlg.GetValue(): |
for i in dlg.GetValue(): |
|
# XXX: First check whether the dialog is already open |
|
|
# and if so, bring it to the front. |
|
704 |
# XXX: if the table belongs to a layer, open a |
# XXX: if the table belongs to a layer, open a |
705 |
# LayerTableFrame instead of QueryTableFrame |
# LayerTableFrame instead of QueryTableFrame |
706 |
print "tables[i]:", tables[i] |
self.ShowTableView(tables[i]) |
|
dialog = tableview.QueryTableFrame(self, table_list[i], |
|
|
_("Table: %s") % table_list[i], |
|
|
tables[i]) |
|
|
self.add_dialog(table_list[i], dialog) |
|
|
dialog.Show(True) |
|
|
|
|
|
# XXX: just some analyis code, remove it when the above XXX is |
|
|
# resolved. |
|
|
for d in self.dialogs.values(): |
|
|
if isinstance(d, tableview.LayerTableFrame): |
|
|
print "LayerTable:", d.GetTitle() |
|
|
elif isinstance(d, tableview.QueryTableFrame): |
|
|
print "QueryTable:", d.GetTitle() |
|
|
else: |
|
|
print "Other:", d.GetTitle() |
|
|
|
|
|
def TableHide(self): |
|
|
print "TableHide: not implemented" |
|
707 |
|
|
708 |
def TableJoin(self): |
def TableJoin(self): |
709 |
dlg = JoinDialog(self, _("Join Tables"), self.application.session) |
dlg = JoinDialog(self, _("Join Tables"), self.application.session) |
710 |
dlg.ShowModal() |
dlg.ShowModal() |
711 |
|
|
712 |
|
def ShowTableView(self, table): |
713 |
|
"""Open a table view for the table and optionally""" |
714 |
|
name = "table_view%d" % id(table) |
715 |
|
dialog = self.get_open_dialog(name) |
716 |
|
if dialog is None: |
717 |
|
dialog = tableview.QueryTableFrame(self, name, |
718 |
|
_("Table: %s") % table.Title(), |
719 |
|
table) |
720 |
|
self.add_dialog(name, dialog) |
721 |
|
dialog.Show(True) |
722 |
|
# FIXME: else bring dialog to front |
723 |
|
|
724 |
def ZoomInTool(self): |
def ZoomInTool(self): |
725 |
self.canvas.ZoomInTool() |
self.canvas.ZoomInTool() |
726 |
|
|
936 |
sensitive = _has_selected_layer) |
sensitive = _has_selected_layer) |
937 |
_method_command("layer_jointable", _("&Join Table..."), "LayerJoinTable", |
_method_command("layer_jointable", _("&Join Table..."), "LayerJoinTable", |
938 |
sensitive = _has_selected_layer) |
sensitive = _has_selected_layer) |
939 |
|
|
940 |
|
def _can_unjoin(context): |
941 |
|
layer = context.mainwindow.SelectedLayer() |
942 |
|
return bool(layer and layer.ShapeStore().OrigShapeStore() is not None) |
943 |
_method_command("layer_unjointable", _("&Unjoin Table..."), "LayerUnjoinTable", |
_method_command("layer_unjointable", _("&Unjoin Table..."), "LayerUnjoinTable", |
944 |
sensitive = _has_selected_layer) |
sensitive = _can_unjoin) |
945 |
|
|
946 |
# Table menu |
# Table menu |
947 |
_method_command("table_open", _("&Open..."), "TableOpen") |
_method_command("table_open", _("&Open..."), "TableOpen") |
948 |
_method_command("table_close", _("&Close"), "TableClose") |
_method_command("table_close", _("&Close"), "TableClose", |
949 |
|
sensitive = lambda context: bool(context.session.UnreferencedTables())) |
950 |
_method_command("table_show", _("&Show"), "TableShow") |
_method_command("table_show", _("&Show"), "TableShow") |
|
_method_command("table_hide", _("&Hide"), "TableHide") |
|
951 |
_method_command("table_join", _("&Join..."), "TableJoin") |
_method_command("table_join", _("&Join..."), "TableJoin") |
952 |
|
|
953 |
# Export only under Windows ... |
# Export only under Windows ... |
992 |
Menu("table", _("&Table"), |
Menu("table", _("&Table"), |
993 |
["table_open", "table_close", |
["table_open", "table_close", |
994 |
None, |
None, |
995 |
"table_show", "table_hide", |
"table_show", |
996 |
None, |
None, |
997 |
"table_join"]), |
"table_join"]), |
998 |
Menu("help", _("&Help"), |
Menu("help", _("&Help"), |