/[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 730 by jonathan, Thu Apr 24 16:07:41 2003 UTC revision 797 by jonathan, Wed Apr 30 17:01:48 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  #
5    # This program is free software under the GPL (>=v2)
6    # Read the file COPYING coming with Thuban for details.
7                                                                                    
8    import os, sys, math
9  from wxPython.wx import *  from wxPython.wx import *
10    
11  from Thuban import _  from Thuban import _
# Line 15  from Thuban.UI.dialogs import NonModalDi Line 19  from Thuban.UI.dialogs import NonModalDi
19    
20  ID_PROJ_ADVANCED  = 4001  ID_PROJ_ADVANCED  = 4001
21  ID_PROJ_PROJCHOICE = 4002  ID_PROJ_PROJCHOICE = 4002
22  ID_PROJ_SAVEAS    = 4003  ID_PROJ_ADDTOLIST    = 4003
23  ID_PROJ_NEW       = 4004  ID_PROJ_NEW       = 4004
24  ID_PROJ_TRY       = 4005  ID_PROJ_TRY       = 4005
25  ID_PROJ_REVERT    = 4006  ID_PROJ_REVERT    = 4006
# Line 33  CLIENT_PROJFILE = 1 Line 37  CLIENT_PROJFILE = 1
37    
38  class ProjFrame(NonModalDialog):  class ProjFrame(NonModalDialog):
39    
40      def __init__(self, parent, name, receiver, *args, **kwds):      def __init__(self, parent, name, title, receiver):
41          """Initialize the projection dialog.          """Initialize the projection dialog.
42    
43          receiver -- An object that implements the following methods:          receiver -- An object that implements the following methods:
# Line 42  class ProjFrame(NonModalDialog): Line 46  class ProjFrame(NonModalDialog):
46          """          """
47                    
48          self.receiver = receiver          self.receiver = receiver
49          self.originalProjection = -1          self.haveTried = False
50          self.curProjPanel = None          self.curProjPanel = None
51    
52          self.projPanels = []          self.projPanels = []
# Line 55  class ProjFrame(NonModalDialog): Line 59  class ProjFrame(NonModalDialog):
59          self.projPanels.append(          self.projPanels.append(
60              ("latlong", _("Geographic"), GeoPanel))              ("latlong", _("Geographic"), GeoPanel))
61    
62          NonModalDialog.__init__(self, parent, name, "")          NonModalDialog.__init__(self, parent, name, title)
63          # originally generate by wxGlade          # originally generate by wxGlade
64          self.panel_1 = wxPanel(self, -1)          self.panel_1 = wxPanel(self, -1)
65          self.panel_edit = wxPanel(self, -1)          self.panel_edit = wxPanel(self, -1)
66          self.panel_buttons = wxPanel(self, -1)          self.panel_buttons = wxPanel(self, -1)
67          self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:"))          self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:"))
68          self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_EXTENDED |wxLB_SORT)          self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_EXTENDED|wxLB_SORT)
69          self.projfilepath = wxStaticText(self.panel_1, -1, "")          self.projfilepath = wxStaticText(self.panel_1, -1, "")
70          self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:"))          self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:"))
71          self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "")          self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "")
# Line 72  class ProjFrame(NonModalDialog): Line 76  class ProjFrame(NonModalDialog):
76          self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove"))          self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove"))
77          self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New"))          self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New"))
78          self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Save"))          self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Save"))
79          self.button_add = wxButton(self.panel_edit, ID_PROJ_SAVEAS,          self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST,
80                                        _("Add to List"))                                        _("Add to List"))
81          self.button_try = wxButton(self.panel_buttons, ID_PROJ_TRY, _("Try"))          self.button_try = wxButton(self.panel_buttons, ID_PROJ_TRY, _("Try"))
82          self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, _("Revert"))          self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, _("Revert"))
# Line 83  class ProjFrame(NonModalDialog): Line 87  class ProjFrame(NonModalDialog):
87          self.__do_layout()          self.__do_layout()
88          # wxGlade          # wxGlade
89    
90            self.originalProjection = self.receiver.GetProjection()
91    
92          self.__DoOnProjAvail()          self.__DoOnProjAvail()
93                    
94          EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry)          EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry)
# Line 97  class ProjFrame(NonModalDialog): Line 103  class ProjFrame(NonModalDialog):
103    
104          EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew)          EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew)
105          EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave)          EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave)
106          EVT_BUTTON(self, ID_PROJ_SAVEAS, self._OnSaveAs)          EVT_BUTTON(self, ID_PROJ_ADDTOLIST, self._OnAddToList)
107    
108          EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName)          EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName)
109    
     def GetReceiver(self):  
         return self.receiver  
   
