[GRASS-SVN] r29937 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 3 02:45:59 EST 2008


Author: cmbarton
Date: 2008-02-03 02:45:59 -0500 (Sun, 03 Feb 2008)
New Revision: 29937

Modified:
   grass/trunk/gui/wxpython/gui_modules/georect.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
Log:
georectify (GCP) window and regular (map display) window now get GCPs marked with black crosses. Both also can access method in georect.


Modified: grass/trunk/gui/wxpython/gui_modules/georect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/georect.py	2008-02-03 07:41:50 UTC (rev 29936)
+++ grass/trunk/gui/wxpython/gui_modules/georect.py	2008-02-03 07:45:59 UTC (rev 29937)
@@ -162,8 +162,10 @@
                 pass
             else:
                 wx.MessageBox("Georectifying setup canceled.")
+                self.Cleanup()
         else:
             wx.MessageBox("Georectifying setup canceled.")
+            self.Cleanup()
 
         # start display showing xymap - need to put an if statement here
         if success != False:
@@ -181,18 +183,19 @@
     
             self.Map.AddLayer(type=rendertype, command=cmdlist,l_active=True,
                               l_hidden=False, l_opacity=1, l_render=False)
-    
+                
             self.xy_mapdisp = mapdisp.MapFrame(self.parent, title="Set ground control points (GCPs)",
                  pos=wx.DefaultPosition, size=(640,480),
                  style=wx.DEFAULT_FRAME_STYLE, toolbars=["georect"],
-                 Map=self.Map, gwiz=self, gismgr=self.parent, georect=True)
+                 Map=self.Map, gismgr=self.parent, georect=True)
             
             self.mapwin = self.xy_mapdisp.MapWindow
             
             # set mouse characteristics
             self.mapwin.mouse['box'] = 'point'
+            self.mapwin.mouse["use"] == "pointer"
             self.mapwin.zoomtype = 0
-            self.mapwin.pen     = wx.Pen(colour='black',   width=2, style=wx.SOLID)
+            self.mapwin.pen = wx.Pen(colour='black', width=2, style=wx.SOLID)
             self.mapwin.SetCursor(self.xy_mapdisp.cursors["cross"])
             
             # draw selected xy map
@@ -208,8 +211,11 @@
             self.gcpmgr.Show()
             self.gcpmgr.Refresh()
             self.gcpmgr.Update()
-
-        self.Cleanup()
+        else:
+            self.Cleanup()
+                    
+    def PrintCoord(self, coord, coordtype):
+        print coord,coordtype
         
     def SetSrcEnv(self, location, mapset):
         """Create environment to use for location and mapset
@@ -249,11 +255,13 @@
         #print 'maptype=',maptype
 
         return True
+        self.Cleanup()
 
     def Cleanup(self):
         # return to current location and mapset
         self.SwitchEnv('original')
-        self.parent.georect = False
+        self.parent.georectifying = False
+        self.xy_mapdisp.Destroy()
         self.wizard.Destroy()
 
 class LocationPage(TitledPage):

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-02-03 07:41:50 UTC (rev 29936)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-02-03 07:45:59 UTC (rev 29937)
@@ -858,6 +858,7 @@
 
         elif event.Moving():
             self.OnMouseMoving(event)
+        event.Skip()
 
     def OnLeftDown(self, event):
         """
@@ -1122,8 +1123,14 @@
                 self.DrawLines(pdc=self.pdcTmp)
             except:
                 pass
-        elif self.mouse["use"] == "pointer" and self.gismanager.georectifying:
+        elif self.mouse["use"] == "pointer" and self.parent.gismanager.georectifying:
             self.SetCursor(self.parent.cursors["cross"])
+            coord = self.Pixel2Cell(self.mouse['end'])
+            if self.parent.georect:
+                coordtype = 'gcp'
+            else:
+                coordtype = 'mapcoord'
+            self.gismanager.gr.PrintCoord(coord, coordtype)
             self.DrawCross(pdc=self.pdcTmp, coords=self.mouse['end'],
                                        size=5)
 
@@ -2030,7 +2037,7 @@
                  pos=wx.DefaultPosition, size=wx.DefaultSize,
                  style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"],
                  tree=None, notebook=None, gismgr=None, page=None,
-                 Map=None, auimgr=None, gwiz=None, georect=False):
+                 Map=None, auimgr=None, georect=False):
         """
             Main map display window with toolbars, statusbar and
             DrawWindow
@@ -2049,7 +2056,6 @@
                 gismgr  -- GIS Manager panel
                 page    -- notebook page with layer tree
                 Map     -- instance of render.Map
-                gwiz    -- ID of GeorectWizard
                 georect -- is window used by georectifier
         """
 
@@ -2057,13 +2063,12 @@
 
         wx.Frame.__init__(self, parent, id, title, pos, size, style)
 
-        self.gismanager = gismgr   # GIS Manager object
-        self.Map        = Map      # instance of render.Map
-        self.tree       = tree     # GIS Manager layer tree object
-        self.page       = page     # Notebook page holding the layer tree
-        self.layerbook  = notebook # GIS Manager layer tree notebook
-        self.georect    = georect  # Map display used for setting GCPs for georectifier
-        self.gwiz       = gwiz     # Georectifier object
+        self.gismanager = gismgr    # GIS Manager object
+        self.Map        = Map       # instance of render.Map
+        self.tree       = tree      # GIS Manager layer tree object
+        self.page       = page      # Notebook page holding the layer tree
+        self.layerbook  = notebook  # GIS Manager layer tree notebook
+        self.georect    = georect   # Map display used for setting GCPs for georectifier
         self.parent     = parent
 
         #
@@ -2281,15 +2286,24 @@
 
     def OnFocus(self, event):
         """
-        Change choicebook
-        page to match display
+        Change choicebook page to match display.
+        Or set display for georectifying
         """
-        
         if self.georect:
-            if event.GetActive():
-                self.gwiz.SwitchEnv('new')
-            else:
-                self.gwiz.SwitchEnv('original')
+            # display used to set GCPs in map to georectify
+            try:
+                if event.GetActive():
+                    self.gismanager.gr.SwitchEnv('new')
+                else:
+                    self.gismanager.gr.SwitchEnv('original')
+            except:
+                pass
+            
+        elif self.gismanager.georectifying:
+            # in georectifying session; display used to get get geographic
+            # coordinates for GCPs
+            self.MapWindow.pen = wx.Pen(colour='black', width=2, style=wx.SOLID)
+            self.MapWindow.SetCursor(self.cursors["cross"])
         else:
             # change bookcontrol page to page associated with display
             if self.page :



More information about the grass-commit mailing list