/[thuban]/branches/WIP-pyshapelib-bramz/Extensions/umn_mapserver/mf_handle.py
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/Extensions/umn_mapserver/mf_handle.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2271 - (hide annotations)
Wed Jul 7 12:52:16 2004 UTC (20 years, 8 months ago) by jschuengel
Original Path: trunk/thuban/Extensions/umn_mapserver/mf_handle.py
File MIME type: text/x-python
File size: 46042 byte(s)
Added some setting to the Label Dialog and add the OutputDialog.
Make some changes to the code order.

1 jschuengel 2257 # -*- coding:latin1 -*-
2     # Copyright (C) 2004 by Intevation GmbH
3     # Authors:
4     # Jan Schüngel <[email protected]>
5     #
6     # This program is free software under the GPL (>=v2)
7     # Read the file COPYING coming with Thuban for details.
8    
9     """
10     This modul extend Thuban with the possibility to handle
11     UMN MapServer mapfiles.
12     """
13    
14     __version__ = "$Revision$"
15     # $Source$
16     # $Id$
17    
18    
19     # ###################################
20     #
21     # import necessary modules
22     #
23     # ###################################
24    
25     import os, sys
26    
27     # mapscript
28     from mapscript import mapObj
29    
30     # wxPython support
31     # TODO: explicitly use from .. import
32     from wxPython.wx import *
33    
34     # Thuban
35     # use _() already now for all strings that may later be translated
36     from Thuban import _
37    
38     # Thuban has named commands which can be registered in the central
39     # instance registry.
40     from Thuban.UI.command import registry, Command
41    
42     # The instance of the main menu of the Thuban application
43     import Thuban.UI.mainwindow
44    
45     # needed to add the new menu
46     from Thuban.UI.mainwindow import main_menu
47    
48     # import Map Object for the Mapfile
49     from mapfile import MF_Map
50    
51     from Thuban.UI.colordialog import ColorDialog
52    
53     from mapfile import unit_type, legend_status_type, legend_position_type, \
54 jschuengel 2267 label_font_type, scalebar_status_type, scalebar_style_type, \
55 jschuengel 2271 scalebar_position_type, label_position_type, image_type
56 jschuengel 2257
57     # ###################################
58     #
59     # Mainpart of the Extension
60     #
61     # ###################################
62    
63     ID_COLOR_CHANGE= 8001
64 jschuengel 2267 ID_IMGCOLOR_CHANGE = 8002
65 jschuengel 2257
66     class Map_Dialog(wxDialog):
67    
68     def __init__(self, parent, ID, title,
69     pos=wxDefaultPosition, size=wxDefaultSize,
70     style=wxDEFAULT_DIALOG_STYLE):
71    
72     # initialize the Dialog
73     wxDialog.__init__(self, parent, ID, title, pos, size, style)
74    
75     # parent.canvas.Map()
76     self.tb_map = parent.canvas.Map()
77     self.tb_map_umn = self.tb_map.extension_umn_mapobj
78    
79     # create name
80     box_name = wxBoxSizer(wxHORIZONTAL)
81     box_name.Add(wxStaticText(self, -1, _("Map-Name:")), 0,
82     wxALL|wxALIGN_CENTER_VERTICAL, 4)
83     box_name.Add(wxStaticText(self, -1, self.tb_map.Title()), 0,
84     wxALL|wxALIGN_CENTER_VERTICAL, 4)
85    
86     #create size settings
87 jschuengel 2271 insidetxt = self.tb_map_umn.get_size()
88 jschuengel 2257 staticSize = wxStaticBox(self, 1010, _("Size"), style = 0, name = "staticBox", )
89     box_size = wxStaticBoxSizer(staticSize, wxVERTICAL)
90    
91     box_sizepartWidth = wxBoxSizer(wxHORIZONTAL)
92     box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 4)
93     self.text_width = wxTextCtrl(self, -1, str(insidetxt[0]))
94     box_sizepartWidth.Add(self.text_width, 2, wxALL, 4)
95     box_size.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 5)
96     box_sizepartHeight = wxBoxSizer(wxHORIZONTAL)
97     box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 4)
98     self.text_height = wxTextCtrl(self, -1, str(insidetxt[1]))
99     box_sizepartHeight.Add(self.text_height, 2, wxALL, 4)
100     box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5)
101    
102     #get the set unittype
103     insideunit = self.tb_map_umn.get_units()
104    
105     #create the Unittype selector
106     box_unitsStatic = wxStaticBox(self, 1011, _("Unit Type"), style = 0, name = "imagecolor")
107     box_units = wxStaticBoxSizer(box_unitsStatic, wxVERTICAL)
108     sam = []
109     for key in unit_type:
110     sam.append(unit_type[key])
111     self.choice_units = wxChoice(self, 40, (80, 50), choices = sam)
112     self.choice_units.SetStringSelection(insideunit)
113     box_units.Add(self.choice_units,0, wxEXPAND, wxALL, 5)
114    
115     # color chouser
116     box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), style = 0, name = "imagecolor")
117     box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL)
118    
119     # preview box
120     self.previewcolor = wxPanel(self,99, name = 'backgroundPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN)
121     imagecolor = self.tb_map_umn.get_imagecolor()
122     self.previewcolor.SetBackgroundColour(wxColour(imagecolor.get_red(),
123     imagecolor.get_green(), imagecolor.get_blue()))
124     box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5)
125     # color change button, opens a new color dialog
126     button = wxButton(self, ID_COLOR_CHANGE, _("Change Color"))
127     button.SetFocus()
128     EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor)
129     box_color.Add(button, 1, wxEXPAND|wxALL, 5)
130    
131 jschuengel 2271 # status
132     umn_status = self.tb_map_umn.get_status()
133     self.choice_status = wxRadioBox(self, -1, choices=["True","False"],
134     label='status', majorDimension=1,
135     name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
136     self.choice_status.SetStringSelection(str(umn_status))
137    
138    
139 jschuengel 2257 #buttons
140     box_buttons = wxBoxSizer(wxHORIZONTAL)
141     button = wxButton(self, wxID_OK, _("OK"))
142     box_buttons.Add(button, 0, wxALL, 5)
143     button = wxButton(self, wxID_CANCEL, _("Cancel"))
144     box_buttons.Add(button, 0, wxALL, 5)
145     #set the button funcitons
146     EVT_BUTTON(self, wxID_OK, self.OnOK)
147     EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
148    
149     #add all boxes to the box top
150     top = wxBoxSizer(wxVERTICAL)
151     top.Add(box_name, 0, wxEXPAND |wxALL, 5)
152     top.Add(box_size, 0, wxEXPAND |wxALL, 5)
153     top.Add(box_units,0, wxEXPAND |wxALL, 5)
154 jschuengel 2271 top.Add(box_color,0, wxEXPAND |wxALL, 5)
155     top.Add(self.choice_status,0, wxEXPAND |wxALL, 5)
156 jschuengel 2257 top.Add(box_buttons, 0, wxALIGN_RIGHT)
157    
158     # final layout settings
159     self.SetSizer(top)
160     top.Fit(self)
161    
162     def OnChangeColor(self, event):
163     cur = self.tb_map_umn.get_imagecolor().get_thubancolor()
164     dialog = ColorDialog(self)
165     dialog.SetColor(cur)
166     self.retcolor = None
167     if dialog.ShowModal() == wxID_OK:
168     self.retcolor = dialog.GetColor()
169     dialog.Destroy()
170     if self.retcolor:
171     self.redcolor = int(round(self.retcolor.red*255))
172     self.greencolor = int(round(self.retcolor.green*255))
173     self.bluecolor = int(round(self.retcolor.blue*255))
174     self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
175     int(self.greencolor), int(self.bluecolor)))
176    
177     def RunDialog(self):
178     self.ShowModal()
179     self.Destroy()
180    
181     def end_dialog(self, result):
182     self.result = result
183     if self.result is not None:
184     self.EndModal(wxID_OK)
185     else:
186     self.EndModal(wxID_CANCEL)
187     self.Show(False)
188    
189     def OnOK(self, event):
190 jschuengel 2271 self.tb_map_umn.set_size(int(self.text_width.GetValue()),
191     int(self.text_height.GetValue()))
192 jschuengel 2257 self.tb_map_umn.set_units(self.choice_units.GetStringSelection())
193 jschuengel 2271 if self.choice_status.GetStringSelection() == "True":
194     self.tb_map_umn.set_status(True)
195     else:
196     self.tb_map_umn.set_status(False)
197 jschuengel 2267 previewcolor = self.previewcolor.GetBackgroundColour()
198     self.tb_map_umn.get_imagecolor().set_rgbcolor(previewcolor.Red(),
199     previewcolor.Green(), previewcolor.Blue())
200 jschuengel 2257 self.result ="OK"
201     self.end_dialog(self.result)
202    
203     def OnCancel(self, event):
204     self.end_dialog(None)
205    
206    
207 jschuengel 2271 class OutputFormat_Dialog(wxDialog):
208    
209     def __init__(self, parent, ID, title,
210     pos=wxDefaultPosition, size=wxDefaultSize,
211     style=wxDEFAULT_DIALOG_STYLE):
212    
213     # initialize the Dialog
214     wxDialog.__init__(self, parent, ID, title, pos, size, style)
215    
216     # get the web object
217     self.tb_map = parent.canvas.Map()
218     self.tb_map_umn = self.tb_map.extension_umn_mapobj
219    
220     #get the outputformat
221     umn_imagetype = self.tb_map_umn.get_imagetype()
222     #Imagetype selector
223     box_imagetypeStatic = wxStaticBox(self, -1, _("Image Type"), style = 0, name = "imagetype")
224     box_imagetype = wxStaticBoxSizer(box_imagetypeStatic, wxVERTICAL)
225     self.choice_imgtype = wxChoice(self, 8060, (80, 50), choices = image_type)
226     EVT_CHOICE(self, 8060, self.EvtChoiceBox)
227     self.choice_imgtype.SetStringSelection(umn_imagetype)
228     box_imagetype.Add(self.choice_imgtype,0, wxEXPAND, wxALL, 5)
229    
230     #buttons
231     box_buttons = wxBoxSizer(wxHORIZONTAL)
232     button = wxButton(self, wxID_OK, _("OK"))
233     box_buttons.Add(button, 0, wxALL, 5)
234     button = wxButton(self, wxID_CANCEL, _("Cancel"))
235     box_buttons.Add(button, 0, wxALL, 5)
236     #set the button funcitons
237     EVT_BUTTON(self, wxID_OK, self.OnOK)
238     EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
239    
240     #add all boxes to the box top
241     top = wxBoxSizer(wxVERTICAL)
242     top.Add(box_imagetype,0, wxEXPAND |wxALL, 5)
243     top.Add(box_buttons, 0, wxALIGN_RIGHT)
244     # final layout settings
245     self.SetSizer(top)
246     top.Fit(self)
247    
248     def EvtChoiceBox(self, event):
249     print self.choice_imgtype.GetStringSelection()
250     outformat = self.tb_map_umn.get_outputformat().get_name()
251     print outformat
252    
253    
254     def RunDialog(self):
255     self.ShowModal()
256     self.Destroy()
257    
258     def end_dialog(self, result):
259     self.result = result
260     if self.result is not None:
261     self.EndModal(wxID_OK)
262     else:
263     self.EndModal(wxID_CANCEL)
264     self.Show(False)
265    
266     def OnOK(self, event):
267     self.tb_map_umn.set_imagetype(self.choice_imgtype.GetStringSelection())
268     self.result ="OK"
269     self.end_dialog(self.result)
270    
271     def OnCancel(self, event):
272     self.end_dialog(None)
273    
274    
275 jschuengel 2257 class Web_Dialog(wxDialog):
276    
277     def __init__(self, parent, ID, title,
278     pos=wxDefaultPosition, size=wxDefaultSize,
279     style=wxDEFAULT_DIALOG_STYLE):
280    
281     # initialize the Dialog
282     wxDialog.__init__(self, parent, ID, title, pos, size, style)
283    
284     # get the web object
285     self.tb_map = parent.canvas.Map()
286     self.umn_web = self.tb_map.extension_umn_mapobj.get_web()
287    
288     # create name
289     box_name = wxBoxSizer(wxHORIZONTAL)
290     box_name.Add(wxStaticText(self, -1, _("Map-Name:")), 0,
291     wxALL|wxALIGN_CENTER_VERTICAL, 4)
292     box_name.Add(wxStaticText(self, -1, self.tb_map.Title()), 0,
293     wxALL|wxALIGN_CENTER_VERTICAL, 4)
294    
295     # Imagepath
296     box_imagepath = wxBoxSizer(wxHORIZONTAL)
297     box_imagepath.Add(wxStaticText(self, -1, _("Imagepath:")), 0,
298     wxALL|wxALIGN_LEFT, 4)
299     self.text_imagepath = wxTextCtrl(self, -1, str(self.umn_web.get_imagepath()))
300     box_imagepath.Add(self.text_imagepath, 0,
301     wxALL|wxALIGN_CENTER_VERTICAL, 4)
302    
303     # Imageurl
304     box_imageurl = wxBoxSizer(wxHORIZONTAL)
305     box_imageurl.Add(wxStaticText(self, -1, _("Imageurl:")), 0,
306     wxALL|wxALIGN_LEFT, 4)
307     self.text_imageurl = wxTextCtrl(self, -1, str(self.umn_web.get_imageurl()))
308     box_imageurl.Add(self.text_imageurl, 0,
309     wxALL|wxALIGN_CENTER_VERTICAL, 4)
310    
311     # queryformat
312     # include from a query dialog later
313     """box_queryformat = wxBoxSizer(wxHORIZONTAL)
314     box_queryformat.Add(wxStaticText(self, -1, _("Queryformat:")), 0,
315     wxALL|wxALIGN_LEFT, 4)
316     self.text_queryformat = wxTextCtrl(self, -1, str(self.umn_web.get_queryformat()))
317     box_queryformat.Add(self.text_queryformat, 0,
318     wxALL|wxALIGN_CENTER_VERTICAL, 4)
319     top.Add(box_queryformat, 0, wxEXPAND |wxALL, 5)
320     """
321    
322     #buttons
323     box_buttons = wxBoxSizer(wxHORIZONTAL)
324     button = wxButton(self, wxID_OK, _("OK"))
325     box_buttons.Add(button, 0, wxALL, 5)
326     button = wxButton(self, wxID_CANCEL, _("Cancel"))
327     box_buttons.Add(button, 0, wxALL, 5)
328     #set the button funcitons
329     EVT_BUTTON(self, wxID_OK, self.OnOK)
330 jschuengel 2271 EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
331    
332     # compose the final dialog
333     top = wxBoxSizer(wxVERTICAL)
334     top.Add(box_name, 0, wxEXPAND |wxALL, 5)
335     top.Add(box_imagepath, 0, wxEXPAND |wxALL, 5)
336     top.Add(box_imageurl, 0, wxEXPAND |wxALL, 5)
337 jschuengel 2257 top.Add(box_buttons, 0, wxALIGN_RIGHT)
338    
339     # final layout settings
340     self.SetSizer(top)
341     top.Fit(self)
342    
343     def RunDialog(self):
344     self.ShowModal()
345     self.Destroy()
346    
347     def end_dialog(self, result):
348     self.result = result
349     if self.result is not None:
350     self.EndModal(wxID_OK)
351     else:
352     self.EndModal(wxID_CANCEL)
353     self.Show(False)
354    
355     def OnOK(self, event):
356     self.umn_web.set_imagepath(self.text_imagepath.GetValue())
357     self.umn_web.set_imageurl(self.text_imageurl.GetValue())
358 jschuengel 2271 #self.umn_web.set_queryformat(self.text_queryformat.GetValue())
359 jschuengel 2257 self.result ="OK"
360     self.end_dialog(self.result)
361    
362     def OnCancel(self, event):
363     self.end_dialog(None)
364    
365    
366    
367     ID_LABEL_CHANGE = 8011
368    
369     class Legend_Dialog(wxDialog):
370    
371     def __init__(self, parent, ID, title,
372     pos=wxDefaultPosition, size=wxDefaultSize,
373     style=wxDEFAULT_DIALOG_STYLE):
374    
375     # initialize the Dialog
376     wxDialog.__init__(self, parent, ID, title, pos, size, style)
377    
378     # get the web object
379     self.tb_map = parent.canvas.Map()
380     self.umn_legend = self.tb_map.extension_umn_mapobj.get_legend()
381    
382     # create the Keysize
383     keySize = wxStaticBox(self, 1010, _("KeySize"), style = 0, name = "KeySize Box", )
384     box_keysize = wxStaticBoxSizer(keySize, wxVERTICAL)
385     umn_legend_keysize = self.umn_legend.get_keysize()
386     box_sizepartWidth = wxBoxSizer(wxHORIZONTAL)
387     box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 2)
388     self.text_keysize_width = wxSpinCtrl(self, -1,
389     value=str(umn_legend_keysize[0]), max=100, min=0,
390     name='keywidth', style=wxSP_ARROW_KEYS)
391     box_sizepartWidth.Add(self.text_keysize_width, 2, wxALL, 2)
392     box_keysize.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 2)
393     box_sizepartHeight = wxBoxSizer(wxHORIZONTAL)
394     box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 2),
395     self.text_keysize_height = wxSpinCtrl(self, -1,
396     value=str(umn_legend_keysize[1]), max=100, min=0,
397     name='keyheight', style=wxSP_ARROW_KEYS)
398     box_sizepartHeight.Add(self.text_keysize_height, 2, wxALL, 2)
399     box_keysize.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 2)
400    
401     # create the Keyspacing
402     keySpacing= wxStaticBox(self, 1010, _("KeySpacing"), style = 0, name = "KeySpacing Box", )
403     box_keyspacing = wxStaticBoxSizer(keySpacing, wxVERTICAL)
404     umn_legend_keyspacing = self.umn_legend.get_keyspacing()
405     box_sizepartWidth = wxBoxSizer(wxHORIZONTAL)
406     box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 2)
407     self.text_keyspacing_width = wxSpinCtrl(self, -1,
408     value=str(umn_legend_keyspacing[0]), max=100, min=0,
409     name='spacingwidth', style=wxSP_ARROW_KEYS)
410     box_sizepartWidth.Add(self.text_keyspacing_width, 2, wxALL, 2)
411     box_keyspacing.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 2)
412     box_sizepartHeight = wxBoxSizer(wxHORIZONTAL)
413     box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 2),
414     self.text_keyspacing_height = wxSpinCtrl(self, -1,
415     value=str(umn_legend_keyspacing[1]), max=100, min=0,
416     name='spacingheight', style=wxSP_ARROW_KEYS)
417     box_sizepartHeight.Add(self.text_keyspacing_height, 2, wxALL, 2)
418     box_keyspacing.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 2)
419    
420     # color chooser
421     box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), style = 0, name = "imagecolor")
422     box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL)
423     # preview box
424     self.previewcolor = wxPanel(self, 99, name = 'imagecolorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN)
425     imagecolor = self.umn_legend.get_imagecolor()
426     self.previewcolor.SetBackgroundColour(wxColour(imagecolor.get_red(),
427     imagecolor.get_green(), imagecolor.get_blue()))
428     box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5)
429     # color change button, opens a new color dialog
430     button = wxButton(self, ID_COLOR_CHANGE, _("Change Color"))
431     button.SetFocus()
432     EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor)
433     box_color.Add(button, 1, wxEXPAND|wxALL, 5)
434    
435 jschuengel 2267 # status
436 jschuengel 2257 umn_legend_status= self.umn_legend.get_status(art="string")
437     possible_choices = []
438     for key in legend_status_type:
439     possible_choices.append(legend_status_type[key])
440     self.choice_status = wxRadioBox(self, -1, choices=possible_choices,
441     label='Status', majorDimension=1,
442     name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
443     self.choice_status.SetStringSelection(umn_legend_status)
444    
445     # create the positionbox
446     umn_legend_position= self.umn_legend.get_position(art="string")
447     possible_choices = []
448     for key in legend_position_type:
449     possible_choices.append(legend_position_type[key])
450     self.choice_position = wxRadioBox(self, -1, choices=possible_choices,
451     label='Position', majorDimension=1,
452     name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
453     self.choice_position.SetStringSelection(umn_legend_position)
454    
455 jschuengel 2271 # button for label
456     labelbutton = wxButton(self, ID_LABEL_CHANGE, _("Change Label"))
457 jschuengel 2257 EVT_BUTTON(self, ID_LABEL_CHANGE, self.OnChangeLabel)
458    
459     #buttons
460     box_buttons = wxBoxSizer(wxHORIZONTAL)
461     button = wxButton(self, wxID_OK, _("OK"))
462     box_buttons.Add(button, 0, wxALL, 5)
463     button = wxButton(self, wxID_CANCEL, _("Cancel"))
464     box_buttons.Add(button, 0, wxALL, 5)
465     #set the button funcitons
466     EVT_BUTTON(self, wxID_OK, self.OnOK)
467     EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
468 jschuengel 2271
469     # compose the final layout
470     top = wxBoxSizer(wxVERTICAL)
471     top.Add(box_keysize,0, wxEXPAND |wxALL, 5)
472     top.Add(box_keyspacing,0, wxEXPAND |wxALL, 5)
473     top.Add(box_color,0, wxEXPAND |wxALL, 5)
474     top.Add(self.choice_status,0, wxEXPAND |wxALL, 5)
475     top.Add(self.choice_position,0, wxEXPAND |wxALL, 5)
476     top.Add(labelbutton, 1, wxEXPAND|wxALL, 5)
477 jschuengel 2257 top.Add(box_buttons, 0, wxALIGN_RIGHT)
478    
479     # final layout settings
480     self.SetSizer(top)
481     top.Fit(self)
482    
483     def OnChangeLabel(self, event):
484 jschuengel 2267 self.umn_label = self.umn_legend.get_label()
485 jschuengel 2271 dialog = Label_Dialog(self, -1, "Legend Label Settings", size=wxSize(350, 200),
486 jschuengel 2257 style = wxDEFAULT_DIALOG_STYLE
487     )
488     dialog.CenterOnScreen()
489     if dialog.ShowModal() == wxID_OK:
490     return
491     dialog.Destroy()
492    
493     def OnChangeColor(self, event):
494     cur = self.umn_legend.get_imagecolor().get_thubancolor()
495     dialog = ColorDialog(self)
496     dialog.SetColor(cur)
497     self.retcolor = None
498     if dialog.ShowModal() == wxID_OK:
499     self.retcolor = dialog.GetColor()
500     dialog.Destroy()
501     if self.retcolor:
502     self.redcolor = int(round(self.retcolor.red*255))
503     self.greencolor = int(round(self.retcolor.green*255))
504     self.bluecolor = int(round(self.retcolor.blue*255))
505     self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
506     int(self.greencolor), int(self.bluecolor)))
507    
508     def RunDialog(self):
509     self.ShowModal()
510     self.Destroy()
511    
512     def end_dialog(self, result):
513     self.result = result
514     if self.result is not None:
515     self.EndModal(wxID_OK)
516     else:
517     self.EndModal(wxID_CANCEL)
518     self.Show(False)
519    
520     def OnOK(self, event):
521 jschuengel 2271 self.umn_legend.set_keysize(self.text_keysize_width.GetValue(),
522     self.text_keysize_height.GetValue())
523     self.umn_legend.set_keyspacing(self.text_keyspacing_width.GetValue(),
524     self.text_keyspacing_height.GetValue())
525 jschuengel 2257 self.umn_legend.set_status(self.choice_status.GetStringSelection())
526     self.umn_legend.set_position(self.choice_position.GetStringSelection())
527 jschuengel 2267 previewcolor = self.previewcolor.GetBackgroundColour()
528     self.umn_legend.get_imagecolor().set_rgbcolor(previewcolor.Red(),
529     previewcolor.Green(), previewcolor.Blue())
530 jschuengel 2257 self.result ="OK"
531     self.end_dialog(self.result)
532    
533     def OnCancel(self, event):
534     self.end_dialog(None)
535    
536     class Label_Dialog(wxDialog):
537    
538     def __init__(self, parent, ID, title,
539     pos=wxDefaultPosition, size=wxDefaultSize,
540     style=wxDEFAULT_DIALOG_STYLE):
541    
542     # initialize the Dialog
543     wxDialog.__init__(self, parent, ID, title, pos, size, style)
544    
545     # get the web object
546 jschuengel 2267 self.umn_label = parent.umn_label
547 jschuengel 2257
548     # size
549     labelsize= wxStaticBox(self, 1010, _("Size"), style = 0, name = "Size Box", )
550     box_labelsize = wxStaticBoxSizer(labelsize, wxVERTICAL)
551     umn_label_size= self.umn_label.get_size()
552     box_size = wxBoxSizer(wxHORIZONTAL)
553     self.text_labelsize = wxSpinCtrl(self, -1,
554     value=str(umn_label_size), max=10, min=0,
555     name='size', style=wxSP_ARROW_KEYS)
556     box_size.Add(self.text_labelsize, 2, wxALL, 2)
557     box_labelsize.Add(box_size, 0, wxALIGN_RIGHT | wxALL, 2)
558    
559     # color chooser
560     box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, name = "color")
561     box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL)
562     # preview box
563     self.previewcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN)
564     color = self.umn_label.get_color()
565     self.previewcolor.SetBackgroundColour(wxColour(color.get_red(),
566     color.get_green(), color.get_blue()))
567     box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5)
568     # color change button, opens a new color dialog
569     button = wxButton(self, ID_COLOR_CHANGE, _("Change Color"))
570     button.SetFocus()
571     EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor)
572     box_color.Add(button, 1, wxEXPAND|wxALL, 5)
573    
574     #get the set type
575     insidetype = self.umn_label.get_type()
576     #create the type selector for fonttype (Bitmap, TrueType)
577     # TODO: Truetype is not supported yet
578     box_typeStatic = wxStaticBox(self, 1011, _("Type"), style = 0, name = "type")
579     box_type = wxStaticBoxSizer(box_typeStatic, wxVERTICAL)
580     sam = []
581     for key in label_font_type:
582     # dont add truetype
583     #if key != 0:
584     sam.append(label_font_type[key])
585     self.choice_type = wxChoice(self, 40, (80, 50), choices = sam)
586     self.choice_type.SetStringSelection(insidetype)
587     box_type.Add(self.choice_type,0, wxEXPAND, wxALL, 5)
588 jschuengel 2271
589 jschuengel 2257 # Offset
590 jschuengel 2267 offset= wxStaticBox(self, 1010, _("Offset"), style = 0, name = "Offset Box", )
591 jschuengel 2257 box_offset = wxStaticBoxSizer(offset, wxVERTICAL)
592     umn_label_offset = self.umn_label.get_offset()
593     box_offsetX = wxBoxSizer(wxHORIZONTAL)
594     box_offsetX.Add(wxStaticText(self, -1, _("X: ")), 0, wxALL, 2)
595     self.text_offsetx = wxSpinCtrl(self, -1,
596     value=str(umn_label_offset[0]), max=20, min=0,
597     name='offsetX', style=wxSP_ARROW_KEYS)
598     box_offsetX.Add(self.text_offsetx, 2, wxALL, 2)
599     box_offset.Add(box_offsetX, 0, wxALIGN_RIGHT | wxALL, 2)
600     box_offsetY = wxBoxSizer(wxHORIZONTAL)
601     box_offsetY.Add(wxStaticText(self, -1, _("Y: ")), 0, wxALL, 2),
602     self.text_offsety = wxSpinCtrl(self, -1,
603     value=str(umn_label_offset[1]), max=100, min=0,
604     name='offsetY', style=wxSP_ARROW_KEYS)
605     box_offsetY.Add(self.text_offsety, 2, wxALL, 2)
606     box_offset.Add(box_offsetY, 0, wxALIGN_RIGHT | wxALL, 2)
607    
608 jschuengel 2271 # partials
609 jschuengel 2267 umn_partials = self.umn_label.get_partials()
610     self.choice_partials = wxRadioBox(self, -1, choices=["True","False"],
611     label='partials', majorDimension=1,
612     name='partials check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
613     self.choice_partials.SetStringSelection(str(umn_partials))
614 jschuengel 2271
615     # force
616     umn_force = self.umn_label.get_force()
617     self.choice_force = wxRadioBox(self, -1, choices=["True","False"],
618     label='force', majorDimension=1,
619     name='force check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
620     self.choice_force.SetStringSelection(str(umn_force))
621    
622     # buffer
623     buffer = wxStaticBox(self, 1010, _("Buffer"), style = 0, name = "Buffer Box", )
624     box_buffer = wxStaticBoxSizer(buffer, wxVERTICAL)
625     umn_buffer= self.umn_label.get_buffer()
626     box_buffertext = wxBoxSizer(wxHORIZONTAL)
627     self.text_buffer = wxSpinCtrl(self, -1,
628     value=str(umn_buffer), max=10, min=0,
629     name='size', style=wxSP_ARROW_KEYS)
630     box_buffertext.Add(self.text_buffer, 2, wxALL, 2)
631     box_buffer.Add(box_buffertext, 0, wxALIGN_RIGHT | wxALL, 2)
632    
633     # minfeaturesize
634     minfeaturesize = wxStaticBox(self, 1010, _("Minfeaturesize"), style = 0,
635     name = "Minfeaturesize Box", )
636     box_minfeaturesize = wxStaticBoxSizer(minfeaturesize, wxVERTICAL)
637     umn_minfeaturesize= self.umn_label.get_minfeaturesize()
638     box_minfeaturesizetext = wxBoxSizer(wxHORIZONTAL)
639     self.text_minfeaturesize = wxSpinCtrl(self, -1,
640     value=str(umn_minfeaturesize), max=10, min=-1,
641     name='minfeaturesize', style=wxSP_ARROW_KEYS)
642     box_minfeaturesizetext.Add(self.text_minfeaturesize, 2, wxALL, 2)
643     box_minfeaturesize.Add(box_minfeaturesizetext, 0,
644     wxALIGN_RIGHT | wxALL, 2)
645    
646     # mindistance
647     mindistance = wxStaticBox(self, 1010, _("Mindistance"), style = 0,
648     name = "Mindistance Box", )
649     box_mindistance = wxStaticBoxSizer(mindistance, wxVERTICAL)
650     umn_mindistance= self.umn_label.get_mindistance()
651     box_mindistancetext = wxBoxSizer(wxHORIZONTAL)
652     self.text_mindistance = wxSpinCtrl(self, -1,
653     value=str(umn_mindistance), max=10, min=-1,
654     name='mindistance', style=wxSP_ARROW_KEYS)
655     box_mindistancetext.Add(self.text_mindistance, 2, wxALL, 2)
656     box_mindistance.Add(box_mindistancetext, 0,
657     wxALIGN_RIGHT | wxALL, 2)
658 jschuengel 2257
659 jschuengel 2271 # position
660     umn_label_position= self.umn_label.get_position(art="string")
661     possible_choices = []
662     for key in label_position_type:
663     possible_choices.append(label_position_type[key])
664     self.choice_position = wxRadioBox(self, -1, choices=possible_choices,
665     label='Position', majorDimension=1,
666     name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
667     self.choice_position.SetStringSelection(umn_label_position)
668    
669 jschuengel 2257 #buttons
670     box_buttons = wxBoxSizer(wxHORIZONTAL)
671     button = wxButton(self, wxID_OK, _("OK"))
672     box_buttons.Add(button, 0, wxALL, 5)
673     button = wxButton(self, wxID_CANCEL, _("Cancel"))
674     box_buttons.Add(button, 0, wxALL, 5)
675     #set the button funcitons
676     EVT_BUTTON(self, wxID_OK, self.OnOK)
677     EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
678 jschuengel 2271
679     # compose the Dialog
680     top = wxBoxSizer(wxVERTICAL)
681    
682     top1 = wxBoxSizer(wxHORIZONTAL)
683     top1.Add(box_labelsize,0, wxEXPAND |wxALL, 5)
684     top1.Add(box_color,0, wxEXPAND |wxALL, 5)
685     top1.Add(box_minfeaturesize,0, wxEXPAND |wxALL, 5)
686    
687     top2 = wxBoxSizer(wxHORIZONTAL)
688     top2.Add(box_type,0,wxEXPAND |wxALL, 5)
689     top2.Add(box_offset,0, wxEXPAND |wxALL, 5)
690     top2.Add(box_mindistance,0, wxEXPAND |wxALL, 5)
691    
692     top3 = wxBoxSizer(wxHORIZONTAL)
693     top3.Add(self.choice_partials,0, wxEXPAND |wxALL, 5)
694     top3.Add(box_buffer,0, wxEXPAND |wxALL, 5)
695     top3.Add(self.choice_force,0, wxEXPAND |wxALL, 5)
696    
697     top.Add(top1, 0, wxEXPAND)
698     top.Add(top2, 0, wxEXPAND)
699     top.Add(top3, 0, wxEXPAND)
700     top.Add(self.choice_position,0, wxEXPAND |wxALL, 5)
701 jschuengel 2257 top.Add(box_buttons, 0, wxALIGN_RIGHT)
702 jschuengel 2271
703 jschuengel 2257 # final layout settings
704     self.SetSizer(top)
705     top.Fit(self)
706    
707     def OnChangeColor(self, event):
708     cur = self.umn_label.get_color().get_thubancolor()
709     dialog = ColorDialog(self)
710     dialog.SetColor(cur)
711     self.retcolor = None
712     if dialog.ShowModal() == wxID_OK:
713     self.retcolor = dialog.GetColor()
714     dialog.Destroy()
715     if self.retcolor:
716     self.redcolor = int(round(self.retcolor.red*255))
717     self.greencolor = int(round(self.retcolor.green*255))
718     self.bluecolor = int(round(self.retcolor.blue*255))
719     self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
720     int(self.greencolor), int(self.bluecolor)))
721    
722     def RunDialog(self):
723     self.ShowModal()
724     self.Destroy()
725    
726     def end_dialog(self, result):
727     self.result = result
728     if self.result is not None:
729     self.EndModal(wxID_OK)
730     else:
731     self.EndModal(wxID_CANCEL)
732     self.Show(False)
733    
734     def OnOK(self, event):
735     self.umn_label.set_size(self.text_labelsize.GetValue())
736     self.umn_label.set_offset(self.text_offsetx.GetValue(), self.text_offsety.GetValue())
737     self.umn_label.set_type(self.choice_type.GetStringSelection())
738 jschuengel 2267 if self.choice_partials.GetStringSelection() == "True":
739     self.umn_label.set_partials(True)
740     else:
741     self.umn_label.set_partials(False)
742     previewcolor = self.previewcolor.GetBackgroundColour()
743     self.umn_label.get_color().set_rgbcolor(previewcolor.Red(),
744     previewcolor.Green(), previewcolor.Blue())
745 jschuengel 2271 self.umn_label.set_mindistance(self.text_mindistance.GetValue())
746     self.umn_label.set_minfeaturesize(self.text_minfeaturesize.GetValue())
747     self.umn_label.set_position(self.choice_position.GetStringSelection())
748     self.umn_label.set_buffer(self.text_buffer.GetValue())
749     if self.choice_force.GetStringSelection() == "True":
750     self.umn_label.set_force(True)
751     else:
752     self.umn_label.set_force(False)
753 jschuengel 2257 self.result ="OK"
754     self.end_dialog(self.result)
755    
756     def OnCancel(self, event):
757     self.end_dialog(None)
758    
759 jschuengel 2267 class Scalebar_Dialog(wxDialog):
760    
761     def __init__(self, parent, ID, title,
762     pos=wxDefaultPosition, size=wxDefaultSize,
763     style=wxDEFAULT_DIALOG_STYLE):
764    
765     # initialize the Dialog
766     wxDialog.__init__(self, parent, ID, title, pos, size, style)
767 jschuengel 2257
768 jschuengel 2267 # get the web object
769     self.tb_map = parent.canvas.Map()
770     self.umn_scalebar = self.tb_map.extension_umn_mapobj.get_scalebar()
771    
772     # color chooser
773     box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, name = "color")
774     box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL)
775     # preview box
776     self.previewcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN)
777     color = self.umn_scalebar.get_color()
778     self.previewcolor.SetBackgroundColour(wxColour(color.get_red(),
779     color.get_green(), color.get_blue()))
780     box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5)
781     # color change button, opens a new color dialog
782     button = wxButton(self, ID_COLOR_CHANGE, _("Change Color"))
783     button.SetFocus()
784     EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor)
785     box_color.Add(button, 1, wxEXPAND|wxALL, 5)
786     # show the two color chooser horizontal
787     colorHor = wxBoxSizer(wxHORIZONTAL)
788     colorHor.Add(box_color,0, wxEXPAND |wxALL, 5)
789    
790     # imagecolor chooser
791     box_imgcolorStatic = wxStaticBox(self, 1011, _("Image Color"), style = 0, name = "imgcolor")
792     box_imgcolor = wxStaticBoxSizer(box_imgcolorStatic, wxVERTICAL)
793     # preview box
794     self.previewimgcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN)
795     color = self.umn_scalebar.get_imagecolor()
796     self.previewimgcolor.SetBackgroundColour(wxColour(color.get_red(),
797     color.get_green(), color.get_blue()))
798     box_imgcolor.Add(self.previewimgcolor, 1, wxGROW | wxALL, 5)
799     # color change button, opens a new color dialog
800     button = wxButton(self, ID_IMGCOLOR_CHANGE, _("Change ImageColor"))
801     button.SetFocus()
802     EVT_BUTTON(self, ID_IMGCOLOR_CHANGE, self.OnChangeImageColor)
803     box_imgcolor.Add(button, 1, wxEXPAND|wxALL, 5)
804     colorHor.Add(box_imgcolor,0, wxEXPAND |wxALL, 5)
805    
806     # create the intervals
807     intervalsStatic = wxStaticBox(self, 1010, _("Intervals"), style = 0, name = "Intervals Box", )
808     box_intervals = wxStaticBoxSizer(intervalsStatic, wxVERTICAL)
809     umn_scalebar_intervals = self.umn_scalebar.get_intervals()
810     self.text_intervals = wxSpinCtrl(self, -1,
811     value=str(umn_scalebar_intervals), max=100, min=0,
812     name='intervals', style=wxSP_ARROW_KEYS)
813     box_intervals.Add(self.text_intervals, 0, wxALIGN_RIGHT | wxALL, 2)
814     hori2 = wxBoxSizer(wxHORIZONTAL)
815     hori2.Add(box_intervals,0, wxEXPAND |wxALL, 5)
816    
817     #style
818     umn_scalebar_style= self.umn_scalebar.get_style()
819     possible_choices = []
820     for key in scalebar_style_type:
821     possible_choices.append(scalebar_style_type[key])
822     self.choice_style = wxRadioBox(self, -1, choices=possible_choices,
823     label='Style', majorDimension=1,
824     name='style check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
825     self.choice_style.SetSelection(umn_scalebar_style)
826     hori2.Add(self.choice_style, 1, wxEXPAND|wxALL, 5)
827    
828     #create size settings
829     try:
830     insidetxt = self.umn_scalebar.get_size()
831     except:
832     insidetxt = (0,0)
833     # create the Size Box
834     staticSize = wxStaticBox(self, -1, _("Size"), style = 0, name = "sizeBox", )
835     box_size = wxStaticBoxSizer(staticSize, wxHORIZONTAL)
836    
837     box_sizepartWidth = wxBoxSizer(wxHORIZONTAL)
838     box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 4)
839     self.text_width = wxTextCtrl(self, -1, str(insidetxt[0]))
840     box_sizepartWidth.Add(self.text_width, 2, wxALL, 4)
841     box_size.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 5)
842     box_sizepartHeight = wxBoxSizer(wxHORIZONTAL)
843     box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 4)
844     self.text_height = wxTextCtrl(self, -1, str(insidetxt[1]))
845     box_sizepartHeight.Add(self.text_height, 2, wxALL, 4)
846     box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5)
847    
848     # status
849     umn_scalebar_status= self.umn_scalebar.get_status(art="string")
850     possible_choices = []
851     for key in legend_status_type:
852     possible_choices.append(scalebar_status_type[key])
853     self.choice_status = wxRadioBox(self, -1, choices=possible_choices,
854     label='Status', majorDimension=1,
855     name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
856     self.choice_status.SetStringSelection(umn_scalebar_status)
857    
858     # position
859     umn_scalebar_position= self.umn_scalebar.get_position(art="string")
860     possible_choices = []
861     for key in scalebar_position_type:
862     possible_choices.append(scalebar_position_type[key])
863     self.choice_position = wxRadioBox(self, -1, choices=possible_choices,
864     label='Position', majorDimension=1,
865     name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
866     self.choice_position.SetStringSelection(umn_scalebar_position)
867    
868     #get the set unittype
869     insideunit = self.umn_scalebar .get_units()
870     #create the Unittype selector
871     box_unitsStatic = wxStaticBox(self, -1, _("Unit Type"), style = 0, name = "unittype")
872     box_units = wxStaticBoxSizer(box_unitsStatic, wxVERTICAL)
873     sam = []
874     for key in unit_type:
875     sam.append(unit_type[key])
876     self.choice_units = wxChoice(self, 40, (80, 50), choices = sam)
877     self.choice_units.SetStringSelection(insideunit)
878 jschuengel 2271 box_units.Add(self.choice_units,0, wxEXPAND, wxALL, 5)
879 jschuengel 2267
880 jschuengel 2271 # button for label
881     labelbutton = wxButton(self, ID_LABEL_CHANGE, _("Change Label"))
882 jschuengel 2267 EVT_BUTTON(self, ID_LABEL_CHANGE, self.OnChangeLabel)
883    
884     #buttons
885     box_buttons = wxBoxSizer(wxHORIZONTAL)
886     button = wxButton(self, wxID_OK, _("OK"))
887     box_buttons.Add(button, 0, wxALL, 5)
888     button = wxButton(self, wxID_CANCEL, _("Cancel"))
889     button.SetFocus()
890     box_buttons.Add(button, 0, wxALL, 5)
891     #set the button funcitons
892     EVT_BUTTON(self, wxID_OK, self.OnOK)
893 jschuengel 2271 EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
894    
895     # compose the dialog
896     top = wxBoxSizer(wxVERTICAL)
897     top.Add(colorHor,0, wxEXPAND |wxALL, 5)
898     top.Add(hori2, 1, wxEXPAND|wxALL, 5)
899     top.Add(box_size, 1, wxEXPAND|wxALL, 5)
900     top.Add(self.choice_status,0, wxEXPAND |wxALL, 5)
901     top.Add(self.choice_position,0, wxEXPAND |wxALL, 5)
902     top.Add(box_units, 1, wxEXPAND|wxALL, 5)
903     top.Add(labelbutton, 0, wxEXPAND|wxALL, 5)
904 jschuengel 2267 top.Add(box_buttons, 0, wxALIGN_RIGHT)
905    
906     # final layout settings
907     self.SetSizer(top)
908     top.Fit(self)
909    
910     def OnChangeLabel(self, event):
911     # set the umn_label for scalebar so the Label_Dialog can be used
912     self.umn_label = self.umn_scalebar.get_label()
913 jschuengel 2271 dialog = Label_Dialog(self, -1, "Scalbar Label Settings", size=wxSize(350, 200),
914 jschuengel 2267 style = wxDEFAULT_DIALOG_STYLE
915     )
916     dialog.CenterOnScreen()
917     if dialog.ShowModal() == wxID_OK:
918     return
919     dialog.Destroy()
920    
921     def OnChangeImageColor(self, event):
922     cur = self.umn_scalebar.get_imagecolor().get_thubancolor()
923     dialog = ColorDialog(self)
924     dialog.SetColor(cur)
925     self.retcolor = None
926     if dialog.ShowModal() == wxID_OK:
927     self.retcolor = dialog.GetColor()
928     dialog.Destroy()
929     if self.retcolor:
930     self.redcolor = int(round(self.retcolor.red*255))
931     self.greencolor = int(round(self.retcolor.green*255))
932     self.bluecolor = int(round(self.retcolor.blue*255))
933     self.previewimgcolor.SetBackgroundColour(wxColour((self.redcolor),
934     int(self.greencolor), int(self.bluecolor)))
935    
936     def OnChangeColor(self, event):
937     cur = self.umn_scalebar.get_color().get_thubancolor()
938     dialog = ColorDialog(self)
939     dialog.SetColor(cur)
940     self.retcolor = None
941     if dialog.ShowModal() == wxID_OK:
942     self.retcolor = dialog.GetColor()
943     dialog.Destroy()
944     if self.retcolor:
945     self.redcolor = int(round(self.retcolor.red*255))
946     self.greencolor = int(round(self.retcolor.green*255))
947     self.bluecolor = int(round(self.retcolor.blue*255))
948     self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
949     int(self.greencolor), int(self.bluecolor)))
950    
951     def RunDialog(self):
952     self.ShowModal()
953     self.Destroy()
954    
955     def end_dialog(self, result):
956     self.result = result
957     if self.result is not None:
958     self.EndModal(wxID_OK)
959     else:
960     self.EndModal(wxID_CANCEL)
961     self.Show(False)
962    
963     def OnOK(self, event):
964     self.umn_scalebar.set_status(self.choice_status.GetStringSelection())
965     self.umn_scalebar.set_units(self.choice_units.GetStringSelection())
966     self.umn_scalebar.set_intervals(self.text_intervals.GetValue())
967     self.umn_scalebar.set_style(self.choice_style.GetSelection())
968     self.umn_scalebar.set_position(self.choice_position.GetStringSelection())
969     self.umn_scalebar.set_size(int(self.text_width.GetValue()), int(self.text_height.GetValue()))
970    
971     previewcolor = self.previewcolor.GetBackgroundColour()
972     self.umn_scalebar.get_color().set_rgbcolor(previewcolor.Red(),
973     previewcolor.Green(), previewcolor.Blue())
974     previewimgcolor = self.previewimgcolor.GetBackgroundColour()
975     self.umn_scalebar.get_imagecolor().set_rgbcolor(previewimgcolor.Red(),
976     previewimgcolor.Green(), previewimgcolor.Blue())
977     self.result ="OK"
978     self.end_dialog(self.result)
979    
980     def OnCancel(self, event):
981     self.end_dialog(None)
982    
983    
984     def scalebarsettings(context):
985 jschuengel 2271 win = Scalebar_Dialog(context.mainwindow, -1, "Scalebar Settings", size=wxSize(350, 200),
986 jschuengel 2267 style = wxDEFAULT_DIALOG_STYLE
987     )
988     win.CenterOnScreen()
989     val = win.ShowModal()
990    
991 jschuengel 2257 def mapsettings(context):
992 jschuengel 2271 win = Map_Dialog(context.mainwindow, -1, "Map Settings", size=wxSize(350, 200),
993 jschuengel 2257 style = wxDEFAULT_DIALOG_STYLE
994     )
995     win.CenterOnScreen()
996     val = win.ShowModal()
997    
998 jschuengel 2271 def outputformatsettings(context):
999     win = OutputFormat_Dialog(context.mainwindow, -1, "OutputFormat Settings",
1000     size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE
1001     )
1002     win.CenterOnScreen()
1003     val = win.ShowModal()
1004    
1005 jschuengel 2257 def websettings(context):
1006 jschuengel 2271 win = Web_Dialog(context.mainwindow, -1, "Web Settings", size=wxSize(350, 200),
1007 jschuengel 2257 style = wxDEFAULT_DIALOG_STYLE
1008     )
1009     win.CenterOnScreen()
1010     val = win.ShowModal()
1011    
1012     def legendsettings(context):
1013 jschuengel 2271 win = Legend_Dialog(context.mainwindow, -1, "Legend Settings", size=wxSize(350, 200),
1014 jschuengel 2257 style = wxDEFAULT_DIALOG_STYLE
1015     )
1016     win.CenterOnScreen()
1017     val = win.ShowModal()
1018    
1019     #create a new mapfile
1020     def create_new_mapfile(context):
1021     theMap = MF_Map(mapObj(""))
1022     context.mainwindow.canvas.Map().extension_umn_mapobj = theMap
1023    
1024     # ###################################
1025     #
1026     # Hook in MapServer Extension into Thuban
1027     #
1028     # ###################################
1029    
1030     # find the extensions menu (create it anew if not found)
1031     experimental_menu = main_menu.FindOrInsertMenu("experimental", _("Experimenta&l"))
1032     # find the extension menu and add a new submenu if found
1033     mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver", _("&MapServer"))
1034    
1035    
1036     # register the new command
1037     registry.Add(Command("create_new_mapfile", _("Create an empty MapObj"), \
1038     create_new_mapfile, helptext = _("Create a new empty mapscript MapObj")))
1039     # finally add the new entry to the extensions menu
1040     mapserver_menu.InsertItem("create_new_mapfile")
1041    
1042    
1043     # register the new command (Map Settings Dialog)
1044     registry.Add(Command("Map Settings", _("Map Settings"), mapsettings,
1045     helptext = _("Edit the Map Setting")))
1046     # finally add the new entry to the extensions menu
1047     mapserver_menu.InsertItem("Map Settings")
1048    
1049 jschuengel 2271 # register the new command (OutputFormat Settings Dialog)
1050     registry.Add(Command("OutputFormat Settings", _("OutputFormat Settings"),
1051     outputformatsettings,
1052     helptext = _("Edit the OutputFormat Setting")))
1053     # finally add the new entry to the extensions menu
1054     mapserver_menu.InsertItem("OutputFormat Settings")
1055    
1056 jschuengel 2257 # register the new command (Map Settings Dialog)
1057     registry.Add(Command("Web Settings", _("Web Settings"), websettings,
1058     helptext = _("Edit the Web Setting")))
1059     # finally add the new entry to the extensions menu
1060     mapserver_menu.InsertItem("Web Settings")
1061    
1062     # register the new command (Legend Settings Dialog)
1063     registry.Add(Command("Legend Settings", _("Legend Settings"), legendsettings,
1064     helptext = _("Edit the Legend Setting")))
1065     # finally add the new entry to the extensions menu
1066     mapserver_menu.InsertItem("Legend Settings")
1067    
1068 jschuengel 2267 # register the new command (Scalebar Settings Dialog)
1069     registry.Add(Command("Scalebar Settings", _("Scalebar Settings"), scalebarsettings,
1070     helptext = _("Edit the Scalebar Setting")))
1071     # finally add the new entry to the extensions menu
1072     mapserver_menu.InsertItem("Scalebar Settings")
1073 jschuengel 2257
1074 jschuengel 2267

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26