/[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 1140 by jan, Fri Jun 6 11:18:51 2003 UTC revision 1464 by bh, Fri Jul 18 18:20:40 2003 UTC
# Line 13  The main window Line 13  The main window
13    
14  __version__ = "$Revision$"  __version__ = "$Revision$"
15    
16  __ThubanVersion__ = "0.2" #"$THUBAN_0_2$"  __ThubanVersion__ = "0.8" #"$THUBAN_0_2$"
17  #__BuildDate__ = "$Date$"  #__BuildDate__ = "$Date$"
18    
19  import os  import os
# Line 22  import copy Line 22  import copy
22  from wxPython.wx import *  from wxPython.wx import *
23  from wxPython.wx import __version__ as wxPython_version  from wxPython.wx import __version__ as wxPython_version
24    
 from wxPython.lib.dialogs import wxMultipleChoiceDialog  
   
25  import Thuban  import Thuban
26  import Thuban.version  import Thuban.version
27    
# Line 31  from Thuban import _ Line 29  from Thuban import _
29  from Thuban.Model.session import create_empty_session  from Thuban.Model.session import create_empty_session
30  from Thuban.Model.layer import Layer, RasterLayer  from Thuban.Model.layer import Layer, RasterLayer
31    
32    # XXX: replace this by
33    # from wxPython.lib.dialogs import wxMultipleChoiceDialog
34    # when Thuban does not support wxPython 2.4.0 any more.
35    from Thuban.UI.multiplechoicedialog import wxMultipleChoiceDialog
36    
37  import view  import view
38  import tree  import tree
39  import tableview, identifyview  import tableview, identifyview
# Line 40  from menu import Menu Line 43  from menu import Menu
43    
44  from context import Context  from context import Context
45  from command import registry, Command, ToolCommand  from command import registry, Command, ToolCommand
46  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION, \
47         MAP_REPLACED
48    from about import About
49    
50  from Thuban.UI.dock import DockFrame  from Thuban.UI.dock import DockFrame
51  from Thuban.UI.join import JoinDialog  from Thuban.UI.join import JoinDialog
52    
53  import resource  import resource
54    import Thuban.Model.resource
55    
56  import projdialog  import projdialog
57    
58    
   
59  class MainWindow(DockFrame):  class MainWindow(DockFrame):
60    
61      # Some messages that can be subscribed/unsubscribed directly through      # Some messages that can be subscribed/unsubscribed directly through
# Line 59  class MainWindow(DockFrame): Line 64  class MainWindow(DockFrame):
64      # actually come from. This delegation is implemented in the      # actually come from. This delegation is implemented in the
65      # Subscribe and unsubscribed methods      # Subscribe and unsubscribed methods
66      delegated_messages = {LAYER_SELECTED: "canvas",      delegated_messages = {LAYER_SELECTED: "canvas",
67                            SHAPES_SELECTED: "canvas"}                            SHAPES_SELECTED: "canvas",
68                              MAP_REPLACED: "canvas"}
69    
70      # Methods delegated to some instance variables. The delegation is      # Methods delegated to some instance variables. The delegation is
71      # implemented in the __getattr__ method.      # implemented in the __getattr__ method.
# Line 105  class MainWindow(DockFrame): Line 111  class MainWindow(DockFrame):
111    
112          self.init_dialogs()          self.init_dialogs()
113    
114            self.ShowLegend()
115    
116          EVT_CLOSE(self, self.OnClose)          EVT_CLOSE(self, self.OnClose)
117    
118      def Subscribe(self, channel, *args):      def Subscribe(self, channel, *args):
# Line 358  class MainWindow(DockFrame): Line 366  class MainWindow(DockFrame):
366              result = wxID_NO              result = wxID_NO
367          return result          return result
368    
     def prepare_new_session(self):  
         for d in self.dialogs.values():  
             if not isinstance(d, tree.SessionTreeView):  
                 d.Close()  
   
369      def NewSession(self):      def NewSession(self):
370          if self.save_modified_session() != wxID_CANCEL:          if self.save_modified_session() != wxID_CANCEL:
             self.prepare_new_session()  
371              self.application.SetSession(create_empty_session())              self.application.SetSession(create_empty_session())
372    
373      def OpenSession(self):      def OpenSession(self):
# Line 374  class MainWindow(DockFrame): Line 376  class MainWindow(DockFrame):
376                                 "Thuban Session File (*.thuban)|*.thuban",                                 "Thuban Session File (*.thuban)|*.thuban",
377                                 wxOPEN)                                 wxOPEN)
378              if dlg.ShowModal() == wxID_OK:              if dlg.ShowModal() == wxID_OK:
                 self.prepare_new_session()  
379                  self.application.OpenSession(dlg.GetPath())                  self.application.OpenSession(dlg.GetPath())
380              dlg.Destroy()              dlg.Destroy()
381    
# Line 440  class MainWindow(DockFrame): Line 441  class MainWindow(DockFrame):
441          return self.get_open_dialog("session_tree") is not None          return self.get_open_dialog("session_tree") is not None
442    
443      def About(self):      def About(self):
444          self.RunMessageBox(_("About"),          dlg = About(self)
445                             _("Thuban %s\n"          dlg.ShowModal()
446                              #"Build Date: %s\n"          dlg.Destroy()
                             "using:\n"  
                             "  %s\n"  
                             "  %s\n\n"  
                             "Thuban is a program for\n"  
                             "exploring geographic data.\n"  
                             "Copyright (C) 2001-2003 Intevation GmbH.\n"  
                             "Thuban is licensed under the GNU GPL"  
                             % (Thuban.version.longversion,  
                                "wxPython %s" % wxPython_version,  
                                "Python %d.%d.%d" % sys.version_info[:3]  
                               )),  
 #                           % __ThubanVersion__), #__BuildDate__)),  
                            wxOK | wxICON_INFORMATION)  
