5 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
6 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
7 |
|
|
8 |
import os, sys |
import os, sys, math |
9 |
from wxPython.wx import * |
from wxPython.wx import * |
10 |
|
|
11 |
from Thuban import _ |
from Thuban import _ |
21 |
ID_PROJ_PROJCHOICE = 4002 |
ID_PROJ_PROJCHOICE = 4002 |
22 |
ID_PROJ_ADDTOLIST = 4003 |
ID_PROJ_ADDTOLIST = 4003 |
23 |
ID_PROJ_NEW = 4004 |
ID_PROJ_NEW = 4004 |
|
ID_PROJ_TRY = 4005 |
|
24 |
ID_PROJ_REVERT = 4006 |
ID_PROJ_REVERT = 4006 |
|
ID_PROJ_OK = 4007 |
|
|
ID_PROJ_CLOSE = 4008 |
|
25 |
ID_PROJ_AVAIL = 4009 |
ID_PROJ_AVAIL = 4009 |
26 |
ID_PROJ_SAVE = 4010 |
ID_PROJ_SAVE = 4010 |
27 |
ID_PROJ_IMPORT = 4011 |
ID_PROJ_IMPORT = 4011 |
61 |
self.panel_1 = wxPanel(self, -1) |
self.panel_1 = wxPanel(self, -1) |
62 |
self.panel_edit = wxPanel(self, -1) |
self.panel_edit = wxPanel(self, -1) |
63 |
self.panel_buttons = wxPanel(self, -1) |
self.panel_buttons = wxPanel(self, -1) |
64 |
self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:")) |
self.label_5 = wxStaticText(self.panel_1, -1, |
65 |
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_EXTENDED|wxLB_SORT) |
_("Available Projections:")) |
66 |
|
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, |
67 |
|
style=wxLB_EXTENDED|wxLB_SORT) |
68 |
self.projfilepath = wxStaticText(self.panel_1, -1, "") |
self.projfilepath = wxStaticText(self.panel_1, -1, "") |
69 |
self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:")) |
self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:")) |
70 |
self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "") |
self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "") |
71 |
self.label_3 = wxStaticText(self.panel_edit, -1, _("Projection:")) |
self.label_3 = wxStaticText(self.panel_edit, -1, _("Projection:")) |
72 |
self.projchoice = wxChoice(self.panel_edit, ID_PROJ_PROJCHOICE) |
self.projchoice = wxChoice(self.panel_edit, ID_PROJ_PROJCHOICE) |
73 |
self.button_import = wxButton(self.panel_1, ID_PROJ_IMPORT, _("Import...")) |
self.button_import = wxButton(self.panel_1, ID_PROJ_IMPORT, |
74 |
self.button_export = wxButton(self.panel_1, ID_PROJ_EXPORT, _("Export...")) |
_("Import...")) |
75 |
|
self.button_export = wxButton(self.panel_1, ID_PROJ_EXPORT, |
76 |
|
_("Export...")) |
77 |
self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove")) |
self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove")) |
78 |
self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New")) |
self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New")) |
79 |
self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Save")) |
self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Save")) |
80 |
self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST, |
self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST, |
81 |
_("Add to List")) |
_("Add to List")) |
82 |
self.button_try = wxButton(self.panel_buttons, ID_PROJ_TRY, _("Try")) |
self.button_try = wxButton(self.panel_buttons, wxID_APPLY, _("Try")) |
83 |
self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, _("Revert")) |
self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, |
84 |
self.button_ok = wxButton(self.panel_buttons, ID_PROJ_OK, _("OK")) |
_("Revert")) |
85 |
self.button_close = wxButton(self.panel_buttons, ID_PROJ_CLOSE, _("Close")) |
self.button_ok = wxButton(self.panel_buttons, wxID_OK, _("OK")) |
86 |
|
self.button_ok.SetDefault() |
87 |
|
self.button_close = wxButton(self.panel_buttons, wxID_CANCEL, |
88 |
|
_("Close")) |
89 |
|
|
90 |
self.__set_properties() |
self.__set_properties() |
91 |
self.__do_layout() |
self.__do_layout() |
94 |
self.originalProjection = self.receiver.GetProjection() |
self.originalProjection = self.receiver.GetProjection() |
95 |
|
|
96 |
self.__DoOnProjAvail() |
self.__DoOnProjAvail() |
97 |
|
self.button_ok.SetFocus() |
98 |
|
self.availprojs.SetFocus() |
99 |
|
|
100 |
EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry) |
EVT_BUTTON(self, wxID_APPLY, self.OnApply) |
101 |
EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert) |
EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert) |
102 |
EVT_BUTTON(self, ID_PROJ_OK, self._OnOK) |
EVT_BUTTON(self, wxID_OK, self.OnOK) |
103 |
EVT_BUTTON(self, ID_PROJ_CLOSE, self._OnClose) |
EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) |
104 |
EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice) |
EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice) |
105 |
EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail) |
EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail) |
106 |
EVT_BUTTON(self, ID_PROJ_IMPORT, self._OnImport) |
EVT_BUTTON(self, ID_PROJ_IMPORT, self._OnImport) |
113 |
|
|
114 |
EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName) |
EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName) |
115 |
|
|
116 |
def _OnTry(self, event): |
|
117 |
|
def OnApply(self, event): |
118 |
self.__SetProjection() |
self.__SetProjection() |
119 |
self.haveTried = True |
self.haveTried = True |
120 |
|
|
121 |
|
def OnOK(self, event): |
122 |
|
self.__SetProjection() |
123 |
|
self.Close() |
124 |
|
|
125 |
|
def OnCancel(self, event): |
126 |
|
"""Cancel just closes the dialog, but we call it cancel so we |
127 |
|
can overload the functionality of wxDialog. |
128 |
|
""" |
129 |
|
self.Close() |
130 |
|
|
131 |
def _OnRevert(self, event): |
def _OnRevert(self, event): |
132 |
if self.haveTried: |
if self.haveTried: |
133 |
self.receiver.SetProjection(self.originalProjection) |
self.receiver.SetProjection(self.originalProjection) |
134 |
self.haveTried = False |
self.haveTried = False |
135 |
|
|
|
def _OnOK(self, event): |
|
|
self.__SetProjection() |
|
|
self.Close() |
|
|
|
|
|
def _OnClose(self, event): |
|
|
self.Close() |
|
136 |
|
|
137 |
def _OnNew(self, event): |
def _OnNew(self, event): |
138 |
|
|
162 |
newproj = self.__GetProjection() |
newproj = self.__GetProjection() |
163 |
|
|
164 |
if newproj is not None: |
if newproj is not None: |
165 |
proj.SetProjection(newproj) |
projfile.Replace(proj, newproj) |
166 |
try: |
try: |
167 |
WriteProjFile(projfile) |
WriteProjFile(projfile) |
168 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
169 |
self.__ShowError(projfile.GetFilename(), errstr) |
self.__ShowError(projfile.GetFilename(), errstr) |
170 |
|
self.availprojs.SetClientData(sel[0], [newproj, projfile]) |
171 |
|
|
172 |
def _OnAddToList(self, event): |
def _OnAddToList(self, event): |
173 |
|
|
606 |
wxPanel.__init__(self, parent, -1) |
wxPanel.__init__(self, parent, -1) |
607 |
|
|
608 |
self.__ellps = wxChoice(self, -1) |
self.__ellps = wxChoice(self, -1) |
609 |
self.ellpsData = [("bessel", _("Bessel 1841")), |
self.ellpsData = [("airy" , _("Airy")), |
610 |
|
("bessel", _("Bessel 1841")), |
611 |
("clrk66", _("Clarke 1866")), |
("clrk66", _("Clarke 1866")), |
612 |
("clrk80", _("Clarke 1880")), |
("clrk80", _("Clarke 1880")), |
613 |
("GRS80" , _("GRS 1980 (IUGG, 1980)")), |
("GRS80" , _("GRS 1980 (IUGG, 1980)")), |
624 |
panelSizer = wxBoxSizer(wxVERTICAL) |
panelSizer = wxBoxSizer(wxVERTICAL) |
625 |
|
|
626 |
if childPanel is not None: |
if childPanel is not None: |
627 |
panelSizer.Add(childPanel, 0, wxALL|wxEXPAND, 4) |
panelSizer.Add(childPanel, 0, wxEXPAND, 0) |
628 |
|
|
629 |
sizer = wxBoxSizer(wxHORIZONTAL) |
sizer = wxBoxSizer(wxHORIZONTAL) |
630 |
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4) |
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4) |
764 |
self.receiver = receiver |
self.receiver = receiver |
765 |
|
|
766 |
self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60) |
self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60) |
767 |
|
self.__propButton = wxButton(self, ID_UTMPANEL_PROP, _("Propose")) |
768 |
self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH, |
self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH, |
769 |
_("Southern Hemisphere")) |
_("Southern Hemisphere")) |
|
self.__propButton = wxButton(self, ID_UTMPANEL_PROP, _("Propose")) |
|
770 |
|
|
771 |
self._DoLayout() |
self._DoLayout() |
772 |
|
|
886 |
|
|
887 |
def __init__(self, parent, receiver): |
def __init__(self, parent, receiver): |
888 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
889 |
ProjPanel._DoLayout(self, None) |
|
890 |
|
self.__choices = [(_("Radians"), "1"), |
891 |
|
(_("Degrees"), "0.017453")] |
892 |
|
|
893 |
|
self.__scale = wxChoice(self, -1) |
894 |
|
for choice, value in self.__choices: |
895 |
|
self.__scale.Append(choice, value) |
896 |
|
|
897 |
|
self._DoLayout() |
898 |
|
|
899 |
def GetProjName(self): |
def GetProjName(self): |
900 |
return _("Geographic") |
return _("Geographic") |
901 |
|
|
902 |
def SetProjection(self, proj): |
def SetProjection(self, proj): |
903 |
|
value = proj.GetParameter("to_meter") |
904 |
|
for i in range(len(self.__choices)): |
905 |
|
choice, data = self.__choices[i] |
906 |
|
if value == data: |
907 |
|
self.__scale.SetSelection(i) |
908 |
ProjPanel.SetProjection(self, proj) |
ProjPanel.SetProjection(self, proj) |
909 |
|
|
910 |
def GetParameters(self): |
def GetParameters(self): |
911 |
params = ["proj=latlong"] |
params = ["proj=latlong", |
912 |
|
"to_meter=%s" % self.__scale.GetClientData( |
913 |
|
self.__scale.GetSelection())] |
914 |
|
|
915 |
params.extend(ProjPanel.GetParameters(self)) |
params.extend(ProjPanel.GetParameters(self)) |
916 |
return params |
return params |
917 |
|
|
918 |
def Clear(self): |
def Clear(self): |
919 |
ProjPanel.Clear(self) |
ProjPanel.Clear(self) |
920 |
|
|
921 |
|
def _DoLayout(self): |
922 |
|
sizer = wxBoxSizer(wxHORIZONTAL) |
923 |
|
|
924 |
|
sizer.Add(wxStaticText(self, -1, _("Source Data is in: ")), |
925 |
|
0, wxALL, 4) |
926 |
|
sizer.Add(self.__scale, 1, wxEXPAND|wxALL, 4) |
927 |
|
|
928 |
|
self.__scale.SetSelection(0) |
929 |
|
|
930 |
|
ProjPanel._DoLayout(self, sizer) |
931 |
|
|
932 |
|
|
933 |
ID_UTM_PROPOSE_ZONE_DIALOG_TAKE = 4001 |
ID_UTM_PROPOSE_ZONE_DIALOG_TAKE = 4001 |
934 |
ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002 |
ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002 |