1 |
#!/usr/bin/env python |
# Copyright (c) 2003 by Intevation GmbH |
2 |
# generated by wxGlade 0.2.1 on Thu Apr 17 11:51:39 2003 |
# Authors: |
3 |
|
# Jonathan Coles <[email protected]> |
4 |
|
# Frank Koormann <[email protected]> |
5 |
|
# |
6 |
|
# This program is free software under the GPL (>=v2) |
7 |
|
# Read the file COPYING coming with Thuban for details. |
8 |
|
|
9 |
|
"""Projection dialog""" |
10 |
|
|
11 |
|
__version__ = "$Revision$" |
12 |
|
# $Source$ |
13 |
|
# $Id$ |
14 |
|
|
15 |
|
import os, sys, math |
16 |
from wxPython.wx import * |
from wxPython.wx import * |
17 |
|
|
18 |
from Thuban import _ |
from Thuban import _ |
19 |
|
|
20 |
from Thuban.Model.proj import Projection |
from Thuban.Model.proj import Projection, ProjFile |
21 |
|
|
22 |
|
from Thuban.Model.resource import get_user_proj_files, get_system_proj_files, \ |
23 |
|
read_proj_file, write_proj_file |
24 |
|
from Thuban.UI.dialogs import NonModalNonParentDialog |
25 |
|
|
|
from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles |
|
|
from Thuban.UI.dialogs import NonModalDialog |
|
26 |
|
|
27 |
ID_PROJ_ADVANCED = 4001 |
ID_PROJ_ADVANCED = 4001 |
28 |
ID_PROJ_PROJCHOICE = 4002 |
ID_PROJ_PROJCHOICE = 4002 |
29 |
ID_PROJ_SAVEAS = 4003 |
ID_PROJ_ADDTOLIST = 4003 |
30 |
ID_PROJ_NEW = 4004 |
ID_PROJ_NEW = 4004 |
|
ID_PROJ_TRY = 4005 |
|
31 |
ID_PROJ_REVERT = 4006 |
ID_PROJ_REVERT = 4006 |
|
ID_PROJ_OK = 4007 |
|
|
ID_PROJ_CLOSE = 4008 |
|
32 |
ID_PROJ_AVAIL = 4009 |
ID_PROJ_AVAIL = 4009 |
33 |
|
ID_PROJ_SAVE = 4010 |
34 |
|
ID_PROJ_IMPORT = 4011 |
35 |
class ProjFrame(NonModalDialog): |
ID_PROJ_EXPORT = 4012 |
36 |
|
ID_PROJ_REMOVE = 4013 |
37 |
|
ID_PROJ_PROJNAME = 4014 |
38 |
def __init__(self, parent, name, receiver, *args, **kwds): |
|
39 |
# |
CLIENT_PROJ = 0 |
40 |
# Changes to the wxGlade generated code: |
CLIENT_PROJFILE = 1 |
41 |
# o call NonModalDialog.__init__(self, parent, name, "") |
|
42 |
# o remove default choices in combo box |
class ProjFrame(NonModalNonParentDialog): |
43 |
# |
|
44 |
|
def __init__(self, parent, name, title, receiver): |
45 |
self.editing = False |
"""Initialize the projection dialog. |
46 |
|
|
47 |
|
receiver -- An object that implements the following methods: |
48 |
|
SetProjection(projection) |
49 |
|
GetProjection() |
50 |
|
""" |
51 |
|
|
52 |
self.receiver = receiver |
self.receiver = receiver |
53 |
self.originalProjection = -1 |
self.haveTried = False |
54 |
self.curProjPanel = None |
self.curProjPanel = None |
55 |
|
|
56 |
self.projPanels = [] |
self.projPanels = [] |
57 |
self.projPanels.append( |
self.projPanels.append( |
58 |
("tmerc", _("Transverse Mercartor"), TMPanel)) |
("tmerc", _("Transverse Mercator"), TMPanel)) |
59 |
self.projPanels.append( |
self.projPanels.append( |
60 |
("utm", _("Universal Transverse Mercartor"), UTMPanel)) |
("utm", _("Universal Transverse Mercator"), UTMPanel)) |
61 |
self.projPanels.append( |
self.projPanels.append( |
62 |
("lcc", _("Lambert Conic Conformal"), LCCPanel)) |
("lcc", _("Lambert Conic Conformal"), LCCPanel)) |
63 |
self.projPanels.append( |
self.projPanels.append( |
64 |
("latlong", _("Geographic"), GeoPanel)) |
("latlong", _("Geographic"), GeoPanel)) |
65 |
|
|
66 |
# begin wxGlade: ProjFrame.__init__ |
NonModalNonParentDialog.__init__(self, parent, name, title) |
67 |
#kwds["style"] = wxDEFAULT_FRAME_STYLE |
# originally generate by wxGlade |
|
NonModalDialog.__init__(self, parent, name, "") |
|
68 |
self.panel_1 = wxPanel(self, -1) |
self.panel_1 = wxPanel(self, -1) |
69 |
self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:")) |
self.panel_edit = wxPanel(self, -1) |
70 |
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_SINGLE|wxLB_SORT) |
self.label_5 = wxStaticText(self.panel_1, -1, |
71 |
self.button_advanced = wxButton(self.panel_1, ID_PROJ_ADVANCED, _("Advanced >>")) |
_("Available Projections:")) |
72 |
self.label_2 = wxStaticText(self.panel_1, -1, _("Name:")) |
|
73 |
self.projname = wxTextCtrl(self.panel_1, -1, "") |
# Projection List specific actions (Import/Export/Remove) |
74 |
self.label_3 = wxStaticText(self.panel_1, -1, _("Projection:")) |
self.button_import = wxButton(self.panel_1, ID_PROJ_IMPORT, |
75 |
self.projchoice = wxChoice(self.panel_1, ID_PROJ_PROJCHOICE) |
_("Import...")) |
76 |
self.button_new = wxButton(self.panel_1, ID_PROJ_NEW, _("New")) |
self.button_export = wxButton(self.panel_1, ID_PROJ_EXPORT, |
77 |
self.button_saveas = wxButton(self.panel_1, ID_PROJ_SAVEAS, _("Save")) |
_("Export...")) |
78 |
self.button_try = wxButton(self.panel_1, ID_PROJ_TRY, _("Try")) |
self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, |
79 |
self.button_revert = wxButton(self.panel_1, ID_PROJ_REVERT, _("Revert")) |
_("Remove")) |
80 |
self.button_ok = wxButton(self.panel_1, ID_PROJ_OK, _("OK")) |
|
81 |
self.button_close = wxButton(self.panel_1, ID_PROJ_CLOSE, _("Close")) |
# The Projection List |
82 |
|
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, |
83 |
|
style=wxLB_EXTENDED|wxLB_SORT) |
84 |
|
self.projfilepath = wxStaticText(self.panel_1, -1, "") |
85 |
|
|
86 |
|
# Projection Specific Entries (Name/Projection) |
87 |
|
self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:")) |
88 |
|
self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "") |
89 |
|
self.label_3 = wxStaticText(self.panel_edit, -1, _("Projection:")) |
90 |
|
self.projchoice = wxChoice(self.panel_edit, ID_PROJ_PROJCHOICE) |
91 |
|
|
92 |
|
# Projection Specific actions (New/Save/Add) |
93 |
|
self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New")) |
94 |
|
self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST, |
95 |
|
_("Add to List")) |
96 |
|
self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Update")) |
97 |
|
|
98 |
|
# Main Action buttons (Try/Revert/OK/Close) |
99 |
|
self.button_try = wxButton(self, wxID_APPLY, _("Try")) |
100 |
|
self.button_revert = wxButton(self, ID_PROJ_REVERT, |
101 |
|
_("Revert")) |
102 |
|
self.button_ok = wxButton(self, wxID_OK, _("OK")) |
103 |
|
self.button_ok.SetDefault() |
104 |
|
self.button_close = wxButton(self, wxID_CANCEL, |
105 |
|
_("Close")) |
106 |
|
|
107 |
self.__set_properties() |
self.__set_properties() |
108 |
self.__do_layout() |
self.__do_layout() |
|
# end wxGlade |
|
109 |
|
|
110 |
self.sizer_edit.GetStaticBox().Show(False) |
# wxGlade |
|
self.sizer_mainctrls.Show(self.sizer_edit, False) |
|
|
self.topBox.Layout() |
|
111 |
|
|
112 |
EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry) |
# Fill the projection choice list. |
113 |
|
for proj, name, clazz in self.projPanels: |
114 |
|
self.projchoice.Append(name, [clazz, None]) |
115 |
|
|
116 |
|
self.originalProjection = self.receiver.GetProjection() |
117 |
|
|
118 |
|
self.__DoOnProjAvail() |
119 |
|
self.button_ok.SetFocus() |
120 |
|
self.availprojs.SetFocus() |
121 |
|
|
122 |
|
EVT_BUTTON(self, wxID_APPLY, self.OnApply) |
123 |
EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert) |
EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert) |
124 |
EVT_BUTTON(self, ID_PROJ_OK, self._OnOK) |
EVT_BUTTON(self, wxID_OK, self.OnOK) |
125 |
EVT_BUTTON(self, ID_PROJ_CLOSE, self._OnClose) |
EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) |
|
EVT_BUTTON(self, ID_PROJ_ADVANCED, self._OnAdvanced) |
|
126 |
EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice) |
EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice) |
127 |
EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail) |
EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail) |
128 |
|
EVT_BUTTON(self, ID_PROJ_IMPORT, self._OnImport) |
129 |
|
EVT_BUTTON(self, ID_PROJ_EXPORT, self._OnExport) |
130 |
|
EVT_BUTTON(self, ID_PROJ_REMOVE, self._OnRemove) |
131 |
|
|
132 |
EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew) |
EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew) |
133 |
EVT_BUTTON(self, ID_PROJ_SAVEAS, self._OnSave) |
EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave) |
134 |
|
EVT_BUTTON(self, ID_PROJ_ADDTOLIST, self._OnAddToList) |
135 |
|
|
136 |
def GetReceiver(self): |
EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName) |
|
return self.receiver |
|
137 |
|
|
138 |
def _OnTry(self, event): |
def OnApply(self, event): |
139 |
self.__SetProjection() |
self.__SetProjection() |
140 |
|
self.haveTried = True |
141 |
|
|
142 |
def _OnRevert(self, event): |
def OnOK(self, event): |
|
if self.originalProjection != -1: |
|
|
self.receiver.SetProjection(self.originalProjection) |
|
|
|
|
|
def _OnOK(self, event): |
|
143 |
self.__SetProjection() |
self.__SetProjection() |
144 |
self.Close() |
self.Close() |
145 |
|
|
146 |
def _OnClose(self, event): |
def OnCancel(self, event): |
147 |
|
"""Cancel just closes the dialog, but we call it cancel so we |
148 |
|
can overload the functionality of wxDialog. |
149 |
|
""" |
150 |
self.Close() |
self.Close() |
151 |
|
|
152 |
def _OnAdvanced(self, event): |
def _OnRevert(self, event): |
153 |
self.sizer_edit.GetStaticBox().Show(True) |
if self.haveTried: |
154 |
self.sizer_mainctrls.Show(self.sizer_edit, True) |
self.receiver.SetProjection(self.originalProjection) |
155 |
self.topBox.Fit(self) |
self.haveTried = False |
|
self.topBox.SetSizeHints(self) |
|
|
self.topBox.Layout() |
|
|
|
|
|
self.editing = True |
|
156 |
|
|
157 |
self.__DoOnProjAvail() |
def _OnNew(self, event): |
158 |
|
|
159 |
self.button_advanced.Enable(False) |
# clear all selections |
160 |
|
sel = self.availprojs.GetSelections() |
161 |
|
for index in sel: |
162 |
|
self.availprojs.SetSelection(index, False) |
163 |
|
|
|
def _OnNew(self, event): |
|
|
print "_OnNew" |
|
|
self.availprojs.SetSelection(-1) |
|
164 |
self.projname.Clear() |
self.projname.Clear() |
165 |
|
|
166 |
|
# supply a projection panel if there wasn't one |
167 |
|
if self.curProjPanel is None: |
168 |
|
self.projchoice.SetSelection(0) |
169 |
|
self.__DoOnProjChoice() |
170 |
|
|
171 |
self.curProjPanel.Clear() |
self.curProjPanel.Clear() |
172 |
|
|
173 |
def _OnSave(self, event): |
def _OnSave(self, event): |
174 |
print "_OnSave" |
|
175 |
|
sel = self.availprojs.GetSelections() |
176 |
|
assert len(sel) == 1, "button shouldn't be enabled" |
177 |
|
|
178 |
|
proj, projfile = self.availprojs.GetClientData(sel[0]) |
179 |
|
|
180 |
|
assert proj is not None and projfile is not None |
181 |
|
|
182 |
|
newproj = self.__GetProjection() |
183 |
|
|
184 |
|
if newproj is not None: |
185 |
|
projfile.Replace(proj, newproj) |
186 |
|
try: |
187 |
|
write_proj_file(projfile) |
188 |
|
except IOError, (errno, errstr): |
189 |
|
self.__ShowError(projfile.GetFilename(), errstr) |
190 |
|
self.availprojs.SetClientData(sel[0], [newproj, projfile]) |
191 |
|
|
192 |
|
self.__FillAvailList( selectProj = newproj.GetName()) |
193 |
|
|
194 |
|
def _OnAddToList(self, event): |
195 |
|
|
196 |
|
proj = self.__GetProjection() |
197 |
|
if proj is not None: |
198 |
|
self.__usrProjFile.Add(proj) |
199 |
|
try: |
200 |
|
write_proj_file(self.__usrProjFile) |
201 |
|
except IOError, (errno, errstr): |
202 |
|
self.__ShowError(self.__userProjFile.GetFilename(), errstr) |
203 |
|
|
204 |
|
self.__FillAvailList( selectProj = proj.GetName()) |
205 |
|
|
206 |
def _OnProjAvail(self, event): |
def _OnProjAvail(self, event): |
207 |
self.__DoOnProjAvail() |
self.__DoOnProjAvail() |
208 |
|
|
209 |
|
def _OnImport(self, event): |
210 |
|
|
211 |
|
dlg = wxFileDialog(self, _("Import"), style = wxOPEN) |
212 |
|
|
213 |
|
if dlg.ShowModal() == wxID_OK: |
214 |
|
path = dlg.GetPath() |
215 |
|
|
216 |
|
try: |
217 |
|
projFile = read_proj_file(path) |
218 |
|
for proj in projFile.GetProjections(): |
219 |
|
self.__usrProjFile.Add(proj) |
220 |
|
write_proj_file(self.__usrProjFile) |
221 |
|
except IOError, (errno, errstr): |
222 |
|
self.__ShowError(dlg.GetPath(), errstr) |
223 |
|
|
224 |
|
self.__FillAvailList() |
225 |
|
|
226 |
|
dlg.Destroy() |
227 |
|
|
228 |
|
def _OnExport(self, event): |
229 |
|
|
230 |
|
sel = self.availprojs.GetSelections() |
231 |
|
assert len(sel) != 0, "button should be disabled" |
232 |
|
|
233 |
|
dlg = wxFileDialog(self, _("Export"), |
234 |
|
style = wxSAVE|wxOVERWRITE_PROMPT) |
235 |
|
|
236 |
|
if dlg.ShowModal() == wxID_OK: |
237 |
|
path = dlg.GetPath() |
238 |
|
|
239 |
|
projFile = ProjFile(path) |
240 |
|
|
241 |
|
for i in sel: |
242 |
|
proj = self.availprojs.GetClientData(i)[CLIENT_PROJ] |
243 |
|
if proj is not None: |
244 |
|
projFile.Add(proj) |
245 |
|
|
246 |
|
try: |
247 |
|
write_proj_file(projFile) |
248 |
|
except IOError, (errno, errstr): |
249 |
|
self.__ShowError(dlg.GetPath(), errstr) |
250 |
|
|
251 |
|
dlg.Destroy() |
252 |
|
|
253 |
|
def _OnRemove(self, event): |
254 |
|
|
255 |
|
sel = self.availprojs.GetSelections() |
256 |
|
assert len(sel) != 0, "button should be disabled!" |
257 |
|
|
258 |
|
# |
259 |
|
# remove the items backwards so the indices don't change |
260 |
|
# |
261 |
|
sel = list(sel) |
262 |
|
sel.sort() |
263 |
|
sel.reverse() |
264 |
|
|
265 |
|
newselection = -1 |
266 |
|
if len(sel) == 1: |
267 |
|
newselection = sel[0] - 1 |
268 |
|
if newselection < 0: |
269 |
|
newselection = 0 |
270 |
|
|
271 |
|
for i in sel: |
272 |
|
proj, projfile = self.availprojs.GetClientData(i) |
273 |
|
|
274 |
|
# |
275 |
|
# this could be the case if they selected <None> or |
276 |
|
# the currently used projection |
277 |
|
# |
278 |
|
if proj is not None and projfile is not None: |
279 |
|
projfile.Remove(proj) |
280 |
|
|
281 |
|
try: |
282 |
|
write_proj_file(projfile) |
283 |
|
except IOError, (errno, errstr): |
284 |
|
self.__ShowError(projfile.GetFilename(), errstr) |
285 |
|
|
286 |
|
self.__FillAvailList() |
287 |
|
|
288 |
|
# |
289 |
|
# this *could* produce incorrect results if the .proj files |
290 |
|
# change between the last list update and this selection |
291 |
|
# because the list has been repopulated. |
292 |
|
# |
293 |
|
if newselection != -1 and self.availprojs.GetCount() > 0: |
294 |
|
self.availprojs.SetSelection(newselection) |
295 |
|
|
296 |
|
self.__VerifyButtons() |
297 |
|
|
298 |
|
def _OnProjName(self, event): |
299 |
|
self.__VerifyButtons() |
300 |
|
|
301 |
|
def __ShowError(self, filename, errstr): |
302 |
|
wxMessageDialog(self, |
303 |
|
_("The following error occured:\n") + |
304 |
|
filename + "\n" + errstr, |
305 |
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
306 |
|
|
307 |
|
def __VerifyButtons(self): |
308 |
|
"""Enable or disable the appropriate buttons based on the |
309 |
|
current state of the dialog. |
310 |
|
""" |
311 |
|
|
312 |
|
sel = self.availprojs.GetSelections() |
313 |
|
|
314 |
|
self.button_import.Enable(True) |
315 |
|
self.button_export.Enable(True) |
316 |
|
self.button_save.Enable(True) |
317 |
|
self.button_remove.Enable(True) |
318 |
|
|
319 |
|
self.panel_edit.Enable(True) |
320 |
|
|
321 |
|
for ctrl in [self.button_import, |
322 |
|
self.button_export, |
323 |
|
self.button_remove, |
324 |
|
self.button_save, |
325 |
|
self.button_add, |
326 |
|
self.projchoice, |
327 |
|
self.projname, |
328 |
|
self.panel_edit]: |
329 |
|
ctrl.Enable(True) |
330 |
|
|
331 |
|
if self.curProjPanel is not None: |
332 |
|
self.curProjPanel.Enable(True) |
333 |
|
|
334 |
|
if len(sel) == 0: |
335 |
|
self.button_import.Enable(True) |
336 |
|
self.button_export.Enable(False) |
337 |
|
self.button_remove.Enable(False) |
338 |
|
self.button_save.Enable(False) |
339 |
|
|
340 |
|
elif len(sel) == 1: |
341 |
|
|
342 |
|
proj, projFile = self.availprojs.GetClientData(sel[0]) |
343 |
|
|
344 |
|
self.button_save.Enable(len(self.projname.GetValue()) > 0) |
345 |
|
self.button_add.Enable(len(self.projname.GetValue()) > 0) |
346 |
|
|
347 |
|
if proj is None: |
348 |
|
# <None> is selected |
349 |
|
for ctrl in [self.button_export, |
350 |
|
self.button_remove, |
351 |
|
self.button_save, |
352 |
|
self.button_add, |
353 |
|
self.projchoice, |
354 |
|
self.projname]: |
355 |
|
ctrl.Enable(False) |
356 |
|
|
357 |
|
if self.curProjPanel is not None: |
358 |
|
self.curProjPanel.Enable(False) |
359 |
|
|
360 |
|
elif proj is self.originalProjection: |
361 |
|
self.button_remove.Enable(False) |
362 |
|
|
363 |
|
if projFile is None: |
364 |
|
self.button_save.Enable(False) |
365 |
|
|
366 |
|
else: |
367 |
|
self.panel_edit.Enable(False) |
368 |
|
|
369 |
def __DoOnProjAvail(self): |
def __DoOnProjAvail(self): |
|
print "_OnProjAvail" |
|
370 |
|
|
371 |
if not self.editing: return |
sel = self.availprojs.GetSelections() |
372 |
|
if len(sel) == 1: |
373 |
|
|
374 |
sel = self.availprojs.GetSelection() |
proj = self.availprojs.GetClientData(sel[0])[CLIENT_PROJ] |
375 |
if sel == -1: return |
projfile = self.availprojs.GetClientData(sel[0])[CLIENT_PROJFILE] |
376 |
|
|
377 |
|
if proj is None: |
378 |
|
# user selected <None> |
379 |
|
self.projname.Clear() |
380 |
|
self.projfilepath.SetLabel(_("Projection File: ")) |
381 |
|
else: |
382 |
|
|
383 |
|
if projfile is not None: |
384 |
|
self.projfilepath.SetLabel(_("Projection File: ") + |
385 |
|
os.path.basename(projfile.GetFilename())) |
386 |
|
else: |
387 |
|
# only None if the currently used projection is selected |
388 |
|
self.projfilepath.SetLabel(_("Projection File: ")) |
389 |
|
|
390 |
|
self.projname.SetValue(proj.GetName()) |
391 |
|
|
392 |
|
myProjType = proj.GetParameter("proj") |
393 |
|
i = 0 |
394 |
|
for projType, name, clazz in self.projPanels: |
395 |
|
if myProjType == projType: |
396 |
|
self.projchoice.SetSelection(i) |
397 |
|
self.__DoOnProjChoice() |
398 |
|
|
399 |
|
# |
400 |
|
# self.curProjPanel should not be null |
401 |
|
# after a call to __DoOnProjChoice |
402 |
|
# |
403 |
|
assert self.curProjPanel is not None |
404 |
|
|
405 |
proj = self.availprojs.GetClientData(sel) |
self.curProjPanel.SetProjection(proj) |
406 |
assert proj != None |
i += 1 |
407 |
|
|
408 |
self.projname.SetValue(proj.GetName()) |
self.__VerifyButtons() |
|
|
|
|
myProjType = proj.GetParameter("proj") |
|
|
i = 0 |
|
|
for projType, name, clazz in self.projPanels: |
|
|
if myProjType == projType: |
|
|
self.projchoice.SetSelection(i) |
|
|
self.__DoOnProjChoice() |
|
|
self.curProjPanel.SetProjection(proj) |
|
|
i += 1 |
|
409 |
|
|
410 |
def _OnProjChoice(self, event): |
def _OnProjChoice(self, event): |
411 |
self.__DoOnProjChoice() |
self.__DoOnProjChoice() |
412 |
|
|
413 |
def __DoOnProjChoice(self): |
def __DoOnProjChoice(self): |
414 |
print "_OnProjChoice()" |
"""Create and layout a projection panel based on the selected |
415 |
choice = self.projchoice |
projection type. |
416 |
|
|
417 |
sel = choice.GetSelection() |
This is necessary to have in seperate method since calls to |
418 |
if sel == -1: return |
wxChoice.SetSelection() do not trigger an event. |
419 |
|
|
420 |
clazz, obj = choice.GetClientData(choice.GetSelection()) |
At the end of this method self.curProjPanel will not be None |
421 |
|
if there was a item selected. |
422 |
|
""" |
423 |
|
|
424 |
if obj is None: |
choice = self.projchoice |
|
obj = clazz(self) |
|
|
choice.SetClientData(sel, [clazz, obj]) |
|
425 |
|
|
426 |
if self.curProjPanel is not None: |
sel = choice.GetSelection() |
427 |
self.curProjPanel.Hide() |
if sel != -1: |
|
self.sizer_projctrls.Remove(self.curProjPanel) |
|
428 |
|
|
429 |
self.curProjPanel = obj |
clazz, obj = choice.GetClientData(sel) |
|
self.curProjPanel.Show() |
|
430 |
|
|
431 |
print "++", self.topBox.GetSize(), self.GetSize() |
if obj is None: |
432 |
print "!!", self.sizer_projctrls.GetSize(), \ |
obj = clazz(self.panel_edit, self.receiver) |
433 |
self.sizer_edit.GetSize(), \ |
choice.SetClientData(sel, [clazz, obj]) |
|
self.sizer_mainctrls.GetSize(), \ |
|
|
self.sizer_panel.GetSize() |
|
|
self.sizer_projctrls.Add(self.curProjPanel, 1, wxALL|wxEXPAND, 3) |
|
|
#print "$$", self.sizer_projctrls.GetSize() |
|
|
# self.topBox.Fit(self) |
|
|
# self.topBox.SetSizeHints(self) |
|
|
# self.topBox.Layout() |
|
|
|
|
|
self.sizer_panel.SetSizeHints(self.panel_1) |
|
|
w, h = self.sizer_panel.GetSize() |
|
|
self.topBox.SetDimension(0, 0, w, h) |
|
434 |
|
|
435 |
#self.sizer_panel.Fit(self.panel_1) |
if self.curProjPanel is not None: |
436 |
self.topBox.Fit(self) |
self.curProjPanel.Hide() |
437 |
#self.SetAutoLayout(1) |
self.sizer_projctrls.Remove(self.curProjPanel) |
|
self.topBox.SetSizeHints(self) |
|
|
self.SetSize(self.topBox.GetSize()) |
|
|
print "!!", self.sizer_projctrls.GetSize(), \ |
|
|
self.sizer_edit.GetSize(), \ |
|
|
self.sizer_mainctrls.GetSize(), \ |
|
|
self.sizer_panel.GetSize() |
|
|
print "--", self.topBox.GetSize(), self.GetSize() |
|
438 |
|
|
439 |
|
self.curProjPanel = obj |
440 |
|
self.curProjPanel.Show() |
441 |
|
|
442 |
|
self.sizer_projctrls.Add(self.curProjPanel, 1, |
443 |
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 3) |
444 |
|
self.sizer_projctrls.Layout() |
445 |
|
self.Layout() |
446 |
|
self.topBox.SetSizeHints(self) |
447 |
|
|
448 |
def __SetProjection(self): |
def __SetProjection(self): |
449 |
|
"""Set the receiver's projection.""" |
450 |
|
|
451 |
# |
# |
452 |
# save the original projection only once in case |
# save the original projection only once in case |
453 |
# we try to apply several different projections |
# we try to apply several different projections |
454 |
# |
# |
455 |
if self.originalProjection == -1: |
self.receiver.SetProjection(self.__GetProjection()) |
|
self.originalProjection = self.receiver.GetProjection() |
|
456 |
|
|
457 |
sel = self.availprojs.GetSelection() |
def __GetProjection(self): |
458 |
proj = -1 |
"""Return a suitable Projection object based on the current |
459 |
|
state of the dialog box selections. |
460 |
|
|
461 |
if self.editing: |
Could be None. |
462 |
if self.curProjPanel is not None: |
""" |
|
proj = Projection(self.curProjPanel.GetParameters()) |
|
|
elif sel != -1: |
|
|
proj = self.availprojs.GetClientData(sel) |
|
|
|
|
|
if proj != -1: |
|
|
if proj is not None: |
|
|
print proj.GetAllParameters() |
|
|
self.receiver.SetProjection(proj) |
|
463 |
|
|
464 |
|
sel = self.availprojs.GetSelections() |
465 |
|
assert len(sel) < 2, "button should be disabled" |
466 |
|
|
|
def __set_properties(self): |
|
|
self.availprojs.Append("<None>", None) |
|
467 |
|
|
468 |
projfiles = GetSystemProjFiles() |
if len(sel) == 1: |
469 |
for projfile in projfiles: |
proj = self.availprojs.GetClientData(sel[0])[CLIENT_PROJ] |
470 |
for proj in projfile.GetProjections(): |
if proj is None: |
471 |
self.availprojs.Append(proj.GetName(), proj) |
# <None> is selected |
472 |
|
return None |
473 |
projfiles = GetUserProjFiles() |
|
474 |
for projfile in projfiles: |
# |
475 |
for proj in projfile.GetProjections(): |
# self.curProjPanel should always contain the most |
476 |
self.availprojs.Append(proj.GetName(), proj) |
# relevant data for a projection |
477 |
|
# |
478 |
|
if self.curProjPanel is not None: |
479 |
|
return Projection(self.curProjPanel.GetParameters(), |
480 |
|
self.projname.GetValue()) |
481 |
|
|
482 |
|
return None |
483 |
|
|
484 |
|
def __FillAvailList(self, selectCurrent = False, selectProj = None): |
485 |
|
"""Populate the list of available projections. |
486 |
|
|
487 |
|
selectCurrent -- if True, select the projection used by |
488 |
|
the receiver, otherwise select nothing. |
489 |
|
selectProj -- if set, select the projection found under the |
490 |
|
specified name. This overwrites any other |
491 |
|
selection estimate. |
492 |
|
""" |
493 |
|
|
494 |
|
self.availprojs.Clear() |
495 |
|
|
496 |
|
# |
497 |
|
# the list can never be empty. there will always be |
498 |
|
# at least this one item |
499 |
|
# |
500 |
|
self.availprojs.Append("<None>", (None, None)) |
501 |
|
|
502 |
|
projfile = get_system_proj_files() |
503 |
|
projfile = projfile[0] |
504 |
|
for proj in projfile.GetProjections(): |
505 |
|
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
506 |
|
self.__sysProjFile = projfile |
507 |
|
|
508 |
|
projfile = get_user_proj_files() |
509 |
|
projfile = projfile[0] |
510 |
|
for proj in projfile.GetProjections(): |
511 |
|
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
512 |
|
self.__usrProjFile = projfile |
513 |
|
|
514 |
|
# |
515 |
|
# We add the current projection to the list at last. |
516 |
|
# Since the list is resorted immediately a following FindString() |
517 |
|
# determines the index correctly. |
518 |
|
# |
519 |
proj = self.receiver.GetProjection() |
proj = self.receiver.GetProjection() |
520 |
if proj is not None: |
if proj is not None: |
521 |
self.availprojs.Append("## " + proj.GetName() + " ##", proj) |
proj_item = _("%s (current)") % proj.GetName() |
522 |
|
self.availprojs.Append(proj_item, [proj, None]) |
523 |
|
if selectCurrent: |
524 |
|
self.availprojs.SetSelection( |
525 |
|
self.availprojs.FindString(proj_item) |
526 |
|
) |
527 |
|
else: |
528 |
|
if selectCurrent: |
529 |
|
self.availprojs.SetSelection( |
530 |
|
self.availprojs.FindString("<None>") |
531 |
|
) |
532 |
|
if selectProj: |
533 |
|
self.availprojs.SetSelection( |
534 |
|
self.availprojs.FindString(selectProj) |
535 |
|
) |
536 |
|
|
537 |
for proj, name, clazz in self.projPanels: |
|
538 |
self.projchoice.Append(name, [clazz, None]) |
|
539 |
|
def __set_properties(self): |
540 |
|
|
541 |
# begin wxGlade: ProjFrame.__set_properties |
#self.availprojs.SetSelection(0) |
|
self.SetTitle(_("Projections")) |
|
|
self.availprojs.SetSelection(0) |
|
542 |
self.projchoice.SetSelection(0) |
self.projchoice.SetSelection(0) |
543 |
# end wxGlade |
|
544 |
|
self.__FillAvailList(selectCurrent = True) |
545 |
|
|
546 |
|
self.projname.SetMaxLength(32) |
547 |
|
|
548 |
def __do_layout(self): |
def __do_layout(self): |
549 |
# begin wxGlade: ProjFrame.__do_layout |
# originally generated by wxGlade |
550 |
|
|
551 |
self.topBox = wxBoxSizer(wxVERTICAL) |
self.topBox = wxBoxSizer(wxVERTICAL) |
552 |
self.sizer_panel = wxBoxSizer(wxVERTICAL) |
self.sizer_panel = wxBoxSizer(wxVERTICAL) |
553 |
sizer_6 = wxBoxSizer(wxHORIZONTAL) |
sizer_6 = wxBoxSizer(wxHORIZONTAL) |
554 |
|
self.sizer_mainbttns = wxBoxSizer(wxHORIZONTAL) |
555 |
self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL) |
self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL) |
556 |
self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_1, -1, _("Edit")), wxHORIZONTAL) |
self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_edit, -1, _("Edit")), wxHORIZONTAL) |
557 |
sizer_11 = wxBoxSizer(wxVERTICAL) |
sizer_11 = wxBoxSizer(wxVERTICAL) |
558 |
self.sizer_projctrls = wxBoxSizer(wxVERTICAL) |
self.sizer_projctrls = wxBoxSizer(wxVERTICAL) |
559 |
sizer_14 = wxBoxSizer(wxHORIZONTAL) |
sizer_14 = wxBoxSizer(wxHORIZONTAL) |
560 |
sizer_13 = wxBoxSizer(wxHORIZONTAL) |
sizer_13 = wxBoxSizer(wxHORIZONTAL) |
561 |
grid_sizer_1 = wxFlexGridSizer(2, 2, 0, 0) |
sizer_15 = wxBoxSizer(wxVERTICAL) |
562 |
|
sizer_15.Add(self.button_import, 0, wxALL, 4) |
563 |
|
sizer_15.Add(self.button_export, 0, wxALL, 4) |
564 |
|
sizer_15.Add(20, 20, 0, wxEXPAND, 0) |
565 |
|
sizer_15.Add(self.button_remove, 0, wxALL|wxALIGN_BOTTOM, 4) |
566 |
|
|
567 |
|
# list controls |
568 |
|
grid_sizer_1 = wxFlexGridSizer(3, 2, 0, 0) |
569 |
grid_sizer_1.Add(self.label_5, 0, wxLEFT|wxRIGHT|wxTOP, 4) |
grid_sizer_1.Add(self.label_5, 0, wxLEFT|wxRIGHT|wxTOP, 4) |
570 |
grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0) |
grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0) |
571 |
grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND, 4) |
grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
572 |
grid_sizer_1.Add(self.button_advanced, 0, wxALL, 4) |
grid_sizer_1.Add(sizer_15, 0, wxALL|wxEXPAND, 4) |
573 |
|
grid_sizer_1.Add(self.projfilepath, 0, wxEXPAND|wxALL|wxADJUST_MINSIZE, 4) |
574 |
grid_sizer_1.AddGrowableRow(1) |
grid_sizer_1.AddGrowableRow(1) |
575 |
grid_sizer_1.AddGrowableCol(0) |
grid_sizer_1.AddGrowableCol(0) |
576 |
self.sizer_mainctrls.Add(grid_sizer_1, 1, wxEXPAND, 0) |
|
577 |
|
# edit controls |
578 |
sizer_13.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
sizer_13.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
579 |
sizer_13.Add(self.projname, 1, wxALL, 4) |
sizer_13.Add(self.projname, 1, wxALL, 4) |
580 |
self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0) |
self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0) |
581 |
sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
582 |
sizer_14.Add(self.projchoice, 1, wxALL|wxEXPAND, 4) |
sizer_14.Add(self.projchoice, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
583 |
self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0) |
self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0) |
584 |
self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0) |
self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0) |
585 |
sizer_11.Add(self.button_new, 0, wxALL|wxEXPAND, 4) |
sizer_11.Add(self.button_new, 0, wxEXPAND|wxALL, 4) |
586 |
sizer_11.Add(self.button_saveas, 0, wxALL|wxEXPAND, 4) |
sizer_11.Add(self.button_add, 0, wxEXPAND|wxALL, 4) |
587 |
|
sizer_11.Add(20, 20, 0, wxEXPAND, 0) |
588 |
|
sizer_11.Add(self.button_save, 0, wxEXPAND|wxALL|wxALIGN_BOTTOM, 4) |
589 |
self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4) |
self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4) |
590 |
self.sizer_mainctrls.Add(self.sizer_edit, 0, wxALL|wxEXPAND, 4) |
|
591 |
self.sizer_panel.Add(self.sizer_mainctrls, 1, wxEXPAND, 0) |
sizer_6.Add(self.button_try, 0, wxRIGHT| wxEXPAND, 10) |
592 |
sizer_6.Add(20, 20, 1, wxEXPAND, 0) |
sizer_6.Add(self.button_revert, 0, wxRIGHT| wxEXPAND, 10) |
593 |
sizer_6.Add(self.button_try, 0, wxALL, 4) |
sizer_6.Add(self.button_ok, 0, wxRIGHT| wxEXPAND, 10) |
594 |
sizer_6.Add(20, 20, 1, 0, 0) |
sizer_6.Add(self.button_close, 0, wxRIGHT| wxEXPAND, 10) |
595 |
sizer_6.Add(self.button_revert, 0, wxALL, 4) |
|
|
sizer_6.Add(20, 20, 1, 0, 0) |
|
|
sizer_6.Add(self.button_ok, 0, wxALL, 4) |
|
|
sizer_6.Add(20, 20, 1, 0, 0) |
|
|
sizer_6.Add(self.button_close, 0, wxALL, 4) |
|
|
sizer_6.Add(20, 20, 1, wxEXPAND, 0) |
|
|
self.sizer_panel.Add(sizer_6, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 0) |
|
596 |
self.panel_1.SetAutoLayout(1) |
self.panel_1.SetAutoLayout(1) |
597 |
self.panel_1.SetSizer(self.sizer_panel) |
self.panel_1.SetSizer(grid_sizer_1) |
598 |
self.sizer_panel.Fit(self.panel_1) |
grid_sizer_1.Fit(self.panel_1) |
599 |
self.sizer_panel.SetSizeHints(self.panel_1) |
grid_sizer_1.SetSizeHints(self.panel_1) |
600 |
self.topBox.Add(self.panel_1, 1, wxEXPAND, 0) |
|
601 |
|
self.panel_edit.SetAutoLayout(1) |
602 |
|
self.panel_edit.SetSizer(self.sizer_edit) |
603 |
|
self.sizer_edit.Fit(self.panel_edit) |
604 |
|
self.sizer_edit.SetSizeHints(self.panel_edit) |
605 |
|
|
606 |
|
self.sizer_mainctrls.Add(self.panel_1, 0, |
607 |
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 0) |
608 |
|
self.sizer_mainctrls.Add(self.panel_edit, 1, |
609 |
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 0) |
610 |
|
|
611 |
|
self.sizer_mainbttns.Add(sizer_6, 0, |
612 |
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 10) |
613 |
|
|
614 |
|
self.topBox.Add(self.sizer_mainctrls, 1, wxALL|wxEXPAND, 4) |
615 |
|
self.topBox.Add(self.sizer_mainbttns, 0, wxALIGN_RIGHT|wxBOTTOM, 0) |
616 |
|
|
617 |
self.SetAutoLayout(1) |
self.SetAutoLayout(1) |
618 |
self.SetSizer(self.topBox) |
self.SetSizer(self.topBox) |
619 |
self.topBox.Fit(self) |
self.topBox.Fit(self) |
620 |
self.topBox.SetSizeHints(self) |
self.topBox.SetSizeHints(self) |
621 |
self.Layout() |
self.Layout() |
|
# end wxGlade |
|
622 |
|
|
623 |
# end of class ProjFrame |
# end of class ProjFrame |
624 |
|
|
630 |
wxPanel.__init__(self, parent, -1) |
wxPanel.__init__(self, parent, -1) |
631 |
|
|
632 |
self.__ellps = wxChoice(self, -1) |
self.__ellps = wxChoice(self, -1) |
633 |
self.ellpsData = [("bessel", _("Bessel 1841")), |
self.ellpsData = [("airy" , _("Airy")), |
634 |
|
("bessel", _("Bessel 1841")), |
635 |
("clrk66", _("Clarke 1866")), |
("clrk66", _("Clarke 1866")), |
636 |
("clrk80", _("Clarke 1880")), |
("clrk80", _("Clarke 1880")), |
637 |
("GRS80" , _("GRS 1980 (IUGG, 1980)")), |
("GRS80" , _("GRS 1980 (IUGG, 1980)")), |
647 |
|
|
648 |
panelSizer = wxBoxSizer(wxVERTICAL) |
panelSizer = wxBoxSizer(wxVERTICAL) |
649 |
|
|
|
if childPanel is not None: |
|
|
panelSizer.Add(childPanel, 0, wxALL|wxEXPAND, 4) |
|
|
|
|
650 |
sizer = wxBoxSizer(wxHORIZONTAL) |
sizer = wxBoxSizer(wxHORIZONTAL) |
651 |
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4) |
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, |
652 |
sizer.Add(self.__ellps, 1, wxALL|wxEXPAND, 4) |
wxALL|wxALIGN_CENTER_VERTICAL, 4) |
653 |
|
sizer.Add(self.__ellps, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
654 |
panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4) |
panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4) |
655 |
|
|
656 |
|
if childPanel is not None: |
657 |
|
panelSizer.Add(childPanel, 0, wxEXPAND, 0) |
658 |
|
|
659 |
self.SetAutoLayout(1) |
self.SetAutoLayout(1) |
660 |
self.SetSizer(panelSizer) |
self.SetSizer(panelSizer) |
661 |
panelSizer.Fit(self) |
panelSizer.Fit(self) |
678 |
self.__ellps.SetSelection(0) |
self.__ellps.SetSelection(0) |
679 |
|
|
680 |
def GetParameters(self): |
def GetParameters(self): |
|
print "asdfsdf" |
|
681 |
return ["ellps=" + self.__ellps.GetClientData( |
return ["ellps=" + self.__ellps.GetClientData( |
682 |
self.__ellps.GetSelection())] |
self.__ellps.GetSelection())] |
683 |
|
|
689 |
ID_TMPANEL_SCALE = 4005 |
ID_TMPANEL_SCALE = 4005 |
690 |
|
|
691 |
class UnknownProjPanel(ProjPanel): |
class UnknownProjPanel(ProjPanel): |
692 |
def __init__(self, parent): |
def __init__(self, parent, receiver): |
693 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
694 |
|
|
695 |
self._DoLayout() |
self._DoLayout() |
714 |
return None |
return None |
715 |
|
|
716 |
class TMPanel(ProjPanel): |
class TMPanel(ProjPanel): |
717 |
"""Projection panel for Transverse Mercartor.""" |
"""Projection panel for Transverse Mercator.""" |
718 |
|
|
719 |
def __init__(self, parent): |
def __init__(self, parent, receiver): |
720 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
721 |
|
|
722 |
self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT) |
self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT) |
723 |
self.__longitude = wxTextCtrl(self, ID_TMPANEL_LONG) |
self.__longitude = wxTextCtrl(self, ID_TMPANEL_LONG) |
724 |
|
self.__scale = wxTextCtrl(self, ID_TMPANEL_SCALE) |
725 |
self.__falseEast = wxTextCtrl(self, ID_TMPANEL_FASLE_EAST) |
self.__falseEast = wxTextCtrl(self, ID_TMPANEL_FASLE_EAST) |
726 |
self.__falseNorth = wxTextCtrl(self, ID_TMPANEL_FALSE_NORTH) |
self.__falseNorth = wxTextCtrl(self, ID_TMPANEL_FALSE_NORTH) |
|
self.__scale = wxTextCtrl(self, ID_TMPANEL_SCALE) |
|
727 |
|
|
728 |
self._DoLayout() |
self._DoLayout() |
729 |
|
|
744 |
ProjPanel._DoLayout(self, sizer) |
ProjPanel._DoLayout(self, sizer) |
745 |
|
|
746 |
def GetProjName(self): |
def GetProjName(self): |
747 |
return _("Transverse Mercartor") |
return _("Transverse Mercator") |
748 |
|
|
749 |
def SetProjection(self, proj): |
def SetProjection(self, proj): |
750 |
ProjPanel.SetProjection(self, proj) |
ProjPanel.SetProjection(self, proj) |
758 |
ProjPanel.SetProjection(self, proj) |
ProjPanel.SetProjection(self, proj) |
759 |
|
|
760 |
def GetParameters(self): |
def GetParameters(self): |
|
print "** asdfsdf" |
|
761 |
params = ["proj=tmerc", |
params = ["proj=tmerc", |
762 |
"lat_0=" + self.__latitude.GetValue(), |
"lat_0=" + self.__latitude.GetValue(), |
763 |
"lon_0=" + self.__longitude.GetValue(), |
"lon_0=" + self.__longitude.GetValue(), |
781 |
ID_UTMPANEL_PROP = 4003 |
ID_UTMPANEL_PROP = 4003 |
782 |
|
|
783 |
class UTMPanel(ProjPanel): |
class UTMPanel(ProjPanel): |
784 |
"""Projection Panel for Universal Transverse Mercartor.""" |
"""Projection Panel for Universal Transverse Mercator.""" |
785 |
|
|
786 |
def __init__(self, parent): |
def __init__(self, parent, receiver): |
787 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
788 |
|
|
789 |
self.parent = parent |
self.receiver = receiver |
790 |
|
|
791 |
self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60) |
self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60) |
792 |
|
self.__propButton = wxButton(self, ID_UTMPANEL_PROP, _("Propose")) |
793 |
self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH, |
self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH, |
794 |
_("Southern Hemisphere")) |
_("Southern Hemisphere")) |
|
self.__propButton = wxButton(self, ID_UTMPANEL_PROP, _("Propose")) |
|
795 |
|
|
796 |
self._DoLayout() |
self._DoLayout() |
797 |
|
|
810 |
ProjPanel._DoLayout(self, sizer) |
ProjPanel._DoLayout(self, sizer) |
811 |
|
|
812 |
def GetProjName(self): |
def GetProjName(self): |
813 |
return _("Universal Transverse Mercartor") |
return _("Universal Transverse Mercator") |
814 |
|
|
815 |
def SetProjection(self, proj): |
def SetProjection(self, proj): |
816 |
self.__zone.SetValue(int(proj.GetParameter("zone"))) |
self.__zone.SetValue(int(proj.GetParameter("zone"))) |
818 |
ProjPanel.SetProjection(self, proj) |
ProjPanel.SetProjection(self, proj) |
819 |
|
|
820 |
def GetParameters(self): |
def GetParameters(self): |
|
print "** asdfsdf" |
|
821 |
params = ["proj=utm", "zone=" + str(self.__zone.GetValue())] |
params = ["proj=utm", "zone=" + str(self.__zone.GetValue())] |
822 |
if self.__south.IsChecked(): |
if self.__south.IsChecked(): |
823 |
params.append("south") |
params.append("south") |
832 |
|
|
833 |
def _OnPropose(self, event): |
def _OnPropose(self, event): |
834 |
UTMProposeZoneDialog |
UTMProposeZoneDialog |
835 |
dlg = UTMProposeZoneDialog(self, self.parent.GetReceiver().BoundingBox()) |
dlg = UTMProposeZoneDialog(self, self.receiver.BoundingBox()) |
836 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
837 |
self.__zone.SetValue(dlg.GetProposedZone()) |
self.__zone.SetValue(dlg.GetProposedZone()) |
838 |
|
|
839 |
class LCCPanel(ProjPanel): |
class LCCPanel(ProjPanel): |
840 |
"""Projection Panel for Lambert Conic Conformal.""" |
"""Projection Panel for Lambert Conic Conformal.""" |
841 |
|
|
842 |
def __init__(self, parent): |
def __init__(self, parent, receiver): |
843 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
844 |
|
|
845 |
self.__fspLatitude = wxTextCtrl(self, -1) |
self.__fspLatitude = wxTextCtrl(self, -1) |
860 |
sizer.Add(wxStaticText(self, -1, |
sizer.Add(wxStaticText(self, -1, |
861 |
_("Latitude of second standard parallel:"))) |
_("Latitude of second standard parallel:"))) |
862 |
sizer.Add(self.__sspLatitude, 0, wxALL, 4) |
sizer.Add(self.__sspLatitude, 0, wxALL, 4) |
|
sizer.Add(wxStaticText(self, -1, _("Latitude of origin:"))) |
|
|
sizer.Add(self.__originLat, 0, wxALL, 4) |
|
863 |
sizer.Add(wxStaticText(self, -1, _("Central Meridian:"))) |
sizer.Add(wxStaticText(self, -1, _("Central Meridian:"))) |
864 |
sizer.Add(self.__meridian, 0, wxALL, 4) |
sizer.Add(self.__meridian, 0, wxALL, 4) |
865 |
|
sizer.Add(wxStaticText(self, -1, _("Latitude of origin:"))) |
866 |
|
sizer.Add(self.__originLat, 0, wxALL, 4) |
867 |
sizer.Add(wxStaticText(self, -1, _("False Easting:"))) |
sizer.Add(wxStaticText(self, -1, _("False Easting:"))) |
868 |
sizer.Add(self.__falseEast, 0, wxALL, 4) |
sizer.Add(self.__falseEast, 0, wxALL, 4) |
869 |
sizer.Add(wxStaticText(self, -1, _("False Northing:"))) |
sizer.Add(wxStaticText(self, -1, _("False Northing:"))) |
909 |
class GeoPanel(ProjPanel): |
class GeoPanel(ProjPanel): |
910 |
"""Projection Panel for a Geographic Projection.""" |
"""Projection Panel for a Geographic Projection.""" |
911 |
|
|
912 |
def __init__(self, parent): |
def __init__(self, parent, receiver): |
913 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
914 |
ProjPanel._DoLayout(self, None) |
|
915 |
|
self.__choices = [(_("Degrees"), "0.017453"), |
916 |
|
(_("Radians"), "1")] |
917 |
|
|
918 |
|
self.__scale = wxChoice(self, -1) |
919 |
|
for choice, value in self.__choices: |
920 |
|
self.__scale.Append(choice, value) |
921 |
|
|
922 |
|
self._DoLayout() |
923 |
|
|
924 |
def GetProjName(self): |
def GetProjName(self): |
925 |
return _("Geographic") |
return _("Geographic") |
926 |
|
|
927 |
def SetProjection(self, proj): |
def SetProjection(self, proj): |
928 |
|
value = proj.GetParameter("to_meter") |
929 |
|
for i in range(len(self.__choices)): |
930 |
|
choice, data = self.__choices[i] |
931 |
|
if value == data: |
932 |
|
self.__scale.SetSelection(i) |
933 |
ProjPanel.SetProjection(self, proj) |
ProjPanel.SetProjection(self, proj) |
934 |
|
|
935 |
def GetParameters(self): |
def GetParameters(self): |
936 |
params = ["proj=latlong"] |
params = ["proj=latlong", |
937 |
|
"to_meter=%s" % self.__scale.GetClientData( |
938 |
|
self.__scale.GetSelection())] |
939 |
|
|
940 |
params.extend(ProjPanel.GetParameters(self)) |
params.extend(ProjPanel.GetParameters(self)) |
941 |
return params |
return params |
942 |
|
|
943 |
def Clear(self): |
def Clear(self): |
944 |
ProjPanel.Clear(self) |
ProjPanel.Clear(self) |
945 |
|
|
946 |
|
def _DoLayout(self): |
947 |
|
sizer = wxBoxSizer(wxHORIZONTAL) |
948 |
|
|
949 |
|
sizer.Add(wxStaticText(self, -1, _("Source Data is in: ")), |
950 |
|
0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
951 |
|
sizer.Add(self.__scale, 1, wxEXPAND|wxALL, 4) |
952 |
|
|
953 |
|
self.__scale.SetSelection(0) |
954 |
|
|
955 |
|
ProjPanel._DoLayout(self, sizer) |
956 |
|
|
957 |
|
|
958 |
ID_UTM_PROPOSE_ZONE_DIALOG_TAKE = 4001 |
ID_UTM_PROPOSE_ZONE_DIALOG_TAKE = 4001 |
959 |
ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002 |
ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002 |