jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,1.1,1.2
cvs@intevation.de
cvs at intevation.de
Tue Jul 6 16:30:47 CEST 2004
Author: jschuengel
Update of /thubanrepository/thuban/Extensions/umn_mapserver
In directory doto:/tmp/cvs-serv4563
Modified Files:
mf_handle.py
Log Message:
All colors are now set when press ok in the assosiated dialog and not at the end of the colordialog. Added the Dialog for the Scalebar.
(Label_Dialog): Added the offset option
Index: mf_handle.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_handle.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mf_handle.py 1 Jul 2004 14:35:07 -0000 1.1
+++ mf_handle.py 6 Jul 2004 14:30:45 -0000 1.2
@@ -51,7 +51,8 @@
from Thuban.UI.colordialog import ColorDialog
from mapfile import unit_type, legend_status_type, legend_position_type, \
- label_font_type
+ label_font_type, scalebar_status_type, scalebar_style_type, \
+ scalebar_position_type
# ###################################
#
@@ -60,6 +61,7 @@
# ###################################
ID_COLOR_CHANGE= 8001
+ID_IMGCOLOR_CHANGE = 8002
class Map_Dialog(wxDialog):
@@ -166,8 +168,6 @@
self.bluecolor = int(round(self.retcolor.blue*255))
self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
int(self.greencolor), int(self.bluecolor)))
- self.tb_map_umn.get_imagecolor().set_rgbcolor(self.redcolor,
- self.greencolor, self.bluecolor)
def RunDialog(self):
self.ShowModal()
@@ -184,6 +184,9 @@
def OnOK(self, event):
self.tb_map_umn.set_size(int(self.text_width.GetValue()), int(self.text_height.GetValue()))
self.tb_map_umn.set_units(self.choice_units.GetStringSelection())
+ previewcolor = self.previewcolor.GetBackgroundColour()
+ self.tb_map_umn.get_imagecolor().set_rgbcolor(previewcolor.Red(),
+ previewcolor.Green(), previewcolor.Blue())
self.result ="OK"
self.end_dialog(self.result)
@@ -357,7 +360,7 @@
box_color.Add(button, 1, wxEXPAND|wxALL, 5)
top.Add(box_color,0, wxEXPAND |wxALL, 5)
- # create the positionbox
+ # status
umn_legend_status= self.umn_legend.get_status(art="string")
possible_choices = []
for key in legend_status_type:
@@ -401,6 +404,7 @@
top.Fit(self)
def OnChangeLabel(self, event):
+ self.umn_label = self.umn_legend.get_label()
dialog = Label_Dialog(self, -1, "This is a wxDialog", size=wxSize(350, 200),
style = wxDEFAULT_DIALOG_STYLE
)
@@ -423,8 +427,6 @@
self.bluecolor = int(round(self.retcolor.blue*255))
self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
int(self.greencolor), int(self.bluecolor)))
- self.umn_legend.get_imagecolor().set_rgbcolor(self.redcolor,
- self.greencolor, self.bluecolor)
def RunDialog(self):
self.ShowModal()
@@ -443,6 +445,9 @@
self.umn_legend.set_keyspacing(self.text_keyspacing_width.GetValue(),self.text_keyspacing_height.GetValue())
self.umn_legend.set_status(self.choice_status.GetStringSelection())
self.umn_legend.set_position(self.choice_position.GetStringSelection())
+ previewcolor = self.previewcolor.GetBackgroundColour()
+ self.umn_legend.get_imagecolor().set_rgbcolor(previewcolor.Red(),
+ previewcolor.Green(), previewcolor.Blue())
self.result ="OK"
self.end_dialog(self.result)
@@ -462,8 +467,7 @@
top = wxBoxSizer(wxVERTICAL)
# get the web object
- #self.tb_map = parent.canvas.Map()
- self.umn_label = parent.umn_legend.get_label()
+ self.umn_label = parent.umn_label
# size
labelsize= wxStaticBox(self, 1010, _("Size"), style = 0, name = "Size Box", )
@@ -513,7 +517,7 @@
# Offset
- offset= wxStaticBox(self, 1010, _("KeySpacing"), style = 0, name = "KeySpacing Box", )
+ offset= wxStaticBox(self, 1010, _("Offset"), style = 0, name = "Offset Box", )
box_offset = wxStaticBoxSizer(offset, wxVERTICAL)
umn_label_offset = self.umn_label.get_offset()
box_offsetX = wxBoxSizer(wxHORIZONTAL)
@@ -532,6 +536,14 @@
box_offset.Add(box_offsetY, 0, wxALIGN_RIGHT | wxALL, 2)
top.Add(box_offset,0, wxEXPAND |wxALL, 5)
+ # offset
+ umn_partials = self.umn_label.get_partials()
+ self.choice_partials = wxRadioBox(self, -1, choices=["True","False"],
+ label='partials', majorDimension=1,
+ name='partials check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
+ self.choice_partials.SetStringSelection(str(umn_partials))
+ top.Add(self.choice_partials,0, wxEXPAND |wxALL, 5)
+
#buttons
box_buttons = wxBoxSizer(wxHORIZONTAL)
@@ -562,8 +574,6 @@
self.bluecolor = int(round(self.retcolor.blue*255))
self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
int(self.greencolor), int(self.bluecolor)))
- self.umn_label.get_color().set_rgbcolor(self.redcolor,
- self.greencolor, self.bluecolor)
def RunDialog(self):
self.ShowModal()
@@ -581,12 +591,253 @@
self.umn_label.set_size(self.text_labelsize.GetValue())
self.umn_label.set_offset(self.text_offsetx.GetValue(), self.text_offsety.GetValue())
self.umn_label.set_type(self.choice_type.GetStringSelection())
+ if self.choice_partials.GetStringSelection() == "True":
+ self.umn_label.set_partials(True)
+ else:
+ self.umn_label.set_partials(False)
+ previewcolor = self.previewcolor.GetBackgroundColour()
+ self.umn_label.get_color().set_rgbcolor(previewcolor.Red(),
+ previewcolor.Green(), previewcolor.Blue())
self.result ="OK"
self.end_dialog(self.result)
def OnCancel(self, event):
self.end_dialog(None)
+class Scalebar_Dialog(wxDialog):
+
+ def __init__(self, parent, ID, title,
+ pos=wxDefaultPosition, size=wxDefaultSize,
+ style=wxDEFAULT_DIALOG_STYLE):
+
+ # initialize the Dialog
+ wxDialog.__init__(self, parent, ID, title, pos, size, style)
+
+ #add all boxes to this top box
+ top = wxBoxSizer(wxVERTICAL)
+
+ # get the web object
+ self.tb_map = parent.canvas.Map()
+ self.umn_scalebar = self.tb_map.extension_umn_mapobj.get_scalebar()
+
+ # color chooser
+ box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, name = "color")
+ box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL)
+ # preview box
+ self.previewcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN)
+ color = self.umn_scalebar.get_color()
+ self.previewcolor.SetBackgroundColour(wxColour(color.get_red(),
+ color.get_green(), color.get_blue()))
+ box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5)
+ # color change button, opens a new color dialog
+ button = wxButton(self, ID_COLOR_CHANGE, _("Change Color"))
+ button.SetFocus()
+ EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor)
+ box_color.Add(button, 1, wxEXPAND|wxALL, 5)
+ #top.Add(box_color,0, wxEXPAND |wxALL, 5)
+ # show the two color chooser horizontal
+ colorHor = wxBoxSizer(wxHORIZONTAL)
+ colorHor.Add(box_color,0, wxEXPAND |wxALL, 5)
+
+ # imagecolor chooser
+ box_imgcolorStatic = wxStaticBox(self, 1011, _("Image Color"), style = 0, name = "imgcolor")
+ box_imgcolor = wxStaticBoxSizer(box_imgcolorStatic, wxVERTICAL)
+ # preview box
+ self.previewimgcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN)
+ color = self.umn_scalebar.get_imagecolor()
+ self.previewimgcolor.SetBackgroundColour(wxColour(color.get_red(),
+ color.get_green(), color.get_blue()))
+ box_imgcolor.Add(self.previewimgcolor, 1, wxGROW | wxALL, 5)
+ # color change button, opens a new color dialog
+ button = wxButton(self, ID_IMGCOLOR_CHANGE, _("Change ImageColor"))
+ button.SetFocus()
+ EVT_BUTTON(self, ID_IMGCOLOR_CHANGE, self.OnChangeImageColor)
+ box_imgcolor.Add(button, 1, wxEXPAND|wxALL, 5)
+ colorHor.Add(box_imgcolor,0, wxEXPAND |wxALL, 5)
+ #top.Add(box_imgcolor,0, wxEXPAND |wxALL, 5)
+ top.Add(colorHor,0, wxEXPAND |wxALL, 5)
+
+ # create the intervals
+ intervalsStatic = wxStaticBox(self, 1010, _("Intervals"), style = 0, name = "Intervals Box", )
+ box_intervals = wxStaticBoxSizer(intervalsStatic, wxVERTICAL)
+ umn_scalebar_intervals = self.umn_scalebar.get_intervals()
+ self.text_intervals = wxSpinCtrl(self, -1,
+ value=str(umn_scalebar_intervals), max=100, min=0,
+ name='intervals', style=wxSP_ARROW_KEYS)
+ box_intervals.Add(self.text_intervals, 0, wxALIGN_RIGHT | wxALL, 2)
+ hori2 = wxBoxSizer(wxHORIZONTAL)
+ hori2.Add(box_intervals,0, wxEXPAND |wxALL, 5)
+
+ #style
+ umn_scalebar_style= self.umn_scalebar.get_style()
+ possible_choices = []
+ for key in scalebar_style_type:
+ possible_choices.append(scalebar_style_type[key])
+ self.choice_style = wxRadioBox(self, -1, choices=possible_choices,
+ label='Style', majorDimension=1,
+ name='style check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
+ self.choice_style.SetSelection(umn_scalebar_style)
+ hori2.Add(self.choice_style, 1, wxEXPAND|wxALL, 5)
+ top.Add(hori2, 1, wxEXPAND|wxALL, 5)
+
+ #create size settings
+ try:
+ insidetxt = self.umn_scalebar.get_size()
+ except:
+ insidetxt = (0,0)
+ # create the Size Box
+ staticSize = wxStaticBox(self, -1, _("Size"), style = 0, name = "sizeBox", )
+ box_size = wxStaticBoxSizer(staticSize, wxHORIZONTAL)
+
+ box_sizepartWidth = wxBoxSizer(wxHORIZONTAL)
+ box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 4)
+ self.text_width = wxTextCtrl(self, -1, str(insidetxt[0]))
+ box_sizepartWidth.Add(self.text_width, 2, wxALL, 4)
+ box_size.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 5)
+ box_sizepartHeight = wxBoxSizer(wxHORIZONTAL)
+ box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 4)
+ self.text_height = wxTextCtrl(self, -1, str(insidetxt[1]))
+ box_sizepartHeight.Add(self.text_height, 2, wxALL, 4)
+ box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5)
+ top.Add(box_size, 1, wxEXPAND|wxALL, 5)
+
+ # status
+ umn_scalebar_status= self.umn_scalebar.get_status(art="string")
+ possible_choices = []
+ for key in legend_status_type:
+ possible_choices.append(scalebar_status_type[key])
+ self.choice_status = wxRadioBox(self, -1, choices=possible_choices,
+ label='Status', majorDimension=1,
+ name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
+ self.choice_status.SetStringSelection(umn_scalebar_status)
+ top.Add(self.choice_status,0, wxEXPAND |wxALL, 5)
+
+ # position
+ umn_scalebar_position= self.umn_scalebar.get_position(art="string")
+ possible_choices = []
+ for key in scalebar_position_type:
+ possible_choices.append(scalebar_position_type[key])
+ self.choice_position = wxRadioBox(self, -1, choices=possible_choices,
+ label='Position', majorDimension=1,
+ name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS)
+ self.choice_position.SetStringSelection(umn_scalebar_position)
+ top.Add(self.choice_position,0, wxEXPAND |wxALL, 5)
+
+
+ #get the set unittype
+ insideunit = self.umn_scalebar .get_units()
+ #create the Unittype selector
+ box_unitsStatic = wxStaticBox(self, -1, _("Unit Type"), style = 0, name = "unittype")
+ box_units = wxStaticBoxSizer(box_unitsStatic, wxVERTICAL)
+ sam = []
+ for key in unit_type:
+ sam.append(unit_type[key])
+ self.choice_units = wxChoice(self, 40, (80, 50), choices = sam)
+ self.choice_units.SetStringSelection(insideunit)
+ box_units.Add(self.choice_units,0, wxEXPAND, wxALL, 5)
+ top.Add(box_units, 1, wxEXPAND|wxALL, 5)
+
+ #test button for label
+ button = wxButton(self, ID_LABEL_CHANGE, _("Change Label"))
+ EVT_BUTTON(self, ID_LABEL_CHANGE, self.OnChangeLabel)
+ top.Add(button, 1, wxEXPAND|wxALL, 5)
+
+ #buttons
+ box_buttons = wxBoxSizer(wxHORIZONTAL)
+ button = wxButton(self, wxID_OK, _("OK"))
+ box_buttons.Add(button, 0, wxALL, 5)
+ button = wxButton(self, wxID_CANCEL, _("Cancel"))
+ button.SetFocus()
+ box_buttons.Add(button, 0, wxALL, 5)
+ #set the button funcitons
+ EVT_BUTTON(self, wxID_OK, self.OnOK)
+ EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
+ top.Add(box_buttons, 0, wxALIGN_RIGHT)
+
+ # final layout settings
+ self.SetSizer(top)
+ top.Fit(self)
+
+ def OnChangeLabel(self, event):
+ # set the umn_label for scalebar so the Label_Dialog can be used
+ self.umn_label = self.umn_scalebar.get_label()
+ dialog = Label_Dialog(self, -1, "This is a wxDialog", size=wxSize(350, 200),
+ style = wxDEFAULT_DIALOG_STYLE
+ )
+ dialog.CenterOnScreen()
+ if dialog.ShowModal() == wxID_OK:
+ return
+ dialog.Destroy()
+
+ def OnChangeImageColor(self, event):
+ cur = self.umn_scalebar.get_imagecolor().get_thubancolor()
+ dialog = ColorDialog(self)
+ dialog.SetColor(cur)
+ self.retcolor = None
+ if dialog.ShowModal() == wxID_OK:
+ self.retcolor = dialog.GetColor()
+ dialog.Destroy()
+ if self.retcolor:
+ self.redcolor = int(round(self.retcolor.red*255))
+ self.greencolor = int(round(self.retcolor.green*255))
+ self.bluecolor = int(round(self.retcolor.blue*255))
+ self.previewimgcolor.SetBackgroundColour(wxColour((self.redcolor),
+ int(self.greencolor), int(self.bluecolor)))
+
+ def OnChangeColor(self, event):
+ cur = self.umn_scalebar.get_color().get_thubancolor()
+ dialog = ColorDialog(self)
+ dialog.SetColor(cur)
+ self.retcolor = None
+ if dialog.ShowModal() == wxID_OK:
+ self.retcolor = dialog.GetColor()
+ dialog.Destroy()
+ if self.retcolor:
+ self.redcolor = int(round(self.retcolor.red*255))
+ self.greencolor = int(round(self.retcolor.green*255))
+ self.bluecolor = int(round(self.retcolor.blue*255))
+ self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
+ int(self.greencolor), int(self.bluecolor)))
+
+ def RunDialog(self):
+ self.ShowModal()
+ self.Destroy()
+
+ def end_dialog(self, result):
+ self.result = result
+ if self.result is not None:
+ self.EndModal(wxID_OK)
+ else:
+ self.EndModal(wxID_CANCEL)
+ self.Show(False)
+
+ def OnOK(self, event):
+ self.umn_scalebar.set_status(self.choice_status.GetStringSelection())
+ self.umn_scalebar.set_units(self.choice_units.GetStringSelection())
+ self.umn_scalebar.set_intervals(self.text_intervals.GetValue())
+ self.umn_scalebar.set_style(self.choice_style.GetSelection())
+ self.umn_scalebar.set_position(self.choice_position.GetStringSelection())
+ self.umn_scalebar.set_size(int(self.text_width.GetValue()), int(self.text_height.GetValue()))
+
+ previewcolor = self.previewcolor.GetBackgroundColour()
+ self.umn_scalebar.get_color().set_rgbcolor(previewcolor.Red(),
+ previewcolor.Green(), previewcolor.Blue())
+ previewimgcolor = self.previewimgcolor.GetBackgroundColour()
+ self.umn_scalebar.get_imagecolor().set_rgbcolor(previewimgcolor.Red(),
+ previewimgcolor.Green(), previewimgcolor.Blue())
+ self.result ="OK"
+ self.end_dialog(self.result)
+
+ def OnCancel(self, event):
+ self.end_dialog(None)
+
+
+def scalebarsettings(context):
+ win = Scalebar_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200),
+ style = wxDEFAULT_DIALOG_STYLE
+ )
+ win.CenterOnScreen()
+ val = win.ShowModal()
def mapsettings(context):
win = Map_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200),
@@ -650,5 +901,11 @@
helptext = _("Edit the Legend Setting")))
# finally add the new entry to the extensions menu
mapserver_menu.InsertItem("Legend Settings")
+
+# register the new command (Scalebar Settings Dialog)
+registry.Add(Command("Scalebar Settings", _("Scalebar Settings"), scalebarsettings,
+ helptext = _("Edit the Scalebar Setting")))
+# finally add the new entry to the extensions menu
+mapserver_menu.InsertItem("Scalebar Settings")
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)