toolbars.py 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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", label=_("Add new GCP to the list")),
  27. "gcpDelete": MetaIcon(img="gcp-delete", label=_("Delete selected GCP")),
  28. "gcpClear": MetaIcon(img="gcp-remove", label=_("Clear selected GCP")),
  29. "gcpRms": MetaIcon(img="gcp-rms", label=_("Recalculate RMS error")),
  30. "georectify": MetaIcon(img="georectify", label=_("Georectify")),
  31. "gcpSave": MetaIcon(img="gcp-save", label=_("Save GCPs to POINTS file")),
  32. "gcpReload": MetaIcon(
  33. img="reload", label=_("Reload GCPs from POINTS file")
  34. ),
  35. }
  36. return self._getToolbarData(
  37. (
  38. (
  39. ("gcpAdd", icons["gcpAdd"].label),
  40. icons["gcpAdd"],
  41. self.parent.AddGCP,
  42. ),
  43. (
  44. ("gcpDelete", icons["gcpDelete"].label),
  45. icons["gcpDelete"],
  46. self.parent.DeleteGCP,
  47. ),
  48. (
  49. ("gcpClear", icons["gcpClear"].label),
  50. icons["gcpClear"],
  51. self.parent.ClearGCP,
  52. ),
  53. (None,),
  54. (
  55. ("rms", icons["gcpRms"].label),
  56. icons["gcpRms"],
  57. self.parent.OnRMS,
  58. ),
  59. (
  60. ("georect", icons["georectify"].label),
  61. icons["georectify"],
  62. self.parent.OnGeorect,
  63. ),
  64. (None,),
  65. (
  66. ("gcpSave", icons["gcpSave"].label),
  67. icons["gcpSave"],
  68. self.parent.SaveGCPs,
  69. ),
  70. (
  71. ("gcpReload", icons["gcpReload"].label),
  72. icons["gcpReload"],
  73. self.parent.ReloadGCPs,
  74. ),
  75. )
  76. )
  77. class GCPDisplayToolbar(BaseToolbar):
  78. """GCP Display toolbar"""
  79. def __init__(self, parent, toolSwitcher):
  80. """GCP Display toolbar constructor"""
  81. BaseToolbar.__init__(self, parent, toolSwitcher)
  82. self.InitToolbar(self._toolbarData())
  83. self._default = self.gcpset
  84. # add tool to toggle active map window
  85. self.togglemap = wx.Choice(
  86. parent=self, id=wx.ID_ANY, choices=[_("source"), _("target")]
  87. )
  88. self.InsertControl(10, self.togglemap)
  89. self.SetToolShortHelp(
  90. self.togglemap.GetId(),
  91. "%s %s %s"
  92. % (
  93. _("Set map canvas for "),
  94. BaseIcons["zoomBack"].GetLabel(),
  95. _(" / Zoom to map"),
  96. ),
  97. )
  98. for tool in (self.gcpset, self.pan, self.zoomin, self.zoomout):
  99. self.toolSwitcher.AddToolToGroup(group="mouseUse", toolbar=self, tool=tool)
  100. # realize the toolbar
  101. self.Realize()
  102. self.EnableTool(self.zoomback, False)
  103. def _toolbarData(self):
  104. """Toolbar data"""
  105. icons = {
  106. "gcpSet": MetaIcon(
  107. img="gcp-create",
  108. label=_("Update GCP coordinates"),
  109. desc=_("Update GCP coordinates)"),
  110. ),
  111. "quit": BaseIcons["quit"],
  112. "settings": BaseIcons["settings"],
  113. "help": BaseIcons["help"],
  114. }
  115. return self._getToolbarData(
  116. (
  117. (
  118. ("displaymap", BaseIcons["display"].label),
  119. BaseIcons["display"],
  120. self.parent.OnDraw,
  121. ),
  122. (
  123. ("rendermap", BaseIcons["render"].label),
  124. BaseIcons["render"],
  125. self.parent.OnRender,
  126. ),
  127. (
  128. ("erase", BaseIcons["erase"].label),
  129. BaseIcons["erase"],
  130. self.parent.OnErase,
  131. ),
  132. (None,),
  133. (
  134. ("gcpset", icons["gcpSet"].label),
  135. icons["gcpSet"],
  136. self.parent.OnPointer,
  137. wx.ITEM_CHECK,
  138. ),
  139. (
  140. ("pan", BaseIcons["pan"].label),
  141. BaseIcons["pan"],
  142. self.parent.OnPan,
  143. wx.ITEM_CHECK,
  144. ),
  145. (
  146. ("zoomin", BaseIcons["zoomIn"].label),
  147. BaseIcons["zoomIn"],
  148. self.parent.OnZoomIn,
  149. wx.ITEM_CHECK,
  150. ),
  151. (
  152. ("zoomout", BaseIcons["zoomOut"].label),
  153. BaseIcons["zoomOut"],
  154. self.parent.OnZoomOut,
  155. wx.ITEM_CHECK,
  156. ),
  157. (
  158. ("zoommenu", BaseIcons["zoomMenu"].label),
  159. BaseIcons["zoomMenu"],
  160. self.parent.OnZoomMenuGCP,
  161. ),
  162. (None,),
  163. (
  164. ("zoomback", BaseIcons["zoomBack"].label),
  165. BaseIcons["zoomBack"],
  166. self.parent.OnZoomBack,
  167. ),
  168. (
  169. ("zoomtomap", BaseIcons["zoomExtent"].label),
  170. BaseIcons["zoomExtent"],
  171. self.parent.OnZoomToMap,
  172. ),
  173. (None,),
  174. (
  175. ("mapDispSettings", BaseIcons["mapDispSettings"].label),
  176. BaseIcons["mapDispSettings"],
  177. self.parent.OnMapDisplayProperties,
  178. ),
  179. (None,),
  180. (
  181. ("settings", icons["settings"].label),
  182. icons["settings"],
  183. self.parent.OnSettings,
  184. ),
  185. (
  186. ("help", icons["help"].label),
  187. icons["help"],
  188. self.parent.OnHelp,
  189. ),
  190. (None,),
  191. (
  192. ("quit", icons["quit"].label),
  193. icons["quit"],
  194. self.parent.OnQuit,
  195. ),
  196. )
  197. )