/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/projdialog.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/projdialog.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 741 by jonathan, Fri Apr 25 09:14:27 2003 UTC revision 1135 by frank, Thu Jun 5 15:05:21 2003 UTC
# Line 1  Line 1 
1  #!/usr/bin/env python  # Copyright (c) 2003 by Intevation GmbH
2  # generated by wxGlade 0.2.1 on Thu Apr 17 11:51:39 2003  # Authors:
3    # Jonathan Coles <[email protected]>
4  import os, sys  # Frank Koormann <[email protected]>
5    #
6    # This program is free software under the GPL (>=v2)
7    # Read the file COPYING coming with Thuban for details.
8                                                                                    
9    import os, sys, math
10  from wxPython.wx import *  from wxPython.wx import *
11    
12  from Thuban import _  from Thuban import _
# Line 10  from Thuban.Model.proj import Projection Line 15  from Thuban.Model.proj import Projection
15    
16  from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles, \  from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles, \
17                                    ReadProjFile, WriteProjFile                                    ReadProjFile, WriteProjFile
18  from Thuban.UI.dialogs import NonModalDialog  from Thuban.UI.dialogs import NonModalNonParentDialog
19    
20    
21  ID_PROJ_ADVANCED  = 4001  ID_PROJ_ADVANCED  = 4001
22  ID_PROJ_PROJCHOICE = 4002  ID_PROJ_PROJCHOICE = 4002
23  ID_PROJ_ADDTOLIST    = 4003  ID_PROJ_ADDTOLIST    = 4003
24  ID_PROJ_NEW       = 4004  ID_PROJ_NEW       = 4004
 ID_PROJ_TRY       = 4005  
25  ID_PROJ_REVERT    = 4006  ID_PROJ_REVERT    = 4006
 ID_PROJ_OK        = 4007  
 ID_PROJ_CLOSE     = 4008  
26  ID_PROJ_AVAIL     = 4009  ID_PROJ_AVAIL     = 4009
27  ID_PROJ_SAVE      = 4010  ID_PROJ_SAVE      = 4010
28  ID_PROJ_IMPORT    = 4011  ID_PROJ_IMPORT    = 4011
# Line 31  ID_PROJ_PROJNAME  = 4014 Line 33  ID_PROJ_PROJNAME  = 4014
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, receiver, *args, **kwds):      def __init__(self, parent, name, title, receiver):
39          """Initialize the projection dialog.          """Initialize the projection dialog.
40    
41          receiver -- An object that implements the following methods:          receiver -- An object that implements the following methods:
# Line 42  class ProjFrame(NonModalDialog): Line 44  class ProjFrame(NonModalDialog):
44          """          """
45                    
46          self.receiver = receiver          self.receiver = receiver
47          self.originalProjection = -1          self.haveTried = False
48          self.curProjPanel = None          self.curProjPanel = None
49    
50          self.projPanels = []          self.projPanels = []
# Line 55  class ProjFrame(NonModalDialog): Line 57  class ProjFrame(NonModalDialog):
57          self.projPanels.append(          self.projPanels.append(
58              ("latlong", _("Geographic"), GeoPanel))              ("latlong", _("Geographic"), GeoPanel))
59    
60          NonModalDialog.__init__(self, parent, name, "")          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)
64          self.panel_buttons = wxPanel(self, -1)          self.label_5 = wxStaticText(self.panel_1, -1,
65          self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:"))                          _("Available Projections:"))
66          self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_EXTENDED |wxLB_SORT)  
67            # Projection List specific actions (Import/Export/Remove)
68            self.button_import = wxButton(self.panel_1, ID_PROJ_IMPORT,
69                                          _("Import..."))
70            self.button_export = wxButton(self.panel_1, ID_PROJ_EXPORT,
71                                          _("Export..."))
72            self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE,
73                                          _("Remove"))
74    
75            # The Projection List
76            self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL,
77                                        style=wxLB_EXTENDED|wxLB_SORT)
78          self.projfilepath = wxStaticText(self.panel_1, -1, "")          self.projfilepath = wxStaticText(self.panel_1, -1, "")
79    
80            # Projection Specific Entries (Name/Projection)
81          self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:"))          self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:"))
82          self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "")          self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "")
83          self.label_3 = wxStaticText(self.panel_edit, -1, _("Projection:"))          self.label_3 = wxStaticText(self.panel_edit, -1, _("Projection:"))
84          self.projchoice = wxChoice(self.panel_edit, ID_PROJ_PROJCHOICE)          self.projchoice = wxChoice(self.panel_edit, ID_PROJ_PROJCHOICE)
85          self.button_import = wxButton(self.panel_1, ID_PROJ_IMPORT, _("Import..."))  
86          self.button_export = wxButton(self.panel_1, ID_PROJ_EXPORT, _("Export..."))          # Projection Specific actions (New/Save/Add)
         self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove"))  
