GRASS Programmer's Manual  6.5.svn(2012)-r51648
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
gcp/toolbars.py
Go to the documentation of this file.
00001 """!
00002 @package gcp.toolbars
00003 
00004 @brief Georectification module - toolbars
00005 
00006 Classes:
00007  - toolbars::GCPManToolbar
00008  - toolbars::GCPDisplayToolbar
00009 
00010 (C) 2007-2011 by the GRASS Development Team
00011 
00012 This program is free software under the GNU General Public License
00013 (>=v2). Read the file COPYING that comes with GRASS for details.
00014 
00015 @author Markus Metz
00016 """
00017 
00018 import os
00019 import sys
00020 
00021 import wx
00022 
00023 from core              import globalvar
00024 from gui_core.toolbars import BaseToolbar, BaseIcons
00025 from icon              import MetaIcon
00026    
00027 class GCPManToolbar(BaseToolbar):
00028     """!Toolbar for managing ground control points
00029 
00030     @param parent reference to GCP widget
00031     """
00032     def __init__(self, parent):
00033         BaseToolbar.__init__(self, parent)
00034         
00035         self.InitToolbar(self._toolbarData())
00036         
00037         # realize the toolbar
00038         self.Realize()
00039 
00040     def _toolbarData(self):
00041         icons = {
00042             'gcpSave'    : MetaIcon(img = 'gcp-save',
00043                                     label = _('Save GCPs to POINTS file')),
00044             'gcpReload'  : MetaIcon(img = 'reload',
00045                                     label = _('Reload GCPs from POINTS file')),
00046             'gcpAdd'     : MetaIcon(img = 'gcp-add',
00047                                     label = _('Add new GCP')),
00048             'gcpDelete'  : MetaIcon(img = 'gcp-delete',
00049                                     label = _('Delete selected GCP')),
00050             'gcpClear'   : MetaIcon(img = 'gcp-remove',
00051                                     label = _('Clear selected GCP')),
00052             'gcpRms'     : MetaIcon(img = 'gcp-rms',
00053                                     label = _('Recalculate RMS error')),
00054             'georectify' : MetaIcon(img = 'georectify',
00055                                     label = _('Georectify')),
00056             }
00057         
00058         return self._getToolbarData((('gcpSave', icons["gcpSave"],
00059                                       self.parent.SaveGCPs),
00060                                      ('gcpReload', icons["gcpReload"],
00061                                       self.parent.ReloadGCPs),
00062                                      (None, ),
00063                                      ('gcpAdd', icons["gcpAdd"],
00064                                       self.parent.AddGCP),
00065                                      ('gcpDelete', icons["gcpDelete"],
00066                                       self.parent.DeleteGCP),
00067                                      ('gcpClear', icons["gcpClear"],
00068                                       self.parent.ClearGCP),
00069                                      (None, ),
00070                                      ('rms', icons["gcpRms"],
00071                                       self.parent.OnRMS),
00072                                      ('georect', icons["georectify"],
00073                                       self.parent.OnGeorect))
00074                                     )
00075     
00076 class GCPDisplayToolbar(BaseToolbar):
00077     """
00078     GCP Display toolbar
00079     """
00080     def __init__(self, parent):
00081         """!
00082         GCP Display toolbar constructor
00083         """
00084         BaseToolbar.__init__(self, parent)
00085         
00086         self.InitToolbar(self._toolbarData())
00087         
00088         # add tool to toggle active map window
00089         self.togglemapid = wx.NewId()
00090         self.togglemap = wx.Choice(parent = self, id = self.togglemapid,
00091                                    choices = [_('source'), _('target')])
00092 
00093         self.InsertControl(10, self.togglemap)
00094 
00095         self.SetToolShortHelp(self.togglemapid, '%s %s %s' % (_('Set map canvas for '),
00096                                                               BaseIcons["zoomBack"].GetLabel(),
00097                                                               _(' / Zoom to map')))
00098 
00099         # realize the toolbar
00100         self.Realize()
00101         
00102         self.action = { 'id' : self.gcpset }
00103         self.defaultAction = { 'id' : self.gcpset,
00104                                'bind' : self.parent.OnPointer }
00105         
00106         self.OnTool(None)
00107         
00108         self.EnableTool(self.zoomback, False)
00109         
00110     def _toolbarData(self):
00111         """!Toolbar data"""
00112         icons = {
00113             'gcpSet'    : MetaIcon(img = 'gcp-create',
00114                                    label = _('Set GCP'),
00115                                    desc = _('Define GCP (Ground Control Points)')),
00116             'quit'      : BaseIcons['quit'].SetLabel(_('Quit georectification tool')),
00117             'settings'  : BaseIcons['settings'].SetLabel( _('Georectifier settings')),
00118             'help'      : BaseIcons['help'].SetLabel(_('Georectifier manual')),
00119             }
00120         
00121         return self._getToolbarData((("displaymap", BaseIcons["display"],
00122                                       self.parent.OnDraw),
00123                                      ("rendermap", BaseIcons["render"],
00124                                       self.parent.OnRender),
00125                                      ("erase", BaseIcons["erase"],
00126                                       self.parent.OnErase),
00127                                      (None, ),
00128                                      ("gcpset", icons["gcpSet"],
00129                                       self.parent.OnPointer),
00130                                      ("pan", BaseIcons["pan"],
00131                                       self.parent.OnPan),
00132                                      ("zoomin", BaseIcons["zoomIn"],
00133                                       self.parent.OnZoomIn),
00134                                      ("zoomout", BaseIcons["zoomOut"],
00135                                       self.parent.OnZoomOut),
00136                                      ("zoommenu", BaseIcons["zoomMenu"],
00137                                       self.parent.OnZoomMenuGCP),
00138                                      (None, ),
00139                                      ("zoomback", BaseIcons["zoomBack"],
00140                                       self.parent.OnZoomBack),
00141                                      ("zoomtomap", BaseIcons["zoomExtent"],
00142                                       self.parent.OnZoomToMap),
00143                                      (None, ),
00144                                      ('settings', icons["settings"],
00145                                       self.parent.OnSettings),
00146                                      ('help', icons["help"],
00147                                       self.parent.OnHelp),
00148                                      (None, ),
00149                                      ('quit', icons["quit"],
00150                                       self.parent.OnQuit))
00151                                     )