/[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 796 by jonathan, Wed Apr 30 17:01:18 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 634  class MainWindow(DockFrame): Line 659  class MainWindow(DockFrame):
659      def FullExtent(self):      def FullExtent(self):
660          self.canvas.FitMapToWindow()          self.canvas.FitMapToWindow()
661    
662        def FullLayerExtent(self):
663            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 715  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 740  def _has_legend_shown(context): Line 775  def _has_legend_shown(context):
775    
776  # File menu  # File menu
777  _method_command("new_session", _("&New Session"), "NewSession")  _method_command("new_session", _("&New Session"), "NewSession")
778  _method_command("open_session", _("&Open Session"), "OpenSession")  _method_command("open_session", _("&Open Session..."), "OpenSession")
779  _method_command("save_session", _("&Save Session"), "SaveSession")  _method_command("save_session", _("&Save Session"), "SaveSession")
780  _method_command("save_session_as", _("Save Session &As"), "SaveSessionAs")  _method_command("save_session_as", _("Save Session &As..."), "SaveSessionAs")
781  _method_command("toggle_session_tree", _("Session &Tree"), "ToggleSessionTree",  _method_command("toggle_session_tree", _("Session &Tree"), "ToggleSessionTree",
782                  checked = _has_tree_window_shown)                  checked = _has_tree_window_shown)
783  _method_command("toggle_legend", _("Legend"), "ToggleLegend",  _method_command("toggle_legend", _("Legend"), "ToggleLegend",
# Line 750  _method_command("toggle_legend", _("Lege Line 785  _method_command("toggle_legend", _("Lege
785  _method_command("exit", _("E&xit"), "Exit")  _method_command("exit", _("E&xit"), "Exit")
786    
787  # Help menu  # Help menu
788  _method_command("help_about", _("&About"), "About")  _method_command("help_about", _("&About..."), "About")
789    
790    
791  # Map menu  # Map menu
792  _method_command("map_projection", _("Pro&jection"), "MapProjection")  _method_command("map_projection", _("Pro&jection..."), "MapProjection")
793    
794  _tool_command("map_zoom_in_tool", _("&Zoom in"), "ZoomInTool", "ZoomInTool",  _tool_command("map_zoom_in_tool", _("&Zoom in"), "ZoomInTool", "ZoomInTool",
795                helptext = _("Switch to map-mode 'zoom-in'"), icon = "zoom_in",                helptext = _("Switch to map-mode 'zoom-in'"), icon = "zoom_in",
# Line 775  _tool_command("map_label_tool", _("&Labe Line 810  _tool_command("map_label_tool", _("&Labe
810  _method_command("map_full_extent", _("&Full extent"), "FullExtent",  _method_command("map_full_extent", _("&Full extent"), "FullExtent",
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",
814                   helptext = _("Full Layer Extent"), icon = "fulllayerextent",
815                  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",
822                  helptext = _("Rename the map"))                  helptext = _("Rename the map"))
823  _method_command("layer_add", _("&Add Layer"), "AddLayer",  _method_command("layer_add", _("&Add Layer..."), "AddLayer",
824                  helptext = _("Add a new layer to active map"))                  helptext = _("Add a new layer to active map"))
825  _method_command("layer_remove", _("&Remove Layer"), "RemoveLayer",  _method_command("layer_remove", _("&Remove Layer"), "RemoveLayer",
826                  helptext = _("Remove selected layer(s)"),                  helptext = _("Remove selected layer(s)"),
827                  sensitive = _can_remove_layer)                  sensitive = _can_remove_layer)
828    
829  # Layer menu  # Layer menu
830  _method_command("layer_projection", _("Pro&jection"), "LayerProjection",  _method_command("layer_projection", _("Pro&jection..."), "LayerProjection",
831                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
832  _method_command("layer_raise", _("&Raise"), "RaiseLayer",  _method_command("layer_raise", _("&Raise"), "RaiseLayer",
833                  helptext = _("Raise selected layer(s)"),                  helptext = _("Raise selected layer(s)"),
# Line 803  _method_command("layer_hide", _("&Hide") Line 844  _method_command("layer_hide", _("&Hide")
844  _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable",  _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable",
845                  helptext = _("Show the selected layer's table"),                  helptext = _("Show the selected layer's table"),
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)
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)                  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>",
863                   [Menu("file", _("&File"),                   [Menu("file", _("&File"),
# Line 819  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_identify_tool", "map_label_tool",                          "map_pan_tool",
875                            "map_full_extent",
876                            "layer_full_extent",
877                            "selected_full_extent",
878                          None,                          None,
879                          "map_full_extent",                          "map_identify_tool", "map_label_tool",
880                          None,                          None,
881                          "toggle_legend",                          "toggle_legend",
882                          None,                          None,
# Line 831  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_show_table",                          "layer_projection",
890                          None,                          None,
891                          "layer_properties",                          "layer_show_table",
892                            "layer_jointable",
893                            "layer_unjointable",
894                          None,                          None,
895                          "layer_projection"]),                          "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 843  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.796  
changed lines
  Added in v.879

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26