87          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"))  
88          self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST,          self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST,
89                                        _("Add to List"))                                        _("Add to List"))
90          self.button_try = wxButton(self.panel_buttons, ID_PROJ_TRY, _("Try"))          self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Update"))
91          self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, _("Revert"))  
92          self.button_ok = wxButton(self.panel_buttons, ID_PROJ_OK, _("OK"))          # Main Action buttons (Try/Revert/OK/Close)
93          self.button_close = wxButton(self.panel_buttons, ID_PROJ_CLOSE, _("Close"))          self.button_try = wxButton(self, wxID_APPLY, _("Try"))
94            self.button_revert = wxButton(self, ID_PROJ_REVERT,
95                                          _("Revert"))
96            self.button_ok = wxButton(self, wxID_OK, _("OK"))
97            self.button_ok.SetDefault()
98            self.button_close = wxButton(self, wxID_CANCEL,
99                                         _("Close"))
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()
111    
112          self.__DoOnProjAvail()          self.__DoOnProjAvail()
113            self.button_ok.SetFocus()
114            self.availprojs.SetFocus()
115                    
116          EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry)          EVT_BUTTON(self, wxID_APPLY, self.OnApply)
117          EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert)          EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert)
118          EVT_BUTTON(self, ID_PROJ_OK, self._OnOK)          EVT_BUTTON(self, wxID_OK, self.OnOK)
119          EVT_BUTTON(self, ID_PROJ_CLOSE, self._OnClose)          EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
120          EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice)          EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice)
121          EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail)          EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail)
122          EVT_BUTTON(self, ID_PROJ_IMPORT, self._OnImport)          EVT_BUTTON(self, ID_PROJ_IMPORT, self._OnImport)
# Line 101  class ProjFrame(NonModalDialog): Line 129  class ProjFrame(NonModalDialog):
129    
130          EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName)          EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName)
131    
     def GetReceiver(self):  
         return self.receiver  
132    
133      def _OnTry(self, event):      def OnApply(self, event):
134          self.__SetProjection()          self.__SetProjection()
135            self.haveTried = True
136    
137      def _OnRevert(self, event):      def OnOK(self, event):
         if self.originalProjection != -1:  
             self.receiver.SetProjection(self.originalProjection)  
   
     def _OnOK(self, event):  
138          self.__SetProjection()          self.__SetProjection()
139          self.Close()          self.Close()
140    
141      def _OnClose(self, event):      def OnCancel(self, event):
142            """Cancel just closes the dialog, but we call it cancel so we
143            can overload the functionality of wxDialog.
144            """
145          self.Close()          self.Close()
146    
147        def _OnRevert(self, event):
148            if self.haveTried:
149                self.receiver.SetProjection(self.originalProjection)
150                self.haveTried = False
151    
152    
153      def _OnNew(self, event):      def _OnNew(self, event):
154          self.__DoOnNew()  
155            # clear all selections
156            sel = self.availprojs.GetSelections()
157            for index in sel:
158                self.availprojs.SetSelection(index, False)
159    
160            self.projname.Clear()
161    
162            # supply a projection panel if there wasn't one
163            if self.curProjPanel is None:
164                self.projchoice.SetSelection(0)
165                self.__DoOnProjChoice()
166    
167            self.curProjPanel.Clear()
168    
169      def _OnSave(self, event):      def _OnSave(self, event):
170    
# Line 133  class ProjFrame(NonModalDialog): Line 178  class ProjFrame(NonModalDialog):
178          newproj = self.__GetProjection()          newproj = self.__GetProjection()
179    
180          if newproj is not None:          if newproj is not None:
181              projfile.Remove(proj)              projfile.Replace(proj, newproj)
             projfile.Add(newproj)  
