/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/mainwindow.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/mainwindow.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 621 by jonathan, Mon Apr 7 10:14:50 2003 UTC revision 640 by jonathan, Thu Apr 10 14:36:08 2003 UTC
# Line 30  import view Line 30  import view
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    
# Line 403  class MainWindow(DockFrame): Line 403  class MainWindow(DockFrame):
403    
404      def SetMap(self, map):      def SetMap(self, map):
405          self.canvas.SetMap(map)          self.canvas.SetMap(map)
406            self.SetTitle("Thuban - " + map.Title())
407          #self.legendPanel.SetMap(map)          #self.legendPanel.SetMap(map)
408    
409      def Map(self):      def Map(self):
# Line 413  class MainWindow(DockFrame): Line 414  class MainWindow(DockFrame):
414    
415          return self.canvas.Map()          return self.canvas.Map()
416    
417      def ShowSessionTree(self):      def ToggleSessionTree(self):
418            """If the session tree is shown close it otherwise create a new tree"""
419          name = "session_tree"          name = "session_tree"
420          dialog = self.get_open_dialog(name)          dialog = self.get_open_dialog(name)
421          if dialog is None:          if dialog is None:
# Line 421  class MainWindow(DockFrame): Line 423  class MainWindow(DockFrame):
423              self.add_dialog(name, dialog)              self.add_dialog(name, dialog)
424              dialog.Show(True)              dialog.Show(True)
425          else:          else:
426              # FIXME: bring dialog to front here              dialog.Close()
             pass  
