/[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 2184 by jan, Fri Apr 16 08:21:12 2004 UTC revision 2365 by joey, Fri Oct 1 18:22:32 2004 UTC
# Line 35  from Thuban.UI.multiplechoicedialog impo Line 35  from Thuban.UI.multiplechoicedialog impo
35  import view  import view
36  import tree  import tree
37  import tableview, identifyview  import tableview, identifyview
 from Thuban.UI.classifier import Classifier  
38  import legend  import legend
39  from menu import Menu  from menu import Menu
40    
# Line 53  import Thuban.Model.resource Line 52  import Thuban.Model.resource
52    
53  import projdialog  import projdialog
54    
55    from Thuban.Lib.classmapper import ClassMapper
56    
57    layer_properties_dialogs = ClassMapper()
58    
59  class MainWindow(DockFrame):  class MainWindow(DockFrame):
60    
# Line 349  class MainWindow(DockFrame): Line 351  class MainWindow(DockFrame):
351          """          """
352          self.SetStatusText(text)          self.SetStatusText(text)
353    
354        def OpenOrRaiseDialog(self, name, dialog_class, *args, **kw):
355            """
356            Open or raise a dialog.
357    
358            If a dialog with the denoted name does already exist it is
359            raised.  Otherwise a new dialog, an instance of dialog_class,
360            is created, inserted into the main list and displayed.
361            """
362            dialog = self.get_open_dialog(name)
363    
364            if dialog is None:
365                dialog = dialog_class(self, name, *args, **kw)
366                self.add_dialog(name, dialog)
367                dialog.Show(True)
368            else:
369                dialog.Raise()
370                              
371      def save_modified_session(self, can_veto = 1):      def save_modified_session(self, can_veto = 1):
372          """If the current session has been modified, ask the user          """If the current session has been modified, ask the user
373          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 572  class MainWindow(DockFrame): Line 591  class MainWindow(DockFrame):
591              return self.canvas.Map().CanRemoveLayer(layer)              return self.canvas.Map().CanRemoveLayer(layer)
592          return False          return False
593    
594        def LayerToTop(self):
595            layer = self.current_layer()
596            if layer is not None:
597                self.canvas.Map().MoveLayerToTop(layer)
598    
599      def RaiseLayer(self):      def RaiseLayer(self):
600          layer = self.current_layer()          layer = self.current_layer()
601          if layer is not None:          if layer is not None:
# Line 582  class MainWindow(DockFrame): Line 606  class MainWindow(DockFrame):
606          if layer is not None:          if layer is not None:
607              self.canvas.Map().LowerLayer(layer)              self.canvas.Map().LowerLayer(layer)
608    
609        def LayerToBottom(self):
610            layer = self.current_layer()
611            if layer is not None:
612                self.canvas.Map().MoveLayerToBottom(layer)
613    
614      def current_layer(self):      def current_layer(self):
615          """Return the currently selected layer.          """Return the currently selected layer.
616    
# Line 604  class MainWindow(DockFrame): Line 633  class MainWindow(DockFrame):
633      def HideLayer(self):      def HideLayer(self):
634          layer = self.current_layer()          layer = self.current_layer()
635          if layer is not None:          if layer is not None:
636              layer.SetVisible(0)              layer.SetVisible(False)
637    
638      def ShowLayer(self):      def ShowLayer(self):
639          layer = self.current_layer()          layer = self.current_layer()
640          if layer is not None:          if layer is not None:
641              layer.SetVisible(1)              layer.SetVisible(True)
642    
643        def ToggleLayerVisibility(self):
644            layer = self.current_layer()
645            layer.SetVisible(not layer.Visible())
646    
647      def DuplicateLayer(self):      def DuplicateLayer(self):
648          """Ceate a new layer above the selected layer with the same shapestore          """Ceate a new layer above the selected layer with the same shapestore
# Line 633  class MainWindow(DockFrame): Line 666  class MainWindow(DockFrame):
666          Present a TableView Window for the current layer.          Present a TableView Window for the current layer.
667          In case the window is already open, bring it to the front.          In case the window is already open, bring it to the front.
668          In case, there is no active layer, do nothing.          In case, there is no active layer, do nothing.
669          In case, the layer has not ShapeStore, raise a corresponding message dialog          In case, the layer has no ShapeStore, do nothing.
         and do nothing else.  
670          """          """
671          layer = self.current_layer()          layer = self.current_layer()
672          if layer is not None:          if layer is not None:
673              if not hasattr(layer, "ShapeStore"):              if not hasattr(layer, "ShapeStore"):
                 self.RunMessageBox(_("Show Table"),  
                                    _("The layer '%s' has no table." % layer.Title()))  
674                  return                  return
675              table = layer.ShapeStore().Table()              table = layer.ShapeStore().Table()
676              name = "table_view" + str(id(table))              name = "table_view" + str(id(table))
# Line 694  class MainWindow(DockFrame): Line 724  class MainWindow(DockFrame):
724          self.OpenLayerProperties(layer)          self.OpenLayerProperties(layer)
725    
726      def OpenLayerProperties(self, layer, group = None):      def OpenLayerProperties(self, layer, group = None):
727          name = "layer_properties" + str(id(layer))          """
728          dialog = self.get_open_dialog(name)          Open or raise the properties dialog.
729    
730          if dialog is None:          This method opens or raises the properties dialog for the
731              dialog = Classifier(self, name, self.Map(), layer, group)          currently selected layer if one is defined for this layer
732              self.add_dialog(name, dialog)          type.
733              dialog.Show()          """
734          dialog.Raise()          dialog_class = layer_properties_dialogs.get(layer)
735    
736            if dialog_class is not None:
737                name = "layer_properties" + str(id(layer))
738                self.OpenOrRaiseDialog(name, dialog_class, layer, group = group)
739    
740      def LayerJoinTable(self):      def LayerJoinTable(self):
741          layer = self.canvas.SelectedLayer()          layer = self.canvas.SelectedLayer()
# Line 997  def _has_selected_layer(context): Line 1031  def _has_selected_layer(context):
1031      """Return true if a layer is selected in the context"""      """Return true if a layer is selected in the context"""
1032      return context.mainwindow.has_selected_layer()      return context.mainwindow.has_selected_layer()
1033    
1034    def _has_selected_layer_visible(context):
1035        """Return true if a layer is selected in the context which is
1036        visible."""
1037        if context.mainwindow.has_selected_layer():
1038            layer = context.mainwindow.current_layer()
1039            if layer.Visible(): return True
1040        return False
1041    
1042  def _has_selected_shape_layer(context):  def _has_selected_shape_layer(context):
1043      """Return true if a shape layer is selected in the context"""      """Return true if a shape layer is selected in the context"""
1044      return context.mainwindow.has_selected_shape_layer()      return context.mainwindow.has_selected_shape_layer()
# Line 1020  def _has_visible_map(context): Line 1062  def _has_visible_map(context):
1062      if map is not None:      if map is not None:
1063          for layer in map.Layers():          for layer in map.Layers():
1064              if layer.Visible():              if layer.Visible():
1065                  return 1                  return True
1066      return 0      return False
1067    
1068  def _has_legend_shown(context):  def _has_legend_shown(context):
1069      """Return true if the legend window is shown"""      """Return true if the legend window is shown"""
# Line 1145  _method_command("layer_jointable", _("&J Line 1187  _method_command("layer_jointable", _("&J
1187                  sensitive = _has_selected_shape_layer,                  sensitive = _has_selected_shape_layer,
1188                  helptext = _("Join and attach a table to the selected layer"))                  helptext = _("Join and attach a table to the selected layer"))
1189    
1190    # further layer methods:
1191    _method_command("layer_to_top", _("&Top"), "LayerToTop",
1192                    helptext = _("Put selected layer to the top"),
1193                    sensitive = _has_selected_layer)
1194    _method_command("layer_to_bottom", _("&Bottom"), "LayerToBottom",
1195                    helptext = _("Put selected layer to the bottom"),
1196                    sensitive = _has_selected_layer)
1197    _method_command("layer_visibility", _("&Visible"), "ToggleLayerVisibility",
1198                    checked = _has_selected_layer_visible,
1199                    helptext = _("Toggle visibility of selected layer"),
1200                    sensitive = _has_selected_layer)
1201    
1202  def _can_unjoin(context):  def _can_unjoin(context):
1203      """Return whether the Layer/Unjoin command can be executed.      """Return whether the Layer/Unjoin command can be executed.
1204    

Legend:
Removed from v.2184  
changed lines
  Added in v.2365

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26