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 |
|
|
scalebar_position_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 |
|
|
try: |
88 |
|
|
insidetxt = self.tb_map_umn.get_size() |
89 |
|
|
except: |
90 |
|
|
insidetxt = (0,0) |
91 |
|
|
# create the Size Box |
92 |
|
|
staticSize = wxStaticBox(self, 1010, _("Size"), style = 0, name = "staticBox", ) |
93 |
|
|
box_size = wxStaticBoxSizer(staticSize, wxVERTICAL) |
94 |
|
|
|
95 |
|
|
box_sizepartWidth = wxBoxSizer(wxHORIZONTAL) |
96 |
|
|
box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 4) |
97 |
|
|
self.text_width = wxTextCtrl(self, -1, str(insidetxt[0])) |
98 |
|
|
box_sizepartWidth.Add(self.text_width, 2, wxALL, 4) |
99 |
|
|
box_size.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 5) |
100 |
|
|
box_sizepartHeight = wxBoxSizer(wxHORIZONTAL) |
101 |
|
|
box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 4) |
102 |
|
|
self.text_height = wxTextCtrl(self, -1, str(insidetxt[1])) |
103 |
|
|
box_sizepartHeight.Add(self.text_height, 2, wxALL, 4) |
104 |
|
|
box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5) |
105 |
|
|
|
106 |
|
|
#get the set unittype |
107 |
|
|
insideunit = self.tb_map_umn.get_units() |
108 |
|
|
|
109 |
|
|
#create the Unittype selector |
110 |
|
|
box_unitsStatic = wxStaticBox(self, 1011, _("Unit Type"), style = 0, name = "imagecolor") |
111 |
|
|
box_units = wxStaticBoxSizer(box_unitsStatic, wxVERTICAL) |
112 |
|
|
sam = [] |
113 |
|
|
for key in unit_type: |
114 |
|
|
sam.append(unit_type[key]) |
115 |
|
|
self.choice_units = wxChoice(self, 40, (80, 50), choices = sam) |
116 |
|
|
self.choice_units.SetStringSelection(insideunit) |
117 |
|
|
box_units.Add(self.choice_units,0, wxEXPAND, wxALL, 5) |
118 |
|
|
|
119 |
|
|
# color chouser |
120 |
|
|
box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), style = 0, name = "imagecolor") |
121 |
|
|
box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL) |
122 |
|
|
|
123 |
|
|
# preview box |
124 |
|
|
self.previewcolor = wxPanel(self,99, name = 'backgroundPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) |
125 |
|
|
imagecolor = self.tb_map_umn.get_imagecolor() |
126 |
|
|
self.previewcolor.SetBackgroundColour(wxColour(imagecolor.get_red(), |
127 |
|
|
imagecolor.get_green(), imagecolor.get_blue())) |
128 |
|
|
box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5) |
129 |
|
|
# color change button, opens a new color dialog |
130 |
|
|
button = wxButton(self, ID_COLOR_CHANGE, _("Change Color")) |
131 |
|
|
button.SetFocus() |
132 |
|
|
EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor) |
133 |
|
|
box_color.Add(button, 1, wxEXPAND|wxALL, 5) |
134 |
|
|
|
135 |
|
|
#buttons |
136 |
|
|
box_buttons = wxBoxSizer(wxHORIZONTAL) |
137 |
|
|
button = wxButton(self, wxID_OK, _("OK")) |
138 |
|
|
box_buttons.Add(button, 0, wxALL, 5) |
139 |
|
|
button = wxButton(self, wxID_CANCEL, _("Cancel")) |
140 |
|
|
box_buttons.Add(button, 0, wxALL, 5) |
141 |
|
|
#set the button funcitons |
142 |
|
|
EVT_BUTTON(self, wxID_OK, self.OnOK) |
143 |
|
|
EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) |
144 |
|
|
|
145 |
|
|
#add all boxes to the box top |
146 |
|
|
top = wxBoxSizer(wxVERTICAL) |
147 |
|
|
top.Add(box_name, 0, wxEXPAND |wxALL, 5) |
148 |
|
|
top.Add(box_size, 0, wxEXPAND |wxALL, 5) |
149 |
|
|
top.Add(box_units,0, wxEXPAND |wxALL, 5) |
150 |
|
|
top.Add(box_color,0, wxEXPAND |wxALL, 5) |
151 |
|
|
top.Add(box_buttons, 0, wxALIGN_RIGHT) |
152 |
|
|
|
153 |
|
|
# final layout settings |
154 |
|
|
self.SetSizer(top) |
155 |
|
|
top.Fit(self) |
156 |
|
|
|
157 |
|
|
def OnChangeColor(self, event): |
158 |
|
|
cur = self.tb_map_umn.get_imagecolor().get_thubancolor() |
159 |
|
|
dialog = ColorDialog(self) |
160 |
|
|
dialog.SetColor(cur) |
161 |
|
|
self.retcolor = None |
162 |
|
|
if dialog.ShowModal() == wxID_OK: |
163 |
|
|
self.retcolor = dialog.GetColor() |
164 |
|
|
dialog.Destroy() |
165 |
|
|
if self.retcolor: |
166 |
|
|
self.redcolor = int(round(self.retcolor.red*255)) |
167 |
|
|
self.greencolor = int(round(self.retcolor.green*255)) |
168 |
|
|
self.bluecolor = int(round(self.retcolor.blue*255)) |
169 |
|
|
self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), |
170 |
|
|
int(self.greencolor), int(self.bluecolor))) |
171 |
|
|
|
172 |
|
|
def RunDialog(self): |
173 |
|
|
self.ShowModal() |
174 |
|
|
self.Destroy() |
175 |
|
|
|
176 |
|
|
def end_dialog(self, result): |
177 |
|
|
self.result = result |
178 |
|
|
if self.result is not None: |
179 |
|
|
self.EndModal(wxID_OK) |
180 |
|
|
else: |
181 |
|
|
self.EndModal(wxID_CANCEL) |
182 |
|
|
self.Show(False) |
183 |
|
|
|
184 |
|
|
def OnOK(self, event): |
185 |
|
|
self.tb_map_umn.set_size(int(self.text_width.GetValue()), int(self.text_height.GetValue())) |
186 |
|
|
self.tb_map_umn.set_units(self.choice_units.GetStringSelection()) |
187 |
jschuengel |
2267 |
previewcolor = self.previewcolor.GetBackgroundColour() |
188 |
|
|
self.tb_map_umn.get_imagecolor().set_rgbcolor(previewcolor.Red(), |
189 |
|
|
previewcolor.Green(), previewcolor.Blue()) |
190 |
jschuengel |
2257 |
self.result ="OK" |
191 |
|
|
self.end_dialog(self.result) |
192 |
|
|
|
193 |
|
|
def OnCancel(self, event): |
194 |
|
|
self.end_dialog(None) |
195 |
|
|
|
196 |
|
|
|
197 |
|
|
class Web_Dialog(wxDialog): |
198 |
|
|
|
199 |
|
|
def __init__(self, parent, ID, title, |
200 |
|
|
pos=wxDefaultPosition, size=wxDefaultSize, |
201 |
|
|
style=wxDEFAULT_DIALOG_STYLE): |
202 |
|
|
|
203 |
|
|
# initialize the Dialog |
204 |
|
|
wxDialog.__init__(self, parent, ID, title, pos, size, style) |
205 |
|
|
|
206 |
|
|
#add all boxes to this top box |
207 |
|
|
top = wxBoxSizer(wxVERTICAL) |
208 |
|
|
|
209 |
|
|
# get the web object |
210 |
|
|
self.tb_map = parent.canvas.Map() |
211 |
|
|
self.umn_web = self.tb_map.extension_umn_mapobj.get_web() |
212 |
|
|
|
213 |
|
|
# create name |
214 |
|
|
box_name = wxBoxSizer(wxHORIZONTAL) |
215 |
|
|
box_name.Add(wxStaticText(self, -1, _("Map-Name:")), 0, |
216 |
|
|
wxALL|wxALIGN_CENTER_VERTICAL, 4) |
217 |
|
|
box_name.Add(wxStaticText(self, -1, self.tb_map.Title()), 0, |
218 |
|
|
wxALL|wxALIGN_CENTER_VERTICAL, 4) |
219 |
|
|
top.Add(box_name, 0, wxEXPAND |wxALL, 5) |
220 |
|
|
|
221 |
|
|
# Imagepath |
222 |
|
|
box_imagepath = wxBoxSizer(wxHORIZONTAL) |
223 |
|
|
box_imagepath.Add(wxStaticText(self, -1, _("Imagepath:")), 0, |
224 |
|
|
wxALL|wxALIGN_LEFT, 4) |
225 |
|
|
self.text_imagepath = wxTextCtrl(self, -1, str(self.umn_web.get_imagepath())) |
226 |
|
|
box_imagepath.Add(self.text_imagepath, 0, |
227 |
|
|
wxALL|wxALIGN_CENTER_VERTICAL, 4) |
228 |
|
|
top.Add(box_imagepath, 0, wxEXPAND |wxALL, 5) |
229 |
|
|
|
230 |
|
|
# Imageurl |
231 |
|
|
box_imageurl = wxBoxSizer(wxHORIZONTAL) |
232 |
|
|
box_imageurl.Add(wxStaticText(self, -1, _("Imageurl:")), 0, |
233 |
|
|
wxALL|wxALIGN_LEFT, 4) |
234 |
|
|
self.text_imageurl = wxTextCtrl(self, -1, str(self.umn_web.get_imageurl())) |
235 |
|
|
box_imageurl.Add(self.text_imageurl, 0, |
236 |
|
|
wxALL|wxALIGN_CENTER_VERTICAL, 4) |
237 |
|
|
top.Add(box_imageurl, 0, wxEXPAND |wxALL, 5) |
238 |
|
|
|
239 |
|
|
# queryformat |
240 |
|
|
# include from a query dialog later |
241 |
|
|
"""box_queryformat = wxBoxSizer(wxHORIZONTAL) |
242 |
|
|
box_queryformat.Add(wxStaticText(self, -1, _("Queryformat:")), 0, |
243 |
|
|
wxALL|wxALIGN_LEFT, 4) |
244 |
|
|
self.text_queryformat = wxTextCtrl(self, -1, str(self.umn_web.get_queryformat())) |
245 |
|
|
box_queryformat.Add(self.text_queryformat, 0, |
246 |
|
|
wxALL|wxALIGN_CENTER_VERTICAL, 4) |
247 |
|
|
top.Add(box_queryformat, 0, wxEXPAND |wxALL, 5) |
248 |
|
|
""" |
249 |
|
|
|
250 |
|
|
#buttons |
251 |
|
|
box_buttons = wxBoxSizer(wxHORIZONTAL) |
252 |
|
|
button = wxButton(self, wxID_OK, _("OK")) |
253 |
|
|
box_buttons.Add(button, 0, wxALL, 5) |
254 |
|
|
button = wxButton(self, wxID_CANCEL, _("Cancel")) |
255 |
|
|
box_buttons.Add(button, 0, wxALL, 5) |
256 |
|
|
#set the button funcitons |
257 |
|
|
EVT_BUTTON(self, wxID_OK, self.OnOK) |
258 |
|
|
EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) |
259 |
|
|
top.Add(box_buttons, 0, wxALIGN_RIGHT) |
260 |
|
|
|
261 |
|
|
# final layout settings |
262 |
|
|
self.SetSizer(top) |
263 |
|
|
top.Fit(self) |
264 |
|
|
|
265 |
|
|
def RunDialog(self): |
266 |
|
|
self.ShowModal() |
267 |
|
|
self.Destroy() |
268 |
|
|
|
269 |
|
|
def end_dialog(self, result): |
270 |
|
|
self.result = result |
271 |
|
|
if self.result is not None: |
272 |
|
|
self.EndModal(wxID_OK) |
273 |
|
|
else: |
274 |
|
|
self.EndModal(wxID_CANCEL) |
275 |
|
|
self.Show(False) |
276 |
|
|
|
277 |
|
|
def OnOK(self, event): |
278 |
|
|
self.umn_web.set_imagepath(self.text_imagepath.GetValue()) |
279 |
|
|
self.umn_web.set_imageurl(self.text_imageurl.GetValue()) |
280 |
|
|
self.umn_web.set_queryformat(self.text_queryformat.GetValue()) |
281 |
|
|
self.result ="OK" |
282 |
|
|
self.end_dialog(self.result) |
283 |
|
|
|
284 |
|
|
def OnCancel(self, event): |
285 |
|
|
self.end_dialog(None) |
286 |
|
|
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
ID_LABEL_CHANGE = 8011 |
290 |
|
|
|
291 |
|
|
class Legend_Dialog(wxDialog): |
292 |
|
|
|
293 |
|
|
def __init__(self, parent, ID, title, |
294 |
|
|
pos=wxDefaultPosition, size=wxDefaultSize, |
295 |
|
|
style=wxDEFAULT_DIALOG_STYLE): |
296 |
|
|
|
297 |
|
|
# initialize the Dialog |
298 |
|
|
wxDialog.__init__(self, parent, ID, title, pos, size, style) |
299 |
|
|
|
300 |
|
|
#add all boxes to this top box |
301 |
|
|
top = wxBoxSizer(wxVERTICAL) |
302 |
|
|
|
303 |
|
|
# get the web object |
304 |
|
|
self.tb_map = parent.canvas.Map() |
305 |
|
|
self.umn_legend = self.tb_map.extension_umn_mapobj.get_legend() |
306 |
|
|
|
307 |
|
|
# create the Keysize |
308 |
|
|
keySize = wxStaticBox(self, 1010, _("KeySize"), style = 0, name = "KeySize Box", ) |
309 |
|
|
box_keysize = wxStaticBoxSizer(keySize, wxVERTICAL) |
310 |
|
|
umn_legend_keysize = self.umn_legend.get_keysize() |
311 |
|
|
box_sizepartWidth = wxBoxSizer(wxHORIZONTAL) |
312 |
|
|
box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 2) |
313 |
|
|
self.text_keysize_width = wxSpinCtrl(self, -1, |
314 |
|
|
value=str(umn_legend_keysize[0]), max=100, min=0, |
315 |
|
|
name='keywidth', style=wxSP_ARROW_KEYS) |
316 |
|
|
box_sizepartWidth.Add(self.text_keysize_width, 2, wxALL, 2) |
317 |
|
|
box_keysize.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 2) |
318 |
|
|
box_sizepartHeight = wxBoxSizer(wxHORIZONTAL) |
319 |
|
|
box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 2), |
320 |
|
|
self.text_keysize_height = wxSpinCtrl(self, -1, |
321 |
|
|
value=str(umn_legend_keysize[1]), max=100, min=0, |
322 |
|
|
name='keyheight', style=wxSP_ARROW_KEYS) |
323 |
|
|
box_sizepartHeight.Add(self.text_keysize_height, 2, wxALL, 2) |
324 |
|
|
box_keysize.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 2) |
325 |
|
|
top.Add(box_keysize,0, wxEXPAND |wxALL, 5) |
326 |
|
|
|
327 |
|
|
# create the Keyspacing |
328 |
|
|
keySpacing= wxStaticBox(self, 1010, _("KeySpacing"), style = 0, name = "KeySpacing Box", ) |
329 |
|
|
box_keyspacing = wxStaticBoxSizer(keySpacing, wxVERTICAL) |
330 |
|
|
umn_legend_keyspacing = self.umn_legend.get_keyspacing() |
331 |
|
|
box_sizepartWidth = wxBoxSizer(wxHORIZONTAL) |
332 |
|
|
box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 2) |
333 |
|
|
self.text_keyspacing_width = wxSpinCtrl(self, -1, |
334 |
|
|
value=str(umn_legend_keyspacing[0]), max=100, min=0, |
335 |
|
|
name='spacingwidth', style=wxSP_ARROW_KEYS) |
336 |
|
|
box_sizepartWidth.Add(self.text_keyspacing_width, 2, wxALL, 2) |
337 |
|
|
box_keyspacing.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 2) |
338 |
|
|
box_sizepartHeight = wxBoxSizer(wxHORIZONTAL) |
339 |
|
|
box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 2), |
340 |
|
|
self.text_keyspacing_height = wxSpinCtrl(self, -1, |
341 |
|
|
value=str(umn_legend_keyspacing[1]), max=100, min=0, |
342 |
|
|
name='spacingheight', style=wxSP_ARROW_KEYS) |
343 |
|
|
box_sizepartHeight.Add(self.text_keyspacing_height, 2, wxALL, 2) |
344 |
|
|
box_keyspacing.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 2) |
345 |
|
|
top.Add(box_keyspacing,0, wxEXPAND |wxALL, 5) |
346 |
|
|
|
347 |
|
|
# color chooser |
348 |
|
|
box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), style = 0, name = "imagecolor") |
349 |
|
|
box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL) |
350 |
|
|
# preview box |
351 |
|
|
self.previewcolor = wxPanel(self, 99, name = 'imagecolorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) |
352 |
|
|
imagecolor = self.umn_legend.get_imagecolor() |
353 |
|
|
self.previewcolor.SetBackgroundColour(wxColour(imagecolor.get_red(), |
354 |
|
|
imagecolor.get_green(), imagecolor.get_blue())) |
355 |
|
|
box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5) |
356 |
|
|
# color change button, opens a new color dialog |
357 |
|
|
button = wxButton(self, ID_COLOR_CHANGE, _("Change Color")) |
358 |
|
|
button.SetFocus() |
359 |
|
|
EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor) |
360 |
|
|
box_color.Add(button, 1, wxEXPAND|wxALL, 5) |
361 |
|
|
top.Add(box_color,0, wxEXPAND |wxALL, 5) |
362 |
|
|
|
363 |
jschuengel |
2267 |
# status |
364 |
jschuengel |
2257 |
umn_legend_status= self.umn_legend.get_status(art="string") |
365 |
|
|
possible_choices = [] |
366 |
|
|
for key in legend_status_type: |
367 |
|
|
possible_choices.append(legend_status_type[key]) |
368 |
|
|
self.choice_status = wxRadioBox(self, -1, choices=possible_choices, |
369 |
|
|
label='Status', majorDimension=1, |
370 |
|
|
name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) |
371 |
|
|
self.choice_status.SetStringSelection(umn_legend_status) |
372 |
|
|
top.Add(self.choice_status,0, wxEXPAND |wxALL, 5) |
373 |
|
|
|
374 |
|
|
# create the positionbox |
375 |
|
|
umn_legend_position= self.umn_legend.get_position(art="string") |
376 |
|
|
possible_choices = [] |
377 |
|
|
for key in legend_position_type: |
378 |
|
|
possible_choices.append(legend_position_type[key]) |
379 |
|
|
self.choice_position = wxRadioBox(self, -1, choices=possible_choices, |
380 |
|
|
label='Position', majorDimension=1, |
381 |
|
|
name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) |
382 |
|
|
self.choice_position.SetStringSelection(umn_legend_position) |
383 |
|
|
top.Add(self.choice_position,0, wxEXPAND |wxALL, 5) |
384 |
|
|
|
385 |
|
|
#test button for label |
386 |
|
|
button = wxButton(self, ID_LABEL_CHANGE, _("Change Label")) |
387 |
|
|
button.SetFocus() |
388 |
|
|
EVT_BUTTON(self, ID_LABEL_CHANGE, self.OnChangeLabel) |
389 |
|
|
top.Add(button, 1, wxEXPAND|wxALL, 5) |
390 |
|
|
|
391 |
|
|
#buttons |
392 |
|
|
box_buttons = wxBoxSizer(wxHORIZONTAL) |
393 |
|
|
button = wxButton(self, wxID_OK, _("OK")) |
394 |
|
|
box_buttons.Add(button, 0, wxALL, 5) |
395 |
|
|
button = wxButton(self, wxID_CANCEL, _("Cancel")) |
396 |
|
|
box_buttons.Add(button, 0, wxALL, 5) |
397 |
|
|
#set the button funcitons |
398 |
|
|
EVT_BUTTON(self, wxID_OK, self.OnOK) |
399 |
|
|
EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) |
400 |
|
|
top.Add(box_buttons, 0, wxALIGN_RIGHT) |
401 |
|
|
|
402 |
|
|
# final layout settings |
403 |
|
|
self.SetSizer(top) |
404 |
|
|
top.Fit(self) |
405 |
|
|
|
406 |
|
|
def OnChangeLabel(self, event): |
407 |
jschuengel |
2267 |
self.umn_label = self.umn_legend.get_label() |
408 |
jschuengel |
2257 |
dialog = Label_Dialog(self, -1, "This is a wxDialog", size=wxSize(350, 200), |
409 |
|
|
style = wxDEFAULT_DIALOG_STYLE |
410 |
|
|
) |
411 |
|
|
dialog.CenterOnScreen() |
412 |
|
|
if dialog.ShowModal() == wxID_OK: |
413 |
|
|
return |
414 |
|
|
dialog.Destroy() |
415 |
|
|
|
416 |
|
|
def OnChangeColor(self, event): |
417 |
|
|
cur = self.umn_legend.get_imagecolor().get_thubancolor() |
418 |
|
|
dialog = ColorDialog(self) |
419 |
|
|
dialog.SetColor(cur) |
420 |
|
|
self.retcolor = None |
421 |
|
|
if dialog.ShowModal() == wxID_OK: |
422 |
|
|
self.retcolor = dialog.GetColor() |
423 |
|
|
dialog.Destroy() |
424 |
|
|
if self.retcolor: |
425 |
|
|
self.redcolor = int(round(self.retcolor.red*255)) |
426 |
|
|
self.greencolor = int(round(self.retcolor.green*255)) |
427 |
|
|
self.bluecolor = int(round(self.retcolor.blue*255)) |
428 |
|
|
self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), |
429 |
|
|
int(self.greencolor), int(self.bluecolor))) |
430 |
|
|
|
431 |
|
|
def RunDialog(self): |
432 |
|
|
self.ShowModal() |
433 |
|
|
self.Destroy() |
434 |
|
|
|
435 |
|
|
def end_dialog(self, result): |
436 |
|
|
self.result = result |
437 |
|
|
if self.result is not None: |
438 |
|
|
self.EndModal(wxID_OK) |
439 |
|
|
else: |
440 |
|
|
self.EndModal(wxID_CANCEL) |
441 |
|
|
self.Show(False) |
442 |
|
|
|
443 |
|
|
def OnOK(self, event): |
444 |
|
|
self.umn_legend.set_keysize(self.text_keysize_width.GetValue(),self.text_keysize_height.GetValue()) |
445 |
|
|
self.umn_legend.set_keyspacing(self.text_keyspacing_width.GetValue(),self.text_keyspacing_height.GetValue()) |
446 |
|
|
self.umn_legend.set_status(self.choice_status.GetStringSelection()) |
447 |
|
|
self.umn_legend.set_position(self.choice_position.GetStringSelection()) |
448 |
jschuengel |
2267 |
previewcolor = self.previewcolor.GetBackgroundColour() |
449 |
|
|
self.umn_legend.get_imagecolor().set_rgbcolor(previewcolor.Red(), |
450 |
|
|
previewcolor.Green(), previewcolor.Blue()) |
451 |
jschuengel |
2257 |
self.result ="OK" |
452 |
|
|
self.end_dialog(self.result) |
453 |
|
|
|
454 |
|
|
def OnCancel(self, event): |
455 |
|
|
self.end_dialog(None) |
456 |
|
|
|
457 |
|
|
class Label_Dialog(wxDialog): |
458 |
|
|
|
459 |
|
|
def __init__(self, parent, ID, title, |
460 |
|
|
pos=wxDefaultPosition, size=wxDefaultSize, |
461 |
|
|
style=wxDEFAULT_DIALOG_STYLE): |
462 |
|
|
|
463 |
|
|
# initialize the Dialog |
464 |
|
|
wxDialog.__init__(self, parent, ID, title, pos, size, style) |
465 |
|
|
|
466 |
|
|
#add all boxes to this top box |
467 |
|
|
top = wxBoxSizer(wxVERTICAL) |
468 |
|
|
|
469 |
|
|
# get the web object |
470 |
jschuengel |
2267 |
self.umn_label = parent.umn_label |
471 |
jschuengel |
2257 |
|
472 |
|
|
# size |
473 |
|
|
labelsize= wxStaticBox(self, 1010, _("Size"), style = 0, name = "Size Box", ) |
474 |
|
|
box_labelsize = wxStaticBoxSizer(labelsize, wxVERTICAL) |
475 |
|
|
umn_label_size= self.umn_label.get_size() |
476 |
|
|
box_size = wxBoxSizer(wxHORIZONTAL) |
477 |
|
|
box_size.Add(wxStaticText(self, -1, _("Size: ")), 0, wxALL, 2) |
478 |
|
|
self.text_labelsize = wxSpinCtrl(self, -1, |
479 |
|
|
value=str(umn_label_size), max=10, min=0, |
480 |
|
|
name='size', style=wxSP_ARROW_KEYS) |
481 |
|
|
box_size.Add(self.text_labelsize, 2, wxALL, 2) |
482 |
|
|
box_labelsize.Add(box_size, 0, wxALIGN_RIGHT | wxALL, 2) |
483 |
|
|
top.Add(box_labelsize,0, wxEXPAND |wxALL, 5) |
484 |
|
|
|
485 |
|
|
|
486 |
|
|
# color chooser |
487 |
|
|
box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, name = "color") |
488 |
|
|
box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL) |
489 |
|
|
# preview box |
490 |
|
|
self.previewcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) |
491 |
|
|
color = self.umn_label.get_color() |
492 |
|
|
self.previewcolor.SetBackgroundColour(wxColour(color.get_red(), |
493 |
|
|
color.get_green(), color.get_blue())) |
494 |
|
|
box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5) |
495 |
|
|
# color change button, opens a new color dialog |
496 |
|
|
button = wxButton(self, ID_COLOR_CHANGE, _("Change Color")) |
497 |
|
|
button.SetFocus() |
498 |
|
|
EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor) |
499 |
|
|
box_color.Add(button, 1, wxEXPAND|wxALL, 5) |
500 |
|
|
top.Add(box_color,0, wxEXPAND |wxALL, 5) |
501 |
|
|
|
502 |
|
|
#get the set type |
503 |
|
|
insidetype = self.umn_label.get_type() |
504 |
|
|
#create the type selector for fonttype (Bitmap, TrueType) |
505 |
|
|
# TODO: Truetype is not supported yet |
506 |
|
|
box_typeStatic = wxStaticBox(self, 1011, _("Type"), style = 0, name = "type") |
507 |
|
|
box_type = wxStaticBoxSizer(box_typeStatic, wxVERTICAL) |
508 |
|
|
sam = [] |
509 |
|
|
for key in label_font_type: |
510 |
|
|
# dont add truetype |
511 |
|
|
#if key != 0: |
512 |
|
|
sam.append(label_font_type[key]) |
513 |
|
|
self.choice_type = wxChoice(self, 40, (80, 50), choices = sam) |
514 |
|
|
self.choice_type.SetStringSelection(insidetype) |
515 |
|
|
box_type.Add(self.choice_type,0, wxEXPAND, wxALL, 5) |
516 |
|
|
top.Add(box_type,0,wxEXPAND |wxALL, 5) |
517 |
|
|
|
518 |
|
|
|
519 |
|
|
# Offset |
520 |
jschuengel |
2267 |
offset= wxStaticBox(self, 1010, _("Offset"), style = 0, name = "Offset Box", ) |
521 |
jschuengel |
2257 |
box_offset = wxStaticBoxSizer(offset, wxVERTICAL) |
522 |
|
|
umn_label_offset = self.umn_label.get_offset() |
523 |
|
|
box_offsetX = wxBoxSizer(wxHORIZONTAL) |
524 |
|
|
box_offsetX.Add(wxStaticText(self, -1, _("X: ")), 0, wxALL, 2) |
525 |
|
|
self.text_offsetx = wxSpinCtrl(self, -1, |
526 |
|
|
value=str(umn_label_offset[0]), max=20, min=0, |
527 |
|
|
name='offsetX', style=wxSP_ARROW_KEYS) |
528 |
|
|
box_offsetX.Add(self.text_offsetx, 2, wxALL, 2) |
529 |
|
|
box_offset.Add(box_offsetX, 0, wxALIGN_RIGHT | wxALL, 2) |
530 |
|
|
box_offsetY = wxBoxSizer(wxHORIZONTAL) |
531 |
|
|
box_offsetY.Add(wxStaticText(self, -1, _("Y: ")), 0, wxALL, 2), |
532 |
|
|
self.text_offsety = wxSpinCtrl(self, -1, |
533 |
|
|
value=str(umn_label_offset[1]), max=100, min=0, |
534 |
|
|
name='offsetY', style=wxSP_ARROW_KEYS) |
535 |
|
|
box_offsetY.Add(self.text_offsety, 2, wxALL, 2) |
536 |
|
|
box_offset.Add(box_offsetY, 0, wxALIGN_RIGHT | wxALL, 2) |
537 |
|
|
top.Add(box_offset,0, wxEXPAND |wxALL, 5) |
538 |
|
|
|
539 |
jschuengel |
2267 |
# offset |
540 |
|
|
umn_partials = self.umn_label.get_partials() |
541 |
|
|
self.choice_partials = wxRadioBox(self, -1, choices=["True","False"], |
542 |
|
|
label='partials', majorDimension=1, |
543 |
|
|
name='partials check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) |
544 |
|
|
self.choice_partials.SetStringSelection(str(umn_partials)) |
545 |
|
|
top.Add(self.choice_partials,0, wxEXPAND |wxALL, 5) |
546 |
jschuengel |
2257 |
|
547 |
jschuengel |
2267 |
|
548 |
jschuengel |
2257 |
#buttons |
549 |
|
|
box_buttons = wxBoxSizer(wxHORIZONTAL) |
550 |
|
|
button = wxButton(self, wxID_OK, _("OK")) |
551 |
|
|
box_buttons.Add(button, 0, wxALL, 5) |
552 |
|
|
button = wxButton(self, wxID_CANCEL, _("Cancel")) |
553 |
|
|
box_buttons.Add(button, 0, wxALL, 5) |
554 |
|
|
#set the button funcitons |
555 |
|
|
EVT_BUTTON(self, wxID_OK, self.OnOK) |
556 |
|
|
EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) |
557 |
|
|
top.Add(box_buttons, 0, wxALIGN_RIGHT) |
558 |
|
|
|
559 |
|
|
# final layout settings |
560 |
|
|
self.SetSizer(top) |
561 |
|
|
top.Fit(self) |
562 |
|
|
|
563 |
|
|
def OnChangeColor(self, event): |
564 |
|
|
cur = self.umn_label.get_color().get_thubancolor() |
565 |
|
|
dialog = ColorDialog(self) |
566 |
|
|
dialog.SetColor(cur) |
567 |
|
|
self.retcolor = None |
568 |
|
|
if dialog.ShowModal() == wxID_OK: |
569 |
|
|
self.retcolor = dialog.GetColor() |
570 |
|
|
dialog.Destroy() |
571 |
|
|
if self.retcolor: |
572 |
|
|
self.redcolor = int(round(self.retcolor.red*255)) |
573 |
|
|
self.greencolor = int(round(self.retcolor.green*255)) |
574 |
|
|
self.bluecolor = int(round(self.retcolor.blue*255)) |
575 |
|
|
self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), |
576 |
|
|
int(self.greencolor), int(self.bluecolor))) |
577 |
|
|
|
578 |
|
|
def RunDialog(self): |
579 |
|
|
self.ShowModal() |
580 |
|
|
self.Destroy() |
581 |
|
|
|
582 |
|
|
def end_dialog(self, result): |
583 |
|
|
self.result = result |
584 |
|
|
if self.result is not None: |
585 |
|
|
self.EndModal(wxID_OK) |
586 |
|
|
else: |
587 |
|
|
self.EndModal(wxID_CANCEL) |
588 |
|
|
self.Show(False) |
589 |
|
|
|
590 |
|
|
def OnOK(self, event): |
591 |
|
|
self.umn_label.set_size(self.text_labelsize.GetValue()) |
592 |
|
|
self.umn_label.set_offset(self.text_offsetx.GetValue(), self.text_offsety.GetValue()) |
593 |
|
|
self.umn_label.set_type(self.choice_type.GetStringSelection()) |
594 |
jschuengel |
2267 |
if self.choice_partials.GetStringSelection() == "True": |
595 |
|
|
self.umn_label.set_partials(True) |
596 |
|
|
else: |
597 |
|
|
self.umn_label.set_partials(False) |
598 |
|
|
previewcolor = self.previewcolor.GetBackgroundColour() |
599 |
|
|
self.umn_label.get_color().set_rgbcolor(previewcolor.Red(), |
600 |
|
|
previewcolor.Green(), previewcolor.Blue()) |
601 |
jschuengel |
2257 |
self.result ="OK" |
602 |
|
|
self.end_dialog(self.result) |
603 |
|
|
|
604 |
|
|
def OnCancel(self, event): |
605 |
|
|
self.end_dialog(None) |
606 |
|
|
|
607 |
jschuengel |
2267 |
class Scalebar_Dialog(wxDialog): |
608 |
|
|
|
609 |
|
|
def __init__(self, parent, ID, title, |
610 |
|
|
pos=wxDefaultPosition, size=wxDefaultSize, |
611 |
|
|
style=wxDEFAULT_DIALOG_STYLE): |
612 |
|
|
|
613 |
|
|
# initialize the Dialog |
614 |
|
|
wxDialog.__init__(self, parent, ID, title, pos, size, style) |
615 |
jschuengel |
2257 |
|
616 |
jschuengel |
2267 |
#add all boxes to this top box |
617 |
|
|
top = wxBoxSizer(wxVERTICAL) |
618 |
|
|
|
619 |
|
|
# get the web object |
620 |
|
|
self.tb_map = parent.canvas.Map() |
621 |
|
|
self.umn_scalebar = self.tb_map.extension_umn_mapobj.get_scalebar() |
622 |
|
|
|
623 |
|
|
# color chooser |
624 |
|
|
box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, name = "color") |
625 |
|
|
box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL) |
626 |
|
|
# preview box |
627 |
|
|
self.previewcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) |
628 |
|
|
color = self.umn_scalebar.get_color() |
629 |
|
|
self.previewcolor.SetBackgroundColour(wxColour(color.get_red(), |
630 |
|
|
color.get_green(), color.get_blue())) |
631 |
|
|
box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5) |
632 |
|
|
# color change button, opens a new color dialog |
633 |
|
|
button = wxButton(self, ID_COLOR_CHANGE, _("Change Color")) |
634 |
|
|
button.SetFocus() |
635 |
|
|
EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor) |
636 |
|
|
box_color.Add(button, 1, wxEXPAND|wxALL, 5) |
637 |
|
|
#top.Add(box_color,0, wxEXPAND |wxALL, 5) |
638 |
|
|
# show the two color chooser horizontal |
639 |
|
|
colorHor = wxBoxSizer(wxHORIZONTAL) |
640 |
|
|
colorHor.Add(box_color,0, wxEXPAND |wxALL, 5) |
641 |
|
|
|
642 |
|
|
# imagecolor chooser |
643 |
|
|
box_imgcolorStatic = wxStaticBox(self, 1011, _("Image Color"), style = 0, name = "imgcolor") |
644 |
|
|
box_imgcolor = wxStaticBoxSizer(box_imgcolorStatic, wxVERTICAL) |
645 |
|
|
# preview box |
646 |
|
|
self.previewimgcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) |
647 |
|
|
color = self.umn_scalebar.get_imagecolor() |
648 |
|
|
self.previewimgcolor.SetBackgroundColour(wxColour(color.get_red(), |
649 |
|
|
color.get_green(), color.get_blue())) |
650 |
|
|
box_imgcolor.Add(self.previewimgcolor, 1, wxGROW | wxALL, 5) |
651 |
|
|
# color change button, opens a new color dialog |
652 |
|
|
button = wxButton(self, ID_IMGCOLOR_CHANGE, _("Change ImageColor")) |
653 |
|
|
button.SetFocus() |
654 |
|
|
EVT_BUTTON(self, ID_IMGCOLOR_CHANGE, self.OnChangeImageColor) |
655 |
|
|
box_imgcolor.Add(button, 1, wxEXPAND|wxALL, 5) |
656 |
|
|
colorHor.Add(box_imgcolor,0, wxEXPAND |wxALL, 5) |
657 |
|
|
#top.Add(box_imgcolor,0, wxEXPAND |wxALL, 5) |
658 |
|
|
top.Add(colorHor,0, wxEXPAND |wxALL, 5) |
659 |
|
|
|
660 |
|
|
# create the intervals |
661 |
|
|
intervalsStatic = wxStaticBox(self, 1010, _("Intervals"), style = 0, name = "Intervals Box", ) |
662 |
|
|
box_intervals = wxStaticBoxSizer(intervalsStatic, wxVERTICAL) |
663 |
|
|
umn_scalebar_intervals = self.umn_scalebar.get_intervals() |
664 |
|
|
self.text_intervals = wxSpinCtrl(self, -1, |
665 |
|
|
value=str(umn_scalebar_intervals), max=100, min=0, |
666 |
|
|
name='intervals', style=wxSP_ARROW_KEYS) |
667 |
|
|
box_intervals.Add(self.text_intervals, 0, wxALIGN_RIGHT | wxALL, 2) |
668 |
|
|
hori2 = wxBoxSizer(wxHORIZONTAL) |
669 |
|
|
hori2.Add(box_intervals,0, wxEXPAND |wxALL, 5) |
670 |
|
|
|
671 |
|
|
#style |
672 |
|
|
umn_scalebar_style= self.umn_scalebar.get_style() |
673 |
|
|
possible_choices = [] |
674 |
|
|
for key in scalebar_style_type: |
675 |
|
|
possible_choices.append(scalebar_style_type[key]) |
676 |
|
|
self.choice_style = wxRadioBox(self, -1, choices=possible_choices, |
677 |
|
|
label='Style', majorDimension=1, |
678 |
|
|
name='style check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) |
679 |
|
|
self.choice_style.SetSelection(umn_scalebar_style) |
680 |
|
|
hori2.Add(self.choice_style, 1, wxEXPAND|wxALL, 5) |
681 |
|
|
top.Add(hori2, 1, wxEXPAND|wxALL, 5) |
682 |
|
|
|
683 |
|
|
#create size settings |
684 |
|
|
try: |
685 |
|
|
insidetxt = self.umn_scalebar.get_size() |
686 |
|
|
except: |
687 |
|
|
insidetxt = (0,0) |
688 |
|
|
# create the Size Box |
689 |
|
|
staticSize = wxStaticBox(self, -1, _("Size"), style = 0, name = "sizeBox", ) |
690 |
|
|
box_size = wxStaticBoxSizer(staticSize, wxHORIZONTAL) |
691 |
|
|
|
692 |
|
|
box_sizepartWidth = wxBoxSizer(wxHORIZONTAL) |
693 |
|
|
box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 4) |
694 |
|
|
self.text_width = wxTextCtrl(self, -1, str(insidetxt[0])) |
695 |
|
|
box_sizepartWidth.Add(self.text_width, 2, wxALL, 4) |
696 |
|
|
box_size.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 5) |
697 |
|
|
box_sizepartHeight = wxBoxSizer(wxHORIZONTAL) |
698 |
|
|
box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 4) |
699 |
|
|
self.text_height = wxTextCtrl(self, -1, str(insidetxt[1])) |
700 |
|
|
box_sizepartHeight.Add(self.text_height, 2, wxALL, 4) |
701 |
|
|
box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5) |
702 |
|
|
top.Add(box_size, 1, wxEXPAND|wxALL, 5) |
703 |
|
|
|
704 |
|
|
# status |
705 |
|
|
umn_scalebar_status= self.umn_scalebar.get_status(art="string") |
706 |
|
|
possible_choices = [] |
707 |
|
|
for key in legend_status_type: |
708 |
|
|
possible_choices.append(scalebar_status_type[key]) |
709 |
|
|
self.choice_status = wxRadioBox(self, -1, choices=possible_choices, |
710 |
|
|
label='Status', majorDimension=1, |
711 |
|
|
name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) |
712 |
|
|
self.choice_status.SetStringSelection(umn_scalebar_status) |
713 |
|
|
top.Add(self.choice_status,0, wxEXPAND |wxALL, 5) |
714 |
|
|
|
715 |
|
|
# position |
716 |
|
|
umn_scalebar_position= self.umn_scalebar.get_position(art="string") |
717 |
|
|
possible_choices = [] |
718 |
|
|
for key in scalebar_position_type: |
719 |
|
|
possible_choices.append(scalebar_position_type[key]) |
720 |
|
|
self.choice_position = wxRadioBox(self, -1, choices=possible_choices, |
721 |
|
|
label='Position', majorDimension=1, |
722 |
|
|
name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) |
723 |
|
|
self.choice_position.SetStringSelection(umn_scalebar_position) |
724 |
|
|
top.Add(self.choice_position,0, wxEXPAND |wxALL, 5) |
725 |
|
|
|
726 |
|
|
|
727 |
|
|
#get the set unittype |
728 |
|
|
insideunit = self.umn_scalebar .get_units() |
729 |
|
|
#create the Unittype selector |
730 |
|
|
box_unitsStatic = wxStaticBox(self, -1, _("Unit Type"), style = 0, name = "unittype") |
731 |
|
|
box_units = wxStaticBoxSizer(box_unitsStatic, wxVERTICAL) |
732 |
|
|
sam = [] |
733 |
|
|
for key in unit_type: |
734 |
|
|
sam.append(unit_type[key]) |
735 |
|
|
self.choice_units = wxChoice(self, 40, (80, 50), choices = sam) |
736 |
|
|
self.choice_units.SetStringSelection(insideunit) |
737 |
|
|
box_units.Add(self.choice_units,0, wxEXPAND, wxALL, 5) |
738 |
|
|
top.Add(box_units, 1, wxEXPAND|wxALL, 5) |
739 |
|
|
|
740 |
|
|
#test button for label |
741 |
|
|
button = wxButton(self, ID_LABEL_CHANGE, _("Change Label")) |
742 |
|
|
EVT_BUTTON(self, ID_LABEL_CHANGE, self.OnChangeLabel) |
743 |
|
|
top.Add(button, 1, wxEXPAND|wxALL, 5) |
744 |
|
|
|
745 |
|
|
#buttons |
746 |
|
|
box_buttons = wxBoxSizer(wxHORIZONTAL) |
747 |
|
|
button = wxButton(self, wxID_OK, _("OK")) |
748 |
|
|
box_buttons.Add(button, 0, wxALL, 5) |
749 |
|
|
button = wxButton(self, wxID_CANCEL, _("Cancel")) |
750 |
|
|
button.SetFocus() |
751 |
|
|
box_buttons.Add(button, 0, wxALL, 5) |
752 |
|
|
#set the button funcitons |
753 |
|
|
EVT_BUTTON(self, wxID_OK, self.OnOK) |
754 |
|
|
EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) |
755 |
|
|
top.Add(box_buttons, 0, wxALIGN_RIGHT) |
756 |
|
|
|
757 |
|
|
# final layout settings |
758 |
|
|
self.SetSizer(top) |
759 |
|
|
top.Fit(self) |
760 |
|
|
|
761 |
|
|
def OnChangeLabel(self, event): |
762 |
|
|
# set the umn_label for scalebar so the Label_Dialog can be used |
763 |
|
|
self.umn_label = self.umn_scalebar.get_label() |
764 |
|
|
dialog = Label_Dialog(self, -1, "This is a wxDialog", size=wxSize(350, 200), |
765 |
|
|
style = wxDEFAULT_DIALOG_STYLE |
766 |
|
|
) |
767 |
|
|
dialog.CenterOnScreen() |
768 |
|
|
if dialog.ShowModal() == wxID_OK: |
769 |
|
|
return |
770 |
|
|
dialog.Destroy() |
771 |
|
|
|
772 |
|
|
def OnChangeImageColor(self, event): |
773 |
|
|
cur = self.umn_scalebar.get_imagecolor().get_thubancolor() |
774 |
|
|
dialog = ColorDialog(self) |
775 |
|
|
dialog.SetColor(cur) |
776 |
|
|
self.retcolor = None |
777 |
|
|
if dialog.ShowModal() == wxID_OK: |
778 |
|
|
self.retcolor = dialog.GetColor() |
779 |
|
|
dialog.Destroy() |
780 |
|
|
if self.retcolor: |
781 |
|
|
self.redcolor = int(round(self.retcolor.red*255)) |
782 |
|
|
self.greencolor = int(round(self.retcolor.green*255)) |
783 |
|
|
self.bluecolor = int(round(self.retcolor.blue*255)) |
784 |
|
|
self.previewimgcolor.SetBackgroundColour(wxColour((self.redcolor), |
785 |
|
|
int(self.greencolor), int(self.bluecolor))) |
786 |
|
|
|
787 |
|
|
def OnChangeColor(self, event): |
788 |
|
|
cur = self.umn_scalebar.get_color().get_thubancolor() |
789 |
|
|
dialog = ColorDialog(self) |
790 |
|
|
dialog.SetColor(cur) |
791 |
|
|
self.retcolor = None |
792 |
|
|
if dialog.ShowModal() == wxID_OK: |
793 |
|
|
self.retcolor = dialog.GetColor() |
794 |
|
|
dialog.Destroy() |
795 |
|
|
if self.retcolor: |
796 |
|
|
self.redcolor = int(round(self.retcolor.red*255)) |
797 |
|
|
self.greencolor = int(round(self.retcolor.green*255)) |
798 |
|
|
self.bluecolor = int(round(self.retcolor.blue*255)) |
799 |
|
|
self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), |
800 |
|
|
int(self.greencolor), int(self.bluecolor))) |
801 |
|
|
|
802 |
|
|
def RunDialog(self): |
803 |
|
|
self.ShowModal() |
804 |
|
|
self.Destroy() |
805 |
|
|
|
806 |
|
|
def end_dialog(self, result): |
807 |
|
|
self.result = result |
808 |
|
|
if self.result is not None: |
809 |
|
|
self.EndModal(wxID_OK) |
810 |
|
|
else: |
811 |
|
|
self.EndModal(wxID_CANCEL) |
812 |
|
|
self.Show(False) |
813 |
|
|
|
814 |
|
|
def OnOK(self, event): |
815 |
|
|
self.umn_scalebar.set_status(self.choice_status.GetStringSelection()) |
816 |
|
|
self.umn_scalebar.set_units(self.choice_units.GetStringSelection()) |
817 |
|
|
self.umn_scalebar.set_intervals(self.text_intervals.GetValue()) |
818 |
|
|
self.umn_scalebar.set_style(self.choice_style.GetSelection()) |
819 |
|
|
self.umn_scalebar.set_position(self.choice_position.GetStringSelection()) |
820 |
|
|
self.umn_scalebar.set_size(int(self.text_width.GetValue()), int(self.text_height.GetValue())) |
821 |
|
|
|
822 |
|
|
previewcolor = self.previewcolor.GetBackgroundColour() |
823 |
|
|
self.umn_scalebar.get_color().set_rgbcolor(previewcolor.Red(), |
824 |
|
|
previewcolor.Green(), previewcolor.Blue()) |
825 |
|
|
previewimgcolor = self.previewimgcolor.GetBackgroundColour() |
826 |
|
|
self.umn_scalebar.get_imagecolor().set_rgbcolor(previewimgcolor.Red(), |
827 |
|
|
previewimgcolor.Green(), previewimgcolor.Blue()) |
828 |
|
|
self.result ="OK" |
829 |
|
|
self.end_dialog(self.result) |
830 |
|
|
|
831 |
|
|
def OnCancel(self, event): |
832 |
|
|
self.end_dialog(None) |
833 |
|
|
|
834 |
|
|
|
835 |
|
|
def scalebarsettings(context): |
836 |
|
|
win = Scalebar_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200), |
837 |
|
|
style = wxDEFAULT_DIALOG_STYLE |
838 |
|
|
) |
839 |
|
|
win.CenterOnScreen() |
840 |
|
|
val = win.ShowModal() |
841 |
|
|
|
842 |
jschuengel |
2257 |
def mapsettings(context): |
843 |
|
|
win = Map_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200), |
844 |
|
|
style = wxDEFAULT_DIALOG_STYLE |
845 |
|
|
) |
846 |
|
|
win.CenterOnScreen() |
847 |
|
|
val = win.ShowModal() |
848 |
|
|
|
849 |
|
|
def websettings(context): |
850 |
|
|
win = Web_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200), |
851 |
|
|
style = wxDEFAULT_DIALOG_STYLE |
852 |
|
|
) |
853 |
|
|
win.CenterOnScreen() |
854 |
|
|
val = win.ShowModal() |
855 |
|
|
|
856 |
|
|
def legendsettings(context): |
857 |
|
|
win = Legend_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200), |
858 |
|
|
style = wxDEFAULT_DIALOG_STYLE |
859 |
|
|
) |
860 |
|
|
win.CenterOnScreen() |
861 |
|
|
val = win.ShowModal() |
862 |
|
|
|
863 |
|
|
#create a new mapfile |
864 |
|
|
def create_new_mapfile(context): |
865 |
|
|
theMap = MF_Map(mapObj("")) |
866 |
|
|
context.mainwindow.canvas.Map().extension_umn_mapobj = theMap |
867 |
|
|
|
868 |
|
|
# ################################### |
869 |
|
|
# |
870 |
|
|
# Hook in MapServer Extension into Thuban |
871 |
|
|
# |
872 |
|
|
# ################################### |
873 |
|
|
|
874 |
|
|
# find the extensions menu (create it anew if not found) |
875 |
|
|
experimental_menu = main_menu.FindOrInsertMenu("experimental", _("Experimenta&l")) |
876 |
|
|
# find the extension menu and add a new submenu if found |
877 |
|
|
mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver", _("&MapServer")) |
878 |
|
|
|
879 |
|
|
|
880 |
|
|
# register the new command |
881 |
|
|
registry.Add(Command("create_new_mapfile", _("Create an empty MapObj"), \ |
882 |
|
|
create_new_mapfile, helptext = _("Create a new empty mapscript MapObj"))) |
883 |
|
|
# finally add the new entry to the extensions menu |
884 |
|
|
mapserver_menu.InsertItem("create_new_mapfile") |
885 |
|
|
|
886 |
|
|
|
887 |
|
|
# register the new command (Map Settings Dialog) |
888 |
|
|
registry.Add(Command("Map Settings", _("Map Settings"), mapsettings, |
889 |
|
|
helptext = _("Edit the Map Setting"))) |
890 |
|
|
# finally add the new entry to the extensions menu |
891 |
|
|
mapserver_menu.InsertItem("Map Settings") |
892 |
|
|
|
893 |
|
|
# register the new command (Map Settings Dialog) |
894 |
|
|
registry.Add(Command("Web Settings", _("Web Settings"), websettings, |
895 |
|
|
helptext = _("Edit the Web Setting"))) |
896 |
|
|
# finally add the new entry to the extensions menu |
897 |
|
|
mapserver_menu.InsertItem("Web Settings") |
898 |
|
|
|
899 |
|
|
# register the new command (Legend Settings Dialog) |
900 |
|
|
registry.Add(Command("Legend Settings", _("Legend Settings"), legendsettings, |
901 |
|
|
helptext = _("Edit the Legend Setting"))) |
902 |
|
|
# finally add the new entry to the extensions menu |
903 |
|
|
mapserver_menu.InsertItem("Legend Settings") |
904 |
|
|
|
905 |
jschuengel |
2267 |
# register the new command (Scalebar Settings Dialog) |
906 |
|
|
registry.Add(Command("Scalebar Settings", _("Scalebar Settings"), scalebarsettings, |
907 |
|
|
helptext = _("Edit the Scalebar Setting"))) |
908 |
|
|
# finally add the new entry to the extensions menu |
909 |
|
|
mapserver_menu.InsertItem("Scalebar Settings") |
910 |
jschuengel |
2257 |
|
911 |
jschuengel |
2267 |
|