447    
448      def AddLayer(self):      def AddLayer(self):
449          dlg = wxFileDialog(self, _("Select a data file"), ".", "", "*.*",          dlg = wxFileDialog(self, _("Select a data file"), ".", "", "*.*",
# Line 575  class MainWindow(DockFrame): Line 563  class MainWindow(DockFrame):
563      def LayerShowTable(self):      def LayerShowTable(self):
564          layer = self.current_layer()          layer = self.current_layer()
565          if layer is not None:          if layer is not None:
566              table = layer.table              table = layer.ShapeStore().Table()
567              name = "table_view" + str(id(table))              name = "table_view" + str(id(table))
568              dialog = self.get_open_dialog(name)              dialog = self.get_open_dialog(name)
569              if dialog is None:              if dialog is None:
# Line 632  class MainWindow(DockFrame): Line 620  class MainWindow(DockFrame):
620          dialog = self.get_open_dialog(name)          dialog = self.get_open_dialog(name)
621    
622          if dialog is None:          if dialog is None:
623              dialog = Classifier(self, name, layer, group)              dialog = Classifier(self, name, self.Map(), layer, group)
624              self.add_dialog(name, dialog)              self.add_dialog(name, dialog)
625              dialog.Show()              dialog.Show()
626          dialog.Raise()          dialog.Raise()
# Line 670  class MainWindow(DockFrame): Line 658  class MainWindow(DockFrame):
658          else:          else:
659              dialog.Show(not dialog.IsShown())              dialog.Show(not dialog.IsShown())
660    
         self.canvas.FitMapToWindow()  
   
661      def LegendShown(self):      def LegendShown(self):
662          """Return true iff the legend is currently open"""          """Return true iff the legend is currently open"""
663          dialog = self.FindRegisteredDock("legend")          dialog = self.FindRegisteredDock("legend")
# Line 747  class MainWindow(DockFrame): Line 733  class MainWindow(DockFrame):
733                                                 table)                                                 table)
734              self.add_dialog(name, dialog)              self.add_dialog(name, dialog)
735              dialog.Show(True)              dialog.Show(True)
736          # FIXME: else bring dialog to front          dialog.Raise()
737    
738      def TableRename(self):      def TableRename(self):
739          """Let the user rename a table"""          """Let the user rename a table"""
# Line 936  def _has_legend_shown(context): Line 922  def _has_legend_shown(context):
922      """Return true if the legend window is shown"""      """Return true if the legend window is shown"""
923      return context.mainwindow.LegendShown()      return context.mainwindow.LegendShown()
924    
925    def _has_gdal_support(context):
926        """Return True if the GDAL is available"""
927        return Thuban.Model.resource.has_gdal_support()
928    
929  # File menu  # File menu
930  _method_command("new_session", _("&New Session"), "NewSession",  _method_command("new_session", _("&New Session"), "NewSession",
# Line 999  _method_command("map_rename", _("&Rename Line 988  _method_command("map_rename", _("&Rename
988  _method_command("layer_add", _("&Add Layer..."), "AddLayer",  _method_command("layer_add", _("&Add Layer..."), "AddLayer",
989                  helptext = _("Add a new layer to the map"))                  helptext = _("Add a new layer to the map"))
990  _method_command("rasterlayer_add", _("&Add Image Layer..."), "AddRasterLayer",  _method_command("rasterlayer_add", _("&Add Image Layer..."), "AddRasterLayer",
991                  helptext = _("Add a new image layer to the map"))                  helptext = _("Add a new image layer to the map"),
992                    sensitive = _has_gdal_support)
993  _method_command("layer_remove", _("&Remove Layer"), "RemoveLayer",  _method_command("layer_remove", _("&Remove Layer"), "RemoveLayer",
994                  helptext = _("Remove selected layer"),                  helptext = _("Remove selected layer"),
995                  sensitive = _can_remove_layer)                  sensitive = _can_remove_layer)
# Line 1075  _method_command("table_join", _("&Join.. Line 1065  _method_command("table_join", _("&Join..
1065                  helptext = _("Join two tables creating a new one"))                  helptext = _("Join two tables creating a new one"))
1066    
1067  #  Export only under Windows ...  #  Export only under Windows ...
1068  map_menu = ["layer_add", "rasterlayer_add", "layer_remove", "map_rename",  map_menu = ["layer_add", "rasterlayer_add", "layer_remove",
1069                          None,                          None,
1070                            "map_rename",
1071                          "map_projection",                          "map_projection",
1072                          None,                          None,
1073                          "map_zoom_in_tool", "map_zoom_out_tool",                          "map_zoom_in_tool", "map_zoom_out_tool",
# Line 1133  main_toolbar = Menu("<toolbar>", "<toolb Line 1124  main_toolbar = Menu("<toolbar>", "<toolb
1124                       "selected_full_extent",                       "selected_full_extent",
1125                       None,                       None,
1126                       "map_identify_tool", "map_label_tool"])                       "map_identify_tool", "map_label_tool"])
1127    

Legend:
Removed from v.1140  
changed lines
  Added in v.1464

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26