toolbars.py 6.3 KB

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