[Thuban-commits] r2761 - in trunk/thuban: . Thuban/UI

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 25 02:19:27 CEST 2007


Author: bernhard
Date: 2007-04-25 02:19:25 +0200 (Wed, 25 Apr 2007)
New Revision: 2761

Modified:
   trunk/thuban/ChangeLog
   trunk/thuban/Thuban/UI/mainwindow.py
Log:
* Thuban/UI/mainwindow.py: Refactored, now the build-in function map()
can be used again:
a) renamed local variables map to mymap. It was covering up map().
b) removed calls filling  map = self.Map() in
DatabaseManagement()and LayerProjection() as the result was not
used and MapCanvas.Map() does not have a side effect.


Modified: trunk/thuban/ChangeLog
===================================================================
--- trunk/thuban/ChangeLog	2007-04-24 23:26:00 UTC (rev 2760)
+++ trunk/thuban/ChangeLog	2007-04-25 00:19:25 UTC (rev 2761)
@@ -3,6 +3,13 @@
 	Fixing the problem that with localisation the selection of
 	a class generator might not work. (Reported by Samuel Mesa.)
 
+	* Thuban/UI/mainwindow.py: Refactored, now the build-in function map() 
+	can be used again:
+	a) renamed local variables map to mymap. It was covering up map().
+	b) removed calls filling  map = self.Map() in
+	DatabaseManagement()and LayerProjection() as the result was not
+	used and MapCanvas.Map() does not have a side effect.
+
 	*  Thuban/UI/classgen.py(ClassGenDialog): translating result from
 	genChoice.GetString() back to internal encoding.
 	

Modified: trunk/thuban/Thuban/UI/mainwindow.py
===================================================================
--- trunk/thuban/Thuban/UI/mainwindow.py	2007-04-24 23:26:00 UTC (rev 2760)
+++ trunk/thuban/Thuban/UI/mainwindow.py	2007-04-25 00:19:25 UTC (rev 2761)
@@ -514,8 +514,8 @@
             self.canvas.Destroy()
             self.Destroy()
 
-    def SetMap(self, map):
-        self.canvas.SetMap(map)
+    def SetMap(self, mymap):
+        self.canvas.SetMap(mymap)
         self.update_title()
 
         dialog = self.FindRegisteredDock("legend")
@@ -551,7 +551,6 @@
         name = "dbmanagement"
         dialog = self.get_open_dialog(name)
         if dialog is None:
-            map = self.canvas.Map()
             dialog = DBFrame(self, name, self.application.Session())
             self.add_dialog(name, dialog)
             dialog.Show()
@@ -567,8 +566,8 @@
             filenames = dlg.GetPaths()
             for filename in filenames:
                 title = os.path.splitext(os.path.basename(filename))[0]
-                map = self.canvas.Map()
-                has_layers = map.HasLayers()
+                mymap = self.canvas.Map()
+                has_layers = mymap.HasLayers()
                 try:
                     store = self.application.Session().OpenShapefile(filename)
                 except IOError:
@@ -577,7 +576,7 @@
                                        _("Can't open the file '%s'.")%filename)
                 else:
                     layer = Layer(title, store)
-                    map.AddLayer(layer)
+                    mymap.AddLayer(layer)
                     if not has_layers:
                         # if we're adding a layer to an empty map, fit the
                         # new map to the window
@@ -590,10 +589,10 @@
                            self.application.Path("data"), "", "*.*",
                            wx.OPEN)
         if dlg.ShowModal() == wx.ID_OK:
-            filename = dlg.GetPath()
+            filenames = GetPaths()
             title = os.path.splitext(os.path.basename(filename))[0]
-            map = self.canvas.Map()
-            has_layers = map.HasLayers()
+            mymap = self.canvas.Map()
+            has_layers = mymap.HasLayers()
             try:
                 layer = RasterLayer(title, filename)
             except IOError:
@@ -601,7 +600,7 @@
                 self.RunMessageBox(_("Add Image Layer"),
                                    _("Can't open the file '%s'.") % filename)
             else:
-                map.AddLayer(layer)
+                mymap.AddLayer(layer)
                 if not has_layers:
                     # if we're adding a layer to an empty map, fit the
                     # new map to the window
@@ -631,10 +630,10 @@
                                    % dbtable)
                 return
 
-            map = self.canvas.Map()
+            mymap = self.canvas.Map()
 
-            has_layers = map.HasLayers()
-            map.AddLayer(layer)
+            has_layers = mymap.HasLayers()
+            mymap.AddLayer(layer)
             if not has_layers:
                 self.canvas.FitMapToWindow()
 
@@ -759,9 +758,9 @@
         dialog = self.get_open_dialog(name)
 
         if dialog is None:
-            map = self.canvas.Map()
+            mymap = self.canvas.Map()
             dialog = projdialog.ProjFrame(self, name,
-                     _("Map Projection: %s") % map.Title(), map)
+                     _("Map Projection: %s") % mymap.Title(), mymap)
             self.add_dialog(name, dialog)
             dialog.Show()
         dialog.Raise()
@@ -774,7 +773,6 @@
         dialog = self.get_open_dialog(name)
 
         if dialog is None:
-            map = self.canvas.Map()
             dialog = projdialog.ProjFrame(self, name,
                      _("Layer Projection: %s") % layer.Title(), layer)
             self.add_dialog(name, dialog)
@@ -1035,7 +1033,7 @@
                 # FIXME: bring dialog to front?
                 pass
 
-    def title_changed(self, map):
+    def title_changed(self, mymap):
         """Subscribed to the canvas' TITLE_CHANGED messages"""
         self.update_title()
 
@@ -1052,9 +1050,9 @@
         class this usually only means that a different map has been set
         or the current map's title has changed.
         """
-        map = self.Map()
-        if map is not None:
-            title = _("Thuban - %s") % (map.Title(),)
+        mymap = self.Map()
+        if mymap is not None:
+            title = _("Thuban - %s") % (mymap.Title(),)
         else:
             title = _("Thuban")
         self.SetTitle(title)
@@ -1127,9 +1125,9 @@
     """Return true iff theres a visible map in the mainwindow.
 
     A visible map is a map with at least one visible layer."""
-    map = context.mainwindow.Map()
-    if map is not None:
-        for layer in map.Layers():
+    mymap = context.mainwindow.Map()
+    if mymap is not None:
+        for layer in mymap.Layers():
             if layer.Visible():
                 return True
     return False



More information about the Thuban-commits mailing list