13 |
|
|
14 |
from Thuban.Model.proj import Projection, ProjFile |
from Thuban.Model.proj import Projection, ProjFile |
15 |
|
|
16 |
from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles, \ |
from Thuban.Model.resource import get_user_proj_files, get_system_proj_files, \ |
17 |
ReadProjFile, WriteProjFile |
read_proj_file, write_proj_file |
18 |
from Thuban.UI.dialogs import NonModalDialog |
from Thuban.UI.dialogs import NonModalNonParentDialog |
19 |
|
|
20 |
|
|
21 |
ID_PROJ_ADVANCED = 4001 |
ID_PROJ_ADVANCED = 4001 |
33 |
CLIENT_PROJ = 0 |
CLIENT_PROJ = 0 |
34 |
CLIENT_PROJFILE = 1 |
CLIENT_PROJFILE = 1 |
35 |
|
|
36 |
class ProjFrame(NonModalDialog): |
class ProjFrame(NonModalNonParentDialog): |
37 |
|
|
38 |
def __init__(self, parent, name, title, receiver): |
def __init__(self, parent, name, title, receiver): |
39 |
"""Initialize the projection dialog. |
"""Initialize the projection dialog. |
57 |
self.projPanels.append( |
self.projPanels.append( |
58 |
("latlong", _("Geographic"), GeoPanel)) |
("latlong", _("Geographic"), GeoPanel)) |
59 |
|
|
60 |
NonModalDialog.__init__(self, parent, name, title) |
NonModalNonParentDialog.__init__(self, parent, name, title) |
61 |
# originally generate by wxGlade |
# originally generate by wxGlade |
62 |
self.panel_1 = wxPanel(self, -1) |
self.panel_1 = wxPanel(self, -1) |
63 |
self.panel_edit = wxPanel(self, -1) |
self.panel_edit = wxPanel(self, -1) |
100 |
|
|
101 |
self.__set_properties() |
self.__set_properties() |
102 |
self.__do_layout() |
self.__do_layout() |
103 |
|
|
104 |
# wxGlade |
# wxGlade |
105 |
|
|
106 |
|
# Fill the projection choice list. |
107 |
|
for proj, name, clazz in self.projPanels: |
108 |
|
self.projchoice.Append(name, [clazz, None]) |
109 |
|
|
110 |
self.originalProjection = self.receiver.GetProjection() |
self.originalProjection = self.receiver.GetProjection() |
111 |
|
|
112 |
self.__DoOnProjAvail() |
self.__DoOnProjAvail() |
180 |
if newproj is not None: |
if newproj is not None: |
181 |
projfile.Replace(proj, newproj) |
projfile.Replace(proj, newproj) |
182 |
try: |
try: |
183 |
WriteProjFile(projfile) |
write_proj_file(projfile) |
184 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
185 |
self.__ShowError(projfile.GetFilename(), errstr) |
self.__ShowError(projfile.GetFilename(), errstr) |
186 |
self.availprojs.SetClientData(sel[0], [newproj, projfile]) |
self.availprojs.SetClientData(sel[0], [newproj, projfile]) |
187 |
|
|
188 |
|
self.__FillAvailList( selectProj = newproj.GetName()) |
189 |
|
|
190 |
def _OnAddToList(self, event): |
def _OnAddToList(self, event): |
191 |
|
|
192 |
proj = self.__GetProjection() |
proj = self.__GetProjection() |
193 |
if proj is not None: |
if proj is not None: |
194 |
self.__usrProjFile.Add(proj) |
self.__usrProjFile.Add(proj) |
195 |
try: |
try: |
196 |
WriteProjFile(self.__usrProjFile) |
write_proj_file(self.__usrProjFile) |
197 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
198 |
self.__ShowError(self.__userProjFile.GetFilename(), errstr) |
self.__ShowError(self.__userProjFile.GetFilename(), errstr) |
199 |
|
|
200 |
self.__FillAvailList() |
self.__FillAvailList( selectProj = proj.GetName()) |
201 |
|
|
202 |
def _OnProjAvail(self, event): |
def _OnProjAvail(self, event): |
203 |
self.__DoOnProjAvail() |
self.__DoOnProjAvail() |
210 |
path = dlg.GetPath() |
path = dlg.GetPath() |
211 |
|
|
212 |
try: |
try: |
213 |
projFile = ReadProjFile(path) |
projFile = read_proj_file(path) |
214 |
for proj in projFile.GetProjections(): |
for proj in projFile.GetProjections(): |
215 |
self.__usrProjFile.Add(proj) |
self.__usrProjFile.Add(proj) |
216 |
WriteProjFile(self.__usrProjFile) |
write_proj_file(self.__usrProjFile) |
217 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
218 |
self.__ShowError(dlg.GetPath(), errstr) |
self.__ShowError(dlg.GetPath(), errstr) |
219 |
|
|
240 |
projFile.Add(proj) |
projFile.Add(proj) |
241 |
|
|
242 |
try: |
try: |
243 |
WriteProjFile(projFile) |
write_proj_file(projFile) |
244 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
245 |
self.__ShowError(dlg.GetPath(), errstr) |
self.__ShowError(dlg.GetPath(), errstr) |
246 |
|
|
275 |
projfile.Remove(proj) |
projfile.Remove(proj) |
276 |
|
|
277 |
try: |
try: |
278 |
WriteProjFile(projfile) |
write_proj_file(projfile) |
279 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
280 |
self.__ShowError(projfile.GetFilename(), errstr) |
self.__ShowError(projfile.GetFilename(), errstr) |
281 |
|
|
476 |
|
|
477 |
return None |
return None |
478 |
|
|
479 |
def __FillAvailList(self, selectCurrent = False): |
def __FillAvailList(self, selectCurrent = False, selectProj = None): |
480 |
"""Populate the list of available projections. |
"""Populate the list of available projections. |
481 |
|
|
482 |
selectCurrent -- if True, select the projection used by |
selectCurrent -- if True, select the projection used by |
483 |
the receiver, otherwise select nothing. |
the receiver, otherwise select nothing. |
484 |
|
selectProj -- if set, select the projection found under the |
485 |
|
specified name. This overwrites any other |
486 |
|
selection estimate. |
487 |
""" |
""" |
488 |
|
|
489 |
self.availprojs.Clear() |
self.availprojs.Clear() |
494 |
# |
# |
495 |
self.availprojs.Append("<None>", (None, None)) |
self.availprojs.Append("<None>", (None, None)) |
496 |
|
|
497 |
projfile = GetSystemProjFiles() |
projfile = get_system_proj_files() |
498 |
projfile = projfile[0] |
projfile = projfile[0] |
499 |
for proj in projfile.GetProjections(): |
for proj in projfile.GetProjections(): |
500 |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
501 |
self.__sysProjFile = projfile |
self.__sysProjFile = projfile |
502 |
|
|
503 |
projfile = GetUserProjFiles() |
projfile = get_user_proj_files() |
504 |
projfile = projfile[0] |
projfile = projfile[0] |
505 |
for proj in projfile.GetProjections(): |
for proj in projfile.GetProjections(): |
506 |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
507 |
self.__usrProjFile = projfile |
self.__usrProjFile = projfile |
508 |
|
|
|
for proj, name, clazz in self.projPanels: |
|
|
self.projchoice.Append(name, [clazz, None]) |
|
|
|
|
509 |
# |
# |
510 |
# We add the current projection to the list at last. |
# We add the current projection to the list at last. |
511 |
# Since the list is resorted immediately a following FindString() |
# Since the list is resorted immediately a following FindString() |
524 |
self.availprojs.SetSelection( |
self.availprojs.SetSelection( |
525 |
self.availprojs.FindString("<None>") |
self.availprojs.FindString("<None>") |
526 |
) |
) |
527 |
|
if selectProj: |
528 |
|
self.availprojs.SetSelection( |
529 |
|
self.availprojs.FindString(selectProj) |
530 |
|
) |
531 |
|
|
532 |
|
|
533 |
|
|
534 |
def __set_properties(self): |
def __set_properties(self): |
574 |
sizer_13.Add(self.projname, 1, wxALL, 4) |
sizer_13.Add(self.projname, 1, wxALL, 4) |
575 |
self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0) |
self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0) |
576 |
sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
577 |
sizer_14.Add(self.projchoice, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
sizer_14.Add(self.projchoice, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
578 |
self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0) |
self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0) |
579 |
self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0) |
self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0) |
580 |
sizer_11.Add(self.button_new, 0, wxALL, 4) |
sizer_11.Add(self.button_new, 0, wxEXPAND|wxALL, 4) |
581 |
sizer_11.Add(self.button_add, 0, wxALL, 4) |
sizer_11.Add(self.button_add, 0, wxEXPAND|wxALL, 4) |
582 |
sizer_11.Add(20, 20, 0, wxEXPAND, 0) |
sizer_11.Add(20, 20, 0, wxEXPAND, 0) |
583 |
sizer_11.Add(self.button_save, 0, wxALL|wxALIGN_BOTTOM, 4) |
sizer_11.Add(self.button_save, 0, wxEXPAND|wxALL|wxALIGN_BOTTOM, 4) |
584 |
self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4) |
self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4) |
585 |
|
|
586 |
sizer_6.Add(self.button_try, 0, wxRIGHT| wxEXPAND, 10) |
sizer_6.Add(self.button_try, 0, wxRIGHT| wxEXPAND, 10) |
645 |
sizer = wxBoxSizer(wxHORIZONTAL) |
sizer = wxBoxSizer(wxHORIZONTAL) |
646 |
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, |
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, |
647 |
wxALL|wxALIGN_CENTER_VERTICAL, 4) |
wxALL|wxALIGN_CENTER_VERTICAL, 4) |
648 |
sizer.Add(self.__ellps, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
sizer.Add(self.__ellps, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
649 |
panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4) |
panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4) |
650 |
|
|
651 |
if childPanel is not None: |
if childPanel is not None: |
855 |
sizer.Add(wxStaticText(self, -1, |
sizer.Add(wxStaticText(self, -1, |
856 |
_("Latitude of second standard parallel:"))) |
_("Latitude of second standard parallel:"))) |
857 |
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) |
|
858 |
sizer.Add(wxStaticText(self, -1, _("Central Meridian:"))) |
sizer.Add(wxStaticText(self, -1, _("Central Meridian:"))) |
859 |
sizer.Add(self.__meridian, 0, wxALL, 4) |
sizer.Add(self.__meridian, 0, wxALL, 4) |
860 |
|
sizer.Add(wxStaticText(self, -1, _("Latitude of origin:"))) |
861 |
|
sizer.Add(self.__originLat, 0, wxALL, 4) |
862 |
sizer.Add(wxStaticText(self, -1, _("False Easting:"))) |
sizer.Add(wxStaticText(self, -1, _("False Easting:"))) |
863 |
sizer.Add(self.__falseEast, 0, wxALL, 4) |
sizer.Add(self.__falseEast, 0, wxALL, 4) |
864 |
sizer.Add(wxStaticText(self, -1, _("False Northing:"))) |
sizer.Add(wxStaticText(self, -1, _("False Northing:"))) |