/[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 821 by jonathan, Mon May 5 18:20:15 2003 UTC revision 879 by jonathan, Fri May 9 16:33:10 2003 UTC
# Line 39  from command import registry, Command, T Line 39  from command import registry, Command, T
39  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION
40    
41  from Thuban.UI.dock import DockFrame  from Thuban.UI.dock import DockFrame
42    from Thuban.UI.join import JoinDialog
43    
44  import resource  import resource
45    
# Line 60  class MainWindow(DockFrame): Line 61  class MainWindow(DockFrame):
61      # implemented in the __getattr__ method.      # implemented in the __getattr__ method.
62      delegated_methods = {"SelectLayer": "canvas",      delegated_methods = {"SelectLayer": "canvas",
63                           "SelectShapes": "canvas",                           "SelectShapes": "canvas",
64                             "SelectedShapes": "canvas",
65                           }                           }
66    
67      def __init__(self, parent, ID, title, application, interactor,      def __init__(self, parent, ID, title, application, interactor,
# Line 363  class MainWindow(DockFrame): Line 365  class MainWindow(DockFrame):
365    
366      def OpenSession(self):      def OpenSession(self):
367          self.save_modified_session()          self.save_modified_session()
368          dlg = wxFileDialog(self, _("Open Session"), ".", "", "*.thuban", wxOPEN)          dlg = wxFileDialog(self, _("Open Session"), ".", "",
369                               "Thuban Session File (*.thuban)|*.thuban", wxOPEN)
370          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
371              self.prepare_new_session()              self.prepare_new_session()
372              self.application.OpenSession(dlg.GetPath())              self.application.OpenSession(dlg.GetPath())
# Line 377  class MainWindow(DockFrame): Line 380  class MainWindow(DockFrame):
380    
381      def SaveSessionAs(self):      def SaveSessionAs(self):
382          dlg = wxFileDialog(self, _("Save Session As"), ".", "",          dlg = wxFileDialog(self, _("Save Session As"), ".", "",
383                             "*.thuban", wxSAVE|wxOVERWRITE_PROMPT)                             "Thuban Session File (*.thuban)|*.thuban",
384                               wxSAVE|wxOVERWRITE_PROMPT)
385          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
386              self.application.session.SetFilename(dlg.GetPath())              self.application.session.SetFilename(dlg.GetPath())
387              self.application.SaveSession()              self.application.SaveSession()
# Line 500  class MainWindow(DockFrame): Line 504  class MainWindow(DockFrame):
504          """Return true if a layer is currently selected"""          """Return true if a layer is currently selected"""
505          return self.canvas.HasSelectedLayer()          return self.canvas.HasSelectedLayer()
506    
507      def choose_color(self):      def has_selected_shapes(self):
508          """Run the color selection dialog and return the selected color.          """Return true if a shape is currently selected"""
509            return self.canvas.HasSelectedShapes()
         If the user cancels, return None.  
         """  
         dlg = wxColourDialog(self)  
         color = None  
         if dlg.ShowModal() == wxID_OK:  
             data = dlg.GetColourData()  
             wxc = data.GetColour()  
             color = Color(wxc.Red() / 255.0,  
                           wxc.Green() / 255.0,  
                           wxc.Blue() / 255.0)  
         dlg.Destroy()  
         return color  
510    
511      def HideLayer(self):      def HideLayer(self):
512          layer = self.current_layer()          layer = self.current_layer()
# Line 591  class MainWindow(DockFrame): Line 583  class MainWindow(DockFrame):
583              dialog.Show()              dialog.Show()
584          dialog.Raise()          dialog.Raise()
585    
586        def LayerJoinTable(self):
587            print "LayerJoinTable"
588    
589        def LayerUnjoinTable(self):
590            print "LayerUnjoinTable"
591    
592      def ShowLegend(self):      def ShowLegend(self):
593          if not self.LegendShown():          if not self.LegendShown():
# Line 615  class MainWindow(DockFrame): Line 612  class MainWindow(DockFrame):
612          dialog = self.FindRegisteredDock("legend")          dialog = self.FindRegisteredDock("legend")
613          return dialog is not None and dialog.IsShown()          return dialog is not None and dialog.IsShown()
614    
615        def TableOpen(self):
616            print "TableOpen"
617            dlg = wxFileDialog(self, _("Open Table"), ".", "",
618                               "DBF Files (*.dbf)|*.dbf|" +
619                               "CSV Files (*.csv)|*.csv|" +
620                               "All Files (*.*)|*.*",
621                               wxOPEN)
622            if dlg.ShowModal() == wxID_OK:
623                #self.application.session.OpenTable(dlg.GetPath())
624                pass
625    
626            dlg.Destroy()
627    
628        def TableClose(self):
629            print "TableClose"
630    
631        def TableShow(self):
632            print "TableShow"
633    
634        def TableHide(self):
635            print "TableHide"
636    
637        def TableJoin(self):
638            print "TableJoin"
639            dlg = JoinDialog(self, _("Join Tables"), self.application.session)
640            if dlg.ShowModal() == wxID_OK:
641                print "OK"
642    
643      def ZoomInTool(self):      def ZoomInTool(self):
644          self.canvas.ZoomInTool()          self.canvas.ZoomInTool()
645    
# Line 637  class MainWindow(DockFrame): Line 662  class MainWindow(DockFrame):
662      def FullLayerExtent(self):      def FullLayerExtent(self):
663          self.canvas.FitLayerToWindow(self.current_layer())          self.canvas.FitLayerToWindow(self.current_layer())
664    
665        def FullSelectionExtent(self):
666            self.canvas.FitSelectedToWindow()
667    
668      def PrintMap(self):      def PrintMap(self):
669          self.canvas.Print()          self.canvas.Print()
670    
# Line 718  def _has_selected_layer(context): Line 746  def _has_selected_layer(context):
746      """Return true if a layer is selected in the context"""      """Return true if a layer is selected in the context"""
747      return context.mainwindow.has_selected_layer()      return context.mainwindow.has_selected_layer()
748    
749    def _has_selected_shapes(context):
750        """Return true if a layer is selected in the context"""
751        return context.mainwindow.has_selected_shapes()
752    
753  def _can_remove_layer(context):  def _can_remove_layer(context):
754      return context.mainwindow.CanRemoveLayer()      return context.mainwindow.CanRemoveLayer()
755    
# Line 779  _method_command("map_full_extent", _("&F Line 811  _method_command("map_full_extent", _("&F
811                 helptext = _("Full Extent"), icon = "fullextent",                 helptext = _("Full Extent"), icon = "fullextent",
812                sensitive = _has_visible_map)                sensitive = _has_visible_map)
813  _method_command("layer_full_extent", _("&Full layer extent"), "FullLayerExtent",  _method_command("layer_full_extent", _("&Full layer extent"), "FullLayerExtent",
814                 helptext = _("Full Layer Extent"), icon = "fullextent",                 helptext = _("Full Layer Extent"), icon = "fulllayerextent",
815                sensitive = _has_selected_layer)                sensitive = _has_selected_layer)
816    _method_command("selected_full_extent", _("&Full selection extent"), "FullSelectionExtent",
817                   helptext = _("Full Selection Extent"), icon = "fullselextent",
818                  sensitive = _has_selected_shapes)
819  _method_command("map_print", _("Prin&t"), "PrintMap",  _method_command("map_print", _("Prin&t"), "PrintMap",
820                  helptext = _("Print the map"))                  helptext = _("Print the map"))
821  _method_command("map_rename", _("&Rename..."), "RenameMap",  _method_command("map_rename", _("&Rename..."), "RenameMap",
# Line 811  _method_command("layer_show_table", _("S Line 846  _method_command("layer_show_table", _("S
846                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
847  _method_command("layer_properties", _("&Properties..."), "LayerEditProperties",  _method_command("layer_properties", _("&Properties..."), "LayerEditProperties",
848                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
849    _method_command("layer_jointable", _("&Join Table..."), "LayerJoinTable",
850                    sensitive = _has_selected_layer)
851    _method_command("layer_unjointable", _("&Unjoin Table..."), "LayerUnjoinTable",
852                    sensitive = _has_selected_layer)
853    
854    # Table menu
855    _method_command("table_open", _("&Open..."), "TableOpen")
856    _method_command("table_close", _("&Close"), "TableClose")
857    _method_command("table_show", _("&Show"), "TableShow")
858    _method_command("table_hide", _("&Hide"), "TableHide")
859    _method_command("table_join", _("&Join..."), "TableJoin")
860    
861  # the menu structure  # the menu structure
862  main_menu = Menu("<main>", "<main>",  main_menu = Menu("<main>", "<main>",
# Line 825  main_menu = Menu("<main>", "<main>", Line 871  main_menu = Menu("<main>", "<main>",
871                          "map_projection",                          "map_projection",
872                          None,                          None,
873                          "map_zoom_in_tool", "map_zoom_out_tool",                          "map_zoom_in_tool", "map_zoom_out_tool",
874                          "map_pan_tool", "map_full_extent", "layer_full_extent",                          "map_pan_tool",
875                            "map_full_extent",
876                            "layer_full_extent",
877                            "selected_full_extent",
878                          None,                          None,
879                          "map_identify_tool", "map_label_tool",                          "map_identify_tool", "map_label_tool",
880                          None,                          None,
# Line 837  main_menu = Menu("<main>", "<main>", Line 886  main_menu = Menu("<main>", "<main>",
886                          None,                          None,
887                          "layer_show", "layer_hide",                          "layer_show", "layer_hide",
888                          None,                          None,
889                            "layer_projection",
890                            None,
891                          "layer_show_table",                          "layer_show_table",
892                            "layer_jointable",
893                            "layer_unjointable",
894                          None,                          None,
                         "layer_projection",  
895                          "layer_properties"]),                          "layer_properties"]),
896                      Menu("table", _("&Table"),
897                           ["table_open", "table_close",
898                           None,
899                           "table_show", "table_hide",
900                           None,
901                           "table_join"]),
902                    Menu("help", _("&Help"),                    Menu("help", _("&Help"),
903                         ["help_about"])])                         ["help_about"])])
904    
# Line 848  main_menu = Menu("<main>", "<main>", Line 906  main_menu = Menu("<main>", "<main>",
906    
907  main_toolbar = Menu("<toolbar>", "<toolbar>",  main_toolbar = Menu("<toolbar>", "<toolbar>",
908                      ["map_zoom_in_tool", "map_zoom_out_tool", "map_pan_tool",                      ["map_zoom_in_tool", "map_zoom_out_tool", "map_pan_tool",
909                       "map_full_extent", None,                       "map_full_extent",
910                         "layer_full_extent",
911                         "selected_full_extent",
912                         None,
913                       "map_identify_tool", "map_label_tool"])                       "map_identify_tool", "map_label_tool"])

Legend:
Removed from v.821  
changed lines
  Added in v.879

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26