Browse Source

add GCP Manager, wxGUI version of i.points

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@42794 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 14 years ago
parent
commit
039650f207

+ 2 - 0
gui/wxpython/gui_modules/__init__.py

@@ -8,6 +8,8 @@ all = [
     "gcmd.py",
     "gdialogs.py",
     "georect.py",
+    "gcpmanager.py",
+    "gcpmapdisp.py",
     "ghelp.py"
     "globalvar.py",
     "goutput.py",

File diff suppressed because it is too large
+ 2536 - 0
gui/wxpython/gui_modules/gcpmanager.py


File diff suppressed because it is too large
+ 2385 - 0
gui/wxpython/gui_modules/gcpmapdisp.py


+ 7 - 0
gui/wxpython/gui_modules/mapdisp.py

@@ -143,6 +143,7 @@ class MapFrame(wx.Frame):
         self.toolbars = { 'map' : None,
                           'vdigit' : None,
                           'georect' : None, 
+                          'gcpdisp' : None, 
                           'nviz' : None }
         for toolb in toolbars:
             self.AddToolbar(toolb)
@@ -303,6 +304,7 @@ class MapFrame(wx.Frame):
         Currently known toolbars are:
          - 'map'     - basic map toolbar
          - 'vdigit'  - vector digitizer
+         - 'gcpdisp' - GCP Manager Display
          - 'georect' - georectifier
          - 'nviz'    - 3D view mode
         """
@@ -521,6 +523,11 @@ class MapFrame(wx.Frame):
             # in georectifying session; display used to get get geographic
             # coordinates for GCPs
             self.OnPointer(event)
+        elif self._layerManager and \
+                self._layerManager.gcpmanagement:
+            # in georectifying session; display used to get get geographic
+            # coordinates for GCPs
+            self.OnPointer(event)
         else:
             # change bookcontrol page to page associated with display
             if self.page:

+ 47 - 0
gui/wxpython/gui_modules/mapdisp_window.py

@@ -837,6 +837,17 @@ class BufferedWindow(MapWindow, wx.Window):
                 coordtype = 'mapcoord'
             self.parent.GetLayerManager().georectifying.DrawGCP(coordtype)
             
+        if not self.parent.IsStandalone() and \
+                self.parent.GetLayerManager().gcpmanagement:
+            # -> georectifier (redraw GCPs)
+            if self.parent.toolbars['gcpdisp']:
+                if self == self.parent.TgtMapWindow:
+                    coordtype = 'target'
+                else:
+                    coordtype = 'source'
+
+                self.parent.DrawGCP(coordtype)
+
         # 
         # clear measurement
         #
@@ -1149,6 +1160,9 @@ class BufferedWindow(MapWindow, wx.Window):
         elif event.RightUp():
             self.OnRightUp(event)
 
+        elif event.Entering():
+            self.OnMouseEnter(event)
+
         elif event.Moving():
             self.OnMouseMoving(event)
         
@@ -1946,6 +1960,19 @@ class BufferedWindow(MapWindow, wx.Window):
             self.DrawLines(pdc=self.pdcTmp)
         
         elif self.mouse["use"] == "pointer" and \
+                self.parent.GetLayerManager().gcpmanagement:
+            # -> GCP manager
+            if self.parent.toolbars['gcpdisp']:
+                coord = self.Pixel2Cell(self.mouse['end'])
+                if self.parent.MapWindow == self.parent.SrcMapWindow:
+                    coordtype = 'source'
+                else:
+                    coordtype = 'target'
+
+                self.parent.GetLayerManager().gcpmanagement.SetGCPData(coordtype, coord, self, confirm=True)
+                self.UpdateMap(render=False, renderVector=False)
+
+        elif self.mouse["use"] == "pointer" and \
                 self.parent.GetLayerManager().georectifying:
             # -> georectifying
             coord = self.Pixel2Cell(self.mouse['end'])
@@ -2365,6 +2392,19 @@ class BufferedWindow(MapWindow, wx.Window):
         # update statusbar
         self.parent.StatusbarUpdate()
         
+    def OnMouseEnter(self, event):
+        """!
+        Mouse entered window and no mouse buttons were pressed
+        """
+        if self.parent.GetLayerManager().gcpmanagement:
+            if self.parent.toolbars['gcpdisp']:
+                if not self.parent.MapWindow == self:
+                    self.parent.MapWindow = self
+                    self.parent.Map = self.Map
+                    self.parent.UpdateActive(self)
+        else:
+            event.Skip()
+
     def OnMouseMoving(self, event):
         """!
         Motion event and no mouse buttons were pressed
@@ -2539,6 +2579,9 @@ class BufferedWindow(MapWindow, wx.Window):
         elif zoomtype == 0:
             dx = x1 - x2
             dy = y1 - y2
+            if dx == 0 and dy == 0:
+                dx = x1 - self.Map.width / 2
+                dy = y1 - self.Map.height / 2
             newreg['w'], newreg['n'] = self.Pixel2Cell((dx, dy))
             newreg['e'], newreg['s'] = self.Pixel2Cell((self.Map.width  + dx,
                                                         self.Map.height + dy))
@@ -2597,6 +2640,8 @@ class BufferedWindow(MapWindow, wx.Window):
                 toolbar = self.parent.toolbars['map']
             elif self.parent.GetName() == 'GRMapWindow':
                 toolbar = self.parent.toolbars['georect']
+            elif self.parent.GetName() == 'GCPMapWindow':
+                toolbar = self.parent.toolbars['gcpdisp']
             
             toolbar.Enable('zoomback', enable = False)
         
@@ -2641,6 +2686,8 @@ class BufferedWindow(MapWindow, wx.Window):
             toolbar = self.parent.toolbars['map']
         elif self.parent.GetName() == 'GRMapWindow':
             toolbar = self.parent.toolbars['georect']
+        elif self.parent.GetName() == 'GCPMapWindow':
+            toolbar = self.parent.toolbars['gcpdisp']
         
         toolbar.Enable('zoomback', enable)
         

+ 15 - 0
gui/wxpython/gui_modules/preferences.py

@@ -424,6 +424,21 @@ class Settings:
                     'enabled' : True
                     },
                 },
