toolbars.py 6.4 KB

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