427    
428        def SessionTreeShown(self):
429            """Return true iff the session tree is currently shown"""
430            return self.get_open_dialog("session_tree") is not None
431    
432      def About(self):      def About(self):
433          self.RunMessageBox(_("About"),          self.RunMessageBox(_("About"),
# Line 514  class MainWindow(DockFrame): Line 518  class MainWindow(DockFrame):
518          dlg.Destroy()          dlg.Destroy()
519          return color          return color
520    
     def LayerFillColor(self):  
         layer = self.current_layer()  
         if layer is not None:  
             color = self.choose_color()  
             if color is not None:  
                 layer.GetClassification().SetDefaultFill(color)  
   
     def LayerTransparentFill(self):  
         layer = self.current_layer()  
         if layer is not None:  
             layer.GetClassification().SetDefaultFill(Color.Transparent)  
   
     def LayerOutlineColor(self):  
         layer = self.current_layer()  
         if layer is not None:  
             color = self.choose_color()  
             if color is not None:  
                 layer.GetClassification().SetDefaultLineColor(color)  
   
     def LayerNoOutline(self):  
         layer = self.current_layer()  
         if layer is not None:  
             layer.GetClassification().SetDefaultLineColor(Color.Transparent)  
   
521      def HideLayer(self):      def HideLayer(self):
522          layer = self.current_layer()          layer = self.current_layer()
523          if layer is not None:          if layer is not None:
# Line 581  class MainWindow(DockFrame): Line 561  class MainWindow(DockFrame):
561              map.SetProjection(proj)              map.SetProjection(proj)
562          proj4Dlg.Destroy()          proj4Dlg.Destroy()
563    
564      def Classify(self):      def LayerEditProperties(self):
565    
566          #          #
567          # the menu option for this should only be available if there          # the menu option for this should only be available if there
# Line 590  class MainWindow(DockFrame): Line 570  class MainWindow(DockFrame):
570          #          #
571    
572          layer = self.current_layer()          layer = self.current_layer()
573          self.OpenClassifier(layer)          self.OpenLayerProperties(layer)
574    
575      def OpenClassifier(self, layer, group = None):      def OpenLayerProperties(self, layer, group = None):
576          name = "classifier" + str(id(layer))          name = "layer_properties" + str(id(layer))
577          dialog = self.get_open_dialog(name)          dialog = self.get_open_dialog(name)
578    
579          if dialog is None:          if dialog is None:
580              dialog = classifier.Classifier(self, name, layer, group)              dialog = Classifier(self, name, layer, group)
581              self.add_dialog(name, dialog)              self.add_dialog(name, dialog)
582              dialog.Show()              dialog.Show()
583          dialog.Raise()          dialog.Raise()
584    
585    
586      def ShowLegend(self):      def ShowLegend(self):
587            if not self.LegendShown():
588                self.ToggleLegend()
589    
590        def ToggleLegend(self):
591            """Show the legend if it's not shown otherwise hide it again"""
592          name = "legend"          name = "legend"
593          dialog = self.FindRegisteredDock(name)          dialog = self.FindRegisteredDock(name)
594    
595          if dialog is None:          if dialog is None:
596              title = "Legend: %s" % self.Map().Title()              dialog = self.CreateDock(name, -1, _("Legend"), wxLAYOUT_LEFT)
             dialog = self.CreateDock(name, -1, title, wxLAYOUT_LEFT)  
597              legend.LegendPanel(dialog, None, self)              legend.LegendPanel(dialog, None, self)
598              dialog.Dock()              dialog.Dock()
599                dialog.GetPanel().SetMap(self.Map())
600                dialog.Show()
601            else:
602                dialog.Show(not dialog.IsShown())
603    
604          dialog.GetPanel().SetMap(self.Map())      def LegendShown(self):
605          dialog.Show()          """Return true iff the legend is currently open"""
606            dialog = self.FindRegisteredDock("legend")
607            return dialog is not None and dialog.IsShown()
608    
609      def ZoomInTool(self):      def ZoomInTool(self):
610          self.canvas.ZoomInTool()          self.canvas.ZoomInTool()
# Line 660  def call_method(context, methodname, *ar Line 650  def call_method(context, methodname, *ar
650      apply(getattr(context.mainwindow, methodname), args)      apply(getattr(context.mainwindow, methodname), args)
651    
652  def _method_command(name, title, method, helptext = "",  def _method_command(name, title, method, helptext = "",
653                      icon = "", sensitive = None):                      icon = "", sensitive = None, checked = None):
654      """Add a command implemented by a method of the mainwindow object"""      """Add a command implemented by a method of the mainwindow object"""
655      registry.Add(Command(name, title, call_method, args=(method,),      registry.Add(Command(name, title, call_method, args=(method,),
656                           helptext = helptext, icon = icon,                           helptext = helptext, icon = icon,
657                           sensitive = sensitive))                           sensitive = sensitive, checked = checked))
658    
659  def make_check_current_tool(toolname):  def make_check_current_tool(toolname):
660      """Return a function that tests if the currently active tool is toolname      """Return a function that tests if the currently active tool is toolname
# Line 694  def _can_remove_layer(context): Line 684  def _can_remove_layer(context):
684    
685  def _has_tree_window_shown(context):  def _has_tree_window_shown(context):
686      """Return true if the tree window is shown"""      """Return true if the tree window is shown"""
687      return context.mainwindow.get_open_dialog("session_tree") is None      return context.mainwindow.SessionTreeShown()
688    
689  def _has_visible_map(context):  def _has_visible_map(context):
690      """Return true iff theres a visible map in the mainwindow.      """Return true iff theres a visible map in the mainwindow.
# Line 709  def _has_visible_map(context): Line 699  def _has_visible_map(context):
699    
700  def _has_legend_shown(context):  def _has_legend_shown(context):
701      """Return true if the legend window is shown"""      """Return true if the legend window is shown"""
702      return context.mainwindow.FindRegisteredDock("legend") is None      return context.mainwindow.LegendShown()
703    
704    
705  # File menu  # File menu
# Line 717  _method_command("new_session", _("&New S Line 707  _method_command("new_session", _("&New S
707  _method_command("open_session", _("&Open Session"), "OpenSession")  _method_command("open_session", _("&Open Session"), "OpenSession")
708  _method_command("save_session", _("&Save Session"), "SaveSession")  _method_command("save_session", _("&Save Session"), "SaveSession")
709  _method_command("save_session_as", _("Save Session &As"), "SaveSessionAs")  _method_command("save_session_as", _("Save Session &As"), "SaveSessionAs")
710  _method_command("show_session_tree", _("Session &Tree"), "ShowSessionTree",  _method_command("toggle_session_tree", _("Session &Tree"), "ToggleSessionTree",
711                  sensitive = _has_tree_window_shown)                  checked = _has_tree_window_shown)
712  _method_command("show_legend", _("Legend"), "ShowLegend",  _method_command("toggle_legend", _("Legend"), "ToggleLegend",
713                  sensitive = _has_legend_shown)                  checked = _has_legend_shown)
714  _method_command("exit", _("E&xit"), "Exit")  _method_command("exit", _("E&xit"), "Exit")
715    
716  # Help menu  # Help menu
# Line 758  _method_command("layer_add", _("&Add Lay Line 748  _method_command("layer_add", _("&Add Lay
748  _method_command("layer_remove", _("&Remove Layer"), "RemoveLayer",  _method_command("layer_remove", _("&Remove Layer"), "RemoveLayer",
749                  helptext = _("Remove selected layer(s)"),                  helptext = _("Remove selected layer(s)"),
750                  sensitive = _can_remove_layer)                  sensitive = _can_remove_layer)
 _method_command("layer_fill_color", _("&Fill Color"), "LayerFillColor",  
                 helptext = _("Set the fill color of selected layer(s)"),  
                 sensitive = _has_selected_layer)  
 _method_command("layer_transparent_fill", _("&Transparent Fill"),  
                 "LayerTransparentFill",  
                 helptext = _("Do not fill the selected layer(s)"),  
                 sensitive = _has_selected_layer)  
 _method_command("layer_outline_color", _("&Outline Color"), "LayerOutlineColor",  
                 helptext = _("Set the outline color of selected layer(s)"),  
                 sensitive = _has_selected_layer)  
 _method_command("layer_no_outline", _("&No Outline"), "LayerNoOutline",  
                 helptext= _("Do not draw the outline of the selected layer(s)"),  
                 sensitive = _has_selected_layer)  
751  _method_command("layer_raise", _("&Raise"), "RaiseLayer",  _method_command("layer_raise", _("&Raise"), "RaiseLayer",
752                  helptext = _("Raise selected layer(s)"),                  helptext = _("Raise selected layer(s)"),
753                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
# Line 786  _method_command("layer_hide", _("&Hide") Line 763  _method_command("layer_hide", _("&Hide")
763  _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable",  _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable",
764                  helptext = _("Show the selected layer's table"),                  helptext = _("Show the selected layer's table"),
765                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
766  _method_command("layer_classifier", _("Classify"), "Classify",  _method_command("layer_properties", _("Properties"), "LayerEditProperties",
767                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
768    
769  # the menu structure  # the menu structure
# Line 794  main_menu = Menu("<main>", "<main>", Line 771  main_menu = Menu("<main>", "<main>",
771                   [Menu("file", _("&File"),                   [Menu("file", _("&File"),
772                         ["new_session", "open_session", None,                         ["new_session", "open_session", None,
773                          "save_session", "save_session_as", None,                          "save_session", "save_session_as", None,
774                          "show_session_tree",                          "toggle_session_tree", None,
                         "show_legend", None,  
775                          "exit"]),                          "exit"]),
776                    Menu("map", _("&Map"),                    Menu("map", _("&Map"),
777                         ["layer_add", "layer_remove",                         ["layer_add", "layer_remove",
# Line 807  main_menu = Menu("<main>", "<main>", Line 783  main_menu = Menu("<main>", "<main>",
783                          None,                          None,
784                          "map_full_extent",                          "map_full_extent",
785                          None,                          None,
786                            "toggle_legend",
787                            None,
788                          "map_print"]),                          "map_print"]),
789                    Menu("layer", _("&Layer"),                    Menu("layer", _("&Layer"),
790                         ["layer_fill_color", "layer_transparent_fill",                          ["layer_raise", "layer_lower",
                         "layer_outline_color", "layer_no_outline",  
                         None,  
                         "layer_raise", "layer_lower",  
791                          None,                          None,
792                          "layer_show", "layer_hide",                          "layer_show", "layer_hide",
793                          None,                          None,
794                          "layer_show_table",                          "layer_show_table",
795                          None,                          None,
796                          "layer_classifier"]),                          "layer_properties"]),
797                    Menu("help", _("&Help"),                    Menu("help", _("&Help"),
798                         ["help_about"])])                         ["help_about"])])
799    

Legend:
Removed from v.621  
changed lines
  Added in v.640

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26