From jan at intevation.de Sat May 1 00:03:22 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Sat, 1 May 2004 00:03:22 +0200 Subject: ColorDialog patch (winning HSV) Message-ID: <20040430220322.GA13683@intevation.de> Hi Thuban developers, I've prepared a patch to make it possible to make use of different color selection dialogs. Especially, the pyColourChooser which offers HSV in contrast to the default wxColourDialog of wxWindows. Also, the custom colors feature works. attached is a patch to Thuban/UI/classifier.py in order to use a new abstract ColorDialog and attached is the new file Thuban/UI/colordialog.py. Let me know whether you think this abstract ColorDialog class is a good or bad idea. Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ -------------- next part -------------- Index: classifier.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/classifier.py,v retrieving revision 1.64 diff -u -3 -p -r1.64 classifier.py --- classifier.py 1 Aug 2003 14:27:57 -0000 1.64 +++ classifier.py 30 Apr 2004 22:00:49 -0000 @@ -33,6 +33,7 @@ from Thuban.Model.layer import Layer, Ra from Thuban.Model.data import SHAPETYPE_ARC, SHAPETYPE_POLYGON, SHAPETYPE_POINT from Thuban.UI.classgen import ClassGenDialog +from Thuban.UI.colordialog import ColorDialog from dialogs import NonModalNonParentDialog from messages import MAP_REPLACED @@ -1285,13 +1286,12 @@ class SelectPropertiesDialog(wxDialog): self.previewWin.Refresh() def __GetColor(self, cur): - dialog = wxColourDialog(self) - if cur is not Transparent: - dialog.GetColourData().SetColour(Color2wxColour(cur)) + dialog = ColorDialog(self) + dialog.SetColor(cur) ret = None if dialog.ShowModal() == wxID_OK: - ret = wxColour2Color(dialog.GetColourData().GetColour()) + ret = dialog.GetColor() dialog.Destroy() -------------- next part -------------- # Copyright (c) 2004 by Intevation GmbH # Authors: # Jan-Oliver Wagnber # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with Thuban for details. __version__ = "$Revision$" from wxPython.wx import wxDialog, wxColourDialog, wxID_OK, wxID_CANCEL, \ wxBoxSizer, wxVERTICAL, wxHORIZONTAL, wxALL, \ wxALIGN_CENTER_HORIZONTAL, wxButton, EVT_BUTTON, \ wxInitAllImageHandlers from Thuban import _ from Thuban.UI.common import Color2wxColour, wxColour2Color from Thuban.Model.color import Transparent # determine whether the pyColourChooserDialog is available # It was not available with the very first versions of wxWindows 2.4 # (I don't know the exact version though) try: from wxPython.lib.colourchooser import wxPyColourChooser _wxPyColourChooser = True wxInitAllImageHandlers() # should be somewhere at Thuban startup? except: _wxPyColourChooser = False class PyColorChooserDialog(wxDialog): """ A Dialog that uses the wxPyColourChooser Frame and simply adds OK and Cancel button to form a modal color selection dialog. """ def __init__(self, parent): wxDialog.__init__(self, parent, -1, _("Select Color")) self.parent = parent self.dialog_layout() def dialog_layout(self): top_box = wxBoxSizer(wxVERTICAL) self.chooser = wxPyColourChooser(self, -1) top_box.Add(self.chooser, 1, wxALL | wxALIGN_CENTER_HORIZONTAL, 5) box = wxBoxSizer(wxHORIZONTAL) box.Add(wxButton(self, wxID_OK, _("OK")), 0, wxALL, 4) box.Add(wxButton(self, wxID_CANCEL, _("Cancel")), 0, wxALL, 4) top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10) EVT_BUTTON(self, wxID_OK, self.OnOK) EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) self.SetAutoLayout(True) self.SetSizer(top_box) top_box.Fit(self) top_box.SetSizeHints(self) def GetValue(self): return self.chooser.GetValue() def SetValue(self, color): return self.chooser.SetValue(color) def OnOK(self, event): self.EndModal(wxID_OK) def OnCancel(self, event): self.EndModal(wxID_CANCEL) class ColorDialog: """ The color dialog raises one of the available color selection dialogs. ColorDialog is no derived from any GUI class though. Furthermore, wxColour class is mapped to the Thuban Color class already through this class. Eventually it should be configurable globally for Thuban which color dialog to use since they might differ in functionality, translation or stability. """ def __init__(self, parent): if _wxPyColourChooser: self.dlg = PyColorChooserDialog(parent) else: self.dlg = wxColourDialog(parent) def GetColor(self): if _wxPyColourChooser: return wxColour2Color(self.dlg.GetValue()) else: return wxColour2Color(self.dlg.GetColourData().GetColour()) def SetColor(self, color): if color is not Transparent: if _wxPyColourChooser: self.dlg.SetValue(Color2wxColour(color)) else: self.dlg.GetColourData().SetColour(Color2wxColour(color)) def ShowModal(self): return self.dlg.ShowModal() def Destroy(self): return self.dlg.Destroy() if __name__ == "__main__": # Test routine to run the dialog without Thuban from wxPython.wx import wxApp, NULL wxInitAllImageHandlers() class _TestApp(wxApp): def OnInit(self): dialog = ColorDialog(NULL) if dialog.ShowModal() == wxID_OK: print "Selected color:", dialog.GetColor() else: print "No color selected" dialog.Destroy() return True app = _TestApp() app.MainLoop() From jan at intevation.de Sun May 2 14:08:47 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Sun, 2 May 2004 14:08:47 +0200 Subject: extensions/experimental menu In-Reply-To: References: <20040422171156.47FCF13AAE@lists.intevation.de> Message-ID: <20040502120847.GA1515@intevation.de> On Thu, Apr 22, 2004 at 07:27:10PM +0200, Bernhard Herzog wrote: > > # find the extensions menu (create it anew if not found) > > extensions_menu = main_menu.find_menu('extensions') > > if extensions_menu is None: > > extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions')) > > We should add a function to Thuban.UI.mainwindow that returns the > extensions menu after creating it if it doesn't exist yet. This code > has been duplicated in at least 5 extensions. AFAIKS, we have another option: Add a method FindOrInsert() for class Menu of Thuban.UI.menu which either finds and returns the menu or it creates it if not found and then returns the newly created one. What do you think of this? I can easily implement this. Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From joey at infodrom.org Sun May 2 14:33:19 2004 From: joey at infodrom.org (Martin Schulze) Date: Sun, 2 May 2004 14:33:19 +0200 Subject: extensions/experimental menu In-Reply-To: <20040502120847.GA1515@intevation.de> References: <20040422171156.47FCF13AAE@lists.intevation.de> <20040502120847.GA1515@intevation.de> Message-ID: <20040502123319.GJ716@finlandia.infodrom.north.de> Jan-Oliver Wagner wrote: > On Thu, Apr 22, 2004 at 07:27:10PM +0200, Bernhard Herzog wrote: > > > # find the extensions menu (create it anew if not found) > > > extensions_menu = main_menu.find_menu('extensions') > > > if extensions_menu is None: > > > extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions')) > > > > We should add a function to Thuban.UI.mainwindow that returns the > > extensions menu after creating it if it doesn't exist yet. This code > > has been duplicated in at least 5 extensions. > > AFAIKS, we have another option: > > Add a method FindOrInsert() for class Menu of Thuban.UI.menu > which either finds and returns the menu or it creates it if not > found and then returns the newly created one. > > What do you think of this? Both sound good, imho. Regards, Joey -- Still can't talk about what I can't talk about. Sorry. -- Bruce Schneier From frank.koormann at intevation.de Mon May 3 16:37:35 2004 From: frank.koormann at intevation.de (Frank Koormann) Date: Mon, 3 May 2004 16:37:35 +0200 Subject: Improved PostGIS-Interface In-Reply-To: <11c.2e86a1c8.2dc3b8c2@aol.com> References: <11c.2e86a1c8.2dc3b8c2@aol.com> Message-ID: <20040503143735.GA22916@intevation.de> Hi Jens, thank you very much for your work on the postgis interface. I discussed your post briefly with Bernhard (H.), but we haven't had the time to look into it deeply. One thought: * JensMattke at aol.com [040430 16:12]: > So I decided to rewrite the postgisdb.py and wellknowntext.py files using > a binary cursor. Unfortunately, it seems to me as if psycopg is unable to > read 'normal data' (integer, double, text...) as a binary cursor. Trying > that, always killed the python-interpreter. Did you contact the psycopg people to elaborate this? Maybe a bug in in there? However, in your test setting even a speed up by four times seems to be a very big step forward :) Best regards, Frank -- Frank Koormann Professional Service around Free Software (http://intevation.net/) FreeGIS Project (http://freegis.org/) From jan at intevation.de Mon May 3 22:29:42 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Mon, 3 May 2004 22:29:42 +0200 Subject: [Thuban-devel] Re: extensions/experimental menu In-Reply-To: <20040502123319.GJ716@finlandia.infodrom.north.de> References: <20040422171156.47FCF13AAE@lists.intevation.de> <20040502120847.GA1515@intevation.de> <20040502123319.GJ716@finlandia.infodrom.north.de> Message-ID: <20040503202942.GA31542@intevation.de> On Sun, May 02, 2004 at 02:33:19PM +0200, Martin Schulze wrote: > Jan-Oliver Wagner wrote: > > On Thu, Apr 22, 2004 at 07:27:10PM +0200, Bernhard Herzog wrote: > > > > # find the extensions menu (create it anew if not found) > > > > extensions_menu = main_menu.find_menu('extensions') > > > > if extensions_menu is None: > > > > extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions')) > > > > > > We should add a function to Thuban.UI.mainwindow that returns the > > > extensions menu after creating it if it doesn't exist yet. This code > > > has been duplicated in at least 5 extensions. > > > > AFAIKS, we have another option: > > > > Add a method FindOrInsert() for class Menu of Thuban.UI.menu > > which either finds and returns the menu or it creates it if not > > found and then returns the newly created one. > > > > What do you think of this? > > Both sound good, imho. if noone objects, I will prepare a patch for this. Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From jan at intevation.de Mon May 3 22:31:12 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Mon, 3 May 2004 22:31:12 +0200 Subject: [Thuban-devel] ColorDialog patch (winning HSV) In-Reply-To: <20040430220322.GA13683@intevation.de> References: <20040430220322.GA13683@intevation.de> Message-ID: <20040503203112.GB31542@intevation.de> On Sat, May 01, 2004 at 12:03:22AM +0200, Jan-Oliver Wagner wrote: > I've prepared a patch to make it possible to > make use of different color selection dialogs. > Especially, the pyColourChooser which offers HSV > in contrast to the default wxColourDialog of wxWindows. > Also, the custom colors feature works. > > attached is a patch to Thuban/UI/classifier.py > in order to use a new abstract ColorDialog and > attached is the new file Thuban/UI/colordialog.py. > > Let me know whether you think this abstract ColorDialog > class is a good or bad idea. will commit soon if noone objects. Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From bh at intevation.de Tue May 4 17:55:56 2004 From: bh at intevation.de (Bernhard Herzog) Date: Tue, 4 May 2004 17:55:56 +0200 Subject: PyShapelib In-Reply-To: <6.1.0.6.2.20040429113533.01dcd3c8@hobu.mail.iastate.edu> References: <6.1.0.6.2.20040429113533.01dcd3c8@hobu.mail.iastate.edu> Message-ID: <20040504155556.GA28014@intevation.de> [Reply with permission to a private mail; Full quote for the benefit of thuban-devel] On Thu, Apr 29, 2004 at 11:45:48AM -0500, Howard Butler wrote: > Bernhard, > > I maintain the windows binary of your Python wrapper for shapelib > . The SWIG interface files use many > older, deprecated, and removed directives as compared to the recent 1.3.21 > series of SWIG. I have a couple of questions: Some general remarks first: The shapelib bindings are now maintained as part of Thuban. There have been quite a few changes [4] since the last separate release, 0.2 almost 3 years ago. We should take the current CVS version as the basis for the discussions of the future of pyshapelib. > 1. I have a wrapper that I've developed for ESRI SDE, called PySDE, that > uses SWIG typemaps to do its magic. I know that this is a poor way of > doing things, but it works. I would like to extend a couple of methods in > pyshapelib so that I can suck up geometry from SDE and pass it in to > shapefiles (directly, using the WKB stuff, rather than one vertex at a > time). > > 2. As it stands now, I cannot run SWIG 1.3.21 on the interface files > you've defined for pyshapelib because of the deprecated directives. I > don't know if you've been following SWIG developments recently, but 1.3.21 > has many Python-specific improvements that I would like to incorporate in > both the shapelib and SDE wrappers. I don't have time to keep up with SWIG developmen, thus I've kept using the same SWIG version for the shapelib bindings. > 3. Although I don't fully understand how the directives of pyshapelib are > laid out, I could invest the time to get up to speed. My question is, do > you still wish to be the maintainer of this package? I would gladly take > it up if you don't have the time or desire to fool with it anymore. If you > would like to continue to maintain it, would you have time in the next > month or so to update the interface files so that they play nicely with the > latest 1.3 SWIG series? The situation from Intevation's point of view is as follows: we (Intevation) currently only use pyshapelib in Thuban. It's unlikely that we will have time to invest in further work on pyshapelib that is not directly needed for a paying project involving Thuban. That means we won't have the time to update the interface files to a newer SWIG version ourselves. In fact, it would be better, i.e. less maintenance work, if we would use a handwritten binding instead of SWIG [1]. However, it would be nice to see further development on pyshapelib, even if we can't do it ourselves. For Thuban it's easiest to keep maintaining the bindings in Thuban CVS, though. So, here's what we suggest to do: 1. We make a new release in the next few weeks. This is really overdue [2]. Apart from packaging it there's one issue to resolve for the release [3] 2. Invite more developers to help with the things we don't have time for You (Howard) want to have it work with newer SWIG versions. So, please work on that and submit a patch. Patches for other changes and from other people are also welcome of course. Please run the Thuban testsuite with your modified pyshapelib to make sure that it's still Thuban compatible. For Thuban itself it might be acceptable to make incompatible changes to pyshapelib if any necessary changes to Thuban itself are also part of the patch. However, other users of pyshapelib may not like that :) Bernhard [1] https://intevation.de/rt/webrt?serial_num=1807 [2] https://intevation.de/rt/webrt?serial_num=1805 [3] https://intevation.de/rt/webrt?serial_num=2247 [4] http://www.intevation.de/cgi-bin/viewcvs-thuban.cgi/thuban/libraries/pyshapelib/ChangeLog?rev=1.3&content-type=text/vnd.viewcvs-markup -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Tue May 4 19:17:03 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 4 May 2004 19:17:03 +0200 (CEST) Subject: frank: thuban/Extensions/bboxdump __init__.py, 1.1, 1.2 bboxdump.py, 1.1, 1.2 Message-ID: <20040504171703.10168139AB@lists.intevation.de> Author: frank Update of /thubanrepository/thuban/Extensions/bboxdump In directory doto:/tmp/cvs-serv22494/Extensions/bboxdump Modified Files: __init__.py bboxdump.py Log Message: Extensions/bboxdump/__init__.py: Fixed string left over from copying. Extensions/bboxdump/bboxdump.py (bboxdump): Use layer.ShapeStore().AllShapes() to loop over shapes instead of xrange(layer.NumShapes()). Compile the bboxmessage from a list of formatted outputs (string.join) instead of appending to the message. Two progress bar dialogs to report progress on the sometimes lenghty processing. Index: __init__.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/bboxdump/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- __init__.py 22 Apr 2004 17:11:54 -0000 1.1 +++ __init__.py 4 May 2004 17:17:00 -0000 1.2 @@ -1,6 +1,6 @@ # Copyright (c) 2003 by Intevation GmbH # Authors: -# Jan-Oliver Wagner +# Frank Koormann # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with Thuban for details. Index: bboxdump.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/bboxdump/bboxdump.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- bboxdump.py 22 Apr 2004 17:11:54 -0000 1.1 +++ bboxdump.py 4 May 2004 17:17:00 -0000 1.2 @@ -16,8 +16,8 @@ __version__ = '$Revision$' import os, sys +import string -# only import GUI when not called as command line tool from wxPython.wx import * from wxPython.lib.dialogs import wxScrolledMessageDialog @@ -29,6 +29,7 @@ import shapelib import dbflib +# Widget IDs ID_FILENAME = 4001 ID_ATTRIBUTES = 4002 ID_SELFN = 4003 @@ -121,8 +122,7 @@ if bboxmessage: dlg = wxScrolledMessageDialog( self.parent, bboxmessage, - _("Bounding Box Dump %s") % self.layer.Title() - ) + _("Bounding Box Dump %s") % self.layer.Title()) dlg.ShowModal() def OnSelectFilename(self, event): @@ -149,42 +149,74 @@ layer - Layer of shapes to be dumped column - optional column to group shapes (else None) filename - optional filename to dump into (else empty string, i.e. dump - to stdio) + to message dialog) """ # Preparation shapelist = {} - bboxmessage = "" + bboxmessage = [] + dlg= wxProgressDialog(_("Bounding Box Dump"), + _("Collecting shapes ..."), + layer.ShapeStore().NumShapes(), + None) + + cnt = 0 + step = int(layer.ShapeStore().NumShapes() / 100.0) + if step == 0: + step = 1 + # Collect shape ids to be dumped if column is None: # A simple dump of shapes bbox is required - for i in xrange(layer.NumShapes()): + for s in layer.ShapeStore().AllShapes(): + i = s.ShapeID() shapelist[i] = (i,) + if cnt % step == 0: + dlg.Update(cnt) + cnt = cnt + 1 else: # group them by column ... - for i in xrange(layer.NumShapes()): + for s in layer.ShapeStore().AllShapes(): + i = s.ShapeID() row = layer.ShapeStore().Table().ReadRowAsDict(i) att = row[column.name] if not shapelist.has_key(att): shapelist[att] = [] shapelist[att].append(i) + if cnt % step == 0: + dlg.Update(cnt) + cnt = cnt + 1 + + dlg.Destroy() + dlg= wxProgressDialog(_("Bounding Box Dump"), + _("Dump bounding boxes of selected shapes ..."), + len(shapelist), + None) + cnt = 0 + step = int(len(shapelist) / 100.0) + if step == 0: + step = 1 # Dump them, sorted keys = shapelist.keys() keys.sort() for key in keys: bbox = layer.ShapesBoundingBox(shapelist[key]) - bboxmessage = bboxmessage + "%.3f,%.3f,%.3f,%.3f,%s\n" % ( - bbox[0],bbox[1],bbox[2],bbox[3],key) + bboxmessage.append("%.3f,%.3f,%.3f,%.3f,%s\n" % ( + bbox[0], bbox[1], bbox[2], bbox[3], key)) + if cnt % step == 0: + dlg.Update(cnt) + cnt = cnt + 1 + dlg.Destroy() # finally if filename != '': - bboxfile = file(filename,'w+') - bboxfile.write(bboxmessage) + bboxfile = file(filename, 'w+') + bboxfile.write(string.join(bboxmessage)) bboxfile.close() return None else: - return bboxmessage + return string.join(bboxmessage) def LayerBBoxDump(context): """Menu Handler BBoxDump @@ -196,7 +228,7 @@ dlg.ShowModal() -# gns2shp executed as an extension to Thuban +# bboxdump executed as an extension to Thuban # register the new command registry.Add(Command('bboxdump', _('BBox Dump'), LayerBBoxDump, From cvs at intevation.de Tue May 4 19:17:03 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 4 May 2004 19:17:03 +0200 (CEST) Subject: frank: thuban ChangeLog,1.646,1.647 Message-ID: <20040504171703.596BA13A0C@lists.intevation.de> Author: frank Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv22494 Modified Files: ChangeLog Log Message: Extensions/bboxdump/__init__.py: Fixed string left over from copying. Extensions/bboxdump/bboxdump.py (bboxdump): Use layer.ShapeStore().AllShapes() to loop over shapes instead of xrange(layer.NumShapes()). Compile the bboxmessage from a list of formatted outputs (string.join) instead of appending to the message. Two progress bar dialogs to report progress on the sometimes lenghty processing. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.646 retrieving revision 1.647 diff -u -d -r1.646 -r1.647 --- ChangeLog 22 Apr 2004 17:11:54 -0000 1.646 +++ ChangeLog 4 May 2004 17:17:00 -0000 1.647 @@ -1,3 +1,15 @@ +2004-05-04 Frank Koormann + + * Extensions/bboxdump/__init__.py: Fixed string left over from + copying. + + * Extensions/bboxdump/bboxdump.py (bboxdump): + Use layer.ShapeStore().AllShapes() to loop over shapes instead of + xrange(layer.NumShapes()). Compile the bboxmessage from a list + of formatted outputs (string.join) instead of appending to the + message. Two progress bar dialogs to report progress on the sometimes + lenghty processing. + 2004-04-22 Frank Koormann New Extension to dump bounding boxes of all shapes of the selected From cvs at intevation.de Fri May 7 22:02:21 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 7 May 2004 22:02:21 +0200 (CEST) Subject: jan: thuban/Thuban/UI proj4dialog.py,1.9,NONE Message-ID: <20040507200221.6D8A613B5E@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv26586 Removed Files: proj4dialog.py Log Message: Removed. It is has been replaced by projdialog for quite a while and is not used anymore. --- proj4dialog.py DELETED --- From cvs at intevation.de Fri May 7 22:12:18 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 7 May 2004 22:12:18 +0200 (CEST) Subject: jan: thuban/Thuban/UI colordialog.py,NONE,1.1 Message-ID: <20040507201218.3CF9C13B53@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv26767 Added Files: colordialog.py Log Message: Abstraction for color selection dialog(s). --- NEW FILE: colordialog.py --- # Copyright (c) 2004 by Intevation GmbH # Authors: # Jan-Oliver Wagnber # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with Thuban for details. __version__ = "$Revision: 1.1 $" # $Source: /thubanrepository/thuban/Thuban/UI/colordialog.py,v $ # $Id: colordialog.py,v 1.1 2004/05/07 20:12:16 jan Exp $ from wxPython.wx import wxDialog, wxColourDialog, wxID_OK, wxID_CANCEL, \ wxBoxSizer, wxVERTICAL, wxHORIZONTAL, wxALL, \ wxALIGN_CENTER_HORIZONTAL, wxButton, EVT_BUTTON, \ wxInitAllImageHandlers from Thuban import _ from Thuban.UI.common import Color2wxColour, wxColour2Color from Thuban.Model.color import Transparent # determine whether the pyColourChooserDialog is available # It was not available with the very first versions of wxWindows 2.4 # (I don't know the exact version though) try: from wxPython.lib.colourchooser import wxPyColourChooser _wxPyColourChooser = True wxInitAllImageHandlers() # should be somewhere at Thuban startup? except: _wxPyColourChooser = False class PyColorChooserDialog(wxDialog): """ A Dialog that uses the wxPyColourChooser Frame and simply adds OK and Cancel button to form a modal color selection dialog. """ def __init__(self, parent): wxDialog.__init__(self, parent, -1, _("Select Color")) self.parent = parent self.dialog_layout() def dialog_layout(self): top_box = wxBoxSizer(wxVERTICAL) self.chooser = wxPyColourChooser(self, -1) top_box.Add(self.chooser, 1, wxALL | wxALIGN_CENTER_HORIZONTAL, 5) box = wxBoxSizer(wxHORIZONTAL) box.Add(wxButton(self, wxID_OK, _("OK")), 0, wxALL, 4) box.Add(wxButton(self, wxID_CANCEL, _("Cancel")), 0, wxALL, 4) top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10) EVT_BUTTON(self, wxID_OK, self.OnOK) EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) self.SetAutoLayout(True) self.SetSizer(top_box) top_box.Fit(self) top_box.SetSizeHints(self) def GetValue(self): return self.chooser.GetValue() def SetValue(self, color): return self.chooser.SetValue(color) def OnOK(self, event): self.EndModal(wxID_OK) def OnCancel(self, event): self.EndModal(wxID_CANCEL) class ColorDialog: """ The color dialog raises one of the available color selection dialogs. ColorDialog is no derived from any GUI class though. Furthermore, wxColour class is mapped to the Thuban Color class already through this class. Eventually it should be configurable globally for Thuban which color dialog to use since they might differ in functionality, translation or stability. """ def __init__(self, parent): if _wxPyColourChooser: self.dlg = PyColorChooserDialog(parent) else: self.dlg = wxColourDialog(parent) def GetColor(self): if _wxPyColourChooser: return wxColour2Color(self.dlg.GetValue()) else: return wxColour2Color(self.dlg.GetColourData().GetColour()) def SetColor(self, color): if color is not Transparent: if _wxPyColourChooser: self.dlg.SetValue(Color2wxColour(color)) else: self.dlg.GetColourData().SetColour(Color2wxColour(color)) def ShowModal(self): return self.dlg.ShowModal() def Destroy(self): return self.dlg.Destroy() if __name__ == "__main__": # Test routine to run the dialog without Thuban from wxPython.wx import wxApp, NULL wxInitAllImageHandlers() class _TestApp(wxApp): def OnInit(self): dialog = ColorDialog(NULL) if dialog.ShowModal() == wxID_OK: print "Selected color:", dialog.GetColor() else: print "No color selected" dialog.Destroy() return True app = _TestApp() app.MainLoop() From cvs at intevation.de Fri May 7 22:20:45 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 7 May 2004 22:20:45 +0200 (CEST) Subject: jan: thuban/Thuban/UI classifier.py,1.64,1.65 Message-ID: <20040507202045.4149213B53@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv26843 Modified Files: classifier.py Log Message: (SelectPropertiesDialog.__GetColor): Now calls the abstract ColorDialog instead of wxColourDialog. This also removed the dependency to Color class conversion from this function. Index: classifier.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/classifier.py,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- classifier.py 1 Aug 2003 14:27:57 -0000 1.64 +++ classifier.py 7 May 2004 20:20:43 -0000 1.65 @@ -33,6 +33,7 @@ from Thuban.Model.data import SHAPETYPE_ARC, SHAPETYPE_POLYGON, SHAPETYPE_POINT from Thuban.UI.classgen import ClassGenDialog +from Thuban.UI.colordialog import ColorDialog from dialogs import NonModalNonParentDialog from messages import MAP_REPLACED @@ -1285,13 +1286,12 @@ self.previewWin.Refresh() def __GetColor(self, cur): - dialog = wxColourDialog(self) - if cur is not Transparent: - dialog.GetColourData().SetColour(Color2wxColour(cur)) + dialog = ColorDialog(self) + dialog.SetColor(cur) ret = None if dialog.ShowModal() == wxID_OK: - ret = wxColour2Color(dialog.GetColourData().GetColour()) + ret = dialog.GetColor() dialog.Destroy() From cvs at intevation.de Fri May 7 22:22:15 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 7 May 2004 22:22:15 +0200 (CEST) Subject: jan: thuban ChangeLog,1.647,1.648 Message-ID: <20040507202215.EE72613B53@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv26871 Modified Files: ChangeLog Log Message: Introduce a abstract ColorDialog class and remove and outdated file. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.647 retrieving revision 1.648 diff -u -d -r1.647 -r1.648 --- ChangeLog 4 May 2004 17:17:00 -0000 1.647 +++ ChangeLog 7 May 2004 20:22:12 -0000 1.648 @@ -1,3 +1,20 @@ +2004-05-06 Jan-Oliver Wagner + + Introduce a abstract ColorDialog class and remove + and outdated file. + + * Thuban/UI/proj4dialog.py: Removed. It is has been + replaced by projdialog for quite a while and is not used + anymore. + + * Thuban/UI/colordialog.py: New. Abstraction for color selection + dialog(s). + + * Thuban/UI/classifier.py (SelectPropertiesDialog.__GetColor): + Now calls the abstract ColorDialog instead of wxColourDialog. + This also removed the dependency to Color class conversion + from this function. + 2004-05-04 Frank Koormann * Extensions/bboxdump/__init__.py: Fixed string left over from From cvs at intevation.de Tue May 11 23:39:42 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 11 May 2004 23:39:42 +0200 (CEST) Subject: jan: thuban/Thuban/UI menu.py,1.6,1.7 Message-ID: <20040511213942.3397213BCA@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv29153 Modified Files: menu.py Log Message: (Menu.FindOrInsertMenu): New. Find a given menu or, if not found, insert it. Index: menu.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/menu.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- menu.py 27 May 2003 13:11:18 -0000 1.6 +++ menu.py 11 May 2004 21:39:39 -0000 1.7 @@ -126,6 +126,20 @@ self.InsertItem(newmenu, menu = menu, after = after) return newmenu + def FindOrInsertMenu(self, name, title, menu = (), after = None): + """ + Find the menu with the specified name. If found, return it. + Else insert the menu as specified and return it. + + Parameters: See InsertMenu(). + """ + + m = self.find_menu(name) + if m is None: + m = self.InsertMenu(name, title, menu, after) + return m + + def SetItems(self, items): """Replace the contents of the menu by items.""" self.items = items From cvs at intevation.de Wed May 12 00:34:51 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 12 May 2004 00:34:51 +0200 (CEST) Subject: jan: thuban/Extensions/bboxdump bboxdump.py,1.2,1.3 Message-ID: <20040511223451.9AD9213BCB@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Extensions/bboxdump In directory doto:/tmp/cvs-serv30058/bboxdump Modified Files: bboxdump.py Log Message: Use FindOrInsertMenu() instead of finding menu on its own. Index: bboxdump.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/bboxdump/bboxdump.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bboxdump.py 4 May 2004 17:17:00 -0000 1.2 +++ bboxdump.py 11 May 2004 22:34:49 -0000 1.3 @@ -14,6 +14,8 @@ """ __version__ = '$Revision$' +# $Source$ +# $Id$ import os, sys import string @@ -236,9 +238,7 @@ sensitive = _has_selected_shape_layer)) # find the extensions menu (create it anew if not found) -extensions_menu = main_menu.find_menu('extensions') -if extensions_menu is None: - extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions')) +extensions_menu = main_menu.FindOrInsertMenu('extensions', _('E&xtensions')) # finally add the new entry to the extensions menu extensions_menu.InsertItem('bboxdump') From cvs at intevation.de Wed May 12 00:34:51 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 12 May 2004 00:34:51 +0200 (CEST) Subject: jan: thuban/Extensions/gns2shp gns2shp.py,1.1,1.2 Message-ID: <20040511223451.A00C713BCC@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Extensions/gns2shp In directory doto:/tmp/cvs-serv30058/gns2shp Modified Files: gns2shp.py Log Message: Use FindOrInsertMenu() instead of finding menu on its own. Index: gns2shp.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/gns2shp/gns2shp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gns2shp.py 22 Sep 2003 10:32:04 -0000 1.1 +++ gns2shp.py 11 May 2004 22:34:49 -0000 1.2 @@ -18,6 +18,8 @@ """ __version__ = '$Revision$' +# $Source$ +# $Id$ import os, sys @@ -26,7 +28,7 @@ from wxPython.wx import * from Thuban.UI.command import registry, Command - import Thuban.UI.mainwindow + from Thuban.UI.mainwindow import main_menu from Thuban import _ from Thuban.Model.layer import Layer @@ -176,10 +178,7 @@ helptext = _('Convert GNS-file into a shapefile'))) # find the extensions menu (create it anew if not found) -main_menu = Thuban.UI.mainwindow.main_menu -extensions_menu = main_menu.find_menu('extensions') -if extensions_menu is None: - extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions')) +extensions_menu = main_menu.FindOrInsertMenu('extensions', _('E&xtensions')) # finally add the new entry to the extensions menu extensions_menu.InsertItem('gns2shp') From cvs at intevation.de Wed May 12 00:34:51 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 12 May 2004 00:34:51 +0200 (CEST) Subject: jan: thuban/Extensions/profiling profiling.py,1.3,1.4 Message-ID: <20040511223451.C6EB213BCE@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Extensions/profiling In directory doto:/tmp/cvs-serv30058/profiling Modified Files: profiling.py Log Message: Use FindOrInsertMenu() instead of finding menu on its own. Index: profiling.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/profiling/profiling.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- profiling.py 3 Nov 2003 14:19:40 -0000 1.3 +++ profiling.py 11 May 2004 22:34:49 -0000 1.4 @@ -32,7 +32,7 @@ from Thuban import _ from Thuban.UI.command import registry, Command -import Thuban.UI.mainwindow +from Thuban.UI.mainwindow import main_menu # # Customization @@ -139,12 +139,8 @@ time_screen_renderer, helptext = _('Time the screen render'))) - # find the extensions menu (create it anew if not found) -main_menu = Thuban.UI.mainwindow.main_menu -extensions_menu = main_menu.find_menu('extensions') -if extensions_menu is None: - extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions')) +extensions_menu = main_menu.FindOrInsertMenu('extensions', _('E&xtensions')) profiler_menu = extensions_menu.InsertMenu("profiler", _('&Profiler')) profiler_menu.InsertItem("time_screen_renderer") From cvs at intevation.de Wed May 12 00:34:51 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 12 May 2004 00:34:51 +0200 (CEST) Subject: jan: thuban/Extensions/importAPR importAPR.py,1.3,1.4 Message-ID: <20040511223451.B0B3913BCD@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Extensions/importAPR In directory doto:/tmp/cvs-serv30058/importAPR Modified Files: importAPR.py Log Message: Use FindOrInsertMenu() instead of finding menu on its own. Index: importAPR.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/importAPR/importAPR.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- importAPR.py 30 Oct 2003 09:16:46 -0000 1.3 +++ importAPR.py 11 May 2004 22:34:49 -0000 1.4 @@ -11,6 +11,8 @@ """ __version__ = "$Revision$" +# $Source$ +# $Id$ import os, sys @@ -21,7 +23,7 @@ from Thuban.Model.extension import Extension from Thuban.Model.base import TitledObject, Modifiable from Thuban.UI.command import registry, Command -import Thuban.UI.mainwindow +from Thuban.UI.mainwindow import main_menu from Thuban import _ from Thuban.Model.layer import Layer from Thuban.Model.classification import ClassGroupRange, ClassGroupSingleton @@ -322,10 +324,8 @@ helptext = _('Import a ArcView project file'))) # find the experimental menu (create it anew if not found) -main_menu = Thuban.UI.mainwindow.main_menu -experimental_menu = main_menu.find_menu('experimental') -if experimental_menu is None: - experimental_menu = main_menu.InsertMenu('experimental', _('Experimenta&l')) +experimental_menu = main_menu.FindOrInsertMenu('experimental', + _('Experimenta&l')) # finally add the new entry to the experimental menu experimental_menu.InsertItem('import-apr') From cvs at intevation.de Wed May 12 00:34:52 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 12 May 2004 00:34:52 +0200 (CEST) Subject: jan: thuban/Extensions/wms wms.py,1.8,1.9 Message-ID: <20040511223452.DB10313BCF@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Extensions/wms In directory doto:/tmp/cvs-serv30058/wms Modified Files: wms.py Log Message: Use FindOrInsertMenu() instead of finding menu on its own. Index: wms.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/wms/wms.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- wms.py 15 Apr 2004 07:14:25 -0000 1.8 +++ wms.py 11 May 2004 22:34:49 -0000 1.9 @@ -16,6 +16,8 @@ """ __version__ = "$Revision$" +# $Source$ +# $Id$ import os, sys import xml.dom.minidom @@ -26,7 +28,7 @@ from Thuban.Model.proj import Projection from Thuban.Model.extension import Extension from Thuban.UI.command import registry, Command -import Thuban.UI.mainwindow +from Thuban.UI.mainwindow import main_menu from Thuban import _ import Thuban.UI.baserenderer @@ -143,10 +145,8 @@ helptext = _('Add a WMS Layer'))) # find the experimental menu (create it anew if not found) -main_menu = Thuban.UI.mainwindow.main_menu -experimental_menu = main_menu.find_menu('experimental') -if experimental_menu is None: - experimental_menu = main_menu.InsertMenu('experimental', _('Experimenta&l')) +experimental_menu = main_menu.FindOrInsertMenu('experimental', + _('Experimenta&l')) # finally add the new entry to the experimental menu experimental_menu.InsertItem('wms') From cvs at intevation.de Wed May 12 00:36:05 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 12 May 2004 00:36:05 +0200 (CEST) Subject: jan: thuban ChangeLog,1.648,1.649 Message-ID: <20040511223605.49F4E13BCB@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv30126 Modified Files: ChangeLog Log Message: Introduce and use Menu.FindOrInsertMenu. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.648 retrieving revision 1.649 diff -u -d -r1.648 -r1.649 --- ChangeLog 7 May 2004 20:22:12 -0000 1.648 +++ ChangeLog 11 May 2004 22:36:03 -0000 1.649 @@ -1,3 +1,15 @@ +2004-05-10 Jan-Oliver Wagner + + Introduce and use Menu.FindOrInsertMenu. + + * Thuban/UI/menu.py (Menu.FindOrInsertMenu): New. Find a + given menu or, if not found, insert it. + + * Extensions/bboxdump/bboxdump.py, /Extensions/gns2shp/gns2shp.py, + /Extensions/importAPR/importAPR.py, Extensions/profiling/profiling.py, + /Extensions/wms/wms.py: Use FindOrInsertMenu() instead of finding + menu on its own. + 2004-05-06 Jan-Oliver Wagner Introduce a abstract ColorDialog class and remove From jan at intevation.de Wed May 12 00:59:25 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Wed, 12 May 2004 00:59:25 +0200 Subject: extensions/experimental menu In-Reply-To: <20040503202942.GA31542@intevation.de> References: <20040422171156.47FCF13AAE@lists.intevation.de> <20040502120847.GA1515@intevation.de> <20040502123319.GJ716@finlandia.infodrom.north.de> <20040503202942.GA31542@intevation.de> Message-ID: <20040511225925.GA32674@intevation.de> On Mon, May 03, 2004 at 10:29:42PM +0200, Jan-Oliver Wagner wrote: > if noone objects, I will prepare a patch for this. done now and committed. Yet to change: svgexport: I'd like to see this running first (no tech problems). drawshape: Shouldn't there be a menu additionally to the tool icon? And there seems to be a bug in gns2shp. Grmpf. Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From bh at intevation.de Wed May 12 11:38:50 2004 From: bh at intevation.de (Bernhard Herzog) Date: Wed, 12 May 2004 11:38:50 +0200 Subject: jan: thuban/Thuban/UI menu.py,1.6,1.7 In-Reply-To: <20040511213942.3397213BCA@lists.intevation.de> (cvs@intevation.de's message of "Tue, 11 May 2004 23:39:42 +0200 (CEST)") References: <20040511213942.3397213BCA@lists.intevation.de> Message-ID: cvs at intevation.de writes: > Author: jan > > Update of /thubanrepository/thuban/Thuban/UI > In directory doto:/tmp/cvs-serv29153 > > Modified Files: > menu.py > Log Message: > (Menu.FindOrInsertMenu): New. Find a given menu or, if not found, > insert it. Where's the test case for this? Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Wed May 12 22:50:35 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 12 May 2004 22:50:35 +0200 (CEST) Subject: jan: thuban/test test_menu.py,1.3,1.4 Message-ID: <20040512205035.677EB139C1@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/test In directory doto:/tmp/cvs-serv32298 Modified Files: test_menu.py Log Message: (MenuTest.test): Added testing of method Menu.FindOrInsertMenu. Index: test_menu.py =================================================================== RCS file: /thubanrepository/thuban/test/test_menu.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- test_menu.py 27 May 2003 13:10:08 -0000 1.3 +++ test_menu.py 12 May 2004 20:50:33 -0000 1.4 @@ -96,6 +96,26 @@ self.compare_menus(editmenu, Menu("edit", "Edit", edit_items[:])) editmenu.RemoveItem("copy") self.compare_menus(editmenu, Menu("edit", "Edit", ['cut', 'paste'])) + editmenu.InsertItem("copy", after="cut") # for convenience for + # the following tests + + # find-or-insert a menu + self.compare_menus(menu, Menu("
", "
", + [Menu("file", "File", file_items[:]), + Menu("edit", "Edit", edit_items[:]), + Menu("help", "Help", help_items[:])])) + menu.FindOrInsertMenu("extensions", "Extensions") + self.compare_menus(menu, Menu("
", "
", + [Menu("file", "File", file_items[:]), + Menu("edit", "Edit", edit_items[:]), + Menu("help", "Help", help_items[:]), + Menu("extensions", "Extensions", [])])) + menu.FindOrInsertMenu("extensions", "Extensions") + self.compare_menus(menu, Menu("
", "
", + [Menu("file", "File", file_items[:]), + Menu("edit", "Edit", edit_items[:]), + Menu("help", "Help", help_items[:]), + Menu("extensions", "Extensions", [])])) if __name__ == "__main__": From cvs at intevation.de Wed May 12 23:13:56 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 12 May 2004 23:13:56 +0200 (CEST) Subject: jan: thuban ChangeLog,1.649,1.650 Message-ID: <20040512211356.AA83713BCD@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv32693 Modified Files: ChangeLog Log Message: added a test Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.649 retrieving revision 1.650 diff -u -d -r1.649 -r1.650 --- ChangeLog 11 May 2004 22:36:03 -0000 1.649 +++ ChangeLog 12 May 2004 21:13:54 -0000 1.650 @@ -1,3 +1,8 @@ +2004-05-11 Jan-Oliver Wagner + + * test/test_menu.py (MenuTest.test): Added testing + of method Menu.FindOrInsertMenu. + 2004-05-10 Jan-Oliver Wagner Introduce and use Menu.FindOrInsertMenu. From jan at intevation.de Wed May 12 23:17:05 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Wed, 12 May 2004 23:17:05 +0200 Subject: jan: thuban/Thuban/UI menu.py,1.6,1.7 In-Reply-To: References: <20040511213942.3397213BCA@lists.intevation.de> Message-ID: <20040512211705.GA10999@intevation.de> On Wed, May 12, 2004 at 11:38:50AM +0200, Bernhard Herzog wrote: > cvs at intevation.de writes: > > Author: jan > > > > Update of /thubanrepository/thuban/Thuban/UI > > In directory doto:/tmp/cvs-serv29153 > > > > Modified Files: > > menu.py > > Log Message: > > (Menu.FindOrInsertMenu): New. Find a given menu or, if not found, > > insert it. > > Where's the test case for this? now checked into CVS. -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From cvs at intevation.de Sun May 16 11:30:37 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sun, 16 May 2004 11:30:37 +0200 (CEST) Subject: jan: thuban/Extensions/drawshape drawshape.py,1.1,1.2 Message-ID: <20040516093037.4EE7D1398D@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Extensions/drawshape In directory doto:/tmp/cvs-serv15996 Modified Files: drawshape.py Log Message: Add the command to the experimental menu additionally to the toolbar. Index: drawshape.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/drawshape/drawshape.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- drawshape.py 25 Nov 2003 14:05:35 -0000 1.1 +++ drawshape.py 16 May 2004 09:30:34 -0000 1.2 @@ -23,11 +23,13 @@ from wxPython.wx import * import shapelib +import Thuban +from Thuban import _ from Thuban.Model.data import SHAPETYPE_POLYGON from Thuban.Model.table import FIELDTYPE_INT, FIELDTYPE_STRING, \ FIELDTYPE_DOUBLE from Thuban.UI.command import registry, ToolCommand -import Thuban.UI.mainwindow +from Thuban.UI.mainwindow import main_menu, main_toolbar from Thuban.UI.viewport import Tool @@ -142,5 +144,12 @@ checked = check_shape_draw_tool)) # Add the command to the toolbar -Thuban.UI.mainwindow.main_toolbar.InsertSeparator() -Thuban.UI.mainwindow.main_toolbar.InsertItem("shape_draw_tool") +main_toolbar.InsertSeparator() +main_toolbar.InsertItem("shape_draw_tool") + +# find the experimental menu (create it anew if not found) +experimental_menu = main_menu.FindOrInsertMenu('experimental', + _('Experimenta&l')) + +# finally add the new command to the experimental menu +experimental_menu.InsertItem('shape_draw_tool') From cvs at intevation.de Sun May 16 11:33:06 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sun, 16 May 2004 11:33:06 +0200 (CEST) Subject: jan: thuban/Extensions/svgexport svgsaver.py,1.1,1.2 Message-ID: <20040516093306.B79E61398D@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Extensions/svgexport In directory doto:/tmp/cvs-serv16087 Modified Files: svgsaver.py Log Message: Use FindOrInsertMenu() instead of finding menu on its own. Index: svgsaver.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/svgexport/svgsaver.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- svgsaver.py 19 Feb 2004 13:38:27 -0000 1.1 +++ svgsaver.py 16 May 2004 09:33:04 -0000 1.2 @@ -83,14 +83,12 @@ # See Thuban/UI/menu.py for the API of the Menu class from Thuban.UI.mainwindow import main_menu -# find the extensions menu (create it anew if not found) -extensions_menu = main_menu.find_menu('extensions') -if extensions_menu is None: - extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions')) - # create a new command and register it registry.Add(Command('write_to_svg', _('Write SVG Map'), write_to_svg, helptext = _('Export the a map into a SVG file'))) + +# find the extensions menu (create it anew if not found) +extensions_menu = main_menu.FindOrInsertMenu('extensions', _('E&xtensions')) # finally bind the new command with an entry in the extensions menu extensions_menu.InsertItem('write_to_svg') From cvs at intevation.de Sun May 16 11:38:50 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sun, 16 May 2004 11:38:50 +0200 (CEST) Subject: jan: thuban/Doc/manual thuban-manual.xml,1.24,1.25 Message-ID: <20040516093850.99F901398D@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Doc/manual In directory doto:/tmp/cvs-serv16162 Modified Files: thuban-manual.xml Log Message: updated sample file to use FindOrInsertMenu(). Index: thuban-manual.xml =================================================================== RCS file: /thubanrepository/thuban/Doc/manual/thuban-manual.xml,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- thuban-manual.xml 22 Jan 2004 14:40:32 -0000 1.24 +++ thuban-manual.xml 16 May 2004 09:38:48 -0000 1.25 @@ -1831,9 +1831,7 @@ helptext = _('Welcome everyone on this planet'))) # find the extensions menu (create it anew if not found) -extensions_menu = main_menu.find_menu('extensions') -if extensions_menu is None: - extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions')) +extensions_menu = main_menu.FindOrInsertMenu('extensions', _('E&xtensions')) # finally bind the new command with an entry in the extensions menu extensions_menu.InsertItem('hello_world') From cvs at intevation.de Sun May 16 11:45:07 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sun, 16 May 2004 11:45:07 +0200 (CEST) Subject: jan: thuban/Examples/simple_extensions hello_world.py,1.1,1.2 Message-ID: <20040516094507.537F91398D@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Examples/simple_extensions In directory doto:/tmp/cvs-serv16273 Modified Files: hello_world.py Log Message: Use FindOrInsertMenu() instead of finding menu on its own. Index: hello_world.py =================================================================== RCS file: /thubanrepository/thuban/Examples/simple_extensions/hello_world.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- hello_world.py 19 Aug 2003 10:44:56 -0000 1.1 +++ hello_world.py 16 May 2004 09:45:05 -0000 1.2 @@ -36,9 +36,7 @@ helptext = _('Welcome everyone on this planet'))) # find the extensions menu (create it anew if not found) -extensions_menu = main_menu.find_menu('extensions') -if extensions_menu is None: - extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions')) +extensions_menu = main_menu.FindOrInsertMenu('extensions', _('E&xtensions')) # finally bind the new command with an entry in the extensions menu extensions_menu.InsertItem('hello_world') From cvs at intevation.de Sun May 16 11:50:13 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sun, 16 May 2004 11:50:13 +0200 (CEST) Subject: jan: thuban ChangeLog,1.650,1.651 Message-ID: <20040516095013.0331B1398D@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv16372 Modified Files: ChangeLog Log Message: Finished introduction of Menu.FindOrInsertMenu. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.650 retrieving revision 1.651 diff -u -d -r1.650 -r1.651 --- ChangeLog 12 May 2004 21:13:54 -0000 1.650 +++ ChangeLog 16 May 2004 09:50:09 -0000 1.651 @@ -1,3 +1,19 @@ +2004-05-16 Jan-Oliver Wagner + + Finished introduction of Menu.FindOrInsertMenu. + + * Extensions/drawshape/drawshape.py: Add the command + to the experimental menu additionally to the toolbar. + + * Extensions/svgexport/svgsaver.py: Use FindOrInsertMenu() instead of + finding menu on its own. + + * Doc/manual/thuban-manual.xml: updated sample file + to use FindOrInsertMenu(). + + * Examples/simple_extensions/hello_world.py: Use FindOrInsertMenu() + instead of finding menu on its own. + 2004-05-11 Jan-Oliver Wagner * test/test_menu.py (MenuTest.test): Added testing From cvs at intevation.de Mon May 17 17:48:00 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 17 May 2004 17:48:00 +0200 (CEST) Subject: bh: thuban setup.py,1.44,1.45 Message-ID: <20040517154800.13A2F13BC8@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv23933 Modified Files: setup.py Log Message: Update to newest shapelib and get rid of Thuban specific extensions, i.e. use the new DBFUpdateHeader instead of our DBFCommit kludge * libraries/shapelib/shpopen.c: Update to version from current shapelib CVS. * libraries/shapelib/shapefil.h: Update to version from current shapelib CVS. * libraries/shapelib/dbfopen.c: Update to version from current shapelib CVS. (DBFCommit): Effectively removed since shapelib itself has DBFUpdateHeader now which is better for what DBFCommit wanted to achieve. We're now using an unmodified version of dbfopen. * libraries/pyshapelib/dbflib_wrap.c, libraries/pyshapelib/dbflib.py: Update from dbflib.i * libraries/pyshapelib/dbflib.i (DBFInfo_commit): New. Implementation of the commit method. This new indirection is necessary because we use the DBFUpdateHeader function now which is not available in shapelib <= 1.2.10 (DBFFile::commit): Use DBFInfo_commit as implementation (pragma __class__): New. Kludge to remove the commit method when the DBFUpdateHeader function isn't available (_have_commit): New. Helper for the pragma kludge. * libraries/pyshapelib/setup.py (dbf_macros): New. Return the preprocessor macros needed to compile the dbflib wrapper. Determine whether DBFUpdateHeader is available and define the right value of HAVE_UPDATE_HEADER (extensions): Use dbf_macros for the dbflibc extension * setup.py (extensions): Add the HAVE_UPDATE_HEADER macro with value '1' to the Lib.dbflibc extension. This simply reflects the shapelib and pyshapelib updates Index: setup.py =================================================================== RCS file: /thubanrepository/thuban/setup.py,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- setup.py 22 Dec 2003 17:49:43 -0000 1.44 +++ setup.py 17 May 2004 15:47:57 -0000 1.45 @@ -1,4 +1,4 @@ -# Copyright (c) 2001, 2002, 2003 by Intevation GmbH +# Copyright (c) 2001, 2002, 2003, 2004 by Intevation GmbH # Authors: # Bernhard Herzog # @@ -275,7 +275,8 @@ extensions.append(Extension("Lib.dbflibc", [ext_dir + "/pyshapelib/dbflib_wrap.c", shp_dir + "/dbfopen.c"], - include_dirs = [shp_dir])) + include_dirs = [shp_dir], + define_macros = [("HAVE_UPDATE_HEADER", "1")])) for name in ("shapelib", "dbflib"): py_modules.append(ext_dir + "/pyshapelib/" + name) From cvs at intevation.de Mon May 17 17:48:00 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 17 May 2004 17:48:00 +0200 (CEST) Subject: bh: thuban/libraries/shapelib shpopen.c, 1.2, 1.3 shapefil.h, 1.2, 1.3 dbfopen.c, 1.2, 1.3 Message-ID: <20040517154800.0C73413BC7@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/shapelib In directory doto:/tmp/cvs-serv23933/libraries/shapelib Modified Files: shpopen.c shapefil.h dbfopen.c Log Message: Update to newest shapelib and get rid of Thuban specific extensions, i.e. use the new DBFUpdateHeader instead of our DBFCommit kludge * libraries/shapelib/shpopen.c: Update to version from current shapelib CVS. * libraries/shapelib/shapefil.h: Update to version from current shapelib CVS. * libraries/shapelib/dbfopen.c: Update to version from current shapelib CVS. (DBFCommit): Effectively removed since shapelib itself has DBFUpdateHeader now which is better for what DBFCommit wanted to achieve. We're now using an unmodified version of dbfopen. * libraries/pyshapelib/dbflib_wrap.c, libraries/pyshapelib/dbflib.py: Update from dbflib.i * libraries/pyshapelib/dbflib.i (DBFInfo_commit): New. Implementation of the commit method. This new indirection is necessary because we use the DBFUpdateHeader function now which is not available in shapelib <= 1.2.10 (DBFFile::commit): Use DBFInfo_commit as implementation (pragma __class__): New. Kludge to remove the commit method when the DBFUpdateHeader function isn't available (_have_commit): New. Helper for the pragma kludge. * libraries/pyshapelib/setup.py (dbf_macros): New. Return the preprocessor macros needed to compile the dbflib wrapper. Determine whether DBFUpdateHeader is available and define the right value of HAVE_UPDATE_HEADER (extensions): Use dbf_macros for the dbflibc extension * setup.py (extensions): Add the HAVE_UPDATE_HEADER macro with value '1' to the Lib.dbflibc extension. This simply reflects the shapelib and pyshapelib updates Index: shpopen.c =================================================================== RCS file: /thubanrepository/thuban/libraries/shapelib/shpopen.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- shpopen.c 2 Oct 2003 15:15:16 -0000 1.2 +++ shpopen.c 17 May 2004 15:47:57 -0000 1.3 @@ -34,9 +34,59 @@ ****************************************************************************** * * $Log$ - * Revision 1.2 2003/10/02 15:15:16 bh + * Revision 1.3 2004/05/17 15:47:57 bh + * Update to newest shapelib and get rid of Thuban specific extensions, + * i.e. use the new DBFUpdateHeader instead of our DBFCommit kludge * - * Update to shapelib 1.2.10 + * * libraries/shapelib/shpopen.c: Update to version from current + * shapelib CVS. + * + * * libraries/shapelib/shapefil.h: Update to version from current + * shapelib CVS. + * + * * libraries/shapelib/dbfopen.c: Update to version from current + * shapelib CVS. + * (DBFCommit): Effectively removed since shapelib itself has + * DBFUpdateHeader now which is better for what DBFCommit wanted to + * achieve. + * We're now using an unmodified version of dbfopen. + * + * * libraries/pyshapelib/dbflib_wrap.c, libraries/pyshapelib/dbflib.py: + * Update from dbflib.i + * + * * libraries/pyshapelib/dbflib.i (DBFInfo_commit): New. Implementation of + * the commit method. This new indirection is necessary because we use the + * DBFUpdateHeader function now which is not available in shapelib <= + * 1.2.10 + * (DBFFile::commit): Use DBFInfo_commit as implementation + * (pragma __class__): New. Kludge to remove the commit method when + * the DBFUpdateHeader function isn't available + * (_have_commit): New. Helper for the pragma kludge. + * + * * libraries/pyshapelib/setup.py (dbf_macros): New. Return the + * preprocessor macros needed to compile the dbflib wrapper. Determine + * whether DBFUpdateHeader is available and define the right value of + * HAVE_UPDATE_HEADER + * (extensions): Use dbf_macros for the dbflibc extension + * + * * setup.py (extensions): Add the HAVE_UPDATE_HEADER macro with + * value '1' to the Lib.dbflibc extension. This simply reflects the + * shapelib and pyshapelib updates + * + * Revision 1.44 2003/12/29 00:18:39 fwarmerdam + * added error checking for failed IO and optional CPL error reporting + * + * Revision 1.43 2003/12/01 16:20:08 warmerda + * be careful of zero vertex shapes + * + * Revision 1.42 2003/12/01 14:58:27 warmerda + * added degenerate object check in SHPRewindObject() + * + * Revision 1.41 2003/07/08 15:22:43 warmerda + * avoid warning + * + * Revision 1.40 2003/04/21 18:30:37 warmerda + * added header write/update public methods * * Revision 1.39 2002/08/26 06:46:56 warmerda * avoid c++ comments @@ -238,7 +288,7 @@ /* contents of the index (.shx) file. */ /************************************************************************/ -static void SHPWriteHeader( SHPHandle psSHP ) +void SHPWriteHeader( SHPHandle psSHP ) { uchar abyHeader[100]; @@ -303,8 +353,15 @@ /* -------------------------------------------------------------------- */ /* Write .shp file header. */ /* -------------------------------------------------------------------- */ - fseek( psSHP->fpSHP, 0, 0 ); - fwrite( abyHeader, 100, 1, psSHP->fpSHP ); + if( fseek( psSHP->fpSHP, 0, 0 ) != 0 + || fwrite( abyHeader, 100, 1, psSHP->fpSHP ) != 1 ) + { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_OpenFailed, + "Failure writing .shp header." ); +#endif + return; + } /* -------------------------------------------------------------------- */ /* Prepare, and write .shx file header. */ @@ -313,8 +370,15 @@ ByteCopy( &i32, abyHeader+24, 4 ); if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); - fseek( psSHP->fpSHX, 0, 0 ); - fwrite( abyHeader, 100, 1, psSHP->fpSHX ); + if( fseek( psSHP->fpSHX, 0, 0 ) != 0 + || fwrite( abyHeader, 100, 1, psSHP->fpSHX ) != 1 ) + { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_OpenFailed, + "Failure writing .shx header." ); +#endif + return; + } /* -------------------------------------------------------------------- */ /* Write out the .shx contents. */ @@ -329,13 +393,26 @@ if( !bBigEndian ) SwapWord( 4, panSHX+i*2+1 ); } - fwrite( panSHX, sizeof(int32) * 2, psSHP->nRecords, psSHP->fpSHX ); + if( fwrite( panSHX, sizeof(int32) * 2, psSHP->nRecords, psSHP->fpSHX ) + != psSHP->nRecords ) + { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_OpenFailed, + "Failure writing .shx contents." ); +#endif + } free( panSHX ); + +/* -------------------------------------------------------------------- */ +/* Flush to disk. */ +/* -------------------------------------------------------------------- */ + fflush( psSHP->fpSHP ); + fflush( psSHP->fpSHX ); } /************************************************************************/ -/* SHPOpen() */ +/* shpopen() */ /* */ /* Open the .shp and .shx files based on the basename of the */ /* files or either file name. */ @@ -408,6 +485,11 @@ if( psSHP->fpSHP == NULL ) { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to open %s.shp or %s.SHP.", + pszBasename, pszBasename ); +#endif free( psSHP ); free( pszBasename ); free( pszFullname ); @@ -424,6 +506,11 @@ if( psSHP->fpSHX == NULL ) { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to open %s.shx or %s.SHX.", + pszBasename, pszBasename ); +#endif fclose( psSHP->fpSHP ); free( psSHP ); free( pszBasename ); @@ -448,13 +535,16 @@ /* -------------------------------------------------------------------- */ /* Read SHX file Header info */ /* -------------------------------------------------------------------- */ - fread( pabyBuf, 100, 1, psSHP->fpSHX ); - - if( pabyBuf[0] != 0 + if( fread( pabyBuf, 100, 1, psSHP->fpSHX ) != 1 + || pabyBuf[0] != 0 || pabyBuf[1] != 0 || pabyBuf[2] != 0x27 || (pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d) ) { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_AppDefined, + ".shx file is unreadable, or corrupt." ); +#endif fclose( psSHP->fpSHP ); fclose( psSHP->fpSHX ); free( psSHP ); @@ -470,7 +560,12 @@ if( psSHP->nRecords < 0 || psSHP->nRecords > 256000000 ) { - /* this header appears to be corrupt. Give up. */ +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_AppDefined, + "Record count in .shp header is %d, which seems\n" + "unreasonable. Assuming header is corrupt.", + psSHP->nRecords ); +#endif fclose( psSHP->fpSHP ); fclose( psSHP->fpSHX ); free( psSHP ); @@ -527,7 +622,22 @@ (int *) malloc(sizeof(int) * MAX(1,psSHP->nMaxRecords) ); pabyBuf = (uchar *) malloc(8 * MAX(1,psSHP->nRecords) ); - fread( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX ); + if( fread( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX ) != psSHP->nRecords ) + { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to read all values for %d records in .shx file.", + psSHP->nRecords ); +#endif + /* SHX is short or unreadable for some reason. */ + fclose( psSHP->fpSHP ); + fclose( psSHP->fpSHX ); + free( psSHP->panRecOffset ); + free( psSHP->panRecSize ); + free( psSHP ); + + return( NULL ); + } for( i = 0; i < psSHP->nRecords; i++ ) { @@ -557,13 +667,14 @@ SHPClose(SHPHandle psSHP ) { + if( psSHP == NULL ) + return; + /* -------------------------------------------------------------------- */ /* Update the header if we have modified anything. */ /* -------------------------------------------------------------------- */ if( psSHP->bUpdated ) - { SHPWriteHeader( psSHP ); - } /* -------------------------------------------------------------------- */ /* Free all resources, and close files. */ @@ -594,6 +705,9 @@ { int i; + + if( psSHP == NULL ) + return; if( pnEntities != NULL ) *pnEntities = psSHP->nRecords; @@ -658,12 +772,26 @@ sprintf( pszFullname, "%s.shp", pszBasename ); fpSHP = fopen(pszFullname, "wb" ); if( fpSHP == NULL ) + { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to create file %s.", + pszFullname ); +#endif return( NULL ); + } sprintf( pszFullname, "%s.shx", pszBasename ); fpSHX = fopen(pszFullname, "wb" ); if( fpSHX == NULL ) + { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to create file %s.", + pszFullname ); +#endif return( NULL ); + } free( pszFullname ); free( pszBasename ); @@ -698,7 +826,14 @@ /* -------------------------------------------------------------------- */ /* Write .shp file header. */ /* -------------------------------------------------------------------- */ - fwrite( abyHeader, 100, 1, fpSHP ); + if( fwrite( abyHeader, 100, 1, fpSHP ) != 1 ) + { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to write .shp header." ); +#endif + return NULL; + } /* -------------------------------------------------------------------- */ /* Prepare, and write .shx file header. */ @@ -707,7 +842,14 @@ ByteCopy( &i32, abyHeader+24, 4 ); if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); - fwrite( abyHeader, 100, 1, fpSHX ); + if( fwrite( abyHeader, 100, 1, fpSHX ) != 1 ) + { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to write .shx header." ); +#endif + return NULL; + } /* -------------------------------------------------------------------- */ /* Close the files, and then open them as regular existing files. */ @@ -918,7 +1060,7 @@ SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject ) { - int nRecordOffset, i, nRecordSize; + int nRecordOffset, i, nRecordSize=0; uchar *pabyRec; int32 i32; @@ -1232,7 +1374,10 @@ if( fseek( psSHP->fpSHP, nRecordOffset, 0 ) != 0 || fwrite( pabyRec, nRecordSize, 1, psSHP->fpSHP ) < 1 ) { - printf( "Error in fseek() or fwrite().\n" ); +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_FileIO, + "Error in fseek() or fwrite() writing object to .shp file." ); +#endif free( pabyRec ); return -1; } @@ -1245,13 +1390,22 @@ if( psSHP->adBoundsMin[0] == 0.0 && psSHP->adBoundsMax[0] == 0.0 && psSHP->adBoundsMin[1] == 0.0 - && psSHP->adBoundsMax[1] == 0.0 - && psObject->nSHPType != SHPT_NULL ) + && psSHP->adBoundsMax[1] == 0.0 ) { - psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0]; - psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0]; - psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ[0]; - psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = psObject->padfM[0]; + if( psObject->nSHPType == SHPT_NULL || psObject->nVertices == 0 ) + { + psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = 0.0; + psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = 0.0; + psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = 0.0; + psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = 0.0; + } + else + { + psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0]; + psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0]; + psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ[0]; + psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = psObject->padfM[0]; + } } for( i = 0; i < psObject->nVertices; i++ ) @@ -1300,8 +1454,16 @@ /* -------------------------------------------------------------------- */ /* Read the record. */ /* -------------------------------------------------------------------- */ - fseek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 ); - fread( psSHP->pabyRec, psSHP->panRecSize[hEntity]+8, 1, psSHP->fpSHP ); + if( fseek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 ) != 0 + || fread( psSHP->pabyRec, psSHP->panRecSize[hEntity]+8, 1, + psSHP->fpSHP ) != 1 ) + { +#ifdef USE_CPL + CPLError( CE_Failure, CPLE_FileIO, + "Error in fseek() or fread() reading object from .shp file." ); +#endif + return NULL; + } /* -------------------------------------------------------------------- */ /* Allocate and minimally initialize the object. */ @@ -1737,6 +1899,9 @@ if( psObject->nSHPType != SHPT_POLYGON && psObject->nSHPType != SHPT_POLYGONZ && psObject->nSHPType != SHPT_POLYGONM ) + return 0; + + if( psObject->nVertices == 0 || psObject->nParts == 0 ) return 0; /* -------------------------------------------------------------------- */ Index: shapefil.h =================================================================== RCS file: /thubanrepository/thuban/libraries/shapelib/shapefil.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- shapefil.h 2 Oct 2003 15:15:16 -0000 1.2 +++ shapefil.h 17 May 2004 15:47:57 -0000 1.3 @@ -37,9 +37,50 @@ ****************************************************************************** * * $Log$ - * Revision 1.2 2003/10/02 15:15:16 bh + * Revision 1.3 2004/05/17 15:47:57 bh + * Update to newest shapelib and get rid of Thuban specific extensions, + * i.e. use the new DBFUpdateHeader instead of our DBFCommit kludge * - * Update to shapelib 1.2.10 + * * libraries/shapelib/shpopen.c: Update to version from current + * shapelib CVS. + * + * * libraries/shapelib/shapefil.h: Update to version from current + * shapelib CVS. + * + * * libraries/shapelib/dbfopen.c: Update to version from current + * shapelib CVS. + * (DBFCommit): Effectively removed since shapelib itself has + * DBFUpdateHeader now which is better for what DBFCommit wanted to + * achieve. + * We're now using an unmodified version of dbfopen. + * + * * libraries/pyshapelib/dbflib_wrap.c, libraries/pyshapelib/dbflib.py: + * Update from dbflib.i + * + * * libraries/pyshapelib/dbflib.i (DBFInfo_commit): New. Implementation of + * the commit method. This new indirection is necessary because we use the + * DBFUpdateHeader function now which is not available in shapelib <= + * 1.2.10 + * (DBFFile::commit): Use DBFInfo_commit as implementation + * (pragma __class__): New. Kludge to remove the commit method when + * the DBFUpdateHeader function isn't available + * (_have_commit): New. Helper for the pragma kludge. + * + * * libraries/pyshapelib/setup.py (dbf_macros): New. Return the + * preprocessor macros needed to compile the dbflib wrapper. Determine + * whether DBFUpdateHeader is available and define the right value of + * HAVE_UPDATE_HEADER + * (extensions): Use dbf_macros for the dbflibc extension + * + * * setup.py (extensions): Add the HAVE_UPDATE_HEADER macro with + * value '1' to the Lib.dbflibc extension. This simply reflects the + * shapelib and pyshapelib updates + * + * Revision 1.28 2003/12/29 06:02:18 fwarmerdam + * added cpl_error.h option + * + * Revision 1.27 2003/04/21 18:30:37 warmerda + * added header write/update public methods * * Revision 1.26 2002/09/29 00:00:08 warmerda * added FTLogical and logical attribute read/write calls @@ -124,6 +165,10 @@ #include #endif +#ifdef USE_CPL +#include "cpl_error.h" +#endif + #ifdef __cplusplus extern "C" { #endif @@ -309,8 +354,8 @@ int SHPAPI_CALL SHPRewindObject( SHPHandle hSHP, SHPObject * psObject ); -void SHPAPI_CALL - SHPClose( SHPHandle hSHP ); +void SHPAPI_CALL SHPClose( SHPHandle hSHP ); +void SHPAPI_CALL SHPWriteHeader( SHPHandle hSHP ); const char SHPAPI_CALL1(*) SHPTypeName( int nSHPType ); @@ -478,11 +523,10 @@ void SHPAPI_CALL DBFClose( DBFHandle hDBF ); +void SHPAPI_CALL + DBFUpdateHeader( DBFHandle hDBF ); char SHPAPI_CALL DBFGetNativeFieldType( DBFHandle hDBF, int iField ); - -int SHPAPI_CALL - DBFCommit( DBFHandle hDBF ); #ifdef __cplusplus } Index: dbfopen.c =================================================================== RCS file: /thubanrepository/thuban/libraries/shapelib/dbfopen.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- dbfopen.c 2 Oct 2003 15:15:16 -0000 1.2 +++ dbfopen.c 17 May 2004 15:47:57 -0000 1.3 @@ -34,9 +34,59 @@ ****************************************************************************** * * $Log$ - * Revision 1.2 2003/10/02 15:15:16 bh + * Revision 1.3 2004/05/17 15:47:57 bh + * Update to newest shapelib and get rid of Thuban specific extensions, + * i.e. use the new DBFUpdateHeader instead of our DBFCommit kludge * - * Update to shapelib 1.2.10 + * * libraries/shapelib/shpopen.c: Update to version from current + * shapelib CVS. + * + * * libraries/shapelib/shapefil.h: Update to version from current + * shapelib CVS. + * + * * libraries/shapelib/dbfopen.c: Update to version from current + * shapelib CVS. + * (DBFCommit): Effectively removed since shapelib itself has + * DBFUpdateHeader now which is better for what DBFCommit wanted to + * achieve. + * We're now using an unmodified version of dbfopen. + * + * * libraries/pyshapelib/dbflib_wrap.c, libraries/pyshapelib/dbflib.py: + * Update from dbflib.i + * + * * libraries/pyshapelib/dbflib.i (DBFInfo_commit): New. Implementation of + * the commit method. This new indirection is necessary because we use the + * DBFUpdateHeader function now which is not available in shapelib <= + * 1.2.10 + * (DBFFile::commit): Use DBFInfo_commit as implementation + * (pragma __class__): New. Kludge to remove the commit method when + * the DBFUpdateHeader function isn't available + * (_have_commit): New. Helper for the pragma kludge. + * + * * libraries/pyshapelib/setup.py (dbf_macros): New. Return the + * preprocessor macros needed to compile the dbflib wrapper. Determine + * whether DBFUpdateHeader is available and define the right value of + * HAVE_UPDATE_HEADER + * (extensions): Use dbf_macros for the dbflibc extension + * + * * setup.py (extensions): Add the HAVE_UPDATE_HEADER macro with + * value '1' to the Lib.dbflibc extension. This simply reflects the + * shapelib and pyshapelib updates + * + * Revision 1.53 2003/12/29 00:00:30 fwarmerdam + * mark DBFWriteAttributeDirectly as SHPAPI_CALL + * + * Revision 1.52 2003/07/08 15:20:03 warmerda + * avoid warnings about downcasting to unsigned char + * + * Revision 1.51 2003/07/08 13:50:15 warmerda + * DBFIsAttributeNULL check for pszValue==NULL - bug 360 + * + * Revision 1.50 2003/04/21 18:58:25 warmerda + * ensure current record is flushed at same time as header is updated + * + * Revision 1.49 2003/04/21 18:30:37 warmerda + * added header write/update public methods * * Revision 1.48 2003/03/10 14:51:27 warmerda * DBFWrite* calls now return FALSE if they have to truncate @@ -248,13 +298,18 @@ abyHeader[0] = 0x03; /* memo field? - just copying */ - /* date updated on close, record count preset at zero */ + /* write out a dummy date */ + abyHeader[1] = 95; /* YY */ + abyHeader[2] = 7; /* MM */ + abyHeader[3] = 26; /* DD */ - abyHeader[8] = psDBF->nHeaderLength % 256; - abyHeader[9] = psDBF->nHeaderLength / 256; + /* record count preset at zero */ + + abyHeader[8] = (unsigned char) (psDBF->nHeaderLength % 256); + abyHeader[9] = (unsigned char) (psDBF->nHeaderLength / 256); - abyHeader[10] = psDBF->nRecordLength % 256; - abyHeader[11] = psDBF->nRecordLength / 256; + abyHeader[10] = (unsigned char) (psDBF->nRecordLength % 256); + abyHeader[11] = (unsigned char) (psDBF->nRecordLength / 256); /* -------------------------------------------------------------------- */ /* Write the initial 32 byte file header, and all the field */ @@ -300,6 +355,35 @@ } /************************************************************************/ +/* DBFUpdateHeader() */ +/************************************************************************/ + +void SHPAPI_CALL +DBFUpdateHeader( DBFHandle psDBF ) + +{ + unsigned char abyFileHeader[32]; + + if( psDBF->bNoHeader ) + DBFWriteHeader( psDBF ); + + DBFFlushRecord( psDBF ); + + fseek( psDBF->fp, 0, 0 ); + fread( abyFileHeader, 32, 1, psDBF->fp ); + + abyFileHeader[4] = (unsigned char) (psDBF->nRecords % 256); + abyFileHeader[5] = (unsigned char) ((psDBF->nRecords/256) % 256); + abyFileHeader[6] = (unsigned char) ((psDBF->nRecords/(256*256)) % 256); + abyFileHeader[7] = (unsigned char) ((psDBF->nRecords/(256*256*256)) % 256); + + fseek( psDBF->fp, 0, 0 ); + fwrite( abyFileHeader, 32, 1, psDBF->fp ); + + fflush( psDBF->fp ); +} + +/************************************************************************/ /* DBFOpen() */ /* */ /* Open a .dbf file. */ @@ -458,24 +542,7 @@ /* write access. */ /* -------------------------------------------------------------------- */ if( psDBF->bUpdated ) - { - unsigned char abyFileHeader[32]; - - fseek( psDBF->fp, 0, 0 ); - fread( abyFileHeader, 32, 1, psDBF->fp ); - - abyFileHeader[1] = 95; /* YY */ - abyFileHeader[2] = 7; /* MM */ - abyFileHeader[3] = 26; /* DD */ - - abyFileHeader[4] = psDBF->nRecords % 256; - abyFileHeader[5] = (psDBF->nRecords/256) % 256; - abyFileHeader[6] = (psDBF->nRecords/(256*256)) % 256; - abyFileHeader[7] = (psDBF->nRecords/(256*256*256)) % 256; - - fseek( psDBF->fp, 0, 0 ); - fwrite( abyFileHeader, 32, 1, psDBF->fp ); - } + DBFUpdateHeader( psDBF ); /* -------------------------------------------------------------------- */ /* Close, and free resources. */ @@ -663,13 +730,13 @@ if( eType == FTString ) { - pszFInfo[16] = nWidth % 256; - pszFInfo[17] = nWidth / 256; + pszFInfo[16] = (unsigned char) (nWidth % 256); + pszFInfo[17] = (unsigned char) (nWidth / 256); } else { - pszFInfo[16] = nWidth; - pszFInfo[17] = nDecimals; + pszFInfo[16] = (unsigned char) nWidth; + pszFInfo[17] = (unsigned char) nDecimals; } /* -------------------------------------------------------------------- */ @@ -870,6 +937,9 @@ pszValue = DBFReadStringAttribute( psDBF, iRecord, iField ); + if( pszValue == NULL ) + return TRUE; + switch(psDBF->pachFieldType[iField]) { case 'N': @@ -1141,7 +1211,8 @@ /* as is to the field position in the record. */ /************************************************************************/ -int DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField, +int SHPAPI_CALL +DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField, void * pValue ) { @@ -1464,7 +1535,7 @@ while (++i < len) if (isalpha(string[i]) && islower(string[i])) - string[i] = toupper ((int)string[i]); + string[i] = (char) toupper ((int)string[i]); } /************************************************************************/ @@ -1496,21 +1567,4 @@ return(i); } return(-1); -} - -/************************************************************************/ -/* DBFCommit() */ -/* */ -/* Write any changes made into the file. */ -/* */ -/************************************************************************/ -int SHPAPI_CALL -DBFCommit( DBFHandle psDBF ) - -{ - DBFFlushRecord( psDBF ); - if (fflush( psDBF->fp ) == EOF) - return FALSE; - - return TRUE; } From cvs at intevation.de Mon May 17 17:48:00 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 17 May 2004 17:48:00 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib setup.py, 1.1, 1.2 dbflib_wrap.c, 1.3, 1.4 dbflib.py, 1.2, 1.3 dbflib.i, 1.3, 1.4 Message-ID: <20040517154800.21A4013BC9@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv23933/libraries/pyshapelib Modified Files: setup.py dbflib_wrap.c dbflib.py dbflib.i Log Message: Update to newest shapelib and get rid of Thuban specific extensions, i.e. use the new DBFUpdateHeader instead of our DBFCommit kludge * libraries/shapelib/shpopen.c: Update to version from current shapelib CVS. * libraries/shapelib/shapefil.h: Update to version from current shapelib CVS. * libraries/shapelib/dbfopen.c: Update to version from current shapelib CVS. (DBFCommit): Effectively removed since shapelib itself has DBFUpdateHeader now which is better for what DBFCommit wanted to achieve. We're now using an unmodified version of dbfopen. * libraries/pyshapelib/dbflib_wrap.c, libraries/pyshapelib/dbflib.py: Update from dbflib.i * libraries/pyshapelib/dbflib.i (DBFInfo_commit): New. Implementation of the commit method. This new indirection is necessary because we use the DBFUpdateHeader function now which is not available in shapelib <= 1.2.10 (DBFFile::commit): Use DBFInfo_commit as implementation (pragma __class__): New. Kludge to remove the commit method when the DBFUpdateHeader function isn't available (_have_commit): New. Helper for the pragma kludge. * libraries/pyshapelib/setup.py (dbf_macros): New. Return the preprocessor macros needed to compile the dbflib wrapper. Determine whether DBFUpdateHeader is available and define the right value of HAVE_UPDATE_HEADER (extensions): Use dbf_macros for the dbflibc extension * setup.py (extensions): Add the HAVE_UPDATE_HEADER macro with value '1' to the Lib.dbflibc extension. This simply reflects the shapelib and pyshapelib updates Index: setup.py =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/setup.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- setup.py 19 Aug 2003 21:24:20 -0000 1.1 +++ setup.py 17 May 2004 15:47:57 -0000 1.2 @@ -1,23 +1,44 @@ import os from distutils.core import setup, Extension +from distutils.util import convert_path # try to determine the directory where the shapelib source files are. # There are currently two supported situations. # # 1. "Standalone" build: the parent directory is the shapelib source # directory -# 2. Built in the Thuban source tree where it's ../shapelib/ relative to -# the directory containing this setup.py +# 2. Built in the Thuban source tree where ../shapelib/ relative to the +# directory containing this setup.py contains (the relevant parts of) +# shapelib # os.path expects filenames in OS-specific form so we have to construct # the files with os.path functions. distutils, OTOH, uses posix-style -# filenames exclusively, so we posix when making filenames for -# distutils. -if os.path.exists(os.path.join(os.pardir, "shpeopen.c")): - shp_dir = ".." -elif os.path.exists(os.path.join(os.pardir, "shapelib")): - shp_dir = "../shapelib" +# filenames exclusively, so we use posix conventions when making +# filenames for distutils. +for shp_dir in ["..", "../shapelib"]: + if os.path.exists(os.path.join(convert_path(shp_dir), "shpopen.c")): + # shp_dir contains shpopen.c, so assume it's the directory with + # the shapefile library to use + break + +def dbf_macros(): + """Return the macros to define when compiling the dbflib wrapper. + + The returned list specifies one macro, HAVE_UPDATE_HEADER, which is + '1' if the dbflib version we will be compiling with has the + DBFUpdateHeader function and '0' otherwise. To check whether + DBFUpdateHeader is available, we scan shapefil.h for the string + 'DBFUpdateHeader'. + """ + f = open(convert_path(shp_dir + "/shapefil.h")) + contents = f.read() + f.close() + print contents.find("DBFUpdateHeader") + if contents.find("DBFUpdateHeader") >= 0: + return [("HAVE_UPDATE_HEADER", "1")] + else: + return [("HAVE_UPDATE_HEADER", "0")] extensions = [Extension("shapelibc", ["shapelib_wrap.c", @@ -30,7 +51,8 @@ Extension("dbflibc", ["dbflib_wrap.c", shp_dir + "/dbfopen.c"], - include_dirs = [shp_dir])] + include_dirs = [shp_dir], + define_macros = dbf_macros())] setup(name = "pyshapelib", version = "0.3", Index: dbflib_wrap.c =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/dbflib_wrap.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- dbflib_wrap.c 3 Nov 2003 17:31:11 -0000 1.3 +++ dbflib_wrap.c 17 May 2004 15:47:57 -0000 1.4 @@ -820,6 +820,15 @@ return NULL; } +static +void +DBFInfo_commit(DBFHandle handle) +{ +#if HAVE_UPDATE_HEADER + DBFUpdateHeader(handle); +#endif +} + static PyObject* l_output_helper(PyObject* target, PyObject* o) { PyObject* o2; if (!target) { @@ -1326,9 +1335,9 @@ } -int DBFFile_commit(DBFFile *self) { +void DBFFile_commit(DBFFile *self) { { - return DBFCommit(self->handle); + DBFInfo_commit(self->handle); } } @@ -1337,7 +1346,6 @@ PyObject *resultobj; DBFFile *arg0 ; PyObject * argo0 =0 ; - int result ; if(!PyArg_ParseTuple(args,"O:DBFFile_commit",&argo0)) return NULL; if ((SWIG_ConvertPtr(argo0,(void **) &arg0,SWIGTYPE_p_DBFFile,1)) == -1) return NULL; @@ -1347,8 +1355,9 @@ SWIG_exception(SWIG_TypeError, "dbffile already closed"); #endif } - result = (int )DBFFile_commit(arg0); - resultobj = PyInt_FromLong((long)result); + DBFFile_commit(arg0); + Py_INCREF(Py_None); + resultobj = Py_None; return resultobj; } @@ -1391,6 +1400,7 @@ { SWIG_PY_INT, "FTInteger", (long) FTInteger, 0, 0, 0}, { SWIG_PY_INT, "FTDouble", (long) FTDouble, 0, 0, 0}, { SWIG_PY_INT, "FTInvalid", (long) FTInvalid, 0, 0, 0}, + { SWIG_PY_INT, "_have_commit", (long) HAVE_UPDATE_HEADER, 0, 0, 0}, {0}}; static PyObject *SWIG_globals; Index: dbflib.py =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/dbflib.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- dbflib.py 3 Nov 2003 17:31:11 -0000 1.2 +++ dbflib.py 17 May 2004 15:47:57 -0000 1.3 @@ -37,6 +37,7 @@ return val def __repr__(self): return "" % (self.this,) + if not dbflibc._have_commit: del commit class DBFFilePtr(DBFFile): def __init__(self,this): self.this = this @@ -67,3 +68,4 @@ FTInteger = dbflibc.FTInteger FTDouble = dbflibc.FTDouble FTInvalid = dbflibc.FTInvalid +_have_commit = dbflibc._have_commit Index: dbflib.i =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/dbflib.i,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- dbflib.i 3 Nov 2003 17:31:11 -0000 1.3 +++ dbflib.i 17 May 2004 15:47:57 -0000 1.4 @@ -345,6 +345,25 @@ %} +/* The commit method implementation + * + * The method relies on the DBFUpdateHeader method which is not + * available in shapelib <= 1.2.10. setup.py defines + * HAVE_UPDATE_HEADER's value depending on whether the function is + * available in the shapelib version the code is compiled with. + */ +%{ +static +void +DBFInfo_commit(DBFHandle handle) +{ +#if HAVE_UPDATE_HEADER + DBFUpdateHeader(handle); +#endif +} +%} + + /* * The SWIG Interface definition. */ @@ -502,9 +521,13 @@ dict_or_sequence); } - int commit() { - return DBFCommit(self->handle); + void commit() { + DBFInfo_commit(self->handle); } + /* Delete the commit method from the class if it doesn't have a + * real implementation. + */ + %pragma(python) addtomethod="__class__:if not dbflibc._have_commit: del commit" } } DBFFile; @@ -550,3 +573,11 @@ FTDouble, FTInvalid } DBFFieldType; + + +/* Put the value of the HAVE_UPDATE_HEADER preprocessor macro into the + * wrapper so that the __class__ pragma above knows when to remove the + * commit method + */ +const int _have_commit = HAVE_UPDATE_HEADER; + From cvs at intevation.de Mon May 17 17:48:55 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 17 May 2004 17:48:55 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib ChangeLog,1.3,1.4 Message-ID: <20040517154855.514D113BC7@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv23993/libraries/pyshapelib Modified Files: ChangeLog Log Message: update ChangeLogs Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/ChangeLog,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ChangeLog 3 Nov 2003 17:31:25 -0000 1.3 +++ ChangeLog 17 May 2004 15:48:53 -0000 1.4 @@ -1,3 +1,24 @@ +2004-05-17 Bernhard Herzog + + * README: Update for new release + + * setup.py (dbf_macros): New. Return the preprocessor macros + needed to compile the dbflib wrapper. Determine whether + DBFUpdateHeader is available and define the right value of + HAVE_UPDATE_HEADER + (extensions): Use dbf_macros for the dbflibc extension + + * dbflib_wrap.c, dbflib.py: Update from dbflib.i + + * dbflib.i (DBFInfo_commit): New. Implementation of the commit + method. This new indirection is necessary because we use the + DBFUpdateHeader function now which is not available in shapelib <= + 1.2.10 + (DBFFile::commit): Use DBFInfo_commit as implementation + (pragma __class__): New. Kludge to remove the commit method when + the DBFUpdateHeader function isn't available + (_have_commit): New. Helper for the pragma kludge. + 2003-11-03 Bernhard Herzog * dbflib.i (do_read_attribute): New helper function for reading From cvs at intevation.de Mon May 17 17:48:55 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 17 May 2004 17:48:55 +0200 (CEST) Subject: bh: thuban ChangeLog,1.651,1.652 Message-ID: <20040517154855.9EE6A13BC8@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv23993 Modified Files: ChangeLog Log Message: update ChangeLogs Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.651 retrieving revision 1.652 diff -u -d -r1.651 -r1.652 --- ChangeLog 16 May 2004 09:50:09 -0000 1.651 +++ ChangeLog 17 May 2004 15:48:53 -0000 1.652 @@ -1,3 +1,26 @@ +2004-05-17 Bernhard Herzog + + Update to newest shapelib and get rid of Thuban specific + extensions, i.e. use the new DBFUpdateHeader instead of our + DBFCommit kludge + + * libraries/shapelib/shpopen.c: Update to version from current + shapelib CVS. + + * libraries/shapelib/shapefil.h: Update to version from current + shapelib CVS. + + * libraries/shapelib/dbfopen.c: Update to version from current + shapelib CVS. + (DBFCommit): Effectively removed since shapelib itself has + DBFUpdateHeader now which is better for what DBFCommit wanted to + achieve. + We're now using an unmodified version of dbfopen. + + * setup.py (extensions): Add the HAVE_UPDATE_HEADER macro with + value '1' to the Lib.dbflibc extension. This simply reflects the + shapelib and pyshapelib updates + 2004-05-16 Jan-Oliver Wagner Finished introduction of Menu.FindOrInsertMenu. From cvs at intevation.de Mon May 17 17:50:44 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 17 May 2004 17:50:44 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib NEWS,1.1,1.2 Message-ID: <20040517155044.0C5FB13BC7@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv24040/libraries/pyshapelib Modified Files: NEWS Log Message: update for the next release Index: NEWS =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/NEWS,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- NEWS 19 Aug 2003 21:24:20 -0000 1.1 +++ NEWS 17 May 2004 15:50:41 -0000 1.2 @@ -1,3 +1,28 @@ +pyshapelib 0.3 (2004-05-17) +=========================== + + * New module shptree. It's a simple wrapper for shapelib's quadtree. + + * Provide a way to access the shapelib module and shapefile objects + from C. It's not documented, unfortunately, but pyshapelib_api.h may + be a starting point. This feature is used in Thuban which could be + used as an example. + +Module dbflib: + + * dbf objects now have a method commit if compiled with shapelib newer + than 1.2.10 (that is only the CVS version of shapelib at the time of + writing). This method calls the new function dbflib DBFUpdateHeader. + + * New method read_attribute which reads a single attribute instead of a + whole record like read_record + + * NULL values are now returned as None. DBF files don't really support + NULL, but this change matches a new feature in shapelib 1.2.9. It's + not clear whether it should be implemented in the python wrapper in + this way. It might be better to make it optional. + + pyshapelib 0.2 (2001-06-15) =========================== From cvs at intevation.de Mon May 17 17:51:07 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 17 May 2004 17:51:07 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib README,1.1,1.2 Message-ID: <20040517155107.55E1213BC7@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv24060/libraries/pyshapelib Modified Files: README Log Message: Update for next release Index: README =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/README,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- README 19 Aug 2003 21:24:20 -0000 1.1 +++ README 17 May 2004 15:51:05 -0000 1.2 @@ -2,31 +2,36 @@ Python bindings for Shapelib ============================ -These are two python modules for shapelib created with SWIG. +These are three python modules for shapelib: + + shapelib read/write shapefiles + + dbflib read/write dbf files + + shptree quadtree for shapes Shapelib is a free software library for reading and writing ESRI shape files and can be found at http://gdal.velocet.ca/projects/shapelib. -SWIG is tool that can generate wrappers of C and C++ libraries for a -variety of scripting languages. It's homepage is www.swig.org. +The bindings were partly created with SWIG, a tool that can generate +wrappers of C and C++ libraries for a variety of scripting languages. +It's homepage is http://www.swig.org. -The two modules here wrap the shape file reading and writing API and the -DBF file reading and writing API. The shape file bindings are currently -limited to 2-dimensional data. Requirements ------------ -To compile the bindings, you need shapelib 1.2.8. Older versions may or -may not work, I've only tested the code with 1.2.8. +To compile the bindings, you need shapelib 1.2.8 or newer. Older +versions may or may not work; nobody has tested that. SWIG is not required. The files generated by SWIG are contained in the -archive. If modify shapelib.i or dbflib.i and need to recreate the -generated files, you need at least SWIG 1.3. +archive. If you modify shapelib.i or dbflib.i and need to recreate the +generated files, you need SWIG 1.3 Alpha 5. It's unlikely that other +versions will work. -You also need Python, of course. If you installed prebuilt packages such -as RPMs of some Linux distributions, please make sure that the +You also need Python, of course. If you installed prebuilt packages +such as RPMs of some Linux distributions, please make sure that the development package is also installed. @@ -44,7 +49,9 @@ and are also available separately from python.org for older versions. To compile the bindings, unpack the archive under the shapelib archive -or move the directory there if you've already unpacked it. Then run +or move the directory there if you've already unpacked it. The setup +script expects to find the shapelib files in the parent directory. Then +run python setup.py build From cvs at intevation.de Tue May 18 23:09:52 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 18 May 2004 23:09:52 +0200 (CEST) Subject: jan: thuban/Extensions/gns2shp gns2shp.py,1.2,1.3 Message-ID: <20040518210952.55B1013B83@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Extensions/gns2shp In directory doto:/tmp/cvs-serv13312 Modified Files: gns2shp.py Log Message: (gns2shp): Fixed a bug by increasing a field size. Index: gns2shp.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/gns2shp/gns2shp.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gns2shp.py 11 May 2004 22:34:49 -0000 1.2 +++ gns2shp.py 18 May 2004 21:09:50 -0000 1.3 @@ -77,7 +77,7 @@ dbf.add_field('SORT_NAME', dbflib.FTString, 40, 0) dbf.add_field('FULL_NAME', dbflib.FTString, 40, 0) dbf.add_field('FULL_ND', dbflib.FTString, 40, 0) - dbf.add_field('MODIFY_DATE', dbflib.FTString, 10, 0) + dbf.add_field('MODIFY_DATE', dbflib.FTString, 11, 0) del dbf dbf = dbflib.open(dbf_filename, 'r+b') From cvs at intevation.de Tue May 18 23:10:35 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 18 May 2004 23:10:35 +0200 (CEST) Subject: jan: thuban ChangeLog,1.652,1.653 Message-ID: <20040518211035.DBADC13B83@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv13340 Modified Files: ChangeLog Log Message: Fixed a bug in Extension gns2shp Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.652 retrieving revision 1.653 diff -u -d -r1.652 -r1.653 --- ChangeLog 17 May 2004 15:48:53 -0000 1.652 +++ ChangeLog 18 May 2004 21:10:33 -0000 1.653 @@ -1,3 +1,8 @@ +2004-05-18 Jan-Oliver Wagner + + * Extensions/gns2shp/gns2shp.py (gns2shp): Fixed a bug + by increasing a field size. + 2004-05-17 Bernhard Herzog Update to newest shapelib and get rid of Thuban specific From cvs at intevation.de Tue May 18 23:22:27 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 18 May 2004 23:22:27 +0200 (CEST) Subject: jan: thuban/Extensions/gns2shp gns2shp.py,1.1,1.1.2.1 Message-ID: <20040518212227.45B6313B83@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Extensions/gns2shp In directory doto:/tmp/cvs-serv13430 Modified Files: Tag: thuban-1-0-branch gns2shp.py Log Message: (gns2shp): Fixed a bug by increasing a field size. Index: gns2shp.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/gns2shp/gns2shp.py,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -d -r1.1 -r1.1.2.1 --- gns2shp.py 22 Sep 2003 10:32:04 -0000 1.1 +++ gns2shp.py 18 May 2004 21:22:25 -0000 1.1.2.1 @@ -75,7 +75,7 @@ dbf.add_field('SORT_NAME', dbflib.FTString, 40, 0) dbf.add_field('FULL_NAME', dbflib.FTString, 40, 0) dbf.add_field('FULL_ND', dbflib.FTString, 40, 0) - dbf.add_field('MODIFY_DATE', dbflib.FTString, 10, 0) + dbf.add_field('MODIFY_DATE', dbflib.FTString, 11, 0) del dbf dbf = dbflib.open(dbf_filename, 'r+b') From cvs at intevation.de Tue May 18 23:24:01 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 18 May 2004 23:24:01 +0200 (CEST) Subject: jan: thuban ChangeLog,1.624.2.5,1.624.2.6 Message-ID: <20040518212401.10C7D13B83@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv13473 Modified Files: Tag: thuban-1-0-branch ChangeLog Log Message: Fixed a bug in Extension gns2shp Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.624.2.5 retrieving revision 1.624.2.6 diff -u -d -r1.624.2.5 -r1.624.2.6 --- ChangeLog 22 Apr 2004 15:52:13 -0000 1.624.2.5 +++ ChangeLog 18 May 2004 21:23:58 -0000 1.624.2.6 @@ -1,3 +1,8 @@ +2004-05-18 Jan-Oliver Wagner + + * Extensions/gns2shp/gns2shp.py (gns2shp): Fixed a bug + by increasing a field size. + 2004-04-22 Bernhard Herzog * Thuban/UI/classgen.py (GenQuantilesPanel.GetList): The row From jan at intevation.de Tue May 18 23:28:43 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Tue, 18 May 2004 23:28:43 +0200 Subject: extensions/experimental menu In-Reply-To: <20040511225925.GA32674@intevation.de> References: <20040422171156.47FCF13AAE@lists.intevation.de> <20040502120847.GA1515@intevation.de> <20040502123319.GJ716@finlandia.infodrom.north.de> <20040503202942.GA31542@intevation.de> <20040511225925.GA32674@intevation.de> Message-ID: <20040518212843.GB25528@intevation.de> On Wed, May 12, 2004 at 12:59:25AM +0200, Jan-Oliver Wagner wrote: > On Mon, May 03, 2004 at 10:29:42PM +0200, Jan-Oliver Wagner wrote: > > if noone objects, I will prepare a patch for this. > > done now and committed. > Yet to change: > svgexport: I'd like to see this running first (no tech problems). > drawshape: Shouldn't there be a menu additionally to the tool icon? > > And there seems to be a bug in gns2shp. Grmpf. finally all done/fixed now :-) Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From joey at infodrom.org Wed May 19 13:03:48 2004 From: joey at infodrom.org (Martin Schulze) Date: Wed, 19 May 2004 13:03:48 +0200 Subject: Extensions vs. Experimental Message-ID: <20040519110348.GM716@finlandia.infodrom.north.de> Hi, I just noticed that some extensions hook itself into the 'E&xtensions' menu and some others add themselfes to the 'Experimenta&l' menu. Not sure if that's intended and I don't know which one more appropriate either, but I thought I'd better let you know. Regards, Joey -- Ten years and still binary compatible. -- XFree86 From jan at intevation.de Wed May 19 16:37:51 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Wed, 19 May 2004 16:37:51 +0200 Subject: [Thuban-devel] Extensions vs. Experimental In-Reply-To: <20040519110348.GM716@finlandia.infodrom.north.de> References: <20040519110348.GM716@finlandia.infodrom.north.de> Message-ID: <20040519143751.GF8387@intevation.de> On Wed, May 19, 2004 at 01:03:48PM +0200, Martin Schulze wrote: > I just noticed that some extensions hook itself into the 'E&xtensions' > menu and some others add themselfes to the 'Experimenta&l' menu. Not > sure if that's intended and I don't know which one more appropriate > either, but I thought I'd better let you know. it is intentional. I put the stuff of which I think is complete and working into the Extensions menu. The stuff that is incomplete or has still serious bugs to solve go into Experimental. WMS was in Experimental so far because the implementation was not completet. So, once you are done with this, it should be moved to Extensions ;-) Best Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From joey at infodrom.org Wed May 19 16:48:13 2004 From: joey at infodrom.org (Martin Schulze) Date: Wed, 19 May 2004 16:48:13 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: <20040419113029.GA10000@intevation.de> References: <20040415182050.GH1655@finlandia.infodrom.north.de> <20040419113029.GA10000@intevation.de> Message-ID: <20040519144813.GX716@finlandia.infodrom.north.de> Jan-Oliver Wagner wrote: > On Fri, Apr 16, 2004 at 05:02:28PM +0200, Bernhard Herzog wrote: > > The main problem with the Show Table command is that it's not grayed out > > in the context menu for non-shape layers. It is grayed out in the main > > menu, so it should be easy to do it in the context menu too. Jan is > > already looking into that. > > and fixed that in HEAD and thuban-1-0-branch now :-) > > > For the properties dialog, a registry like that for the renderer would > > be an easy way to define new layer type specific properties dialogs. > > > > The existing properties dialog should perhaps be split in two, one for > > the shape layers and one for raster layers, instead of having one which > > simply doesn't have some of the widgets of the other. It might be a > > good idea ot have a common base class for the property dialogs which has > > the widgets for the common base class BaseLayer. > > these two actions look quite sensible to me. > > Joey: Do you think you could develop patches for this (first the dialog > separation, then based on that, the registry for properties dialogs like > for renderer)? Looking at the current code: MainWindow.OpenLayerProperties(): dialog = self.get_open_dialog(name) if dialog is None: dialog = Classifier(self, name, self.Map(), layer, group) self.add_dialog(name, dialog) dialog.Show() else dialog.Raise() Classifier is a specialisation of NonModalNonParentDialog So what you would like to see is something like class GeneralPropertiesDialogs (NonModalNonParentDialog) ... class Classifier (GeneralPropertiesDialog) ... class wmsPropertiesDialog (GeneralPropertiesDialog) ... and BaseLayer.propertiesDialog of class PropertiesDialog, or rather one of the specialisations of it (i.e. Classifier or wmsPropertiesDialog). MainWindow.OpenLayerProperties would then contain code like if current_layer.has_properties(): name = ... dialog = self.get_open_dialog(name) if dialog is None: dialog = current_layer.properties_dialog(..) self.add_dialog(name, dialog) dialog.Show() else dialog.Raise() Is that what you wanted? Or did I misunderstand you? Regards, Joey -- Ten years and still binary compatible. -- XFree86 From joey at infodrom.org Wed May 19 16:53:21 2004 From: joey at infodrom.org (Martin Schulze) Date: Wed, 19 May 2004 16:53:21 +0200 Subject: [Thuban-devel] Extensions vs. Experimental In-Reply-To: <20040519143751.GF8387@intevation.de> References: <20040519110348.GM716@finlandia.infodrom.north.de> <20040519143751.GF8387@intevation.de> Message-ID: <20040519145321.GY716@finlandia.infodrom.north.de> Jan-Oliver Wagner wrote: > On Wed, May 19, 2004 at 01:03:48PM +0200, Martin Schulze wrote: > > I just noticed that some extensions hook itself into the 'E&xtensions' > > menu and some others add themselfes to the 'Experimenta&l' menu. Not > > sure if that's intended and I don't know which one more appropriate > > either, but I thought I'd better let you know. > > it is intentional. > I put the stuff of which I think is complete and working > into the Extensions menu. > > The stuff that is incomplete or has still serious bugs > to solve go into Experimental. Ok, I understand. Regards, Joey -- Ten years and still binary compatible. -- XFree86 From bh at intevation.de Wed May 19 18:55:33 2004 From: bh at intevation.de (Bernhard Herzog) Date: Wed, 19 May 2004 18:55:33 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: <20040519144813.GX716@finlandia.infodrom.north.de> (Martin Schulze's message of "Wed, 19 May 2004 16:48:13 +0200") References: <20040415182050.GH1655@finlandia.infodrom.north.de> <20040419113029.GA10000@intevation.de> <20040519144813.GX716@finlandia.infodrom.north.de> Message-ID: Martin Schulze writes: > Looking at the current code: > > MainWindow.OpenLayerProperties(): > dialog = self.get_open_dialog(name) > if dialog is None: > dialog = Classifier(self, name, self.Map(), layer, group) > self.add_dialog(name, dialog) > dialog.Show() > else > dialog.Raise() > > Classifier is a specialisation of NonModalNonParentDialog > > So what you would like to see is something like > > class GeneralPropertiesDialogs (NonModalNonParentDialog) > ... > class Classifier (GeneralPropertiesDialog) > ... > class wmsPropertiesDialog (GeneralPropertiesDialog) Yes > ... > > and > > BaseLayer.propertiesDialog of class PropertiesDialog, or rather one > of the specialisations of it (i.e. Classifier or wmsPropertiesDialog). > > MainWindow.OpenLayerProperties would then contain code like > > if current_layer.has_properties(): > name = ... > dialog = self.get_open_dialog(name) > if dialog is None: > dialog = current_layer.properties_dialog(..) > self.add_dialog(name, dialog) > dialog.Show() > else > dialog.Raise() No. The code outside of Thuban.UI should not depend on the GUI. I'd prefer a solution like the one used for the renderer extensions in baserenderer.py. It basically means that there's a mapping between layer classes and property dialog classes. This mapping should be in a new module, I think, together with the GeneralPropertiesDialog class. The OpenLayerProperties method would call a function in that module which returns the dialog class for a given layer. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From bh at intevation.de Wed May 19 19:08:57 2004 From: bh at intevation.de (Bernhard Herzog) Date: Wed, 19 May 2004 19:08:57 +0200 Subject: [Thuban-devel] Extensions vs. Experimental In-Reply-To: <20040519143751.GF8387@intevation.de> (Jan-Oliver Wagner's message of "Wed, 19 May 2004 16:37:51 +0200") References: <20040519110348.GM716@finlandia.infodrom.north.de> <20040519143751.GF8387@intevation.de> Message-ID: Jan-Oliver Wagner writes: > The stuff that is incomplete or has still serious bugs > to solve go into Experimental. I think we should put the SVG export into Experimental too. While it works and is usable for some applications, there are some things that will need to be fixed and which might require incompatible changes. The format of the meta-data that Thuban adds will have to change, for instance, since the IDs are not valid XML IDs. IIRC there were some other problems that need fixing but most of them were on the Skencil side. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From joey at infodrom.org Mon May 24 18:26:41 2004 From: joey at infodrom.org (Martin Schulze) Date: Mon, 24 May 2004 18:26:41 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: References: <20040415182050.GH1655@finlandia.infodrom.north.de> <20040419113029.GA10000@intevation.de> <20040519144813.GX716@finlandia.infodrom.north.de> Message-ID: <20040524162641.GQ716@finlandia.infodrom.north.de> Bernhard Herzog wrote: > > BaseLayer.propertiesDialog of class PropertiesDialog, or rather one > > of the specialisations of it (i.e. Classifier or wmsPropertiesDialog). > > > > MainWindow.OpenLayerProperties would then contain code like > > > > if current_layer.has_properties(): > > name = ... > > dialog = self.get_open_dialog(name) > > if dialog is None: > > dialog = current_layer.properties_dialog(..) > > self.add_dialog(name, dialog) > > dialog.Show() > > else > > dialog.Raise() > > No. The code outside of Thuban.UI should not depend on the GUI. Hm, that means that we'll have to move the properties and information dialogs from Extensions/wms into Thuban/UI in the long-term. > I'd prefer a solution like the one used for the renderer extensions in > baserenderer.py. It basically means that there's a mapping between > layer classes and property dialog classes. This mapping should be in a > new module, I think, together with the GeneralPropertiesDialog class. > The OpenLayerProperties method would call a function in that module > which returns the dialog class for a given layer. Understood. Is the patch below and the two new files (test/test_layer_dialogs.py and Thuban/UI/layer_dialogs.py) what you want? Documentation will follow, of course. I've decided to implement layer_dialogs.py a bit more generic, so it can be used for show-table and information in addition to properties. Hope that's ok with you. Regards, Joey -- Ten years and still binary compatible. -- XFree86 -------------- next part -------------- A non-text attachment was scrubbed... Name: test_layer_dialogs.py Type: text/x-python Size: 742 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20040524/75333a45/test_layer_dialogs.py -------------- next part -------------- A non-text attachment was scrubbed... Name: layer_dialogs.py Type: text/x-python Size: 575 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20040524/75333a45/layer_dialogs.py -------------- next part -------------- Index: Extensions/wms/properties.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/wms/properties.py,v retrieving revision 1.1 diff -u -r1.1 properties.py --- Extensions/wms/properties.py 15 Apr 2004 16:14:51 -0000 1.1 +++ Extensions/wms/properties.py 24 May 2004 15:54:14 -0000 @@ -192,7 +192,7 @@ self.Close() -def OpenWMSProperties(parent, layer): +def OpenWMSProperties(parent, layer, group = None): """ Open or raise the WMS properties dialog """ Index: wms.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/wms/wms.py,v retrieving revision 1.9 diff -u -r1.9 wms.py --- wms.py 11 May 2004 22:34:49 -0000 1.9 +++ wms.py 24 May 2004 16:01:14 -0000 @@ -33,6 +33,7 @@ import Thuban.UI.baserenderer from layer import WMSLayer +from properties import OpenWMSProperties class WMSExtension(Extension): @@ -57,6 +58,7 @@ return () Thuban.UI.baserenderer.add_renderer_extension(WMSLayer, render_wms_layer) +Thuban.UI.layer_dialogs.add_layer_dialog('properties', WMSLayer, OpenWMSProperties) class SelectWMSServer(wxDialog): =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/classifier.py,v retrieving revision 1.65 diff -u -r1.65 classifier.py --- Thuban/UI/classifier.py 7 May 2004 20:20:43 -0000 1.65 +++ Thuban/UI/classifier.py 24 May 2004 15:54:47 -0000 @@ -38,6 +38,8 @@ from dialogs import NonModalNonParentDialog from messages import MAP_REPLACED +from Thuban.UI.layer_dialogs import add_layer_dialog + ID_CLASS_TABLE = 40011 @@ -1510,3 +1512,17 @@ def _OnLeftDClick(self, event): self.DoEdit() + +def OpenClassifier(parent, layer, group): + name = "layer_properties" + str(id(layer)) + dialog = parent.get_open_dialog(name) + + if dialog is None: + dialog = Classifier(parent, name, parent.Map(), layer, group) + parent.add_dialog(name, dialog) + dialog.Show(True) + else: + dialog.Raise() + +add_layer_dialog('properties', Layer, OpenClassifier) +add_layer_dialog('properties', RasterLayer, OpenClassifier) Index: mainwindow.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/mainwindow.py,v retrieving revision 1.132 diff -u -r1.132 mainwindow.py --- mainwindow.py 18 Apr 2004 20:37:01 -0000 1.132 +++ mainwindow.py 24 May 2004 16:09:52 -0000 @@ -53,6 +53,9 @@ import projdialog +from Extensions.wms.infodialog import wmsInfoDialog + +from Thuban.UI.layer_dialogs import open_properties_dialog class MainWindow(DockFrame): @@ -607,6 +610,10 @@ """Return true if a shape layer is currently selected""" return isinstance(self.current_layer(), Layer) + def has_selected_wms_layer(self): + """Return true if a WMS layer is currently selected""" + return 'capabilities' in dir(self.current_layer()) + def has_selected_shapes(self): """Return true if a shape is currently selected""" return self.canvas.HasSelectedShapes() @@ -705,14 +712,7 @@ self.OpenLayerProperties(layer) def OpenLayerProperties(self, layer, group = None): - name = "layer_properties" + str(id(layer)) - dialog = self.get_open_dialog(name) - - if dialog is None: - dialog = Classifier(self, name, self.Map(), layer, group) - self.add_dialog(name, dialog) - dialog.Show() - dialog.Raise() + open_properties_dialog (self, layer, group) def LayerJoinTable(self): layer = self.canvas.SelectedLayer() @@ -1020,6 +1020,11 @@ """Return true if a shape layer is selected in the context""" return context.mainwindow.has_selected_shape_layer() +def _has_selected_wms_or_shape_layer(context): + """Return true if a WMS layer is selected in the context""" + return (context.mainwindow.has_selected_shape_layer() + or context.mainwindow.has_selected_wms_layer()) + def _has_selected_shapes(context): """Return true if a layer is selected in the context""" return context.mainwindow.has_selected_shapes() @@ -1156,7 +1161,7 @@ sensitive = _has_selected_layer) _method_command("layer_show_table", _("Show Ta&ble"), "LayerShowTable", helptext = _("Show the selected layer's table"), - sensitive = _has_selected_shape_layer) + sensitive = _has_selected_wms_or_shape_layer) _method_command("layer_properties", _("&Properties..."), "LayerEditProperties", sensitive = _has_selected_layer, helptext = _("Edit the properties of the selected layer")) From jan at intevation.de Tue May 25 18:18:09 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Tue, 25 May 2004 18:18:09 +0200 Subject: Improved PostGIS-Interface In-Reply-To: <20040503143735.GA22916@intevation.de> References: <11c.2e86a1c8.2dc3b8c2@aol.com> <20040503143735.GA22916@intevation.de> Message-ID: <20040525161809.GA25241@intevation.de> Hello Jens, have you had contact with the psychopg people meanwhile? I just added a link to your posting on http://thuban.intevation.org/roadmap.html, so people interested in this can more easily find it. BTW: Have you used the profiling extension of Thuban to analyse the performance increase? Best Jan On Mon, May 03, 2004 at 04:37:35PM +0200, Frank Koormann wrote: > thank you very much for your work on the postgis interface. I discussed > your post briefly with Bernhard (H.), but we haven't had the time to > look into it deeply. One thought: > > * JensMattke at aol.com [040430 16:12]: > > So I decided to rewrite the postgisdb.py and wellknowntext.py files using > > a binary cursor. Unfortunately, it seems to me as if psycopg is unable to > > read 'normal data' (integer, double, text...) as a binary cursor. Trying > > that, always killed the python-interpreter. > > Did you contact the psycopg people to elaborate this? Maybe a bug in in > there? > > However, in your test setting even a speed up by four times seems to be > a very big step forward :) -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From bh at intevation.de Thu May 27 12:12:23 2004 From: bh at intevation.de (Bernhard Herzog) Date: Thu, 27 May 2004 12:12:23 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources References: <20040415182050.GH1655@finlandia.infodrom.north.de> <20040419113029.GA10000@intevation.de> <20040519144813.GX716@finlandia.infodrom.north.de> <20040524162641.GQ716@finlandia.infodrom.north.de> Message-ID: Martin Schulze writes: > Bernhard Herzog wrote: >> No. The code outside of Thuban.UI should not depend on the GUI. > > Hm, that means that we'll have to move the properties and information > dialogs from Extensions/wms into Thuban/UI in the long-term. Well, I should have phrased that perhaps a bit more strictly: The code under Thuban but outside of Thuban.UI should not depend on Thuban.UI. Extensions are a different matter. How they are organized is up to each extension more or less, depending mostly on the maturity of the extension. It's a good idea in general to keep GUI code separate from the application logic so in Extensions the GUI and logic should at least be in separate modules, but for very small or experimental extensions it's often not a problem to mix them. >> I'd prefer a solution like the one used for the renderer extensions in >> baserenderer.py. It basically means that there's a mapping between >> layer classes and property dialog classes. This mapping should be in a >> new module, I think, together with the GeneralPropertiesDialog class. >> The OpenLayerProperties method would call a function in that module >> which returns the dialog class for a given layer. > > Understood. > > Is the patch below and the two new files (test/test_layer_dialogs.py > and Thuban/UI/layer_dialogs.py) what you want? Not quite. See below, especially my comment on open_properties_dialog. [2. text/x-python; test_layer_dialogs.py] [...] > class TestLayerDialogs(unittest.TestCase): > > def test_layer_dialogs(self): > > class MyLayer(BaseLayer): > pass > > my_class = MyLayer("test") Why "my_class"? It's not a class. [3. text/x-python; layer_dialogs.py] > def open_properties_dialog(parent, layer, group): > for cls, func in _layer_dialogs['properties']: > if isinstance(layer, cls): > func(parent, layer, group) > return > raise NotImplementedError This function should return the class, not the already instantiated dialog. More precisely, the return value should be an object that when called with name, parent and layer creates the dialog and returns it. If there is not dialog class available for a given layer, the function should return None. Also, the function shouldn't be called open_properties_dialog then, but perhaps get_layer_properties_dialog instead. The logic that determines whether the dialog is already shown and either raises the existing one or creates a new one should be left in the mainwindow. Actually, it should be moved into its own mainwindow method as this logic has already been duplicated at least seven times in mainwindow.py, but that's for another patch. > Index: mainwindow.py > =================================================================== > RCS file: /thubanrepository/thuban/Thuban/UI/mainwindow.py,v > retrieving revision 1.132 > diff -u -r1.132 mainwindow.py [...] > @@ -607,6 +610,10 @@ > """Return true if a shape layer is currently selected""" > return isinstance(self.current_layer(), Layer) > > + def has_selected_wms_layer(self): > + """Return true if a WMS layer is currently selected""" > + return 'capabilities' in dir(self.current_layer()) This is specific for one extension. Such code should not be in the Thuban core, i.e. the code in Thuban/. Also, you use it to determine whether the sensitivity of the layer_show_table command, which AFAICT doesn't make sense for WMS layers. If that's a bug and you wanted to use it for the sensitivity of the layer_properties command, then it's better to have a method that returns whether a dialog can be opened for the currently selected layer, i.e. whether get_layer_properties_dialog returns None or not. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Fri May 28 19:28:03 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 28 May 2004 19:28:03 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib MANIFEST.in,NONE,1.1 Message-ID: <20040528172803.4E59713BEB@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv10894/libraries/pyshapelib Added Files: MANIFEST.in Log Message: New. Define which files belong into a source distribution --- NEW FILE: MANIFEST.in --- include README COPYING ChangeLog NEWS include *.i *.c *.py *.h include MANIFEST.in # prune the references to the shapelib files which are in either .. or # ../shapelib. These are pulled in by distutils because they're # referenced by the Extension objects prune .. From cvs at intevation.de Fri May 28 19:28:26 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 28 May 2004 19:28:26 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib NEWS,1.2,1.3 Message-ID: <20040528172826.2365113BEB@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv10919/libraries/pyshapelib Modified Files: NEWS Log Message: Also mention the new (compared to 0.2) setup.py Index: NEWS =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/NEWS,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- NEWS 17 May 2004 15:50:41 -0000 1.2 +++ NEWS 28 May 2004 17:28:24 -0000 1.3 @@ -8,6 +8,8 @@ be a starting point. This feature is used in Thuban which could be used as an example. + * distutils based build and install script, setup.py + Module dbflib: * dbf objects now have a method commit if compiled with shapelib newer From cvs at intevation.de Fri May 28 19:29:00 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 28 May 2004 19:29:00 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib setup.py,1.2,1.3 Message-ID: <20040528172900.0813A13BEB@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv10938/libraries/pyshapelib Modified Files: setup.py Log Message: * setup.py: Determine shp_dir correctly when run with bdist_rpm (dbf_macros): Remove a debug print Index: setup.py =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/setup.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- setup.py 17 May 2004 15:47:57 -0000 1.2 +++ setup.py 28 May 2004 17:28:57 -0000 1.3 @@ -1,5 +1,6 @@ import os +import sys from distutils.core import setup, Extension from distutils.util import convert_path @@ -11,16 +12,23 @@ # 2. Built in the Thuban source tree where ../shapelib/ relative to the # directory containing this setup.py contains (the relevant parts of) # shapelib +# +# 3. Binary build with e.g. bdist_rpm. This takes place deep in the +# build directory. # os.path expects filenames in OS-specific form so we have to construct # the files with os.path functions. distutils, OTOH, uses posix-style # filenames exclusively, so we use posix conventions when making # filenames for distutils. -for shp_dir in ["..", "../shapelib"]: - if os.path.exists(os.path.join(convert_path(shp_dir), "shpopen.c")): +for shp_dir in ["..", "../shapelib", "../../../../../../shapelib"]: + if (os.path.isdir(convert_path(shp_dir)) + and os.path.exists(os.path.join(convert_path(shp_dir), "shpopen.c"))): # shp_dir contains shpopen.c, so assume it's the directory with # the shapefile library to use break +else: + print >>sys.stderr, "no shapelib directory found" + sys.exit(1) def dbf_macros(): """Return the macros to define when compiling the dbflib wrapper. @@ -34,7 +42,6 @@ f = open(convert_path(shp_dir + "/shapefil.h")) contents = f.read() f.close() - print contents.find("DBFUpdateHeader") if contents.find("DBFUpdateHeader") >= 0: return [("HAVE_UPDATE_HEADER", "1")] else: From cvs at intevation.de Fri May 28 19:29:18 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 28 May 2004 19:29:18 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib ChangeLog,1.4,1.5 Message-ID: <20040528172918.22EC413BEB@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv10949/libraries/pyshapelib Modified Files: ChangeLog Log Message: update ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/ChangeLog,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ChangeLog 17 May 2004 15:48:53 -0000 1.4 +++ ChangeLog 28 May 2004 17:29:16 -0000 1.5 @@ -1,3 +1,13 @@ +2004-05-28 Bernhard Herzog + + * setup.py: Determine shp_dir correctly when run with bdist_rpm + (dbf_macros): Remove a debug print + + * NEWS: Also mention the new (compared to 0.2) setup.py + + * MANIFEST.in: New. Define which files belong into a source + distribution + 2004-05-17 Bernhard Herzog * README: Update for new release From cvs at intevation.de Fri May 28 19:29:32 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 28 May 2004 19:29:32 +0200 (CEST) Subject: bh: thuban/Thuban/UI baserenderer.py,1.9,1.10 Message-ID: <20040528172932.8F14613BEB@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv10965/Thuban/UI Modified Files: baserenderer.py Log Message: Fix some typos. Index: baserenderer.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/baserenderer.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- baserenderer.py 11 Nov 2003 18:16:20 -0000 1.9 +++ baserenderer.py 28 May 2004 17:29:30 -0000 1.10 @@ -1,4 +1,4 @@ -# Copyright (c) 2001, 2002, 2003 by Intevation GmbH +# Copyright (c) 2001, 2002, 2003, 2004 by Intevation GmbH # Authors: # Bernhard Herzog # Jonathan Coles @@ -42,7 +42,7 @@ # (layer_class, draw_function) pairs. If the renderer has to draw a # non-builtin layer type, i.e. a layer that is not a subclass of Layer # or RasterLayer, it iterates through that list, tests whether the layer -# to be drawin is an instance of layer_class and if so calls +# to be drawn is an instance of layer_class and if so calls # draw_function with the renderer and the layer as arguments. Since # drawing is done incrementally, the draw_function should return an # iterable. The easiest way is to simply implement the draw_function as @@ -64,7 +64,7 @@ function should return an iterable. The easiest way is to simply implement the draw_function as a generator and to yield True in suitable places, or to return the empty tuple if it's not possible - to do the rendering in incrementally. + to do the rendering incrementally. """ _renderer_extensions.append((layer_class, function)) From cvs at intevation.de Fri May 28 19:29:32 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 28 May 2004 19:29:32 +0200 (CEST) Subject: bh: thuban ChangeLog,1.653,1.654 Message-ID: <20040528172932.E2B5213BEE@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv10965 Modified Files: ChangeLog Log Message: Fix some typos. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.653 retrieving revision 1.654 diff -u -d -r1.653 -r1.654 --- ChangeLog 18 May 2004 21:10:33 -0000 1.653 +++ ChangeLog 28 May 2004 17:29:30 -0000 1.654 @@ -1,3 +1,7 @@ +2004-05-28 Bernhard Herzog + + * Thuban/UI/baserenderer.py: Fix some typos. + 2004-05-18 Jan-Oliver Wagner * Extensions/gns2shp/gns2shp.py (gns2shp): Fixed a bug From cvs at intevation.de Fri May 28 21:07:08 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 28 May 2004 21:07:08 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib NEWS,1.3,1.4 Message-ID: <20040528190708.4A2B913B80@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv11912/libraries/pyshapelib Modified Files: NEWS Log Message: Update the date of the actual release of 0.3 Index: NEWS =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/NEWS,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- NEWS 28 May 2004 17:28:24 -0000 1.3 +++ NEWS 28 May 2004 19:07:06 -0000 1.4 @@ -1,4 +1,4 @@ -pyshapelib 0.3 (2004-05-17) +pyshapelib 0.3 (2004-05-28) =========================== * New module shptree. It's a simple wrapper for shapelib's quadtree. From cvs at intevation.de Fri May 28 21:07:20 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 28 May 2004 21:07:20 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib README,1.2,1.3 Message-ID: <20040528190720.3FDD713B80@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv11937/libraries/pyshapelib Modified Files: README Log Message: Flesh out the some more. Correct the shapelib requirements. Index: README =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/README,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- README 17 May 2004 15:51:05 -0000 1.2 +++ README 28 May 2004 19:07:18 -0000 1.3 @@ -17,13 +17,16 @@ wrappers of C and C++ libraries for a variety of scripting languages. It's homepage is http://www.swig.org. +The bindings themselves don't have a homepage at the moment, but the +source tarballs/zip files can be downloaded from +http://ftp.intevation.de/users/bh/pyshapelib/ Requirements ------------ -To compile the bindings, you need shapelib 1.2.8 or newer. Older -versions may or may not work; nobody has tested that. +To compile the bindings, you need shapelib 1.2.9 or newer and Python 2.0 +or newer. SWIG is not required. The files generated by SWIG are contained in the archive. If you modify shapelib.i or dbflib.i and need to recreate the @@ -79,3 +82,17 @@ there's a simple demo/test script called pytest.py. The change history is recorded in NEWS and in detail in ChangeLog. + + +Contact Information +------------------- + +pyshapelib is currently being developed as part of the interactive +viewer for geographic data Thuban, so the best way to reach the +developers is to post on the Thuban mailing lists. + +Thuban: + http://thuban.intevation.org/ + +Thuban mailing lists: + http://thuban.intevation.org/mailinglist.html From cvs at intevation.de Fri May 28 21:07:29 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 28 May 2004 21:07:29 +0200 (CEST) Subject: bh: thuban/libraries/pyshapelib ChangeLog,1.5,1.6 Message-ID: <20040528190729.2A0C513B80@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/libraries/pyshapelib In directory doto:/tmp/cvs-serv11949/libraries/pyshapelib Modified Files: ChangeLog Log Message: update ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/libraries/pyshapelib/ChangeLog,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ChangeLog 28 May 2004 17:29:16 -0000 1.5 +++ ChangeLog 28 May 2004 19:07:27 -0000 1.6 @@ -1,5 +1,12 @@ 2004-05-28 Bernhard Herzog + * README: Flesh out the some more. Correct the shapelib + requirements. + + * NEWS: Update the date of the actual release of 0.3 + +2004-05-28 Bernhard Herzog + * setup.py: Determine shp_dir correctly when run with bdist_rpm (dbf_macros): Remove a debug print From bh at intevation.de Fri May 28 21:15:09 2004 From: bh at intevation.de (Bernhard Herzog) Date: Fri, 28 May 2004 21:15:09 +0200 Subject: PyShapelib In-Reply-To: <20040504155556.GA28014@intevation.de> (Bernhard Herzog's message of "Tue, 4 May 2004 17:55:56 +0200") References: <6.1.0.6.2.20040429113533.01dcd3c8@hobu.mail.iastate.edu> <20040504155556.GA28014@intevation.de> Message-ID: Bernhard Herzog writes: [shapelib bindings] > 1. We make a new release in the next few weeks. The new version is available now: http://ftp.intevation.de/users/bh/pyshapelib/pyshapelib-0.3.tar.gz or http://ftp.intevation.de/users/bh/pyshapelib/pyshapelib-0.3.zip Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From joey at infodrom.org Sun May 30 18:26:36 2004 From: joey at infodrom.org (Martin Schulze) Date: Sun, 30 May 2004 18:26:36 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: References: <20040415182050.GH1655@finlandia.infodrom.north.de> <20040419113029.GA10000@intevation.de> <20040519144813.GX716@finlandia.infodrom.north.de> <20040524162641.GQ716@finlandia.infodrom.north.de> Message-ID: <20040530162635.GA20524@finlandia.infodrom.north.de> Moin! Bernhard Herzog wrote: > [2. text/x-python; test_layer_dialogs.py] > [...] > > class TestLayerDialogs(unittest.TestCase): > > > > def test_layer_dialogs(self): > > > > class MyLayer(BaseLayer): > > pass > > > > my_class = MyLayer("test") > > Why "my_class"? It's not a class. Whoops, corrected to my_instance. > [3. text/x-python; layer_dialogs.py] > > def open_properties_dialog(parent, layer, group): > > for cls, func in _layer_dialogs['properties']: > > if isinstance(layer, cls): > > func(parent, layer, group) > > return > > raise NotImplementedError > > This function should return the class, not the already instantiated > dialog. More precisely, the return value should be an object that when > called with name, parent and layer creates the dialog and returns it. > If there is not dialog class available for a given layer, the function > should return None. > > Also, the function shouldn't be called open_properties_dialog then, but > perhaps get_layer_properties_dialog instead. What about this one instead? def get_layer_properties_dialog(layer): for cls, func in _layer_dialogs['properties']: if isinstance(layer, cls): return func return None > The logic that determines whether the dialog is already shown and either > raises the existing one or creates a new one should be left in the > mainwindow. Actually, it should be moved into its own mainwindow method > as this logic has already been duplicated at least seven times in > mainwindow.py, but that's for another patch. That would require a global logic for naming windows/dialogs. We may also need some sort of registration for calculation functions. Something like def OpenOrRaiseDialog(self, type, layer, group=None): # type one of [layer,properties,information] name = self.calculate_dialog_name(...) dialog = self.get_open_dialog(name) if dialog is None: open_func = get_layer_properties_dialog(layer) if open_func is None: return None dialog = open_func(self, layer, group) parent.add_dialog(name, dialog) dialog.Show(True) else: dialog.Raise() Since add_dialog/get_open_dialog are only used in mainwindow (and in the WMS extension), this should not be too difficult, I guess. > > Index: mainwindow.py > > =================================================================== > > RCS file: /thubanrepository/thuban/Thuban/UI/mainwindow.py,v > > retrieving revision 1.132 > > diff -u -r1.132 mainwindow.py > [...] > > @@ -607,6 +610,10 @@ > > """Return true if a shape layer is currently selected""" > > return isinstance(self.current_layer(), Layer) > > > > + def has_selected_wms_layer(self): > > + """Return true if a WMS layer is currently selected""" > > + return 'capabilities' in dir(self.current_layer()) > > This is specific for one extension. Such code should not be in the > Thuban core, i.e. the code in Thuban/. Also, you use it to determine > whether the sensitivity of the layer_show_table command, which AFAICT > doesn't make sense for WMS layers. If that's a bug and you wanted to > use it for the sensitivity of the layer_properties command, then it's > better to have a method that returns whether a dialog can be opened for > the currently selected layer, i.e. whether get_layer_properties_dialog > returns None or not. Whoops, too much information for you... I should have removed that part as well, but forgot it apparently. I had hooked the wms information dialog to the "Show Table" menu item. Please ignore it for the moment, we will probably handle show_table and information similar to the properties dialog. Apart from that, this method is executed quite often. We would probably create a reasonable delay if it would be implemented that way. In order to avoid this, I propose a hierarchical data structure for layer_dialogs.py (attached). I've also added a simple function has_layer_dialog() that can be called from the menu support functions. Regards, Joey -- Of course, I didn't mean that, which is why I didn't say it. What I meant to say, I said. -- Thomas Bushnell -------------- next part -------------- A non-text attachment was scrubbed... Name: layer_dialogs.py Type: text/x-python Size: 675 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20040530/eec30e05/layer_dialogs.py