1 |
# Copyright (c) 2003 by Intevation GmbH |
# Copyright (c) 2003 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Jonathan Coles <[email protected]> |
# Jonathan Coles <[email protected]> |
4 |
|
# Frank Koormann <[email protected]> |
5 |
|
# Jan-Oliver Wagner <[email protected]> |
6 |
# |
# |
7 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
8 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
9 |
|
|
10 |
import os, sys, math |
"""Projection dialog""" |
11 |
|
|
12 |
|
__version__ = "$Revision$" |
13 |
|
# $Source$ |
14 |
|
# $Id$ |
15 |
|
|
16 |
|
import os |
17 |
from wxPython.wx import * |
from wxPython.wx import * |
18 |
|
|
19 |
from Thuban import _ |
from Thuban import _ |
20 |
|
|
21 |
from Thuban.Model.proj import Projection, ProjFile |
from Thuban.Model.proj import Projection, ProjFile |
22 |
|
|
23 |
from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles, \ |
from Thuban.Model.resource import get_user_proj_file, get_system_proj_file, \ |
24 |
ReadProjFile, WriteProjFile |
read_proj_file, write_proj_file |
25 |
from Thuban.UI.dialogs import NonModalDialog |
from Thuban.UI.dialogs import NonModalNonParentDialog |
26 |
|
|
27 |
|
|
28 |
ID_PROJ_ADVANCED = 4001 |
ID_PROJ_ADVANCED = 4001 |
40 |
CLIENT_PROJ = 0 |
CLIENT_PROJ = 0 |
41 |
CLIENT_PROJFILE = 1 |
CLIENT_PROJFILE = 1 |
42 |
|
|
43 |
class ProjFrame(NonModalDialog): |
class ProjFrame(NonModalNonParentDialog): |
44 |
|
|
45 |
def __init__(self, parent, name, title, receiver): |
def __init__(self, parent, name, title, receiver): |
46 |
"""Initialize the projection dialog. |
"""Initialize the projection dialog. |
64 |
self.projPanels.append( |
self.projPanels.append( |
65 |
("latlong", _("Geographic"), GeoPanel)) |
("latlong", _("Geographic"), GeoPanel)) |
66 |
|
|
67 |
NonModalDialog.__init__(self, parent, name, title) |
NonModalNonParentDialog.__init__(self, parent, name, title) |
68 |
# originally generate by wxGlade |
# originally generate by wxGlade |
69 |
self.panel_1 = wxPanel(self, -1) |
self.panel_1 = wxPanel(self, -1) |
70 |
self.panel_edit = wxPanel(self, -1) |
self.panel_edit = wxPanel(self, -1) |
|
self.panel_buttons = wxPanel(self, -1) |
|
71 |
self.label_5 = wxStaticText(self.panel_1, -1, |
self.label_5 = wxStaticText(self.panel_1, -1, |
72 |
_("Available Projections:")) |
_("Available Projections:")) |
73 |
|
|
74 |
|
# Projection List specific actions (Import/Export/Remove) |
75 |
|
self.button_import = wxButton(self.panel_1, ID_PROJ_IMPORT, |
76 |
|
_("Import...")) |
77 |
|
self.button_export = wxButton(self.panel_1, ID_PROJ_EXPORT, |
78 |
|
_("Export...")) |
79 |
|
self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, |
80 |
|
_("Remove")) |
81 |
|
|
82 |
|
# The Projection List |
83 |
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, |
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, |
84 |
style=wxLB_EXTENDED|wxLB_SORT) |
style=wxLB_EXTENDED|wxLB_SORT) |
85 |
self.projfilepath = wxStaticText(self.panel_1, -1, "") |
self.projfilepath = wxStaticText(self.panel_1, -1, "") |
86 |
|
|
87 |
|
# Projection Specific Entries (Name/Projection) |
88 |
self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:")) |
self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:")) |
89 |
self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "") |
self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "") |
90 |
self.label_3 = wxStaticText(self.panel_edit, -1, _("Projection:")) |
self.label_3 = wxStaticText(self.panel_edit, -1, _("Projection:")) |
91 |
self.projchoice = wxChoice(self.panel_edit, ID_PROJ_PROJCHOICE) |
self.projchoice = wxChoice(self.panel_edit, ID_PROJ_PROJCHOICE) |
92 |
self.button_import = wxButton(self.panel_1, ID_PROJ_IMPORT, |
|
93 |
_("Import...")) |
# Projection Specific actions (New/Save/Add) |
|
self.button_export = wxButton(self.panel_1, ID_PROJ_EXPORT, |
|
|
_("Export...")) |
|
|
self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove")) |
|
94 |
self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New")) |
self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New")) |
|
self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Save")) |
|
95 |
self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST, |
self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST, |
96 |
_("Add to List")) |
_("Add to List")) |
97 |
self.button_try = wxButton(self.panel_buttons, wxID_APPLY, _("Try")) |
self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Update")) |
98 |
self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, |
|
99 |
|
# Main Action buttons (Try/Revert/OK/Close) |
100 |
|
self.button_try = wxButton(self, wxID_APPLY, _("Try")) |
101 |
|
self.button_revert = wxButton(self, ID_PROJ_REVERT, |
102 |
_("Revert")) |
_("Revert")) |
103 |
self.button_ok = wxButton(self.panel_buttons, wxID_OK, _("OK")) |
self.button_ok = wxButton(self, wxID_OK, _("OK")) |
104 |
self.button_ok.SetDefault() |
self.button_ok.SetDefault() |
105 |
self.button_close = wxButton(self.panel_buttons, wxID_CANCEL, |
self.button_close = wxButton(self, wxID_CANCEL, |
106 |
_("Close")) |
_("Close")) |
107 |
|
|
108 |
self.__set_properties() |
self.__set_properties() |
109 |
self.__do_layout() |
self.__do_layout() |
110 |
|
|
111 |
# wxGlade |
# wxGlade |
112 |
|
|
113 |
|
# Fill the projection choice list. |
114 |
|
for proj, name, clazz in self.projPanels: |
115 |
|
self.projchoice.Append(name, [clazz, None]) |
116 |
|
|
117 |
self.originalProjection = self.receiver.GetProjection() |
self.originalProjection = self.receiver.GetProjection() |
118 |
|
|
119 |
self.__DoOnProjAvail() |
self.__DoOnProjAvail() |
136 |
|
|
137 |
EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName) |
EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName) |
138 |
|
|
|
|
|
139 |
def OnApply(self, event): |
def OnApply(self, event): |
140 |
self.__SetProjection() |
self.__SetProjection() |
141 |
self.haveTried = True |
self.haveTried = True |
155 |
self.receiver.SetProjection(self.originalProjection) |
self.receiver.SetProjection(self.originalProjection) |
156 |
self.haveTried = False |
self.haveTried = False |
157 |
|
|
|
|
|
158 |
def _OnNew(self, event): |
def _OnNew(self, event): |
159 |
|
|
160 |
# clear all selections |
# clear all selections |
185 |
if newproj is not None: |
if newproj is not None: |
186 |
projfile.Replace(proj, newproj) |
projfile.Replace(proj, newproj) |
187 |
try: |
try: |
188 |
WriteProjFile(projfile) |
write_proj_file(projfile) |
189 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
190 |
self.__ShowError(projfile.GetFilename(), errstr) |
self.__ShowError(projfile.GetFilename(), errstr) |
191 |
self.availprojs.SetClientData(sel[0], [newproj, projfile]) |
self.availprojs.SetClientData(sel[0], [newproj, projfile]) |
192 |
|
|
193 |
|
self.__FillAvailList( selectProj = newproj.GetName()) |
194 |
|
|
195 |
def _OnAddToList(self, event): |
def _OnAddToList(self, event): |
196 |
|
|
197 |
proj = self.__GetProjection() |
proj = self.__GetProjection() |
198 |
if proj is not None: |
if proj is not None: |
199 |
self.__usrProjFile.Add(proj) |
self.__usrProjFile.Add(proj) |
200 |
try: |
try: |
201 |
WriteProjFile(self.__usrProjFile) |
write_proj_file(self.__usrProjFile) |
202 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
203 |
self.__ShowError(self.__userProjFile.GetFilename(), errstr) |
self.__ShowError(self.__userProjFile.GetFilename(), errstr) |
204 |
|
|
205 |
self.__FillAvailList() |
self.__FillAvailList( selectProj = proj.GetName()) |
206 |
|
|
207 |
def _OnProjAvail(self, event): |
def _OnProjAvail(self, event): |
208 |
self.__DoOnProjAvail() |
self.__DoOnProjAvail() |
209 |
|
|
210 |
|
def show_warnings(self, title, filename, warnings): |
211 |
|
"""Show the warnings (a list of strings) in a dialog |
212 |
|
|
213 |
|
If the list is empty no dialog will be shown. |
214 |
|
""" |
215 |
|
if warnings: |
216 |
|
text = (_('Warnings when reading "%s":\n\n%s') |
217 |
|
% (filename, "\n\n".join(warnings))) |
218 |
|
self.parent.RunMessageBox(title, text) |
219 |
|
|
220 |
def _OnImport(self, event): |
def _OnImport(self, event): |
221 |
|
|
222 |
dlg = wxFileDialog(self, _("Import"), style = wxOPEN) |
dlg = wxFileDialog(self, _("Import"), style = wxOPEN) |
225 |
path = dlg.GetPath() |
path = dlg.GetPath() |
226 |
|
|
227 |
try: |
try: |
228 |
projFile = ReadProjFile(path) |
projFile, warnings = read_proj_file(path) |
229 |
|
self.show_warnings(_("Warnings"), path, warnings) |
230 |
for proj in projFile.GetProjections(): |
for proj in projFile.GetProjections(): |
231 |
self.__usrProjFile.Add(proj) |
self.__usrProjFile.Add(proj) |
232 |
WriteProjFile(self.__usrProjFile) |
write_proj_file(self.__usrProjFile) |
233 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
234 |
self.__ShowError(dlg.GetPath(), errstr) |
self.__ShowError(dlg.GetPath(), errstr) |
235 |
|
|
256 |
projFile.Add(proj) |
projFile.Add(proj) |
257 |
|
|
258 |
try: |
try: |
259 |
WriteProjFile(projFile) |
write_proj_file(projFile) |
260 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
261 |
self.__ShowError(dlg.GetPath(), errstr) |
self.__ShowError(dlg.GetPath(), errstr) |
262 |
|
|
291 |
projfile.Remove(proj) |
projfile.Remove(proj) |
292 |
|
|
293 |
try: |
try: |
294 |
WriteProjFile(projfile) |
write_proj_file(projfile) |
295 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
296 |
self.__ShowError(projfile.GetFilename(), errstr) |
self.__ShowError(projfile.GetFilename(), errstr) |
297 |
|
|
389 |
if proj is None: |
if proj is None: |
390 |
# user selected <None> |
# user selected <None> |
391 |
self.projname.Clear() |
self.projname.Clear() |
392 |
|
self.projfilepath.SetLabel(_("Projection File: ")) |
393 |
else: |
else: |
394 |
|
|
395 |
if projfile is not None: |
if projfile is not None: |
396 |
self.projfilepath.SetLabel(projfile.GetFilename()) |
self.projfilepath.SetLabel(_("Projection File: ") + |
397 |
|
os.path.basename(projfile.GetFilename())) |
398 |
else: |
else: |
399 |
# only None if the currently used projection is selected |
# only None if the currently used projection is selected |
400 |
self.projfilepath.SetLabel("") |
self.projfilepath.SetLabel(_("Projection File: ")) |
401 |
|
|
402 |
self.projname.SetValue(proj.GetName()) |
self.projname.SetValue(proj.GetName()) |
403 |
|
|
405 |
i = 0 |
i = 0 |
406 |
for projType, name, clazz in self.projPanels: |
for projType, name, clazz in self.projPanels: |
407 |
if myProjType == projType: |
if myProjType == projType: |
408 |
|
self.projchoice.Enable(True) |
409 |
self.projchoice.SetSelection(i) |
self.projchoice.SetSelection(i) |
410 |
self.__DoOnProjChoice() |
self.__DoOnProjChoice() |
411 |
|
|
416 |
assert self.curProjPanel is not None |
assert self.curProjPanel is not None |
417 |
|
|
418 |
self.curProjPanel.SetProjection(proj) |
self.curProjPanel.SetProjection(proj) |
419 |
|
break |
420 |
i += 1 |
i += 1 |
421 |
|
else: |
422 |
|
self.projchoice.Disable() |
423 |
|
self._show_proj_panel(UnknownProjPanel(self.panel_edit, |
424 |
|
self.receiver)) |
425 |
|
|
426 |
self.__VerifyButtons() |
self.__VerifyButtons() |
427 |
|
|
443 |
|
|
444 |
sel = choice.GetSelection() |
sel = choice.GetSelection() |
445 |
if sel != -1: |
if sel != -1: |
|
|
|
446 |
clazz, obj = choice.GetClientData(sel) |
clazz, obj = choice.GetClientData(sel) |
|
|
|
447 |
if obj is None: |
if obj is None: |
448 |
obj = clazz(self.panel_edit, self.receiver) |
obj = clazz(self.panel_edit, self.receiver) |
449 |
choice.SetClientData(sel, [clazz, obj]) |
choice.SetClientData(sel, [clazz, obj]) |
450 |
|
self._show_proj_panel(obj) |
451 |
|
|
452 |
if self.curProjPanel is not None: |
def _show_proj_panel(self, panel): |
453 |
self.curProjPanel.Hide() |
"""Show the panel as the projection panel""" |
454 |
self.sizer_projctrls.Remove(self.curProjPanel) |
if self.curProjPanel is not None: |
455 |
|
self.curProjPanel.Hide() |
456 |
self.curProjPanel = obj |
self.sizer_projctrls.Remove(self.curProjPanel) |
457 |
self.curProjPanel.Show() |
|
458 |
|
self.curProjPanel = panel |
459 |
self.sizer_projctrls.Add(self.curProjPanel, 1, |
self.curProjPanel.Show() |
460 |
wxALL|wxEXPAND|wxADJUST_MINSIZE, 3) |
|
461 |
self.sizer_projctrls.Layout() |
self.sizer_projctrls.Add(self.curProjPanel, 1, |
462 |
self.Layout() |
wxALL|wxEXPAND|wxADJUST_MINSIZE, 3) |
463 |
self.topBox.SetSizeHints(self) |
self.sizer_projctrls.Layout() |
464 |
|
self.Layout() |
465 |
|
self.topBox.SetSizeHints(self) |
466 |
|
|
467 |
def __SetProjection(self): |
def __SetProjection(self): |
468 |
"""Set the receiver's projection.""" |
"""Set the receiver's projection.""" |
500 |
|
|
501 |
return None |
return None |
502 |
|
|
503 |
def __FillAvailList(self, selectCurrent = False): |
def __FillAvailList(self, selectCurrent = False, selectProj = None): |
504 |
"""Populate the list of available projections. |
"""Populate the list of available projections. |
505 |
|
|
506 |
selectCurrent -- if True, select the projection used by |
selectCurrent -- if True, select the projection used by |
507 |
the receiver, otherwise select nothing. |
the receiver, otherwise select nothing. |
508 |
|
selectProj -- if set, select the projection found under the |
509 |
|
specified name. This overwrites any other |
510 |
|
selection estimate. |
511 |
""" |
""" |
512 |
|
|
513 |
self.availprojs.Clear() |
self.availprojs.Clear() |
514 |
|
|
515 |
# |
# |
|
# We add the current projection to the list first so that |
|
|
# we are sure that it's at index 0. That way we can |
|
|
# set the selection with confidence. The problem is the |
|
|
# the list is automatically sorted when an item is appended |
|
|
# and the index of where it was inserted is not returned. |
|
|
# |
|
|
proj = self.receiver.GetProjection() |
|
|
if proj is not None: |
|
|
self.availprojs.Append(_("%s (current)") % proj.GetName(), |
|
|
[proj, None]) |
|
|
if selectCurrent: |
|
|
self.availprojs.SetSelection(0) |
|
|
self.availprojs.SetFirstItem(0) |
|
|
|
|
|
# |
|
516 |
# the list can never be empty. there will always be |
# the list can never be empty. there will always be |
517 |
# at least this one item |
# at least this one item |
518 |
# |
# |
519 |
self.availprojs.Append("<None>", (None, None)) |
self.availprojs.Append("<None>", (None, None)) |
520 |
|
|
521 |
# proj is only None when <None> should be selected |
projfile, warnings = get_system_proj_file() |
522 |
if proj is None and selectCurrent: |
self.show_warnings(_("Warnings"), projfile.GetFilename(), warnings) |
|
self.availprojs.SetSelection(0) |
|
|
self.availprojs.SetFirstItem(0) |
|
|
|
|
|
projfile = GetSystemProjFiles() |
|
|
projfile = projfile[0] |
|
523 |
for proj in projfile.GetProjections(): |
for proj in projfile.GetProjections(): |
524 |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
525 |
self.__sysProjFile = projfile |
self.__sysProjFile = projfile |
526 |
|
|
527 |
projfile = GetUserProjFiles() |
projfile, warnings = get_user_proj_file() |
528 |
projfile = projfile[0] |
self.show_warnings(_("Warnings"), projfile.GetFilename(), warnings) |
529 |
for proj in projfile.GetProjections(): |
for proj in projfile.GetProjections(): |
530 |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
531 |
self.__usrProjFile = projfile |
self.__usrProjFile = projfile |
532 |
|
|
533 |
for proj, name, clazz in self.projPanels: |
# |
534 |
self.projchoice.Append(name, [clazz, None]) |
# We add the current projection to the list at last. |
535 |
|
# Since the list is resorted immediately a following FindString() |
536 |
|
# determines the index correctly. |
537 |
|
# |
538 |
|
proj = self.receiver.GetProjection() |
539 |
|
if proj is not None: |
540 |
|
proj_item = _("%s (current)") % proj.GetName() |
541 |
|
self.availprojs.Append(proj_item, [proj, None]) |
542 |
|
if selectCurrent: |
543 |
|
self.availprojs.SetSelection( |
544 |
|
self.availprojs.FindString(proj_item) |
545 |
|
) |
546 |
|
else: |
547 |
|
if selectCurrent: |
548 |
|
self.availprojs.SetSelection( |
549 |
|
self.availprojs.FindString("<None>") |
550 |
|
) |
551 |
|
if selectProj: |
552 |
|
self.availprojs.SetSelection( |
553 |
|
self.availprojs.FindString(selectProj) |
554 |
|
) |
555 |
|
|
556 |
|
|
557 |
|
|
558 |
def __set_properties(self): |
def __set_properties(self): |
559 |
|
|
570 |
self.topBox = wxBoxSizer(wxVERTICAL) |
self.topBox = wxBoxSizer(wxVERTICAL) |
571 |
self.sizer_panel = wxBoxSizer(wxVERTICAL) |
self.sizer_panel = wxBoxSizer(wxVERTICAL) |
572 |
sizer_6 = wxBoxSizer(wxHORIZONTAL) |
sizer_6 = wxBoxSizer(wxHORIZONTAL) |
573 |
|
self.sizer_mainbttns = wxBoxSizer(wxHORIZONTAL) |
574 |
self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL) |
self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL) |
575 |
self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_edit, -1, _("Edit")), wxHORIZONTAL) |
self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_edit, -1, _("Edit")), wxHORIZONTAL) |
576 |
sizer_11 = wxBoxSizer(wxVERTICAL) |
sizer_11 = wxBoxSizer(wxVERTICAL) |
589 |
grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0) |
grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0) |
590 |
grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
591 |
grid_sizer_1.Add(sizer_15, 0, wxALL|wxEXPAND, 4) |
grid_sizer_1.Add(sizer_15, 0, wxALL|wxEXPAND, 4) |
592 |
grid_sizer_1.Add(self.projfilepath, 0, wxALL|wxADJUST_MINSIZE, 4) |
grid_sizer_1.Add(self.projfilepath, 0, wxEXPAND|wxALL|wxADJUST_MINSIZE, 4) |
593 |
grid_sizer_1.AddGrowableRow(1) |
grid_sizer_1.AddGrowableRow(1) |
594 |
grid_sizer_1.AddGrowableCol(0) |
grid_sizer_1.AddGrowableCol(0) |
595 |
|
|
597 |
sizer_13.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
sizer_13.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
598 |
sizer_13.Add(self.projname, 1, wxALL, 4) |
sizer_13.Add(self.projname, 1, wxALL, 4) |
599 |
self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0) |
self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0) |
600 |
sizer_14.Add(self.label_3, 0, wxALL, 4) |
sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
601 |
sizer_14.Add(self.projchoice, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
sizer_14.Add(self.projchoice, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
602 |
self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0) |
self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0) |
603 |
self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0) |
self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0) |
604 |
sizer_11.Add(self.button_new, 0, wxALL|wxEXPAND, 4) |
sizer_11.Add(self.button_new, 0, wxEXPAND|wxALL, 4) |
605 |
sizer_11.Add(self.button_save, 0, wxALL|wxEXPAND, 4) |
sizer_11.Add(self.button_add, 0, wxEXPAND|wxALL, 4) |
606 |
sizer_11.Add(self.button_add, 0, wxALL|wxEXPAND, 4) |
sizer_11.Add(20, 20, 0, wxEXPAND, 0) |
607 |
|
sizer_11.Add(self.button_save, 0, wxEXPAND|wxALL|wxALIGN_BOTTOM, 4) |
608 |
self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4) |
self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4) |
609 |
|
|
610 |
sizer_6.Add(20, 20, 1, wxEXPAND, 0) |
sizer_6.Add(self.button_try, 0, wxRIGHT| wxEXPAND, 10) |
611 |
sizer_6.Add(self.button_try, 0, wxALL, 4) |
sizer_6.Add(self.button_revert, 0, wxRIGHT| wxEXPAND, 10) |
612 |
sizer_6.Add(20, 20, 1, 0, 0) |
sizer_6.Add(self.button_ok, 0, wxRIGHT| wxEXPAND, 10) |
613 |
sizer_6.Add(self.button_revert, 0, wxALL, 4) |
sizer_6.Add(self.button_close, 0, wxRIGHT| wxEXPAND, 10) |
|
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) |
|
614 |
|
|
615 |
self.panel_1.SetAutoLayout(1) |
self.panel_1.SetAutoLayout(1) |
616 |
self.panel_1.SetSizer(grid_sizer_1) |
self.panel_1.SetSizer(grid_sizer_1) |
622 |
self.sizer_edit.Fit(self.panel_edit) |
self.sizer_edit.Fit(self.panel_edit) |
623 |
self.sizer_edit.SetSizeHints(self.panel_edit) |
self.sizer_edit.SetSizeHints(self.panel_edit) |
624 |
|
|
|
self.panel_buttons.SetAutoLayout(1) |
|
|
self.panel_buttons.SetSizer(sizer_6) |
|
|
sizer_6.Fit(self.panel_buttons) |
|
|
sizer_6.SetSizeHints(self.panel_buttons) |
|
|
|
|
625 |
self.sizer_mainctrls.Add(self.panel_1, 0, |
self.sizer_mainctrls.Add(self.panel_1, 0, |
626 |
wxALL|wxEXPAND|wxADJUST_MINSIZE, 0) |
wxALL|wxEXPAND|wxADJUST_MINSIZE, 0) |
627 |
self.sizer_mainctrls.Add(self.panel_edit, 1, |
self.sizer_mainctrls.Add(self.panel_edit, 1, |
628 |
wxALL|wxEXPAND|wxADJUST_MINSIZE, 0) |
wxALL|wxEXPAND|wxADJUST_MINSIZE, 0) |
629 |
|
|
630 |
|
self.sizer_mainbttns.Add(sizer_6, 0, |
631 |
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 10) |
632 |
|
|
633 |
self.topBox.Add(self.sizer_mainctrls, 1, wxALL|wxEXPAND, 4) |
self.topBox.Add(self.sizer_mainctrls, 1, wxALL|wxEXPAND, 4) |
634 |
self.topBox.Add(self.panel_buttons, 0, wxEXPAND, 0) |
self.topBox.Add(self.sizer_mainbttns, 0, wxALIGN_RIGHT|wxBOTTOM, 0) |
635 |
|
|
636 |
self.SetAutoLayout(1) |
self.SetAutoLayout(1) |
637 |
self.SetSizer(self.topBox) |
self.SetSizer(self.topBox) |
666 |
|
|
667 |
panelSizer = wxBoxSizer(wxVERTICAL) |
panelSizer = wxBoxSizer(wxVERTICAL) |
668 |
|
|
|
if childPanel is not None: |
|
|
panelSizer.Add(childPanel, 0, wxEXPAND, 0) |
|
|
|
|
669 |
sizer = wxBoxSizer(wxHORIZONTAL) |
sizer = wxBoxSizer(wxHORIZONTAL) |
670 |
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4) |
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, |
671 |
sizer.Add(self.__ellps, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
wxALL|wxALIGN_CENTER_VERTICAL, 4) |
672 |
|
sizer.Add(self.__ellps, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
673 |
panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4) |
panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4) |
674 |
|
|
675 |
|
if childPanel is not None: |
676 |
|
panelSizer.Add(childPanel, 0, wxEXPAND, 0) |
677 |
|
|
678 |
self.SetAutoLayout(1) |
self.SetAutoLayout(1) |
679 |
self.SetSizer(panelSizer) |
self.SetSizer(panelSizer) |
680 |
panelSizer.Fit(self) |
panelSizer.Fit(self) |
708 |
ID_TMPANEL_SCALE = 4005 |
ID_TMPANEL_SCALE = 4005 |
709 |
|
|
710 |
class UnknownProjPanel(ProjPanel): |
class UnknownProjPanel(ProjPanel): |
711 |
|
|
712 |
|
"""Panel for unknown projection types""" |
713 |
|
|
714 |
def __init__(self, parent, receiver): |
def __init__(self, parent, receiver): |
715 |
ProjPanel.__init__(self, parent) |
ProjPanel.__init__(self, parent) |
716 |
|
|
719 |
def _DoLayout(self): |
def _DoLayout(self): |
720 |
sizer = wxBoxSizer(wxVERTICAL) |
sizer = wxBoxSizer(wxVERTICAL) |
721 |
|
|
722 |
sizer.Add(wxStaticText(self, -1, |
sizer.Add(wxStaticText(self, -1, |
723 |
_("Thuban does not know the parameters for the " + |
_("Thuban does not know the parameters for the" |
724 |
"current projection and cannot display a " + |
" current projection\n" |
725 |
"configuration panel."))) |
"and cannot display a configuration panel."))) |
726 |
|
|
727 |
ProjPanel._DoLayout(self, sizer) |
ProjPanel._DoLayout(self, sizer) |
728 |
|
|
743 |
|
|
744 |
self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT) |
self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT) |
745 |
self.__longitude = wxTextCtrl(self, ID_TMPANEL_LONG) |
self.__longitude = wxTextCtrl(self, ID_TMPANEL_LONG) |
746 |
|
self.__scale = wxTextCtrl(self, ID_TMPANEL_SCALE) |
747 |
self.__falseEast = wxTextCtrl(self, ID_TMPANEL_FASLE_EAST) |
self.__falseEast = wxTextCtrl(self, ID_TMPANEL_FASLE_EAST) |
748 |
self.__falseNorth = wxTextCtrl(self, ID_TMPANEL_FALSE_NORTH) |
self.__falseNorth = wxTextCtrl(self, ID_TMPANEL_FALSE_NORTH) |
|
self.__scale = wxTextCtrl(self, ID_TMPANEL_SCALE) |
|
749 |
|
|
750 |
self._DoLayout() |
self._DoLayout() |
751 |
|
|
853 |
ProjPanel.Clear(self) |
ProjPanel.Clear(self) |
854 |
|
|
855 |
def _OnPropose(self, event): |
def _OnPropose(self, event): |
856 |
UTMProposeZoneDialog |
"""Call the propose dialog. |
857 |
|
If the receiver (e.g. the current map) has no bounding box, |
858 |
|
inform the user accordingly. |
859 |
|
""" |
860 |
|
bb = self.receiver.BoundingBox() |
861 |
|
if bb is None: |
862 |
|
dlg = wxMessageDialog(self, |
863 |
|
_("Can not propose: No bounding box found."), |
864 |
|
_("Projection: Propose UTM Zone"), |
865 |
|
wxOK | wxICON_INFORMATION) |
866 |
|
dlg.CenterOnParent() |
867 |
|
result = dlg.ShowModal() |
868 |
|
dlg.Destroy() |
869 |
|
return |
870 |
|
|
871 |
dlg = UTMProposeZoneDialog(self, self.receiver.BoundingBox()) |
dlg = UTMProposeZoneDialog(self, self.receiver.BoundingBox()) |
872 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
873 |
self.__zone.SetValue(dlg.GetProposedZone()) |
self.__zone.SetValue(dlg.GetProposedZone()) |
896 |
sizer.Add(wxStaticText(self, -1, |
sizer.Add(wxStaticText(self, -1, |
897 |
_("Latitude of second standard parallel:"))) |
_("Latitude of second standard parallel:"))) |
898 |
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) |
|
899 |
sizer.Add(wxStaticText(self, -1, _("Central Meridian:"))) |
sizer.Add(wxStaticText(self, -1, _("Central Meridian:"))) |
900 |
sizer.Add(self.__meridian, 0, wxALL, 4) |
sizer.Add(self.__meridian, 0, wxALL, 4) |
901 |
|
sizer.Add(wxStaticText(self, -1, _("Latitude of origin:"))) |
902 |
|
sizer.Add(self.__originLat, 0, wxALL, 4) |
903 |
sizer.Add(wxStaticText(self, -1, _("False Easting:"))) |
sizer.Add(wxStaticText(self, -1, _("False Easting:"))) |
904 |
sizer.Add(self.__falseEast, 0, wxALL, 4) |
sizer.Add(self.__falseEast, 0, wxALL, 4) |
905 |
sizer.Add(wxStaticText(self, -1, _("False Northing:"))) |
sizer.Add(wxStaticText(self, -1, _("False Northing:"))) |
983 |
sizer = wxBoxSizer(wxHORIZONTAL) |
sizer = wxBoxSizer(wxHORIZONTAL) |
984 |
|
|
985 |
sizer.Add(wxStaticText(self, -1, _("Source Data is in: ")), |
sizer.Add(wxStaticText(self, -1, _("Source Data is in: ")), |
986 |
0, wxALL, 4) |
0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
987 |
sizer.Add(self.__scale, 1, wxEXPAND|wxALL, 4) |
sizer.Add(self.__scale, 1, wxEXPAND|wxALL, 4) |
988 |
|
|
989 |
self.__scale.SetSelection(0) |
self.__scale.SetSelection(0) |
994 |
ID_UTM_PROPOSE_ZONE_DIALOG_TAKE = 4001 |
ID_UTM_PROPOSE_ZONE_DIALOG_TAKE = 4001 |
995 |
ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002 |
ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002 |
996 |
class UTMProposeZoneDialog(wxDialog): |
class UTMProposeZoneDialog(wxDialog): |
997 |
|
|
998 |
"""Propose a sensible Zone considering the current map extent.""" |
"""Propose a sensible Zone considering the current map extent.""" |
999 |
|
|
1000 |
def __init__(self, parent, (x, y, x2, y2)): |
def __init__(self, parent, (x, y, x2, y2)): |
1001 |
wxDialog.__init__(self, parent, -1, _("Projection: Propose UTM Zone"), |
wxDialog.__init__(self, parent, -1, _("Projection: Propose UTM Zone"), |
1002 |
wxDefaultPosition, wxSize(200, 100)) |
wxDefaultPosition, wxSize(200, 100)) |
1003 |
self.parent = parent |
self.parent = parent |
|
#x, y, x2, y2 = elf.parent.parent.map_bounding_box |
|
1004 |
x = x + 180 |
x = x + 180 |
1005 |
x2 = x2 + 180 |
x2 = x2 + 180 |
1006 |
center = (x2 - x) / 2 + x |
center = (x2 - x) / 2 + x |
1007 |
self.proposedZone = int(center / 6 + 1) |
self.proposedZone = int(center / 6 + 1) |
1008 |
self.dialogLayout() |
self.dialogLayout() |
1009 |
|
|
1010 |
def dialogLayout(self): |
def dialogLayout(self): |
1011 |
topBox = wxBoxSizer(wxVERTICAL) |
topBox = wxBoxSizer(wxVERTICAL) |
1012 |
|
|
1013 |
textBox = wxBoxSizer(wxVERTICAL) |
textBox = wxBoxSizer(wxVERTICAL) |
1014 |
textBox.Add(wxStaticText(self, -1, _("The current map extent center " + |
textBox.Add(wxStaticText(self, -1, _("The current map extent center " |
1015 |
"lies in UTM Zone")), |
"lies in UTM Zone")), |
1016 |
0, wxALIGN_CENTER|wxALL, 4) |
0, wxALIGN_CENTER|wxALL, 4) |
1017 |
textBox.Add(wxStaticText(self, -1, str(self.proposedZone)), |
textBox.Add(wxStaticText(self, -1, str(self.proposedZone)), |
1018 |
0, wxALIGN_CENTER|wxALL, 4) |
0, wxALIGN_CENTER|wxALL, 4) |
1019 |
|
|
1020 |
topBox.Add(textBox, 1, wxEXPAND|wxALL, 4) |
topBox.Add(textBox, 1, wxEXPAND|wxALL, 4) |
1021 |
|
|
1022 |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
buttonBox = wxBoxSizer(wxHORIZONTAL) |
1023 |
buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, |
buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, |
1024 |
_("Take")), 0, wxALL, 4) |
_("Take")), 0, wxALL, 4) |
1027 |
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10) |
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10) |
1028 |
EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, self.OnTake) |
EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, self.OnTake) |
1029 |
EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL, self.OnCancel) |
EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL, self.OnCancel) |
1030 |
|
|
1031 |
self.SetAutoLayout(True) |
self.SetAutoLayout(True) |
1032 |
self.SetSizer(topBox) |
self.SetSizer(topBox) |
1033 |
topBox.Fit(self) |
topBox.Fit(self) |
1034 |
topBox.SetSizeHints(self) |
topBox.SetSizeHints(self) |
1035 |
|
|
1036 |
def OnTake(self, event): |
def OnTake(self, event): |
1037 |
self.EndModal(wxID_OK) |
self.EndModal(wxID_OK) |
1038 |
|
|
1039 |
def OnCancel(self, event): |
def OnCancel(self, event): |
1040 |
self.EndModal(wxID_CANCEL) |
self.EndModal(wxID_CANCEL) |
1041 |
|
|