/[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 976 by frank, Thu May 22 11:39:31 2003 UTC revision 1190 by jonathan, Thu Jun 12 17:01:37 2003 UTC
# Line 13  from Thuban import _ Line 13  from Thuban import _
13    
14  from Thuban.Model.proj import Projection, ProjFile  from Thuban.Model.proj import Projection, ProjFile
15    
16  from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles, \  from Thuban.Model.resource import get_user_proj_files, get_system_proj_files, \
17                                    ReadProjFile, WriteProjFile                                    read_proj_file, write_proj_file
18  from Thuban.UI.dialogs import NonModalDialog  from Thuban.UI.dialogs import NonModalNonParentDialog
19    
20    
21  ID_PROJ_ADVANCED  = 4001  ID_PROJ_ADVANCED  = 4001
# Line 33  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, title, receiver):      def __init__(self, parent, name, title, receiver):
39          """Initialize the projection dialog.          """Initialize the projection dialog.
# Line 57  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, title)          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)
# Line 100  class ProjFrame(NonModalDialog): Line 100  class ProjFrame(NonModalDialog):
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()          self.originalProjection = self.receiver.GetProjection()
111    
112          self.__DoOnProjAvail()          self.__DoOnProjAvail()
# Line 124  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    
   
132      def OnApply(self, event):      def OnApply(self, event):
133          self.__SetProjection()          self.__SetProjection()
134          self.haveTried = True          self.haveTried = True
# Line 144  class ProjFrame(NonModalDialog): Line 148  class ProjFrame(NonModalDialog):
148              self.receiver.SetProjection(self.originalProjection)              self.receiver.SetProjection(self.originalProjection)
149              self.haveTried = False              self.haveTried = False
150    
   
151      def _OnNew(self, event):      def _OnNew(self, event):
152    
153          # clear all selections          # clear all selections
# Line 175  class ProjFrame(NonModalDialog): Line 178  class ProjFrame(NonModalDialog):
178          if newproj is not None:          if newproj is not None:
179              projfile.Replace(proj, newproj)              projfile.Replace(proj, newproj)
180              try:              try:
181                  WriteProjFile(projfile)                  write_proj_file(projfile)
182              except IOError, (errno, errstr):              except IOError, (errno, errstr):
183                  self.__ShowError(projfile.GetFilename(), errstr)                  self.__ShowError(projfile.GetFilename(), errstr)
184              self.availprojs.SetClientData(sel[0], [newproj, projfile])              self.availprojs.SetClientData(sel[0], [newproj, projfile])
185    
186                self.__FillAvailList( selectProj = newproj.GetName())
187    
188      def _OnAddToList(self, event):      def _OnAddToList(self, event):
189    
190          proj = self.__GetProjection()          proj = self.__GetProjection()
191          if proj is not None:          if proj is not None:
192              self.__usrProjFile.Add(proj)              self.__usrProjFile.Add(proj)
193              try:              try:
194                  WriteProjFile(self.__usrProjFile)                  write_proj_file(self.__usrProjFile)
195              except IOError, (errno, errstr):              except IOError, (errno, errstr):
196                  self.__ShowError(self.__userProjFile.GetFilename(), errstr)                  self.__ShowError(self.__userProjFile.GetFilename(), errstr)
197    
198              self.__FillAvailList()              self.__FillAvailList( selectProj = proj.GetName())
199    
200      def _OnProjAvail(self, event):      def _OnProjAvail(self, event):
201          self.__DoOnProjAvail()          self.__DoOnProjAvail()
# Line 203  class ProjFrame(NonModalDialog): Line 208  class ProjFrame(NonModalDialog):
208              path = dlg.GetPath()              path = dlg.GetPath()
209    
210              try:              try:
211                  projFile = ReadProjFile(path)                  projFile = read_proj_file(path)
212                  for proj in projFile.GetProjections():                  for proj in projFile.GetProjections():
213                      self.__usrProjFile.Add(proj)                      self.__usrProjFile.Add(proj)
214                  WriteProjFile(self.__usrProjFile)                  write_proj_file(self.__usrProjFile)
215              except IOError, (errno, errstr):              except IOError, (errno, errstr):
216                  self.__ShowError(dlg.GetPath(), errstr)                  self.__ShowError(dlg.GetPath(), errstr)
217    
# Line 233  class ProjFrame(NonModalDialog): Line 238  class ProjFrame(NonModalDialog):
238                      projFile.Add(proj)                      projFile.Add(proj)
239    
240              try:              try:
241                  WriteProjFile(projFile)                  write_proj_file(projFile)
242              except IOError, (errno, errstr):              except IOError, (errno, errstr):
243                  self.__ShowError(dlg.GetPath(), errstr)                  self.__ShowError(dlg.GetPath(), errstr)
244    
# Line 268  class ProjFrame(NonModalDialog): Line 273  class ProjFrame(NonModalDialog):
273                  projfile.Remove(proj)                  projfile.Remove(proj)
274    
275          try:          try:
276              WriteProjFile(projfile)              write_proj_file(projfile)
277          except IOError, (errno, errstr):          except IOError, (errno, errstr):
278              self.__ShowError(projfile.GetFilename(), errstr)              self.__ShowError(projfile.GetFilename(), errstr)
279    
# Line 366  class ProjFrame(NonModalDialog): Line 371  class ProjFrame(NonModalDialog):
371              if proj is None:              if proj is None:
372                  # user selected <None>                  # user selected <None>
373                  self.projname.Clear()                  self.projname.Clear()
374                                    self.projfilepath.SetLabel(_("Projection File: "))
375              else:              else:
376                            
377                  if projfile is not None:                  if projfile is not None:
378                      self.projfilepath.SetLabel(projfile.GetFilename())                      self.projfilepath.SetLabel(_("Projection File: ") +
379                            os.path.basename(projfile.GetFilename()))
380                  else:                  else:
381                      # only None if the currently used projection is selected                      # only None if the currently used projection is selected
382                      self.projfilepath.SetLabel("")                      self.projfilepath.SetLabel(_("Projection File: "))
383    
384                  self.projname.SetValue(proj.GetName())                  self.projname.SetValue(proj.GetName())
385    
# Line 469  class ProjFrame(NonModalDialog): Line 475  class ProjFrame(NonModalDialog):
475    
476          return None          return None
477    
478      def __FillAvailList(self, selectCurrent = False):      def __FillAvailList(self, selectCurrent = False, selectProj = None):
479          """Populate the list of available projections.          """Populate the list of available projections.
480                    
481          selectCurrent -- if True, select the projection used by          selectCurrent -- if True, select the projection used by
482                           the receiver, otherwise select nothing.                           the receiver, otherwise select nothing.
483            selectProj    -- if set, select the projection found under the
484                             specified name. This overwrites any other
485                             selection estimate.
486          """          """
487    
488          self.availprojs.Clear()          self.availprojs.Clear()
# Line 484  class ProjFrame(NonModalDialog): Line 493  class ProjFrame(NonModalDialog):
493          #          #
494          self.availprojs.Append("<None>", (None, None))          self.availprojs.Append("<None>", (None, None))
495    
496          projfile = GetSystemProjFiles()          projfile = get_system_proj_files()
497          projfile = projfile[0]          projfile = projfile[0]
498          for proj in projfile.GetProjections():          for proj in projfile.GetProjections():
499              self.availprojs.Append(proj.GetName(), [proj, projfile])              self.availprojs.Append(proj.GetName(), [proj, projfile])
500          self.__sysProjFile = projfile          self.__sysProjFile = projfile
501    
502          projfile = GetUserProjFiles()          projfile = get_user_proj_files()
503          projfile = projfile[0]          projfile = projfile[0]
504          for proj in projfile.GetProjections():          for proj in projfile.GetProjections():
505              self.availprojs.Append(proj.GetName(), [proj, projfile])              self.availprojs.Append(proj.GetName(), [proj, projfile])
506          self.__usrProjFile = projfile          self.__usrProjFile = projfile
507    
         for proj, name, clazz in self.projPanels:  
             self.projchoice.Append(name, [clazz, None])  
   
508          #          #
509          # We add the current projection to the list at last.          # We add the current projection to the list at last.
510          # Since the list is resorted immediately a following FindString()          # Since the list is resorted immediately a following FindString()
# Line 517  class ProjFrame(NonModalDialog): Line 523  class ProjFrame(NonModalDialog):
523                  self.availprojs.SetSelection(                  self.availprojs.SetSelection(
524                          self.availprojs.FindString("<None>")                          self.availprojs.FindString("<None>")
525                      )                      )
526            if selectProj:
527                self.availprojs.SetSelection(
528                            self.availprojs.FindString(selectProj)
529                        )
530    
531                                    
532    
533      def __set_properties(self):      def __set_properties(self):
# Line 553  class ProjFrame(NonModalDialog): Line 564  class ProjFrame(NonModalDialog):
564          grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0)          grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0)
565          grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)          grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)
566          grid_sizer_1.Add(sizer_15, 0, wxALL|wxEXPAND, 4)          grid_sizer_1.Add(sizer_15, 0, wxALL|wxEXPAND, 4)
567          grid_sizer_1.Add(self.projfilepath, 0, wxALL|wxADJUST_MINSIZE, 4)          grid_sizer_1.Add(self.projfilepath, 0, wxEXPAND|wxALL|wxADJUST_MINSIZE, 4)
568          grid_sizer_1.AddGrowableRow(1)          grid_sizer_1.AddGrowableRow(1)
569          grid_sizer_1.AddGrowableCol(0)          grid_sizer_1.AddGrowableCol(0)
570    
# Line 562  class ProjFrame(NonModalDialog): Line 573  class ProjFrame(NonModalDialog):
573          sizer_13.Add(self.projname, 1, wxALL, 4)          sizer_13.Add(self.projname, 1, wxALL, 4)
574          self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0)          self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0)
575          sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)          sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)
576          sizer_14.Add(self.projchoice, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)          sizer_14.Add(self.projchoice, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4)
577          self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0)          self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0)
578          self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0)          self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0)
579          sizer_11.Add(self.button_new, 0, wxALL, 4)          sizer_11.Add(self.button_new, 0, wxEXPAND|wxALL, 4)
580          sizer_11.Add(self.button_add, 0, wxALL, 4)          sizer_11.Add(self.button_add, 0, wxEXPAND|wxALL, 4)
581          sizer_11.Add(20, 20, 0, wxEXPAND, 0)          sizer_11.Add(20, 20, 0, wxEXPAND, 0)
582          sizer_11.Add(self.button_save, 0, wxALL|wxALIGN_BOTTOM, 4)          sizer_11.Add(self.button_save, 0, wxEXPAND|wxALL|wxALIGN_BOTTOM, 4)
583          self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4)          self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4)
584    
585          sizer_6.Add(self.button_try, 0, wxRIGHT| wxEXPAND, 10)          sizer_6.Add(self.button_try, 0, wxRIGHT| wxEXPAND, 10)
# Line 633  class ProjPanel(wxPanel): Line 644  class ProjPanel(wxPanel):
644          sizer = wxBoxSizer(wxHORIZONTAL)          sizer = wxBoxSizer(wxHORIZONTAL)
645          sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0,          sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0,
646                                      wxALL|wxALIGN_CENTER_VERTICAL, 4)                                      wxALL|wxALIGN_CENTER_VERTICAL, 4)
647          sizer.Add(self.__ellps, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)          sizer.Add(self.__ellps, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4)
648          panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4)          panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4)
649    
650          if childPanel is not None:          if childPanel is not None:
# Line 843  class LCCPanel(ProjPanel): Line 854  class LCCPanel(ProjPanel):
854          sizer.Add(wxStaticText(self, -1,          sizer.Add(wxStaticText(self, -1,
855              _("Latitude of second standard parallel:")))              _("Latitude of second standard parallel:")))
856          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)  
857          sizer.Add(wxStaticText(self, -1, _("Central Meridian:")))          sizer.Add(wxStaticText(self, -1, _("Central Meridian:")))
858          sizer.Add(self.__meridian, 0, wxALL, 4)          sizer.Add(self.__meridian, 0, wxALL, 4)
859            sizer.Add(wxStaticText(self, -1, _("Latitude of origin:")))
860            sizer.Add(self.__originLat, 0, wxALL, 4)
861          sizer.Add(wxStaticText(self, -1, _("False Easting:")))          sizer.Add(wxStaticText(self, -1, _("False Easting:")))
862          sizer.Add(self.__falseEast, 0, wxALL, 4)          sizer.Add(self.__falseEast, 0, wxALL, 4)
863          sizer.Add(wxStaticText(self, -1, _("False Northing:")))          sizer.Add(wxStaticText(self, -1, _("False Northing:")))

Legend:
Removed from v.976  
changed lines
  Added in v.1190

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26