[GRASS-SVN] r55003 - in grass/trunk/gui/wxpython: gui_core mapdisp

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 12 00:32:00 PST 2013


Author: annakrat
Date: 2013-02-12 00:32:00 -0800 (Tue, 12 Feb 2013)
New Revision: 55003

Modified:
   grass/trunk/gui/wxpython/gui_core/query.py
   grass/trunk/gui/wxpython/mapdisp/frame.py
Log:
wxGUI: add query coordinates to dialog

Modified: grass/trunk/gui/wxpython/gui_core/query.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/query.py	2013-02-12 05:39:44 UTC (rev 55002)
+++ grass/trunk/gui/wxpython/gui_core/query.py	2013-02-12 08:32:00 UTC (rev 55003)
@@ -62,21 +62,9 @@
     def _load(self):
         self.tree.DeleteAllItems()
         self.root = self.tree.AddRoot("The Root Item")
-        # TODO: move elsewhere
         for part in self.data:
-            if 'Map' in part:
-                itemText = part['Map']
-                if 'Mapset' in part:
-                    itemText += '@' + part['Mapset']
-                    del part['Mapset']
-                item = self.tree.AppendItem(self.root, text = itemText)
-                del part['Map']
-                if part:
-                    self._addItem(item, part)
-                else:
-                    self.tree.AppendItem(item, text = _("Nothing found"))
-            else:
-                self._addItem(self.root, part)
+            self._addItem(self.root, part)
+
         self.tree.UnselectAll()
         self.tree.ExpandAll(self.root)
 
@@ -122,6 +110,29 @@
         event.Skip()
 
 
+def PrepareQueryResults(coordinates, result):
+    """!Prepare query results as a Query dialog input.
+
+    Adds coordinates, improves vector results tree structure.
+    """
+    data = []
+    data.append({_("east"): coordinates[0]})
+    data.append({_("north"): coordinates[1]})
+    for part in result:
+        if 'Map' in part:
+            itemText = part['Map']
+            if 'Mapset' in part:
+                itemText += '@' + part['Mapset']
+                del part['Mapset']
+            del part['Map']
+            if part:
+                data.append({itemText: part})
+            else:
+                data.append({itemText: _("Nothing found")})
+        else:
+            data.append(part)
+    return data
+
 def test():
     app = wx.PySimpleApp()
     import pprint
@@ -134,7 +145,8 @@
                                   coord=(633177.897487,221352.921257), distance=10)
     
     testdata = testdata1 + testdata2
-    frame = QueryDialog(parent = None, data = testdata)
+    data = PrepareQueryResults(coordinates = (638509.051416,224742.348346), result = testdata)
+    frame = QueryDialog(parent = None, data = data)
     frame.ShowModal()
     frame.Destroy()
     app.MainLoop()

Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py	2013-02-12 05:39:44 UTC (rev 55002)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py	2013-02-12 08:32:00 UTC (rev 55003)
@@ -48,7 +48,7 @@
 from core.debug         import Debug
 from core.settings      import UserSettings
 from gui_core.mapdisp   import SingleMapFrame
-from gui_core.query     import QueryDialog
+from gui_core.query     import QueryDialog, PrepareQueryResults
 from mapdisp.mapwindow  import BufferedWindow
 from mapdisp.overlays   import LegendController, BarscaleController
 from modules.histogram  import HistogramFrame
@@ -730,6 +730,7 @@
             self._queryHighlight(vectQuery)
 
         result = rastQuery + vectQuery
+        result = PrepareQueryResults(coordinates = (east, north), result = result)
         if self.dialogs['query']:
             self.dialogs['query'].Raise()
             self.dialogs['query'].SetData(result)



More information about the grass-commit mailing list