110      def _OnTry(self, event):      def _OnTry(self, event):
111          self.__SetProjection()          self.__SetProjection()
112            self.haveTried = True
113    
114      def _OnRevert(self, event):      def _OnRevert(self, event):
115          if self.originalProjection != -1:          if self.haveTried:
116              self.receiver.SetProjection(self.originalProjection)              self.receiver.SetProjection(self.originalProjection)
117                self.haveTried = False
118    
119      def _OnOK(self, event):      def _OnOK(self, event):
120          self.__SetProjection()          self.__SetProjection()
# Line 119  class ProjFrame(NonModalDialog): Line 124  class ProjFrame(NonModalDialog):
124          self.Close()          self.Close()
125    
126      def _OnNew(self, event):      def _OnNew(self, event):
127          self.__DoOnNew()  
128            # clear all selections
129            sel = self.availprojs.GetSelections()
130            for index in sel:
131                self.availprojs.SetSelection(index, False)
132    
133            self.projname.Clear()
134    
135            # supply a projection panel if there wasn't one
136            if self.curProjPanel is None:
137                self.projchoice.SetSelection(0)
138                self.__DoOnProjChoice()
139    
140            self.curProjPanel.Clear()
141    
142      def _OnSave(self, event):      def _OnSave(self, event):
143    
# Line 133  class ProjFrame(NonModalDialog): Line 151  class ProjFrame(NonModalDialog):
151          newproj = self.__GetProjection()          newproj = self.__GetProjection()
152    
153          if newproj is not None:          if newproj is not None:
154              projfile.Remove(proj)              projfile.Replace(proj, newproj)
             projfile.Add(newproj)  
155              try:              try:
156                  WriteProjFile(projfile)                  WriteProjFile(projfile)
157              except IOError, (errno, errstr):              except IOError, (errno, errstr):
158                  wxMessageDialog(self,                  self.__ShowError(projfile.GetFilename(), errstr)
159                      _("The following error occured:\n") +              self.availprojs.SetClientData(sel[0], [newproj, projfile])
                     projfile.GetFileName() + "\n" + errstr,  
                     _("Error"), wxOK | wxICON_ERROR).ShowModal()  
             self.__FillAvailList()  
160    
161      def _OnSaveAs(self, event):      def _OnAddToList(self, event):
162    
163          proj = self.__GetProjection()          proj = self.__GetProjection()
164          if proj is not None:          if proj is not None:
# Line 152  class ProjFrame(NonModalDialog): Line 166  class ProjFrame(NonModalDialog):
166              try:              try:
167                  WriteProjFile(self.__usrProjFile)                  WriteProjFile(self.__usrProjFile)
168              except IOError, (errno, errstr):              except IOError, (errno, errstr):
169                  wxMessageDialog(self,                  self.__ShowError(self.__userProjFile.GetFilename(), errstr)
                     _("The following error occured:\n") +  
                     self.__usrProjFile.GetFileName() + "\n" + errstr,  
                     _("Error"), wxOK | wxICON_ERROR).ShowModal()  
             self.__FillAvailList()  
   
         return  
   
         """Save the projection somewhere.  
   
         There are three important cases to consider.  
             1. the file already exists and the user wants to overwrite it.  
             2. the file already exists and the user wants to append the  
                current projection to the end of the file  
             3. the file doesn't exist and the user wants to create it  
   
         The list of available projections is then updated.  
         """  
   
         proj = Projection(self.curProjPanel.GetParameters())  
         if self.projname.GetValue() != "":  
             proj.SetName(self.projname.GetValue())  
   
         dlg = wxFileDialog(self, _("Save As"), style = wxSAVE)  
         if dlg.ShowModal() == wxID_OK:  
             path = dlg.GetPath()  
   
             if os.access(path, os.F_OK):  
                 # file already exists.  
                 if os.access(path, os.W_OK | os.R_OK):  
                   
                     # is it a .proj file?  
                     try:  
                         projFile = ReadProjFile(path)  
                     except:  
                         # obviously not.  
                         dlg = wxMessageDialog(self,  
                             path + _(" already exists. Overwrite?"),  
                             _(""),  
                             wxYES | wxNO)  
   
                         if dlg.ShowModal() == wxID_YES:  
                             projFile = ProjFile(path)  
                         else:  
                             return # returning early  
                     else:  
                         # ask the user to overwrite or append  
                         dlg = wxMessageDialog(self,  
                             _("The selected projection file already exists.\n"+  
                               "The current projection can be added to the " +  
                               "file, or it can completely replace the " +  
                               "selected file.\n\nShould the current " +  
                               "projection be added to the file?"),  
                             _("Question"),  
                             wxYES | wxNO | wxICON_QUESTION)  
   
                         if dlg.ShowModal() == wxID_NO:  
                             projFile = ProjFile(path)  
                 else:  
                     # can't access the file  
                     dlg = wxMessageDialog(self,  
                         _("Couldn't access ") + path,  
                         _(""),  
                         wxOK | wxICON | wxICON_EXCLAMATION)  
                     return  
