toolbars.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. ("gcpAdd", icons["gcpAdd"], self.parent.AddGCP),
  39. ("gcpDelete", icons["gcpDelete"], self.parent.DeleteGCP),
  40. ("gcpClear", icons["gcpClear"], self.parent.ClearGCP),
  41. (None,),
  42. ("rms", icons["gcpRms"], self.parent.OnRMS),
  43. ("georect", icons["georectify"], self.parent.OnGeorect),
  44. (None,),
  45. ("gcpSave", icons["gcpSave"], self.parent.SaveGCPs),
  46. ("gcpReload", icons["gcpReload"], self.parent.ReloadGCPs),
  47. )
  48. )
  49. class GCPDisplayToolbar(BaseToolbar):
  50. """GCP Display toolbar"""
  51. def __init__(self, parent, toolSwitcher):
  52. """GCP Display toolbar constructor"""
  53. BaseToolbar.__init__(self, parent, toolSwitcher)
  54. self.InitToolbar(self._toolbarData())
  55. self._default = self.gcpset
  56. # add tool to toggle active map window
  57. self.togglemap = wx.Choice(
  58. parent=self, id=wx.ID_ANY, choices=[_("source"), _("target")]
  59. )
  60. self.InsertControl(10, self.togglemap)
  61. self.SetToolShortHelp(
  62. self.togglemap.GetId(),
  63. "%s %s %s"
  64. % (
  65. _("Set map canvas for "),
  66. BaseIcons["zoomBack"].GetLabel(),
  67. _(" / Zoom to map"),
  68. ),
  69. )
  70. for tool in (self.gcpset, self.pan, self.zoomin, self.zoomout):
  71. self.toolSwitcher.AddToolToGroup(group="mouseUse", toolbar=self, tool=tool)
  72. # realize the toolbar
  73. self.Realize()
  74. self.EnableTool(self.zoomback, False)
  75. def _toolbarData(self):
  76. """Toolbar data"""
  77. icons = {
  78. "gcpSet": MetaIcon(
  79. img="gcp-create",
  80. label=_("Update GCP coordinates"),
  81. desc=_("Update GCP coordinates)"),
  82. ),
  83. "quit": BaseIcons["quit"].SetLabel(_("Quit georectification tool")),
  84. "settings": BaseIcons["settings"].SetLabel(_("Georectifier settings")),
  85. "help": BaseIcons["help"].SetLabel(_("Georectifier manual")),
  86. }
  87. return self._getToolbarData(
  88. (
  89. ("displaymap", BaseIcons["display"], self.parent.OnDraw),
  90. ("rendermap", BaseIcons["render"], self.parent.OnRender),
  91. ("erase", BaseIcons["erase"], self.parent.OnErase),
  92. (None,),
  93. ("gcpset", icons["gcpSet"], self.parent.OnPointer, wx.ITEM_CHECK),
  94. ("pan", BaseIcons["pan"], self.parent.OnPan, wx.ITEM_CHECK),
  95. ("zoomin", BaseIcons["zoomIn"], self.parent.OnZoomIn, wx.ITEM_CHECK),
  96. ("zoomout", BaseIcons["zoomOut"], self.parent.OnZoomOut, wx.ITEM_CHECK),
  97. ("zoommenu", BaseIcons["zoomMenu"], self.parent.OnZoomMenuGCP),
  98. (None,),
  99. ("zoomback", BaseIcons["zoomBack"], self.parent.OnZoomBack),
  100. ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap),
  101. (None,),
  102. ("settings", icons["settings"], self.parent.OnSettings),
  103. ("help", icons["help"], self.parent.OnHelp),
  104. (None,),
  105. ("quit", icons["quit"], self.parent.OnQuit),
  106. )
  107. )