/[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 2102 by bh, Thu Mar 11 21:04:30 2004 UTC revision 2364 by joey, Fri Oct 1 18:18:49 2004 UTC
# Line 349  class MainWindow(DockFrame): Line 349  class MainWindow(DockFrame):
349          """          """
350          self.SetStatusText(text)          self.SetStatusText(text)
351    
352        def OpenOrRaiseDialog(self, name, dialog_class, *args, **kw):
353            """
354            Open or raise a dialog.
355    
356            If a dialog with the denoted name does already exist it is
357            raised.  Otherwise a new dialog, an instance of dialog_class,
358            is created, inserted into the main list and displayed.
359            """
360            dialog = self.get_open_dialog(name)
361    
362            if dialog is None:
363                dialog = dialog_class(self, name, *args, **kw)
364                self.add_dialog(name, dialog)
365                dialog.Show(True)
366            else:
367                dialog.Raise()
368                              
369      def save_modified_session(self, can_veto = 1):      def save_modified_session(self, can_veto = 1):
370          """If the current session has been modified, ask the user          """If the current session has been modified, ask the user
371          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 589  class MainWindow(DockFrame):
589              return self.canvas.Map().CanRemoveLayer(layer)              return self.canvas.Map().CanRemoveLayer(layer)
590          return False          return False
591    
592        def LayerToTop(self):
593            layer = self.current_layer()
594            if layer is not None:
595                self.canvas.Map().MoveLayerToTop(layer)
596    
597      def RaiseLayer(self):      def RaiseLayer(self):
598          layer = self.current_layer()          layer = self.current_layer()
599          if layer is not None:          if layer is not None:
# Line 582  class MainWindow(DockFrame): Line 604  class MainWindow(DockFrame):
604          if layer is not None:          if layer is not None:
605              self.canvas.Map().LowerLayer(layer)              self.canvas.Map().LowerLayer(layer)
606    
607        def LayerToBottom(self):
608            layer = self.current_layer()
609            if layer is not None:
610                self.canvas.Map().MoveLayerToBottom(layer)
611    
612      def current_layer(self):      def current_layer(self):
613          """Return the currently selected layer.          """Return the currently selected layer.
614    
# Line 604  class MainWindow(DockFrame): Line 631  class MainWindow(DockFrame):
631      def HideLayer(self):      def HideLayer(self):
632          layer = self.current_layer()          layer = self.current_layer()
633          if layer is not None:          if layer is not None:
634              layer.SetVisible(0)              layer.SetVisible(False)
635    
636      def ShowLayer(self):      def ShowLayer(self):
637          layer = self.current_layer()          layer = self.current_layer()
638          if layer is not None:          if layer is not None:
639              layer.SetVisible(1)              layer.SetVisible(True)
640    
641        def ToggleLayerVisibility(self):
642            layer = self.current_layer()
643            layer.SetVisible(not layer.Visible())
644    
645      def DuplicateLayer(self):      def DuplicateLayer(self):
646          """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 629  class MainWindow(DockFrame): Line 660  class MainWindow(DockFrame):
660          return layer is not None and hasattr(layer, "ShapeStore")          return layer is not None and hasattr(layer, "ShapeStore")
661    
662      def LayerShowTable(self):      def LayerShowTable(self):
663            """
664            Present a TableView Window for the current layer.
665            In case the window is already open, bring it to the front.
666            In case, there is no active layer, do nothing.
667            In case, the layer has no ShapeStore, do nothing.
668            """
669          layer = self.current_layer()          layer = self.current_layer()
670          if layer is not None:          if layer is not None:
671                if not hasattr(layer, "ShapeStore"):
672                    return
673              table = layer.ShapeStore().Table()              table = layer.ShapeStore().Table()
674              name = "table_view" + str(id(table))              name = "table_view" + str(id(table))
675              dialog = self.get_open_dialog(name)              dialog = self.get_open_dialog(name)
# Line 641  class MainWindow(DockFrame): Line 680  class MainWindow(DockFrame):
680                  self.add_dialog(name, dialog)                  self.add_dialog(name, dialog)
681                  dialog.Show(True)                  dialog.Show(True)
682              else:              else:
683                  # FIXME: bring dialog to front here                  dialog.Raise()
                 pass  
684    
685      def MapProjection(self):      def MapProjection(self):
686    
# Line 684  class MainWindow(DockFrame): Line 722  class MainWindow(DockFrame):
722          self.OpenLayerProperties(layer)          self.OpenLayerProperties(layer)
723    
724      def OpenLayerProperties(self, layer, group = None):      def OpenLayerProperties(self, layer, group = None):
725          name = "layer_properties" + str(id(layer))          """
726          dialog = self.get_open_dialog(name)          Open or raise the properties dialog.
   
         if dialog is None:  
             dialog = Classifier(self, name, self.Map(), layer, group)  
             self.add_dialog(name, dialog)  
             dialog.Show()  
         dialog.Raise()  
727    
728            This method opens or raises the properties dialog for the
729            currently selected layer if one is defined for this layer
730            type.
731            """
732            name = "layer_properties" + str(id(layer))
733            self.OpenOrRaiseDialog(name, Classifier, layer, group = group)
734            
735      def LayerJoinTable(self):      def LayerJoinTable(self):
736          layer = self.canvas.SelectedLayer()          layer = self.canvas.SelectedLayer()
737          if layer is not None:          if layer is not None:
# Line 987  def _has_selected_layer(context): Line 1026  def _has_selected_layer(context):
1026      """Return true if a layer is selected in the context"""      """Return true if a layer is selected in the context"""
1027      return context.mainwindow.has_selected_layer()      return context.mainwindow.has_selected_layer()
1028    
1029    def _has_selected_layer_visible(context):
1030        """Return true if a layer is selected in the context which is
1031        visible."""
1032        if context.mainwindow.has_selected_layer():
1033            layer = context.mainwindow.current_layer()
1034            if layer.Visible(): return True
1035        return False
1036    
1037  def _has_selected_shape_layer(context):  def _has_selected_shape_layer(context):
1038      """Return true if a shape layer is selected in the context"""      """Return true if a shape layer is selected in the context"""
1039      return context.mainwindow.has_selected_shape_layer()      return context.mainwindow.has_selected_shape_layer()
# Line 1010  def _has_visible_map(context): Line 1057  def _has_visible_map(context):
1057      if map is not None:      if map is not None:
1058          for layer in map.Layers():          for layer in map.Layers():
1059              if layer.Visible():              if layer.Visible():
1060                  return 1                  return True
1061      return 0      return False
1062    
1063  def _has_legend_shown(context):  def _has_legend_shown(context):
1064      """Return true if the legend window is shown"""      """Return true if the legend window is shown"""
# Line 1135  _method_command("layer_jointable", _("&J Line 1182  _method_command("layer_jointable", _("&J
1182                  sensitive = _has_selected_shape_layer,                  sensitive = _has_selected_shape_layer,
1183                  helptext = _("Join and attach a table to the selected layer"))                  helptext = _("Join and attach a table to the selected layer"))
1184    
1185    # further layer methods:
1186    _method_command("layer_to_top", _("&Top"), "LayerToTop",
1187                    helptext = _("Put selected layer to the top"),
1188                    sensitive = _has_selected_layer)
1189    _method_command("layer_to_bottom", _("&Bottom"), "LayerToBottom",
1190                    helptext = _("Put selected layer to the bottom"),
1191                    sensitive = _has_selected_layer)
1192    _method_command("layer_visibility", _("&Visible"), "ToggleLayerVisibility",
1193                    checked = _has_selected_layer_visible,
1194                    helptext = _("Toggle visibility of selected layer"),
1195                    sensitive = _has_selected_layer)
1196    
1197  def _can_unjoin(context):  def _can_unjoin(context):
1198      """Return whether the Layer/Unjoin command can be executed.      """Return whether the Layer/Unjoin command can be executed.
1199    

Legend:
Removed from v.2102  
changed lines
  Added in v.2364

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26