182              try:              try:
183                  WriteProjFile(projfile)                  WriteProjFile(projfile)
184              except IOError, (errno, errstr):              except IOError, (errno, errstr):
185                  wxMessageDialog(self,                  self.__ShowError(projfile.GetFilename(), errstr)
186                      _("The following error occured:\n") +              self.availprojs.SetClientData(sel[0], [newproj, projfile])
187                      projfile.GetFilename() + "\n" + errstr,  
188                      _("Error"), wxOK | wxICON_ERROR).ShowModal()              self.__FillAvailList( selectProj = newproj.GetName())
             self.__FillAvailList()  
189    
190      def _OnAddToList(self, event):      def _OnAddToList(self, event):
191    
# Line 152  class ProjFrame(NonModalDialog): Line 195  class ProjFrame(NonModalDialog):
195              try:              try:
196                  WriteProjFile(self.__usrProjFile)                  WriteProjFile(self.__usrProjFile)
197              except IOError, (errno, errstr):              except IOError, (errno, errstr):
198                  wxMessageDialog(self,                  self.__ShowError(self.__userProjFile.GetFilename(), errstr)
199                      _("The following error occured:\n") +  
200                      self.__usrProjFile.GetFilename() + "\n" + errstr,              self.__FillAvailList( selectProj = proj.GetName())
                     _("Error"), wxOK | wxICON_ERROR).ShowModal()  
             self.__FillAvailList()  
201    
202      def _OnProjAvail(self, event):      def _OnProjAvail(self, event):
203          self.__DoOnProjAvail()          self.__DoOnProjAvail()
# Line 174  class ProjFrame(NonModalDialog): Line 215  class ProjFrame(NonModalDialog):
215                      self.__usrProjFile.Add(proj)                      self.__usrProjFile.Add(proj)
216                  WriteProjFile(self.__usrProjFile)                  WriteProjFile(self.__usrProjFile)
217              except IOError, (errno, errstr):              except IOError, (errno, errstr):
218                  wxMessageDialog(self,                  self.__ShowError(dlg.GetPath(), errstr)
                     _("The following error occured:\n") +  
                     dlg.GetPath() + "\n" + errstr,  
                     _("Error"), wxOK | wxICON_ERROR).ShowModal()  
219    
220              self.__FillAvailList()              self.__FillAvailList()
221    
# Line 204  class ProjFrame(NonModalDialog): Line 242  class ProjFrame(NonModalDialog):
242              try:              try:
243                  WriteProjFile(projFile)                  WriteProjFile(projFile)
244              except IOError, (errno, errstr):              except IOError, (errno, errstr):
245                  wxMessageDialog(self,                  self.__ShowError(dlg.GetPath(), errstr)
                     _("The following error occured:\n") +  
                     dlg.GetPath() + "\n" + errstr,  
                     _("Error"), wxOK | wxICON_ERROR).ShowModal()  
246    
247          dlg.Destroy()          dlg.Destroy()
248    
# Line 242  class ProjFrame(NonModalDialog): Line 277  class ProjFrame(NonModalDialog):
277          try:          try:
278              WriteProjFile(projfile)              WriteProjFile(projfile)
279          except IOError, (errno, errstr):          except IOError, (errno, errstr):
280              wxMessageDialog(self,              self.__ShowError(projfile.GetFilename(), errstr)
                 _("The following error occured:\n") +  
                 projfile.GetFilename() + "\n" + errstr,  
                 _("Error"), wxOK | wxICON_ERROR).ShowModal()  
   
