/[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 717 by jonathan, Wed Apr 23 08:59:57 2003 UTC revision 747 by jonathan, Fri Apr 25 11:02:08 2003 UTC
# Line 1  Line 1 
1  #!/usr/bin/env python  #!/usr/bin/env python
2  # generated by wxGlade 0.2.1 on Thu Apr 17 11:51:39 2003  # generated by wxGlade 0.2.1 on Thu Apr 17 11:51:39 2003
3    
4    import os, sys
5  from wxPython.wx import *  from wxPython.wx import *
6    
7  from Thuban import _  from Thuban import _
8    
9  from Thuban.Model.proj import Projection  from Thuban.Model.proj import Projection, ProjFile
10    
11  from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles  from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles, \
12                                      ReadProjFile, WriteProjFile
13  from Thuban.UI.dialogs import NonModalDialog  from Thuban.UI.dialogs import NonModalDialog
14    
15    
16  ID_PROJ_ADVANCED  = 4001  ID_PROJ_ADVANCED  = 4001
17  ID_PROJ_PROJCHOICE = 4002  ID_PROJ_PROJCHOICE = 4002
18  ID_PROJ_SAVEAS    = 4003  ID_PROJ_ADDTOLIST    = 4003
19  ID_PROJ_NEW       = 4004  ID_PROJ_NEW       = 4004
20  ID_PROJ_TRY       = 4005  ID_PROJ_TRY       = 4005
21  ID_PROJ_REVERT    = 4006  ID_PROJ_REVERT    = 4006
22  ID_PROJ_OK        = 4007  ID_PROJ_OK        = 4007
23  ID_PROJ_CLOSE     = 4008  ID_PROJ_CLOSE     = 4008
24  ID_PROJ_AVAIL     = 4009  ID_PROJ_AVAIL     = 4009
25    ID_PROJ_SAVE      = 4010
26    ID_PROJ_IMPORT    = 4011
27    ID_PROJ_EXPORT    = 4012
28    ID_PROJ_REMOVE    = 4013
29    ID_PROJ_PROJNAME  = 4014
30    
31    CLIENT_PROJ = 0
32    CLIENT_PROJFILE = 1
33    
34  class ProjFrame(NonModalDialog):  class ProjFrame(NonModalDialog):
35    
   
36      def __init__(self, parent, name, receiver, *args, **kwds):      def __init__(self, parent, name, receiver, *args, **kwds):
37          #          """Initialize the projection dialog.
         # Changes to the wxGlade generated code:  
         #   o   call NonModalDialog.__init__(self, parent, name, "")  
         #   o   remove default choices in combo box  
         #  
38    
39          self.editing = False          receiver -- An object that implements the following methods:
40                            SetProjection(projection)
41                            GetProjection()
42            """
43            
44          self.receiver = receiver          self.receiver = receiver
45          self.originalProjection = -1          self.originalProjection = -1
46          self.curProjPanel = None          self.curProjPanel = None
47    
48          self.projPanels = []          self.projPanels = []
49          self.projPanels.append(          self.projPanels.append(
50              ("tmerc", _("Transverse Mercartor"), TMPanel))              ("tmerc", _("Transverse Mercator"), TMPanel))
51          self.projPanels.append(          self.projPanels.append(
52              ("utm", _("Universal Transverse Mercartor"), UTMPanel))              ("utm", _("Universal Transverse Mercator"), UTMPanel))
53          self.projPanels.append(          self.projPanels.append(
54              ("lcc", _("Lambert Conic Conformal"), LCCPanel))              ("lcc", _("Lambert Conic Conformal"), LCCPanel))
55          self.projPanels.append(          self.projPanels.append(
56              ("latlong", _("Geographic"), GeoPanel))              ("latlong", _("Geographic"), GeoPanel))
57    
         # begin wxGlade: ProjFrame.__init__  
         #kwds["style"] = wxDEFAULT_FRAME_STYLE  
58          NonModalDialog.__init__(self, parent, name, "")          NonModalDialog.__init__(self, parent, name, "")
59            # originally generate by wxGlade
60          self.panel_1 = wxPanel(self, -1)          self.panel_1 = wxPanel(self, -1)
61            self.panel_edit = wxPanel(self, -1)
62            self.panel_buttons = wxPanel(self, -1)
63          self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:"))          self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:"))
64          self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_SINGLE|wxLB_SORT)          self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_EXTENDED|wxLB_SORT)
65          self.button_advanced = wxButton(self.panel_1, ID_PROJ_ADVANCED, _("Advanced >>"))          self.projfilepath = wxStaticText(self.panel_1, -1, "")
66          self.label_2 = wxStaticText(self.panel_1, -1, _("Name:"))          self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:"))
67          self.projname = wxTextCtrl(self.panel_1, -1, "")          self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "")
68          self.label_3 = wxStaticText(self.panel_1, -1, _("Projection:"))          self.label_3 = wxStaticText(self.panel_edit, -1, _("Projection:"))
69          self.projchoice = wxChoice(self.panel_1, ID_PROJ_PROJCHOICE)          self.projchoice = wxChoice(self.panel_edit, ID_PROJ_PROJCHOICE)
70          self.button_new = wxButton(self.panel_1, ID_PROJ_NEW, _("New"))          self.button_import = wxButton(self.panel_1, ID_PROJ_IMPORT, _("Import..."))
71          self.button_saveas = wxButton(self.panel_1, ID_PROJ_SAVEAS, _("Save"))          self.button_export = wxButton(self.panel_1, ID_PROJ_EXPORT, _("Export..."))
72          self.button_try = wxButton(self.panel_1, ID_PROJ_TRY, _("Try"))          self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove"))
73          self.button_revert = wxButton(self.panel_1, ID_PROJ_REVERT, _("Revert"))          self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New"))
74          self.button_ok = wxButton(self.panel_1, ID_PROJ_OK, _("OK"))          self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Save"))
75          self.button_close = wxButton(self.panel_1, ID_PROJ_CLOSE, _("Close"))          self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST,
76                                          _("Add to List"))
77            self.button_try = wxButton(self.panel_buttons, ID_PROJ_TRY, _("Try"))
78            self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, _("Revert"))
79            self.button_ok = wxButton(self.panel_buttons, ID_PROJ_OK, _("OK"))
80            self.button_close = wxButton(self.panel_buttons, ID_PROJ_CLOSE, _("Close"))
81    
82          self.__set_properties()          self.__set_properties()
83          self.__do_layout()          self.__do_layout()
84          # end wxGlade          # wxGlade
   
         self.sizer_edit.GetStaticBox().Show(False)  
         self.sizer_mainctrls.Show(self.sizer_edit, False)  
         self.topBox.Layout()  
85    
86            self.__DoOnProjAvail()
87            
88          EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry)          EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry)
89          EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert)          EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert)
90          EVT_BUTTON(self, ID_PROJ_OK, self._OnOK)          EVT_BUTTON(self, ID_PROJ_OK, self._OnOK)
91          EVT_BUTTON(self, ID_PROJ_CLOSE, self._OnClose)          EVT_BUTTON(self, ID_PROJ_CLOSE, self._OnClose)
         EVT_BUTTON(self, ID_PROJ_ADVANCED, self._OnAdvanced)  
92          EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice)          EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice)
93          EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail)          EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail)
94            EVT_BUTTON(self, ID_PROJ_IMPORT, self._OnImport)
95            EVT_BUTTON(self, ID_PROJ_EXPORT, self._OnExport)
96            EVT_BUTTON(self, ID_PROJ_REMOVE, self._OnRemove)
97    
98          EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew)          EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew)
99          EVT_BUTTON(self, ID_PROJ_SAVEAS, self._OnSave)          EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave)
100            EVT_BUTTON(self, ID_PROJ_ADDTOLIST, self._OnAddToList)
101    
102            EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName)
103    
104      def GetReceiver(self):      def GetReceiver(self):
105          return self.receiver          return self.receiver
# Line 100  class ProjFrame(NonModalDialog): Line 118  class ProjFrame(NonModalDialog):
118      def _OnClose(self, event):      def _OnClose(self, event):
119          self.Close()          self.Close()
120    
121      def _OnAdvanced(self, event):      def _OnNew(self, event):
122          self.sizer_edit.GetStaticBox().Show(True)          self.__DoOnNew()
123          self.sizer_mainctrls.Show(self.sizer_edit, True)  
124          self.topBox.Fit(self)      def _OnSave(self, event):
         self.topBox.SetSizeHints(self)  
         self.topBox.Layout()  
125    
126          self.editing = True          sel = self.availprojs.GetSelections()
127            assert len(sel) == 1,  "button shouldn't be enabled"
128    
129          self.__DoOnProjAvail()          proj, projfile = self.availprojs.GetClientData(sel[0])
130    
131          self.button_advanced.Enable(False)          assert proj is not None and projfile is not None
132    
133      def _OnNew(self, event):          newproj = self.__GetProjection()
         print "_OnNew"  
         self.availprojs.SetSelection(-1)  
         self.projname.Clear()  
         self.curProjPanel.Clear()  
134    
135      def _OnSave(self, event):          if newproj is not None:
136          print "_OnSave"              projfile.Remove(proj)
137                projfile.Add(newproj)
138                try:
139                    WriteProjFile(projfile)
140                except IOError, (errno, errstr):
141                    wxMessageDialog(self,
142                        _("The following error occured:\n") +
143                        projfile.GetFilename() + "\n" + errstr,
144                        _("Error"), wxOK | wxICON_ERROR).ShowModal()
145                self.__FillAvailList()
146    
147        def _OnAddToList(self, event):
148    
149            proj = self.__GetProjection()
150            if proj is not None:
151                self.__usrProjFile.Add(proj)
152                try:
153                    WriteProjFile(self.__usrProjFile)
154                except IOError, (errno, errstr):
155                    wxMessageDialog(self,
156                        _("The following error occured:\n") +
157                        self.__usrProjFile.GetFilename() + "\n" + errstr,
158                        _("Error"), wxOK | wxICON_ERROR).ShowModal()
159                self.__FillAvailList()
160    
161      def _OnProjAvail(self, event):      def _OnProjAvail(self, event):
162          self.__DoOnProjAvail()          self.__DoOnProjAvail()
163    
164        def _OnImport(self, event):
165    
166            dlg = wxFileDialog(self, _("Import"), style = wxOPEN)
167    
168            if dlg.ShowModal() == wxID_OK:
169                path = dlg.GetPath()
170    
171                try:
172                    projFile = ReadProjFile(path)
173                    for proj in projFile.GetProjections():
174                        self.__usrProjFile.Add(proj)
175                    WriteProjFile(self.__usrProjFile)
176                except IOError, (errno, errstr):
177                    wxMessageDialog(self,
178                        _("The following error occured:\n") +
179                        dlg.GetPath() + "\n" + errstr,
180                        _("Error"), wxOK | wxICON_ERROR).ShowModal()
181    
182                self.__FillAvailList()
183    
184            dlg.Destroy()
185    
186        def _OnExport(self, event):
187    
188            sel = self.availprojs.GetSelections()
189            assert len(sel) != 0, "button should be disabled"
190    
191            dlg = wxFileDialog(self, _("Export"),
192                            style = wxSAVE|wxOVERWRITE_PROMPT)
193    
194            if dlg.ShowModal() == wxID_OK:
195                path = dlg.GetPath()
196    
197                projFile = ProjFile(path)
198    
199                for i in sel:
200                    proj = self.availprojs.GetClientData(i)[CLIENT_PROJ]
201                    if proj is not None:
202                        projFile.Add(proj)
203    
204                try:
205                    WriteProjFile(projFile)
206                except IOError, (errno, errstr):
207                    wxMessageDialog(self,
208                        _("The following error occured:\n") +
209                        dlg.GetPath() + "\n" + errstr,
210                        _("Error"), wxOK | wxICON_ERROR).ShowModal()
211    
212            dlg.Destroy()
213    
214        def _OnRemove(self, event):
215    
216            sel = self.availprojs.GetSelections()
217            assert len(sel) != 0, "button should be disabled!"
218    
219            #
220            # remove the items backwards so the indices don't change
221            #
222            sel = list(sel)
223            sel.sort()
224            sel.reverse()
225    
226            newselection = -1
227            if len(sel) == 1:
228                newselection = sel[0] - 1
229                if newselection < 0:
230                    newselection = 0
231    
232            for i in sel:
233                proj, projfile = self.availprojs.GetClientData(i)
234    
235                #
236                # this could be the case if they selected <None> or
237                # the currently used projection
238                #
239                if proj is not None and projfile is not None:
240                    projfile.Remove(proj)
241    
242            try:
243                WriteProjFile(projfile)
244            except IOError, (errno, errstr):
245                wxMessageDialog(self,
246                    _("The following error occured:\n") +
247                    projfile.GetFilename() + "\n" + errstr,
248                    _("Error"), wxOK | wxICON_ERROR).ShowModal()
249    
250    
251            self.__FillAvailList()
252    
253            #
254            # this *could* produce incorrect results if the .proj files
255            # change between the last list update and this selection
256            # because the list has been repopulated.
257            #
258            if newselection != -1 and self.availprojs.GetCount() > 0:
259                self.availprojs.SetSelection(newselection)
260    
261        def _OnProjName(self, event):
262            self.__VerifyButtons()
263    
264        def __VerifyButtons(self):
265            sel = self.availprojs.GetSelections()
266    
267            self.button_import.Enable(True)
268            self.button_export.Enable(True)
269            self.button_save.Enable(True)
270            self.button_remove.Enable(True)
271    
272            self.panel_edit.Enable(True)
273    
274            if len(sel) == 0:
275                self.button_import.Enable(True)
276                self.button_export.Enable(False)
277                self.button_remove.Enable(False)
278    
279            elif len(sel) == 1:
280    
281                proj, projFile = self.availprojs.GetClientData(sel[0])
282    
283                self.button_save.Enable(len(self.projname.GetValue()) > 0)
284                self.button_add.Enable(len(self.projname.GetValue()) > 0)
285    
286                if proj is None:
287                    self.button_export.Enable(False)
288                    self.button_remove.Enable(False)
289    
290                if projFile is None:
291                    self.button_save.Enable(False)
292    
293            else:
294                self.panel_edit.Enable(False)
295    
296        def __DoOnNew(self):
297            sel = self.availprojs.GetSelections()
298            if len(sel) != 0:
299                self.availprojs.SetSelection(sel, False)
300            self.projname.Clear()
301            self.curProjPanel.Clear()
302    
303      def __DoOnProjAvail(self):      def __DoOnProjAvail(self):
         print "_OnProjAvail"  
304    
305          if not self.editing: return          sel = self.availprojs.GetSelections()
306            if len(sel) == 1:
307    
308                proj = self.availprojs.GetClientData(sel[0])[CLIENT_PROJ]
309                projfile = self.availprojs.GetClientData(sel[0])[CLIENT_PROJFILE]
310    
311          sel = self.availprojs.GetSelection()              if proj is None:
312          if sel == -1: return                  # user selected <None>
313                    self.projname.Clear()
314                else:
315                
316                    if projfile is not None:
317                        self.projfilepath.SetLabel(projfile.GetFilename())
318                    else:
319                        # only None if the currently used projection is selected
320                        self.projfilepath.SetLabel("")
321    
322                    self.projname.SetValue(proj.GetName())
323    
324                    myProjType = proj.GetParameter("proj")
325                    i = 0
326                    for projType, name, clazz in self.projPanels:
327                        if myProjType == projType:
328                            self.projchoice.SetSelection(i)
329                            self.__DoOnProjChoice()
330                            self.curProjPanel.SetProjection(proj)
331                        i += 1
332    
333          proj = self.availprojs.GetClientData(sel)          self.__VerifyButtons()
         assert proj != None  
   
         self.projname.SetValue(proj.GetName())  
   
         myProjType = proj.GetParameter("proj")  
         i = 0  
         for projType, name, clazz in self.projPanels:  
             if myProjType == projType:  
                 self.projchoice.SetSelection(i)  
                 self.__DoOnProjChoice()  
                 self.curProjPanel.SetProjection(proj)  
             i += 1  
334    
335      def _OnProjChoice(self, event):      def _OnProjChoice(self, event):
336          self.__DoOnProjChoice()          self.__DoOnProjChoice()
337    
338      def __DoOnProjChoice(self):      def __DoOnProjChoice(self):
         print "_OnProjChoice()"  
339          choice = self.projchoice          choice = self.projchoice
340    
341          sel = choice.GetSelection()          sel = choice.GetSelection()
342          if sel == -1: return          if sel != -1:
   
         clazz, obj = choice.GetClientData(choice.GetSelection())  
343    
344          if obj is None:              clazz, obj = choice.GetClientData(sel)
             obj = clazz(self)  
             choice.SetClientData(sel, [clazz, obj])  
345    
346          if self.curProjPanel is not None:              if obj is None:
347              self.curProjPanel.Hide()                  obj = clazz(self.panel_edit, self.receiver)
348              self.sizer_projctrls.Remove(self.curProjPanel)                  choice.SetClientData(sel, [clazz, obj])
349    
350          self.curProjPanel = obj              if self.curProjPanel is not None:
351          self.curProjPanel.Show()                  self.curProjPanel.Hide()
352                    self.sizer_projctrls.Remove(self.curProjPanel)
         print "++", self.topBox.GetSize(), self.GetSize()  
         print "!!", self.sizer_projctrls.GetSize(), \  
                     self.sizer_edit.GetSize(), \  
                     self.sizer_mainctrls.GetSize(), \  
                     self.sizer_panel.GetSize()  
         self.sizer_projctrls.Add(self.curProjPanel, 1, wxALL|wxEXPAND, 3)  
         #print "$$", self.sizer_projctrls.GetSize()  
 #       self.topBox.Fit(self)  
 #       self.topBox.SetSizeHints(self)  
 #       self.topBox.Layout()  
   
         self.sizer_panel.SetSizeHints(self.panel_1)  
         w, h = self.sizer_panel.GetSize()  
         self.topBox.SetDimension(0, 0, w, h)  
353    
354          #self.sizer_panel.Fit(self.panel_1)              self.curProjPanel = obj
355          self.topBox.Fit(self)              self.curProjPanel.Show()
         #self.SetAutoLayout(1)  
         self.topBox.SetSizeHints(self)  
         self.SetSize(self.topBox.GetSize())  
         print "!!", self.sizer_projctrls.GetSize(), \  
                     self.sizer_edit.GetSize(), \  
                     self.sizer_mainctrls.GetSize(), \  
                     self.sizer_panel.GetSize()  
         print "--", self.topBox.GetSize(), self.GetSize()  
356    
357                                self.sizer_projctrls.Add(self.curProjPanel, 1,
358                    wxALL|wxEXPAND|wxADJUST_MINSIZE, 3)
359                self.sizer_projctrls.Layout()
360                self.Layout()
361                self.topBox.SetSizeHints(self)
362    
363      def __SetProjection(self):      def __SetProjection(self):
364    
# Line 207  class ProjFrame(NonModalDialog): Line 369  class ProjFrame(NonModalDialog):
369          if self.originalProjection == -1:          if self.originalProjection == -1:
370              self.originalProjection = self.receiver.GetProjection()              self.originalProjection = self.receiver.GetProjection()
371    
372          sel = self.availprojs.GetSelection()          self.receiver.SetProjection(self.__GetProjection())
         proj = -1  
373    
374          if self.editing:      def __GetProjection(self):
375              if self.curProjPanel is not None:          """Return the packaged projection.
                 proj = Projection(self.curProjPanel.GetParameters())  
         elif sel != -1:  
             proj = self.availprojs.GetClientData(sel)  
   
         if proj != -1:  
             if proj is not None:  
                 print proj.GetAllParameters()  
             self.receiver.SetProjection(proj)  
376    
377            Could be None.
378            """
379    
380      def __set_properties(self):          proj = None
         self.availprojs.Append("<None>", None)  
381    
382          projfiles = GetSystemProjFiles()          if self.curProjPanel is not None:
383          for projfile in projfiles:              proj = Projection(self.curProjPanel.GetParameters())
384              for proj in projfile.GetProjections():              proj.SetName(self.projname.GetValue())
                 self.availprojs.Append(proj.GetName(), proj)  
385    
386          projfiles = GetUserProjFiles()          return proj
         for projfile in projfiles:  
             for proj in projfile.GetProjections():  
                 self.availprojs.Append(proj.GetName(), proj)  
387    
388        def __FillAvailList(self, selectCurrent = False):
389            self.availprojs.Clear()
390    
391            #
392            # We add the current projection to the list first so that
393            # we are sure that it's at index 0. That way we can
394            # set the selection with confidence. The problem is the
395            # the list is automatically sorted when an item is appended
396            # and the index of where it was inserted is not returned.
397            #
398          proj = self.receiver.GetProjection()          proj = self.receiver.GetProjection()
399          if proj is not None:          if proj is not None:
400              self.availprojs.Append("## " + proj.GetName() + " ##", proj)              self.availprojs.Append(_("%s (current)") % proj.GetName(),
401                                       [proj, None])
402                if selectCurrent:
403                    self.availprojs.SetSelection(0)
404                    self.availprojs.SetFirstItem(0)
405    
406            #
407            # the list can never be empty. there will always be
408            # at least this one item
409            #
410            self.availprojs.Append("<None>", (None, None))
411    
412            self.__sysProjFile = None
413            self.__usrProjFile = None
414    
415            projfile = GetSystemProjFiles()
416            if len(projfile) > 0:
417                projfile = projfile[0]
418                for proj in projfile.GetProjections():
419                    self.availprojs.Append(proj.GetName(), [proj, projfile])
420                self.__sysProjFile = projfile
421    
422            projfile = GetUserProjFiles()
423            if len(projfile) > 0:
424                projfile = projfile[0]
425                for proj in projfile.GetProjections():
426                    self.availprojs.Append(proj.GetName(), [proj, projfile])
427                self.__usrProjFile = projfile
428    
429          for proj, name, clazz in self.projPanels:          for proj, name, clazz in self.projPanels:
430              self.projchoice.Append(name, [clazz, None])              self.projchoice.Append(name, [clazz, None])
431    
432          # begin wxGlade: ProjFrame.__set_properties      def __set_properties(self):
433    
434          self.SetTitle(_("Projections"))          self.SetTitle(_("Projections"))
435          self.availprojs.SetSelection(0)          self.availprojs.SetSelection(0)
436          self.projchoice.SetSelection(0)          self.projchoice.SetSelection(0)
437          # end wxGlade  
438            self.__FillAvailList(selectCurrent = True)
439    
440            self.projname.SetMaxLength(32)
441    
442      def __do_layout(self):      def __do_layout(self):
443          # begin wxGlade: ProjFrame.__do_layout          # originally generated by wxGlade
444    
445          self.topBox = wxBoxSizer(wxVERTICAL)          self.topBox = wxBoxSizer(wxVERTICAL)
446          self.sizer_panel = wxBoxSizer(wxVERTICAL)          self.sizer_panel = wxBoxSizer(wxVERTICAL)
447          sizer_6 = wxBoxSizer(wxHORIZONTAL)          sizer_6 = wxBoxSizer(wxHORIZONTAL)
448          self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL)          self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL)
449          self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_1, -1, _("Edit")), wxHORIZONTAL)          self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_edit, -1, _("Edit")), wxHORIZONTAL)
450          sizer_11 = wxBoxSizer(wxVERTICAL)          sizer_11 = wxBoxSizer(wxVERTICAL)
451          self.sizer_projctrls = wxBoxSizer(wxVERTICAL)          self.sizer_projctrls = wxBoxSizer(wxVERTICAL)
452          sizer_14 = wxBoxSizer(wxHORIZONTAL)          sizer_14 = wxBoxSizer(wxHORIZONTAL)
453          sizer_13 = wxBoxSizer(wxHORIZONTAL)          sizer_13 = wxBoxSizer(wxHORIZONTAL)
454          grid_sizer_1 = wxFlexGridSizer(2, 2, 0, 0)          sizer_15 = wxBoxSizer(wxVERTICAL)
455            sizer_15.Add(self.button_import, 0, wxALL, 4)
456            sizer_15.Add(self.button_export, 0, wxALL, 4)
457            sizer_15.Add(20, 20, 0, wxEXPAND, 0)
458            sizer_15.Add(self.button_remove, 0, wxALL|wxALIGN_BOTTOM, 4)
459    
460            # list controls
461            grid_sizer_1 = wxFlexGridSizer(3, 2, 0, 0)
462          grid_sizer_1.Add(self.label_5, 0, wxLEFT|wxRIGHT|wxTOP, 4)          grid_sizer_1.Add(self.label_5, 0, wxLEFT|wxRIGHT|wxTOP, 4)
463          grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0)          grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0)
464          grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND, 4)          grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)
465          grid_sizer_1.Add(self.button_advanced, 0, wxALL, 4)          grid_sizer_1.Add(sizer_15, 0, wxALL|wxEXPAND, 4)
466            grid_sizer_1.Add(self.projfilepath, 0, wxALL|wxADJUST_MINSIZE, 4)
467          grid_sizer_1.AddGrowableRow(1)          grid_sizer_1.AddGrowableRow(1)
468          grid_sizer_1.AddGrowableCol(0)          grid_sizer_1.AddGrowableCol(0)
469          self.sizer_mainctrls.Add(grid_sizer_1, 1, wxEXPAND, 0)  
470            # edit controls
471          sizer_13.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)          sizer_13.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)
472          sizer_13.Add(self.projname, 1, wxALL, 4)          sizer_13.Add(self.projname, 1, wxALL, 4)
473          self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0)          self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0)
474          sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)          sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)
475          sizer_14.Add(self.projchoice, 1, wxALL|wxEXPAND, 4)          sizer_14.Add(self.projchoice, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)
476          self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0)          self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0)
477          self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0)          self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0)
478          sizer_11.Add(self.button_new, 0, wxALL|wxEXPAND, 4)          sizer_11.Add(self.button_new, 0, wxALL|wxEXPAND, 4)
479          sizer_11.Add(self.button_saveas, 0, wxALL|wxEXPAND, 4)          sizer_11.Add(self.button_save, 0, wxALL|wxEXPAND, 4)
480            sizer_11.Add(self.button_add, 0, wxALL|wxEXPAND, 4)
481          self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4)          self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4)
482          self.sizer_mainctrls.Add(self.sizer_edit, 0, wxALL|wxEXPAND, 4)  
         self.sizer_panel.Add(self.sizer_mainctrls, 1, wxEXPAND, 0)  
483          sizer_6.Add(20, 20, 1, wxEXPAND, 0)          sizer_6.Add(20, 20, 1, wxEXPAND, 0)
484          sizer_6.Add(self.button_try, 0, wxALL, 4)          sizer_6.Add(self.button_try, 0, wxALL, 4)
485          sizer_6.Add(20, 20, 1, 0, 0)          sizer_6.Add(20, 20, 1, 0, 0)
# Line 288  class ProjFrame(NonModalDialog): Line 489  class ProjFrame(NonModalDialog):
489          sizer_6.Add(20, 20, 1, 0, 0)          sizer_6.Add(20, 20, 1, 0, 0)
490          sizer_6.Add(self.button_close, 0, wxALL, 4)          sizer_6.Add(self.button_close, 0, wxALL, 4)
491          sizer_6.Add(20, 20, 1, wxEXPAND, 0)          sizer_6.Add(20, 20, 1, wxEXPAND, 0)
492          self.sizer_panel.Add(sizer_6, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 0)  
493          self.panel_1.SetAutoLayout(1)          self.panel_1.SetAutoLayout(1)
494          self.panel_1.SetSizer(self.sizer_panel)          self.panel_1.SetSizer(grid_sizer_1)
495          self.sizer_panel.Fit(self.panel_1)          grid_sizer_1.Fit(self.panel_1)
496          self.sizer_panel.SetSizeHints(self.panel_1)          grid_sizer_1.SetSizeHints(self.panel_1)
497          self.topBox.Add(self.panel_1, 1, wxEXPAND, 0)  
498            self.panel_edit.SetAutoLayout(1)
499            self.panel_edit.SetSizer(self.sizer_edit)
500            self.sizer_edit.Fit(self.panel_edit)
501            self.sizer_edit.SetSizeHints(self.panel_edit)
502    
503            self.panel_buttons.SetAutoLayout(1)
504            self.panel_buttons.SetSizer(sizer_6)
505            sizer_6.Fit(self.panel_buttons)
506            sizer_6.SetSizeHints(self.panel_buttons)
507    
508            self.sizer_mainctrls.Add(self.panel_1, 0,
509                wxALL|wxEXPAND|wxADJUST_MINSIZE, 0)
510            self.sizer_mainctrls.Add(self.panel_edit, 1,
511                wxALL|wxEXPAND|wxADJUST_MINSIZE, 0)
512    
513            self.topBox.Add(self.sizer_mainctrls, 1, wxALL|wxEXPAND, 4)
514            self.topBox.Add(self.panel_buttons, 0, wxEXPAND, 0)
515    
516          self.SetAutoLayout(1)          self.SetAutoLayout(1)
517          self.SetSizer(self.topBox)          self.SetSizer(self.topBox)
518          self.topBox.Fit(self)          self.topBox.Fit(self)
519          self.topBox.SetSizeHints(self)          self.topBox.SetSizeHints(self)
520          self.Layout()          self.Layout()
         # end wxGlade  
521    
522  # end of class ProjFrame  # end of class ProjFrame
523    
# Line 332  class ProjPanel(wxPanel): Line 550  class ProjPanel(wxPanel):
550                            
551          sizer = wxBoxSizer(wxHORIZONTAL)          sizer = wxBoxSizer(wxHORIZONTAL)
552          sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4)          sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4)
553          sizer.Add(self.__ellps, 1, wxALL|wxEXPAND, 4)          sizer.Add(self.__ellps, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)
554          panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4)          panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4)
555    
556          self.SetAutoLayout(1)          self.SetAutoLayout(1)
# Line 357  class ProjPanel(wxPanel): Line 575  class ProjPanel(wxPanel):
575          self.__ellps.SetSelection(0)          self.__ellps.SetSelection(0)
576    
577      def GetParameters(self):      def GetParameters(self):
         print "asdfsdf"  
578          return ["ellps=" + self.__ellps.GetClientData(          return ["ellps=" + self.__ellps.GetClientData(
579                                          self.__ellps.GetSelection())]                                          self.__ellps.GetSelection())]
580    
# Line 369  ID_TMPANEL_FALSE_NORTH = 4004 Line 586  ID_TMPANEL_FALSE_NORTH = 4004
586  ID_TMPANEL_SCALE = 4005  ID_TMPANEL_SCALE = 4005
587    
588  class UnknownProjPanel(ProjPanel):  class UnknownProjPanel(ProjPanel):
589      def __init__(self, parent):      def __init__(self, parent, receiver):
590          ProjPanel.__init__(self, parent)          ProjPanel.__init__(self, parent)
591    
592          self._DoLayout()          self._DoLayout()
# Line 394  class UnknownProjPanel(ProjPanel): Line 611  class UnknownProjPanel(ProjPanel):
611          return None          return None
612    
613  class TMPanel(ProjPanel):  class TMPanel(ProjPanel):
614      """Projection panel for Transverse Mercartor."""      """Projection panel for Transverse Mercator."""
615    
616      def __init__(self, parent):      def __init__(self, parent, receiver):
617          ProjPanel.__init__(self, parent)          ProjPanel.__init__(self, parent)
618    
619          self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT)          self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT)
# Line 424  class TMPanel(ProjPanel): Line 641  class TMPanel(ProjPanel):
641          ProjPanel._DoLayout(self, sizer)          ProjPanel._DoLayout(self, sizer)
642    
643      def GetProjName(self):      def GetProjName(self):
644          return _("Transverse Mercartor")          return _("Transverse Mercator")
645    
646      def SetProjection(self, proj):      def SetProjection(self, proj):
647          ProjPanel.SetProjection(self, proj)          ProjPanel.SetProjection(self, proj)
# Line 438  class TMPanel(ProjPanel): Line 655  class TMPanel(ProjPanel):
655          ProjPanel.SetProjection(self, proj)          ProjPanel.SetProjection(self, proj)
656    
657      def GetParameters(self):      def GetParameters(self):
         print "** asdfsdf"  
658          params = ["proj=tmerc",          params = ["proj=tmerc",
659                    "lat_0=" + self.__latitude.GetValue(),                    "lat_0=" + self.__latitude.GetValue(),
660                    "lon_0=" + self.__longitude.GetValue(),                    "lon_0=" + self.__longitude.GetValue(),
# Line 462  ID_UTMPANEL_SOUTH = 4002 Line 678  ID_UTMPANEL_SOUTH = 4002
678  ID_UTMPANEL_PROP = 4003  ID_UTMPANEL_PROP = 4003
679    
680  class UTMPanel(ProjPanel):  class UTMPanel(ProjPanel):
681      """Projection Panel for Universal Transverse Mercartor."""      """Projection Panel for Universal Transverse Mercator."""
682    
683      def __init__(self, parent):      def __init__(self, parent, receiver):
684          ProjPanel.__init__(self, parent)          ProjPanel.__init__(self, parent)
685    
686          self.parent = parent          self.receiver = receiver
687    
688          self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60)          self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60)
689          self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH,          self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH,
# Line 491  class UTMPanel(ProjPanel): Line 707  class UTMPanel(ProjPanel):
707          ProjPanel._DoLayout(self, sizer)          ProjPanel._DoLayout(self, sizer)
708    
709      def GetProjName(self):      def GetProjName(self):
710          return _("Universal Transverse Mercartor")          return _("Universal Transverse Mercator")
711    
712      def SetProjection(self, proj):      def SetProjection(self, proj):
713          self.__zone.SetValue(int(proj.GetParameter("zone")))          self.__zone.SetValue(int(proj.GetParameter("zone")))
# Line 499  class UTMPanel(ProjPanel): Line 715  class UTMPanel(ProjPanel):
715          ProjPanel.SetProjection(self, proj)          ProjPanel.SetProjection(self, proj)
716    
717      def GetParameters(self):      def GetParameters(self):
         print "** asdfsdf"  
718          params = ["proj=utm", "zone=" + str(self.__zone.GetValue())]          params = ["proj=utm", "zone=" + str(self.__zone.GetValue())]
719          if self.__south.IsChecked():          if self.__south.IsChecked():
720              params.append("south")              params.append("south")
# Line 514  class UTMPanel(ProjPanel): Line 729  class UTMPanel(ProjPanel):
729    
730      def _OnPropose(self, event):      def _OnPropose(self, event):
731          UTMProposeZoneDialog          UTMProposeZoneDialog
732          dlg = UTMProposeZoneDialog(self, self.parent.GetReceiver().BoundingBox())          dlg = UTMProposeZoneDialog(self, self.receiver.BoundingBox())
733          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
734              self.__zone.SetValue(dlg.GetProposedZone())              self.__zone.SetValue(dlg.GetProposedZone())
735    
736  class LCCPanel(ProjPanel):  class LCCPanel(ProjPanel):
737      """Projection Panel for Lambert Conic Conformal."""      """Projection Panel for Lambert Conic Conformal."""
738    
739      def __init__(self, parent):      def __init__(self, parent, receiver):
740          ProjPanel.__init__(self, parent)          ProjPanel.__init__(self, parent)
741                    
742          self.__fspLatitude = wxTextCtrl(self, -1)          self.__fspLatitude = wxTextCtrl(self, -1)
# Line 591  class LCCPanel(ProjPanel): Line 806  class LCCPanel(ProjPanel):
806  class GeoPanel(ProjPanel):  class GeoPanel(ProjPanel):
807      """Projection Panel for a Geographic Projection."""      """Projection Panel for a Geographic Projection."""
808    
809      def __init__(self, parent):      def __init__(self, parent, receiver):
810          ProjPanel.__init__(self, parent)          ProjPanel.__init__(self, parent)
811          ProjPanel._DoLayout(self, None)          ProjPanel._DoLayout(self, None)
812    

Legend:
Removed from v.717  
changed lines
  Added in v.747

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26