/[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 1167 by jonathan, Thu Jun 12 12:42:34 2003 UTC revision 1566 by bh, Fri Aug 8 13:01:30 2003 UTC
# Line 2  Line 2 
2  # Authors:  # Authors:
3  # Jonathan Coles <[email protected]>  # Jonathan Coles <[email protected]>
4  # Frank Koormann <[email protected]>  # Frank Koormann <[email protected]>
5    # Jan-Oliver Wagner <[email protected]>
6  #  #
7  # This program is free software under the GPL (>=v2)  # This program is free software under the GPL (>=v2)
8  # Read the file COPYING coming with Thuban for details.  # Read the file COPYING coming with Thuban for details.
9                                                                                    
10    """Projection dialog"""
11    
12    __version__ = "$Revision$"
13    # $Source$
14    # $Id$
15    
16  import os, sys, math  import os, sys, math
17  from wxPython.wx import *  from wxPython.wx import *
18    
# Line 129  class ProjFrame(NonModalNonParentDialog) Line 136  class ProjFrame(NonModalNonParentDialog)
136    
137          EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName)          EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName)
138    
   
139      def OnApply(self, event):      def OnApply(self, event):
140          self.__SetProjection()          self.__SetProjection()
141          self.haveTried = True          self.haveTried = True
# Line 149  class ProjFrame(NonModalNonParentDialog) Line 155  class ProjFrame(NonModalNonParentDialog)
155              self.receiver.SetProjection(self.originalProjection)              self.receiver.SetProjection(self.originalProjection)
156              self.haveTried = False              self.haveTried = False
157    
   
158      def _OnNew(self, event):      def _OnNew(self, event):
159    
160          # clear all selections          # clear all selections
# Line 373  class ProjFrame(NonModalNonParentDialog) Line 378  class ProjFrame(NonModalNonParentDialog)
378              if proj is None:              if proj is None:
379                  # user selected <None>                  # user selected <None>
380                  self.projname.Clear()                  self.projname.Clear()
381                                    self.projfilepath.SetLabel(_("Projection File: "))
382              else:              else:
383                            
384                  if projfile is not None:                  if projfile is not None:
385                      self.projfilepath.SetLabel(projfile.GetFilename())                      self.projfilepath.SetLabel(_("Projection File: ") +
386                            os.path.basename(projfile.GetFilename()))
387                  else:                  else:
388                      # only None if the currently used projection is selected                      # only None if the currently used projection is selected
389                      self.projfilepath.SetLabel("")                      self.projfilepath.SetLabel(_("Projection File: "))
390    
391                  self.projname.SetValue(proj.GetName())                  self.projname.SetValue(proj.GetName())
392    
# Line 565  class ProjFrame(NonModalNonParentDialog) Line 571  class ProjFrame(NonModalNonParentDialog)
571          grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0)          grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0)
572          grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)          grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)
573          grid_sizer_1.Add(sizer_15, 0, wxALL|wxEXPAND, 4)          grid_sizer_1.Add(sizer_15, 0, wxALL|wxEXPAND, 4)
574          grid_sizer_1.Add(self.projfilepath, 0, wxALL|wxADJUST_MINSIZE, 4)          grid_sizer_1.Add(self.projfilepath, 0, wxEXPAND|wxALL|wxADJUST_MINSIZE, 4)
575          grid_sizer_1.AddGrowableRow(1)          grid_sizer_1.AddGrowableRow(1)
576          grid_sizer_1.AddGrowableCol(0)          grid_sizer_1.AddGrowableCol(0)
577    
# Line 826  class UTMPanel(ProjPanel): Line 832  class UTMPanel(ProjPanel):
832          ProjPanel.Clear(self)          ProjPanel.Clear(self)
833    
834      def _OnPropose(self, event):      def _OnPropose(self, event):
835          UTMProposeZoneDialog          """Call the propose dialog.
836            If the receiver (e.g. the current map) has no bounding box,
837            inform the user accordingly.
838            """
839            bb = self.receiver.BoundingBox()
840            if bb is None:
841                dlg = wxMessageDialog(self,
842                        _("Can not propose: No bounding box found."),
843                        _("Projection: Propose UTM Zone"),
844                        wxOK | wxICON_INFORMATION)
845                dlg.CenterOnParent()
846                result = dlg.ShowModal()
847                dlg.Destroy()
848                return
849    
850          dlg = UTMProposeZoneDialog(self, self.receiver.BoundingBox())          dlg = UTMProposeZoneDialog(self, self.receiver.BoundingBox())
851          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
852              self.__zone.SetValue(dlg.GetProposedZone())              self.__zone.SetValue(dlg.GetProposedZone())
# Line 953  class GeoPanel(ProjPanel): Line 973  class GeoPanel(ProjPanel):
973  ID_UTM_PROPOSE_ZONE_DIALOG_TAKE   = 4001  ID_UTM_PROPOSE_ZONE_DIALOG_TAKE   = 4001
974  ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002  ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002
975  class UTMProposeZoneDialog(wxDialog):  class UTMProposeZoneDialog(wxDialog):
976                                                                                    
977      """Propose a sensible Zone considering the current map extent."""      """Propose a sensible Zone considering the current map extent."""
978                                                                                    
979      def __init__(self, parent, (x, y, x2, y2)):      def __init__(self, parent, (x, y, x2, y2)):
980          wxDialog.__init__(self, parent, -1, _("Projection: Propose UTM Zone"),          wxDialog.__init__(self, parent, -1, _("Projection: Propose UTM Zone"),
981                            wxDefaultPosition, wxSize(200, 100))                            wxDefaultPosition, wxSize(200, 100))
982          self.parent = parent          self.parent = parent
         #x, y, x2, y2 = elf.parent.parent.map_bounding_box  
