/[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 1806 by bh, Fri Oct 10 10:36:34 2003 UTC revision 1819 by bh, Mon Oct 13 15:55:43 2003 UTC
# Line 24  from Thuban.Model.resource import get_us Line 24  from Thuban.Model.resource import get_us
24                                    read_proj_file, write_proj_file                                    read_proj_file, write_proj_file
25  from Thuban.UI.dialogs import NonModalNonParentDialog  from Thuban.UI.dialogs import NonModalNonParentDialog
26    
27    from sizers import NotebookLikeSizer
28    
29  ID_PROJ_ADVANCED  = 4001  ID_PROJ_ADVANCED  = 4001
30  ID_PROJ_PROJCHOICE = 4002  ID_PROJ_PROJCHOICE = 4002
# Line 51  class ProjFrame(NonModalNonParentDialog) Line 52  class ProjFrame(NonModalNonParentDialog)
52          """          """
53          NonModalNonParentDialog.__init__(self, parent, name, title)          NonModalNonParentDialog.__init__(self, parent, name, title)
54    
55          self.projection_panels = [          self.projection_panel_defs = [
56              ("tmerc", _("Transverse Mercator"), TMPanel),              ("tmerc", _("Transverse Mercator"), TMPanel),
57              ("utm", _("Universal Transverse Mercator"), UTMPanel),              ("utm", _("Universal Transverse Mercator"), UTMPanel),
58              ("lcc", _("Lambert Conic Conformal"), LCCPanel),              ("lcc", _("Lambert Conic Conformal"), LCCPanel),
# Line 139  class ProjFrame(NonModalNonParentDialog) Line 140  class ProjFrame(NonModalNonParentDialog)
140          EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice)          EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice)
141          hbox.Add(self.projchoice, 1, wxALL|wxEXPAND, 4)          hbox.Add(self.projchoice, 1, wxALL|wxEXPAND, 4)
142          # Fill the projection choice list.          # Fill the projection choice list.
143          for proj, name, clazz in self.projection_panels:          self.nbsizer = NotebookLikeSizer()
144              self.projchoice.Append(name, [clazz, None])          self.sizer_projctrls.Add(self.nbsizer, 1,
145                                     wxALL|wxEXPAND|wxADJUST_MINSIZE, 3)
146            self.projection_panels = []
147            for proj_type, name, cls in self.projection_panel_defs:
148                self.projchoice.Append(name, proj_type)
149                panel = cls(self, self.receiver)
150                panel.Hide()
151                panel.projection_index = len(self.projection_panels)
152                panel.projection_type = proj_type
153                self.projection_panels.append(panel)
154                self.nbsizer.Add(panel)
155            self.unknown_projection_panel = UnknownProjPanel(self, self.receiver)
156            self.unknown_projection_panel.Hide()
157            self.nbsizer.Add(self.unknown_projection_panel)
158    
159          # Projection Specific actions (New/Save/Add)          # Projection Specific actions (New/Save/Add)
160          buttons = wxBoxSizer(wxVERTICAL)          buttons = wxBoxSizer(wxVERTICAL)
# Line 238  class ProjFrame(NonModalNonParentDialog) Line 252  class ProjFrame(NonModalNonParentDialog)
252                  self.__ShowError(projfile.GetFilename(), errstr)                  self.__ShowError(projfile.GetFilename(), errstr)
253              self.availprojs.SetClientData(sel[0], [newproj, projfile])              self.availprojs.SetClientData(sel[0], [newproj, projfile])
254    
255              self.__FillAvailList( selectProj = newproj.GetName())              self.__FillAvailList( selectProj = newproj.Label())
256    
257      def _OnAddToList(self, event):      def _OnAddToList(self, event):
258    
# Line 250  class ProjFrame(NonModalNonParentDialog) Line 264  class ProjFrame(NonModalNonParentDialog)
264              except IOError, (errno, errstr):              except IOError, (errno, errstr):
265                  self.__ShowError(self.__userProjFile.GetFilename(), errstr)                  self.__ShowError(self.__userProjFile.GetFilename(), errstr)
266    
267              self.__FillAvailList( selectProj = proj.GetName())              self.__FillAvailList( selectProj = proj.Label())
268    
269      def _OnProjAvail(self, event):      def _OnProjAvail(self, event):
270          self.__DoOnProjAvail()          self.__DoOnProjAvail()
# Line 439  class ProjFrame(NonModalNonParentDialog) Line 453  class ProjFrame(NonModalNonParentDialog)
453                  self.projname.Clear()                  self.projname.Clear()
454                  self.projfilepath.SetLabel(_("Projection File: "))                  self.projfilepath.SetLabel(_("Projection File: "))
455              else:              else:
456                
457                  if projfile is not None:                  if projfile is not None:
458                      self.projfilepath.SetLabel(_("Projection File: ") +                      self.projfilepath.SetLabel(_("Projection File: ") +
459                          os.path.basename(projfile.GetFilename()))                          os.path.basename(projfile.GetFilename()))
# Line 447  class ProjFrame(NonModalNonParentDialog) Line 461  class ProjFrame(NonModalNonParentDialog)
461                      # only None if the currently used projection is selected                      # only None if the currently used projection is selected
462                      self.projfilepath.SetLabel(_("Projection File: "))                      self.projfilepath.SetLabel(_("Projection File: "))
463    
464                  self.projname.SetValue(proj.GetName())                  self.projname.SetValue(proj.Label())
465    
466                  myProjType = proj.GetParameter("proj")                  myProjType = proj.GetParameter("proj")
467                  i = 0                  i = 0
468                  for projType, name, clazz in self.projection_panels:                  for projType, name, cls in self.projection_panel_defs:
469                      if myProjType == projType:                      if myProjType == projType:
470                          self.projchoice.Enable(True)                          self.projchoice.Enable(True)
471                          self.projchoice.SetSelection(i)                          self.projchoice.SetSelection(i)
# Line 468  class ProjFrame(NonModalNonParentDialog) Line 482  class ProjFrame(NonModalNonParentDialog)
482                      i += 1                      i += 1
483                  else:                  else:
484                      self.projchoice.Disable()                      self.projchoice.Disable()
485                      self._show_proj_panel(UnknownProjPanel(self,                      self._show_proj_panel(UnknownProjPanel)
                                                            self.receiver))  
486    
487          self.__VerifyButtons()          self.__VerifyButtons()
488    
# Line 490  class ProjFrame(NonModalNonParentDialog) Line 503  class ProjFrame(NonModalNonParentDialog)
503    
504          sel = choice.GetSelection()          sel = choice.GetSelection()
505          if sel != -1:          if sel != -1:
506              clazz, obj = choice.GetClientData(sel)              proj_type = choice.GetClientData(sel)
507              if obj is None:              for t, name, cls in self.projection_panel_defs:
508                  obj = clazz(self, self.receiver)                  if t == proj_type:
509                  choice.SetClientData(sel, [clazz, obj])                      self._show_proj_panel(cls)
510              self._show_proj_panel(obj)                      break
511            # FIXME: what to do if sel == -1?
512    
513      def _show_proj_panel(self, panel):      def _show_proj_panel(self, panel_class):
514          """Show the panel as the projection panel"""          """Show the panel as the projection panel"""
515          if self.curProjPanel is not None:          if panel_class is UnknownProjPanel:
516              self.curProjPanel.Hide()              self.edit_box.Disable()
517              self.sizer_projctrls.Remove(self.curProjPanel)              self.nbsizer.Activate(self.unknown_projection_panel)
518                self.curProjPanel = self.unknown_projection_panel
519          self.curProjPanel = panel          else:
520          self.curProjPanel.Show()              self.edit_box.Enable(True)
521                self.unknown_projection_panel.Hide()
522          self.sizer_projctrls.Add(self.curProjPanel, 1,              for panel in self.projection_panels:
523              wxALL|wxEXPAND|wxADJUST_MINSIZE, 3)                  if panel.__class__ is panel_class:
524          self.sizer_projctrls.Layout()                      self.nbsizer.Activate(panel)
525          self.Layout()                      self.curProjPanel = panel
         self.topBox.SetSizeHints(self)  
526    
527      def __SetProjection(self):      def __SetProjection(self):
528          """Set the receiver's projection."""          """Set the receiver's projection."""
# Line 568  class ProjFrame(NonModalNonParentDialog) Line 581  class ProjFrame(NonModalNonParentDialog)
581          projfile, warnings = get_system_proj_file()          projfile, warnings = get_system_proj_file()
582          self.show_warnings(_("Warnings"), projfile.GetFilename(), warnings)          self.show_warnings(_("Warnings"), projfile.GetFilename(), warnings)
583          for proj in projfile.GetProjections():          for proj in projfile.GetProjections():
584              self.availprojs.Append(proj.GetName(), [proj, projfile])              self.availprojs.Append(proj.Label(), [proj, projfile])
585          self.__sysProjFile = projfile          self.__sysProjFile = projfile
586    
587          projfile, warnings = get_user_proj_file()          projfile, warnings = get_user_proj_file()
588          self.show_warnings(_("Warnings"), projfile.GetFilename(), warnings)          self.show_warnings(_("Warnings"), projfile.GetFilename(), warnings)
589          for proj in projfile.GetProjections():          for proj in projfile.GetProjections():
590              self.availprojs.Append(proj.GetName(), [proj, projfile])              self.availprojs.Append(proj.Label(), [proj, projfile])
591          self.__usrProjFile = projfile          self.__usrProjFile = projfile
592    
593          #          #
# Line 584  class ProjFrame(NonModalNonParentDialog) Line 597  class ProjFrame(NonModalNonParentDialog)
597          #          #
598          proj = self.receiver.GetProjection()          proj = self.receiver.GetProjection()
599          if proj is not None:          if proj is not None:
600              proj_item = _("%s (current)") % proj.GetName()              proj_item = _("%s (current)") % proj.Label()
601              self.availprojs.Append(proj_item, [proj, None])              self.availprojs.Append(proj_item, [proj, None])
602              if selectCurrent:              if selectCurrent:
603                  self.availprojs.SetSelection(                  self.availprojs.SetSelection(
# Line 679  class UnknownProjPanel(ProjPanel): Line 692  class UnknownProjPanel(ProjPanel):
692          sizer = wxBoxSizer(wxVERTICAL)          sizer = wxBoxSizer(wxVERTICAL)
693    
694          sizer.Add(wxStaticText(self, -1,          sizer.Add(wxStaticText(self, -1,
695                                 _("Thuban does not know the parameters for the"                                 _("Thuban does not know the parameters\n"
696                                   " current projection\n"                                   "for the current projection and cannot\n"
697                                   "and cannot display a configuration panel.")))                                   "display a configuration panel.")))
698    
699          ProjPanel._DoLayout(self, sizer)          ProjPanel._DoLayout(self, sizer)
700    
# Line 710  class TMPanel(ProjPanel): Line 723  class TMPanel(ProjPanel):
723    
724      def _DoLayout(self):      def _DoLayout(self):
725    
726          sizer = wxFlexGridSizer(4, 4, 0, 0)          sizer = wxFlexGridSizer(4, 2, 0, 0)
727          sizer.Add(wxStaticText(self, -1, _("Latitude:")), 0, wxALL, 4)          sizer.Add(wxStaticText(self, -1, _("Latitude:")), 0, wxALL, 4)
728          sizer.Add(self.__latitude, 0, wxALL, 4)          sizer.Add(self.__latitude, 0, wxALL, 4)
         sizer.Add(wxStaticText(self, -1, _("False Easting:")), 0, wxALL, 4)  
         sizer.Add(self.__falseEast, 0, wxALL, 4)  
729          sizer.Add(wxStaticText(self, -1, _("Longitude:")), 0, wxALL, 4)          sizer.Add(wxStaticText(self, -1, _("Longitude:")), 0, wxALL, 4)
730          sizer.Add(self.__longitude, 0, wxALL, 4)          sizer.Add(self.__longitude, 0, wxALL, 4)
731            sizer.Add(wxStaticText(self, -1, _("False Easting:")), 0, wxALL, 4)
732            sizer.Add(self.__falseEast, 0, wxALL, 4)
733          sizer.Add(wxStaticText(self, -1, _("False Northing:")), 0, wxALL, 4)          sizer.Add(wxStaticText(self, -1, _("False Northing:")), 0, wxALL, 4)
734          sizer.Add(self.__falseNorth, 0, wxALL, 4)          sizer.Add(self.__falseNorth, 0, wxALL, 4)
735          sizer.Add(wxStaticText(self, -1, _("Scale Factor:")), 0, wxALL, 4)          sizer.Add(wxStaticText(self, -1, _("Scale Factor:")), 0, wxALL, 4)

Legend:
Removed from v.1806  
changed lines
  Added in v.1819

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26