+            'gcpman' : {
+                'rms' : {
+                    'highestonly' : True,
+                    'sdfactor' : 1,
+                    },
+                'symbol' : {
+                    'color' : (0, 0, 255, 255),
+                    'hcolor' : (255, 0, 0, 255),
+                    'scolor' : (0, 255, 0, 255),
+                    'ucolor' : (255, 165, 0, 255),
+                    'unused' : True,
+                    'size' : 8,
+                    'width' : 2,
+                    },
+                },
             'georect' : {
                 'symbol' : {
                     'color' : (0, 0, 255, 255),

+ 147 - 0
gui/wxpython/gui_modules/toolbars.py

@@ -311,6 +311,153 @@ class MapToolbar(AbstractToolbar):
                      self.printmap):
             self.EnableTool(tool, enabled)
         
+class GCPManToolbar(AbstractToolbar):
+    """!
+    Toolbar for managing ground control points
+
+    @param parent reference to GCP widget
+    """
+    def __init__(self, parent):
+        AbstractToolbar.__init__(self, parent)
+        
+        self.InitToolbar(self.ToolbarData())
+        
+        # realize the toolbar
+        self.Realize()
+
+    def ToolbarData(self):
+        self.gcpSave = wx.NewId()
+        self.gcpReload = wx.NewId()
+        self.gcpAdd = wx.NewId()
+        self.gcpDelete = wx.NewId()
+        self.gcpClear = wx.NewId()
+        self.rms = wx.NewId()
+        self.georect = wx.NewId()
+
+        return (
+            (self.gcpSave, 'grGcpSave', Icons["grGcpSave"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["grGcpSave"].GetLabel(), Icons["grGcpSave"].GetDesc(),
+             self.parent.SaveGCPs),
+            (self.gcpReload, 'grGcpReload', Icons["grGcpReload"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["grGcpReload"].GetLabel(), Icons["grGcpReload"].GetDesc(), 
+             self.parent.ReloadGCPs),
+            ("", "", "", "", "", "", ""),
+            (self.gcpAdd, 'grGrGcpAdd', Icons["grGcpAdd"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["grGcpAdd"].GetLabel(), Icons["grGcpAdd"].GetDesc(),
+             self.parent.AddGCP),
+            (self.gcpDelete, 'grGrGcpDelete', Icons["grGcpDelete"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["grGcpDelete"].GetLabel(), Icons["grGcpDelete"].GetDesc(), 
+             self.parent.DeleteGCP),
+            (self.gcpClear, 'grGcpClear', Icons["grGcpClear"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["grGcpClear"].GetLabel(), Icons["grGcpClear"].GetDesc(), 
+             self.parent.ClearGCP),
+            ("", "", "", "", "", "", ""),
+            (self.rms, 'grGcpRms', Icons["grGcpRms"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["grGcpRms"].GetLabel(), Icons["grGcpRms"].GetDesc(),
+             self.parent.OnRMS),
+            (self.georect, 'grGeorect', Icons["grGeorect"].GetBitmap(), 
+             wx.ITEM_NORMAL, Icons["grGeorect"].GetLabel(), Icons["grGeorect"].GetDesc(),
+             self.parent.OnGeorect),
+            )
+    
+class GCPDisplayToolbar(AbstractToolbar):
+    """
+    GCP Display toolbar
+    """
+    def __init__(self, parent):
+        """!
+        GCP Display toolbar constructor
+        """
+        AbstractToolbar.__init__(self, parent)
+        
+        self.InitToolbar(self.ToolbarData())
+        
+        # add tool to toggle active map window
+        self.togglemapid = wx.NewId()
+        self.togglemap = wx.Choice(parent=self, id=self.togglemapid,
+						    choices = [_('source'), _('target')],
+						    style=wx.CB_READONLY)
+
+        self.InsertControl(10, self.togglemap)
+
+        self.SetToolShortHelp(self.togglemapid, '%s %s %s' % (_('Set map canvas for '),
+                                                              Icons["zoom_back"].GetLabel(),
+                                                              _(' / Zoom to map')))
+
+        # realize the toolbar
+        self.Realize()
+        
+        self.action = { 'id' : self.gcpset }
+        self.defaultAction = { 'id' : self.gcpset,
+                               'bind' : self.parent.OnPointer }
+        
+        self.OnTool(None)
+        
+        self.EnableTool(self.zoomback, False)
+        
+    def ToolbarData(self):
+        """!Toolbar data"""
+        self.displaymap = wx.NewId()
+        self.rendermap = wx.NewId()
+        self.erase = wx.NewId()
+        self.gcpset = wx.NewId()
+        self.pan = wx.NewId()
+        self.zoomin = wx.NewId()
+        self.zoomout = wx.NewId()
+        self.zoomback = wx.NewId()
+        self.zoomtomap = wx.NewId()
+        self.zoommenu = wx.NewId()
+        self.settings = wx.NewId()
+        self.helpid = wx.NewId()
+        self.quit = wx.NewId()
+        
+        # tool, label, bitmap, kind, shortHelp, longHelp, handler
+        return (
+            (self.displaymap, "displaymap", Icons["displaymap"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["displaymap"].GetLabel(), Icons["displaymap"].GetDesc(),
+             self.parent.OnDraw),
+            (self.rendermap, "rendermap", Icons["rendermap"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["rendermap"].GetLabel(), Icons["rendermap"].GetDesc(),
+             self.parent.OnRender),
+            (self.erase, "erase", Icons["erase"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
+             self.parent.OnErase),
+            ("", "", "", "", "", "", ""),
+            (self.gcpset, "grGcpSet", Icons["grGcpSet"].GetBitmap(),
+             wx.ITEM_RADIO, Icons["grGcpSet"].GetLabel(), Icons["grGcpSet"].GetDesc(),
+             self.parent.OnPointer),
+            (self.pan, "pan", Icons["pan"].GetBitmap(),
+             wx.ITEM_RADIO, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
+             self.parent.OnPan),
+            (self.zoomin, "zoom_in", Icons["zoom_in"].GetBitmap(),
+             wx.ITEM_RADIO, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(),
+             self.parent.OnZoomIn),
+            (self.zoomout, "zoom_out", Icons["zoom_out"].GetBitmap(),
+             wx.ITEM_RADIO, Icons["zoom_out"].GetLabel(), Icons["zoom_out"].GetDesc(),
+             self.parent.OnZoomOut),
+            (self.zoommenu, "zoommenu", Icons["zoommenu"].GetBitmap(),
+             wx.ITEM_NORMAL, _("Adjust display zoom"), Icons["zoommenu"].GetDesc(),
+             self.parent.OnZoomMenuGCP),
+            ("", "", "", "", "", "", ""),
+            (self.zoomback, "zoom_back", Icons["zoom_back"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["zoom_back"].GetLabel(), Icons["zoom_back"].GetDesc(),
+             self.parent.OnZoomBack),
+            (self.zoomtomap, "zoomtomap", Icons["zoom_extent"].GetBitmap(),
+             wx.ITEM_NORMAL, _("Zoom to map"), _("Zoom to displayed map"),
+             self.parent.OnZoomToMap),
+            ("", "", "", "", "", "", ""),
+            (self.settings, 'grSettings', Icons["grSettings"].GetBitmap(), 
+             wx.ITEM_NORMAL, Icons["grSettings"].GetLabel(), Icons["grSettings"].GetDesc(),
+             self.parent.OnSettings),
+            (self.helpid, 'grHelp', wx.ArtProvider.GetBitmap(id=wx.ART_HELP, client=wx.ART_TOOLBAR, size=globalvar.toolbarSize), 
+             wx.ITEM_NORMAL, _('Show Help'), _('Show Help for GCP Manager'),
+             self.parent.OnHelp),
+            ("", "", "", "", "", "", ""),
+            (self.quit, 'grGcpQuit', Icons["grGcpQuit"].GetBitmap(), 
+             wx.ITEM_NORMAL, Icons["grGcpQuit"].GetLabel(), Icons["grGcpQuit"].GetDesc(),
+             self.parent.OnQuit)
+            )
+    
 class GRToolbar(AbstractToolbar):
     """
     Georectification toolbar

+ 7 - 0
gui/wxpython/wxgui.py

@@ -71,6 +71,7 @@ import gui_modules.rules as rules
 import gui_modules.mcalc_builder as mapcalculator
 import gui_modules.gcmd as gcmd
 import gui_modules.georect as georect
+import gui_modules.gcpmanager as gcpmanager
 import gui_modules.dbm as dbm
 import gui_modules.workspace as workspace
 import gui_modules.goutput as goutput
@@ -119,6 +120,7 @@ class GMFrame(wx.Frame):
         self.workspaceFile = workspace    # workspace file
         self.workspaceChanged = False     # track changes in workspace
         self.georectifying = None         # reference to GCP class or None
+        self.gcpmanagement = None         # reference to GCP class or None
         # list of open dialogs
         self.dialogs        = dict()
         self.dialogs['preferences'] = None
@@ -250,6 +252,11 @@ class GMFrame(wx.Frame):
         """
         georect.GeorectWizard(self)
 
+    def OnGCPManager(self, event):
+        """!Launch georectifier module
+        """
+        gcpmanager.GCPWizard(self)
+
     def OnGModeler(self, event):
         """!Launch Graphical Modeler"""
         win = gmodeler.ModelFrame(parent = self)

+ 5 - 0
gui/wxpython/xml/menudata.xml

@@ -614,6 +614,11 @@
 	</menu>
 	<separator />
 	<menuitem>
+	  <label>Manage Ground Control Points</label>
+	  <help>Manage Ground Control Points for Georectification</help>
+	  <handler>OnGCPManager</handler>
+	</menuitem>
+	<menuitem>
 	  <label>Georectify</label>
 	  <help>Georectify raster and vector maps</help>
 	  <handler>OnGeorectify</handler>