281    
282          self.__FillAvailList()          self.__FillAvailList()
283    
# Line 258  class ProjFrame(NonModalDialog): Line 289  class ProjFrame(NonModalDialog):
289          if newselection != -1 and self.availprojs.GetCount() > 0:          if newselection != -1 and self.availprojs.GetCount() > 0:
290              self.availprojs.SetSelection(newselection)              self.availprojs.SetSelection(newselection)
291    
292            self.__VerifyButtons()
293    
294      def _OnProjName(self, event):      def _OnProjName(self, event):
295          self.__VerifyButtons()          self.__VerifyButtons()
296    
297        def __ShowError(self, filename, errstr):
298            wxMessageDialog(self,
299                _("The following error occured:\n") +
300                filename + "\n" + errstr,
301                _("Error"), wxOK | wxICON_ERROR).ShowModal()
302    
303      def __VerifyButtons(self):      def __VerifyButtons(self):
304            """Enable or disable the appropriate buttons based on the
305            current state of the dialog.
306            """
307    
308          sel = self.availprojs.GetSelections()          sel = self.availprojs.GetSelections()
309    
310          self.button_import.Enable(True)          self.button_import.Enable(True)
# Line 271  class ProjFrame(NonModalDialog): Line 314  class ProjFrame(NonModalDialog):
314    
315          self.panel_edit.Enable(True)          self.panel_edit.Enable(True)
316    
317            for ctrl in [self.button_import,
318                         self.button_export,
319                         self.button_remove,
320                         self.button_save,
321                         self.button_add,
322                         self.projchoice,
323                         self.projname,
324                         self.panel_edit]:
325                ctrl.Enable(True)
326    
327            if self.curProjPanel is not None:
328                self.curProjPanel.Enable(True)
329    
330          if len(sel) == 0:          if len(sel) == 0:
331              self.button_import.Enable(True)              self.button_import.Enable(True)
332              self.button_export.Enable(False)              self.button_export.Enable(False)
333              self.button_remove.Enable(False)              self.button_remove.Enable(False)
334                self.button_save.Enable(False)
335    
336          elif len(sel) == 1:          elif len(sel) == 1:
337    
# Line 284  class ProjFrame(NonModalDialog): Line 341  class ProjFrame(NonModalDialog):
341              self.button_add.Enable(len(self.projname.GetValue()) > 0)              self.button_add.Enable(len(self.projname.GetValue()) > 0)
342    
343              if proj is None:              if proj is None:
344                  self.button_export.Enable(False)                  # <None> is selected
345                    for ctrl in [self.button_export,
346                                 self.button_remove,
347                                 self.button_save,
348                                 self.button_add,
349                                 self.projchoice,
350                                 self.projname]:
351                        ctrl.Enable(False)
352    
353                    if self.curProjPanel is not None:
354                        self.curProjPanel.Enable(False)
355    
356                elif proj is self.originalProjection:
357                  self.button_remove.Enable(False)                  self.button_remove.Enable(False)
358    
359              if projFile is None:              if projFile is None:
# Line 293  class ProjFrame(NonModalDialog): Line 362  class ProjFrame(NonModalDialog):
362          else:          else:
363              self.panel_edit.Enable(False)              self.panel_edit.Enable(False)
364    
     def __DoOnNew(self):  
         sel = self.availprojs.GetSelections()  
         if len(sel) != 0:  
             self.availprojs.SetSelection(sel, False)  
         self.projname.Clear()  
         self.curProjPanel.Clear()  
   
