1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
|
"""
@package gcp.toolbars
@brief Georectification module - toolbars
Classes:
- toolbars::GCPMapToolbar
- toolbars::GCPDisplayToolbar
(C) 2007-2011 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@author Markus Metz
"""
import wx
from gui_core.toolbars import BaseToolbar, BaseIcons
from icons.icon import MetaIcon
class GCPManToolbar(BaseToolbar):
"""Toolbar for managing ground control points
:param parent: reference to GCP widget
"""
def __init__(self, parent):
BaseToolbar.__init__(self, parent)
self.InitToolbar(self._toolbarData())
# realize the toolbar
self.Realize()
def _toolbarData(self):
icons = {
"gcpAdd": MetaIcon(img="gcp-add", label=_("Add new GCP to the list")),
"gcpDelete": MetaIcon(img="gcp-delete", label=_("Delete selected GCP")),
"gcpClear": MetaIcon(img="gcp-remove", label=_("Clear selected GCP")),
"gcpRms": MetaIcon(img="gcp-rms", label=_("Recalculate RMS error")),
"georectify": MetaIcon(img="georectify", label=_("Georectify")),
"gcpSave": MetaIcon(img="gcp-save", label=_("Save GCPs to POINTS file")),
"gcpReload": MetaIcon(
img="reload", label=_("Reload GCPs from POINTS file")
),
}
return self._getToolbarData(
(
(
("gcpAdd", icons["gcpAdd"].label),
icons["gcpAdd"],
self.parent.AddGCP,
),
(
("gcpDelete", icons["gcpDelete"].label),
icons["gcpDelete"],
self.parent.DeleteGCP,
),
(
("gcpClear", icons["gcpClear"].label),
icons["gcpClear"],
self.parent.ClearGCP,
),
(None,),
(
("rms", icons["gcpRms"].label),
icons["gcpRms"],
self.parent.OnRMS,
),
(
("georect", icons["georectify"].label),
icons["georectify"],
self.parent.OnGeorect,
),
(None,),
(
("gcpSave", icons["gcpSave"].label),
icons["gcpSave"],
self.parent.SaveGCPs,
),
(
("gcpReload", icons["gcpReload"].label),
icons["gcpReload"],
self.parent.ReloadGCPs,
),
)
)
class GCPDisplayToolbar(BaseToolbar):
"""GCP Display toolbar"""
def __init__(self, parent, toolSwitcher):
"""GCP Display toolbar constructor"""
BaseToolbar.__init__(self, parent, toolSwitcher)
self.InitToolbar(self._toolbarData())
self._default = self.gcpset
# add tool to toggle active map window
self.togglemap = wx.Choice(
parent=self, id=wx.ID_ANY, choices=[_("source"), _("target")]
)
self.InsertControl(10, self.togglemap)
self.SetToolShortHelp(
self.togglemap.GetId(),
"%s %s %s"
% (
_("Set map canvas for "),
BaseIcons["zoomBack"].GetLabel(),
_(" / Zoom to map"),
),
)
for tool in (self.gcpset, self.pan, self.zoomin, self.zoomout):
self.toolSwitcher.AddToolToGroup(group="mouseUse", toolbar=self, tool=tool)
# realize the toolbar
self.Realize()
self.EnableTool(self.zoomback, False)
def _toolbarData(self):
"""Toolbar data"""
icons = {
"gcpSet": MetaIcon(
img="gcp-create",
label=_("Update GCP coordinates"),
desc=_("Update GCP coordinates)"),
),
"quit": BaseIcons["quit"],
"settings": BaseIcons["settings"],
"help": BaseIcons["help"],
}
return self._getToolbarData(
(
(
("displaymap", BaseIcons["display"].label),
BaseIcons["display"],
self.parent.OnDraw,
),
(
("rendermap", BaseIcons["render"].label),
BaseIcons["render"],
self.parent.OnRender,
),
(
("erase", BaseIcons["erase"].label),
BaseIcons["erase"],
self.parent.OnErase,
),
(None,),
(
("gcpset", icons["gcpSet"].label),
icons["gcpSet"],
self.parent.OnPointer,
wx.ITEM_CHECK,
),
(
("pan", BaseIcons["pan"].label),
BaseIcons["pan"],
self.parent.OnPan,
wx.ITEM_CHECK,
),
(
("zoomin", BaseIcons["zoomIn"].label),
BaseIcons["zoomIn"],
self.parent.OnZoomIn,
wx.ITEM_CHECK,
),
(
("zoomout", BaseIcons["zoomOut"].label),
BaseIcons["zoomOut"],
self.parent.OnZoomOut,
wx.ITEM_CHECK,
),
(
("zoommenu", BaseIcons["zoomMenu"].label),
BaseIcons["zoomMenu"],
self.parent.OnZoomMenuGCP,
),
(None,),
(
("zoomback", BaseIcons["zoomBack"].label),
BaseIcons["zoomBack"],
self.parent.OnZoomBack,
),
(
("zoomtomap", BaseIcons["zoomExtent"].label),
BaseIcons["zoomExtent"],
self.parent.OnZoomToMap,
),
(None,),
(
("mapDispSettings", BaseIcons["mapDispSettings"].label),
BaseIcons["mapDispSettings"],
self.parent.OnMapDisplayProperties,
),
(None,),
(
("settings", icons["settings"].label),
icons["settings"],
self.parent.OnSettings,
),
(
("help", icons["help"].label),
icons["help"],
self.parent.OnHelp,
),
(None,),
(
("quit", icons["quit"].label),
icons["quit"],
self.parent.OnQuit,
),
)
)
|