983          x = x + 180          x = x + 180
984          x2 = x2 + 180          x2 = x2 + 180
985          center = (x2 - x) / 2 + x          center = (x2 - x) / 2 + x
986          self.proposedZone = int(center / 6 + 1)          self.proposedZone = int(center / 6 + 1)
987          self.dialogLayout()          self.dialogLayout()
988                                                                                    
989      def dialogLayout(self):      def dialogLayout(self):
990          topBox = wxBoxSizer(wxVERTICAL)          topBox = wxBoxSizer(wxVERTICAL)
991                                                                                    
992          textBox = wxBoxSizer(wxVERTICAL)          textBox = wxBoxSizer(wxVERTICAL)
993          textBox.Add(wxStaticText(self, -1, _("The current map extent center " +          textBox.Add(wxStaticText(self, -1, _("The current map extent center "
994                                             "lies in UTM Zone")),                                               "lies in UTM Zone")),
995                      0, wxALIGN_CENTER|wxALL, 4)                      0, wxALIGN_CENTER|wxALL, 4)
996          textBox.Add(wxStaticText(self, -1, str(self.proposedZone)),          textBox.Add(wxStaticText(self, -1, str(self.proposedZone)),
997                      0, wxALIGN_CENTER|wxALL, 4)                      0, wxALIGN_CENTER|wxALL, 4)
998                                                                                    
999          topBox.Add(textBox, 1, wxEXPAND|wxALL, 4)          topBox.Add(textBox, 1, wxEXPAND|wxALL, 4)
1000                                                                                    
1001          buttonBox = wxBoxSizer(wxHORIZONTAL)          buttonBox = wxBoxSizer(wxHORIZONTAL)
1002          buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE,          buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE,
1003                        _("Take")), 0, wxALL, 4)                        _("Take")), 0, wxALL, 4)
# Line 987  class UTMProposeZoneDialog(wxDialog): Line 1006  class UTMProposeZoneDialog(wxDialog):
1006          topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)          topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)
1007          EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, self.OnTake)          EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, self.OnTake)
1008          EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL, self.OnCancel)          EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL, self.OnCancel)
1009                                                                                    
1010          self.SetAutoLayout(True)          self.SetAutoLayout(True)
1011          self.SetSizer(topBox)          self.SetSizer(topBox)
1012          topBox.Fit(self)          topBox.Fit(self)
1013          topBox.SetSizeHints(self)          topBox.SetSizeHints(self)
1014                                                                                    
1015      def OnTake(self, event):      def OnTake(self, event):
1016          self.EndModal(wxID_OK)          self.EndModal(wxID_OK)
1017                                                                                    
1018      def OnCancel(self, event):      def OnCancel(self, event):
1019          self.EndModal(wxID_CANCEL)          self.EndModal(wxID_CANCEL)
1020    

Legend:
Removed from v.1167  
changed lines
  Added in v.1566

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26