/[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 84 by bh, Wed Apr 3 15:21:46 2002 UTC revision 150 by bh, Tue May 7 16:55:38 2002 UTC
# Line 1  Line 1 
1  # Copyright (C) 2001 by Intevation GmbH  # Copyright (C) 2001, 2002 by Intevation GmbH
2  # Authors:  # Authors:
3  # Jan-Oliver Wagner <[email protected]>  # Jan-Oliver Wagner <[email protected]>
4  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
# Line 30  import tableview, identifyview Line 30  import tableview, identifyview
30    
31  import main  import main
32  from command import registry, Command  from command import registry, Command
33  from messages import SELECTED_SHAPE  from messages import SELECTED_SHAPE, VIEW_POSITION
34    
35    
36  # the directory where the toolbar icons are stored  # the directory where the toolbar icons are stored
# Line 60  class MainWindow(wxFrame): Line 60  class MainWindow(wxFrame):
60          menuBar.Append(menu, "&File");          menuBar.Append(menu, "&File");
61          for name in ["new_session", "open_session", None,          for name in ["new_session", "open_session", None,
62                       "save_session", "save_session_as", None,                       "save_session", "save_session_as", None,
63                         "show_session_tree", None,
64                       "exit"]:                       "exit"]:
65              self.add_menu_command(menu, name)              self.add_menu_command(menu, name)
66    
# Line 104  class MainWindow(wxFrame): Line 105  class MainWindow(wxFrame):
105          toolbar.SetToolBitmapSize(wxSize(24, 24))          toolbar.SetToolBitmapSize(wxSize(24, 24))
106    
107          for name in ["map_zoom_in_tool", "map_zoom_out_tool", "map_pan_tool",          for name in ["map_zoom_in_tool", "map_zoom_out_tool", "map_pan_tool",
108                       "map_identify_tool", "map_label_tool"]:                       "map_identify_tool", "map_label_tool", "map_full_extent"]:
109              self.add_toolbar_command(toolbar, name)              self.add_toolbar_command(toolbar, name)
110          # call Realize to make sure that the tools appear.          # call Realize to make sure that the tools appear.
111          toolbar.Realize()          toolbar.Realize()
112    
113          # Create the map canvas          # Create the map canvas
114          canvas = view.MapCanvas(self, -1, interactor)          canvas = view.MapCanvas(self, -1, interactor)
115            canvas.Subscribe(VIEW_POSITION, self.view_position_changed)
116          self.canvas = canvas          self.canvas = canvas
117    
118          self.init_dialogs()          self.init_dialogs()
# Line 223  class MainWindow(wxFrame): Line 225  class MainWindow(wxFrame):
225      def get_open_dialog(self, name):      def get_open_dialog(self, name):
226          return self.dialogs.get(name)          return self.dialogs.get(name)
227    
228        def view_position_changed(self):
229            pos = self.canvas.CurrentPosition()
230            if pos is not None:
231                text = "(%10.10g, %10.10g)" % pos
232            else:
233                text = ""
234            self.SetStatusText(text)
235    
236      def save_modified_session(self, can_veto = 1):      def save_modified_session(self, can_veto = 1):
237          """If the current session has been modified, ask the user          """If the current session has been modified, ask the user
238          whether to save it and do so if requested. Return the outcome of          whether to save it and do so if requested. Return the outcome of
# Line 253  class MainWindow(wxFrame): Line 263  class MainWindow(wxFrame):
263      def OpenSession(self):      def OpenSession(self):
264          self.save_modified_session()          self.save_modified_session()
265          dlg = wxFileDialog(self, "Select a session file", ".", "",          dlg = wxFileDialog(self, "Select a session file", ".", "",
266                             "*.session", wxOPEN)                             "*.thuban", wxOPEN)
267          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
268              main.app.OpenSession(dlg.GetPath())              main.app.OpenSession(dlg.GetPath())
269          dlg.Destroy()          dlg.Destroy()
270    
271      def SaveSession(self):      def SaveSession(self):
272            if main.app.session.filename == None:
273                self.SaveSessionAs()
274          main.app.SaveSession()          main.app.SaveSession()
275    
276      def SaveSessionAs(self):      def SaveSessionAs(self):
277          dlg = wxFileDialog(self, "Enter a filename for session", ".", "",          dlg = wxFileDialog(self, "Enter a filename for session", ".", "",
278                             "*.session", wxOPEN)                             "*.thuban", wxOPEN)
279          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
280              main.app.session.SetFilename(dlg.GetPath())              main.app.session.SetFilename(dlg.GetPath())
281              main.app.SaveSession()              main.app.SaveSession()
# Line 302  class MainWindow(wxFrame): Line 314  class MainWindow(wxFrame):
314                             wxOK | wxICON_INFORMATION)                             wxOK | wxICON_INFORMATION)
315    
316      def AddLayer(self):      def AddLayer(self):
317          dlg = wxFileDialog(self, "Select a session file", ".", "", "*.*",          dlg = wxFileDialog(self, "Select a data file", ".", "", "*.*",
318                             wxOPEN)                             wxOPEN)
319          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
320              filename = dlg.GetPath()              filename = dlg.GetPath()
# Line 419  class MainWindow(wxFrame): Line 431  class MainWindow(wxFrame):
431          map = self.canvas.Map()          map = self.canvas.Map()
432          proj = map.projection          proj = map.projection
433          if proj is None:          if proj is None:
434              proj4Dlg = proj4dialog.Proj4Dialog(NULL, None)              proj4Dlg = proj4dialog.Proj4Dialog(NULL, None, map.BoundingBox())
435          else:          else:
436              proj4Dlg = proj4dialog.Proj4Dialog(NULL, map.projection.params)              proj4Dlg = proj4dialog.Proj4Dialog(NULL, map.projection.params,
437                                                   map.BoundingBox())
438          if proj4Dlg.ShowModal() == wxID_OK:          if proj4Dlg.ShowModal() == wxID_OK:
439              params = proj4Dlg.GetParams()              params = proj4Dlg.GetParams()
440              if params is not None:              if params is not None:
# Line 474  def call_method(context, methodname, *ar Line 487  def call_method(context, methodname, *ar
487      """Call the context's method methodname with args *args"""      """Call the context's method methodname with args *args"""
488      apply(getattr(context, methodname), args)      apply(getattr(context, methodname), args)
489    
490  def _method_command(name, title, method, helptext = "", sensitive = None):  def _method_command(name, title, method, helptext = "",
491                        icon = "", sensitive = None):
492      """Add a command implemented by a method of the context object"""      """Add a command implemented by a method of the context object"""
493      registry.Add(Command(name, title, call_method, args=(method,),      registry.Add(Command(name, title, call_method, args=(method,),
494                           helptext = helptext, sensitive = sensitive))                           helptext = helptext, icon = icon,
495                             sensitive = sensitive))
496    
497  def _tool_command(name, title, method, toolname, helptext = "",  def _tool_command(name, title, method, toolname, helptext = "",
498                    icon = ""):                    icon = ""):
499      """Add a tool command"""      """Add a tool command"""
# Line 496  _method_command("new_session", "&New Ses Line 512  _method_command("new_session", "&New Ses
512  _method_command("open_session", "&Open Session", "OpenSession")  _method_command("open_session", "&Open Session", "OpenSession")
513  _method_command("save_session", "&Save Session", "SaveSession")  _method_command("save_session", "&Save Session", "SaveSession")
514  _method_command("save_session_as", "Save Session &As", "SaveSessionAs")  _method_command("save_session_as", "Save Session &As", "SaveSessionAs")
515    _method_command("show_session_tree", "Show Session &Tree", "ShowSessionTree")
516  _method_command("exit", "&Exit", "Exit")  _method_command("exit", "&Exit", "Exit")
517    
518  # Help menu  # Help menu
# Line 515  _tool_command("map_identify_tool", "&Ide Line 532  _tool_command("map_identify_tool", "&Ide
532                helptext = "Switch to map-mode 'identify'", icon = "identify")                helptext = "Switch to map-mode 'identify'", icon = "identify")
533  _tool_command("map_label_tool", "&Label", "LabelTool", "LabelTool",  _tool_command("map_label_tool", "&Label", "LabelTool", "LabelTool",
534                helptext = "Add/Remove labels", icon = "label")                helptext = "Add/Remove labels", icon = "label")
535  _method_command("map_full_extent", "&Full extent", "FullExtent")  _method_command("map_full_extent", "&Full extent", "FullExtent",
536                   helptext = "Full Extent", icon = "fullextent")
537  _method_command("map_print", "Prin&t", "PrintMap", helptext = "Print the map")  _method_command("map_print", "Prin&t", "PrintMap", helptext = "Print the map")
538    
539  # Layer menu  # Layer menu

Legend:
Removed from v.84  
changed lines
  Added in v.150

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26