365      def __DoOnProjAvail(self):      def __DoOnProjAvail(self):
366    
367          sel = self.availprojs.GetSelections()          sel = self.availprojs.GetSelections()
# Line 311  class ProjFrame(NonModalDialog): Line 373  class ProjFrame(NonModalDialog):
373              if proj is None:              if proj is None:
374                  # user selected <None>                  # user selected <None>
375                  self.projname.Clear()                  self.projname.Clear()
376                    
377              else:              else:
378                            
379                  if projfile is not None:                  if projfile is not None:
# Line 327  class ProjFrame(NonModalDialog): Line 390  class ProjFrame(NonModalDialog):
390                      if myProjType == projType:                      if myProjType == projType:
391                          self.projchoice.SetSelection(i)                          self.projchoice.SetSelection(i)
392                          self.__DoOnProjChoice()                          self.__DoOnProjChoice()
393    
394                            #
395                            # self.curProjPanel should not be null
396                            # after a call to __DoOnProjChoice
397                            #
398                            assert self.curProjPanel is not None
399    
400                          self.curProjPanel.SetProjection(proj)                          self.curProjPanel.SetProjection(proj)
401                      i += 1                      i += 1
402    
# Line 336  class ProjFrame(NonModalDialog): Line 406  class ProjFrame(NonModalDialog):
406          self.__DoOnProjChoice()          self.__DoOnProjChoice()
407    
408      def __DoOnProjChoice(self):      def __DoOnProjChoice(self):
409            """Create and layout a projection panel based on the selected
410            projection type.
411    
412            This is necessary to have in seperate method since calls to
413            wxChoice.SetSelection() do not trigger an event.
414    
415            At the end of this method self.curProjPanel will not be None
416            if there was a item selected.
417            """
418    
419          choice = self.projchoice          choice = self.projchoice
420    
421          sel = choice.GetSelection()          sel = choice.GetSelection()
# Line 361  class ProjFrame(NonModalDialog): Line 441  class ProjFrame(NonModalDialog):
441              self.topBox.SetSizeHints(self)              self.topBox.SetSizeHints(self)
442    
443      def __SetProjection(self):      def __SetProjection(self):
444            """Set the receiver's projection."""
445    
446          #          #
447          # save the original projection only once in case          # save the original projection only once in case
448          # we try to apply several different projections          # we try to apply several different projections
449          #          #
         if self.originalProjection == -1:  
             self.originalProjection = self.receiver.GetProjection()  
   
