toolbars.py 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 icons.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, toolSwitcher):
  66. """GCP Display toolbar constructor
  67. """
  68. BaseToolbar.__init__(self, parent, toolSwitcher)
  69. self.InitToolbar(self._toolbarData())
  70. self._default = self.gcpset
  71. # add tool to toggle active map window
  72. self.togglemapid = wx.NewId()
  73. self.togglemap = wx.Choice(parent=self, id=self.togglemapid,
  74. choices=[_('source'), _('target')])
  75. self.InsertControl(10, self.togglemap)
  76. self.SetToolShortHelp(
  77. self.togglemapid, '%s %s %s' %
  78. (_('Set map canvas for '),
  79. BaseIcons["zoomBack"].GetLabel(),
  80. _(' / Zoom to map')))
  81. for tool in (self.gcpset, self.pan, self.zoomin, self.zoomout):
  82. self.toolSwitcher.AddToolToGroup(
  83. group='mouseUse', toolbar=self, tool=tool)
  84. # realize the toolbar
  85. self.Realize()
  86. self.EnableTool(self.zoomback, False)
  87. def _toolbarData(self):
  88. """Toolbar data"""
  89. icons = {
  90. 'gcpSet': MetaIcon(
  91. img='gcp-create',
  92. label=_('Update GCP coordinates'),
  93. desc=_('Update GCP coordinates)')),
  94. 'quit': BaseIcons['quit'].SetLabel(
  95. _('Quit georectification tool')),
  96. 'settings': BaseIcons['settings'].SetLabel(
  97. _('Georectifier settings')),
  98. 'help': BaseIcons['help'].SetLabel(
  99. _('Georectifier manual')),
  100. }
  101. return self._getToolbarData((("displaymap", BaseIcons["display"],
  102. self.parent.OnDraw),
  103. ("rendermap", BaseIcons["render"],
  104. self.parent.OnRender),
  105. ("erase", BaseIcons["erase"],
  106. self.parent.OnErase),
  107. (None, ),
  108. ("gcpset", icons["gcpSet"],
  109. self.parent.OnPointer,
  110. wx.ITEM_CHECK),
  111. ("pan", BaseIcons["pan"],
  112. self.parent.OnPan,
  113. wx.ITEM_CHECK),
  114. ("zoomin", BaseIcons["zoomIn"],
  115. self.parent.OnZoomIn,
  116. wx.ITEM_CHECK),
  117. ("zoomout", BaseIcons["zoomOut"],
  118. self.parent.OnZoomOut,
  119. wx.ITEM_CHECK),
  120. ("zoommenu", BaseIcons["zoomMenu"],
  121. self.parent.OnZoomMenuGCP),
  122. (None, ),
  123. ("zoomback", BaseIcons["zoomBack"],
  124. self.parent.OnZoomBack),
  125. ("zoomtomap", BaseIcons["zoomExtent"],
  126. self.parent.OnZoomToMap),
  127. (None, ),
  128. ('settings', icons["settings"],
  129. self.parent.OnSettings),
  130. ('help', icons["help"],
  131. self.parent.OnHelp),
  132. (None, ),
  133. ('quit', icons["quit"],
  134. self.parent.OnQuit))
  135. )