/[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 24 by bh, Wed Sep 5 13:35:46 2001 UTC revision 49 by bh, Mon Sep 10 16:03:59 2001 UTC
# 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
34    
35    
36  # the directory where the toolbar icons are stored  # the directory where the toolbar icons are stored
# Line 43  class MainWindow(wxFrame): Line 44  class MainWindow(wxFrame):
44          wxFrame.__init__(self, parent, ID, 'Thuban',          wxFrame.__init__(self, parent, ID, 'Thuban',
45                           wxDefaultPosition, wxSize(400, 300))                           wxDefaultPosition, wxSize(400, 300))
46    
47            self.interactor = interactor
48    
49          self.CreateStatusBar()          self.CreateStatusBar()
50          self.SetStatusText("This is the wxPython-based "          self.SetStatusText("This is the wxPython-based "
51                        "Graphical User Interface for exploring geographic data")                        "Graphical User Interface for exploring geographic data")
# Line 104  class MainWindow(wxFrame): Line 107  class MainWindow(wxFrame):
107          canvas = view.MapCanvas(self, -1, interactor)          canvas = view.MapCanvas(self, -1, interactor)
108          self.canvas = canvas          self.canvas = canvas
109    
110            self.init_dialogs()
111    
112            interactor.Subscribe(SELECTED_SHAPE, self.identify_view_on_demand)
113    
114          EVT_CLOSE(self, self.OnClose)          EVT_CLOSE(self, self.OnClose)
115    
116      def init_ids(self):      def init_ids(self):
# Line 189  class MainWindow(wxFrame): Line 196  class MainWindow(wxFrame):
196          dlg.Destroy()          dlg.Destroy()
197          return result          return result
198    
199        def init_dialogs(self):
200            """Initialize the dialog handling"""
201            # The mainwindow maintains a dict mapping names to open
202            # non-modal dialogs. The dialogs are put into this dict when
203            # they're created and removed when they're closed
204            self.dialogs = {}
205    
206        def add_dialog(self, name, dialog):
207            if self.dialogs.has_key(name):
208                raise RuntimeError("The Dialog named %s is already open" % name)
209            self.dialogs[name] = dialog
210    
211        def dialog_open(self, name):
212            return self.dialogs.has_key(name)
213    
214        def remove_dialog(self, name):
215            del self.dialogs[name]
216    
217        def get_open_dialog(self, name):
218            return self.dialogs.get(name)
219    
220      def NewSession(self):      def NewSession(self):
221          session = Session("")          session = Session("")
222          session.AddMap(Map(""))          session.AddMap(Map(""))
# Line 238  class MainWindow(wxFrame): Line 266  class MainWindow(wxFrame):
266      def SetMap(self, map):      def SetMap(self, map):
267          self.canvas.SetMap(map)          self.canvas.SetMap(map)
268    
269        def ShowSessionTree(self):
270            name = "session_tree"
271            dialog = self.get_open_dialog(name)
272            if dialog is None:
273                dialog = tree.SessionTreeView(self, main.app, name)
274                self.add_dialog(name, dialog)
275                dialog.Show(true)
276            else:
277                # FIXME: bring dialog to front here
278                pass
279    
280      def About(self):      def About(self):
281          self.RunMessageBox("About",          self.RunMessageBox("About",
282                             ("Thuban is a program for\n"                             ("Thuban is a program for\n"
# Line 288  class MainWindow(wxFrame): Line 327  class MainWindow(wxFrame):
327    
328          If no layer is selected, return None          If no layer is selected, return None
329          """          """
330          tree = main.app.tree.tree          return self.interactor.SelectedLayer()
         layer = tree.GetPyData(tree.GetSelection())  
         if isinstance(layer, Layer):  
             return layer  
         return None  
331    
332      def has_selected_layer(self):      def has_selected_layer(self):
333          """Return true if a layer is currently selected"""          """Return true if a layer is currently selected"""
334          tree = main.app.tree.tree          return self.interactor.HasSelectedLayer()
         layer = tree.GetPyData(tree.GetSelection())  
         return isinstance(layer, Layer)  
335    
336      def choose_color(self):      def choose_color(self):
337          """Run the color selection dialog and return the selected color.          """Run the color selection dialog and return the selected color.
# Line 353  class MainWindow(wxFrame): Line 386  class MainWindow(wxFrame):
386      def LayerShowTable(self):      def LayerShowTable(self):
387          layer = self.current_layer()          layer = self.current_layer()
388          if layer is not None:          if layer is not None:
389              tv = tableview.TableFrame(self, layer.table)              table = layer.table
390              tv.Show(true)              name = "table_view" + str(id(table))
391                dialog = self.get_open_dialog(name)
392                if dialog is None:
393                    dialog = tableview.TableFrame(self, self.interactor, name,
394                                                  "Table: %s" % layer.Title(),
395                                                  layer, table)
396                    self.add_dialog(name, dialog)
397                    dialog.Show(true)
398                else:
399                    # FIXME: bring dialog to front here
400                    pass
401    
402      def Projection(self):      def Projection(self):
403          map = self.canvas.Map()          map = self.canvas.Map()
# Line 382  class MainWindow(wxFrame): Line 425  class MainWindow(wxFrame):
425          self.canvas.PanTool()          self.canvas.PanTool()
426    
427      def IdentifyTool(self):      def IdentifyTool(self):
         if self.identify_view is None:  
             self.identify_view = identifyview.IdentifyView(self, main.app)  
             self.identify_view.Show(true)  
428          self.canvas.IdentifyTool()          self.canvas.IdentifyTool()
429            self.identify_view_on_demand(None, None)
430    
431      def LabelTool(self):      def LabelTool(self):
432          self.canvas.LabelTool()          self.canvas.LabelTool()
# Line 396  class MainWindow(wxFrame): Line 437  class MainWindow(wxFrame):
437      def PrintMap(self):      def PrintMap(self):
438          self.canvas.Print()          self.canvas.Print()
439    
440        def identify_view_on_demand(self, layer, shape):
441            name = "identify_view"
442            if self.canvas.CurrentTool() == "IdentifyTool":
443                if not self.dialog_open(name):
444                    dialog = identifyview.IdentifyView(self, self.interactor, name)
445                    self.add_dialog(name, dialog)
446                    dialog.Show(true)
447                else:
448                    # FIXME: bring dialog to front?
449                    pass
450    
451  #  #
452  # Define all the commands available in the main window  # Define all the commands available in the main window

Legend:
Removed from v.24  
changed lines
  Added in v.49

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26