450          self.receiver.SetProjection(self.__GetProjection())          self.receiver.SetProjection(self.__GetProjection())
451    
452      def __GetProjection(self):      def __GetProjection(self):
453          """Return the packaged projection.          """Return a suitable Projection object based on the current
454            state of the dialog box selections.
455    
456          Could be None.          Could be None.
457          """          """
458    
459          proj = None          sel = self.availprojs.GetSelections()
460            assert len(sel) < 2, "button should be disabled"
461    
462    
463            if len(sel) == 1:
464                proj = self.availprojs.GetClientData(sel[0])[CLIENT_PROJ]
465                if proj is None:
466                    # <None> is selected
467                    return None
468    
469            #
470            # self.curProjPanel should always contain the most
471            # relevant data for a projection
472            #
473          if self.curProjPanel is not None:          if self.curProjPanel is not None:
474              proj = Projection(self.curProjPanel.GetParameters())              return Projection(self.curProjPanel.GetParameters(),
475              proj.SetName(self.projname.GetValue())                                self.projname.GetValue())
476    
477            return None
478    
479          return proj      def __FillAvailList(self, selectCurrent = False, selectProj = None):
480            """Populate the list of available projections.
481            
482            selectCurrent -- if True, select the projection used by
483                             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    
     def __FillAvailList(self):  
489          self.availprojs.Clear()          self.availprojs.Clear()
490    
491          #          #
# Line 394  class ProjFrame(NonModalDialog): Line 494  class ProjFrame(NonModalDialog):
494          #          #
495          self.availprojs.Append("<None>", (None, None))          self.availprojs.Append("<None>", (None, None))
496    
         self.__sysProjFile = None  
         self.__usrProjFile = None  
   
497          projfile = GetSystemProjFiles()          projfile = GetSystemProjFiles()
498          if len(projfile) > 0:          projfile = projfile[0]
499              projfile = projfile[0]          for proj in projfile.GetProjections():
500              for proj in projfile.GetProjections():              self.availprojs.Append(proj.GetName(), [proj, projfile])
501                  self.availprojs.Append(proj.GetName(), [proj, projfile])          self.__sysProjFile = projfile
             self.__sysProjFile = projfile  
502    
503          projfile = GetUserProjFiles()          projfile = GetUserProjFiles()
504          if len(projfile) > 0:          projfile = projfile[0]
505              projfile = projfile[0]          for proj in projfile.GetProjections():
506              for proj in projfile.GetProjections():              self.availprojs.Append(proj.GetName(), [proj, projfile])
507                  self.availprojs.Append(proj.GetName(), [proj, projfile])          self.__usrProjFile = projfile
             self.__usrProjFile = projfile  
   
 #       projfiles = GetSystemProjFiles()  
 #       for projfile in projfiles:  
 #           for proj in projfile.GetProjections():  
 #               self.availprojs.Append(proj.GetName(), [proj, projfile])  
 #       self.__sysProjFiles = projfiles  
   
 #       projfiles = GetUserProjFiles()  
 #       for projfile in projfiles:  
 #           for proj in projfile.GetProjections():  
 #               self.availprojs.Append(proj.GetName(), [proj, projfile])  
 #       self.__usrProjFiles = projfiles  
508    
509            #
510            # We add the current projection to the list at last.
511            # Since the list is resorted immediately a following FindString()
512            # determines the index correctly.
513            #
514          proj = self.receiver.GetProjection()          proj = self.receiver.GetProjection()
515          if proj is not None:          if proj is not None:
516              self.availprojs.Append(_("%s (current)") % proj.GetName(),              proj_item = _("%s (current)") % proj.GetName()
517                                     [proj, None])              self.availprojs.Append(proj_item, [proj, None])
518                if selectCurrent:
519                    self.availprojs.SetSelection(
520                            self.availprojs.FindString(proj_item)
521                        )
522            else:
523                if selectCurrent:
524                    self.availprojs.SetSelection(
525                            self.availprojs.FindString("<None>")
526                        )
527            if selectProj:
528                self.availprojs.SetSelection(
529                            self.availprojs.FindString(selectProj)
530                        )
531    
532          for proj, name, clazz in self.projPanels:                  
             self.projchoice.Append(name, [clazz, None])  
533    
534      def __set_properties(self):      def __set_properties(self):
         self.__FillAvailList()  
535    
536          # begin wxGlade: ProjFrame.__set_properties          #self.availprojs.SetSelection(0)
         self.SetTitle(_("Projections"))  
         self.availprojs.SetSelection(0)  
537          self.projchoice.SetSelection(0)          self.projchoice.SetSelection(0)
538          # end wxGlade  
539            self.__FillAvailList(selectCurrent = True)
540    
541          self.projname.SetMaxLength(32)          self.projname.SetMaxLength(32)
542    
# Line 448  class ProjFrame(NonModalDialog): Line 546  class ProjFrame(NonModalDialog):
546          self.topBox = wxBoxSizer(wxVERTICAL)          self.topBox = wxBoxSizer(wxVERTICAL)
547          self.sizer_panel = wxBoxSizer(wxVERTICAL)          self.sizer_panel = wxBoxSizer(wxVERTICAL)
548          sizer_6 = wxBoxSizer(wxHORIZONTAL)          sizer_6 = wxBoxSizer(wxHORIZONTAL)
549            self.sizer_mainbttns = wxBoxSizer(wxHORIZONTAL)
550          self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL)          self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL)
551          self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_edit, -1, _("Edit")), wxHORIZONTAL)          self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_edit, -1, _("Edit")), wxHORIZONTAL)
552          sizer_11 = wxBoxSizer(wxVERTICAL)          sizer_11 = wxBoxSizer(wxVERTICAL)
# Line 475  class ProjFrame(NonModalDialog): Line 574  class ProjFrame(NonModalDialog):
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|wxEXPAND, 4)          sizer_11.Add(self.button_new, 0, wxALL, 4)
581          sizer_11.Add(self.button_save, 0, wxALL|wxEXPAND, 4)          sizer_11.Add(self.button_add, 0, wxALL, 4)
582          sizer_11.Add(self.button_add, 0, wxALL|wxEXPAND, 4)          sizer_11.Add(20, 20, 0, wxEXPAND, 0)
583            sizer_11.Add(self.button_save, 0, 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(20, 20, 1, wxEXPAND, 0)          sizer_6.Add(self.button_try, 0, wxRIGHT| wxEXPAND, 10)
587          sizer_6.Add(self.button_try, 0, wxALL, 4)          sizer_6.Add(self.button_revert, 0, wxRIGHT| wxEXPAND, 10)
588          sizer_6.Add(20, 20, 1, 0, 0)          sizer_6.Add(self.button_ok, 0, wxRIGHT| wxEXPAND, 10)
589          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)  
590    
591          self.panel_1.SetAutoLayout(1)          self.panel_1.SetAutoLayout(1)
592          self.panel_1.SetSizer(grid_sizer_1)          self.panel_1.SetSizer(grid_sizer_1)
# Line 503  class ProjFrame(NonModalDialog): Line 598  class ProjFrame(NonModalDialog):
598          self.sizer_edit.Fit(self.panel_edit)          self.sizer_edit.Fit(self.panel_edit)
599          self.sizer_edit.SetSizeHints(self.panel_edit)          self.sizer_edit.SetSizeHints(self.panel_edit)
600    
         self.panel_buttons.SetAutoLayout(1)  
         self.panel_buttons.SetSizer(sizer_6)  
         sizer_6.Fit(self.panel_buttons)  
         sizer_6.SetSizeHints(self.panel_buttons)  
   
601          self.sizer_mainctrls.Add(self.panel_1, 0,          self.sizer_mainctrls.Add(self.panel_1, 0,
602              wxALL|wxEXPAND|wxADJUST_MINSIZE, 0)              wxALL|wxEXPAND|wxADJUST_MINSIZE, 0)
603          self.sizer_mainctrls.Add(self.panel_edit, 1,          self.sizer_mainctrls.Add(self.panel_edit, 1,
604              wxALL|wxEXPAND|wxADJUST_MINSIZE, 0)              wxALL|wxEXPAND|wxADJUST_MINSIZE, 0)
605    
606            self.sizer_mainbttns.Add(sizer_6, 0,
607                wxALL|wxEXPAND|wxADJUST_MINSIZE, 10)
608    
609          self.topBox.Add(self.sizer_mainctrls, 1, wxALL|wxEXPAND, 4)          self.topBox.Add(self.sizer_mainctrls, 1, wxALL|wxEXPAND, 4)
610          self.topBox.Add(self.panel_buttons, 0, wxEXPAND, 0)          self.topBox.Add(self.sizer_mainbttns, 0, wxALIGN_RIGHT|wxBOTTOM, 0)
611    
612          self.SetAutoLayout(1)          self.SetAutoLayout(1)
613          self.SetSizer(self.topBox)          self.SetSizer(self.topBox)
# Line 532  class ProjPanel(wxPanel): Line 625  class ProjPanel(wxPanel):
625          wxPanel.__init__(self, parent, -1)          wxPanel.__init__(self, parent, -1)
626    
627          self.__ellps = wxChoice(self, -1)          self.__ellps = wxChoice(self, -1)
628          self.ellpsData = [("bessel", _("Bessel 1841")),          self.ellpsData = [("airy"  , _("Airy")),
629                              ("bessel", _("Bessel 1841")),
630                            ("clrk66", _("Clarke 1866")),                            ("clrk66", _("Clarke 1866")),
631                            ("clrk80", _("Clarke 1880")),                            ("clrk80", _("Clarke 1880")),
632                            ("GRS80" , _("GRS 1980 (IUGG, 1980)")),                            ("GRS80" , _("GRS 1980 (IUGG, 1980)")),
# Line 548  class ProjPanel(wxPanel): Line 642  class ProjPanel(wxPanel):
642    
643          panelSizer = wxBoxSizer(wxVERTICAL)          panelSizer = wxBoxSizer(wxVERTICAL)
644    
         if childPanel is not None:  
             panelSizer.Add(childPanel, 0, wxALL|wxEXPAND, 4)  
               
645          sizer = wxBoxSizer(wxHORIZONTAL)          sizer = wxBoxSizer(wxHORIZONTAL)
646          sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4)          sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0,
647          sizer.Add(self.__ellps, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)                                      wxALL|wxALIGN_CENTER_VERTICAL, 4)
648            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:
652                panelSizer.Add(childPanel, 0, wxEXPAND, 0)
653                
654          self.SetAutoLayout(1)          self.SetAutoLayout(1)
655          self.SetSizer(panelSizer)          self.SetSizer(panelSizer)
656          panelSizer.Fit(self)          panelSizer.Fit(self)
# Line 621  class TMPanel(ProjPanel): Line 716  class TMPanel(ProjPanel):
716    
717          self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT)          self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT)
718          self.__longitude = wxTextCtrl(self, ID_TMPANEL_LONG)          self.__longitude = wxTextCtrl(self, ID_TMPANEL_LONG)
719            self.__scale = wxTextCtrl(self, ID_TMPANEL_SCALE)
720          self.__falseEast = wxTextCtrl(self, ID_TMPANEL_FASLE_EAST)          self.__falseEast = wxTextCtrl(self, ID_TMPANEL_FASLE_EAST)
721          self.__falseNorth = wxTextCtrl(self, ID_TMPANEL_FALSE_NORTH)          self.__falseNorth = wxTextCtrl(self, ID_TMPANEL_FALSE_NORTH)
         self.__scale = wxTextCtrl(self, ID_TMPANEL_SCALE)  
722    
723          self._DoLayout()          self._DoLayout()
724    
# Line 689  class UTMPanel(ProjPanel): Line 784  class UTMPanel(ProjPanel):
784          self.receiver = receiver          self.receiver = receiver
785    
786          self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60)          self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60)
787            self.__propButton = wxButton(self, ID_UTMPANEL_PROP, _("Propose"))
788          self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH,          self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH,
789                                    _("Southern Hemisphere"))                                    _("Southern Hemisphere"))
         self.__propButton = wxButton(self, ID_UTMPANEL_PROP, _("Propose"))  
790    
791          self._DoLayout()          self._DoLayout()
792    
# Line 760  class LCCPanel(ProjPanel): Line 855  class LCCPanel(ProjPanel):
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:")))
# Line 811  class GeoPanel(ProjPanel): Line 906  class GeoPanel(ProjPanel):
906    
907      def __init__(self, parent, receiver):      def __init__(self, parent, receiver):
908          ProjPanel.__init__(self, parent)          ProjPanel.__init__(self, parent)
909          ProjPanel._DoLayout(self, None)  
910            self.__choices = [(_("Degrees"), "0.017453"),
911                              (_("Radians"), "1")]
912    
913            self.__scale = wxChoice(self, -1)
914            for choice, value in self.__choices:
915                self.__scale.Append(choice, value)
916    
917            self._DoLayout()
918    
919      def GetProjName(self):      def GetProjName(self):
920          return _("Geographic")          return _("Geographic")
921                    
922      def SetProjection(self, proj):      def SetProjection(self, proj):
923            value = proj.GetParameter("to_meter")
924            for i in range(len(self.__choices)):
925                choice, data = self.__choices[i]
926                if value == data:
927                    self.__scale.SetSelection(i)
928          ProjPanel.SetProjection(self, proj)          ProjPanel.SetProjection(self, proj)
929    
930      def GetParameters(self):      def GetParameters(self):
931          params = ["proj=latlong"]          params = ["proj=latlong",
932                      "to_meter=%s" % self.__scale.GetClientData(
933                                      self.__scale.GetSelection())]
934    
935          params.extend(ProjPanel.GetParameters(self))          params.extend(ProjPanel.GetParameters(self))
936          return params          return params
937    
938      def Clear(self):      def Clear(self):
939          ProjPanel.Clear(self)          ProjPanel.Clear(self)
940    
941        def _DoLayout(self):
942            sizer = wxBoxSizer(wxHORIZONTAL)
943    
944            sizer.Add(wxStaticText(self, -1, _("Source Data is in: ")),
945                      0, wxALL|wxALIGN_CENTER_VERTICAL, 4)
946            sizer.Add(self.__scale, 1, wxEXPAND|wxALL, 4)
947    
948            self.__scale.SetSelection(0)
949    
950            ProjPanel._DoLayout(self, sizer)
951    
952    
953  ID_UTM_PROPOSE_ZONE_DIALOG_TAKE   = 4001  ID_UTM_PROPOSE_ZONE_DIALOG_TAKE   = 4001
954  ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002  ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002

Legend:
Removed from v.741  
changed lines
  Added in v.1135

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26