jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,1.4,1.5
cvs@intevation.de
cvs at intevation.de
Wed Jul 14 12:35:53 CEST 2004
Author: jschuengel
Update of /thubanrepository/thuban/Extensions/umn_mapserver
In directory doto:/tmp/cvs-serv9201
Modified Files:
mf_handle.py
Log Message:
Removed the import Thuban.UI.mainwindow clause, because it is not needed.
Added the command Refresh() to all "OnChangeColor()" functions, because the color preview window was not updated on a color change.
Added the function to check if a mapobject exists and used it to set the status of the menu items. If no mapobject exists the settings could not be edditied.
(Map_Dialog): Moved the imagetype selector from the Outputformat_Dialog to Map_Dialog and removed Outputformat_Dialog.
(Web_Dialog): Removed the name label and added the template textbox.
Index: mf_handle.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_handle.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mf_handle.py 8 Jul 2004 14:27:58 -0000 1.4
+++ mf_handle.py 14 Jul 2004 10:35:51 -0000 1.5
@@ -39,9 +39,6 @@
# instance registry.
from Thuban.UI.command import registry, Command
-# The instance of the main menu of the Thuban application
-import Thuban.UI.mainwindow
-
# needed to add the new menu
from Thuban.UI.mainwindow import main_menu
@@ -101,6 +98,26 @@
box_sizepartHeight.Add(self.text_height, 2, wxALL, 4)
box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5)
+ # get the web object
+ self.tb_map = parent.canvas.Map()
+ self.tb_map_umn = self.tb_map.extension_umn_mapobj
+
+ #get the imagetype
+ umn_imagetype = self.tb_map_umn.get_imagetype()
+ # create a list with the outputformat names
+ umn_outputformats = []
+ for format in self.tb_map_umn.get_alloutputformats():
+ umn_outputformats.append(format.get_name())
+ #Imagetype selector
+ box_imagetypeStatic = wxStaticBox(self, -1, _("Image Type"),
+ style = 0, name = "imagetype")
+ box_imagetype = wxStaticBoxSizer(box_imagetypeStatic, wxVERTICAL)
+ self.choice_imgtype = wxChoice(self, 8060, (80, 50),
+ choices = umn_outputformats)
+ EVT_CHOICE(self, 8060, self.EvtChoiceBox)
+ self.choice_imgtype.SetStringSelection(umn_imagetype)
+ box_imagetype.Add(self.choice_imgtype,0, wxEXPAND, wxALL, 5)
+
#unittype
insideunit = self.tb_map_umn.get_units()
#Unittype selector
@@ -153,6 +170,7 @@
top = wxBoxSizer(wxVERTICAL)
top.Add(box_name, 0, wxEXPAND |wxALL, 5)
top.Add(box_size, 0, wxEXPAND |wxALL, 5)
+ top.Add(box_imagetype,0, wxEXPAND |wxALL, 5)
top.Add(box_units,0, wxEXPAND |wxALL, 5)
top.Add(box_color,0, wxEXPAND |wxALL, 5)
top.Add(self.choice_status,0, wxEXPAND |wxALL, 5)
@@ -176,6 +194,11 @@
self.bluecolor = int(round(self.retcolor.blue*255))
self.previewcolor.SetBackgroundColour(wxColour((self.redcolor),
int(self.greencolor), int(self.bluecolor)))
+ # refresh the colorbox to show the new color
+ self.previewcolor.Refresh()
+
+ def EvtChoiceBox(self, event):
+ outformat = self.tb_map_umn.get_outputformat().get_name()
def RunDialog(self):
self.ShowModal()
@@ -200,76 +223,6 @@
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)
-
- def OnCancel(self, event):
- self.end_dialog(None)
-
-
-class OutputFormat_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)
-
- # get the web object
- self.tb_map = parent.canvas.Map()
- self.tb_map_umn = self.tb_map.extension_umn_mapobj
-
- #get the imagetype
- umn_imagetype = self.tb_map_umn.get_imagetype()
- # create a list with the outputformat names
- umn_outputformats = []
- for format in self.tb_map_umn.get_alloutputformats():
- umn_outputformats.append(format.get_name())
- #Imagetype selector
- box_imagetypeStatic = wxStaticBox(self, -1, _("Image Type"),
- style = 0, name = "imagetype")
- box_imagetype = wxStaticBoxSizer(box_imagetypeStatic, wxVERTICAL)
- self.choice_imgtype = wxChoice(self, 8060, (80, 50),
- choices = umn_outputformats)
- EVT_CHOICE(self, 8060, self.EvtChoiceBox)
- self.choice_imgtype.SetStringSelection(umn_imagetype)
- box_imagetype.Add(self.choice_imgtype,0, 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"))
- 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)
-
- #add all boxes to the box top
- top = wxBoxSizer(wxVERTICAL)
- top.Add(box_imagetype,0, wxEXPAND |wxALL, 5)
- top.Add(box_buttons, 0, wxALIGN_RIGHT)
- # final layout settings
- self.SetSizer(top)
- top.Fit(self)
-
- def EvtChoiceBox(self, event):
- outformat = self.tb_map_umn.get_outputformat().get_name()
-
- 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.tb_map_umn.set_imagetype(self.choice_imgtype.GetStringSelection())
self.result ="OK"
self.end_dialog(self.result)
@@ -290,14 +243,17 @@
# get the web object
self.tb_map = parent.canvas.Map()
self.umn_web = self.tb_map.extension_umn_mapobj.get_web()
-
- # create name
- box_name = wxBoxSizer(wxHORIZONTAL)
- box_name.Add(wxStaticText(self, -1, _("Map-Name:")), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
- box_name.Add(wxStaticText(self, -1, self.tb_map.Title()), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
-
+
+ # Template
+ box_template = wxBoxSizer(wxHORIZONTAL)
+ box_template.Add(wxStaticText(self, -1, _("Template:")), 0,
+ wxALL|wxALIGN_LEFT, 4)
+ self.text_template = wxTextCtrl(self, -1,
+ str(self.umn_web.get_template()))
+ self.text_template.SetSize((250,self.text_template.GetSize()[1]))
+ box_template.Add(self.text_template, 0,
+ wxALL|wxALIGN_CENTER_VERTICAL, 4)
+
# Imagepath
box_imagepath = wxBoxSizer(wxHORIZONTAL)
box_imagepath.Add(wxStaticText(self, -1, _("Imagepath:")), 0,
@@ -328,7 +284,7 @@
# compose the final dialog
top = wxBoxSizer(wxVERTICAL)
- top.Add(box_name, 0, wxEXPAND |wxALL, 5)
+ top.Add(box_template, 0, wxEXPAND |wxALL, 5)
top.Add(box_imagepath, 0, wxEXPAND |wxALL, 5)
top.Add(box_imageurl, 0, wxEXPAND |wxALL, 5)
top.Add(box_buttons, 0, wxALIGN_RIGHT)
@@ -350,6 +306,7 @@
self.Show(False)
def OnOK(self, event):
+ self.umn_web.set_template(self.text_template.GetValue())
self.umn_web.set_imagepath(self.text_imagepath.GetValue())
self.umn_web.set_imageurl(self.text_imageurl.GetValue())
self.result ="OK"
@@ -507,6 +464,8 @@
self.previewcolor.SetBackgroundColour(wxColour(int(self.redcolor),
int(self.greencolor),
int(self.bluecolor)))
+ # refresh the colorbox to show the new color
+ self.previewcolor.Refresh()
def RunDialog(self):
self.ShowModal()
@@ -732,6 +691,8 @@
self.previewcolor.SetBackgroundColour(wxColour(int(self.redcolor),
int(self.greencolor),
int(self.bluecolor)))
+ # refresh the colorbox to show the new color
+ self.previewcolor.Refresh()
def RunDialog(self):
self.ShowModal()
@@ -958,6 +919,8 @@
self.previewimgcolor.SetBackgroundColour(wxColour(int(self.redcolor),
int(self.greencolor),
int(self.bluecolor)))
+ # refresh the colorbox to show the new color
+ self.previewimgcolor.Refresh()
def OnChangeColor(self, event):
cur = self.umn_scalebar.get_color().get_thubancolor()
@@ -974,6 +937,8 @@
self.previewcolor.SetBackgroundColour(wxColour(int(self.redcolor),
int(self.greencolor),
int(self.bluecolor)))
+ # refresh the colorbox to show the new color
+ self.previewcolor.Refresh()
def RunDialog(self):
self.ShowModal()
@@ -1049,6 +1014,14 @@
theMap = MF_Map(mapObj(""))
context.mainwindow.canvas.Map().extension_umn_mapobj = theMap
+
+# TODO: Maybe can be imported from another class
+# check if an mapobj exists, to control the menuitem is available or not
+def _has_umn_mapobj(context):
+ """Return true if a umn_mapobj exists"""
+ return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj")
+
+
# ###################################
#
# Hook in MapServer Extension into Thuban
@@ -1062,47 +1035,48 @@
mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver",
_("&MapServer"))
-
# register the new command
-registry.Add(Command("create_new_mapfile", _("Create an empty MapObj"), \
- create_new_mapfile,
- helptext = _("Create a new empty mapscript MapObj")))
+registry.Add(Command("create_new_mapfile", _("Create new mapfile"), \
+ create_new_mapfile, \
+ helptext = _("Create a new empty mapscript MapObj")))
# finally add the new entry to the extensions menu
-mapserver_menu.InsertItem("create_new_mapfile")
+mapserver_menu.InsertItem("create_new_mapfile", after = "import_mapfile" )
+# find the MapServer menu and add a new submenu if found
+mapserver_edit_menu = mapserver_menu.FindOrInsertMenu("edit_mapfile",
+ _("&Edit mapfile"), \
+ after = "create_new_mapfile")
# register the new command (Map Settings Dialog)
-registry.Add(Command("Map Settings", _("Map Settings"), mapsettings,
- helptext = _("Edit the Map Setting")))
+registry.Add(Command("Map Settings", _("Map"), mapsettings,
+ helptext = _("Edit the Map Setting"), \
+ sensitive = _has_umn_mapobj))
# finally add the new entry to the extensions menu
-mapserver_menu.InsertItem("Map Settings")
+mapserver_edit_menu.InsertItem("Map Settings")
-# register the new command (OutputFormat Settings Dialog)
-registry.Add(Command("OutputFormat Settings", _("OutputFormat Settings"),
- outputformatsettings,
- helptext = _("Edit the OutputFormat Setting")))
-# finally add the new entry to the extensions menu
-mapserver_menu.InsertItem("OutputFormat Settings")
# register the new command (Map Settings Dialog)
-registry.Add(Command("Web Settings", _("Web Settings"),
+registry.Add(Command("Web Settings", _("Web"),
websettings,
- helptext = _("Edit the Web Setting")))
+ helptext = _("Edit the Web Setting"), \
+ sensitive = _has_umn_mapobj))
# finally add the new entry to the extensions menu
-mapserver_menu.InsertItem("Web Settings")
+mapserver_edit_menu.InsertItem("Web Settings")
# register the new command (Legend Settings Dialog)
-registry.Add(Command("Legend Settings", _("Legend Settings"),
+registry.Add(Command("Legend Settings", _("Legend"),
legendsettings,
- helptext = _("Edit the Legend Setting")))
+ helptext = _("Edit the Legend Setting"), \
+ sensitive = _has_umn_mapobj))
# finally add the new entry to the extensions menu
-mapserver_menu.InsertItem("Legend Settings")
+mapserver_edit_menu.InsertItem("Legend Settings")
# register the new command (Scalebar Settings Dialog)
-registry.Add(Command("Scalebar Settings", _("Scalebar Settings"),
+registry.Add(Command("Scalebar Settings", _("Scalebar"),
scalebarsettings,
- helptext = _("Edit the Scalebar Setting")))
+ helptext = _("Edit the Scalebar Setting"), \
+ sensitive = _has_umn_mapobj))
# finally add the new entry to the extensions menu
-mapserver_menu.InsertItem("Scalebar Settings")
+mapserver_edit_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)