/[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 1858 by jan, Fri Oct 24 15:12:58 2003 UTC revision 1941 by bh, Tue Nov 11 18:27:48 2003 UTC
# Line 21  from Thuban import _ Line 21  from Thuban import _
21  from Thuban.Model.proj import Projection, ProjFile  from Thuban.Model.proj import Projection, ProjFile
22    
23  from Thuban.Model.resource import get_user_proj_file, get_system_proj_file, \  from Thuban.Model.resource import get_user_proj_file, get_system_proj_file, \
24                                    read_proj_file, write_proj_file                                    read_proj_file, write_proj_file, \
25                                      DEFAULT_PROJ_FILE, EPSG_PROJ_FILE, \
26                                      EPSG_DEPRECATED_PROJ_FILE
27  from Thuban.UI.dialogs import NonModalNonParentDialog  from Thuban.UI.dialogs import NonModalNonParentDialog
28    
29  from common import ThubanBeginBusyCursor, ThubanEndBusyCursor  from common import ThubanBeginBusyCursor, ThubanEndBusyCursor
# Line 60  class ProjFrame(NonModalNonParentDialog) Line 62  class ProjFrame(NonModalNonParentDialog)
62              ("tmerc", _("Transverse Mercator"), TMPanel),              ("tmerc", _("Transverse Mercator"), TMPanel),
63              ("utm", _("Universal Transverse Mercator"), UTMPanel),              ("utm", _("Universal Transverse Mercator"), UTMPanel),
64              ("lcc", _("Lambert Conic Conformal"), LCCPanel),              ("lcc", _("Lambert Conic Conformal"), LCCPanel),
65              ("latlong", _("Geographic"), GeoPanel)]              ("latlong", _("Geographic"), GeoPanel),
66                ("longlat", _("Geographic"), GeoPanel)]#longlat is an alias of proj
67          self.receiver = receiver          self.receiver = receiver
68          self.haveTried = False          self.haveTried = False
69          self.curProjPanel = None          self.curProjPanel = None
70          self.__usrProjFile = None          self.__usrProjFile = None
71          self.__sysProjFile = None          self._sys_proj_files = {}
72    
73          self.build_dialog()          self.build_dialog()
74          self.Layout()          self.Layout()
# Line 93  class ProjFrame(NonModalNonParentDialog) Line 96  class ProjFrame(NonModalNonParentDialog)
96    
97          hbox = wxBoxSizer(wxHORIZONTAL)          hbox = wxBoxSizer(wxHORIZONTAL)
98          vbox.Add(hbox, 1, wxALL|wxEXPAND)          vbox.Add(hbox, 1, wxALL|wxEXPAND)
99          self.projection_list = ProjectionList(self, self.load_system_proj(),          proj_files = [self.load_user_proj(),
100                                                self.load_user_proj(),                        self.load_system_proj(DEFAULT_PROJ_FILE)]
101            self.projection_list = ProjectionList(self, proj_files,
102                                                self.receiver.GetProjection())                                                self.receiver.GetProjection())
103          hbox.Add(self.projection_list, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)          hbox.Add(self.projection_list, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)
104          self.projection_list.Subscribe(PROJ_SELECTION_CHANGED,          self.projection_list.Subscribe(PROJ_SELECTION_CHANGED,
# Line 114  class ProjFrame(NonModalNonParentDialog) Line 118  class ProjFrame(NonModalNonParentDialog)
118          EVT_BUTTON(self, ID_PROJ_REMOVE, self._OnRemove)          EVT_BUTTON(self, ID_PROJ_REMOVE, self._OnRemove)
119          buttons.Add(self.button_remove, 1, wxALL|wxEXPAND, 4)          buttons.Add(self.button_remove, 1, wxALL|wxEXPAND, 4)
120    
121            buttons.Add(20, 20, 0, wxEXPAND, 0)
122            label = wxStaticText(self, -1, _("Show EPSG:"))
123            buttons.Add(label, 0, wxLEFT|wxRIGHT|wxTOP, 4)
124            self.check_epsg = wxCheckBox(self, -1, _("Normal"))
125            EVT_CHECKBOX(self, self.check_epsg.GetId(), self._OnShowEPSG)
126            buttons.Add(self.check_epsg, 1, wxALL|wxEXPAND, 4)
127            self.check_epsg_depr = wxCheckBox(self, -1, _("Deprecated"))
128            EVT_CHECKBOX(self, self.check_epsg_depr.GetId(), self._OnShowEPSG)
129            buttons.Add(self.check_epsg_depr, 1, wxALL|wxEXPAND, 4)
130    
131          # The file path          # The file path
132          self.projfilepath = wxStaticText(self, -1, "")          self.projfilepath = wxStaticText(self, -1, "")
133          vbox.Add(self.projfilepath, 0, wxALL|wxEXPAND)          vbox.Add(self.projfilepath, 0, wxALL|wxEXPAND)
# Line 348  class ProjFrame(NonModalNonParentDialog) Line 362  class ProjFrame(NonModalNonParentDialog)
362          if modified:          if modified:
363              self.write_proj_file(self.__usrProjFile)              self.write_proj_file(self.__usrProjFile)
364    
365        def _OnShowEPSG(self, event):
366            """Handler for the EVT_CHECKBOX events from the EPSG check button
367    
368            If the button is checked add the EPSG_PROJ_FILE to the list of
369            projfiles shown by the projection list. Otherwise remove it
370            """
371            proj_files = [self.load_user_proj(),
372                          self.load_system_proj(DEFAULT_PROJ_FILE)]
373            if self.check_epsg.IsChecked():
374                proj_files.append(self.load_system_proj(EPSG_PROJ_FILE))
375            if self.check_epsg_depr.IsChecked():
376                proj_files.append(self.load_system_proj(EPSG_DEPRECATED_PROJ_FILE))
377            self.projection_list.SetProjFiles(proj_files)
378    
379      def _OnProjName(self, event):      def _OnProjName(self, event):
380          self.__VerifyButtons()          self.__VerifyButtons()
381    
# Line 542  class ProjFrame(NonModalNonParentDialog) Line 570  class ProjFrame(NonModalNonParentDialog)
570          return None          return None
571    
572      def load_user_proj(self):      def load_user_proj(self):
573          ThubanBeginBusyCursor()          """Return the user's ProjFile
574          try:  
575              if self.__usrProjFile is None:          If the file has not yet been loaded by the dialog, load it first
576            with get_user_proj_file and cache it in self.__usrProjFile.
577    
578            Show a busy cursor while loading the file.
579            """
580            if self.__usrProjFile is None:
581                ThubanBeginBusyCursor()
582                try:
583                  projfile, warnings = get_user_proj_file()                  projfile, warnings = get_user_proj_file()
584                  self.show_warnings(_("Warnings"), projfile.GetFilename(),                  self.show_warnings(_("Warnings"), projfile.GetFilename(),
585                                     warnings)                                     warnings)
586                  self.__usrProjFile = projfile                  self.__usrProjFile = projfile
587              return self.__usrProjFile              finally:
588          finally:                  ThubanEndBusyCursor()
589              ThubanEndBusyCursor()          return self.__usrProjFile
590    
591      def load_system_proj(self):      def load_system_proj(self, name):
592          ThubanBeginBusyCursor()          """Load the system ProjFile with the given name.
593          try:  
594              if self.__sysProjFile is None:          If the file has not been loaded yet, load it first with
595                  projfile, warnings = get_system_proj_file()          get_system_proj_file and put it into the cache. The name is
596            simply forwarded to get_system_proj_file.
597    
598            Show a busy cursor while loading the file.
599            """
600            if name not in self._sys_proj_files:
601                ThubanBeginBusyCursor()
602                try:
603                    projfile, warnings = get_system_proj_file(name)
604                  self.show_warnings(_("Warnings"), projfile.GetFilename(),                  self.show_warnings(_("Warnings"), projfile.GetFilename(),
605                                     warnings)                                     warnings)
606                  self.__sysProjFile = projfile                  self._sys_proj_files[name] = projfile
607              return self.__sysProjFile              finally:
608          finally:                  ThubanEndBusyCursor()
609              ThubanEndBusyCursor()          return self._sys_proj_files[name]
610    
611      def write_proj_file(self, proj_file):      def write_proj_file(self, proj_file):
612          """Write the ProjFile object proj_file back to its file          """Write the ProjFile object proj_file back to its file

Legend:
Removed from v.1858  
changed lines
  Added in v.1941

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26