1 |
# Copyright (c) 2003 by Intevation GmbH |
# Copyright (c) 2003, 2004 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Jonathan Coles <[email protected]> |
# Jonathan Coles <[email protected]> |
4 |
# Frank Koormann <[email protected]> |
# Frank Koormann <[email protected]> |
13 |
# $Source$ |
# $Source$ |
14 |
# $Id$ |
# $Id$ |
15 |
|
|
16 |
import os |
import sys, os |
17 |
from wxPython.wx import * |
from wxPython.wx import * |
18 |
|
|
19 |
from Thuban import _ |
from Thuban import _ |
113 |
self.button_export = wxButton(self, ID_PROJ_EXPORT, _("Export...")) |
self.button_export = wxButton(self, ID_PROJ_EXPORT, _("Export...")) |
114 |
EVT_BUTTON(self, ID_PROJ_EXPORT, self._OnExport) |
EVT_BUTTON(self, ID_PROJ_EXPORT, self._OnExport) |
115 |
buttons.Add(self.button_export, 1, wxALL|wxEXPAND, 4) |
buttons.Add(self.button_export, 1, wxALL|wxEXPAND, 4) |
116 |
buttons.Add(20, 20, 0, wxEXPAND, 0) |
buttons.Add( (20, 20), 0, wxEXPAND, 0) |
117 |
self.button_remove = wxButton(self, ID_PROJ_REMOVE, _("Remove")) |
self.button_remove = wxButton(self, ID_PROJ_REMOVE, _("Remove")) |
118 |
EVT_BUTTON(self, ID_PROJ_REMOVE, self._OnRemove) |
EVT_BUTTON(self, ID_PROJ_REMOVE, self._OnRemove) |
119 |
buttons.Add(self.button_remove, 1, wxALL|wxEXPAND, 4) |
buttons.Add(self.button_remove, 1, wxALL|wxEXPAND, 4) |
120 |
|
|
121 |
buttons.Add(20, 20, 0, wxEXPAND, 0) |
buttons.Add( (20, 20), 0, wxEXPAND, 0) |
122 |
label = wxStaticText(self, -1, _("Show EPSG:")) |
label = wxStaticText(self, -1, _("Show EPSG:")) |
123 |
buttons.Add(label, 0, wxLEFT|wxRIGHT|wxTOP, 4) |
buttons.Add(label, 0, wxLEFT|wxRIGHT|wxTOP, 4) |
124 |
self.check_epsg = wxCheckBox(self, -1, _("Normal")) |
self.check_epsg = wxCheckBox(self, -1, _("Normal")) |
186 |
self.button_add = wxButton(self, ID_PROJ_ADDTOLIST, _("Add to List")) |
self.button_add = wxButton(self, ID_PROJ_ADDTOLIST, _("Add to List")) |
187 |
EVT_BUTTON(self, ID_PROJ_ADDTOLIST, self._OnAddToList) |
EVT_BUTTON(self, ID_PROJ_ADDTOLIST, self._OnAddToList) |
188 |
buttons.Add(self.button_add, 0, wxEXPAND|wxALL, 4) |
buttons.Add(self.button_add, 0, wxEXPAND|wxALL, 4) |
189 |
buttons.Add(20, 20, 0, wxEXPAND, 0) |
buttons.Add( (20, 20), 0, wxEXPAND, 0) |
190 |
self.button_save = wxButton(self, ID_PROJ_SAVE,_("Update")) |
self.button_save = wxButton(self, ID_PROJ_SAVE,_("Update")) |
191 |
EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave) |
EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave) |
192 |
buttons.Add(self.button_save, 0, wxEXPAND|wxALL|wxALIGN_BOTTOM, 4) |
buttons.Add(self.button_save, 0, wxEXPAND|wxALL|wxALIGN_BOTTOM, 4) |
303 |
add them to the user ProjFile object and write the user file |
add them to the user ProjFile object and write the user file |
304 |
back to disk. |
back to disk. |
305 |
""" |
""" |
306 |
dlg = wxFileDialog(self, _("Import"), style = wxOPEN) |
dlg = wxFileDialog(self, _("Import"), |
307 |
|
self.parent.application.Path("projection"), style = wxOPEN) |
308 |
|
|
309 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
310 |
path = dlg.GetPath() |
path = dlg.GetPath() |
320 |
for proj in projFile.GetProjections(): |
for proj in projFile.GetProjections(): |
321 |
self.__usrProjFile.Add(proj) |
self.__usrProjFile.Add(proj) |
322 |
self.write_proj_file(self.__usrProjFile) |
self.write_proj_file(self.__usrProjFile) |
323 |
|
self.parent.application.SetPath("projection", path) |
324 |
finally: |
finally: |
325 |
ThubanEndBusyCursor() |
ThubanEndBusyCursor() |
326 |
dlg.Destroy() |
dlg.Destroy() |
334 |
sel = self.projection_list.selected_projections() |
sel = self.projection_list.selected_projections() |
335 |
assert len(sel) != 0, "button should be disabled" |
assert len(sel) != 0, "button should be disabled" |
336 |
|
|
337 |
dlg = wxFileDialog(self, _("Export"), style=wxSAVE|wxOVERWRITE_PROMPT) |
dlg = wxFileDialog(self, _("Export"), |
338 |
|
self.parent.application.Path("projection"), |
339 |
|
style=wxSAVE|wxOVERWRITE_PROMPT) |
340 |
|
|
341 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
342 |
proj_file = ProjFile(dlg.GetPath()) |
proj_file = ProjFile(dlg.GetPath()) |
344 |
if proj is not None: |
if proj is not None: |
345 |
proj_file.Add(proj) |
proj_file.Add(proj) |
346 |
self.write_proj_file(proj_file) |
self.write_proj_file(proj_file) |
347 |
|
self.parent.application.SetPath("projection", dlg.GetPath()) |
348 |
|
|
349 |
dlg.Destroy() |
dlg.Destroy() |
350 |
|
|
530 |
def _show_proj_panel(self, panel_class): |
def _show_proj_panel(self, panel_class): |
531 |
"""Show the panel as the projection panel""" |
"""Show the panel as the projection panel""" |
532 |
if panel_class is UnknownProjPanel: |
if panel_class is UnknownProjPanel: |
533 |
|
self.button_ok.Disable() |
534 |
|
self.button_try.Disable() |
535 |
self.edit_box.Disable() |
self.edit_box.Disable() |
536 |
self.nbsizer.Activate(self.unknown_projection_panel) |
self.nbsizer.Activate(self.unknown_projection_panel) |
537 |
self.curProjPanel = self.unknown_projection_panel |
self.curProjPanel = self.unknown_projection_panel |
538 |
else: |
else: |
539 |
|
self.button_ok.Enable(True) |
540 |
|
self.button_try.Enable(True) |
541 |
self.edit_box.Enable(True) |
self.edit_box.Enable(True) |
542 |
self.unknown_projection_panel.Hide() |
self.unknown_projection_panel.Hide() |
543 |
for panel in self.projection_panels: |
for panel in self.projection_panels: |
573 |
# self.curProjPanel should always contain the most relevant data |
# self.curProjPanel should always contain the most relevant data |
574 |
# for a projection |
# for a projection |
575 |
if self.curProjPanel is not None: |
if self.curProjPanel is not None: |
576 |
return Projection(self.curProjPanel.GetParameters(), |
parameters = self.curProjPanel.GetParameters() |
577 |
self.projname.GetValue()) |
if parameters is not None: |
578 |
|
return Projection(parameters, self.projname.GetValue()) |
579 |
|
|
580 |
return None |
return None |
581 |
|
|
586 |
with get_user_proj_file and cache it in self.__usrProjFile. |
with get_user_proj_file and cache it in self.__usrProjFile. |
587 |
|
|
588 |
Show a busy cursor while loading the file. |
Show a busy cursor while loading the file. |
589 |
|
|
590 |
|
If the file is not available, leave a note to the console. |
591 |
""" |
""" |
592 |
if self.__usrProjFile is None: |
if self.__usrProjFile is None: |
593 |
ThubanBeginBusyCursor() |
ThubanBeginBusyCursor() |
594 |
try: |
try: |
595 |
projfile, warnings = get_user_proj_file() |
projfile, warnings = get_user_proj_file() |
596 |
self.show_warnings(_("Warnings"), projfile.GetFilename(), |
if warnings: |
597 |
warnings) |
sys.stderr.write("".join(warnings)) |
598 |
|
sys.stderr.write("\n") |
599 |
self.__usrProjFile = projfile |
self.__usrProjFile = projfile |
600 |
finally: |
finally: |
601 |
ThubanEndBusyCursor() |
ThubanEndBusyCursor() |