170    
171              else:              self.__FillAvailList()
                 # file doesn't exist. make a new one.  
                 projFile = ProjFile(path)  
                   
             #  
             # if we get this far we have a valid projFile and  
             # can just write the file  
             #  
             projFile.Add(proj)  
             try:  
                 WriteProjFile(projFile)  
                 self.__FillAvailList()  
             except IOError, (errno, errstr):  
                 wxMessageDialog(self,  
                     _("The following error occured:\n") +  
                     dlg.GetPath() + "\n" + errstr,  
                     _("Error"), wxOK | wxICON_ERROR).ShowModal()  
         dlg.Destroy()  
172    
173      def _OnProjAvail(self, event):      def _OnProjAvail(self, event):
174          self.__DoOnProjAvail()          self.__DoOnProjAvail()
# Line 253  class ProjFrame(NonModalDialog): Line 186  class ProjFrame(NonModalDialog):
186                      self.__usrProjFile.Add(proj)                      self.__usrProjFile.Add(proj)
187                  WriteProjFile(self.__usrProjFile)                  WriteProjFile(self.__usrProjFile)
188              except IOError, (errno, errstr):              except IOError, (errno, errstr):
189                  wxMessageDialog(self,                  self.__ShowError(dlg.GetPath(), errstr)
                     _("The following error occured:\n") +  
                     dlg.GetPath() + "\n" + errstr,  
                     _("Error"), wxOK | wxICON_ERROR).ShowModal()  
190    
191              self.__FillAvailList()              self.__FillAvailList()
192    
193          dlg.Destroy()          dlg.Destroy()
194    
195      def _OnExport(self, event):      def _OnExport(self, event):
         proj = self.__GetProjection()  
196    
197          if proj is None: return          sel = self.availprojs.GetSelections()
198            assert len(sel) != 0, "button should be disabled"
199    
200          dlg = wxFileDialog(self, _("Export"),          dlg = wxFileDialog(self, _("Export"),
201                             style = wxSAVE|wxOVERWRITE_PROMPT)                          style = wxSAVE|wxOVERWRITE_PROMPT)
202    
203          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
204              path = dlg.GetPath()              path = dlg.GetPath()
205    
206              projFile = ProjFile(path)              projFile = ProjFile(path)
207              projFile.Add(proj)  
208                for i in sel:
209                    proj = self.availprojs.GetClientData(i)[CLIENT_PROJ]
210                    if proj is not None:
211                        projFile.Add(proj)
212    
213              try:              try:
214                  WriteProjFile(projFile)                  WriteProjFile(projFile)
215              except IOError, (errno, errstr):              except IOError, (errno, errstr):
216                  wxMessageDialog(self,                  self.__ShowError(dlg.GetPath(), errstr)
                     _("The following error occured:\n") +  
                     dlg.GetPath() + "\n" + errstr,  
                     _("Error"), wxOK | wxICON_ERROR).ShowModal()  
217    
218          dlg.Destroy()          dlg.Destroy()
219    
# Line 316  class ProjFrame(NonModalDialog): Line 248  class ProjFrame(NonModalDialog):
248          try:          try:
249              WriteProjFile(projfile)              WriteProjFile(projfile)
250          except IOError, (errno, errstr):          except IOError, (errno, errstr):
251              wxMessageDialog(self,              self.__ShowError(projfile.GetFilename(), errstr)
                 _("The following error occured:\n") +  
                 projfile.GetFileName() + "\n" + errstr,  
                 _("Error"), wxOK | wxICON_ERROR).ShowModal()  
   
