jan: thuban/Thuban/UI mainwindow.py,1.131,1.132

cvs@intevation.de cvs at intevation.de
Sun Apr 18 22:37:03 CEST 2004


Author: jan

Update of /thubanrepository/thuban/Thuban/UI
In directory doto:/tmp/cvs-serv30022

Modified Files:
	mainwindow.py 
Log Message:
New method commands: layer_to_top, layer_to_bottom, layer_visibility
(MainWindow.LayerToTop): New. Put current layer to the top.
(MainWindow.LayerToBottom): New. Put current layer to bottom.
(MainWindow.HideLayer, MainWindow.ShowLayer, _has_visible_map):
Replace 1,0 by True, False.
(MainWindow.ToggleLayerVisibility): New. Toggle visibility of
current layer.
(MainWindow.LayerShowTable): Removed raising of dialog. 
(_has_selected_layer_visible): New. Support function. 


Index: mainwindow.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/mainwindow.py,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- mainwindow.py	16 Apr 2004 08:21:12 -0000	1.131
+++ mainwindow.py	18 Apr 2004 20:37:01 -0000	1.132
@@ -572,6 +572,11 @@
             return self.canvas.Map().CanRemoveLayer(layer)
         return False
 
+    def LayerToTop(self):
+        layer = self.current_layer()
+        if layer is not None:
+            self.canvas.Map().MoveLayerToTop(layer)
+
     def RaiseLayer(self):
         layer = self.current_layer()
         if layer is not None:
@@ -582,6 +587,11 @@
         if layer is not None:
             self.canvas.Map().LowerLayer(layer)
 
+    def LayerToBottom(self):
+        layer = self.current_layer()
+        if layer is not None:
+            self.canvas.Map().MoveLayerToBottom(layer)
+
     def current_layer(self):
         """Return the currently selected layer.
 
@@ -604,12 +614,16 @@
     def HideLayer(self):
         layer = self.current_layer()
         if layer is not None:
-            layer.SetVisible(0)
+            layer.SetVisible(False)
 
     def ShowLayer(self):
         layer = self.current_layer()
         if layer is not None:
-            layer.SetVisible(1)
+            layer.SetVisible(True)
+
+    def ToggleLayerVisibility(self):
+        layer = self.current_layer()
+        layer.SetVisible(not layer.Visible())
 
     def DuplicateLayer(self):
         """Ceate a new layer above the selected layer with the same shapestore
@@ -633,14 +647,11 @@
         Present a TableView Window for the current layer.
         In case the window is already open, bring it to the front.
         In case, there is no active layer, do nothing.
-        In case, the layer has not ShapeStore, raise a corresponding message dialog
-        and do nothing else.
+        In case, the layer has no ShapeStore, do nothing.
         """
         layer = self.current_layer()
         if layer is not None:
             if not hasattr(layer, "ShapeStore"):
-                self.RunMessageBox(_("Show Table"),
-                                   _("The layer '%s' has no table." % layer.Title()))
                 return
             table = layer.ShapeStore().Table()
             name = "table_view" + str(id(table))
@@ -997,6 +1008,14 @@
     """Return true if a layer is selected in the context"""
     return context.mainwindow.has_selected_layer()
 
+def _has_selected_layer_visible(context):
+    """Return true if a layer is selected in the context which is
+    visible."""
+    if context.mainwindow.has_selected_layer():
+        layer = context.mainwindow.current_layer()
+        if layer.Visible(): return True
+    return False
+
 def _has_selected_shape_layer(context):
     """Return true if a shape layer is selected in the context"""
     return context.mainwindow.has_selected_shape_layer()
@@ -1020,8 +1039,8 @@
     if map is not None:
         for layer in map.Layers():
             if layer.Visible():
-                return 1
-    return 0
+                return True
+    return False
 
 def _has_legend_shown(context):
     """Return true if the legend window is shown"""
@@ -1144,6 +1163,18 @@
 _method_command("layer_jointable", _("&Join Table..."), "LayerJoinTable",
                 sensitive = _has_selected_shape_layer,
                 helptext = _("Join and attach a table to the selected layer"))
+
+# further layer methods:
+_method_command("layer_to_top", _("&Top"), "LayerToTop",
+                helptext = _("Put selected layer to the top"),
+                sensitive = _has_selected_layer)
+_method_command("layer_to_bottom", _("&Bottom"), "LayerToBottom",
+                helptext = _("Put selected layer to the bottom"),
+                sensitive = _has_selected_layer)
+_method_command("layer_visibility", _("&Visible"), "ToggleLayerVisibility",
+                checked = _has_selected_layer_visible,
+                helptext = _("Toggle visibility of selected layer"),
+                sensitive = _has_selected_layer)
 
 def _can_unjoin(context):
     """Return whether the Layer/Unjoin command can be executed.





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)