/[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 622 by bh, Mon Apr 7 10:54:32 2003 UTC revision 704 by bh, Tue Apr 22 16:55:50 2003 UTC
# Line 30  import view Line 30  import view
30  import tree  import tree
31  import proj4dialog  import proj4dialog
32  import tableview, identifyview  import tableview, identifyview
33  import classifier  from Thuban.UI.classifier import Classifier
34  import legend  import legend
35  from menu import Menu  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, DOCKABLE_DOCKED, DOCKABLE_UNDOCKED, DOCKABLE_CLOSED  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION
40    
41  from Thuban.UI.dock import DockableWindow, DockFrame, DockPanel  from Thuban.UI.dock import DockFrame
42    
43    import resource
44    
 # the directory where the toolbar icons are stored  
 bitmapdir = os.path.join(Thuban.__path__[0], os.pardir, "Resources", "Bitmaps")  
 bitmapext = ".xpm"  
   
 ID_WINDOW_LEGEND = 4001  
 ID_WINDOW_CANVAS = 4002  
45    
46    
47  class MainWindow(DockFrame):  class MainWindow(DockFrame):
# Line 243  class MainWindow(DockFrame): Line 238  class MainWindow(DockFrame):
238              command = registry.Command(name)              command = registry.Command(name)
239              if command is not None:              if command is not None:
240                  ID = self.get_id(name)                  ID = self.get_id(name)
241                  filename = os.path.join(bitmapdir, command.Icon()) + bitmapext                  bitmap = resource.GetBitmapResource(command.Icon(),
242                  bitmap = wxBitmap(filename, wxBITMAP_TYPE_XPM)                                                      wxBITMAP_TYPE_XPM)
243                  toolbar.AddTool(ID, bitmap,                  toolbar.AddTool(ID, bitmap,
244                                  shortHelpString = command.HelpText(),                                  shortHelpString = command.HelpText(),
245                                  isToggle = command.IsCheckCommand())                                  isToggle = command.IsCheckCommand())
# Line 403  class MainWindow(DockFrame): Line 398  class MainWindow(DockFrame):
398    
399      def SetMap(self, map):      def SetMap(self, map):
400          self.canvas.SetMap(map)          self.canvas.SetMap(map)
401            self.__SetTitle(map.Title())
402          #self.legendPanel.SetMap(map)          #self.legendPanel.SetMap(map)
403    
404      def Map(self):      def Map(self):
# Line 517  class MainWindow(DockFrame): Line 513  class MainWindow(DockFrame):
513          dlg.Destroy()          dlg.Destroy()
514          return color          return color
515    
     def LayerFillColor(self):  
         layer = self.current_layer()  
         if layer is not None:  
             color = self.choose_color()  
             if color is not None:  
                 layer.GetClassification().SetDefaultFill(color)  
   
     def LayerTransparentFill(self):  
         layer = self.current_layer()  
         if layer is not None:  
             layer.GetClassification().SetDefaultFill(Color.Transparent)  
   
     def LayerOutlineColor(self):  
         layer = self.current_layer()  
         if layer is not None:  
             color = self.choose_color()  
             if color is not None:  
                 layer.GetClassification().SetDefaultLineColor(color)  
   
     def LayerNoOutline(self):  
         layer = self.current_layer()  
         if layer is not None:  
             layer.GetClassification().SetDefaultLineColor(Color.Transparent)  
   
516      def HideLayer(self):      def HideLayer(self):
517          layer = self.current_layer()          layer = self.current_layer()
518          if layer is not None:          if layer is not None:
# Line 584  class MainWindow(DockFrame): Line 556  class MainWindow(DockFrame):
556              map.SetProjection(proj)              map.SetProjection(proj)
557          proj4Dlg.Destroy()          proj4Dlg.Destroy()
558    
559      def Classify(self):      def LayerEditProperties(self):
560    
561          #          #
562          # the menu option for this should only be available if there          # the menu option for this should only be available if there
# Line 593  class MainWindow(DockFrame): Line 565  class MainWindow(DockFrame):
565          #          #
566    
567          layer = self.current_layer()          layer = self.current_layer()
568          self.OpenClassifier(layer)          self.OpenLayerProperties(layer)
569    
570      def OpenClassifier(self, layer, group = None):      def OpenLayerProperties(self, layer, group = None):
571          name = "classifier" + str(id(layer))          name = "layer_properties" + str(id(layer))
572          dialog = self.get_open_dialog(name)          dialog = self.get_open_dialog(name)
573    
574          if dialog is None:          if dialog is None:
575              dialog = classifier.Classifier(self, name, layer, group)              dialog = Classifier(self, name, layer, group)
576              self.add_dialog(name, dialog)              self.add_dialog(name, dialog)
577              dialog.Show()              dialog.Show()
578          dialog.Raise()          dialog.Raise()
# Line 616  class MainWindow(DockFrame): Line 588  class MainWindow(DockFrame):
588          dialog = self.FindRegisteredDock(name)          dialog = self.FindRegisteredDock(name)
589    
590          if dialog is None:          if dialog is None:
591              title = "Legend: %s" % self.Map().Title()              dialog = self.CreateDock(name, -1, _("Legend"), wxLAYOUT_LEFT)
             dialog = self.CreateDock(name, -1, title, wxLAYOUT_LEFT)  
592              legend.LegendPanel(dialog, None, self)              legend.LegendPanel(dialog, None, self)
593              dialog.Dock()              dialog.Dock()
594              dialog.GetPanel().SetMap(self.Map())              dialog.GetPanel().SetMap(self.Map())
# Line 652  class MainWindow(DockFrame): Line 623  class MainWindow(DockFrame):
623      def PrintMap(self):      def PrintMap(self):
624          self.canvas.Print()          self.canvas.Print()
625    
626        def RenameMap(self):
627            dlg = wxTextEntryDialog(self, "Map Title: ", "Rename Map",
628                                    self.Map().Title())
629            if dlg.ShowModal() == wxID_OK:
630                title = dlg.GetValue()
631                if title != "":
632                    self.Map().SetTitle(title)
633                    self.__SetTitle(title)
634    
635            dlg.Destroy()
636    
637      def identify_view_on_demand(self, layer, shapes):      def identify_view_on_demand(self, layer, shapes):
638          name = "identify_view"          name = "identify_view"
639          if self.canvas.CurrentTool() == "IdentifyTool":          if self.canvas.CurrentTool() == "IdentifyTool":
# Line 663  class MainWindow(DockFrame): Line 645  class MainWindow(DockFrame):
645                  # FIXME: bring dialog to front?                  # FIXME: bring dialog to front?
646                  pass                  pass
647    
648        def __SetTitle(self, title):
649            self.SetTitle("Thuban - " + title)
650    
651  #  #
652  # Define all the commands available in the main window  # Define all the commands available in the main window
653  #  #
# Line 765  _method_command("map_full_extent", _("&F Line 750  _method_command("map_full_extent", _("&F
750                sensitive = _has_visible_map)                sensitive = _has_visible_map)
751  _method_command("map_print", _("Prin&t"), "PrintMap",  _method_command("map_print", _("Prin&t"), "PrintMap",
752                  helptext = _("Print the map"))                  helptext = _("Print the map"))
753    _method_command("map_rename", _("&Rename"), "RenameMap",
754                    helptext = _("Rename the map"))
755    
756  # Layer menu  # Layer menu
757  _method_command("layer_add", _("&Add Layer"), "AddLayer",  _method_command("layer_add", _("&Add Layer"), "AddLayer",
# Line 772  _method_command("layer_add", _("&Add Lay Line 759  _method_command("layer_add", _("&Add Lay
759  _method_command("layer_remove", _("&Remove Layer"), "RemoveLayer",  _method_command("layer_remove", _("&Remove Layer"), "RemoveLayer",
760                  helptext = _("Remove selected layer(s)"),                  helptext = _("Remove selected layer(s)"),
761                  sensitive = _can_remove_layer)                  sensitive = _can_remove_layer)
 _method_command("layer_fill_color", _("&Fill Color"), "LayerFillColor",  
                 helptext = _("Set the fill color of selected layer(s)"),  
                 sensitive = _has_selected_layer)  
 _method_command("layer_transparent_fill", _("&Transparent Fill"),  
                 "LayerTransparentFill",  
                 helptext = _("Do not fill the selected layer(s)"),  
                 sensitive = _has_selected_layer)  
 _method_command("layer_outline_color", _("&Outline Color"), "LayerOutlineColor",  
                 helptext = _("Set the outline color of selected layer(s)"),  
                 sensitive = _has_selected_layer)  
 _method_command("layer_no_outline", _("&No Outline"), "LayerNoOutline",  
                 helptext= _("Do not draw the outline of the selected layer(s)"),  
                 sensitive = _has_selected_layer)  
762  _method_command("layer_raise", _("&Raise"), "RaiseLayer",  _method_command("layer_raise", _("&Raise"), "RaiseLayer",
763                  helptext = _("Raise selected layer(s)"),                  helptext = _("Raise selected layer(s)"),
764                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
# Line 800  _method_command("layer_hide", _("&Hide") Line 774  _method_command("layer_hide", _("&Hide")
774  _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable",  _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable",
775                  helptext = _("Show the selected layer's table"),                  helptext = _("Show the selected layer's table"),
776                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
777  _method_command("layer_classifier", _("Classify"), "Classify",  _method_command("layer_properties", _("Properties"), "LayerEditProperties",
778                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
779    
780  # the menu structure  # the menu structure
# Line 808  main_menu = Menu("<main>", "<main>", Line 782  main_menu = Menu("<main>", "<main>",
782                   [Menu("file", _("&File"),                   [Menu("file", _("&File"),
783                         ["new_session", "open_session", None,                         ["new_session", "open_session", None,
784                          "save_session", "save_session_as", None,                          "save_session", "save_session_as", None,
785                          "toggle_session_tree",                          "toggle_session_tree", None,
                         "toggle_legend", None,  
786                          "exit"]),                          "exit"]),
787                    Menu("map", _("&Map"),                    Menu("map", _("&Map"),
788                         ["layer_add", "layer_remove",                         ["layer_add", "layer_remove",
# Line 821  main_menu = Menu("<main>", "<main>", Line 794  main_menu = Menu("<main>", "<main>",
794                          None,                          None,
795                          "map_full_extent",                          "map_full_extent",
796                          None,                          None,
797                          "map_print"]),                          "toggle_legend",
798                    Menu("layer", _("&Layer"),                          None,
799                         ["layer_fill_color", "layer_transparent_fill",                          "map_print",
                         "layer_outline_color", "layer_no_outline",  
800                          None,                          None,
801                          "layer_raise", "layer_lower",                          "map_rename"]),
802                      Menu("layer", _("&Layer"),
803                            ["layer_raise", "layer_lower",
804                          None,                          None,
805                          "layer_show", "layer_hide",                          "layer_show", "layer_hide",
806                          None,                          None,
807                          "layer_show_table",                          "layer_show_table",
808                          None,                          None,
809                          "layer_classifier"]),                          "layer_properties"]),
810                    Menu("help", _("&Help"),                    Menu("help", _("&Help"),
811                         ["help_about"])])                         ["help_about"])])
812    

Legend:
Removed from v.622  
changed lines
  Added in v.704

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26