252    
253          self.__FillAvailList()          self.__FillAvailList()
254    
# Line 332  class ProjFrame(NonModalDialog): Line 260  class ProjFrame(NonModalDialog):
260          if newselection != -1 and self.availprojs.GetCount() > 0:          if newselection != -1 and self.availprojs.GetCount() > 0:
261              self.availprojs.SetSelection(newselection)              self.availprojs.SetSelection(newselection)
262    
263            self.__VerifyButtons()
264    
265      def _OnProjName(self, event):      def _OnProjName(self, event):
266          self.__VerifyButtons()          self.__VerifyButtons()
267    
268        def __ShowError(self, filename, errstr):
269            wxMessageDialog(self,
270                _("The following error occured:\n") +
271                filename + "\n" + errstr,
272                _("Error"), wxOK | wxICON_ERROR).ShowModal()
273    
274      def __VerifyButtons(self):      def __VerifyButtons(self):
275            """Enable or disable the appropriate buttons based on the
276            current state of the dialog.
277            """
278    
279          sel = self.availprojs.GetSelections()          sel = self.availprojs.GetSelections()
280    
281          self.button_import.Enable(True)          self.button_import.Enable(True)
# Line 345  class ProjFrame(NonModalDialog): Line 285  class ProjFrame(NonModalDialog):
285    
286          self.panel_edit.Enable(True)          self.panel_edit.Enable(True)
287    
288            for ctrl in [self.button_import,
289                         self.button_export,
290                         self.button_remove,
291                         self.button_save,
292                         self.button_add,
293                         self.projchoice,
294                         self.projname,
295                         self.panel_edit]:
296                ctrl.Enable(True)
297    
298            if self.curProjPanel is not None:
299                self.curProjPanel.Enable(True)
300    
301          if len(sel) == 0:          if len(sel) == 0:
302              self.button_import.Enable(True)              self.button_import.Enable(True)
303              self.button_export.Enable(False)              self.button_export.Enable(False)
# Line 358  class ProjFrame(NonModalDialog): Line 311  class ProjFrame(NonModalDialog):
311              self.button_add.Enable(len(self.projname.GetValue()) > 0)              self.button_add.Enable(len(self.projname.GetValue()) > 0)
312    
313              if proj is None:              if proj is None:
314                  self.button_export.Enable(False)                  # <None> is selected
315                    for ctrl in [self.button_export,
316                                 self.button_remove,
317                                 self.button_save,
318                                 self.button_add,
319                                 self.projchoice,
320                                 self.projname]:
321                        ctrl.Enable(False)
322    
323                    if self.curProjPanel is not None:
324                        self.curProjPanel.Enable(False)
325    
326                elif proj is self.originalProjection:
327                  self.button_remove.Enable(False)                  self.button_remove.Enable(False)
328    
329              if projFile is None:              if projFile is None:
# Line 367  class ProjFrame(NonModalDialog): Line 332  class ProjFrame(NonModalDialog):
332          else:          else:
333              self.panel_edit.Enable(False)              self.panel_edit.Enable(False)
334    
     def __DoOnNew(self):  
         sel = self.availprojs.GetSelections()  
         if len(sel) != 0:  
             self.availprojs.SetSelection(sel, False)  
         self.projname.Clear()  
         self.curProjPanel.Clear()  
   
