ii2t_toolbars.py 6.2 KB

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