30 |
import tree |
import tree |
31 |
import proj4dialog |
import proj4dialog |
32 |
import tableview, identifyview |
import tableview, identifyview |
33 |
import classifier |
from Thuban.UI.classifier import Classifier |
34 |
import legend |
import legend |
35 |
from menu import Menu |
from menu import Menu |
36 |
|
|
413 |
|
|
414 |
return self.canvas.Map() |
return self.canvas.Map() |
415 |
|
|
416 |
def ShowSessionTree(self): |
def ToggleSessionTree(self): |
417 |
|
"""If the session tree is shown close it otherwise create a new tree""" |
418 |
name = "session_tree" |
name = "session_tree" |
419 |
dialog = self.get_open_dialog(name) |
dialog = self.get_open_dialog(name) |
420 |
if dialog is None: |
if dialog is None: |
422 |
self.add_dialog(name, dialog) |
self.add_dialog(name, dialog) |
423 |
dialog.Show(True) |
dialog.Show(True) |
424 |
else: |
else: |
425 |
# FIXME: bring dialog to front here |
dialog.Close() |
|
pass |
|
426 |
|
|
427 |
|
def SessionTreeShown(self): |
428 |
|
"""Return true iff the session tree is currently shown""" |
429 |
|
return self.get_open_dialog("session_tree") is not None |
430 |
|
|
431 |
def About(self): |
def About(self): |
432 |
self.RunMessageBox(_("About"), |
self.RunMessageBox(_("About"), |
600 |
dialog = self.get_open_dialog(name) |
dialog = self.get_open_dialog(name) |
601 |
|
|
602 |
if dialog is None: |
if dialog is None: |
603 |
dialog = classifier.Classifier(self, name, layer, group) |
dialog = Classifier(self, name, layer, group) |
604 |
self.add_dialog(name, dialog) |
self.add_dialog(name, dialog) |
605 |
dialog.Show() |
dialog.Show() |
606 |
dialog.Raise() |
dialog.Raise() |
607 |
|
|
608 |
|
|
609 |
def ShowLegend(self): |
def ShowLegend(self): |
610 |
|
if not self.LegendShown(): |
611 |
|
self.ToggleLegend() |
612 |
|
|
613 |
|
def ToggleLegend(self): |
614 |
|
"""Show the legend if it's not shown otherwise hide it again""" |
615 |
name = "legend" |
name = "legend" |
616 |
dialog = self.FindRegisteredDock(name) |
dialog = self.FindRegisteredDock(name) |
617 |
|
|
620 |
dialog = self.CreateDock(name, -1, title, wxLAYOUT_LEFT) |
dialog = self.CreateDock(name, -1, title, wxLAYOUT_LEFT) |
621 |
legend.LegendPanel(dialog, None, self) |
legend.LegendPanel(dialog, None, self) |
622 |
dialog.Dock() |
dialog.Dock() |
623 |
|
dialog.GetPanel().SetMap(self.Map()) |
624 |
|
dialog.Show() |
625 |
|
else: |
626 |
|
dialog.Show(not dialog.IsShown()) |
627 |
|
|
628 |
dialog.GetPanel().SetMap(self.Map()) |
def LegendShown(self): |
629 |
dialog.Show() |
"""Return true iff the legend is currently open""" |
630 |
|
dialog = self.FindRegisteredDock("legend") |
631 |
|
return dialog is not None and dialog.IsShown() |
632 |
|
|
633 |
def ZoomInTool(self): |
def ZoomInTool(self): |
634 |
self.canvas.ZoomInTool() |
self.canvas.ZoomInTool() |
674 |
apply(getattr(context.mainwindow, methodname), args) |
apply(getattr(context.mainwindow, methodname), args) |
675 |
|
|
676 |
def _method_command(name, title, method, helptext = "", |
def _method_command(name, title, method, helptext = "", |
677 |
icon = "", sensitive = None): |
icon = "", sensitive = None, checked = None): |
678 |
"""Add a command implemented by a method of the mainwindow object""" |
"""Add a command implemented by a method of the mainwindow object""" |
679 |
registry.Add(Command(name, title, call_method, args=(method,), |
registry.Add(Command(name, title, call_method, args=(method,), |
680 |
helptext = helptext, icon = icon, |
helptext = helptext, icon = icon, |
681 |
sensitive = sensitive)) |
sensitive = sensitive, checked = checked)) |
682 |
|
|
683 |
def make_check_current_tool(toolname): |
def make_check_current_tool(toolname): |
684 |
"""Return a function that tests if the currently active tool is toolname |
"""Return a function that tests if the currently active tool is toolname |
708 |
|
|
709 |
def _has_tree_window_shown(context): |
def _has_tree_window_shown(context): |
710 |
"""Return true if the tree window is shown""" |
"""Return true if the tree window is shown""" |
711 |
return context.mainwindow.get_open_dialog("session_tree") is None |
return context.mainwindow.SessionTreeShown() |
712 |
|
|
713 |
def _has_visible_map(context): |
def _has_visible_map(context): |
714 |
"""Return true iff theres a visible map in the mainwindow. |
"""Return true iff theres a visible map in the mainwindow. |
723 |
|
|
724 |
def _has_legend_shown(context): |
def _has_legend_shown(context): |
725 |
"""Return true if the legend window is shown""" |
"""Return true if the legend window is shown""" |
726 |
return context.mainwindow.FindRegisteredDock("legend") is None |
return context.mainwindow.LegendShown() |
727 |
|
|
728 |
|
|
729 |
# File menu |
# File menu |
731 |
_method_command("open_session", _("&Open Session"), "OpenSession") |
_method_command("open_session", _("&Open Session"), "OpenSession") |
732 |
_method_command("save_session", _("&Save Session"), "SaveSession") |
_method_command("save_session", _("&Save Session"), "SaveSession") |
733 |
_method_command("save_session_as", _("Save Session &As"), "SaveSessionAs") |
_method_command("save_session_as", _("Save Session &As"), "SaveSessionAs") |
734 |
_method_command("show_session_tree", _("Session &Tree"), "ShowSessionTree", |
_method_command("toggle_session_tree", _("Session &Tree"), "ToggleSessionTree", |
735 |
sensitive = _has_tree_window_shown) |
checked = _has_tree_window_shown) |
736 |
_method_command("show_legend", _("Legend"), "ShowLegend", |
_method_command("toggle_legend", _("Legend"), "ToggleLegend", |
737 |
sensitive = _has_legend_shown) |
checked = _has_legend_shown) |
738 |
_method_command("exit", _("E&xit"), "Exit") |
_method_command("exit", _("E&xit"), "Exit") |
739 |
|
|
740 |
# Help menu |
# Help menu |
808 |
[Menu("file", _("&File"), |
[Menu("file", _("&File"), |
809 |
["new_session", "open_session", None, |
["new_session", "open_session", None, |
810 |
"save_session", "save_session_as", None, |
"save_session", "save_session_as", None, |
811 |
"show_session_tree", |
"toggle_session_tree", None, |
|
"show_legend", None, |
|
812 |
"exit"]), |
"exit"]), |
813 |
Menu("map", _("&Map"), |
Menu("map", _("&Map"), |
814 |
["layer_add", "layer_remove", |
["layer_add", "layer_remove", |
820 |
None, |
None, |
821 |
"map_full_extent", |
"map_full_extent", |
822 |
None, |
None, |
823 |
|
"toggle_legend", |
824 |
|
None, |
825 |
"map_print"]), |
"map_print"]), |
826 |
Menu("layer", _("&Layer"), |
Menu("layer", _("&Layer"), |
827 |
["layer_fill_color", "layer_transparent_fill", |
["layer_fill_color", "layer_transparent_fill", |