335      def __DoOnProjAvail(self):      def __DoOnProjAvail(self):
336    
337          sel = self.availprojs.GetSelections()          sel = self.availprojs.GetSelections()
# Line 385  class ProjFrame(NonModalDialog): Line 343  class ProjFrame(NonModalDialog):
343              if proj is None:              if proj is None:
344                  # user selected <None>                  # user selected <None>
345                  self.projname.Clear()                  self.projname.Clear()
346                    
347              else:              else:
348                            
349                  if projfile is not None:                  if projfile is not None:
350                      self.projfilepath.SetLabel(projfile.GetFileName())                      self.projfilepath.SetLabel(projfile.GetFilename())
351                  else:                  else:
352                      # only None if the currently used projection is selected                      # only None if the currently used projection is selected
353                      self.projfilepath.SetLabel("")                      self.projfilepath.SetLabel("")
# Line 401  class ProjFrame(NonModalDialog): Line 360  class ProjFrame(NonModalDialog):
360                      if myProjType == projType:                      if myProjType == projType:
361                          self.projchoice.SetSelection(i)                          self.projchoice.SetSelection(i)
362                          self.__DoOnProjChoice()                          self.__DoOnProjChoice()
363    
364                            #
365                            # self.curProjPanel should not be null
366                            # after a call to __DoOnProjChoice
367                            #
368                            assert self.curProjPanel is not None
369    
370                          self.curProjPanel.SetProjection(proj)                          self.curProjPanel.SetProjection(proj)
371                      i += 1                      i += 1
372    
# Line 410  class ProjFrame(NonModalDialog): Line 376  class ProjFrame(NonModalDialog):
376          self.__DoOnProjChoice()          self.__DoOnProjChoice()
377    
378      def __DoOnProjChoice(self):      def __DoOnProjChoice(self):
379            """Create and layout a projection panel based on the selected
380            projection type.
381    
382            This is necessary to have in seperate method since calls to
383            wxChoice.SetSelection() do not trigger an event.
384    
385            At the end of this method self.curProjPanel will not be None
386            if there was a item selected.
387            """
388    
389          choice = self.projchoice          choice = self.projchoice
390    
391          sel = choice.GetSelection()          sel = choice.GetSelection()
# Line 435  class ProjFrame(NonModalDialog): Line 411  class ProjFrame(NonModalDialog):
411              self.topBox.SetSizeHints(self)              self.topBox.SetSizeHints(self)
412    
413      def __SetProjection(self):      def __SetProjection(self):
414            """Set the receiver's projection."""
415    
416          #          #
417          # save the original projection only once in case          # save the original projection only once in case
418          # we try to apply several different projections          # we try to apply several different projections
419          #          #
         if self.originalProjection == -1:  
             self.originalProjection = self.receiver.GetProjection()  
   
420          self.receiver.SetProjection(self.__GetProjection())          self.receiver.SetProjection(self.__GetProjection())
421    
422      def __GetProjection(self):      def __GetProjection(self):
423          """Return the packaged projection.          """Return a suitable Projection object based on the current
424            state of the dialog box selections.
425    
426          Could be None.          Could be None.
427          """          """
428    
429          proj = None          sel = self.availprojs.GetSelections()
430            assert len(sel) < 2, "button should be disabled"
431    
432    
433            if len(sel) == 1:
434                proj = self.availprojs.GetClientData(sel[0])[CLIENT_PROJ]
435                if proj is None:
436                    # <None> is selected
437                    return None
438    
439            #
440            # self.curProjPanel should always contain the most
441            # relevant data for a projection
442            #
443          if self.curProjPanel is not None:          if self.curProjPanel is not None:
444              proj = Projection(self.curProjPanel.GetParameters())              return Projection(self.curProjPanel.GetParameters(),
445              proj.SetName(self.projname.GetValue())                                self.projname.GetValue())
446    
447            return None
448    
449          return proj      def __FillAvailList(self, selectCurrent = False):
450            """Populate the list of available projections.
451            
452            selectCurrent -- if True, select the projection used by
453                             the receiver, otherwise select nothing.
454            """
455    
     def __FillAvailList(self):  
456          self.availprojs.Clear()          self.availprojs.Clear()
457    
458          #          #
459            # We add the current projection to the list first so that
460            # we are sure that it's at index 0. That way we can
461            # set the selection with confidence. The problem is the
462            # the list is automatically sorted when an item is appended
463            # and the index of where it was inserted is not returned.
464            #
465            proj = self.receiver.GetProjection()
466            if proj is not None:
467                self.availprojs.Append(_("%s (current)") % proj.GetName(),
468                                       [proj, None])
469                if selectCurrent:
470                    self.availprojs.SetSelection(0)
471                    self.availprojs.SetFirstItem(0)
472    
473            #
474          # the list can never be empty. there will always be          # the list can never be empty. there will always be
475          # at least this one item          # at least this one item
476          #          #
477          self.availprojs.Append("<None>", (None, None))          self.availprojs.Append("<None>", (None, None))
478    
479          self.__sysProjFile = None          # proj is only None when <None> should be selected
480          self.__usrProjFile = None          if proj is None and selectCurrent:
481                self.availprojs.SetSelection(0)
482                self.availprojs.SetFirstItem(0)
483    
484          projfile = GetSystemProjFiles()          projfile = GetSystemProjFiles()
485          if len(projfile) > 0:          projfile = projfile[0]
486              projfile = projfile[0]          for proj in projfile.GetProjections():
487              for proj in projfile.GetProjections():              self.availprojs.Append(proj.GetName(), [proj, projfile])
488                  self.availprojs.Append(proj.GetName(), [proj, projfile])          self.__sysProjFile = projfile
             self.__sysProjFile = projfile  
