[GRASS-SVN] r43885 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 13 09:23:06 EDT 2010


Author: mmetz
Date: 2010-10-13 06:23:05 -0700 (Wed, 13 Oct 2010)
New Revision: 43885

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcpmanager.py
Log:
backport gcpmanager fixes from trunk (r43772, r43774, r43883)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcpmanager.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcpmanager.py	2010-10-13 13:18:24 UTC (rev 43884)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcpmanager.py	2010-10-13 13:23:05 UTC (rev 43885)
@@ -19,9 +19,9 @@
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
 
- at author Markus Metz
 @author Michael Barton
 @author Updated by Martin Landa <landa.martin gmail.com>
+ at author Markus Metz redesign georectfier -> GCP Manager
 """
 
 import os
@@ -287,28 +287,16 @@
             return False
 
         if grc == 'target':
-            os.environ["GISRC"] = str(self.target_gisrc)
+            os.environ['GISRC'] = str(self.target_gisrc)
             gisrcfile = str(self.target_gisrc)
         elif grc == 'source':
-            os.environ["GISRC"] = str(self.source_gisrc)
+            os.environ['GISRC'] = str(self.source_gisrc)
             gisrcfile = str(self.source_gisrc)
 
         # do it the hard way
-        gisrc_dict = {}
-        try:
-            f = open(gisrcfile, 'r')
-            for line in f.readlines():
-                line = line.replace('\n', '').strip()
-                if len(line) < 1:
-                    continue
-                key, value = line.split(':', 1)
-                gisrc_dict[key.strip()] = value.strip()
-        finally:
-            f.close()
+        gcmd.RunCommand('g.gisenv', 'set=LOCATION_NAME=%s' % self.newlocation)
+        gcmd.RunCommand('g.gisenv', 'set=MAPSET=%s' % self.newmapset)
 
-        gcmd.RunCommand('g.gisenv', 'set=LOCATION_NAME=%s' % gisrc_dict['LOCATION_NAME'])
-        gcmd.RunCommand('g.gisenv', 'set=MAPSET=%s' % gisrc_dict['MAPSET'])
-
         return True
     
     def OnWizFinished(self):
@@ -476,7 +464,7 @@
         self.xygroup = ''
 
         # default extension
-        self.extension = 'georect' + str(os.getpid())
+        self.extension = '.georect' + str(os.getpid())
 
         #
         # layout
@@ -1350,10 +1338,6 @@
         if self.CheckGCPcount():
             # calculate RMS
             self.RMSError(self.xygroup, self.gr_order)
-        else:
-            # draw GCPs (source and target)
-            sourceMapWin.UpdateMap(render=False, renderVector=False)
-            targetMapWin.UpdateMap(render=False, renderVector=False)
 
     def ReloadGCPs(self, event):
         """!Reload data from file"""
@@ -1373,6 +1357,17 @@
 
         self.list.LoadData()
         self.itemDataMap = self.mapcoordlist
+
+        if self._col != -1:
+            self.list.ClearColumnImage(self._col)
+        self._colSortFlag = [1] * self.list.GetColumnCount()
+
+        # draw GCPs (source and target)
+        sourceMapWin = self.SrcMapWindow
+        sourceMapWin.UpdateMap(render=False, renderVector=False)
+        if self.show_target:
+            targetMapWin = self.TgtMapWindow
+            targetMapWin.UpdateMap(render=False, renderVector=False)
     
     def OnFocus(self, event):
         # self.grwiz.SwitchEnv('source')
@@ -1383,6 +1378,12 @@
         RMS button handler
         """
         self.RMSError(self.xygroup,self.gr_order)
+
+        sourceMapWin = self.SrcMapWindow
+        sourceMapWin.UpdateMap(render=False, renderVector=False)
+        if self.show_target:
+            targetMapWin = self.TgtMapWindow
+            targetMapWin.UpdateMap(render=False, renderVector=False)
         
     def CheckGCPcount(self, msg=False):
         """
@@ -1417,16 +1418,28 @@
 
         if maptype == 'cell':
             self.grwiz.SwitchEnv('source')
-            cmdlist = ['i.rectify','-a','group=%s' % self.xygroup,
-                       'extension=%s' % self.extension,'order=%s' % self.gr_order]
+
             if self.clip_to_region:
-                cmdlist.append('-c')
-            
-            self.parent.goutput.RunCmd(cmdlist, compReg=False,
-                                       switchPage=True)
-            
-            time.sleep(.1)
+                flags = "ac"
+            else:
+                flags = "a"
 
+            busy = wx.BusyInfo(message=_("Rectifying images, please wait..."),
+                               parent=self)
+            wx.Yield()
+
+            ret = gcmd.RunCommand('i.rectify',
+                                  parent = self,
+                                  read = False,
+                                  group = self.xygroup,
+                                  extension = self.extension,
+                                  order = self.gr_order,
+                                  flags = flags)
+
+            # provide feedback on success/failure ?
+        
+            busy.Destroy()
+                
         elif maptype == 'vector':
             outmsg = ''
             # loop through all vectors in VREF
@@ -1746,12 +1759,6 @@
         self.bkw_rmserror = round((sumsq_bkw_err/GCPcount)**0.5,4)
         self.list.ResizeColumns()
 
-        sourceMapWin = self.SrcMapWindow
-        sourceMapWin.UpdateMap(render=False, renderVector=False)
-        if self.show_target:
-            targetMapWin = self.TgtMapWindow
-            targetMapWin.UpdateMap(render=False, renderVector=False)
-
     def GetNewExtend(self, region, map = None):
 
         coord_file = utils.GetTempfile()



More information about the grass-commit mailing list