1 |
#!/usr/bin/env python |
#!/usr/bin/env python |
2 |
# generated by wxGlade 0.2.1 on Thu Apr 17 11:51:39 2003 |
# generated by wxGlade 0.2.1 on Thu Apr 17 11:51:39 2003 |
3 |
|
|
4 |
|
import os, sys |
5 |
from wxPython.wx import * |
from wxPython.wx import * |
6 |
|
|
7 |
from Thuban import _ |
from Thuban import _ |
8 |
|
|
9 |
from Thuban.Model.proj import Projection |
from Thuban.Model.proj import Projection, ProjFile |
10 |
|
|
11 |
from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles |
from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles, \ |
12 |
|
ReadProjFile, WriteProjFile |
13 |
from Thuban.UI.dialogs import NonModalDialog |
from Thuban.UI.dialogs import NonModalDialog |
14 |
|
|
15 |
|
|
16 |
ID_PROJ_ADVANCED = 4001 |
ID_PROJ_ADVANCED = 4001 |
17 |
ID_PROJ_PROJCHOICE = 4002 |
ID_PROJ_PROJCHOICE = 4002 |
18 |
ID_PROJ_SAVEAS = 4003 |
ID_PROJ_ADDTOLIST = 4003 |
19 |
ID_PROJ_NEW = 4004 |
ID_PROJ_NEW = 4004 |
20 |
ID_PROJ_TRY = 4005 |
ID_PROJ_TRY = 4005 |
21 |
ID_PROJ_REVERT = 4006 |
ID_PROJ_REVERT = 4006 |
22 |
ID_PROJ_OK = 4007 |
ID_PROJ_OK = 4007 |
23 |
ID_PROJ_CLOSE = 4008 |
ID_PROJ_CLOSE = 4008 |
24 |
ID_PROJ_AVAIL = 4009 |
ID_PROJ_AVAIL = 4009 |
25 |
|
ID_PROJ_SAVE = 4010 |
26 |
|
ID_PROJ_IMPORT = 4011 |
27 |
|
ID_PROJ_EXPORT = 4012 |
28 |
|
ID_PROJ_REMOVE = 4013 |
29 |
|
ID_PROJ_PROJNAME = 4014 |
30 |
|
|
31 |
|
CLIENT_PROJ = 0 |
32 |
|
CLIENT_PROJFILE = 1 |
33 |
|
|
34 |
class ProjFrame(NonModalDialog): |
class ProjFrame(NonModalDialog): |
35 |
|
|
|
|
|
36 |
def __init__(self, parent, name, receiver, *args, **kwds): |
def __init__(self, parent, name, receiver, *args, **kwds): |
37 |
# |
"""Initialize the projection dialog. |
|
# Changes to the wxGlade generated code: |
|
|
# o call NonModalDialog.__init__(self, parent, name, "") |
|
|
# o remove default choices in combo box |
|
|
# |
|
38 |
|
|
39 |
self.editing = False |
receiver -- An object that implements the following methods: |
40 |
|
SetProjection(projection) |
41 |
|
GetProjection() |
42 |
|
""" |
43 |
|
|
44 |
self.receiver = receiver |
self.receiver = receiver |
45 |
self.originalProjection = -1 |
self.originalProjection = -1 |
46 |
self.curProjPanel = None |
self.curProjPanel = None |
47 |
|
|
48 |
self.projPanels = [] |
self.projPanels = [] |
49 |
self.projPanels.append( |
self.projPanels.append( |
50 |
("tmerc", _("Transverse Mercartor"), TMPanel)) |
("tmerc", _("Transverse Mercator"), TMPanel)) |
51 |
self.projPanels.append( |
self.projPanels.append( |
52 |
("utm", _("Universal Transverse Mercartor"), UTMPanel)) |
("utm", _("Universal Transverse Mercator"), UTMPanel)) |
53 |
self.projPanels.append( |
self.projPanels.append( |
54 |
("lcc", _("Lambert Conic Conformal"), LCCPanel)) |
("lcc", _("Lambert Conic Conformal"), LCCPanel)) |
55 |
self.projPanels.append( |
self.projPanels.append( |
56 |
("latlong", _("Geographic"), GeoPanel)) |
("latlong", _("Geographic"), GeoPanel)) |
57 |
|
|
|
# begin wxGlade: ProjFrame.__init__ |
|
|
#kwds["style"] = wxDEFAULT_FRAME_STYLE |
|
58 |
NonModalDialog.__init__(self, parent, name, "") |
NonModalDialog.__init__(self, parent, name, "") |
59 |
|
# originally generate by wxGlade |
60 |
self.panel_1 = wxPanel(self, -1) |
self.panel_1 = wxPanel(self, -1) |
61 |
|
self.panel_edit = wxPanel(self, -1) |
62 |
|
self.panel_buttons = wxPanel(self, -1) |
63 |
self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:")) |
self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:")) |
64 |
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_SINGLE|wxLB_SORT) |
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_EXTENDED |wxLB_SORT) |
65 |
self.button_advanced = wxButton(self.panel_1, ID_PROJ_ADVANCED, _("Advanced >>")) |
self.projfilepath = wxStaticText(self.panel_1, -1, "") |
66 |
self.label_2 = wxStaticText(self.panel_1, -1, _("Name:")) |
self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:")) |
67 |
self.projname = wxTextCtrl(self.panel_1, -1, "") |
self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "") |
68 |
self.label_3 = wxStaticText(self.panel_1, -1, _("Projection:")) |
self.label_3 = wxStaticText(self.panel_edit, -1, _("Projection:")) |
69 |
self.projchoice = wxChoice(self.panel_1, ID_PROJ_PROJCHOICE) |
self.projchoice = wxChoice(self.panel_edit, ID_PROJ_PROJCHOICE) |
70 |
self.button_new = wxButton(self.panel_1, ID_PROJ_NEW, _("New")) |
self.button_import = wxButton(self.panel_1, ID_PROJ_IMPORT, _("Import...")) |
71 |
self.button_saveas = wxButton(self.panel_1, ID_PROJ_SAVEAS, _("Save")) |
self.button_export = wxButton(self.panel_1, ID_PROJ_EXPORT, _("Export...")) |
72 |
self.button_try = wxButton(self.panel_1, ID_PROJ_TRY, _("Try")) |
self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove")) |
73 |
self.button_revert = wxButton(self.panel_1, ID_PROJ_REVERT, _("Revert")) |
self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New")) |
74 |
self.button_ok = wxButton(self.panel_1, ID_PROJ_OK, _("OK")) |
self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Save")) |
75 |
self.button_close = wxButton(self.panel_1, ID_PROJ_CLOSE, _("Close")) |
self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST, |
76 |
|
_("Add to List")) |
77 |
|
self.button_try = wxButton(self.panel_buttons, ID_PROJ_TRY, _("Try")) |
78 |
|
self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, _("Revert")) |
79 |
|
self.button_ok = wxButton(self.panel_buttons, ID_PROJ_OK, _("OK")) |
80 |
|
self.button_close = wxButton(self.panel_buttons, ID_PROJ_CLOSE, _("Close")) |
81 |
|
|
82 |
self.__set_properties() |
self.__set_properties() |
83 |
self.__do_layout() |
self.__do_layout() |
84 |
# end wxGlade |
# wxGlade |
|
|
|
|
self.sizer_edit.GetStaticBox().Show(False) |
|
|
self.sizer_mainctrls.Show(self.sizer_edit, False) |
|
|
self.topBox.Layout() |
|
85 |
|
|
86 |
|
self.__DoOnProjAvail() |
87 |
|
|
88 |
EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry) |
EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry) |
89 |
EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert) |
EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert) |
90 |
EVT_BUTTON(self, ID_PROJ_OK, self._OnOK) |
EVT_BUTTON(self, ID_PROJ_OK, self._OnOK) |
91 |
EVT_BUTTON(self, ID_PROJ_CLOSE, self._OnClose) |
EVT_BUTTON(self, ID_PROJ_CLOSE, self._OnClose) |
|
EVT_BUTTON(self, ID_PROJ_ADVANCED, self._OnAdvanced) |
|
92 |
EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice) |
EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice) |
93 |
EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail) |
EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail) |
94 |
|
EVT_BUTTON(self, ID_PROJ_IMPORT, self._OnImport) |
95 |
|
EVT_BUTTON(self, ID_PROJ_EXPORT, self._OnExport) |
96 |
|
EVT_BUTTON(self, ID_PROJ_REMOVE, self._OnRemove) |
97 |
|
|
98 |
EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew) |
EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew) |
99 |
EVT_BUTTON(self, ID_PROJ_SAVEAS, self._OnSave) |
EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave) |
100 |
|
EVT_BUTTON(self, ID_PROJ_ADDTOLIST, self._OnAddToList) |
101 |
|
|
102 |
|
EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName) |
103 |
|
|
104 |
def GetReceiver(self): |
def GetReceiver(self): |
105 |
return self.receiver |
return self.receiver |
118 |
def _OnClose(self, event): |
def _OnClose(self, event): |
119 |
self.Close() |
self.Close() |
120 |
|
|
121 |
def _OnAdvanced(self, event): |
def _OnNew(self, event): |
122 |
self.sizer_edit.GetStaticBox().Show(True) |
self.__DoOnNew() |
|
self.sizer_mainctrls.Show(self.sizer_edit, True) |
|
|
self.topBox.Fit(self) |
|
|
self.topBox.SetSizeHints(self) |
|
|
self.topBox.Layout() |
|
123 |
|
|
124 |
self.editing = True |
def _OnSave(self, event): |
125 |
|
|
126 |
self.__DoOnProjAvail() |
sel = self.availprojs.GetSelections() |
127 |
|
assert len(sel) == 1, "button shouldn't be enabled" |
128 |
|
|
129 |
self.button_advanced.Enable(False) |
proj, projfile = self.availprojs.GetClientData(sel[0]) |
130 |
|
|
131 |
def _OnNew(self, event): |
assert proj is not None and projfile is not None |
|
print "_OnNew" |
|
|
self.availprojs.SetSelection(-1) |
|
|
self.projname.Clear() |
|
|
self.curProjPanel.Clear() |
|
132 |
|
|
133 |
def _OnSave(self, event): |
newproj = self.__GetProjection() |
134 |
print "_OnSave" |
|
135 |
|
if newproj is not None: |
136 |
|
projfile.Remove(proj) |
137 |
|
projfile.Add(newproj) |
138 |
|
try: |
139 |
|
WriteProjFile(projfile) |
140 |
|
except IOError, (errno, errstr): |
141 |
|
wxMessageDialog(self, |
142 |
|
_("The following error occured:\n") + |
143 |
|
projfile.GetFilename() + "\n" + errstr, |
144 |
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
145 |
|
self.__FillAvailList() |
146 |
|
|
147 |
|
def _OnAddToList(self, event): |
148 |
|
|
149 |
|
proj = self.__GetProjection() |
150 |
|
if proj is not None: |
151 |
|
self.__usrProjFile.Add(proj) |
152 |
|
try: |
153 |
|
WriteProjFile(self.__usrProjFile) |
154 |
|
except IOError, (errno, errstr): |
155 |
|
wxMessageDialog(self, |
156 |
|
_("The following error occured:\n") + |
157 |
|
self.__usrProjFile.GetFilename() + "\n" + errstr, |
158 |
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
159 |
|
self.__FillAvailList() |
160 |
|
|
161 |
def _OnProjAvail(self, event): |
def _OnProjAvail(self, event): |
162 |
self.__DoOnProjAvail() |
self.__DoOnProjAvail() |
163 |
|
|
164 |
|
def _OnImport(self, event): |
165 |
|
|
166 |
|
dlg = wxFileDialog(self, _("Import"), style = wxOPEN) |
167 |
|
|
168 |
|
if dlg.ShowModal() == wxID_OK: |
169 |
|
path = dlg.GetPath() |
170 |
|
|
171 |
|
try: |
172 |
|
projFile = ReadProjFile(path) |
173 |
|
for proj in projFile.GetProjections(): |
174 |
|
self.__usrProjFile.Add(proj) |
175 |
|
WriteProjFile(self.__usrProjFile) |
176 |
|
except IOError, (errno, errstr): |
177 |
|
wxMessageDialog(self, |
178 |
|
_("The following error occured:\n") + |
179 |
|
dlg.GetPath() + "\n" + errstr, |
180 |
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
181 |
|
|
182 |
|
self.__FillAvailList() |
183 |
|
|
184 |
|
dlg.Destroy() |
185 |
|
|
186 |
|
def _OnExport(self, event): |
187 |
|
|
188 |
|
sel = self.availprojs.GetSelections() |
189 |
|
assert len(sel) != 0, "button should be disabled" |
190 |
|
|
191 |
|
dlg = wxFileDialog(self, _("Export"), |
192 |
|
style = wxSAVE|wxOVERWRITE_PROMPT) |
193 |
|
|
194 |
|
if dlg.ShowModal() == wxID_OK: |
195 |
|
path = dlg.GetPath() |
196 |
|
|
197 |
|
projFile = ProjFile(path) |
198 |
|
|
199 |
|
for i in sel: |
200 |
|
proj = self.availprojs.GetClientData(i)[CLIENT_PROJ] |
201 |
|
if proj is not None: |
202 |
|
projFile.Add(proj) |
203 |
|
|
204 |
|
try: |
205 |
|
WriteProjFile(projFile) |
206 |
|
except IOError, (errno, errstr): |
207 |
|
wxMessageDialog(self, |
208 |
|
_("The following error occured:\n") + |
209 |
|
dlg.GetPath() + "\n" + errstr, |
210 |
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
211 |
|
|
212 |
|
dlg.Destroy() |
213 |
|
|
214 |
|
def _OnRemove(self, event): |
215 |
|
|
216 |
|
sel = self.availprojs.GetSelections() |
217 |
|
assert len(sel) != 0, "button should be disabled!" |
218 |
|
|
219 |
|
# |
220 |
|
# remove the items backwards so the indices don't change |
221 |
|
# |
222 |
|
sel = list(sel) |
223 |
|
sel.sort() |
224 |
|
sel.reverse() |
225 |
|
|
226 |
|
newselection = -1 |
227 |
|
if len(sel) == 1: |
228 |
|
newselection = sel[0] - 1 |
229 |
|
if newselection < 0: |
230 |
|
newselection = 0 |
231 |
|
|
232 |
|
for i in sel: |
233 |
|
proj, projfile = self.availprojs.GetClientData(i) |
234 |
|
|
235 |
|
# |
236 |
|
# this could be the case if they selected <None> or |
237 |
|
# the currently used projection |
238 |
|
# |
239 |
|
if proj is not None and projfile is not None: |
240 |
|
projfile.Remove(proj) |
241 |
|
|
242 |
|
try: |
243 |
|
WriteProjFile(projfile) |
244 |
|
except IOError, (errno, errstr): |
245 |
|
wxMessageDialog(self, |
246 |
|
_("The following error occured:\n") + |
247 |
|
projfile.GetFilename() + "\n" + errstr, |
248 |
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
249 |
|
|
250 |
|
|
251 |
|
self.__FillAvailList() |
252 |
|
|
253 |
|
# |
254 |
|
# this *could* produce incorrect results if the .proj files |
255 |
|
# change between the last list update and this selection |
256 |
|
# because the list has been repopulated. |
257 |
|
# |
258 |
|
if newselection != -1 and self.availprojs.GetCount() > 0: |
259 |
|
self.availprojs.SetSelection(newselection) |
260 |
|
|
261 |
|
def _OnProjName(self, event): |
262 |
|
self.__VerifyButtons() |
263 |
|
|
264 |
|
def __VerifyButtons(self): |
265 |
|
sel = self.availprojs.GetSelections() |
266 |
|
|
267 |
|
self.button_import.Enable(True) |
268 |
|
self.button_export.Enable(True) |
269 |
|
self.button_save.Enable(True) |
270 |
|
self.button_remove.Enable(True) |
271 |
|
|
272 |
|
self.panel_edit.Enable(True) |
273 |
|
|
274 |
|
if len(sel) == 0: |
275 |
|
self.button_import.Enable(True) |
276 |
|
self.button_export.Enable(False) |
277 |
|
self.button_remove.Enable(False) |
278 |
|
|
279 |
|
elif len(sel) == 1: |
280 |
|
|
281 |
|
proj, projFile = self.availprojs.GetClientData(sel[0]) |
282 |
|
|
283 |
|
self.button_save.Enable(len(self.projname.GetValue()) > 0) |
284 |
|
self.button_add.Enable(len(self.projname.GetValue()) > 0) |
285 |
|
|
286 |
|
if proj is None: |
287 |
|
self.button_export.Enable(False) |
288 |
|
self.button_remove.Enable(False) |
289 |
|
|
290 |
|
if projFile is None: |
291 |
|
self.button_save.Enable(False) |
292 |
|
|
293 |
|
else: |
294 |
|
self.panel_edit.Enable(False) |
295 |
|
|
296 |
|
def __DoOnNew(self): |
297 |
|
sel = self.availprojs.GetSelections() |
298 |
|
if len(sel) != 0: |
299 |
|
self.availprojs.SetSelection(sel, False) |
300 |
|
self.projname.Clear() |
301 |
|
self.curProjPanel.Clear() |
302 |
|
|
303 |
def __DoOnProjAvail(self): |
def __DoOnProjAvail(self): |
|
print "_OnProjAvail" |
|
304 |
|
|
305 |
if not self.editing: return |
sel = self.availprojs.GetSelections() |
306 |
|
if len(sel) == 1: |
307 |
|
|
308 |
sel = self.availprojs.GetSelection() |
proj = self.availprojs.GetClientData(sel[0])[CLIENT_PROJ] |
309 |
if sel == -1: return |
projfile = self.availprojs.GetClientData(sel[0])[CLIENT_PROJFILE] |
310 |
|
|
311 |
proj = self.availprojs.GetClientData(sel) |
if proj is None: |
312 |
assert proj != None |
# user selected <None> |
313 |
|
self.projname.Clear() |
314 |
self.projname.SetValue(proj.GetName()) |
else: |
315 |
|
|
316 |
myProjType = proj.GetParameter("proj") |
if projfile is not None: |
317 |
i = 0 |
self.projfilepath.SetLabel(projfile.GetFilename()) |
318 |
for projType, name, clazz in self.projPanels: |
else: |
319 |
if myProjType == projType: |
# only None if the currently used projection is selected |
320 |
self.projchoice.SetSelection(i) |
self.projfilepath.SetLabel("") |
321 |
self.__DoOnProjChoice() |
|
322 |
self.curProjPanel.SetProjection(proj) |
self.projname.SetValue(proj.GetName()) |
323 |
i += 1 |
|
324 |
|
myProjType = proj.GetParameter("proj") |
325 |
|
i = 0 |
326 |
|
for projType, name, clazz in self.projPanels: |
327 |
|
if myProjType == projType: |
328 |
|
self.projchoice.SetSelection(i) |
329 |
|
self.__DoOnProjChoice() |
330 |
|
self.curProjPanel.SetProjection(proj) |
331 |
|
i += 1 |
332 |
|
|
333 |
|
self.__VerifyButtons() |
334 |
|
|
335 |
def _OnProjChoice(self, event): |
def _OnProjChoice(self, event): |
336 |
self.__DoOnProjChoice() |
self.__DoOnProjChoice() |
337 |
|
|
338 |
def __DoOnProjChoice(self): |
def __DoOnProjChoice(self): |
|
print "_OnProjChoice()" |
|
339 |
choice = self.projchoice |
choice = self.projchoice |
340 |
|
|
341 |
sel = choice.GetSelection() |
sel = choice.GetSelection() |
342 |
if sel == -1: return |
if sel != -1: |
|
|
|
|
clazz, obj = choice.GetClientData(choice.GetSelection()) |
|
343 |
|
|
344 |
if obj is None: |
clazz, obj = choice.GetClientData(sel) |
|
obj = clazz(self) |
|
|
choice.SetClientData(sel, [clazz, obj]) |
|
345 |
|
|
346 |
if self.curProjPanel is not None: |
if obj is None: |
347 |
self.curProjPanel.Hide() |
obj = clazz(self.panel_edit, self.receiver) |
348 |
self.sizer_projctrls.Remove(self.curProjPanel) |
choice.SetClientData(sel, [clazz, obj]) |
|
|
|
|
self.curProjPanel = obj |
|
|
self.curProjPanel.Show() |
|
349 |
|
|
350 |
print "++", self.topBox.GetSize(), self.GetSize() |
if self.curProjPanel is not None: |
351 |
print "!!", self.sizer_projctrls.GetSize(), \ |
self.curProjPanel.Hide() |
352 |
self.sizer_edit.GetSize(), \ |
self.sizer_projctrls.Remove(self.curProjPanel) |
|
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) |
|
353 |
|
|
354 |
#self.sizer_panel.Fit(self.panel_1) |
self.curProjPanel = obj |
355 |
self.topBox.Fit(self) |
self.curProjPanel.Show() |
|
#self.SetAutoLayout(1) |
|
|
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() |
|
356 |
|
|
357 |
|
self.sizer_projctrls.Add(self.curProjPanel, 1, |
358 |
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 3) |
359 |
|
self.sizer_projctrls.Layout() |
360 |
|
self.Layout() |
361 |
|
self.topBox.SetSizeHints(self) |
362 |
|
|
363 |
def __SetProjection(self): |
def __SetProjection(self): |
364 |
|
|
369 |
if self.originalProjection == -1: |
if self.originalProjection == -1: |
370 |
self.originalProjection = self.receiver.GetProjection() |
self.originalProjection = self.receiver.GetProjection() |
371 |
|
|
372 |
sel = self.availprojs.GetSelection() |
self.receiver.SetProjection(self.__GetProjection()) |
|
proj = -1 |
|
373 |
|
|
374 |
if self.editing: |
def __GetProjection(self): |
375 |
if self.curProjPanel is not None: |
"""Return the packaged projection. |
|
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) |
|
376 |
|
|
377 |
|
Could be None. |
378 |
|
""" |
379 |
|
|
380 |
def __set_properties(self): |
proj = None |
381 |
self.availprojs.Append("<None>", None) |
|
382 |
|
if self.curProjPanel is not None: |
383 |
|
proj = Projection(self.curProjPanel.GetParameters()) |
384 |
|
proj.SetName(self.projname.GetValue()) |
385 |
|
|
386 |
projfiles = GetSystemProjFiles() |
return proj |
387 |
for projfile in projfiles: |
|
388 |
|
def __FillAvailList(self): |
389 |
|
self.availprojs.Clear() |
390 |
|
|
391 |
|
# |
392 |
|
# the list can never be empty. there will always be |
393 |
|
# at least this one item |
394 |
|
# |
395 |
|
self.availprojs.Append("<None>", (None, None)) |
396 |
|
|
397 |
|
self.__sysProjFile = None |
398 |
|
self.__usrProjFile = None |
399 |
|
|
400 |
|
projfile = GetSystemProjFiles() |
401 |
|
if len(projfile) > 0: |
402 |
|
projfile = projfile[0] |
403 |
for proj in projfile.GetProjections(): |
for proj in projfile.GetProjections(): |
404 |
self.availprojs.Append(proj.GetName(), proj) |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
405 |
|
self.__sysProjFile = projfile |
406 |
|
|
407 |
projfiles = GetUserProjFiles() |
projfile = GetUserProjFiles() |
408 |
for projfile in projfiles: |
if len(projfile) > 0: |
409 |
|
projfile = projfile[0] |
410 |
for proj in projfile.GetProjections(): |
for proj in projfile.GetProjections(): |
411 |
self.availprojs.Append(proj.GetName(), proj) |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
412 |
|
self.__usrProjFile = projfile |
413 |
|
|
414 |
|
# projfiles = GetSystemProjFiles() |
415 |
|
# for projfile in projfiles: |
416 |
|
# for proj in projfile.GetProjections(): |
417 |
|
# self.availprojs.Append(proj.GetName(), [proj, projfile]) |
418 |
|
# self.__sysProjFiles = projfiles |
419 |
|
|
420 |
|
# projfiles = GetUserProjFiles() |
421 |
|
# for projfile in projfiles: |
422 |
|
# for proj in projfile.GetProjections(): |
423 |
|
# self.availprojs.Append(proj.GetName(), [proj, projfile]) |
424 |
|
# self.__usrProjFiles = projfiles |
425 |
|
|
426 |
proj = self.receiver.GetProjection() |
proj = self.receiver.GetProjection() |
427 |
if proj is not None: |
if proj is not None: |
428 |
self.availprojs.Append("## " + proj.GetName() + " ##", proj) |
self.availprojs.Append(_("%s (current)") % proj.GetName(), |
429 |
|
[proj, None]) |
430 |
|
|
431 |
for proj, name, clazz in self.projPanels: |
for proj, name, clazz in self.projPanels: |
432 |
self.projchoice.Append(name, [clazz, None]) |
self.projchoice.Append(name, [clazz, None]) |
433 |
|
|
434 |
|
def __set_properties(self): |
435 |
|
self.__FillAvailList() |
436 |
|
|
437 |
# begin wxGlade: ProjFrame.__set_properties |
# begin wxGlade: ProjFrame.__set_properties |
438 |
self.SetTitle(_("Projections")) |
self.SetTitle(_("Projections")) |
439 |
self.availprojs.SetSelection(0) |
self.availprojs.SetSelection(0) |
440 |
self.projchoice.SetSelection(0) |
self.projchoice.SetSelection(0) |
441 |
# end wxGlade |
# end wxGlade |
442 |
|
|
443 |
|
self.projname.SetMaxLength(32) |
444 |
|
|
445 |
def __do_layout(self): |
def __do_layout(self): |
446 |
# begin wxGlade: ProjFrame.__do_layout |
# originally generated by wxGlade |
447 |
|
|
448 |
self.topBox = wxBoxSizer(wxVERTICAL) |
self.topBox = wxBoxSizer(wxVERTICAL) |
449 |
self.sizer_panel = wxBoxSizer(wxVERTICAL) |
self.sizer_panel = wxBoxSizer(wxVERTICAL) |
450 |
sizer_6 = wxBoxSizer(wxHORIZONTAL) |
sizer_6 = wxBoxSizer(wxHORIZONTAL) |
451 |
self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL) |
self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL) |
452 |
self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_1, -1, _("Edit")), wxHORIZONTAL) |
self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_edit, -1, _("Edit")), wxHORIZONTAL) |
453 |
sizer_11 = wxBoxSizer(wxVERTICAL) |
sizer_11 = wxBoxSizer(wxVERTICAL) |
454 |
self.sizer_projctrls = wxBoxSizer(wxVERTICAL) |
self.sizer_projctrls = wxBoxSizer(wxVERTICAL) |
455 |
sizer_14 = wxBoxSizer(wxHORIZONTAL) |
sizer_14 = wxBoxSizer(wxHORIZONTAL) |
456 |
sizer_13 = wxBoxSizer(wxHORIZONTAL) |
sizer_13 = wxBoxSizer(wxHORIZONTAL) |
457 |
grid_sizer_1 = wxFlexGridSizer(2, 2, 0, 0) |
sizer_15 = wxBoxSizer(wxVERTICAL) |
458 |
|
sizer_15.Add(self.button_import, 0, wxALL, 4) |
459 |
|
sizer_15.Add(self.button_export, 0, wxALL, 4) |
460 |
|
sizer_15.Add(20, 20, 0, wxEXPAND, 0) |
461 |
|
sizer_15.Add(self.button_remove, 0, wxALL|wxALIGN_BOTTOM, 4) |
462 |
|
|
463 |
|
# list controls |
464 |
|
grid_sizer_1 = wxFlexGridSizer(3, 2, 0, 0) |
465 |
grid_sizer_1.Add(self.label_5, 0, wxLEFT|wxRIGHT|wxTOP, 4) |
grid_sizer_1.Add(self.label_5, 0, wxLEFT|wxRIGHT|wxTOP, 4) |
466 |
grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0) |
grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0) |
467 |
grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND, 4) |
grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
468 |
grid_sizer_1.Add(self.button_advanced, 0, wxALL, 4) |
grid_sizer_1.Add(sizer_15, 0, wxALL|wxEXPAND, 4) |
469 |
|
grid_sizer_1.Add(self.projfilepath, 0, wxALL|wxADJUST_MINSIZE, 4) |
470 |
grid_sizer_1.AddGrowableRow(1) |
grid_sizer_1.AddGrowableRow(1) |
471 |
grid_sizer_1.AddGrowableCol(0) |
grid_sizer_1.AddGrowableCol(0) |
472 |
self.sizer_mainctrls.Add(grid_sizer_1, 1, wxEXPAND, 0) |
|
473 |
|
# edit controls |
474 |
sizer_13.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
sizer_13.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
475 |
sizer_13.Add(self.projname, 1, wxALL, 4) |
sizer_13.Add(self.projname, 1, wxALL, 4) |
476 |
self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0) |
self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0) |
477 |
sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
478 |
sizer_14.Add(self.projchoice, 1, wxALL|wxEXPAND, 4) |
sizer_14.Add(self.projchoice, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
479 |
self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0) |
self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0) |
480 |
self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0) |
self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0) |
481 |
sizer_11.Add(self.button_new, 0, wxALL|wxEXPAND, 4) |
sizer_11.Add(self.button_new, 0, wxALL|wxEXPAND, 4) |
482 |
sizer_11.Add(self.button_saveas, 0, wxALL|wxEXPAND, 4) |
sizer_11.Add(self.button_save, 0, wxALL|wxEXPAND, 4) |
483 |
|
sizer_11.Add(self.button_add, 0, wxALL|wxEXPAND, 4) |
484 |
self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4) |
self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4) |
485 |
self.sizer_mainctrls.Add(self.sizer_edit, 0, wxALL|wxEXPAND, 4) |
|
|
self.sizer_panel.Add(self.sizer_mainctrls, 1, wxEXPAND, 0) |
|
486 |
sizer_6.Add(20, 20, 1, wxEXPAND, 0) |
sizer_6.Add(20, 20, 1, wxEXPAND, 0) |
487 |
sizer_6.Add(self.button_try, 0, wxALL, 4) |
sizer_6.Add(self.button_try, 0, wxALL, 4) |
488 |
sizer_6.Add(20, 20, 1, 0, 0) |
sizer_6.Add(20, 20, 1, 0, 0) |
492 |
sizer_6.Add(20, 20, 1, 0, 0) |
sizer_6.Add(20, 20, 1, 0, 0) |
493 |
sizer_6.Add(self.button_close, 0, wxALL, 4) |
sizer_6.Add(self.button_close, 0, wxALL, 4) |
494 |
sizer_6.Add(20, 20, 1, wxEXPAND, 0) |
sizer_6.Add(20, 20, 1, wxEXPAND, 0) |
495 |
self.sizer_panel.Add(sizer_6, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 0) |
|
496 |
self.panel_1.SetAutoLayout(1) |
self.panel_1.SetAutoLayout(1) |
497 |
self.panel_1.SetSizer(self.sizer_panel) |
self.panel_1.SetSizer(grid_sizer_1) |
498 |
self.sizer_panel.Fit(self.panel_1) |
grid_sizer_1.Fit(self.panel_1) |
499 |
self.sizer_panel.SetSizeHints(self.panel_1) |
grid_sizer_1.SetSizeHints(self.panel_1) |
500 |
self.topBox.Add(self.panel_1, 1, wxEXPAND, 0) |
|
501 |
|
self.panel_edit.SetAutoLayout(1) |
502 |
|
self.panel_edit.SetSizer(self.sizer_edit) |
503 |
|
self.sizer_edit.Fit(self.panel_edit) |
504 |
|
self.sizer_edit.SetSizeHints(self.panel_edit) |
505 |
|
|
506 |
|
self.panel_buttons.SetAutoLayout(1) |
507 |
|
self.panel_buttons.SetSizer(sizer_6) |
508 |
|
sizer_6.Fit(self.panel_buttons) |
509 |
|
sizer_6.SetSizeHints(self.panel_buttons) |
510 |
|
|
511 |
|
self.sizer_mainctrls.Add(self.panel_1, 0, |
512 |
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 0) |
513 |
|
self.sizer_mainctrls.Add(self.panel_edit, 1, |
514 |
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 0) |
515 |
|
|
516 |
|
self.topBox.Add(self.sizer_mainctrls, 1, wxALL|wxEXPAND, 4) |
517 |
|
self.topBox.Add(self.panel_buttons, 0, wxEXPAND, 0) |
518 |
|
|
519 |
self.SetAutoLayout(1) |
self.SetAutoLayout(1) |
520 |
self.SetSizer(self.topBox) |
self.SetSizer(self.topBox) |
521 |
self.topBox.Fit(self) |
self.topBox.Fit(self) |
522 |
self.topBox.SetSizeHints(self) |
self.topBox.SetSizeHints(self) |
523 |
self.Layout() |
self.Layout() |
|
# end wxGlade |
|
524 |
|
|
525 |
# end of class ProjFrame |
# end of class ProjFrame |
526 |
|
|
553 |
|
|
554 |
sizer = wxBoxSizer(wxHORIZONTAL) |
sizer = wxBoxSizer(wxHORIZONTAL) |
555 |
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4) |
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4) |
556 |
sizer.Add(self.__ellps, 1, wxALL|wxEXPAND, 4) |
sizer.Add(self.__ellps, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
557 |
panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4) |
panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4) |
558 |
|
|
559 |
self.SetAutoLayout(1) |
self.SetAutoLayout(1) |
578 |
self.__ellps.SetSelection(0) |
self.__ellps.SetSelection(0) |
579 |
|
|
580 |
def GetParameters(self): |
def GetParameters(self): |
|
print "asdfsdf" |
|
581 |
return ["ellps=" + self.__ellps.GetClientData( |
return ["ellps=" + self.__ellps.GetClientData( |
582 |
self.__ellps.GetSelection())] |
self.__ellps.GetSelection())] |
583 |
|
|
589 |
ID_TMPANEL_SCALE = 4005 |
ID_TMPANEL_SCALE = 4005 |
590 |
|
|
591 |
class UnknownProjPanel(ProjPanel): |
class UnknownProjPanel(ProjPanel): |
592 |
def __init__(self, parent): |
def __init__(self, parent, receiver): |
593 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
594 |
|
|
595 |
self._DoLayout() |
self._DoLayout() |
614 |
return None |
return None |
615 |
|
|
616 |
class TMPanel(ProjPanel): |
class TMPanel(ProjPanel): |
617 |
"""Projection panel for Transverse Mercartor.""" |
"""Projection panel for Transverse Mercator.""" |
618 |
|
|
619 |
def __init__(self, parent): |
def __init__(self, parent, receiver): |
620 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
621 |
|
|
622 |
self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT) |
self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT) |
644 |
ProjPanel._DoLayout(self, sizer) |
ProjPanel._DoLayout(self, sizer) |
645 |
|
|
646 |
def GetProjName(self): |
def GetProjName(self): |
647 |
return _("Transverse Mercartor") |
return _("Transverse Mercator") |
648 |
|
|
649 |
def SetProjection(self, proj): |
def SetProjection(self, proj): |
650 |
ProjPanel.SetProjection(self, proj) |
ProjPanel.SetProjection(self, proj) |
658 |
ProjPanel.SetProjection(self, proj) |
ProjPanel.SetProjection(self, proj) |
659 |
|
|
660 |
def GetParameters(self): |
def GetParameters(self): |
|
print "** asdfsdf" |
|
661 |
params = ["proj=tmerc", |
params = ["proj=tmerc", |
662 |
"lat_0=" + self.__latitude.GetValue(), |
"lat_0=" + self.__latitude.GetValue(), |
663 |
"lon_0=" + self.__longitude.GetValue(), |
"lon_0=" + self.__longitude.GetValue(), |
681 |
ID_UTMPANEL_PROP = 4003 |
ID_UTMPANEL_PROP = 4003 |
682 |
|
|
683 |
class UTMPanel(ProjPanel): |
class UTMPanel(ProjPanel): |
684 |
"""Projection Panel for Universal Transverse Mercartor.""" |
"""Projection Panel for Universal Transverse Mercator.""" |
685 |
|
|
686 |
def __init__(self, parent): |
def __init__(self, parent, receiver): |
687 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
688 |
|
|
689 |
self.parent = parent |
self.receiver = receiver |
690 |
|
|
691 |
self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60) |
self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60) |
692 |
self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH, |
self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH, |
710 |
ProjPanel._DoLayout(self, sizer) |
ProjPanel._DoLayout(self, sizer) |
711 |
|
|
712 |
def GetProjName(self): |
def GetProjName(self): |
713 |
return _("Universal Transverse Mercartor") |
return _("Universal Transverse Mercator") |
714 |
|
|
715 |
def SetProjection(self, proj): |
def SetProjection(self, proj): |
716 |
self.__zone.SetValue(int(proj.GetParameter("zone"))) |
self.__zone.SetValue(int(proj.GetParameter("zone"))) |
718 |
ProjPanel.SetProjection(self, proj) |
ProjPanel.SetProjection(self, proj) |
719 |
|
|
720 |
def GetParameters(self): |
def GetParameters(self): |
|
print "** asdfsdf" |
|
721 |
params = ["proj=utm", "zone=" + str(self.__zone.GetValue())] |
params = ["proj=utm", "zone=" + str(self.__zone.GetValue())] |
722 |
if self.__south.IsChecked(): |
if self.__south.IsChecked(): |
723 |
params.append("south") |
params.append("south") |
732 |
|
|
733 |
def _OnPropose(self, event): |
def _OnPropose(self, event): |
734 |
UTMProposeZoneDialog |
UTMProposeZoneDialog |
735 |
dlg = UTMProposeZoneDialog(self, self.parent.GetReceiver().BoundingBox()) |
dlg = UTMProposeZoneDialog(self, self.receiver.BoundingBox()) |
736 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
737 |
self.__zone.SetValue(dlg.GetProposedZone()) |
self.__zone.SetValue(dlg.GetProposedZone()) |
738 |
|
|
739 |
class LCCPanel(ProjPanel): |
class LCCPanel(ProjPanel): |
740 |
"""Projection Panel for Lambert Conic Conformal.""" |
"""Projection Panel for Lambert Conic Conformal.""" |
741 |
|
|
742 |
def __init__(self, parent): |
def __init__(self, parent, receiver): |
743 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
744 |
|
|
745 |
self.__fspLatitude = wxTextCtrl(self, -1) |
self.__fspLatitude = wxTextCtrl(self, -1) |
809 |
class GeoPanel(ProjPanel): |
class GeoPanel(ProjPanel): |
810 |
"""Projection Panel for a Geographic Projection.""" |
"""Projection Panel for a Geographic Projection.""" |
811 |
|
|
812 |
def __init__(self, parent): |
def __init__(self, parent, receiver): |
813 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
814 |
ProjPanel._DoLayout(self, None) |
ProjPanel._DoLayout(self, None) |
815 |
|
|