/[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 550 by jonathan, Thu Mar 20 09:45:19 2003 UTC revision 573 by jonathan, Fri Mar 28 17:07:06 2003 UTC
# Line 36  from menu import Menu Line 36  from menu import Menu
36    
37  from context import Context  from context import Context
38  from command import registry, Command, ToolCommand  from command import registry, Command, ToolCommand
39  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION, DOCKABLE_DOCKED, DOCKABLE_UNDOCKED, DOCKABLE_CLOSED
40    
41    from Thuban.UI.dock import DockableWindow, DockFrame, DockPanel
42    
43    
44  # the directory where the toolbar icons are stored  # the directory where the toolbar icons are stored
45  bitmapdir = os.path.join(Thuban.__path__[0], os.pardir, "Resources", "Bitmaps")  bitmapdir = os.path.join(Thuban.__path__[0], os.pardir, "Resources", "Bitmaps")
46  bitmapext = ".xpm"  bitmapext = ".xpm"
47    
48    ID_WINDOW_LEGEND = 4001
49    ID_WINDOW_CANVAS = 4002
50    
51    
52  class MainWindow(wxFrame):  class MainWindow(DockFrame):
53    
54      # Some messages that can be subscribed/unsubscribed directly through      # Some messages that can be subscribed/unsubscribed directly through
55      # the MapCanvas come in fact from other objects. This is a map to      # the MapCanvas come in fact from other objects. This is a map to
# Line 62  class MainWindow(wxFrame): Line 67  class MainWindow(wxFrame):
67    
68      def __init__(self, parent, ID, title, application, interactor,      def __init__(self, parent, ID, title, application, interactor,
69                   initial_message = None, size = wxSize(-1, -1)):                   initial_message = None, size = wxSize(-1, -1)):
70          wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, size)          DockFrame.__init__(self, parent, ID, title, wxDefaultPosition, size)
71            #wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, size)
72    
73          self.application = application          self.application = application
74    
# Line 82  class MainWindow(wxFrame): Line 88  class MainWindow(wxFrame):
88          # call Realize to make sure that the tools appear.          # call Realize to make sure that the tools appear.
89          toolbar.Realize()          toolbar.Realize()
90    
91    
92          # Create the map canvas          # Create the map canvas
93          canvas = view.MapCanvas(self, -1)          canvas = view.MapCanvas(self, -1)
94          canvas.Subscribe(VIEW_POSITION, self.view_position_changed)          canvas.Subscribe(VIEW_POSITION, self.view_position_changed)
95          canvas.Subscribe(SHAPES_SELECTED, self.identify_view_on_demand)          canvas.Subscribe(SHAPES_SELECTED, self.identify_view_on_demand)
96          self.canvas = canvas          self.canvas = canvas
97    
98            self.SetMainWindow(self.canvas)
99    
100            self.SetAutoLayout(True)
101    
102          self.init_dialogs()          self.init_dialogs()
103    
104          EVT_CLOSE(self, self.OnClose)          EVT_CLOSE(self, self.OnClose)
# Line 391  class MainWindow(wxFrame): Line 402  class MainWindow(wxFrame):
402    
403      def SetMap(self, map):      def SetMap(self, map):
404          self.canvas.SetMap(map)          self.canvas.SetMap(map)
405            #self.legendPanel.SetMap(map)
406    
407      def Map(self):      def Map(self):
408          """Return the map displayed by this mainwindow"""          """Return the map displayed by this mainwindow"""
409    
410            # sanity check
411            #assert(self.canvas.Map() is self.legendPanel.GetMap())
412    
413          return self.canvas.Map()          return self.canvas.Map()
414    
415      def ShowSessionTree(self):      def ShowSessionTree(self):
# Line 575  class MainWindow(wxFrame): Line 591  class MainWindow(wxFrame):
591          layer = self.current_layer()          layer = self.current_layer()
592          self.OpenClassifier(layer)          self.OpenClassifier(layer)
593    
594      def OpenClassifier(self, layer):      def OpenClassifier(self, layer, group = None):
595          name = "classifier" + str(id(layer))          name = "classifier" + str(id(layer))
596          dialog = self.get_open_dialog(name)          dialog = self.get_open_dialog(name)
597    
598          if dialog is None:          if dialog is None:
599              dialog = classifier.Classifier(self, name, layer)              dialog = classifier.Classifier(self, name, layer, group)
600              self.add_dialog(name, dialog)              self.add_dialog(name, dialog)
601              dialog.Show()              dialog.Show()
602            dialog.Raise()
603    
604    
605      def ShowLegend(self):      def ShowLegend(self, switch = False):
606          name = "legend"          name = "legend"
607          dialog = self.get_open_dialog(name)          dialog = self.FindRegisteredDock(name)
608    
609          if dialog is None:          if dialog is None:
610              dialog = legend.Legend(self, name, self.Map())              title = "Legend: %s" % self.Map().Title()
611              self.add_dialog(name, dialog)              dialog = self.CreateDock(name, -1, title, wxLAYOUT_LEFT)
612              dialog.Show()              legend.LegendPanel(dialog, None, self)
613    
614            dialog.GetPanel().SetMap(self.Map())
615            dialog.Show()
616    
617      def ZoomInTool(self):      def ZoomInTool(self):
618          self.canvas.ZoomInTool()          self.canvas.ZoomInTool()
# Line 622  class MainWindow(wxFrame): Line 642  class MainWindow(wxFrame):
642              if not self.dialog_open(name):              if not self.dialog_open(name):
643                  dialog = identifyview.IdentifyView(self, name)                  dialog = identifyview.IdentifyView(self, name)
644                  self.add_dialog(name, dialog)                  self.add_dialog(name, dialog)
645                  dialog.Show(true)                  dialog.Show(True)
646              else:              else:
647                  # FIXME: bring dialog to front?                  # FIXME: bring dialog to front?
648                  pass                  pass
# Line 687  def _has_visible_map(context): Line 707  def _has_visible_map(context):
707    
708  def _has_legend_shown(context):  def _has_legend_shown(context):
709      """Return true if the legend window is shown"""      """Return true if the legend window is shown"""
710      return context.mainwindow.get_open_dialog("legend") is None      return context.mainwindow.FindRegisteredDock("legend") is None
711    
712    
713  # File menu  # File menu
# Line 764  _method_command("layer_show_table", _("S Line 784  _method_command("layer_show_table", _("S
784                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
785  _method_command("layer_classifier", _("Classify"), "Classify",  _method_command("layer_classifier", _("Classify"), "Classify",
786                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
787  _method_command("show_legend", _("Legend"), "ShowLegend",  _method_command("show_legend", _("Show Legend"), "ShowLegend",
788                  sensitive = _has_legend_shown)                  sensitive = _has_legend_shown)
789    
790  # the menu structure  # the menu structure

Legend:
Removed from v.550  
changed lines
  Added in v.573

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26