489    
490          projfile = GetUserProjFiles()          projfile = GetUserProjFiles()
491          if len(projfile) > 0:          projfile = projfile[0]
492              projfile = projfile[0]          for proj in projfile.GetProjections():
493              for proj in projfile.GetProjections():              self.availprojs.Append(proj.GetName(), [proj, projfile])
494                  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  
   
         proj = self.receiver.GetProjection()  
         if proj is not None:  
             self.availprojs.Append(proj.GetName() + _(" (current)"),  
                                    [proj, None])  
495    
496          for proj, name, clazz in self.projPanels:          for proj, name, clazz in self.projPanels:
497              self.projchoice.Append(name, [clazz, None])              self.projchoice.Append(name, [clazz, None])
498    
499      def __set_properties(self):      def __set_properties(self):
         self.__FillAvailList()  
500    
501          # begin wxGlade: ProjFrame.__set_properties          #self.availprojs.SetSelection(0)
         self.SetTitle(_("Projections"))  
         self.availprojs.SetSelection(0)  
502          self.projchoice.SetSelection(0)          self.projchoice.SetSelection(0)
503          # end wxGlade  
504            self.__FillAvailList(selectCurrent = True)
505    
506          self.projname.SetMaxLength(32)          self.projname.SetMaxLength(32)
507    
# Line 623  class ProjPanel(wxPanel): Line 612  class ProjPanel(wxPanel):
612          panelSizer = wxBoxSizer(wxVERTICAL)          panelSizer = wxBoxSizer(wxVERTICAL)
613    
614          if childPanel is not None:          if childPanel is not None:
615              panelSizer.Add(childPanel, 0, wxALL|wxEXPAND, 4)              panelSizer.Add(childPanel, 0, wxEXPAND, 0)
616                            
617          sizer = wxBoxSizer(wxHORIZONTAL)          sizer = wxBoxSizer(wxHORIZONTAL)
618          sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4)          sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4)
# Line 885  class GeoPanel(ProjPanel): Line 874  class GeoPanel(ProjPanel):
874    
875      def __init__(self, parent, receiver):      def __init__(self, parent, receiver):
876          ProjPanel.__init__(self, parent)          ProjPanel.__init__(self, parent)
877          ProjPanel._DoLayout(self, None)  
878            self.__choices = [(_("Radians"), "1"),
879                              (_("Degrees"), "0.017453")]
880    
881            self.__scale = wxChoice(self, -1)
882            for choice, value in self.__choices:
883                self.__scale.Append(choice, value)
884    
885            self._DoLayout()
886    
887      def GetProjName(self):      def GetProjName(self):
888          return _("Geographic")          return _("Geographic")
889                    
890      def SetProjection(self, proj):      def SetProjection(self, proj):
891            value = proj.GetParameter("to_meter")
892            for i in range(len(self.__choices)):
893                choice, data = self.__choices[i]
894                if value == data:
895                    self.__scale.SetSelection(i)
896          ProjPanel.SetProjection(self, proj)          ProjPanel.SetProjection(self, proj)
897    
898      def GetParameters(self):      def GetParameters(self):
899          params = ["proj=latlong"]          params = ["proj=latlong",
900                      "to_meter=%s" % self.__scale.GetClientData(
901                                      self.__scale.GetSelection())]
902    
903          params.extend(ProjPanel.GetParameters(self))          params.extend(ProjPanel.GetParameters(self))
904          return params          return params
905    
906      def Clear(self):      def Clear(self):
907          ProjPanel.Clear(self)          ProjPanel.Clear(self)
908    
909        def _DoLayout(self):
910            sizer = wxBoxSizer(wxHORIZONTAL)
911    
912            sizer.Add(wxStaticText(self, -1, _("Source Data is in: ")),
913                      0, wxALL, 4)
914            sizer.Add(self.__scale, 1, wxEXPAND|wxALL, 4)
915    
916            self.__scale.SetSelection(0)
917    
918            ProjPanel._DoLayout(self, sizer)
919    
920    
921  ID_UTM_PROPOSE_ZONE_DIALOG_TAKE   = 4001  ID_UTM_PROPOSE_ZONE_DIALOG_TAKE   = 4001
922  ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002  ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002

Legend:
Removed from v.730  
changed lines
  Added in v.797

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26