toolbars.py 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. """!
  2. @package gcp.toolbars
  3. @brief Georectification module - toolbars
  4. Classes:
  5. - toolbars::GCPMapToolbar
  6. - toolbars::GCPDisplayToolbar
  7. (C) 2007-2011 by the GRASS Development Team
  8. This program is free software under the GNU General Public License
  9. (>=v2). Read the file COPYING that comes with GRASS for details.
  10. @author Markus Metz
  11. """
  12. import os
  13. import sys
  14. import wx
  15. from core import globalvar
  16. from core.utils import _
  17. from gui_core.toolbars import BaseToolbar, BaseIcons
  18. from icon import MetaIcon
  19. class GCPManToolbar(BaseToolbar):
  20. """!Toolbar for managing ground control points
  21. @param parent reference to GCP widget
  22. """
  23. def __init__(self, parent):
  24. BaseToolbar.__init__(self, parent)
  25. self.InitToolbar(self._toolbarData())
  26. # realize the toolbar
  27. self.Realize()
  28. def _toolbarData(self):
  29. icons = {
  30. 'gcpAdd' : MetaIcon(img = 'gcp-add',
  31. label = _('Add new GCP to the list')),
  32. 'gcpDelete' : MetaIcon(img = 'gcp-delete',
  33. label = _('Delete selected GCP')),
  34. 'gcpClear' : MetaIcon(img = 'gcp-remove',
  35. label = _('Clear selected GCP')),
  36. 'gcpRms' : MetaIcon(img = 'gcp-rms',
  37. label = _('Recalculate RMS error')),
  38. 'georectify' : MetaIcon(img = 'georectify',
  39. label = _('Georectify')),
  40. 'gcpSave' : MetaIcon(img = 'gcp-save',
  41. label = _('Save GCPs to POINTS file')),
  42. 'gcpReload' : MetaIcon(img = 'reload',
  43. label = _('Reload GCPs from POINTS file')),
  44. }
  45. return self._getToolbarData((('gcpAdd', icons["gcpAdd"],
  46. self.parent.AddGCP),
  47. ('gcpDelete', icons["gcpDelete"],
  48. self.parent.DeleteGCP),
  49. ('gcpClear', icons["gcpClear"],
  50. self.parent.ClearGCP),
  51. (None, ),
  52. ('rms', icons["gcpRms"],
  53. self.parent.OnRMS),
  54. ('georect', icons["georectify"],
  55. self.parent.OnGeorect),
  56. (None, ),
  57. ('gcpSave', icons["gcpSave"],
  58. self.parent.SaveGCPs),
  59. ('gcpReload', icons["gcpReload"],
  60. self.parent.ReloadGCPs))
  61. )
  62. class GCPDisplayToolbar(BaseToolbar):
  63. """!GCP Display toolbar
  64. """
  65. def __init__(self, parent):
  66. """!GCP Display toolbar constructor
  67. """
  68. BaseToolbar.__init__(self, parent)
  69. self.InitToolbar(self._toolbarData())
  70. # add tool to toggle active map window
  71. self.togglemapid = wx.NewId()
  72. self.togglemap = wx.Choice(parent = self, id = self.togglemapid,
  73. choices = [_('source'), _('target')])
  74. self.InsertControl(10, self.togglemap)
  75. self.SetToolShortHelp(self.togglemapid, '%s %s %s' % (_('Set map canvas for '),
  76. BaseIcons["zoomBack"].GetLabel(),
  77. _(' / Zoom to map')))
  78. # realize the toolbar
  79. self.Realize()
  80. self.action = { 'id' : self.gcpset }
  81. self.defaultAction = { 'id' : self.gcpset,
  82. 'bind' : self.parent.OnPointer }
  83. self.OnTool(None)
  84. self.EnableTool(self.zoomback, False)
  85. def _toolbarData(self):
  86. """!Toolbar data"""
  87. icons = {
  88. 'gcpSet' : MetaIcon(img = 'gcp-create',
  89. label = _('Update GCP coordinates'),
  90. desc = _('Update GCP coordinates)')),
  91. 'quit' : BaseIcons['quit'].SetLabel(_('Quit georectification tool')),
  92. 'settings' : BaseIcons['settings'].SetLabel( _('Georectifier settings')),
  93. 'help' : BaseIcons['help'].SetLabel(_('Georectifier manual')),
  94. }
  95. return self._getToolbarData((("displaymap", BaseIcons["display"],
  96. self.parent.OnDraw),
  97. ("rendermap", BaseIcons["render"],
  98. self.parent.OnRender),
  99. ("erase", BaseIcons["erase"],
  100. self.parent.OnErase),
  101. (None, ),
  102. ("gcpset", icons["gcpSet"],
  103. self.parent.OnPointer,
  104. wx.ITEM_CHECK),
  105. ("pan", BaseIcons["pan"],
  106. self.parent.OnPan,
  107. wx.ITEM_CHECK),
  108. ("zoomin", BaseIcons["zoomIn"],
  109. self.parent.OnZoomIn,
  110. wx.ITEM_CHECK),
  111. ("zoomout", BaseIcons["zoomOut"],
  112. self.parent.OnZoomOut,
  113. wx.ITEM_CHECK),
  114. ("zoommenu", BaseIcons["zoomMenu"],
  115. self.parent.OnZoomMenuGCP),
  116. (None, ),
  117. ("zoomback", BaseIcons["zoomBack"],
  118. self.parent.OnZoomBack),
  119. ("zoomtomap", BaseIcons["zoomExtent"],
  120. self.parent.OnZoomToMap),
  121. (None, ),
  122. ('settings', icons["settings"],
  123. self.parent.OnSettings),
  124. ('help', icons["help"],
  125. self.parent.OnHelp),
  126. (None, ),
  127. ('quit', icons["quit"],
  128. self.parent.OnQuit))
  129. )