/[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 20 by bh, Tue Sep 4 16:44:31 2001 UTC revision 33 by bh, Thu Sep 6 15:31:31 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 39  bitmapext = ".xpm" Line 40  bitmapext = ".xpm"
40    
41  class MainWindow(wxFrame):  class MainWindow(wxFrame):
42    
43      def __init__(self, parent, ID):      def __init__(self, parent, ID, interactor):
44          wxFrame.__init__(self, parent, ID, 'Thuban',          wxFrame.__init__(self, parent, ID, 'Thuban',
45                           wxDefaultPosition, wxSize(400, 300))                           wxDefaultPosition, wxSize(400, 300))
46    
# Line 101  class MainWindow(wxFrame): Line 102  class MainWindow(wxFrame):
102          toolbar.Realize()          toolbar.Realize()
103    
104          # Create the map canvas          # Create the map canvas
105          canvas = view.MapCanvas(self, -1)          canvas = view.MapCanvas(self, -1, interactor)
106          self.canvas = canvas          self.canvas = canvas
107    
108            self.init_dialogs()
109    
110            interactor.Subscribe(SELECTED_SHAPE, self.identify_view_on_demand)
111    
112          EVT_CLOSE(self, self.OnClose)          EVT_CLOSE(self, self.OnClose)
113    
114      def init_ids(self):      def init_ids(self):
# Line 189  class MainWindow(wxFrame): Line 194  class MainWindow(wxFrame):
194          dlg.Destroy()          dlg.Destroy()
195          return result          return result
196    
197        def init_dialogs(self):
198            """Initialize the dialog handling"""
199            # The mainwindow maintains a dict mapping names to open
200            # non-modal dialogs. The dialogs are put into this dict when
201            # they're created and removed when they're closed
202            self.dialogs = {}
203    
204        def add_dialog(self, name, dialog):
205            if self.dialogs.has_key(name):
206                raise RuntimeError("The Dialog named %s is already open" % name)
207            self.dialogs[name] = dialog
208    
209        def dialog_open(self, name):
210            return self.dialogs.has_key(name)
211    
212        def remove_dialog(self, name):
213            del self.dialogs[name]
214    
215        def get_open_dialog(self, name):
216            return self.dialogs.get(name)
217    
218      def NewSession(self):      def NewSession(self):
219          session = Session("")          session = Session("")
220          session.AddMap(Map(""))          session.AddMap(Map(""))
# Line 353  class MainWindow(wxFrame): Line 379  class MainWindow(wxFrame):
379      def LayerShowTable(self):      def LayerShowTable(self):
380          layer = self.current_layer()          layer = self.current_layer()
381          if layer is not None:          if layer is not None:
382              tv = tableview.TableFrame(self, layer.table)              table = layer.table
383              tv.Show(true)              name = "table_view" + str(id(table))
384                dialog = self.get_open_dialog(name)
385                if dialog is None:
386                    dialog = tableview.TableFrame(self, main.app.interactor, name,
387                                                  "Table: %s" % layer.Title(),
388                                                  layer, table)
389                    self.add_dialog(name, dialog)
390                    dialog.Show(true)
391                else:
392                    # FIXME: bring dialog to front here
393                    pass
394    
395      def Projection(self):      def Projection(self):
396          map = self.canvas.Map()          map = self.canvas.Map()
# Line 382  class MainWindow(wxFrame): Line 418  class MainWindow(wxFrame):
418          self.canvas.PanTool()          self.canvas.PanTool()
419    
420      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)  
421          self.canvas.IdentifyTool()          self.canvas.IdentifyTool()
422    
423      def LabelTool(self):      def LabelTool(self):
# Line 396  class MainWindow(wxFrame): Line 429  class MainWindow(wxFrame):
429      def PrintMap(self):      def PrintMap(self):
430          self.canvas.Print()          self.canvas.Print()
431    
432        def identify_view_on_demand(self, layer, shape):
433            name = "identify_view"
434            if self.canvas.CurrentTool() == "IdentifyTool":
435                if not self.dialog_open(name):
436                    dialog = identifyview.IdentifyView(self, main.app.interactor,
437                                                       name)
438                    self.add_dialog(name, dialog)
439                    dialog.Show(true)
440                else:
441                    # FIXME: bring dialog to front?
442                    pass
443    
444  #  #
445  # Define all the commands available in the main window  # Define all the commands available in the main window

Legend:
Removed from v.20  
changed lines
  Added in v.33

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26