From thuban-bugs at intevation.de Fri Feb 4 18:52:17 2005 From: thuban-bugs at intevation.de (Request Tracker) Date: Fri, 4 Feb 2005 18:52:17 +0100 (CET) Subject: [bug #2966] (thuban) Crash on full map extent with postgis layer Message-ID: <20050204175217.B1437102BE0@lists.intevation.de> this bug's URL: http://intevation.de/rt/webrt?serial_num=2966 ------------------------------------------------------------------------- Subject: Crash on full map extent with postgis layer Operating System: GNU/Linux, Debian sarge+unstable debiangis Thuban version: 1.0.0, 1.0.0-1 .deb wxPython version: other, libwxgtk2.4-python 2.4.2.6 .deb Python version: other, 2.3.4-4 .deb PySQLite version: other, python-sqlite 1.0.1-1 .deb SQLite version: other, 2.8.15-3 .deb GDAL version: 1.2.5, libgdal1 1.2.5-1 .deb proj version: other, 4.4.9-1 .deb (Unhandled exception thrown: (approx translation)) Une exception non gérée a été déclenchée: ERROR: current transaction is aborted, commands ignored until end of transaction block SELECT extent("wkb_geometry") FROM "prov_ab"; (veuillez faire un rapport à l'adresse http://thuban.intevation.org/bugtracker.html) (Please submit bug report at:) Traceback (most recent call last): File "/usr/lib/thuban/Thuban/UI/mainwindow.py", line 282, in invoke_command command.Execute(self.Context()) File "/usr/lib/thuban/Thuban/UI/command.py", line 121, in Execute apply(self.function, (context,) + self.args + args, kw) File "/usr/lib/thuban/Thuban/UI/mainwindow.py", line 946, in call_method apply(getattr(context.mainwindow, methodname), args) File "/usr/lib/thuban/Thuban/UI/mainwindow.py", line 851, in FullExtent self.canvas.FitMapToWindow() File "/usr/lib/thuban/Thuban/UI/viewport.py", line 454, in FitMapToWindow bbox = self.map.ProjectedBoundingBox() File "/usr/lib/thuban/Thuban/Model/map.py", line 209, in ProjectedBoundingBox bbox = self.BoundingBox() File "/usr/lib/thuban/Thuban/Model/map.py", line 188, in BoundingBox bbox = layer.LatLongBoundingBox() File "/usr/lib/thuban/Thuban/Model/layer.py", line 168, in LatLongBoundingBox bbox = self.BoundingBox() File "/usr/lib/thuban/Thuban/Model/layer.py", line 161, in BoundingBox return self.store.BoundingBox() File "/usr/lib/thuban/Thuban/Model/postgisdb.py", line 425, in BoundingBox cursor.execute("SELECT extent(%s) FROM %s;" ProgrammingError: ERROR: current transaction is aborted, commands ignored until end of transaction block SELECT extent("wkb_geometry") FROM "prov_ab"; -------------------------------------------- Managed by Request Tracker From cvs at intevation.de Sun Feb 6 17:47:37 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Sun, 6 Feb 2005 17:47:37 +0100 (CET) Subject: joey: thuban/Extensions/wms infodialog.py,1.2,1.3 Message-ID: <20050206164737.07CAA102C26@lists.intevation.de> Author: joey Update of /thubanrepository/thuban/Extensions/wms In directory doto:/tmp/cvs-serv25075/Extensions/wms Modified Files: infodialog.py Log Message: Adjusted the arguments of the contstructor to fit the global scheme Index: infodialog.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/wms/infodialog.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- infodialog.py 11 Apr 2004 18:15:33 -0000 1.2 +++ infodialog.py 6 Feb 2005 16:47:34 -0000 1.3 @@ -48,10 +48,11 @@ This dialog will display the title of the WMS resource """ - def __init__(self, parent, name, title, layer): + def __init__(self, parent, name, layer, *args, **kw): """ Build the information dialog """ + title = _("WMS Information") ThubanFrame.__init__(self, parent, name, title) self.dialog_layout(self.calcText(layer)) From cvs at intevation.de Sun Feb 6 17:47:37 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Sun, 6 Feb 2005 17:47:37 +0100 (CET) Subject: joey: thuban ChangeLog,1.777,1.778 Message-ID: <20050206164737.0A4CB102C27@lists.intevation.de> Author: joey Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv25075 Modified Files: ChangeLog Log Message: Adjusted the arguments of the contstructor to fit the global scheme Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.777 retrieving revision 1.778 diff -u -d -r1.777 -r1.778 --- ChangeLog 31 Jan 2005 09:18:27 -0000 1.777 +++ ChangeLog 6 Feb 2005 16:47:34 -0000 1.778 @@ -1,3 +1,8 @@ +2005-02-06 Martin Schulze + + * Extensions/wms/infodialog.py (wmsInfoDialog.__init__): Adjusted + the arguments of the contstructor to fit the global scheme + 2005-01-31 Nina Hüffmeyer * Extensions/ogr/ogrdialog.py: Added class ogrdialog.py, which provides From thuban-bugs at intevation.de Mon Feb 7 09:49:15 2005 From: thuban-bugs at intevation.de (Request Tracker) Date: Mon, 7 Feb 2005 09:49:15 +0100 (CET) Subject: [bug #2971] (thuban) Re-scaling side bar. Message-ID: <20050207084915.23328102C12@lists.intevation.de> this bug's URL: http://intevation.de/rt/webrt?serial_num=2971 ------------------------------------------------------------------------- Subject: Re-scaling side bar. Operating System: MacOS, 10.3.7 Thuban version: 1.0.1, -3 Traceback (most recent call last): File "/Applications/Grass/Thuban 1.0.1.app/Contents/Resources/Python/site-packages/ Thuban/UI/dock.py", line 490, in _OnSashDragged AssertionError Did you compile Thuban yourself? If not, which binary package did you install (eg. where did you get it from)? Version Tracker -------------------------------------------- Managed by Request Tracker From cvs at intevation.de Mon Feb 7 14:46:55 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 7 Feb 2005 14:46:55 +0100 (CET) Subject: bernhard: thuban ChangeLog,1.778,1.779 Message-ID: <20050207134655.473B2102BD7@lists.intevation.de> Author: bernhard Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv10561 Modified Files: ChangeLog Log Message: * Thuban/UI/classifier.py (ClassGrid.DeleteSelectedRows): Enable translation for message string. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.778 retrieving revision 1.779 diff -u -d -r1.778 -r1.779 --- ChangeLog 6 Feb 2005 16:47:34 -0000 1.778 +++ ChangeLog 7 Feb 2005 13:46:53 -0000 1.779 @@ -1,3 +1,7 @@ +2005-02-07 Bernhard Reiter + * Thuban/UI/classifier.py (ClassGrid.DeleteSelectedRows): + Enable translation for message string. + 2005-02-06 Martin Schulze * Extensions/wms/infodialog.py (wmsInfoDialog.__init__): Adjusted From cvs at intevation.de Mon Feb 7 14:46:55 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 7 Feb 2005 14:46:55 +0100 (CET) Subject: bernhard: thuban/Thuban/UI classifier.py,1.70,1.71 Message-ID: <20050207134655.4D789102BDC@lists.intevation.de> Author: bernhard Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv10561/Thuban/UI Modified Files: classifier.py Log Message: * Thuban/UI/classifier.py (ClassGrid.DeleteSelectedRows): Enable translation for message string. Index: classifier.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/classifier.py,v retrieving revision 1.70 retrieving revision 1.71 diff -u -d -r1.70 -r1.71 --- classifier.py 27 Jan 2005 14:19:41 -0000 1.70 +++ classifier.py 7 Feb 2005 13:46:53 -0000 1.71 @@ -161,7 +161,7 @@ group = self.GetTable().GetClassGroup(sel[0]) if isinstance(group, ClassGroupDefault): wxMessageDialog(self, - "The Default group cannot be removed.", + _("The Default group cannot be removed."), style = wxOK | wxICON_EXCLAMATION).ShowModal() return From bernhard at intevation.de Mon Feb 7 14:49:34 2005 From: bernhard at intevation.de (Bernhard Reiter) Date: Mon, 7 Feb 2005 14:49:34 +0100 Subject: Test failure in test_raster_no_projection Message-ID: <20050207134934.GA4119@intevation.de> Before my checkin I noticed a failure when running the tests: python runtests.py test_baserenderer.TestBaseRenderer.test_raster_no_projection E ====================================================================== ERROR: test_baserenderer.TestBaseRenderer.test_raster_no_projection ---------------------------------------------------------------------- Traceback (most recent call last): File "/mobilehome/bernhard/hacking/thuban/root/thuban/test/test_baserenderer.py", line 286, in test_raster_no_projection renderer.render_map() File "/mobilehome/bernhard/hacking/thuban/root/thuban/Thuban/UI/baserenderer.py", line 165, in render_map for cont in self.render_map_incrementally(): File "/mobilehome/bernhard/hacking/thuban/root/thuban/Thuban/UI/baserenderer.py", line 197, in render_map_incrementally self.draw_raster_layer(layer) File "/mobilehome/bernhard/hacking/thuban/root/thuban/Thuban/UI/baserenderer.py", line 494, in draw_raster_layer data = (width, height, apply(ProjectRasterFile, project_params)) TypeError: function takes exactly 6 arguments (7 given) ---------------------------------------------------------------------- Ran 1 test in 0.860s -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050207/0ef19626/attachment.bin From bernhard at intevation.de Mon Feb 7 14:50:59 2005 From: bernhard at intevation.de (Bernhard Reiter) Date: Mon, 7 Feb 2005 14:50:59 +0100 Subject: Tests Verboseness Message-ID: <20050207135059.GB4119@intevation.de> When running all tests I can see a few extra messages. Usually automatic tests should not output anything. (The 'E' is from test_baserenderer.TestBaseRenderer.test_raster_no_projection.) python runtests.py .............E....................................................................................................................................SSSS.....................SSSS..........SSSS........................................SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS................................................................................................................SSS.....................................................FID: 32 [(-15.082174301147461, 66.277381896972656), (-15.026350021362305, 66.273391723632812)] ....features in bbox: Polygon((-22.78 63.96, -22.78 64.0, -22.72 64.0,-22.72 63.96, -22.78 63.96)) 2 .............. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050207/0172ed57/attachment.bin From bh at intevation.de Mon Feb 7 14:55:14 2005 From: bh at intevation.de (Bernhard Herzog) Date: Mon, 07 Feb 2005 14:55:14 +0100 Subject: Tests Verboseness In-Reply-To: <20050207135059.GB4119@intevation.de> (Bernhard Reiter's message of "Mon, 7 Feb 2005 14:50:59 +0100") References: <20050207135059.GB4119@intevation.de> Message-ID: Bernhard Reiter writes: > python runtests.py [...] > FID: > 32 > [(-15.082174301147461, 66.277381896972656), (-15.026350021362305, > 66.273391723632812)] > ....features in bbox: > Polygon((-22.78 63.96, -22.78 64.0, -22.72 64.0,-22.72 63.96, -22.78 > 63.96)) These extra message are debug messages from the ogr extension. Nina, can you take them out again, please? Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From bh at intevation.de Mon Feb 7 15:00:02 2005 From: bh at intevation.de (Bernhard Herzog) Date: Mon, 07 Feb 2005 15:00:02 +0100 Subject: Test failure in test_raster_no_projection In-Reply-To: <20050207134934.GA4119@intevation.de> (Bernhard Reiter's message of "Mon, 7 Feb 2005 14:49:34 +0100") References: <20050207134934.GA4119@intevation.de> Message-ID: Bernhard Reiter writes: > ====================================================================== > ERROR: test_baserenderer.TestBaseRenderer.test_raster_no_projection > ---------------------------------------------------------------------- [...] > data = (width, height, apply(ProjectRasterFile, project_params)) > TypeError: function takes exactly 6 arguments (7 given) Have you rebuilt the extension modules? This is most like due to a change in gdalwarp.cpp. After recompiling you should get a little farther, but the test probably will still fail. It fails for me, anyway, with an AssertionError: ====================================================================== FAIL: test_baserenderer.TestBaseRenderer.test_raster_no_projection ---------------------------------------------------------------------- Traceback (most recent call last): File "test_baserenderer.py", line 326, in test_raster_no_projection self.assertEquals(renderer.raster_data, (20,20,(raw_data, raw_mask))) File "/usr/lib/python2.2/unittest.py", line 286, in failUnlessEqual raise self.failureException, \ AssertionError: (20, 20, ('Rf\xe6Rf[...]\xe6Rf\xe6', None)) != (20, 20, ('Rf\xe6Rf[...]\x00\x00')) Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From bernhard at intevation.de Mon Feb 7 15:07:26 2005 From: bernhard at intevation.de (Bernhard Reiter) Date: Mon, 7 Feb 2005 15:07:26 +0100 Subject: Test failure in test_raster_no_projection In-Reply-To: References: <20050207134934.GA4119@intevation.de> Message-ID: <20050207140726.GC4119@intevation.de> On Mon, Feb 07, 2005 at 03:00:02PM +0100, Bernhard Herzog wrote: > Bernhard Reiter writes: > > > ====================================================================== > > ERROR: test_baserenderer.TestBaseRenderer.test_raster_no_projection > > ---------------------------------------------------------------------- > [...] > > data = (width, height, apply(ProjectRasterFile, project_params)) > > TypeError: function takes exactly 6 arguments (7 given) > > Have you rebuilt the extension modules? > This is most like due to a change in gdalwarp.cpp. Duh! > After recompiling you should get a little farther, but the test probably > will still fail. It fails for me, anyway, with an AssertionError: After recompilation it works for me. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050207/6d055cd1/attachment.bin From cvs at intevation.de Mon Feb 7 15:09:39 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 7 Feb 2005 15:09:39 +0100 (CET) Subject: bernhard: thuban/Thuban/UI classifier.py,1.64,1.64.2.1 Message-ID: <20050207140939.0F2C2100159@lists.intevation.de> Author: bernhard Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv10939/Thuban/UI Modified Files: Tag: thuban-1-0-branch classifier.py Log Message: * Thuban/UI/classifier.py (ClassGrid.DeleteSelectedRows): Enable translation for message string. Index: classifier.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/classifier.py,v retrieving revision 1.64 retrieving revision 1.64.2.1 diff -u -d -r1.64 -r1.64.2.1 --- classifier.py 1 Aug 2003 14:27:57 -0000 1.64 +++ classifier.py 7 Feb 2005 14:09:36 -0000 1.64.2.1 @@ -154,7 +154,7 @@ group = self.GetTable().GetClassGroup(sel[0]) if isinstance(group, ClassGroupDefault): wxMessageDialog(self, - "The Default group cannot be removed.", + _("The Default group cannot be removed."), style = wxOK | wxICON_EXCLAMATION).ShowModal() return From cvs at intevation.de Mon Feb 7 15:09:39 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 7 Feb 2005 15:09:39 +0100 (CET) Subject: bernhard: thuban ChangeLog,1.624.2.36,1.624.2.37 Message-ID: <20050207140939.14FA810015B@lists.intevation.de> Author: bernhard Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv10939 Modified Files: Tag: thuban-1-0-branch ChangeLog Log Message: * Thuban/UI/classifier.py (ClassGrid.DeleteSelectedRows): Enable translation for message string. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.624.2.36 retrieving revision 1.624.2.37 diff -u -d -r1.624.2.36 -r1.624.2.37 --- ChangeLog 25 Jan 2005 09:31:59 -0000 1.624.2.36 +++ ChangeLog 7 Feb 2005 14:09:36 -0000 1.624.2.37 @@ -1,3 +1,8 @@ +2005-02-07 Bernhard Reiter + + * Thuban/UI/classifier.py (ClassGrid.DeleteSelectedRows): + Enable translation for message string. + 2005-01-25 Jan-Oliver Wagner * test/postgissupport.py: Backport from HEAD: From bh at intevation.de Mon Feb 7 15:38:19 2005 From: bh at intevation.de (Bernhard Herzog) Date: Mon, 07 Feb 2005 15:38:19 +0100 Subject: Test failure in test_raster_no_projection In-Reply-To: <20050207140726.GC4119@intevation.de> (Bernhard Reiter's message of "Mon, 7 Feb 2005 15:07:26 +0100") References: <20050207134934.GA4119@intevation.de> <20050207140726.GC4119@intevation.de> Message-ID: Bernhard Reiter writes: > On Mon, Feb 07, 2005 at 03:00:02PM +0100, Bernhard Herzog wrote: >> After recompiling you should get a little farther, but the test probably >> will still fail. It fails for me, anyway, with an AssertionError: > > After recompilation it works for me. I should have recompiled, too :) Now it works for me as well. However, I had to modify gdalwarp.cpp a bit. My gcc (2.95.4) doesn't accept the syntax for macros with varargs used there. Current gdalwarp has this in line 138f: #define PYTHON_ERRF(n, str, ...) \ {if (str != NULL) PyErr_Format(n, str, ## __VA_ARGS__);} That's correct syntax for C99. This syntax is not supported by gcc 2.95.4, though it apparently is in more recent versions. In gcc 2.95, I can use this gcc-specific form instead: #define PYTHON_ERRF(n, str, args...) \ {if (str != NULL) PyErr_Format(n, str, ## args);} However, I don't think we should be using C99 or gcc-specific things at all, as it may cause portability issues. I don't know whether the Microsoft compiler accepts this, for instance (googling around suggests it doesn't). Also, gdalwarp.cpp is actually C++, and AFAICT variadic macros are not part of the C++ standard yet. I don't even think we need the PYTHON_ERRF in the first place. The (str != NULL) check will always be true AFAICT, as the str parameter is a string literal in all uses in gdalwarp. We might as well call PyErr_Format directly. While we're at it: the PYTHON_ERR macro doesn't seem to be used at all, so it should be removed. It doesn't even seem to be doing something useful. Jonathan, do you have time to fix this? Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Mon Feb 7 20:51:15 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 7 Feb 2005 20:51:15 +0100 (CET) Subject: jonathan: thuban/libraries/thuban gdalwarp.cpp,1.5,1.6 Message-ID: <20050207195115.BD41F102BF9@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban/libraries/thuban In directory doto:/tmp/cvs-serv16480/libraries/thuban Modified Files: gdalwarp.cpp Log Message: Removed unnecessary/unused macros. Index: gdalwarp.cpp =================================================================== RCS file: /thubanrepository/thuban/libraries/thuban/gdalwarp.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- gdalwarp.cpp 28 Jan 2005 19:10:07 -0000 1.5 +++ gdalwarp.cpp 7 Feb 2005 19:51:13 -0000 1.6 @@ -29,6 +29,9 @@ ****************************************************************************** * * $Log$ + * Revision 1.6 2005/02/07 19:51:13 jonathan + * Removed unnecessary/unused macros. + * * Revision 1.5 2005/01/28 19:10:07 jonathan * Recoded how the mask is packed into the bit array. * @@ -132,12 +135,6 @@ {const char *str = CPLGetLastErrorMsg(); \ str != NULL ? PyErr_SetString(x, str) : PyErr_SetString(x, "");} -#define PYTHON_ERR(n, str) \ - {if (str != NULL) PyErr_SetString(n, "");} - -#define PYTHON_ERRF(n, str, ...) \ - {if (str != NULL) PyErr_Format(n, str, ## __VA_ARGS__);} - #define LEAVE_NOW(e) { err = e; goto getOut; } #define OPTS_MASK 1 @@ -260,7 +257,7 @@ int nRasterYSize = ds->GetRasterYSize(); if ( ! (nRasterXSize > 0 && nRasterYSize > 0 )) { - PYTHON_ERRF(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "The dimensions (%ix%i) are invalid in %s", nRasterXSize, nRasterYSize, pszSrcFilename); return CE_Failure; @@ -273,7 +270,7 @@ *imgbuf = (unsigned char*)CPLMalloc(*imglen); if ( *imgbuf == NULL ) { - PYTHON_ERRF(PyExc_MemoryError, + PyErr_Format(PyExc_MemoryError, "The system does not have enough memory to project %s", pszSrcFilename); return CE_Failure; @@ -313,7 +310,7 @@ GDT_Byte, 3, 0); if (ret == CE_Failure) { - PYTHON_ERRF(PyExc_IOError, + PyErr_Format(PyExc_IOError, "An unknown error occured while reading band %i in %s", i, pszSrcFilename); break; @@ -337,7 +334,7 @@ if (pal == NULL) { - PYTHON_ERRF(PyExc_IOError, + PyErr_Format(PyExc_IOError, "Couldn't find a palette for palette-based image %s", pszSrcFilename); ret = CE_Failure; @@ -359,7 +356,7 @@ if (ret == CE_Failure) { - PYTHON_ERRF(PyExc_IOError, + PyErr_Format(PyExc_IOError, "An unknown error occured while reading band 1 in %s", pszSrcFilename); break; } @@ -404,7 +401,7 @@ if (ret == CE_Failure) { - PYTHON_ERRF(PyExc_IOError, + PyErr_Format(PyExc_IOError, "An unknown error occured while reading band 1 in %s", pszSrcFilename); break; @@ -423,7 +420,7 @@ break; default: - PYTHON_ERRF(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "Unsupported color interpretation '%s' in image %s", GDALGetColorInterpretationName( band->GetColorInterpretation()), @@ -435,7 +432,7 @@ } else { - PYTHON_ERRF(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "Unsupported number of raster bands (%i) in image %s\n", rasterCount, pszSrcFilename); @@ -667,7 +664,7 @@ if( pszTargetSRS != NULL && strlen(pszSourceSRS) == 0 ) { - PYTHON_ERRF(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "A target projection was specified, " "but there is no source projection in %s", pszSrcFilename ); LEAVE_NOW( 1 ); @@ -707,7 +704,7 @@ if( hDstDS == NULL ) { - PYTHON_ERRF(PyExc_IOError, + PyErr_Format(PyExc_IOError, "Error creating destination image for projecting %s", pszSrcFilename); LEAVE_NOW( CPLE_FileIO ); From cvs at intevation.de Mon Feb 7 20:51:15 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 7 Feb 2005 20:51:15 +0100 (CET) Subject: jonathan: thuban ChangeLog,1.779,1.780 Message-ID: <20050207195115.B787610015D@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv16480 Modified Files: ChangeLog Log Message: Removed unnecessary/unused macros. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.779 retrieving revision 1.780 diff -u -d -r1.779 -r1.780 --- ChangeLog 7 Feb 2005 13:46:53 -0000 1.779 +++ ChangeLog 7 Feb 2005 19:51:13 -0000 1.780 @@ -1,3 +1,7 @@ +2005-02-07 Jonathan Coles + * libraries/thuban/gdalwarp.cpp: Removed the macros PYTHON_ERR + and PYTHON_ERRF since they were no longer necessary. + 2005-02-07 Bernhard Reiter * Thuban/UI/classifier.py (ClassGrid.DeleteSelectedRows): Enable translation for message string. From jonathan at jpcoles.com Mon Feb 7 20:53:38 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Mon, 07 Feb 2005 14:53:38 -0500 Subject: Test failure in test_raster_no_projection In-Reply-To: References: <20050207134934.GA4119@intevation.de> <20050207140726.GC4119@intevation.de> Message-ID: <1107806018.3543.13.camel@localhost.localdomain> Am Montag, den 07.02.2005, 15:38 +0100 schrieb Bernhard Herzog: > I don't even think we need the PYTHON_ERRF in the first place. > While we're at it: the PYTHON_ERR macro doesn't seem to be used at all, > so it should be removed. i removed them both. --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== From dcalvelo at minag.gob.pe Tue Feb 8 05:46:14 2005 From: dcalvelo at minag.gob.pe (Daniel Calvelo Aros) Date: Mon, 7 Feb 2005 23:46:14 -0500 Subject: wx2.5 and wxproj.cpp segfault Message-ID: <20050208043514.M78968@minag.gob.pe> Hi all. I'm trying to work out the segfaults I get in wxproj when trying to port thuban to wx2.5. The story so far: - the segfault arises when trying to access the C++ object obtained from the Python repr of the object - I isolated the problematic code in wxproj.cpp - according to gdb and valgrind, the address given by wxPython's repr of the wxDC is not an allocated or known address I have tried to build my own debugging version of wxPython to dig deeper, suspecting some weirdness in the unicode version I have (Debian unstable: wxPython-2.5.3.2pre), but I have had no success to date. So, linuxian thubaneers, can anybody with a wx2.5 installed try the following? I attached a small archive that mimics the problematic code in wxproj.cpp; if I run the build_and_run.sh three-liner, I get some output, with coherent addresses for all objects and a segfault when trying to access from C++ the wxDC created in Python. This is precisely what happens in wxproj.cpp. Can you reproduce the problem? If so, I reckon the problem is somewhere between SWIG and its use by wxPython, far beyond my current knowledge. Google is of no use, and the only remotely related bug I found happened (once) in aMule and went so far unresolved. Cheers, Daniel. -- Daniel Calvelo Aros From dcalvelo at minag.gob.pe Tue Feb 8 05:49:03 2005 From: dcalvelo at minag.gob.pe (Daniel Calvelo Aros) Date: Mon, 7 Feb 2005 23:49:03 -0500 Subject: wx2.5 and wxproj.cpp segfault In-Reply-To: <20050208043514.M78968@minag.gob.pe> References: <20050208043514.M78968@minag.gob.pe> Message-ID: <20050208044748.M73871@minag.gob.pe> Ooops. Forgot the attachment. Daniel. -- Daniel Calvelo Aros ---------- Original Message ----------- From: "Daniel Calvelo Aros" To: thuban-devel at intevation.de Sent: Mon, 7 Feb 2005 23:46:14 -0500 Subject: wx2.5 and wxproj.cpp segfault > Hi all. > > I'm trying to work out the segfaults I get in wxproj when trying to port > thuban to wx2.5. > > The story so far: > > - the segfault arises when trying to access the C++ object obtained > from the Python repr of the object > > - I isolated the problematic code in wxproj.cpp > > - according to gdb and valgrind, the address given by wxPython's > repr of the wxDC is not an allocated or known address > > I have tried to build my own debugging version of wxPython to dig > deeper, suspecting some weirdness in the unicode version I have > (Debian unstable: wxPython-2.5.3.2pre), but I have had no success to > date. > > So, linuxian thubaneers, can anybody with a wx2.5 installed try the following? > I attached a small archive that mimics the problematic code in > wxproj.cpp; if I run the build_and_run.sh three-liner, I get some > output, with coherent addresses for all objects and a segfault when > trying to access from C++ the wxDC created in Python. This is > precisely what happens in wxproj.cpp. > > Can you reproduce the problem? If so, I reckon the problem is somewhere > between SWIG and its use by wxPython, far beyond my current > knowledge. Google is of no use, and the only remotely related bug I > found happened (once) in aMule and went so far unresolved. > > Cheers, > > Daniel. > > -- Daniel Calvelo Aros > > _______________________________________________ > Thuban-devel mailing list > Thuban-devel at intevation.de > https://intevation.de/mailman/listinfo/thuban-devel ------- End of Original Message ------- -------------- next part -------------- A non-text attachment was scrubbed... Name: wx_test.tgz Type: application/x-gzip Size: 1185 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050207/c027c155/wx_test.tgz From cvs at intevation.de Tue Feb 8 10:52:58 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 8 Feb 2005 10:52:58 +0100 (CET) Subject: nhueffme: thuban ChangeLog,1.780,1.781 Message-ID: <20050208095258.A2370102BFC@lists.intevation.de> Author: nhueffme Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv26858 Modified Files: ChangeLog Log Message: Changed the GUI. OGR support can now be accessed via the Map menu. Removed some print commands. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.780 retrieving revision 1.781 diff -u -d -r1.780 -r1.781 --- ChangeLog 7 Feb 2005 19:51:13 -0000 1.780 +++ ChangeLog 8 Feb 2005 09:52:56 -0000 1.781 @@ -1,3 +1,10 @@ +2005-02-08 Nina Hüffmeyer + + * Extensions/ogr/ogrshapes.py: Removed some print commands. + + * Extensions/ogr/ogrstart.py: Changed the GUI. OGR is no longer an + additional menu but appears as a possibility in the menu Map. + 2005-02-07 Jonathan Coles * libraries/thuban/gdalwarp.cpp: Removed the macros PYTHON_ERR and PYTHON_ERRF since they were no longer necessary. From cvs at intevation.de Tue Feb 8 10:52:58 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 8 Feb 2005 10:52:58 +0100 (CET) Subject: nhueffme: thuban/Extensions/ogr ogrdialog.py, 1.1, 1.2 ogrshapes.py, 1.4, 1.5 ogrstart.py, 1.3, 1.4 Message-ID: <20050208095258.AB926102C3C@lists.intevation.de> Author: nhueffme Update of /thubanrepository/thuban/Extensions/ogr In directory doto:/tmp/cvs-serv26858/Extensions/ogr Modified Files: ogrdialog.py ogrshapes.py ogrstart.py Log Message: Changed the GUI. OGR support can now be accessed via the Map menu. Removed some print commands. Index: ogrdialog.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/ogr/ogrdialog.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ogrdialog.py 31 Jan 2005 09:18:27 -0000 1.1 +++ ogrdialog.py 8 Feb 2005 09:52:56 -0000 1.2 @@ -186,7 +186,7 @@ datasource = ogr.Open(filename) self.layer = [] - for i in range(datasource.GetLayerCount()): + for i in range(datasource.GetLayerCount()): self.layer.append(datasource.GetLayer(i)) self.lb_drivers.Append(datasource.GetLayer(i).GetName()) if self.lb_drivers.GetCount() > 0: @@ -307,8 +307,14 @@ i = self.lb_connections.GetSelection() if i >= 0: self.selected_conn = self.dbconns[i] - self.tables = self.selected_conn.GeometryTables() - self.lb_tables.Set(self.tables) + connString = ("PG: host=%s dbname=%s user=%s port=%s" + %(self.selected_conn.host, self.selected_conn.dbname, + self.selected_conn.user, self.selected_conn.port)) + ds = ogr.Open(connString) + if ds: + for i in range(ds.GetLayerCount()): + self.tables.append(ds.GetLayer(i).GetName()) + self.lb_tables.Set(self.tables) def OnTableSelect(self, event): i = self.lb_tables.GetSelection() Index: ogrshapes.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/ogr/ogrshapes.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ogrshapes.py 26 Jan 2005 09:17:01 -0000 1.4 +++ ogrshapes.py 8 Feb 2005 09:52:56 -0000 1.5 @@ -26,7 +26,7 @@ from Thuban.Model.data import SHAPETYPE_POLYGON, SHAPETYPE_ARC, SHAPETYPE_POINT from Thuban.Model.data import RAW_PYTHON, RAW_SHAPEFILE, RAW_WKT -SHAPETYPE_UNKNOWN = "unknown" +SHAPETYPE_UNKNOWN = ogr.wkbUnknown def has_ogr_support(): """Return whether this Thuban instance supports ogr file formats @@ -54,15 +54,16 @@ def __init__(self, ogrlayer, shapeid): self.ogrlayer = ogrlayer + self.feature = self.ogrlayer.GetFeature(shapeid) self.shapeid = shapeid + self.geom = self.feature.GetGeometryRef() + self.shapetype = self.geom.GetGeometryType() def compute_bbox(self): """ Return the bounding box of the shape as a tuple (minx,miny,maxx,maxy) """ - shape = self.ogrlayer.GetFeature(self.shapeid) - geom = shape.GetGeometryRef() - minx, maxx, miny, maxy = geom.GetEnvelope() + minx, maxx, miny, maxy = self.geom.GetEnvelope() return (minx, miny, maxx, maxy) def ShapeID(self): @@ -70,39 +71,35 @@ def Points(self): """Return the coordinates of the shape as a list of lists of pairs""" - print "FID: %s" %(self.shapeid) shape = [] #spatialFilter = self.ogrlayer.GetSpatialFilter() - -# if spatialFilter is not None: - self.ogrlayer.SetSpatialFilter(None) - # feature = self.ogrlayer.GetFeature(self.shapeid) - # self.ogrlayer.SetSpatialFilter(spatialFilter) - # else: - feature = self.ogrlayer.GetFeature(self.shapeid) - - if feature is None: - print "feature is none.........................." - return shape.append([]) - geom = feature.GetGeometryRef() - if geom is None: - print "geom is none................................" + #if spatialFilter is not None: + #self.ogrlayer.SetSpatialFilter(None) + #feature = self.ogrlayer.GetFeature(self.shapeid) + #self.ogrlayer.SetSpatialFilter(spatialFilter) + #else: + #feature = self.ogrlayer.GetFeature(self.shapeid) + + #if feature is None: + # return shape.append([]) + #geom = feature.GetGeometryRef() + + if self.geom is None: return shape.append([]) # if geometry object is of type point or line - if geom.GetGeometryCount() == 0: + if self.geom.GetGeometryCount() == 0: points =[] - for point in range(geom.GetPointCount()): - x = geom.GetX(point) - y = geom.GetY(point) + for point in range(self.geom.GetPointCount()): + x = self.geom.GetX(point) + y = self.geom.GetY(point) points.append((x, y)) - print points return [points] # if geometry object is of type polygon or multipolygon - for i in range(geom.GetGeometryCount()): + for i in range(self.geom.GetGeometryCount()): points = [] - geometry = geom.GetGeometryRef(i) + geometry = self.geom.GetGeometryRef(i) # if geometry object is polygon if geometry.GetGeometryCount() == 0: for point in range(geometry.GetPointCount()): @@ -120,7 +117,6 @@ y = subgeom.GetY(point) points.append((x, y)) shape.append(points) - print shape return shape def RawData(self): @@ -131,6 +127,9 @@ """Return the ogrlayer object""" return self.ogrlayer + def ShapeType(self): + return self.shapetype + class OGRShapeStore: @@ -138,7 +137,7 @@ providing all methods Thuban needs. """ - def __init__(self, session, filename, layername): + def __init__(self, filename, layername, id_column = None): # Make the filename absolute. The filename will be # interpreted relative to that anyway, but when saving a # session we need to compare absolute paths and it's usually @@ -173,8 +172,8 @@ if self.shapetype is not ogr.wkbUnknown: self.shapetype = ogrlib_shapetypes[self.shapetype] #else: - # this should be ogr.wkbUnknown, but Thuban does not know how - # to handle an unknown shapetype (e.g. Session Tree) + # this should be ogr.wkbUnknown, but Thuban does not know how + # to handle an unknown shapetype (e.g. Session Tree) #self.shapetype = ogrlib_shapetypes[ogr.wkbPoint] def OGRLayer(self): @@ -223,10 +222,6 @@ ogrlayer = self.ogrlayer left, bottom, right, top = bbox - print "features in bbox: " - print ('Polygon((%s %s, %s %s, %s %s,%s %s, %s %s))' - %(left, bottom, left, top, right, top, - right, bottom, left, bottom)) # create a geometry which can be passed to the layer as spatial filter bboxpolygon = ogr.CreateGeometryFromWkt( ('Polygon((%s %s, %s %s, %s %s,%s %s, %s %s))' @@ -239,11 +234,12 @@ ogrlayer.ResetReading() #ogrlayer.SetSpatialFilterRect(left, bottom, right, top) ogrlayer.SetSpatialFilter(bboxpolygon) + numFeatures = ogrlayer.GetFeatureCount() - print numFeatures for feature in range(numFeatures): nextFeature = ogrlayer.GetNextFeature() yield cls(ogrlayer, nextFeature.GetFID()) + ogrlayer.SetSpatialFilter(None) bboxpolygon.Destroy() @@ -271,6 +267,9 @@ """Return None.""" return None + def Id_column(self): + """Return the id_column.""" + return self.id_column class OGRTable: @@ -483,6 +482,10 @@ if lay is not None: self.datasource.ReleaseResultSet(lay) return result + + def Id_column(self): + """Return the id_column.""" + return self.id_column class OGRColumn: Index: ogrstart.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/ogr/ogrstart.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ogrstart.py 26 Jan 2005 09:17:01 -0000 1.3 +++ ogrstart.py 8 Feb 2005 09:52:56 -0000 1.4 @@ -10,6 +10,7 @@ # $Id$ # Needed wx-toolkit classes +#from wxPython.wx import * from wxPython.wx import wxFileDialog, wxOPEN, wxMULTIPLE, wxID_OK, \ wxOK, wxICON_HAND @@ -26,6 +27,8 @@ from Extensions.ogr import ogrshapes, ogrdialog from Extensions.ogr.ogrdialog import ChooseOGRDBTableDialog +from Thuban.UI.menu import Menu + def open_with_ogr(context): '''Open a file supported by ogr. ''' @@ -49,7 +52,7 @@ layername = layerDlg.GetLayer() try: session = context.application.Session() - store = ogrshapes.OGRShapeStore(session, filename, layername) + store = ogrshapes.OGRShapeStore(filename, layername) session.AddShapeStore(store) except: # the layer couldn't be opened @@ -87,7 +90,7 @@ canvas = context.mainwindow.canvas map = canvas.Map() - + session = context.application.Session() dlg = ChooseOGRDBTableDialog(canvas, session) @@ -98,7 +101,7 @@ filename = ('PG: host=%s user=%s dbname=%s port=%s' %(dbconn.host, dbconn.user, dbconn.dbname, dbconn.port)) - store = ogrshapes.OGRShapeStore(session, filename, dbtable) + store = ogrshapes.OGRShapeStore(filename, dbtable) session.AddShapeStore(store) layer = Layer(dbtable, store) @@ -124,13 +127,17 @@ # See Thuban/UI/menu.py for the API of the Menu class from Thuban.UI.mainwindow import main_menu + +# find the map menu (create it a new if not found) +map_menu = main_menu.FindOrInsertMenu('map', _('Map')) +ogr_menu = Menu("ogr", _("Open layer via OGR"),[]) + + # create new commands and register them registry.Add(Command('open_ogr_files', 'Open an ogr-file', open_with_ogr, helptext = 'Open a file supported from ogr')) -# find the ogr menu (create it a new if not found) -ogr_menu = main_menu.FindOrInsertMenu('ogr', _('OGR')) -registry.Add(Command('select_file_format', 'Select a file format', +registry.Add(Command('select_file_format', 'Select a file format', select_file_format, helptext = "Select a file format supported from ogr")) @@ -139,7 +146,10 @@ helptext = "Open a layer from a database, e.g. PostGIS")) # finally bind the new command with an entry in the extensions menu -ogr_menu.InsertItem('open_ogr_files') +ogr_menu.InsertItem("open_ogr_files") ogr_menu.InsertItem('select_file_format') ogr_menu.InsertItem('open_db') + +# Add ogr menu to map menu +map_menu.InsertItem(ogr_menu, after = "rasterlayer_add") From cvs at intevation.de Tue Feb 8 10:52:58 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 8 Feb 2005 10:52:58 +0100 (CET) Subject: nhueffme: thuban/Extensions/ogr/test test_OGRShapestore.py, 1.4, 1.5 Message-ID: <20050208095258.B96F9102C3D@lists.intevation.de> Author: nhueffme Update of /thubanrepository/thuban/Extensions/ogr/test In directory doto:/tmp/cvs-serv26858/Extensions/ogr/test Modified Files: test_OGRShapestore.py Log Message: Changed the GUI. OGR support can now be accessed via the Map menu. Removed some print commands. Index: test_OGRShapestore.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/ogr/test/test_OGRShapestore.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- test_OGRShapestore.py 31 Jan 2005 09:18:27 -0000 1.4 +++ test_OGRShapestore.py 8 Feb 2005 09:52:56 -0000 1.5 @@ -52,15 +52,12 @@ imported. """ skip_if_no_ogr() - self.session = Session("Test Session") self.filename = os.path.join("..", "Data", "iceland","roads-line.shp") - self.store = OGRShapeStore(self.session, self.filename, "roads-line") + self.store = OGRShapeStore(self.filename, "roads-line") def tearDown(self): """Call self.session.Destroy() and reset self.session to None""" - self.session.Destroy() - self.session = None - self.store = None + self.store = None def test_shape_type(self): """Test OGRShapeStore.ShapeType() with arc shapes""" @@ -110,16 +107,13 @@ class TestOGRTable(unittest.TestCase, support.FloatComparisonMixin): def setUp(self): - """Initialize self.session""" - self.session = Session("Test Session") + """Initialize""" self.filename = os.path.join("..","Data", "iceland","roads-line.shp") - self.store = OGRShapeStore(self.session, self.filename, "roads-line") + self.store = OGRShapeStore(self.filename, "roads-line") self.table = self.store.Table() def tearDown(self): """Call self.session.Destroy() and reset self.session to None""" - self.session.Destroy() - self.session = None def test_Dependencies(self): """Test dependencies, which is always ()""" From cvs at intevation.de Tue Feb 8 21:25:24 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 8 Feb 2005 21:25:24 +0100 (CET) Subject: bh: thuban/Thuban/UI legend.py, 1.37, 1.38 dock.py, 1.15, 1.16 classifier.py, 1.71, 1.72 Message-ID: <20050208202524.BBA69102C4E@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv9432/Thuban/UI Modified Files: legend.py dock.py classifier.py Log Message: Compatibility with wxPython 2.5. The changes should make it work better with 2.5 while still keeping compatibility with 2.4. There are still problems with 2.5, though. * Thuban/UI/dock.py (DockableWindow.__CreateBorder): Pass the size of a spacer as a single item. * Thuban/UI/classifier.py (ClassGroupPropertiesCtrl): Derive only from wxControl * Thuban/UI/legend.py (LegendTree): When running with wxPython < 2.5, add an implementation of the GetFirstChild method that does not require the second parameter. (LegendTree.find_layer, LegendTree._OnMsgMapLayersAdded) (LegendTree._OnMsgMapLayersRemoved, LegendTree.DeleteAllItems) (LegendTree.DeleteChildren, LegendTree.__ShowHideLayer): Do not pass the second parameter to GetFirstChild Index: legend.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/legend.py,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- legend.py 18 Apr 2004 20:37:45 -0000 1.37 +++ legend.py 8 Feb 2005 20:25:22 -0000 1.38 @@ -1,4 +1,4 @@ -# Copyright (c) 2001, 2002, 2003 by Intevation GmbH +# Copyright (c) 2001, 2002, 2003, 2005 by Intevation GmbH # Authors: # Jonathan Coles # Frank Koormann @@ -15,6 +15,7 @@ import resource from wxPython.wx import * +import wxPython from Thuban.Model.layer import BaseLayer from Thuban.Model.map import Map @@ -284,7 +285,7 @@ def find_layer(self, layer): """Return the tree item for the layer""" root = self.GetRootItem() - id, cookie = self.GetFirstChild(root, 0) + id, cookie = self.GetFirstChild(root) while id.IsOk(): if self.GetPyData(id) is layer: return id @@ -487,7 +488,7 @@ # Build a dict with all layers known by the the tree as keys layers = {} root = self.GetRootItem() - id, cookie = self.GetFirstChild(root, 0) + id, cookie = self.GetFirstChild(root) while id.IsOk(): layers[self.GetPyData(id)] = 1 id, cookie = self.GetNextChild(root, cookie) @@ -506,7 +507,7 @@ layers = map.Layers() root = self.GetRootItem() - id, cookie = self.GetFirstChild(root, 0) + id, cookie = self.GetFirstChild(root) while id.IsOk(): if self.GetPyData(id) not in layers: self.__RemoveLayer(id) @@ -598,7 +599,7 @@ pid = self.GetRootItem() - id, cookie = self.GetFirstChild(pid, 123) + id, cookie = self.GetFirstChild(pid) while id.IsOk(): self.__RemoveLayer(id) id, cookie = self.GetNextChild(pid, cookie) @@ -636,7 +637,7 @@ self.Delete(id) def DeleteChildren(self, pid): - id, cookie = self.GetFirstChild(pid, 123) + id, cookie = self.GetFirstChild(pid) while id.IsOk(): self.availImgListIndices.append(self.GetItemImage(id)) id, cookie = self.GetNextChild(pid, cookie) @@ -692,12 +693,25 @@ self.__SetVisibilityStyle(visible, parent) - id, cookie = self.GetFirstChild(parent, 123) + id, cookie = self.GetFirstChild(parent) while id.IsOk(): self.__SetVisibilityStyle(visible, id) id, cookie = self.GetNextChild(parent, cookie) - + + # In wxPython 2.4 the GetFirstChild method has to be called with a + # second argument and in 2.5 it must not. Reading the code of + # wxPython 2.4 it seems that the second parameter was intended to be + # optional there but due to a bug in the C++ code it doesn't work + # and omitting the second argument leads to a segfault. To cope + # with this and to make the code usable with both 2.5 and 2.4 we + # overwrite the inherited method when running with 2.4 to provide a + # default value for the second argument. + if map(int, wxPython.__version__.split(".")[:2]) < [2, 5]: + def GetFirstChild(self, item): + return wxTreeCtrl.GetFirstChild(self, item, 0) + + class ScaleBarBitmap(wxBoxSizer): def __init__(self, parent, map, mainWindow): Index: dock.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/dock.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- dock.py 30 Jul 2003 15:43:28 -0000 1.15 +++ dock.py 8 Feb 2005 20:25:22 -0000 1.16 @@ -375,7 +375,7 @@ # if self.__orientation == wxLAYOUT_VERTICAL: headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0) - headerBox.Add(1, 5, 1, wxGROW) + headerBox.Add((1, 5), 1, wxGROW) headerBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0) headerBox.Add(closeX, 0, wxALIGN_RIGHT | wxLEFT, 4) else: Index: classifier.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/classifier.py,v retrieving revision 1.71 retrieving revision 1.72 diff -u -d -r1.71 -r1.72 --- classifier.py 7 Feb 2005 13:46:53 -0000 1.71 +++ classifier.py 8 Feb 2005 20:25:22 -0000 1.72 @@ -1407,7 +1407,7 @@ dc.DestroyClippingRegion() -class ClassGroupPropertiesCtrl(wxWindow, wxControl): +class ClassGroupPropertiesCtrl(wxControl): """A custom window and control that draw a preview of group properties and can open a dialog to modify the properties if the user double-clicks it. @@ -1415,8 +1415,7 @@ def __init__(self, parent, id, props, shapeType, size = wxDefaultSize, style = 0): - - wxWindow.__init__(self, parent, id, size = size, style = style) + wxControl.__init__(self, parent, id, size = size, style = style) self.parent = parent From cvs at intevation.de Tue Feb 8 21:25:24 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 8 Feb 2005 21:25:24 +0100 (CET) Subject: bh: thuban ChangeLog,1.781,1.782 Message-ID: <20050208202524.C73B4102C4F@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv9432 Modified Files: ChangeLog Log Message: Compatibility with wxPython 2.5. The changes should make it work better with 2.5 while still keeping compatibility with 2.4. There are still problems with 2.5, though. * Thuban/UI/dock.py (DockableWindow.__CreateBorder): Pass the size of a spacer as a single item. * Thuban/UI/classifier.py (ClassGroupPropertiesCtrl): Derive only from wxControl * Thuban/UI/legend.py (LegendTree): When running with wxPython < 2.5, add an implementation of the GetFirstChild method that does not require the second parameter. (LegendTree.find_layer, LegendTree._OnMsgMapLayersAdded) (LegendTree._OnMsgMapLayersRemoved, LegendTree.DeleteAllItems) (LegendTree.DeleteChildren, LegendTree.__ShowHideLayer): Do not pass the second parameter to GetFirstChild Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.781 retrieving revision 1.782 diff -u -d -r1.781 -r1.782 --- ChangeLog 8 Feb 2005 09:52:56 -0000 1.781 +++ ChangeLog 8 Feb 2005 20:25:22 -0000 1.782 @@ -1,3 +1,23 @@ +2005-02-08 Bernhard Herzog + + Compatibility with wxPython 2.5. The changes should make it work + better with 2.5 while still keeping compatibility with 2.4. There + are still problems with 2.5, though. + + * Thuban/UI/dock.py (DockableWindow.__CreateBorder): Pass the size + of a spacer as a single item. + + * Thuban/UI/classifier.py (ClassGroupPropertiesCtrl): Derive only + from wxControl + + * Thuban/UI/legend.py (LegendTree): When running with wxPython < + 2.5, add an implementation of the GetFirstChild method that does + not require the second parameter. + (LegendTree.find_layer, LegendTree._OnMsgMapLayersAdded) + (LegendTree._OnMsgMapLayersRemoved, LegendTree.DeleteAllItems) + (LegendTree.DeleteChildren, LegendTree.__ShowHideLayer): Do not + pass the second parameter to GetFirstChild + 2005-02-08 Nina Hüffmeyer * Extensions/ogr/ogrshapes.py: Removed some print commands. From cvs at intevation.de Tue Feb 8 21:34:31 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 8 Feb 2005 21:34:31 +0100 (CET) Subject: bh: thuban/Thuban/UI tableview.py, 1.34, 1.35 projdialog.py, 1.41, 1.42 dbdialog.py, 1.7, 1.8 classifier.py, 1.72, 1.73 Message-ID: <20050208203431.6322C102C4E@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv9618/Thuban/UI Modified Files: tableview.py projdialog.py dbdialog.py classifier.py Log Message: More wxPython 2.5 changes. This time taken from a patch from Daniel Calvelo Aros. * Thuban/UI/tableview.py (QueryTableFrame.__init__) (QueryTableFrame.__init__): Pass the size of a spacer as a single item. * Thuban/UI/projdialog.py (ProjFrame.build_dialog) (ProjFrame.build_dialog): Pass the size of a spacer as a single item. * Thuban/UI/dbdialog.py (ChooseDBTableDialog.__init__): Pass the size of a spacer as a single item. * Thuban/UI/classifier.py (Classifier.dialog_layout): Pass the size of a spacer as a single item. Index: tableview.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/tableview.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- tableview.py 22 Dec 2003 14:54:47 -0000 1.34 +++ tableview.py 8 Feb 2005 20:34:29 -0000 1.35 @@ -408,7 +408,7 @@ sizer.Add(self.combo_value, 1, wxEXPAND|wxALL, 4) sizer.Add(self.choice_action, 0, wxALL, 4) sizer.Add(button_query, 0, wxALL | wxALIGN_CENTER_VERTICAL, 4) - sizer.Add(40, 20, 0, wxALL, 4) + sizer.Add( (40, 20), 0, wxALL, 4) topBox.Add(sizer, 0, wxEXPAND|wxALL, 4) topBox.Add(self.grid, 1, wxEXPAND|wxALL, 0) @@ -416,7 +416,7 @@ sizer = wxBoxSizer(wxHORIZONTAL) sizer.Add(button_export, 0, wxALL, 4) sizer.Add(button_exportSel, 0, wxALL, 4) - sizer.Add(60, 20, 1, wxALL|wxEXPAND, 4) + sizer.Add( (60, 20), 1, wxALL|wxEXPAND, 4) sizer.Add(button_close, 0, wxALL|wxALIGN_RIGHT, 4) topBox.Add(sizer, 0, wxALL | wxEXPAND, 4) Index: projdialog.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/projdialog.py,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- projdialog.py 23 Dec 2004 15:10:41 -0000 1.41 +++ projdialog.py 8 Feb 2005 20:34:29 -0000 1.42 @@ -113,12 +113,12 @@ self.button_export = wxButton(self, ID_PROJ_EXPORT, _("Export...")) EVT_BUTTON(self, ID_PROJ_EXPORT, self._OnExport) buttons.Add(self.button_export, 1, wxALL|wxEXPAND, 4) - buttons.Add(20, 20, 0, wxEXPAND, 0) + buttons.Add( (20, 20), 0, wxEXPAND, 0) self.button_remove = wxButton(self, ID_PROJ_REMOVE, _("Remove")) EVT_BUTTON(self, ID_PROJ_REMOVE, self._OnRemove) buttons.Add(self.button_remove, 1, wxALL|wxEXPAND, 4) - buttons.Add(20, 20, 0, wxEXPAND, 0) + buttons.Add( (20, 20), 0, wxEXPAND, 0) label = wxStaticText(self, -1, _("Show EPSG:")) buttons.Add(label, 0, wxLEFT|wxRIGHT|wxTOP, 4) self.check_epsg = wxCheckBox(self, -1, _("Normal")) @@ -186,7 +186,7 @@ self.button_add = wxButton(self, ID_PROJ_ADDTOLIST, _("Add to List")) EVT_BUTTON(self, ID_PROJ_ADDTOLIST, self._OnAddToList) buttons.Add(self.button_add, 0, wxEXPAND|wxALL, 4) - buttons.Add(20, 20, 0, wxEXPAND, 0) + buttons.Add( (20, 20), 0, wxEXPAND, 0) self.button_save = wxButton(self, ID_PROJ_SAVE,_("Update")) EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave) buttons.Add(self.button_save, 0, wxEXPAND|wxALL|wxALIGN_BOTTOM, 4) Index: dbdialog.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/dbdialog.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- dbdialog.py 11 Mar 2004 21:04:30 -0000 1.7 +++ dbdialog.py 8 Feb 2005 20:34:29 -0000 1.8 @@ -70,12 +70,12 @@ # The button box between the connections list box and the table # list box buttons = wxFlexGridSizer(3, 1, 0, 0) - buttons.Add(20, 80, 0, wxEXPAND, 0) + buttons.Add( (20, 80), 0, wxEXPAND, 0) retrieve_button = wxButton(self, ID_DBCHOOSE_RETRIEVE, _("Retrieve")) EVT_BUTTON(self, ID_DBCHOOSE_RETRIEVE, self.OnRetrieve) buttons.Add(retrieve_button, 0, wxALL |wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4) - buttons.Add(20, 80, 0, wxEXPAND, 0) + buttons.Add( (20, 80), 0, wxEXPAND, 0) main_sizer.Add(buttons, 0, wxEXPAND, 0) # The list box with the tables Index: classifier.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/classifier.py,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -r1.72 -r1.73 --- classifier.py 8 Feb 2005 20:25:22 -0000 1.72 +++ classifier.py 8 Feb 2005 20:34:29 -0000 1.73 @@ -790,7 +790,7 @@ controlButtonBox.Add(button_moveup, 0, wxGROW|wxALL, 4) controlButtonBox.Add(button_movedown, 0, wxGROW|wxALL, 4) controlButtonBox.Add(button_edit, 0, wxGROW|wxALL, 4) - controlButtonBox.Add(60, 20, 0, wxGROW|wxALL|wxALIGN_BOTTOM, 4) + controlButtonBox.Add( (60, 20), 0, wxGROW|wxALL|wxALIGN_BOTTOM, 4) controlButtonBox.Add(button_remove, 0, wxGROW|wxALL|wxALIGN_BOTTOM, 4) From cvs at intevation.de Tue Feb 8 21:34:31 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 8 Feb 2005 21:34:31 +0100 (CET) Subject: bh: thuban ChangeLog,1.782,1.783 Message-ID: <20050208203431.66025102C4F@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv9618 Modified Files: ChangeLog Log Message: More wxPython 2.5 changes. This time taken from a patch from Daniel Calvelo Aros. * Thuban/UI/tableview.py (QueryTableFrame.__init__) (QueryTableFrame.__init__): Pass the size of a spacer as a single item. * Thuban/UI/projdialog.py (ProjFrame.build_dialog) (ProjFrame.build_dialog): Pass the size of a spacer as a single item. * Thuban/UI/dbdialog.py (ChooseDBTableDialog.__init__): Pass the size of a spacer as a single item. * Thuban/UI/classifier.py (Classifier.dialog_layout): Pass the size of a spacer as a single item. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.782 retrieving revision 1.783 diff -u -d -r1.782 -r1.783 --- ChangeLog 8 Feb 2005 20:25:22 -0000 1.782 +++ ChangeLog 8 Feb 2005 20:34:29 -0000 1.783 @@ -1,5 +1,24 @@ 2005-02-08 Bernhard Herzog + More wxPython 2.5 changes. This time taken from a patch from + Daniel Calvelo Aros. + + * Thuban/UI/tableview.py (QueryTableFrame.__init__) + (QueryTableFrame.__init__): Pass the size of a spacer as a single + item. + + * Thuban/UI/projdialog.py (ProjFrame.build_dialog) + (ProjFrame.build_dialog): Pass the size of a spacer as a single + item. + + * Thuban/UI/dbdialog.py (ChooseDBTableDialog.__init__): Pass the + size of a spacer as a single item. + + * Thuban/UI/classifier.py (Classifier.dialog_layout): Pass the + size of a spacer as a single item. + +2005-02-08 Bernhard Herzog + Compatibility with wxPython 2.5. The changes should make it work better with 2.5 while still keeping compatibility with 2.4. There are still problems with 2.5, though. From bh at intevation.de Tue Feb 8 21:41:34 2005 From: bh at intevation.de (Bernhard Herzog) Date: Tue, 08 Feb 2005 21:41:34 +0100 Subject: wx2.5 In-Reply-To: <20050129063932.M96773@minag.gob.pe> (Daniel Calvelo Aros's message of "Sat, 29 Jan 2005 01:44:30 -0500") References: <20050128215826.M94442@minag.gob.pe> <20050129063932.M96773@minag.gob.pe> Message-ID: "Daniel Calvelo Aros" writes: >> 1) There's some refactoring needed for wxSizers when used as >> separating space: under wx2.4, someSizer.Add( 20, 20, 0,...) >> becomes someSizer.Add( (20,20), 0,...) Back in December there was a thread[1] started by Yao Heling about wx 2.5 where I produced a number of patches for this which were then tested by the OP. I've finally checked them in now. >> 2) ditto for widget.GetFirstChild: >> under 2.4, a second (dummy, AFAICT) argument had to be given; no >> more so under 2.5 AFAICT from the wxPython sources, the second argument was intended to be optinal there, but due to a bug it was necessary. Omitting it produces a sefault. > I attach the patch for the few changes made so far. Applied most of this too. Much was already covered by the changes from december, but there were quite a few places where spacers were not yet updated. The only changes not in CVS yet are the ones related to SetItemSelectedImage. I haven't had time to look at what can be done there to keep 2.4 compatibility. Bernhard [1] The thread starts here: http://intevation.de/pipermail/thuban-devel/2004-December/000652.html The threading is a bit broken, though. -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From thuban-bugs at intevation.de Fri Feb 11 16:18:20 2005 From: thuban-bugs at intevation.de (Request Tracker) Date: Fri, 11 Feb 2005 16:18:20 +0100 (CET) Subject: [bug #2980] (thuban) About box causes exception Message-ID: <20050211151820.C9C0D102C47@lists.intevation.de> this bug's URL: http://intevation.de/rt/webrt?serial_num=2980 ------------------------------------------------------------------------- Subject: About box causes exception looks like it doesn't like the results of calling unicodeToLocale(). Currently using: wxPython 2.5.3.2pre Python 2.3.5 PySQLite 1.0.1 SQLite 2.8.15 GDAL 1.2.5.0 psycopg - not available Compiled for: GTK 2.4.14 proj 4.4.9 An unhandled exception occurred: 'ascii' codec can't decode byte 0xfc in position 9: ordinal not in range(128) (please report to http://thuban.intevation.org/bugtracker.html) Traceback (most recent call last): File "/home/jpc/arbeit/intevation/devel5/thuban/Thuban/UI/mainwindow.py", line 300, in invoke_command command.Execute(self.Context()) File "/home/jpc/arbeit/intevation/devel5/thuban/Thuban/UI/command.py", line 121, in Execute apply(self.function, (context,) + self.args + args, kw) File "/home/jpc/arbeit/intevation/devel5/thuban/Thuban/UI/mainwindow.py", line 1075, in call_method apply(getattr(context.mainwindow, methodname), args) File "/home/jpc/arbeit/intevation/devel5/thuban/Thuban/UI/mainwindow.py", line 549, in About dlg = About(self) File "/home/jpc/arbeit/intevation/devel5/thuban/Thuban/UI/about.py", line 96, in __init__ text += '\t%s\n' % name UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 9: ordinal not in range(128) -------------------------------------------- Managed by Request Tracker From jonathan at jpcoles.com Fri Feb 11 17:08:47 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Fri, 11 Feb 2005 11:08:47 -0500 Subject: wx2.5 and wxproj.cpp segfault In-Reply-To: <20050208044748.M73871@minag.gob.pe> References: <20050208043514.M78968@minag.gob.pe> <20050208044748.M73871@minag.gob.pe> Message-ID: <1108138127.2701.4.camel@localhost.localdomain> Am Montag, den 07.02.2005, 23:49 -0500 schrieb Daniel Calvelo Aros: > Ooops. Forgot the attachment. > > > > Can you reproduce the problem? If so, I reckon the problem is somewhere > > between SWIG and its use by wxPython, far beyond my current > > knowledge. Google is of no use, and the only remotely related bug I > > found happened (once) in aMule and went so far unresolved. i can reproduce the problem: jpc at reisen:/tmp/wx_test$ chmod +x build_and_run.sh jpc at reisen:/tmp/wx_test$ ./build_and_run.sh In Datei, eingef?gt von /usr/include/python2.3/Python.h:8, von wxtest.cpp:4: /usr/include/python2.3/pyconfig.h:856:1: Warnung: ?_POSIX_C_SOURCE? redefiniert In Datei, eingef?gt von /usr/include/stdlib.h:25, von wxtest.cpp:1: /usr/include/features.h:131:1: Warnung: dies ist die Stelle der vorherigen Definition in Python: dc = py_dc:_18eb3a08_p_wxMemoryDC in use_DC:18eb3a08 ./build_and_run.sh: line 3: 21353 Speicherzugriffsfehler python wxtest.py --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== From dcalvelo at minag.gob.pe Tue Feb 15 08:43:02 2005 From: dcalvelo at minag.gob.pe (Daniel Calvelo Aros) Date: Tue, 15 Feb 2005 02:43:02 -0500 Subject: [solved] wxproj.cpp and wx2.5 Message-ID: <20050215073142.M4672@minag.gob.pe> Hi all. I finally got around asking in wxPython-users about the problems with wxproj.cpp and 2.5. Robin Dunn gently and promptly gave the answer, which is, I paraphrase: there are built-in methods in wxPython to get object addresses, don't try to use the 'address' given by the repr. I attach the patch that finally allows thuban to show the Iceland examples without segfaulting. But (and it's a big one) it needs a set of headers that are included in the source tarball of wxPython but e.g. not in the debian packages. I'll fill a reportbug on the matter, but I'm afraid the situation might be the same for other platforms and distributions. It's the include/wx/wxPython/wxPython.h file and all its dependencies, for the record. What it means practically is that 'python setup.py build' won't work (in Debian so far) with the patch applied. I'm not sure what should be done about it. Include the corresponding files in thuban's tarball? Lobby wxPython packagers to include it? Extract the strictly needed definitions and prototypes? BTW, I also had problems with Unicode e.g. in the "About" box. -- Daniel Calvelo Aros -------------- next part -------------- A non-text attachment was scrubbed... Name: wxproj.cpp.wx2.5.patch Type: application/octet-stream Size: 3112 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050215/42219b55/wxproj.cpp.wx2.5.patch From jonathan at jpcoles.com Wed Feb 16 14:28:58 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Wed, 16 Feb 2005 08:28:58 -0500 Subject: [solved] wxproj.cpp and wx2.5 In-Reply-To: <20050215073142.M4672@minag.gob.pe> References: <20050215073142.M4672@minag.gob.pe> Message-ID: <1108560538.12009.48.camel@localhost.localdomain> Am Dienstag, den 15.02.2005, 02:43 -0500 schrieb Daniel Calvelo Aros: > I attach the patch that finally allows thuban to show the Iceland examples > without segfaulting. fantastic! thank you. > But (and it's a big one) it needs a set of headers that are included in the > source tarball of wxPython but e.g. not in the debian packages. I'll fill a > reportbug on the matter, but I'm afraid the situation might be the same for > other platforms and distributions. It's the include/wx/wxPython/wxPython.h > file and all its dependencies, for the record. > I'm not sure what should be done about it. Include the corresponding files in > thuban's tarball? Lobby wxPython packagers to include it? Extract the strictly > needed definitions and prototypes? i've hacked up a solution just to get things working. i created a new header file called swigConvertPtrHack.h which has the necessary macros as well as including wxPython_int.h, which i copied over from the wx2.5 source. these two files need to be in the same place as wxproj.cpp. a patch against cvs for wxproj.cpp is also attached. this at least allows thuban to compile and run successfully. NOTE: i've only done this with wx2.5 installed. i don't know what happens if wx2.4 is installed. now that i have this working, there is a little problem with the raster code that i can now fix. this is not fatal, the mask is just applied incorrectly. --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== -------------- next part -------------- A non-text attachment was scrubbed... Name: swigPtrConvertHack.h Type: text/x-chdr Size: 740 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050216/5dfd05b6/swigPtrConvertHack.h -------------- next part -------------- A non-text attachment was scrubbed... Name: wxproj.cpp.wx2.5-jpc.patch Type: text/x-patch Size: 4799 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050216/5dfd05b6/wxproj.cpp.wx2.5-jpc.patch -------------- next part -------------- A non-text attachment was scrubbed... Name: wxPython_int.h Type: text/x-chdr Size: 140889 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050216/5dfd05b6/wxPython_int.h From jonathan at jpcoles.com Wed Feb 16 14:39:22 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Wed, 16 Feb 2005 08:39:22 -0500 Subject: [solved] wxproj.cpp and wx2.5 In-Reply-To: <1108560538.12009.48.camel@localhost.localdomain> References: <20050215073142.M4672@minag.gob.pe> <1108560538.12009.48.camel@localhost.localdomain> Message-ID: <1108561162.12009.54.camel@localhost.localdomain> [NOTE: the email i'm responding to here was blocked because of the size of the attachment. this email will make sense once that other one has been accepted and those patches applied.] Am Mittwoch, den 16.02.2005, 08:28 -0500 schrieb Jonathan Coles: > now that i have this working, there is a little problem with the raster > code that i can now fix. this is not fatal, the mask is just applied > incorrectly. i've attached a patch. the mask was inverted (1's should have been 0's and vice versa). i believe that wx2.4 had it wrong (the behavior didn't match the documentation) and i had written the inverse so that it would work. wx2.5 corrects the problem so i had to invert my code. be aware that this patch will only work for wx2.5. --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== -------------- next part -------------- A non-text attachment was scrubbed... Name: gdalwarp.cpp.wx2.5-jpc.patch Type: text/x-patch Size: 899 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050216/8946ce5f/gdalwarp.cpp.wx2.5-jpc.patch From bernhard at intevation.de Wed Feb 16 15:15:02 2005 From: bernhard at intevation.de (Bernhard Reiter) Date: Wed, 16 Feb 2005 15:15:02 +0100 Subject: [solved] wxproj.cpp and wx2.5 In-Reply-To: <1108561162.12009.54.camel@localhost.localdomain> References: <20050215073142.M4672@minag.gob.pe> <1108560538.12009.48.camel@localhost.localdomain> <1108561162.12009.54.camel@localhost.localdomain> Message-ID: <20050216141502.GG5610@intevation.de> On Wed, Feb 16, 2005 at 08:39:22AM -0500, Jonathan Coles wrote: > [NOTE: the email i'm responding to here was blocked because of the size > of the attachment. this email will make sense once that other one has > been accepted and those patches applied.] > > Am Mittwoch, den 16.02.2005, 08:28 -0500 schrieb Jonathan Coles: > > now that i have this working, there is a little problem with the raster > > code that i can now fix. this is not fatal, the mask is just applied > > incorrectly. > > i've attached a patch. the mask was inverted (1's should have been 0's > and vice versa). i believe that wx2.4 had it wrong (the behavior didn't > match the documentation) and i had written the inverse so that it would > work. wx2.5 corrects the problem so i had to invert my code. > > be aware that this patch will only work for wx2.5. We should find a way to find out if we are with wx2.5 or higher so we can have "if"s in the code and check this stuff in. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050216/eb5bbf1b/attachment.bin From jonathan at jpcoles.com Wed Feb 16 16:03:41 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Wed, 16 Feb 2005 10:03:41 -0500 Subject: [solved] wxproj.cpp and wx2.5 In-Reply-To: <20050216141502.GG5610@intevation.de> References: <20050215073142.M4672@minag.gob.pe> <1108560538.12009.48.camel@localhost.localdomain> <1108561162.12009.54.camel@localhost.localdomain> <20050216141502.GG5610@intevation.de> Message-ID: <1108566221.12009.56.camel@localhost.localdomain> Am Mittwoch, den 16.02.2005, 15:15 +0100 schrieb Bernhard Reiter: > > be aware that this patch will only work for wx2.5. > > We should find a way to find out if we are with wx2.5 or higher > so we can have "if"s in the code and check this stuff in. there's the wxCHECK_VERSION macro that does this. i'm implementing a solution now. --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== From dcalvelo at minag.gob.pe Wed Feb 16 16:30:15 2005 From: dcalvelo at minag.gob.pe (Daniel Calvelo Aros) Date: Wed, 16 Feb 2005 10:30:15 -0500 Subject: [solved] wxproj.cpp and wx2.5 In-Reply-To: <1108560538.12009.48.camel@localhost.localdomain> References: <20050215073142.M4672@minag.gob.pe> <1108560538.12009.48.camel@localhost.localdomain> Message-ID: <20050216152038.M82536@minag.gob.pe> From: Jonathan Coles Sent: Wed, 16 Feb 2005 08:28:58 -0500 [...] > i've hacked up a solution just to get things working. i created a new > header file called swigConvertPtrHack.h which has the necessary > macros as well as including wxPython_int.h, which i copied over from > the wx2.5 source. these two files need to be in the same place as > wxproj.cpp. a patch against cvs for wxproj.cpp is also attached. I think some chopping could be done for wxPython_int.h as well; by superficial reading, it seems that not much more than the wxPyCoreAPI is needed. All the #ifndef PyUSE_EXPORTED_API blocks may be cut out, since wxPython.h #defines that. You think baking our own own header is the way to go? Daniel. From jonathan at jpcoles.com Wed Feb 16 16:41:43 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Wed, 16 Feb 2005 10:41:43 -0500 Subject: [solved] wxproj.cpp and wx2.5 In-Reply-To: <20050216152038.M82536@minag.gob.pe> References: <20050215073142.M4672@minag.gob.pe> <1108560538.12009.48.camel@localhost.localdomain> <20050216152038.M82536@minag.gob.pe> Message-ID: <1108568503.12009.60.camel@localhost.localdomain> Am Mittwoch, den 16.02.2005, 10:30 -0500 schrieb Daniel Calvelo Aros: > From: Jonathan Coles > Sent: Wed, 16 Feb 2005 08:28:58 -0500 > [...] > > i've hacked up a solution just to get things working. i created a new > > header file called swigConvertPtrHack.h which has the necessary > > macros as well as including wxPython_int.h, which i copied over from > > the wx2.5 source. these two files need to be in the same place as > > wxproj.cpp. a patch against cvs for wxproj.cpp is also attached. > > I think some chopping could be done for wxPython_int.h as well; by superficial > reading, it seems that not much more than the wxPyCoreAPI is needed. All the > #ifndef PyUSE_EXPORTED_API blocks may be cut out, since wxPython.h #defines that. ok, i'll do that. > You think baking our own own header is the way to go? well, it's not ideal. it would be much better, of course, to rely on wxPython.h being available. for the time being, however, this at least allows us to work with wx2.5. --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== From thuban-bugs at intevation.de Wed Feb 16 21:42:21 2005 From: thuban-bugs at intevation.de (Request Tracker) Date: Wed, 16 Feb 2005 21:42:21 +0100 (CET) Subject: [bug #3008] (thuban) point's size affects rendering Message-ID: <20050216204221.C416E102BE6@lists.intevation.de> this bug's URL: http://intevation.de/rt/webrt?serial_num=3008 ------------------------------------------------------------------------- Subject: point's size affects rendering to reproduce: 1) open iceland_sample_raster.thuban 2) open the layer's properties for cultural_landmark-point 3) set the size of the default point to 71 and the line width to 6 4) click 'try' 5) the map is not rendered Thuban 1.1 cvs-20050216 ChangeLog 2005-02-08 Currently using: wxPython 2.5.3.2pre Python 2.3.5 PySQLite 1.0.1 SQLite 2.8.15 GDAL 1.2.5.0 psycopg - not available Compiled for: GTK 2.4.14 proj 4.4.9 -------------------------------------------- Managed by Request Tracker From cvs at intevation.de Wed Feb 16 22:14:49 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 16 Feb 2005 22:14:49 +0100 (CET) Subject: jonathan: thuban ChangeLog,1.783,1.784 setup.py,1.47,1.48 Message-ID: <20050216211449.6B9C4102BE6@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv7505 Modified Files: ChangeLog setup.py Log Message: Further wxPython 2.5 changes using patches from Daniel Calvelo Aros so that that wxproj doesn't crash. Added GUI support for selecting alpha channel (opacity can't be selected yet). Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.783 retrieving revision 1.784 diff -u -d -r1.783 -r1.784 --- ChangeLog 8 Feb 2005 20:34:29 -0000 1.783 +++ ChangeLog 16 Feb 2005 21:14:47 -0000 1.784 @@ -1,3 +1,67 @@ +2005-02-16 Jonathan Coles + + Further wxPython 2.5 changes using patches from Daniel Calvelo Aros + so that that wxproj doesn't crash. Added GUI support for selecting + alpha channel (opacity can't be selected yet). + + NOTE: If wxPython.h is including in future distribution packages + then it will not be necessary to have the files swigPtrConvertHack.h + and wxPython_int.h included with Thuban. This is hopefully + a temporary workaround. + + * setup.py (thuban_build_ext.finalize_options): gdalwarp needs + access to the macro wxCHECK_VERSION so that it will properly + generate a bit mask. There was a problem between wx2.4 and wx2.5 + that this works around. + + * Thuban/Model/layer.py (RasterLayer.UseMask): Removed in favor + of RasterLayer.MaskType. + (RasterLayer.SetUseMask): Removed in favor of RasterLayer.SetMaskType + (RasterLayer.MaskType): New. Returns the type of mask to use. Can + specify none, a bitmap, or an alpha channel. + (RasterLayer.SetMaskType): New. Set what kind of mask to use. + + * Thuban/UI/baserenderer.py (BaseRenderer.draw_raster_layer): + Set the raster warping options for the mask based on the value + of RasterLayer.MaskType. + + * Thuban/UI/legend.py (LegendTree.__FillTreeLayer): Remove + deprecated calls to SetItemSelectedImage in favor of SetItemImage + with wxTreeItemIcon_Selected. + + * Thuban/UI/rasterlayerproperties.py: Support selecting to use + an alpha channel for the mask. + + * Thuban/UI/renderer.py (MapRenderer.draw_raster_data): Use alpha + data if it is available and an alpha channel is supported under + the current version of wxPython. + + * libraries/thuban/gdalwarp.cpp (GetImageData): Added compiler define + to select whether 1's or 0's select the desired portion of an image + in the bit mask. wx2.4 has a bug where the documentation is the opposite + from behavior. + (ProjectRasterFile): Only generate an alpha channel if the version + of wxPython is >= 2.5.3. + + * libraries/thuban/wxproj.cpp: Applied patches from Daniel Calvelo Aros. + When wxPython >= 2.5.3 use the special swig functions to decode an + object's address. + + * libraries/thuban/swigPtrConvertHack.h: Includes conditional code + based on the version of wxPython. If >= 2.5.3 use the special swig + functions from wxPython to decode wxPython objects, otherwise use + the old method of retrieving the address from the object __repr__ string. + + * libraries/thuban/wxPython_int.h: Copied from wxPython source. + Unnecessary code was removed to make it smaller. + + * test/test_baserenderer.py (TestBaseRenderer.test_raster_no_projection): + Add tests for returning an alpha channel. + + * test/test_layer.py (TestLayerModification.test_raster_layer): Fix + tests that used removed functions UseMask and SetUseMask + + 2005-02-08 Bernhard Herzog More wxPython 2.5 changes. This time taken from a patch from Index: setup.py =================================================================== RCS file: /thubanrepository/thuban/setup.py,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- setup.py 21 Jan 2005 14:01:25 -0000 1.47 +++ setup.py 16 Feb 2005 21:14:47 -0000 1.48 @@ -1093,8 +1093,10 @@ self.extensions.append(Extension("Lib.gdalwarp", [ext_dir + "/thuban/gdalwarp.cpp"], include_dirs = gdal_cs_params[CS_INCDIRS] + - [ext_dir + "/thuban/"], - define_macros = gdal_cs_params[CS_DEFS], + [ext_dir + "/thuban/"] + + wx_cs_params[CS_INCDIRS], + define_macros = gdal_cs_params[CS_DEFS] + + wx_cs_params[CS_DEFS], library_dirs = gdal_cs_params[CS_LIBDIRS], libraries = gdal_cs_params[CS_LIBS])) From cvs at intevation.de Wed Feb 16 22:14:49 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 16 Feb 2005 22:14:49 +0100 (CET) Subject: jonathan: thuban/Thuban/Model layer.py,1.62,1.63 Message-ID: <20050216211449.7728C102C0F@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban/Thuban/Model In directory doto:/tmp/cvs-serv7505/Thuban/Model Modified Files: layer.py Log Message: Further wxPython 2.5 changes using patches from Daniel Calvelo Aros so that that wxproj doesn't crash. Added GUI support for selecting alpha channel (opacity can't be selected yet). Index: layer.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/Model/layer.py,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- layer.py 28 Jan 2005 15:54:00 -0000 1.62 +++ layer.py 16 Feb 2005 21:14:47 -0000 1.63 @@ -344,6 +344,10 @@ class RasterLayer(BaseLayer): + MASK_NONE = 0 + MASK_BIT = 1 + MASK_ALPHA = 2 + def __init__(self, title, filename, projection = None, visible = True): """Initialize the Raster Layer. @@ -367,7 +371,8 @@ self.bbox = -1 - self.use_mask = True + self.mask_type = self.MASK_BIT + self.alpha_opacity = 1 self.image_info = None @@ -458,18 +463,44 @@ def GetImageFilename(self): return self.filename - def UseMask(self): + def MaskType(self): """Return True if the mask should be used when rendering the layer.""" - return self.use_mask + return self.mask_type - def SetUseMask(self, use): - """Set whether to use a mask when render the image. + def SetMaskType(self, type): + """Set the type of mask to use. + + type can be one of MASK_NONE, MASK_BIT, MASK_ALPHA If the state changes, a LAYER_CHANGED message is sent. """ - if use != self.use_mask: - self.use_mask = use + if type not in (self.MASK_NONE, self.MASK_BIT, self.MASK_ALPHA): + raise ValueError("type is invalid") + + if type != self.mask_type: + self.mask_type = type self.changed(LAYER_CHANGED, self) + + def AlphaOpacity(self): + """Return the level of opacity used in alpha blending, or None + if mask type is not MASK_ALPHA. + """ + if self.mask_type == self.MASK_ALPHA: + return self.alpha_opacity + else: + return None + + def SetAlphaOpacity(self, op): + """Set the level of alpha opacity. + + 0 <= op <= 1. + + The layer is fully opaque when op = 1. + """ + if not (0 <= op <= 1): + raise ValueError("op out of range") + + self.alpha_opacity = op def ImageInfo(self): return self.image_info From cvs at intevation.de Wed Feb 16 22:14:49 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 16 Feb 2005 22:14:49 +0100 (CET) Subject: jonathan: thuban/Thuban/UI baserenderer.py, 1.16, 1.17 legend.py, 1.38, 1.39 rasterlayerproperties.py, 1.1, 1.2 renderer.py, 1.56, 1.57 Message-ID: <20050216211449.97CD4102C10@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv7505/Thuban/UI Modified Files: baserenderer.py legend.py rasterlayerproperties.py renderer.py Log Message: Further wxPython 2.5 changes using patches from Daniel Calvelo Aros so that that wxproj doesn't crash. Added GUI support for selecting alpha channel (opacity can't be selected yet). Index: baserenderer.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/baserenderer.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- baserenderer.py 28 Jan 2005 15:54:00 -0000 1.16 +++ baserenderer.py 16 Feb 2005 21:14:47 -0000 1.17 @@ -485,7 +485,7 @@ try: options = 0 - if layer.UseMask(): options = options | 1 + options = options | layer.MaskType() project_params = (layer.GetImageFilename(), in_proj, out_proj, (xmin, ymin, xmax, ymax), "", (width, height), @@ -507,10 +507,11 @@ left corner at (x,y) The raster image data is a tuple of the form - (width, height, (image_data, mask_data)) + (width, height, (image_data, mask_data, alpha_data)) - holding the image width, height, image data, and mask data. - mask_data may be None if a mask should not be used. If + holding the image width, height, image data, mask data, and alpha data. + mask_data may be None if a mask should not be used. alpha_data may + also be None. If both are not None mask overrides alpha. If format is 'RAW' the data will be RGB values and the mask will be in XMB format. Otherwise, both kinds of data are assumed to be in the format specified in format. Index: legend.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/legend.py,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- legend.py 8 Feb 2005 20:25:22 -0000 1.38 +++ legend.py 16 Feb 2005 21:14:47 -0000 1.39 @@ -547,6 +547,7 @@ self.Thaw() def __FillTreeLayer(self, pid): + layer = self.GetPyData(pid) self.Freeze() @@ -569,8 +570,9 @@ bmp = self.__BuildGroupImage(g, shapeType) if bmp is None: - self.SetItemImage(id, -1) - self.SetItemSelectedImage(id, -1) + self.SetItemImage(id, -1, wxTreeItemIcon_Normal) + self.SetItemImage(id, -1, wxTreeItemIcon_Selected) + #self.SetItemSelectedImage(id, -1) else: if self.availImgListIndices: i = self.availImgListIndices.pop(0) @@ -578,8 +580,9 @@ else: i = self.image_list.Add(bmp) - self.SetItemImage(id, i) - self.SetItemSelectedImage(id, i) + self.SetItemImage(id, i, wxTreeItemIcon_Normal) + self.SetItemImage(id, i, wxTreeItemIcon_Selected) + #self.SetItemlectedImage(id, i) self.Thaw() Index: rasterlayerproperties.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/rasterlayerproperties.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- rasterlayerproperties.py 27 Jan 2005 14:19:41 -0000 1.1 +++ rasterlayerproperties.py 16 Feb 2005 21:14:47 -0000 1.2 @@ -17,13 +17,15 @@ from Thuban.UI.layerproperties import LayerProperties from Thuban.Model.resource import has_gdal_support, gdal_support_status +from Thuban.version import versions + class RasterLayerProperties(LayerProperties): def __init__(self, parent, name, layer, *args, **kw): LayerProperties.__init__(self, parent, name, layer) self.old_state = {} - self.old_state["use_mask"] = layer.UseMask() + self.old_state["mask_type"] = layer.MaskType() LayerProperties.dialog_layout(self) @@ -79,13 +81,22 @@ maskBox = wxBoxSizer(wxHORIZONTAL) - self.maskCB = wxCheckBox(panel, -1, _("Use Mask")) - maskBox.Add(self.maskCB, 0, wxRIGHT, 10) + if versions['wxPython-tuple'] < (2,5,3): + choices = ["None", "Bitmap", + "Alpha (Not support by wxPython %s)" % \ + versions['wxPython']] + else: + choices = ["None", "Bitmap", "Alpha"] + + self.maskRadioBox = wxRadioBox(panel, -1, _("Mask Type"), + choices=choices) + #self.maskCB = wxCheckBox(panel, -1, _("Use Mask")) + maskBox.Add(self.maskRadioBox, 0, wxRIGHT, 10) rasterBox.Add(maskBox, 0, wxALL, 4) panelBox.Add(rasterBox, 1, wxGROW | wxALL, 4) - self.maskCB.SetValue(self.old_state["use_mask"]) + self.maskRadioBox.SetSelection(self.old_state["mask_type"]) def OnTry(self, event): self.set_state() @@ -95,9 +106,9 @@ self.Close() def OnRevert(self, event): - self.maskCB.SetValue(self.old_state["use_mask"]) + self.maskRadioBox.SetSelection(self.old_state["mask_type"]) self.set_state() def set_state(self): - self.layer.SetUseMask(self.maskCB.GetValue() == 1) + self.layer.SetMaskType(self.maskRadioBox.GetSelection()) return True Index: renderer.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/renderer.py,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- renderer.py 28 Jan 2005 15:54:00 -0000 1.56 +++ renderer.py 16 Feb 2005 21:14:47 -0000 1.57 @@ -43,6 +43,8 @@ from types import StringType +from Thuban.version import versions + # Map the strings used for the format parameter of the draw_raster_data # method to the appropriate wxWindows constants @@ -92,6 +94,8 @@ if (layer.ShapeStore().RawShapeFormat() == RAW_SHAPEFILE and layer.ShapeType() in (SHAPETYPE_ARC, SHAPETYPE_POLYGON)): offx, offy = self.offset + x = lambda a, b, c, d: None + #return (True, x, None) return (True, draw_polygon_shape, draw_polygon_init(layer.ShapeStore().Shapefile(), self.dc, self.map.projection, @@ -107,20 +111,32 @@ def draw_raster_data(self, x,y, data, format = 'BMP'): mask = None + width = data[0] + height = data[1] + image_data, mask_data, alpha_data = data[2] + + if versions['wxPython-tuple'] < (2,5,3): + alpha_data = None if format == 'RAW': - image = wxEmptyImage(data[0], data[1]) - image.SetData(data[2][0]) - if data[2][1] is not None: - mask = wxBitmapFromBits(data[2][1], data[0], data[1], 1) + image = wxEmptyImage(width, height) + image.SetData(image_data) + if mask_data is not None: + mask = wxBitmapFromBits(mask_data, width, height, 1) mask = wxMask(mask) + elif alpha_data is not None: + image.SetAlphaData(alpha_data) else: - stream = cStringIO.StringIO(data[2][0]) + stream = cStringIO.StringIO(image_data) image = wxImageFromStream(stream, raster_format_map[format]) - if data[2][1] is not None: - stream = cStringIO.StringIO(data[2][1]) + if mask_data is not None: + stream = cStringIO.StringIO(mask_data) mask = wxImageFromStream(stream, raster_format_map[format]) mask = wxMask(wxBitmapFromImage(mask, 1)) + elif alpha_data is not None: + stream = cStringIO.StringIO(alpha_data) + alpha = wxImageFromStream(stream, raster_format_map[format]) + image.SetAlpha(alpha.GetData()[:]) bitmap = wxBitmapFromImage(image) bitmap.SetMask(mask) From cvs at intevation.de Wed Feb 16 22:14:49 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 16 Feb 2005 22:14:49 +0100 (CET) Subject: jonathan: thuban/test test_baserenderer.py, 1.10, 1.11 test_layer.py, 1.34, 1.35 Message-ID: <20050216211449.B1DEA102C24@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban/test In directory doto:/tmp/cvs-serv7505/test Modified Files: test_baserenderer.py test_layer.py Log Message: Further wxPython 2.5 changes using patches from Daniel Calvelo Aros so that that wxproj doesn't crash. Added GUI support for selecting alpha channel (opacity can't be selected yet). Index: test_baserenderer.py =================================================================== RCS file: /thubanrepository/thuban/test/test_baserenderer.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- test_baserenderer.py 28 Jan 2005 15:54:00 -0000 1.10 +++ test_baserenderer.py 16 Feb 2005 21:14:47 -0000 1.11 @@ -32,6 +32,7 @@ from Thuban.UI.baserenderer import BaseRenderer, \ add_renderer_extension, init_renderer_extensions +from Thuban.version import versions class MockDC: @@ -287,7 +288,7 @@ # The following commented out code block can be used to generate # the base64 coded reference image data - #hexed = binascii.b2a_base64(renderer.raster_data[2][1]) + #hexed = binascii.b2a_base64(renderer.raster_data[2][0]) #while hexed: #print repr(hexed[:65]) #hexed = hexed[65:] @@ -320,16 +321,58 @@ 'mUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm' 'UmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm\n') - raw_mask = binascii.a2b_base64( - 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' - 'AAAAAAAAAAAAAAA\n') - self.assertEquals(renderer.raster_data, (20,20,(raw_data, raw_mask))) + #print + #hexed = binascii.b2a_base64(renderer.raster_data[2][1]) + #while hexed: + #print repr(hexed[:61]) + #hexed = hexed[61:] + + + if versions['wxPython-tuple'] < (2,5,3): + raw_mask = binascii.a2b_base64( + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAA\n') + else: + raw_mask = binascii.a2b_base64( + '//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P/' + '/8P//8P//8P//8P//8P\n') + + self.assertEquals(renderer.raster_data, + (20,20,(raw_data, raw_mask, None))) + self.assertEquals(renderer.raster_format, "RAW") self.assertEquals(dc.calls, [('BeginDrawing',), ('SetFont', "label font"), ('EndDrawing',)]) + + if versions['wxPython-tuple'] >= (2,5,3): + layer.SetMaskType(layer.MASK_ALPHA) + renderer.render_map() + + #print + #hexed = binascii.b2a_base64(renderer.raster_data[2][2]) + #while hexed: + #print repr(hexed[:61]) + #hexed = hexed[61:] + raw_alpha = binascii.a2b_base64( + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////w==\n') + self.assertEquals(renderer.raster_data, + (20,20,(raw_data, None, raw_alpha))) + + + layer.SetMaskType(layer.MASK_NONE) + renderer.render_map() + self.assertEquals(renderer.raster_data, (20,20,(raw_data, None, None))) def test_point_map_projection(self): """Test BaseRenderer with point layer and map projection""" Index: test_layer.py =================================================================== RCS file: /thubanrepository/thuban/test/test_layer.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- test_layer.py 28 Jan 2005 15:54:00 -0000 1.34 +++ test_layer.py 16 Feb 2005 21:14:47 -0000 1.35 @@ -231,7 +231,7 @@ layer = RasterLayer("Test RasterLayer", filename) self.failIf(layer.HasClassification()) self.failIf(layer.HasShapes()) - self.failUnless(layer.UseMask()) + self.assertEquals(layer.MaskType(), layer.MASK_BIT) self.assertEquals(layer.GetImageFilename(), os.path.abspath(filename)) self.assertFloatSeqEqual(layer.BoundingBox(), [-24.5500000, 63.2833330, @@ -460,27 +460,46 @@ layer.Subscribe(LAYER_CHANGED, self.subscribe_with_params, LAYER_CHANGED) - self.failUnless(layer.UseMask()) + self.assertEquals(layer.MaskType(), layer.MASK_BIT) - layer.SetUseMask(False) - self.failIf(layer.UseMask()) + layer.SetMaskType(layer.MASK_NONE) + self.failIf(layer.MaskType() != layer.MASK_NONE) self.check_messages([(layer, LAYER_CHANGED)]) self.clear_messages() - layer.SetUseMask(False) - self.failIf(layer.UseMask()) + layer.SetMaskType(layer.MASK_NONE) + self.failIf(layer.MaskType() != layer.MASK_NONE) self.check_messages([]) self.clear_messages() - layer.SetUseMask(True) - self.failUnless(layer.UseMask()) + layer.SetMaskType(layer.MASK_BIT) + self.failIf(layer.MaskType() != layer.MASK_BIT) self.check_messages([(layer, LAYER_CHANGED)]) self.clear_messages() - layer.SetUseMask(True) - self.failUnless(layer.UseMask()) + layer.SetMaskType(layer.MASK_BIT) + self.failIf(layer.MaskType() != layer.MASK_BIT) self.check_messages([]) self.clear_messages() + + layer.SetMaskType(layer.MASK_ALPHA) + self.failIf(layer.MaskType() != layer.MASK_ALPHA) + + layer.SetAlphaOpacity(0) + self.assertEquals(layer.AlphaOpacity(), 0) + layer.SetAlphaOpacity(0.5) + self.assertEquals(layer.AlphaOpacity(), 0.5) + layer.SetAlphaOpacity(1) + self.assertEquals(layer.AlphaOpacity(), 1) + + self.assertRaises(ValueError, layer.SetAlphaOpacity, -0.1) + self.assertRaises(ValueError, layer.SetAlphaOpacity, 1.1) + + layer.SetMaskType(layer.MASK_NONE) + self.assertEquals(layer.AlphaOpacity(), None) + + self.assertRaises(ValueError, layer.SetMaskType, -1) + self.assertRaises(ValueError, layer.SetMaskType, 4) if __name__ == "__main__": From cvs at intevation.de Wed Feb 16 22:14:49 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 16 Feb 2005 22:14:49 +0100 (CET) Subject: jonathan: thuban/libraries/thuban swigPtrConvertHack.h, NONE, 1.1 wxPython_int.h, NONE, 1.1 gdalwarp.cpp, 1.6, 1.7 wxproj.cpp, 1.4, 1.5 Message-ID: <20050216211449.A3B35102C16@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban/libraries/thuban In directory doto:/tmp/cvs-serv7505/libraries/thuban Modified Files: gdalwarp.cpp wxproj.cpp Added Files: swigPtrConvertHack.h wxPython_int.h Log Message: Further wxPython 2.5 changes using patches from Daniel Calvelo Aros so that that wxproj doesn't crash. Added GUI support for selecting alpha channel (opacity can't be selected yet). --- NEW FILE: swigPtrConvertHack.h --- #ifndef __WXHACK_H #define __WXHACK_H #include #if wxCHECK_VERSION(2,5,3) #define wxPyUSE_EXPORTED_API #include "wxPython_int.h" static bool wxPyCoreAPI_IMPORT() { wxPyCoreAPIPtr=(wxPyCoreAPI*)PyCObject_Import("wx._core_", "_wxPyCoreAPI"); if (! wxPyCoreAPIPtr) wxPyCoreAPIPtr=(wxPyCoreAPI*)PyCObject_Import("_core_", "_wxPyCoreAPI"); return wxPyCoreAPIPtr != NULL; } // Used by the macros below to fetch the API pointer, importing it first if // needed. This should never need to be called directly. inline wxPyCoreAPI* wxPyGetCoreAPIPtr() { if (wxPyCoreAPIPtr == NULL) wxPyCoreAPI_IMPORT(); // wxASSERT_MSW(wxPyCoreAPIPtr != NULL, wxT("wxPyCoreAPIPtr is NULL!!!")); // uncomment when needed for debugging return wxPyCoreAPIPtr; } #define wxPyConvertSwigPtr(a,b,c) (wxPyGetCoreAPIPtr()->p_wxPyConvertSwigPtr(a,b,c)) #else /* helper function to extract the pointer value from a swig ptr string */ static void * decode_pointer(char *string) { unsigned long p = 0; /* Pointer values must start with leading underscore */ if (*string == '_') { string++; /* Extract hex value from pointer */ while (*string) { if ((*string >= '0') && (*string <= '9')) p = (p << 4) + (*string - '0'); else if ((*string >= 'a') && (*string <= 'f')) p = (p << 4) + ((*string - 'a') + 10); else break; string++; } } return (void*)p; } /* Return the object wrapped by the SWIG shadow object shadow */ bool wxPyConvertSwigPtr( PyObject* obj, void **ptr, const wxChar* className) { PyObject * string; *ptr = 0; string = PyObject_GetAttrString(obj, "this"); if (string && PyString_Check(string)) { *ptr = decode_pointer(PyString_AsString(string)); } Py_XDECREF(string); return *ptr != 0; } #endif #endif --- NEW FILE: wxPython_int.h --- //////////////////////////////////////////////////////////////////////////// // Name: wxPython_int.h (int == internal) // Purpose: Helper functions/classes for the wxPython extension module // This header should only be inclued directly by those source // modules included in the wx._core module. All others should // include wx/wxPython/wxPython.h instead. // // Author: Robin Dunn // // Created: 1-July-1997 // RCS-ID: $Id: wxPython_int.h,v 1.1 2005/02/16 21:14:47 jonathan Exp $ // Copyright: (c) 1998 by Total Control Software // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifndef __wxp_helpers__ #define __wxp_helpers__ #include #if 1 #include #include //#include #include #include #include #include //#include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #include //#include #include #include #include #include //#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include //#include #endif typedef unsigned char byte; typedef wxPoint2DDouble wxPoint2D; //--------------------------------------------------------------------------- // A macro that will help to execute simple statments wrapped in // StartBlock/EndBlockThreads calls #define wxPyBLOCK_THREADS(stmt) \ { bool blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); } // Raise the NotImplementedError exception (blocking threads) #define wxPyRaiseNotImplemented() \ wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError)) // Raise any exception witha string value (blocking threads) #define wxPyErr_SetString(err, str) \ wxPyBLOCK_THREADS(PyErr_SetString(err, str)) //--------------------------------------------------------------------------- #if PYTHON_API_VERSION < 1009 #define PySequence_Fast_GET_ITEM(o, i) \ (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) #endif #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; } #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name) #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val) //--------------------------------------------------------------------------- #ifndef wxPyUSE_EXPORTED_API class wxPyCallback : public wxObject { DECLARE_ABSTRACT_CLASS(wxPyCallback); public: wxPyCallback(PyObject* func); wxPyCallback(const wxPyCallback& other); ~wxPyCallback(); void EventThunker(wxEvent& event); PyObject* m_func; }; #endif // wxPyUSE_EXPORTED_API //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // These Event classes can be derived from in Python and passed through the // event system without loosing anything. They do this by keeping a reference // to themselves and some special case handling in wxPyCallback::EventThunker. class wxPyEvtSelfRef { public: wxPyEvtSelfRef(); ~wxPyEvtSelfRef(); void SetSelf(PyObject* self, bool clone=false); PyObject* GetSelf() const; bool GetCloned() const { return m_cloned; } protected: PyObject* m_self; bool m_cloned; }; class wxPyEvent : public wxEvent, public wxPyEvtSelfRef { DECLARE_ABSTRACT_CLASS(wxPyEvent) public: wxPyEvent(int winid=0, wxEventType commandType = wxEVT_NULL); wxPyEvent(const wxPyEvent& evt); ~wxPyEvent(); virtual wxEvent* Clone() const { return new wxPyEvent(*this); } }; class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef { DECLARE_ABSTRACT_CLASS(wxPyCommandEvent) public: wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0); wxPyCommandEvent(const wxPyCommandEvent& evt); ~wxPyCommandEvent(); virtual wxEvent* Clone() const { return new wxPyCommandEvent(*this); } }; //---------------------------------------------------------------------- // Forward decalre a few things used in the exported API class wxPyClientData; class wxPyUserData; class wxPyOORClientData; class wxPyCBInputStream; void wxPyClientData_dtor(wxPyClientData* self); void wxPyUserData_dtor(wxPyUserData* self); void wxPyOORClientData_dtor(wxPyOORClientData* self); wxPyCBInputStream* wxPyCBInputStream_create(PyObject *py, bool block); //--------------------------------------------------------------------------- // Export a C API in a struct. Other modules will be able to load this from // the wx.core module and will then have safe access to these functions, even if // in another shared library. class wxPyCallbackHelper; struct swig_type_info; struct swig_const_info; typedef double (*py_objasdbl_conv)(PyObject *obj); // Make SunCC happy and make typedef's for these that are extern "C" typedef swig_type_info* (*p_SWIG_Python_TypeRegister_t)(swig_type_info *); typedef swig_type_info* (*p_SWIG_Python_TypeCheck_t)(char *c, swig_type_info *); typedef void* (*p_SWIG_Python_TypeCast_t)(swig_type_info *, void *); typedef swig_type_info* (*p_SWIG_Python_TypeDynamicCast_t)(swig_type_info *, void **); typedef const char* (*p_SWIG_Python_TypeName_t)(const swig_type_info *); typedef const char * (*p_SWIG_Python_TypePrettyName_t)(const swig_type_info *); typedef swig_type_info* (*p_SWIG_Python_TypeQuery_t)(const char *); typedef void (*p_SWIG_Python_TypeClientData_t)(swig_type_info *, void *); typedef PyObject* (*p_SWIG_Python_newvarlink_t)(void); typedef void (*p_SWIG_Python_addvarlink_t)(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *)); typedef int (*p_SWIG_Python_ConvertPtr_t)(PyObject *, void **, swig_type_info *, int); typedef int (*p_SWIG_Python_ConvertPacked_t)(PyObject *, void *, int sz, swig_type_info *, int); typedef char* (*p_SWIG_Python_PackData_t)(char *c, void *, int); typedef char* (*p_SWIG_Python_UnpackData_t)(char *c, void *, int); typedef PyObject* (*p_SWIG_Python_NewPointerObj_t)(void *, swig_type_info *,int own); typedef PyObject* (*p_SWIG_Python_NewPackedObj_t)(void *, int sz, swig_type_info *); typedef void (*p_SWIG_Python_InstallConstants_t)(PyObject *d, swig_const_info constants[]); typedef void* (*p_SWIG_Python_MustGetPtr_t)(PyObject *, swig_type_info *, int, int); struct wxPyCoreAPI { p_SWIG_Python_TypeRegister_t p_SWIG_Python_TypeRegister; p_SWIG_Python_TypeCheck_t p_SWIG_Python_TypeCheck; p_SWIG_Python_TypeCast_t p_SWIG_Python_TypeCast; p_SWIG_Python_TypeDynamicCast_t p_SWIG_Python_TypeDynamicCast; p_SWIG_Python_TypeName_t p_SWIG_Python_TypeName; p_SWIG_Python_TypePrettyName_t p_SWIG_Python_TypePrettyName; p_SWIG_Python_TypeQuery_t p_SWIG_Python_TypeQuery; p_SWIG_Python_TypeClientData_t p_SWIG_Python_TypeClientData; p_SWIG_Python_newvarlink_t p_SWIG_Python_newvarlink; p_SWIG_Python_addvarlink_t p_SWIG_Python_addvarlink; p_SWIG_Python_ConvertPtr_t p_SWIG_Python_ConvertPtr; p_SWIG_Python_ConvertPacked_t p_SWIG_Python_ConvertPacked; p_SWIG_Python_PackData_t p_SWIG_Python_PackData; p_SWIG_Python_UnpackData_t p_SWIG_Python_UnpackData; p_SWIG_Python_NewPointerObj_t p_SWIG_Python_NewPointerObj; p_SWIG_Python_NewPackedObj_t p_SWIG_Python_NewPackedObj; p_SWIG_Python_InstallConstants_t p_SWIG_Python_InstallConstants; p_SWIG_Python_MustGetPtr_t p_SWIG_Python_MustGetPtr; bool (*p_wxPyCheckSwigType)(const wxChar* className); PyObject* (*p_wxPyConstructObject)(void* ptr, const wxChar* className, int setThisOwn); bool (*p_wxPyConvertSwigPtr)(PyObject* obj, void **ptr, const wxChar* className); PyObject* (*p_wxPyMakeSwigPtr)(void* ptr, const wxChar* className); PyThreadState* (*p_wxPyBeginAllowThreads)(); void (*p_wxPyEndAllowThreads)(PyThreadState* state); bool (*p_wxPyBeginBlockThreads)(); void (*p_wxPyEndBlockThreads)(bool blocked); PyObject* (*p_wxPy_ConvertList)(wxListBase* list); wxString* (*p_wxString_in_helper)(PyObject* source); wxString (*p_Py2wxString)(PyObject* source); PyObject* (*p_wx2PyString)(const wxString& src); byte* (*p_byte_LIST_helper)(PyObject* source); int* (*p_int_LIST_helper)(PyObject* source); long* (*p_long_LIST_helper)(PyObject* source); char** (*p_string_LIST_helper)(PyObject* source); wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints); wxBitmap** (*p_wxBitmap_LIST_helper)(PyObject* source); wxString* (*p_wxString_LIST_helper)(PyObject* source); wxAcceleratorEntry* (*p_wxAcceleratorEntry_LIST_helper)(PyObject* source); bool (*p_wxSize_helper)(PyObject* source, wxSize** obj); bool (*p_wxPoint_helper)(PyObject* source, wxPoint** obj); bool (*p_wxRealPoint_helper)(PyObject* source, wxRealPoint** obj); bool (*p_wxRect_helper)(PyObject* source, wxRect** obj); bool (*p_wxColour_helper)(PyObject* source, wxColour** obj); bool (*p_wxPoint2D_helper)(PyObject* source, wxPoint2DDouble** obj); bool (*p_wxPySimple_typecheck)(PyObject* source, const wxChar* classname, int seqLen); bool (*p_wxColour_typecheck)(PyObject* source); void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref); bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name); int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple); PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple); void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh); PyObject* (*p_wxPyMake_wxObject)(wxObject* source, bool setThisOwn, bool checkEvtHandler); PyObject* (*p_wxPyMake_wxSizer)(wxSizer* source, bool setThisOwn); void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName); bool (*p_wxPy2int_seq_helper)(PyObject* source, int* i1, int* i2); bool (*p_wxPy4int_seq_helper)(PyObject* source, int* i1, int* i2, int* i3, int* i4); PyObject* (*p_wxArrayString2PyList_helper)(const wxArrayString& arr); PyObject* (*p_wxArrayInt2PyList_helper)(const wxArrayInt& arr); void (*p_wxPyClientData_dtor)(wxPyClientData*); void (*p_wxPyUserData_dtor)(wxPyUserData*); void (*p_wxPyOORClientData_dtor)(wxPyOORClientData*); wxPyCBInputStream* (*p_wxPyCBInputStream_create)(PyObject *py, bool block); bool (*p_wxPyInstance_Check)(PyObject* obj); bool (*p_wxPySwigInstance_Check)(PyObject* obj); bool (*p_wxPyCheckForApp)(); }; #ifdef wxPyUSE_EXPORTED_API // Notice that this is static, not extern. This is by design, each module // needs one, but doesn't have to use it. static wxPyCoreAPI* wxPyCoreAPIPtr = NULL; inline wxPyCoreAPI* wxPyGetCoreAPIPtr(); #endif // wxPyUSE_EXPORTED_API #endif Index: gdalwarp.cpp =================================================================== RCS file: /thubanrepository/thuban/libraries/thuban/gdalwarp.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- gdalwarp.cpp 7 Feb 2005 19:51:13 -0000 1.6 +++ gdalwarp.cpp 16 Feb 2005 21:14:47 -0000 1.7 @@ -29,6 +29,11 @@ ****************************************************************************** * * $Log$ + * Revision 1.7 2005/02/16 21:14:47 jonathan + * Further wxPython 2.5 changes using patches from Daniel Calvelo Aros + * so that that wxproj doesn't crash. Added GUI support for selecting + * alpha channel (opacity can't be selected yet). + * * Revision 1.6 2005/02/07 19:51:13 jonathan * Removed unnecessary/unused macros. * @@ -123,6 +128,7 @@ */ #include +#include #include "gdal.h" #include "gdal_alg.h" @@ -485,7 +491,11 @@ { for (j=0; j < nRasterXSize;) { +#if wxCHECK_VERSION(2,5,3) + if (*tptr++ >= 128) c |= b; +#else if (*tptr++ < 128) c |= b; +#endif b <<= 1; if (!(++j & 7)) @@ -629,7 +639,10 @@ options = ( int )PyInt_AsLong( opts ); bMakeMask = (options & OPTS_MASK) == OPTS_MASK; + +#if wxCHECK_VERSION(2,5,3) bMakeAlpha = (options & OPTS_ALPHA) == OPTS_ALPHA; +#endif // FIXME: error if bMakeMask == bMaskAlpha @@ -917,14 +930,26 @@ { pyImageData = PyString_FromStringAndSize( ( char * )imgbuf, imglen); - if (bEnableDstAlpha && maskbuf != NULL) + pyReturnData = PyTuple_New(3); + PyTuple_SetItem(pyReturnData, 0, pyImageData); + + if (bMakeAlpha && maskbuf != NULL) + { pyMaskData = PyString_FromStringAndSize( ( char * )maskbuf,masklen); + PyTuple_SetItem(pyReturnData, 1, Py_None); + PyTuple_SetItem(pyReturnData, 2, pyMaskData); + } + else if (bMakeMask && maskbuf != NULL) + { + pyMaskData = PyString_FromStringAndSize( ( char * )maskbuf,masklen); + PyTuple_SetItem(pyReturnData, 1, pyMaskData); + PyTuple_SetItem(pyReturnData, 2, Py_None); + } else - pyMaskData = Py_None; - - pyReturnData = PyTuple_New(2); - PyTuple_SetItem(pyReturnData, 0, pyImageData); - PyTuple_SetItem(pyReturnData, 1, pyMaskData); + { + PyTuple_SetItem(pyReturnData, 1, Py_None); + PyTuple_SetItem(pyReturnData, 2, Py_None); + } if (imgbuf != NULL) { CPLFree(imgbuf); imgbuf = NULL; } if (maskbuf != NULL) { CPLFree(maskbuf); maskbuf = NULL; } Index: wxproj.cpp =================================================================== RCS file: /thubanrepository/thuban/libraries/thuban/wxproj.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- wxproj.cpp 25 Feb 2004 10:33:24 -0000 1.4 +++ wxproj.cpp 16 Feb 2005 21:14:47 -0000 1.5 @@ -10,11 +10,11 @@ * data with proj4 and draw it on a wxWindows DC */ +#include + #include #include -#include - #include #include "pyshapelib_api.h" @@ -31,50 +31,22 @@ #include -static PyShapeLibAPI * pyshapelib_api; - -/* helper function to extract the pointer value from a swig ptr string +/* For wx2.5, we cannot just extract the address of the object from the + * Python string repr; we need to go through the Swig mechanisms + */ +#include "swigPtrConvertHack.h" +//#include +/* We only need this prototype from the above (big) include: + * + * bool wxPyConvertSwigPtr( PyObject* obj, void **ptr, const wxChar* className); + * + * but it is a macro involving a large struct and static variables, so we + * can't just get along with a prototype. + * Trouble is this file is not installed by default on Debian. */ -static void * -decode_pointer(char *string) -{ - unsigned long p = 0; - - /* Pointer values must start with leading underscore */ - if (*string == '_') - { - string++; - /* Extract hex value from pointer */ - while (*string) - { - if ((*string >= '0') && (*string <= '9')) - p = (p << 4) + (*string - '0'); - else if ((*string >= 'a') && (*string <= 'f')) - p = (p << 4) + ((*string - 'a') + 10); - else - break; - string++; - } - } - return (void*)p; -} - -/* Return the object wrapped by the SWIG shadow object shadow */ -static void* -get_pointer(PyObject* shadow) -{ - PyObject * string; - void * result = NULL; - string = PyObject_GetAttrString(shadow, "this"); - if (string && PyString_Check(string)) - { - result = decode_pointer(PyString_AsString(string)); - } - Py_XDECREF(string); +static PyShapeLibAPI * pyshapelib_api; - return result; -} /* Extract a pointer from a python object that has a cobject method. * @@ -289,19 +261,18 @@ draw_info->py_dc = py_dc; Py_INCREF(draw_info->py_dc); - draw_info->dc = (wxDC*)get_pointer(draw_info->py_dc); - if (!draw_info->dc) + if (!wxPyConvertSwigPtr( py_dc, (void**)&(draw_info->dc), wxT("wxDC") )) { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_TypeError, "third argument must be a wxDC instance"); - goto fail; + goto fail; } - + draw_info->py_forward = py_forward; Py_INCREF(draw_info->py_forward); if (!extract_pointer(draw_info->py_forward, &draw_info->forward)) - goto fail; - + goto fail; + draw_info->py_inverse = py_inverse; Py_INCREF(draw_info->py_inverse); if (!extract_pointer(draw_info->py_inverse, &draw_info->inverse)) @@ -351,8 +322,7 @@ } else { - pen = (wxPen*)get_pointer(pen_shadow); - if (!pen) + if (!wxPyConvertSwigPtr( pen_shadow, (void**)&pen, wxT("wxPen"))) { PyErr_SetString(PyExc_TypeError, "fourth argument must be a wxPen instance or None"); @@ -366,8 +336,7 @@ } else { - brush = (wxBrush*)get_pointer(brush_shadow); - if (!brush) + if (!wxPyConvertSwigPtr( brush_shadow, (void**)&brush, wxT("wxBrush"))) { PyErr_SetString(PyExc_TypeError, "fifth argument must be a wxBrush instance or None"); From cvs at intevation.de Thu Feb 17 00:13:21 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 17 Feb 2005 00:13:21 +0100 (CET) Subject: jan: thuban/Thuban/Model label.py,1.2,1.3 Message-ID: <20050216231321.D1594102BE6@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Thuban/Model In directory doto:/tmp/cvs-serv8895 Modified Files: label.py Log Message: Added import of _. (Label, Label.__init__): Improved/added doc string. LabelLayer, LabelLayer.__init__, LabelLayer.Labels, LabelLayer.RemoveLabel, LabelLayer.ClearLabels): Improved/added doc string. (LabelLayer.AddLabel): Use already defined names for align strings and improved doc string. (LabelLayer.TreeInfo): New. Return the object data for the tree view. Index: label.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/Model/label.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- label.py 30 Jul 2002 14:15:39 -0000 1.2 +++ label.py 16 Feb 2005 23:13:19 -0000 1.3 @@ -1,4 +1,4 @@ -# Copyright (c) 2001, 2002 by Intevation GmbH +# Copyright (c) 2001, 2002, 2005 by Intevation GmbH # Authors: # Bernhard Herzog # @@ -7,6 +7,8 @@ __version__ = "$Revision$" +from Thuban import _ + from messages import CHANGED from base import TitledObject, Modifiable @@ -20,7 +22,13 @@ class Label: + """This class repesents a single label that is + defined by its coordinate, the text as well + as vertical and horizontal alignment concerning + the coordinate.""" + def __init__(self, x, y, text, halign, valign): + """Initialize the label with the given parameters.""" self.x = x self.y = y self.text = text @@ -30,23 +38,49 @@ class LabelLayer(TitledObject, Modifiable): + """This represent a layer holding a number of labels.""" + def __init__(self, title): + """Initialize the LabeleLayer with an empty + list of labels and set the title to "title". + """ TitledObject.__init__(self, title) Modifiable.__init__(self) self.labels = [] def Labels(self): + """Return a list of all labels.""" return self.labels - def AddLabel(self, x, y, text, halign = "left", valign="center"): + def AddLabel(self, x, y, text, halign = ALIGN_LEFT, + valign = ALIGN_CENTER): + """Add a label at position (x,y) with contents "text". + + This will emit a CHANGED signal. + """ self.labels.append(Label(x, y, text, halign, valign)) self.changed(CHANGED) def RemoveLabel(self, index): + """Remove the label specified by index. + + This will emit a CHANGED signal. + """ del self.labels[index] self.changed(CHANGED) def ClearLabels(self): - """Remove all labels""" + """Remove all labels. + + This will emit a CHANGED signal. + """ del self.labels[:] self.changed(CHANGED) + + def TreeInfo(self): + """Return a tuple of (title, tupel) describing the contents + of the object in a tree-structure. + """ + items = [] + items.append(_("Number of labels: %d") % len(self.labels)) + return (_("Label Layer: %s") % self.title, items) From cvs at intevation.de Thu Feb 17 00:14:37 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 17 Feb 2005 00:14:37 +0100 (CET) Subject: jan: thuban/Thuban/Model map.py,1.18,1.19 Message-ID: <20050216231437.EABA7102BE6@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Thuban/Model In directory doto:/tmp/cvs-serv8932 Modified Files: map.py Log Message: (Map, Map.Destroy, Map.RemoveLayer, Map.ClearLayers, Map.Layers, Map.HasLayers, Map.MoveLayerToTop, Map.RaiseLayer, Map.LowerLayer, Map.MoveLayerToBottom, Map.ProjectedBoundingBox, Map.GetProjection): Improved/added doc string. (Map.BoundingBox): Removed superfluous test for label_layer and improved doc string. (Map.TreeInfo): Added label_layer and improved sdo string. Index: map.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/Model/map.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- map.py 10 Jul 2003 14:53:15 -0000 1.18 +++ map.py 16 Feb 2005 23:14:35 -0000 1.19 @@ -1,6 +1,7 @@ -# Copyright (c) 2001, 2002 by Intevation GmbH +# Copyright (c) 2001-2003, 2005 by Intevation GmbH # Authors: # Bernhard Herzog +# Jonathan Coles # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with Thuban for details. @@ -21,7 +22,9 @@ class Map(TitledObject, Modifiable): - """Represent a map. A map is simply a list of layers. + """Represent a map. A map is a list of layers. Additionally + there is a special label layer containing all labels that + are defined for the map. Map objects send the following message types: @@ -50,10 +53,14 @@ self.projection = projection def Destroy(self): - # call Modifiable.Destroy first since it will call - # Publisher.Destroy which removes all subscriptions. Otherwise - # clearing the layers results in messages to be sent which can - # cause problems. + """Destroys the map object with all layers including + the label layer. + + Calls Modifiable.Destroy first since it will call + Publisher.Destroy which removes all subscriptions. Otherwise + clearing the layers results in messages to be sent which can + cause problems. + """ Modifiable.Destroy(self) self.ClearLayers() self.label_layer.Unsubscribe(CHANGED, self.forward, MAP_LAYERS_CHANGED) @@ -67,7 +74,9 @@ self.changed(MAP_LAYERS_ADDED, self) def RemoveLayer(self, layer): - """Remove layer from the map.""" + """Remove layer from the map. + This can not be applied for the label layer of the map. + """ self.unsubscribe_layer_channels(layer) self.layers.remove(layer) self.changed(MAP_LAYERS_CHANGED, self) @@ -84,7 +93,9 @@ return 1 def ClearLayers(self): - """Delete all layers.""" + """Delete all layers and also remove all labels from the + label layer. + """ for layer in self.layers: self.unsubscribe_layer_channels(layer) layer.Destroy() @@ -110,15 +121,18 @@ def Layers(self): """Return the list of layers contained in the map. - The list does not include the label layer""" + The list does not include the label layer which + can be retrieved by a separate method.""" return self.layers def HasLayers(self): - """Return true if the map has at least one shape layer""" + """Return true if the map has at least one layer other + than the label layer.""" return len(self.layers) > 0 def MoveLayerToTop(self, layer): - """Put the layer on top of the layer stack. + """Put the layer on top of the layer stack. This can not + be applied to the label layer. If the layer is already at the top do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -130,9 +144,9 @@ self.changed(MAP_LAYERS_CHANGED, self) self.changed(MAP_STACKING_CHANGED, self) - def RaiseLayer(self, layer): - """Swap the layer with the one above it. + """Swap the layer with the one above it. This does + not apply to the label layer. If the layer is already at the top do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -145,7 +159,8 @@ self.changed(MAP_STACKING_CHANGED, self) def LowerLayer(self, layer): - """Swap the layer with the one below it. + """Swap the layer with the one below it. This does + not apply to the label layer. If the layer is already at the bottom do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -158,7 +173,8 @@ self.changed(MAP_STACKING_CHANGED, self) def MoveLayerToBottom(self, layer): - """Put the layer at the bottom of the stack. + """Put the layer at the bottom of the stack. This does + not apply to the label layer. If the layer is already at the bottom do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -172,8 +188,11 @@ def BoundingBox(self): """Return the bounding box of the map in Lat/Lon coordinates. + The label layer is not considered for the computation of the + bounding box. - Return None if there are no layers or no layer contains any shapes. + Return None if there are no layers (except the label layer) or + no layer contains any shapes. """ if not self.layers: return None @@ -182,8 +201,6 @@ urx = [] ury = [] for layer in self.layers: - if layer is self.label_layer: - continue # the layer's bbox may be None if it doesn't have any shapes bbox = layer.LatLongBoundingBox() if bbox is not None: @@ -201,8 +218,11 @@ def ProjectedBoundingBox(self): """Return the bounding box of the map in projected coordinates. + The label layer is not considered for the computation of the + bounding box. - Return None if there are no layers or no layer contains any shapes. + Return None if there are no layers (except the label layer) or + no layer contains any shapes. """ # This simply returns the rectangle given by the projected # corners of the non-projected bbox. @@ -212,6 +232,7 @@ return bbox def GetProjection(self): + """Return the projection of the map.""" return self.projection def SetProjection(self, projection): @@ -246,6 +267,9 @@ self.label_layer.UnsetModified() def TreeInfo(self): + """Return a tuple of (title, tupel) describing the contents + of the object in a tree-structure. + """ items = [] if self.BoundingBox() != None: items.append(_("Extent (lat-lon): (%g, %g, %g, %g)") @@ -260,6 +284,6 @@ layers = self.layers[:] layers.reverse() items.extend(layers) + items.append(self.label_layer) return (_("Map: %s") % self.title, items) - From cvs at intevation.de Thu Feb 17 00:16:16 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 17 Feb 2005 00:16:16 +0100 (CET) Subject: jan: thuban ChangeLog,1.784,1.785 Message-ID: <20050216231616.DC842102BE6@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv8962 Modified Files: ChangeLog Log Message: Docstring improvements and minor fixes for labellayer. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.784 retrieving revision 1.785 diff -u -d -r1.784 -r1.785 --- ChangeLog 16 Feb 2005 21:14:47 -0000 1.784 +++ ChangeLog 16 Feb 2005 23:16:14 -0000 1.785 @@ -1,3 +1,27 @@ +2005-02-17 Jan-Oliver Wagner + + Docstring improvements and minor fixes for labellayer. + + * Thuban/Model/map.py: + (Map, Map.Destroy, Map.RemoveLayer, Map.ClearLayers, + Map.Layers, Map.HasLayers, Map.MoveLayerToTop, + Map.RaiseLayer, Map.LowerLayer, Map.MoveLayerToBottom, + Map.ProjectedBoundingBox, Map.GetProjection): Improved/added + doc string. + (Map.BoundingBox): Removed superfluous test for label_layer + and improved doc string. + (Map.TreeInfo): Added label_layer and improved sdo string. + + * Thuban/Model/label.py: Added import of _. + (Label, Label.__init__): Improved/added doc string. + (LabelLayer, LabelLayer.__init__, LabelLayer.Labels, + LabelLayer.RemoveLabel, LabelLayer.ClearLabels): + Improved/added doc string. + (LabelLayer.AddLabel): Use already defined names for + align strings and improved doc string. + (LabelLayer.TreeInfo): New. Return the object data for + the tree view. + 2005-02-16 Jonathan Coles Further wxPython 2.5 changes using patches from Daniel Calvelo Aros From cvs at intevation.de Thu Feb 17 00:21:13 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 17 Feb 2005 00:21:13 +0100 (CET) Subject: jan: thuban/Thuban/Model label.py,1.2,1.2.4.1 Message-ID: <20050216232113.EA2E0102BE6@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Thuban/Model In directory doto:/tmp/cvs-serv9036 Modified Files: Tag: thuban-1-0-branch label.py Log Message: Added import of _. (Label, Label.__init__): Improved/added doc string. (LabelLayer, LabelLayer.__init__, LabelLayer.Labels, LabelLayer.RemoveLabel, LabelLayer.ClearLabels): Improved/added doc string. (LabelLayer.AddLabel): Use already defined names for align strings and improved doc string. (LabelLayer.TreeInfo): New. Return the object data for the tree view. Index: label.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/Model/label.py,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -d -r1.2 -r1.2.4.1 --- label.py 30 Jul 2002 14:15:39 -0000 1.2 +++ label.py 16 Feb 2005 23:21:11 -0000 1.2.4.1 @@ -7,6 +7,8 @@ __version__ = "$Revision$" +from Thuban import _ + from messages import CHANGED from base import TitledObject, Modifiable @@ -20,7 +22,13 @@ class Label: + """This class repesents a single label that is + defined by its coordinate, the text as well + as vertical and horizontal alignment concerning + the coordinate.""" + def __init__(self, x, y, text, halign, valign): + """Initialize the label with the given parameters.""" self.x = x self.y = y self.text = text @@ -30,23 +38,49 @@ class LabelLayer(TitledObject, Modifiable): + """This represent a layer holding a number of labels.""" + def __init__(self, title): + """Initialize the LabeleLayer with an empty + list of labels and set the title to "title". + """ TitledObject.__init__(self, title) Modifiable.__init__(self) self.labels = [] def Labels(self): + """Return a list of all labels.""" return self.labels - def AddLabel(self, x, y, text, halign = "left", valign="center"): + def AddLabel(self, x, y, text, halign = ALIGN_LEFT, + valign = ALIGN_CENTER): + """Add a label at position (x,y) with contents "text". + + This will emit a CHANGED signal. + """ self.labels.append(Label(x, y, text, halign, valign)) self.changed(CHANGED) def RemoveLabel(self, index): + """Remove the label specified by index. + + This will emit a CHANGED signal. + """ del self.labels[index] self.changed(CHANGED) def ClearLabels(self): - """Remove all labels""" + """Remove all labels. + + This will emit a CHANGED signal. + """ del self.labels[:] self.changed(CHANGED) + + def TreeInfo(self): + """Return a tuple of (title, tupel) describing the contents + of the object in a tree-structure. + """ + items = [] + items.append(_("Number of labels: %d") % len(self.labels)) + return (_("Label Layer: %s") % self.title, items) From cvs at intevation.de Thu Feb 17 00:21:49 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 17 Feb 2005 00:21:49 +0100 (CET) Subject: jan: thuban/Thuban/Model map.py,1.18,1.18.2.1 Message-ID: <20050216232149.49342102C0F@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Thuban/Model In directory doto:/tmp/cvs-serv9070 Modified Files: Tag: thuban-1-0-branch map.py Log Message: (Map, Map.Destroy, Map.RemoveLayer, Map.ClearLayers, Map.Layers, Map.HasLayers, Map.MoveLayerToTop, Map.RaiseLayer, Map.LowerLayer, Map.MoveLayerToBottom, Map.ProjectedBoundingBox, Map.GetProjection): Improved/added doc string. (Map.BoundingBox): Removed superfluous test for label_layer and improved doc string. (Map.TreeInfo): Added label_layer and improved sdo string. Index: map.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/Model/map.py,v retrieving revision 1.18 retrieving revision 1.18.2.1 diff -u -d -r1.18 -r1.18.2.1 --- map.py 10 Jul 2003 14:53:15 -0000 1.18 +++ map.py 16 Feb 2005 23:21:47 -0000 1.18.2.1 @@ -21,7 +21,9 @@ class Map(TitledObject, Modifiable): - """Represent a map. A map is simply a list of layers. + """Represent a map. A map is a list of layers. Additionally + there is a special label layer containing all labels that + are defined for the map. Map objects send the following message types: @@ -50,10 +52,14 @@ self.projection = projection def Destroy(self): - # call Modifiable.Destroy first since it will call - # Publisher.Destroy which removes all subscriptions. Otherwise - # clearing the layers results in messages to be sent which can - # cause problems. + """Destroys the map object with all layers including + the label layer. + + Calls Modifiable.Destroy first since it will call + Publisher.Destroy which removes all subscriptions. Otherwise + clearing the layers results in messages to be sent which can + cause problems. + """ Modifiable.Destroy(self) self.ClearLayers() self.label_layer.Unsubscribe(CHANGED, self.forward, MAP_LAYERS_CHANGED) @@ -67,7 +73,9 @@ self.changed(MAP_LAYERS_ADDED, self) def RemoveLayer(self, layer): - """Remove layer from the map.""" + """Remove layer from the map. + This can not be applied for the label layer of the map. + """ self.unsubscribe_layer_channels(layer) self.layers.remove(layer) self.changed(MAP_LAYERS_CHANGED, self) @@ -84,7 +92,9 @@ return 1 def ClearLayers(self): - """Delete all layers.""" + """Delete all layers and also remove all labels from the + label layer. + """ for layer in self.layers: self.unsubscribe_layer_channels(layer) layer.Destroy() @@ -110,15 +120,18 @@ def Layers(self): """Return the list of layers contained in the map. - The list does not include the label layer""" + The list does not include the label layer which + can be retrieved by a separate method.""" return self.layers def HasLayers(self): - """Return true if the map has at least one shape layer""" + """Return true if the map has at least one layer other + than the label layer.""" return len(self.layers) > 0 def MoveLayerToTop(self, layer): - """Put the layer on top of the layer stack. + """Put the layer on top of the layer stack. This can not + be applied to the label layer. If the layer is already at the top do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -130,9 +143,9 @@ self.changed(MAP_LAYERS_CHANGED, self) self.changed(MAP_STACKING_CHANGED, self) - def RaiseLayer(self, layer): - """Swap the layer with the one above it. + """Swap the layer with the one above it. This does + not apply to the label layer. If the layer is already at the top do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -145,7 +158,8 @@ self.changed(MAP_STACKING_CHANGED, self) def LowerLayer(self, layer): - """Swap the layer with the one below it. + """Swap the layer with the one below it. This does + not apply to the label layer. If the layer is already at the bottom do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -158,7 +172,8 @@ self.changed(MAP_STACKING_CHANGED, self) def MoveLayerToBottom(self, layer): - """Put the layer at the bottom of the stack. + """Put the layer at the bottom of the stack. This does + not apply to the label layer. If the layer is already at the bottom do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -172,8 +187,11 @@ def BoundingBox(self): """Return the bounding box of the map in Lat/Lon coordinates. + The label layer is not considered for the computation of the + bounding box. - Return None if there are no layers or no layer contains any shapes. + Return None if there are no layers (except the label layer) or + no layer contains any shapes. """ if not self.layers: return None @@ -182,8 +200,6 @@ urx = [] ury = [] for layer in self.layers: - if layer is self.label_layer: - continue # the layer's bbox may be None if it doesn't have any shapes bbox = layer.LatLongBoundingBox() if bbox is not None: @@ -201,8 +217,11 @@ def ProjectedBoundingBox(self): """Return the bounding box of the map in projected coordinates. + The label layer is not considered for the computation of the + bounding box. - Return None if there are no layers or no layer contains any shapes. + Return None if there are no layers (except the label layer) or + no layer contains any shapes. """ # This simply returns the rectangle given by the projected # corners of the non-projected bbox. @@ -212,6 +231,7 @@ return bbox def GetProjection(self): + """Return the projection of the map.""" return self.projection def SetProjection(self, projection): @@ -246,6 +266,9 @@ self.label_layer.UnsetModified() def TreeInfo(self): + """Return a tuple of (title, tupel) describing the contents + of the object in a tree-structure. + """ items = [] if self.BoundingBox() != None: items.append(_("Extent (lat-lon): (%g, %g, %g, %g)") @@ -260,6 +283,6 @@ layers = self.layers[:] layers.reverse() items.extend(layers) + items.append(self.label_layer) return (_("Map: %s") % self.title, items) - From cvs at intevation.de Thu Feb 17 00:22:31 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 17 Feb 2005 00:22:31 +0100 (CET) Subject: jan: thuban ChangeLog,1.624.2.37,1.624.2.38 Message-ID: <20050216232231.11C4D102C0F@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv9090 Modified Files: Tag: thuban-1-0-branch ChangeLog Log Message: Backport from HEAD: Docstring improvements and minor fixes for labellayer. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.624.2.37 retrieving revision 1.624.2.38 diff -u -d -r1.624.2.37 -r1.624.2.38 --- ChangeLog 7 Feb 2005 14:09:36 -0000 1.624.2.37 +++ ChangeLog 16 Feb 2005 23:22:28 -0000 1.624.2.38 @@ -1,3 +1,27 @@ +2005-02-17 Jan-Oliver Wagner + + Backport from HEAD: Docstring improvements and minor fixes for labellayer. + + * Thuban/Model/map.py: + (Map, Map.Destroy, Map.RemoveLayer, Map.ClearLayers, + Map.Layers, Map.HasLayers, Map.MoveLayerToTop, + Map.RaiseLayer, Map.LowerLayer, Map.MoveLayerToBottom, + Map.ProjectedBoundingBox, Map.GetProjection): Improved/added + doc string. + (Map.BoundingBox): Removed superfluous test for label_layer + and improved doc string. + (Map.TreeInfo): Added label_layer and improved sdo string. + + * Thuban/Model/label.py: Added import of _. + (Label, Label.__init__): Improved/added doc string. + (LabelLayer, LabelLayer.__init__, LabelLayer.Labels, + LabelLayer.RemoveLabel, LabelLayer.ClearLabels): + Improved/added doc string. + (LabelLayer.AddLabel): Use already defined names for + align strings and improved doc string. + (LabelLayer.TreeInfo): New. Return the object data for + the tree view. + 2005-02-07 Bernhard Reiter * Thuban/UI/classifier.py (ClassGrid.DeleteSelectedRows): From jan at intevation.de Thu Feb 17 00:28:34 2005 From: jan at intevation.de (Jan-Oliver Wagner) Date: Thu, 17 Feb 2005 00:28:34 +0100 Subject: an oopsie? In-Reply-To: <20041227140150.GB26155@intevation.de> References: <16843.48530.709140.712526@desk.crynwr.com> <20041227140150.GB26155@intevation.de> Message-ID: <20050216232834.GA26063@intevation.de> On Mon, Dec 27, 2004 at 03:01:50PM +0100, Jan-Oliver Wagner wrote: > On Fri, Dec 24, 2004 at 01:56:18AM -0500, Russell Nelson wrote: > > Hmmmmm. Thuban/Model/map.py says this: > > > > def Layers(self): > > """Return the list of layers contained in the map. > > > > The list does not include the label layer""" > > return self.layers > > > > and yet later does this in BoundingBox: > > > > for layer in self.layers: > > if layer is self.label_layer: > > continue > > > > I can't see how both of those can be correct. If the first is wrong, > > there might be a bug hiding. If the second is wrong, it's just a few > > wasted cycles. > > I think it is the second. > Attached is a patch that primarily adds/extends doc strings > and removes the above mentioned lines as well as adds LabelLayer > to the TreeInfo output. > > Bernhard Herzog: OK to commit? > If so, OK to backport to 1_0? I finally committed since I received no feedback. Thanks to Russel for pointing this out. Though it was not a dangerous bug, his comment made me write quite some doc strings :-) Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From bh at intevation.de Thu Feb 17 11:39:12 2005 From: bh at intevation.de (Bernhard Herzog) Date: Thu, 17 Feb 2005 11:39:12 +0100 Subject: jonathan: thuban/test test_baserenderer.py, 1.10, 1.11 test_layer.py, 1.34, 1.35 In-Reply-To: <20050216211449.B1DEA102C24@lists.intevation.de> (cvs@intevation.de's message of "Wed, 16 Feb 2005 22:14:49 +0100 (CET)") References: <20050216211449.B1DEA102C24@lists.intevation.de> Message-ID: cvs at intevation.de writes: > Index: test_baserenderer.py [...] > + if versions['wxPython-tuple'] < (2,5,3): > + raw_mask = binascii.a2b_base64( > + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' > + 'AAAAAAAAAAAAAAAAAAA\n') > + else: > + raw_mask = binascii.a2b_base64( > + '//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P/' > + '/8P//8P//8P//8P//8P\n') Why does this depend on the wx Version? Baserenderer must not depend on any GUI library specific things. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From bh at intevation.de Thu Feb 17 11:45:13 2005 From: bh at intevation.de (Bernhard Herzog) Date: Thu, 17 Feb 2005 11:45:13 +0100 Subject: jan: thuban/Thuban/Model map.py,1.18,1.19 In-Reply-To: <20050216231437.EABA7102BE6@lists.intevation.de> (cvs@intevation.de's message of "Thu, 17 Feb 2005 00:14:37 +0100 (CET)") References: <20050216231437.EABA7102BE6@lists.intevation.de> Message-ID: cvs at intevation.de writes: > class Map(TitledObject, Modifiable): > > - """Represent a map. A map is simply a list of layers. > + """Represent a map. A map is a list of layers. Additionally > + there is a special label layer containing all labels that > + are defined for the map. Could you -- and any anybody else writing doc-strings, of course -- please follow the coding_guidelines: - Every class, function and method should have a doc string. The doc string should start with a brief one-line description of the class or method. If more explanations are needed add an empty line and one or more paragraphs. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From bh at intevation.de Thu Feb 17 11:57:17 2005 From: bh at intevation.de (Bernhard Herzog) Date: Thu, 17 Feb 2005 11:57:17 +0100 Subject: [solved] wxproj.cpp and wx2.5 In-Reply-To: <1108568503.12009.60.camel@localhost.localdomain> (Jonathan Coles's message of "Wed, 16 Feb 2005 10:41:43 -0500") References: <20050215073142.M4672@minag.gob.pe> <1108560538.12009.48.camel@localhost.localdomain> <20050216152038.M82536@minag.gob.pe> <1108568503.12009.60.camel@localhost.localdomain> Message-ID: Jonathan Coles writes: > well, it's not ideal. it would be much better, of course, to rely on > wxPython.h being available. for the time being, however, this at least > allows us to work with wx2.5. How difficult would it be to expand setup.py a little to determine whether the necessary headerfiles are installed? If they are installed we should use the installed ones instead of using the copy shipped with Thuban. We should also file bug reports with the distributors that don't package the files so that hopefully at one point we can remove our copy and rely on these files to be installed. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Thu Feb 17 12:02:30 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 17 Feb 2005 12:02:30 +0100 (CET) Subject: jan: thuban/Thuban/Model map.py,1.19,1.20 label.py,1.3,1.4 Message-ID: <20050217110230.57919102C17@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Thuban/Model In directory doto:/tmp/cvs-serv18360 Modified Files: map.py label.py Log Message: Fixed doc-strings to comply with coding_guidelines. Index: map.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/Model/map.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- map.py 16 Feb 2005 23:14:35 -0000 1.19 +++ map.py 17 Feb 2005 11:02:28 -0000 1.20 @@ -22,7 +22,9 @@ class Map(TitledObject, Modifiable): - """Represent a map. A map is a list of layers. Additionally + """Represent a map. + + A map is a list of layers. Additionally there is a special label layer containing all labels that are defined for the map. @@ -53,10 +55,9 @@ self.projection = projection def Destroy(self): - """Destroys the map object with all layers including - the label layer. + """Destroys the map object with all layers including the label layer. - Calls Modifiable.Destroy first since it will call + Calls Modifiable. Destroy first since it will call Publisher.Destroy which removes all subscriptions. Otherwise clearing the layers results in messages to be sent which can cause problems. @@ -75,6 +76,7 @@ def RemoveLayer(self, layer): """Remove layer from the map. + This can not be applied for the label layer of the map. """ self.unsubscribe_layer_channels(layer) @@ -93,8 +95,7 @@ return 1 def ClearLayers(self): - """Delete all layers and also remove all labels from the - label layer. + """Delete all layers and also remove all labels from the label layer. """ for layer in self.layers: self.unsubscribe_layer_channels(layer) @@ -126,13 +127,16 @@ return self.layers def HasLayers(self): - """Return true if the map has at least one layer other + """Information whether this map has layers. + + Returns true if the map has at least one layer other than the label layer.""" return len(self.layers) > 0 def MoveLayerToTop(self, layer): - """Put the layer on top of the layer stack. This can not - be applied to the label layer. + """Put the layer on top of the layer stack. + + This can not be applied to the label layer. If the layer is already at the top do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -145,8 +149,9 @@ self.changed(MAP_STACKING_CHANGED, self) def RaiseLayer(self, layer): - """Swap the layer with the one above it. This does - not apply to the label layer. + """Swap the layer with the one above it. + + This does not apply to the label layer. If the layer is already at the top do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -159,8 +164,9 @@ self.changed(MAP_STACKING_CHANGED, self) def LowerLayer(self, layer): - """Swap the layer with the one below it. This does - not apply to the label layer. + """Swap the layer with the one below it. + + This does not apply to the label layer. If the layer is already at the bottom do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -173,8 +179,9 @@ self.changed(MAP_STACKING_CHANGED, self) def MoveLayerToBottom(self, layer): - """Put the layer at the bottom of the stack. This does - not apply to the label layer. + """Put the layer at the bottom of the stack. + + This does not apply to the label layer. If the layer is already at the bottom do nothing. If the stacking order has been changed, issue a MAP_LAYERS_CHANGED message. @@ -188,6 +195,7 @@ def BoundingBox(self): """Return the bounding box of the map in Lat/Lon coordinates. + The label layer is not considered for the computation of the bounding box. @@ -218,6 +226,7 @@ def ProjectedBoundingBox(self): """Return the bounding box of the map in projected coordinates. + The label layer is not considered for the computation of the bounding box. @@ -238,7 +247,8 @@ def SetProjection(self, projection): """Set the projection of the map. - Issue a MAP_PROJECTION_CHANGED message.""" + Issue a MAP_PROJECTION_CHANGED message. + """ old_proj = self.projection self.projection = projection self.changed(MAP_PROJECTION_CHANGED, self, old_proj) @@ -267,8 +277,10 @@ self.label_layer.UnsetModified() def TreeInfo(self): - """Return a tuple of (title, tupel) describing the contents - of the object in a tree-structure. + """Return a description of the object. + + A tuple of (title, tupel) describing the contents + of the object in a tree-structure is returned. """ items = [] if self.BoundingBox() != None: Index: label.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/Model/label.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- label.py 16 Feb 2005 23:13:19 -0000 1.3 +++ label.py 17 Feb 2005 11:02:28 -0000 1.4 @@ -22,10 +22,12 @@ class Label: - """This class repesents a single label that is - defined by its coordinate, the text as well + """This class repesents a single label. + + The label is defined by its coordinate, the text as well as vertical and horizontal alignment concerning - the coordinate.""" + the coordinate. + """ def __init__(self, x, y, text, halign, valign): """Initialize the label with the given parameters.""" @@ -41,7 +43,9 @@ """This represent a layer holding a number of labels.""" def __init__(self, title): - """Initialize the LabeleLayer with an empty + """Initialize the LabeleLayer. + + Initialization is done with an empty list of labels and set the title to "title". """ TitledObject.__init__(self, title) @@ -78,8 +82,10 @@ self.changed(CHANGED) def TreeInfo(self): - """Return a tuple of (title, tupel) describing the contents - of the object in a tree-structure. + """Return a description of the object. + + A tuple of (title, tupel) describing the contents + of the object in a tree-structure is returned. """ items = [] items.append(_("Number of labels: %d") % len(self.labels)) From cvs at intevation.de Thu Feb 17 12:02:48 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 17 Feb 2005 12:02:48 +0100 (CET) Subject: jan: thuban ChangeLog,1.785,1.786 Message-ID: <20050217110248.B1717102C24@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv18373 Modified Files: ChangeLog Log Message: Improved doc-strings. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.785 retrieving revision 1.786 diff -u -d -r1.785 -r1.786 --- ChangeLog 16 Feb 2005 23:16:14 -0000 1.785 +++ ChangeLog 17 Feb 2005 11:02:46 -0000 1.786 @@ -1,5 +1,10 @@ 2005-02-17 Jan-Oliver Wagner + * Thuban/Model/map.py, Thuban/Model/label.py: Fixed + doc-strings to comply with coding_guidelines. + +2005-02-17 Jan-Oliver Wagner + Docstring improvements and minor fixes for labellayer. * Thuban/Model/map.py: From jan at intevation.de Thu Feb 17 12:03:26 2005 From: jan at intevation.de (Jan-Oliver Wagner) Date: Thu, 17 Feb 2005 12:03:26 +0100 Subject: jan: thuban/Thuban/Model map.py,1.18,1.19 In-Reply-To: References: <20050216231437.EABA7102BE6@lists.intevation.de> Message-ID: <20050217110326.GA26686@intevation.de> On Thu, Feb 17, 2005 at 11:45:13AM +0100, Bernhard Herzog wrote: > cvs at intevation.de writes: > > > class Map(TitledObject, Modifiable): > > > > - """Represent a map. A map is simply a list of layers. > > + """Represent a map. A map is a list of layers. Additionally > > + there is a special label layer containing all labels that > > + are defined for the map. > > Could you -- and any anybody else writing doc-strings, of course -- > please follow the coding_guidelines: done. -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From jan at intevation.de Thu Feb 17 12:25:39 2005 From: jan at intevation.de (Jan-Oliver Wagner) Date: Thu, 17 Feb 2005 12:25:39 +0100 Subject: Finishing the extension registry feature Message-ID: <20050217112539.GA26955@intevation.de> Hi, finally I really aim to finish the extension registry feature. The most important remianing problem was that the __init__.py of a extension should not contain any GUI relevant imports or otherweise the test suite has a problem. On the other hand I wanted a single standard line in thubanstart.py for each extension to load completely. My proposal now is to define a filename (Extensions/myname/all.py) where all imports are done to fully integrate the extension into Thuban. Then, in ~/.thuban/thubanstart.py there are lines like: import Extensions.gns2shp.all This allows for later automized loading of all available Extensions (which is one of my goals). What do you think? Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From bh at intevation.de Thu Feb 17 13:54:10 2005 From: bh at intevation.de (Bernhard Herzog) Date: Thu, 17 Feb 2005 13:54:10 +0100 Subject: jonathan: thuban/test test_baserenderer.py, 1.10, 1.11 test_layer.py, 1.34, 1.35 In-Reply-To: <20050216211449.B1DEA102C24@lists.intevation.de> (cvs@intevation.de's message of "Wed, 16 Feb 2005 22:14:49 +0100 (CET)") References: <20050216211449.B1DEA102C24@lists.intevation.de> Message-ID: cvs at intevation.de writes: > Index: test_baserenderer.py > =================================================================== > diff -u -d -r1.10 -r1.11 > --- test_baserenderer.py 28 Jan 2005 15:54:00 -0000 1.10 > +++ test_baserenderer.py 16 Feb 2005 21:14:47 -0000 1.11 > @@ -32,6 +32,7 @@ > from Thuban.UI.baserenderer import BaseRenderer, \ > add_renderer_extension, init_renderer_extensions > > +from Thuban.version import versions This change breaks the test suite because Thuban.versions imports wxPython which requires X. Maybe it works with wxPython 2.5 where some initialization is delayed until wx.App is created and the test suite doesn't do that. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From jonathan at jpcoles.com Thu Feb 17 14:00:54 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Thu, 17 Feb 2005 08:00:54 -0500 Subject: jonathan: thuban/test test_baserenderer.py, 1.10, 1.11 test_layer.py, 1.34, 1.35 In-Reply-To: References: <20050216211449.B1DEA102C24@lists.intevation.de> Message-ID: <1108645254.12009.77.camel@localhost.localdomain> Am Donnerstag, den 17.02.2005, 11:39 +0100 schrieb Bernhard Herzog: > cvs at intevation.de writes: > > > Index: test_baserenderer.py > [...] > > + if versions['wxPython-tuple'] < (2,5,3): > > + raw_mask = binascii.a2b_base64( > > + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' > > + 'AAAAAAAAAAAAAAAAAAA\n') > > + else: > > + raw_mask = binascii.a2b_base64( > > + '//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P/' > > + '/8P//8P//8P//8P//8P\n') > > Why does this depend on the wx Version? Baserenderer must not depend on > any GUI library specific things. according to the wx2.4 documentation about wxMask for a wxBitmap: "the masked area is black and the unmasked area is white. When associated with a bitmap and drawn in a device context, the unmasked area of the bitmap will be drawn, and the masked area will not be drawn." this says to me, make the portions of the mask that i want drawn 1's and the other portions 0's. this is *not* the behavior under wx2.4. it is reversed. under wx2.5 the problem has been corrected (and i had to change the gdalwarp code to create a correct bitmap mask) so the results are going to be different. i understand why baserenderer shouldn't depend on wx, but the output unfortunately is for the moment. also, aren't we implicitly depending on wx for some of the other tests that check which DC calls were made? is there a better way i should do this? --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== From jonathan at jpcoles.com Thu Feb 17 14:20:03 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Thu, 17 Feb 2005 08:20:03 -0500 Subject: jonathan: thuban/test test_baserenderer.py, 1.10, 1.11 test_layer.py, 1.34, 1.35 In-Reply-To: References: <20050216211449.B1DEA102C24@lists.intevation.de> Message-ID: <1108646403.12009.83.camel@localhost.localdomain> Am Donnerstag, den 17.02.2005, 13:54 +0100 schrieb Bernhard Herzog: > This change breaks the test suite because Thuban.versions imports > wxPython which requires X. Maybe it works with wxPython 2.5 where some > initialization is delayed until wx.App is created and the test suite > doesn't do that. gah! i had even run across this. no, it doesn't happen under 2.5. do you have any ideas what can be done about depending on the wxPython version? btw, if baserenderer shouldn't depend on any gui, perhaps it should be in Model/? although some things in the tests do assume a gui of some sort...at least a DC... maybe there should be two different test suites: one for purely Model code and one for UI code. --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== From bh at intevation.de Thu Feb 17 20:37:52 2005 From: bh at intevation.de (Bernhard Herzog) Date: Thu, 17 Feb 2005 20:37:52 +0100 Subject: jonathan: thuban/test test_baserenderer.py, 1.10, 1.11 test_layer.py, 1.34, 1.35 References: <20050216211449.B1DEA102C24@lists.intevation.de> <1108646403.12009.83.camel@localhost.localdomain> Message-ID: Jonathan Coles writes: > Am Donnerstag, den 17.02.2005, 13:54 +0100 schrieb Bernhard Herzog: > >> This change breaks the test suite because Thuban.versions imports >> wxPython which requires X. Maybe it works with wxPython 2.5 where some >> initialization is delayed until wx.App is created and the test suite >> doesn't do that. > > gah! i had even run across this. no, it doesn't happen under 2.5. > > do you have any ideas what can be done about depending on the wxPython > version? The reason the tests now depend on the wxPython version is that gdalwarp produces output that depends on the version. Now, AFAICT the only reason wx.h is included by gdalwarp.cpp is version checking and that is only needed to determine whether to invert the bitmask and whether it supports a real alpha channel. The solution seems obvious then: make those two flags parameters of ProjectRasterFile. That way the return value of ProjectRasterFile does not depend on the wxWidgets version anymore and you can always test all reasonable combinations of those two flags. It also makes gdalwarp independend of wxWidgets once again. > btw, if baserenderer shouldn't depend on any gui, perhaps it should be > in Model/? One reason it's in UI is that it started out as part of the wx-specific renderer. Another is that IMO rendering is not part of the data model. Ultimately, I think, we should refactor Thuban into more than just Model and UI. Something more like Thuban.Data, Thuban.Map, Thuban.Interaction, Thuban.UI and perhaps Thuban.Renderers and more. Thuban.Interaction would be the non-GUI toolkit specific parts of Thuban.UI. We should also consider separating "Thuban the application" from "Thuban the library" a bit better. The library should be only about mechanism, any default policy would be supplied by the application. E.g. some code in Thuban.Model knows where the user's projection definitions are stored. That kind of thing should be decided by the application, not the library. > although some things in the tests do assume a gui of some > sort...at least a DC... That's why there's the MockDC and the SimpleRenderer in test_baserenderer.py. The do not depend on wxPython at all and only provide the interface the baserenderer needs. > maybe there should be two different test suites: > one for purely Model code and one for UI code. That would be useful, too. The main reason for not allowing any GUI code to be used in the tests is that importing wxPython requires a working X connection. That will be fixed for the most part with wxPython 2.5 apparently. However, if we do add test cases that really need wxPython, they should be separated from the ones that don't. Not sure how to organize that, but they should at least be in different files. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From jonathan at jpcoles.com Thu Feb 17 22:03:51 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Thu, 17 Feb 2005 16:03:51 -0500 Subject: jonathan: thuban/test test_baserenderer.py, 1.10, 1.11 test_layer.py, 1.34, 1.35 In-Reply-To: References: <20050216211449.B1DEA102C24@lists.intevation.de> <1108646403.12009.83.camel@localhost.localdomain> Message-ID: <1108674231.12009.99.camel@localhost.localdomain> Am Donnerstag, den 17.02.2005, 20:37 +0100 schrieb Bernhard Herzog: > The reason the tests now depend on the wxPython version is that gdalwarp > produces output that depends on the version. Now, AFAICT the only > reason wx.h is included by gdalwarp.cpp is version checking and that is > only needed to determine whether to invert the bitmask and whether it > supports a real alpha channel. > > The solution seems obvious then: make those two flags parameters of > ProjectRasterFile. That way the return value of ProjectRasterFile does > not depend on the wxWidgets version anymore and you can always test all > reasonable combinations of those two flags. It also makes gdalwarp > independend of wxWidgets once again. if i add extra options to ProjectRasterFile then those options will have to be set somewhere. no matter where they are set it will require querying wxPython for its version. baserenderer will have to get those values before it calls ProjectRasterFile and then the tests that use baserenderer will fail because the call chain will use wxPython. it's unclear to me how this helps this specific situation. i do agree, though, that having the options would be nicer since the version wouldn't be determined at compile time. do you have any ideas? > > btw, if baserenderer shouldn't depend on any gui, perhaps it should be > > in Model/? > > One reason it's in UI is that it started out as part of the wx-specific > renderer. Another is that IMO rendering is not part of the data model. > Ultimately, I think, we should refactor Thuban into more than just Model > and UI. Something more like Thuban.Data, Thuban.Map, > Thuban.Interaction, Thuban.UI and perhaps Thuban.Renderers and more. > Thuban.Interaction would be the non-GUI toolkit specific parts of > Thuban.UI. i think this is good idea. > > although some things in the tests do assume a gui of some > > sort...at least a DC... > > That's why there's the MockDC and the SimpleRenderer in > test_baserenderer.py. The do not depend on wxPython at all and only > provide the interface the baserenderer needs. they don't depend on the wxPython libraries themselves, but you've assumed that we are using wxPython because of the names of the calls that are tested. from a practical point of view that's ok because we only use wxPython, but from the point of view of seperating Model and UI it's not quite right. that's all i was pointing out. --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== From bh at intevation.de Fri Feb 18 11:50:04 2005 From: bh at intevation.de (Bernhard Herzog) Date: Fri, 18 Feb 2005 11:50:04 +0100 Subject: jonathan: thuban/test test_baserenderer.py, 1.10, 1.11 test_layer.py, 1.34, 1.35 In-Reply-To: <1108674231.12009.99.camel@localhost.localdomain> (Jonathan Coles's message of "Thu, 17 Feb 2005 16:03:51 -0500") References: <20050216211449.B1DEA102C24@lists.intevation.de> <1108646403.12009.83.camel@localhost.localdomain> <1108674231.12009.99.camel@localhost.localdomain> Message-ID: Jonathan Coles writes: > if i add extra options to ProjectRasterFile then those options will have > to be set somewhere. no matter where they are set it will require > querying wxPython for its version. Sure. > baserenderer will have to get those > values before it calls ProjectRasterFile and then the tests that use > baserenderer will fail because the call chain will use wxPython. There are at least two solutions: - BaseRenderer's draw_raster_layer method calls ProjectRasterFile through a new method that can be overwritten by a derived class - Add two new methods that return suitable values for the new parameters. These methods can be overwritten by derived classes. In any case the values for those flags have to be supplied by derived classes such as MapRenderer. MapRenderer does depend on wxPython so it can determine the values needed for the current version of wxPython. >> That's why there's the MockDC and the SimpleRenderer in >> test_baserenderer.py. The do not depend on wxPython at all and only >> provide the interface the baserenderer needs. > > they don't depend on the wxPython libraries themselves, but you've > assumed that we are using wxPython because of the names of the calls > that are tested. The tests assume they have a sufficiently similar interface. That doesn't mean they have to have anything to do with wxPython. If necessary you could adapt other rendering interfaces to the interface expected by the Thuban renderers. A DC is not a very good interface for that (it expects integer coordinates for example) but it was what was already implemented. Of course, one could always implement a completely new renderer that doesn't have anything in common with Thuban's current renderers. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Fri Feb 18 15:54:19 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 18 Feb 2005 15:54:19 +0100 (CET) Subject: jonathan: thuban ChangeLog,1.786,1.787 Message-ID: <20050218145419.59EB1102BC0@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv11859 Modified Files: ChangeLog Log Message: Refactored baserenderer.py and renderer.py to remove baserenderer.py's dependencies on wxPython. Added a new method projected_raster_layer() that returns a raster layer image in projected space. This must be implemented in classes derived from BaseRenderer. This also eliminates the dependency on gdal in baserenderer.py. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.786 retrieving revision 1.787 diff -u -d -r1.786 -r1.787 --- ChangeLog 17 Feb 2005 11:02:46 -0000 1.786 +++ ChangeLog 18 Feb 2005 14:54:17 -0000 1.787 @@ -1,3 +1,38 @@ +2005-02-18 Jonathan Coles + + Refactored baserenderer.py and renderer.py to remove baserenderer.py's + dependencies on wxPython. Added a new method projected_raster_layer() + that returns a raster layer image in projected space. This must be + implemented in classes derived from BaseRenderer. This also eliminates + the dependency on gdal in baserenderer.py. + + * Thuban/UI/baserenderer.py (BaseRenderer.draw_raster_layer): Call + new projected_raster_layer() to get projected raster image instead + of directly calling ProjectRasterFile(). + (BaseRenderer.projected_raster_layer): New. This must be implemented + by derived classes. It takes almost the same arguments as ProjectRasterFile + did and returns a projected image with mask and alpha data (if requested). + (BaseRenderer.render_map_incrementally): Remove the check for gdal since + that check will be done in MapRenderer.projected_raster_layer(). This + also allows other implementations to use different projection code. + + * Thuban/UI/renderer.py (MapRenderer.projected_raster_layer): + Implementation of BaseRenderer.projected_raster_layer. Checks for + gdal support and wxPython version. Also handles exceptions from + ProjectRasterFile. + + * libraries/thuban/gdalwarp.cpp: Removed checks for wxPython versions + and added a variable which can be set through the options argument + of ProjectRasterFile. + + * test/test_baserenderer.py (SimpleRenderer.projected_raster_layer): New. + Calls ProjectRasterFile and returns the result. + (TestBaseRenderer.test_projected_raster_layer): New. Tests the results + of calling projected_raster_layer() with different options. + (TestBaseRenderer.test_raster_no_projection): Removed tests based on + wxPython version and all tests of masks and alpha channels. These are + now in test_projected_raster_layer(). + 2005-02-17 Jan-Oliver Wagner * Thuban/Model/map.py, Thuban/Model/label.py: Fixed From cvs at intevation.de Fri Feb 18 15:54:19 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 18 Feb 2005 15:54:19 +0100 (CET) Subject: jonathan: thuban/Thuban/UI baserenderer.py, 1.17, 1.18 renderer.py, 1.57, 1.58 Message-ID: <20050218145419.57EE1100174@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv11859/Thuban/UI Modified Files: baserenderer.py renderer.py Log Message: Refactored baserenderer.py and renderer.py to remove baserenderer.py's dependencies on wxPython. Added a new method projected_raster_layer() that returns a raster layer image in projected space. This must be implemented in classes derived from BaseRenderer. This also eliminates the dependency on gdal in baserenderer.py. Index: baserenderer.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/baserenderer.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- baserenderer.py 16 Feb 2005 21:14:47 -0000 1.17 +++ baserenderer.py 18 Feb 2005 14:54:17 -0000 1.18 @@ -30,8 +30,6 @@ import Thuban.Model.resource -if Thuban.Model.resource.has_gdal_support(): - from gdalwarp import ProjectRasterFile # @@ -192,8 +190,7 @@ if isinstance(layer, Layer): for i in self.draw_shape_layer_incrementally(layer): yield True - elif isinstance(layer, RasterLayer) \ - and Thuban.Model.resource.has_gdal_support(): + elif isinstance(layer, RasterLayer): self.draw_raster_layer(layer) yield True else: @@ -443,10 +440,10 @@ def draw_raster_layer(self, layer): """Draw the raster layer - This implementation does the projection and scaling of the data - as required by the layer's and map's projections and the scale - and offset of the renderer and then hands the transformed data - to self.draw_raster_data() which has to be implemented in + This implementation uses self.projected_raster_layer() to project + and scale the data as required by the layer's and map's projections + and the scale and offset of the renderer and then hands the transformed + data to self.draw_raster_data() which has to be implemented in derived classes. """ offx, offy = self.offset @@ -483,24 +480,47 @@ width = int(min(width, round(fmax[0] - fmin[0] + 1))) height = int(min(height, round(fmax[1] - fmin[1] + 1))) - try: - options = 0 - options = options | layer.MaskType() - - project_params = (layer.GetImageFilename(), in_proj, out_proj, - (xmin, ymin, xmax, ymax), "", (width, height), - options) + options = 0 + options = options | layer.MaskType() - data = (width, height, apply(ProjectRasterFile, project_params)) + img_data = self.projected_raster_layer(layer, in_proj, out_proj, + (xmin,ymin,xmax,ymax), [0,0], (width, height), options) - except (MemoryError, IOError, AttributeError, ValueError): - # Why does this catch AttributeError and ValueError? - # FIXME: The exception should be communicated to the user - # better. - traceback.print_exc() - else: + if img_data is not None: + data = (width, height, img_data) self.draw_raster_data(fmin[0]+offx, offy-fmax[1], data, "RAW") data = None + + def projected_raster_layer(self, layer, srcProj, dstProj, extents, + resolution, dimensions, options): + """Return the projected raster image associated with the layer. + + The returned value will be a tuple of the form + + (image_data, mask_data, alpha_data) + + suitable for the data parameter to draw_raster_data. + + The return value may be None if raster projections are not supported. + + srcProj -- a string describing the source projection + dstProj -- a string describing the destination projection + extents -- a tuple of the region to project in map coordinates + resolution -- (currently not used, defaults to [0,0]) + dimensions -- a tuple (width, height) for the output image + options -- bit-wise options to pass to the renderer + + the currently supported values for options are + + OPTS_MASK = 1 -- generate a mask + OPTS_ALPHA = 2 -- generate an alpha channel + OPTS_INVERT_MASK = 4 -- invert the values in the mask + (if generated) + + This method has to be implemented by derived classes. + """ + + raise NotImplementedError def draw_raster_data(self, x, y, data, format="BMP"): """Draw the raster image in data onto the DC with the top Index: renderer.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/renderer.py,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- renderer.py 16 Feb 2005 21:14:47 -0000 1.57 +++ renderer.py 18 Feb 2005 14:54:17 -0000 1.58 @@ -45,6 +45,9 @@ from Thuban.version import versions +if Thuban.Model.resource.has_gdal_support(): + from gdalwarp import ProjectRasterFile + # Map the strings used for the format parameter of the draw_raster_data # method to the appropriate wxWindows constants @@ -107,6 +110,30 @@ def label_font(self): return wxFont(int(round(self.resolution * 10)), wxSWISS, wxNORMAL, wxNORMAL) + + def projected_raster_layer(self, layer, srcProj, dstProj, extents, + resolution, dimensions, options): + + ret = None + + if Thuban.Model.resource.has_gdal_support(): + + if versions['wxPython-tuple'] < (2,5,3): + options = options | 4 # INVERT_MASK_BITS + options = options & ~2 # ALPHA_MASK not supported + + try: + ret = ProjectRasterFile(layer.GetImageFilename(), + srcProj, dstProj, + extents, resolution, dimensions, + options) + except (MemoryError, IOError, AttributeError, ValueError): + # Why does this catch AttributeError and ValueError? + # FIXME: The exception should be communicated to the user + # better. + traceback.print_exc() + + return ret def draw_raster_data(self, x,y, data, format = 'BMP'): From cvs at intevation.de Fri Feb 18 15:54:19 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 18 Feb 2005 15:54:19 +0100 (CET) Subject: jonathan: thuban/test test_baserenderer.py,1.11,1.12 Message-ID: <20050218145419.66377102BFF@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban/test In directory doto:/tmp/cvs-serv11859/test Modified Files: test_baserenderer.py Log Message: Refactored baserenderer.py and renderer.py to remove baserenderer.py's dependencies on wxPython. Added a new method projected_raster_layer() that returns a raster layer image in projected space. This must be implemented in classes derived from BaseRenderer. This also eliminates the dependency on gdal in baserenderer.py. Index: test_baserenderer.py =================================================================== RCS file: /thubanrepository/thuban/test/test_baserenderer.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- test_baserenderer.py 16 Feb 2005 21:14:47 -0000 1.11 +++ test_baserenderer.py 18 Feb 2005 14:54:17 -0000 1.12 @@ -32,7 +32,8 @@ from Thuban.UI.baserenderer import BaseRenderer, \ add_renderer_extension, init_renderer_extensions -from Thuban.version import versions +if Thuban.Model.resource.has_gdal_support(): + from gdalwarp import ProjectRasterFile class MockDC: @@ -94,7 +95,19 @@ self.raster_data = data self.raster_format = format + def projected_raster_layer(self, layer, srcProj, dstProj, extents, + resolution, dimensions, options): + + if not Thuban.Model.resource.has_gdal_support(): + raise support.SkipTest("No gdal support") + + #print srcProj, dstProj,extents, resolution, dimensions, options + return ProjectRasterFile(layer.GetImageFilename(), + srcProj, dstProj, + extents, resolution, dimensions, + options) + class MockProjection: """Objects that look like projections but simply apply non-uniform scalings @@ -263,6 +276,72 @@ ('SetFont', "label font"), ('EndDrawing',)]) + def test_projected_raster_layer(self): + if not Thuban.Model.resource.has_gdal_support(): + raise support.SkipTest("No gdal support") + + layer = RasterLayer("raster layer", + os.path.join("..", "Data", "iceland", + "island.tif")) + + dc = MockDC(size = (20, 20)) + renderer = SimpleRenderer(dc, map, 34, (800, 2250)) + + # The reference data as a base64 coded RAW image + raw_data = binascii.a2b_base64( + 'UmbmUmbmUmbmUmbmUmbmAtYCJooCAtICAq4CJooCArICAuICArICAuYCAs4COn4CO' + 'n4CAq4CAuICFpICUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmAuYCAqICAqoCAqoCFp' + 'ICJooCIo4CCpoCQnoGOn4CDpYCOn4CUmbmUmbmNo6aEpYCLoYCAqICGpICFpICUmb' + 'mAt4CUmbmNo6aAtICArYCAqoCKoYCMoICTnYKOn4CFpICUmbmUmbmUmbmUmbmAp4C' + 'NoICArYCAr4CCpoCAqYCCpoCEpYCHo4CFpICHo4CGpICFpICKoYCTnYKMoICAp4CU' + 'mbmUmbmUmbmUmbmUmbmUmbmAtYCAroCArYCCpoCAtYCAroCAtICAsYCUmbmAt4CAq' + 'YCAroCMoICAs4CAs4CAtYCAt4CAqYCUmbmUmbmUmbmUmbmAtoCAtYCAq4CAtoCBp4' + 'CAroCAqoCAq4CAr4CDpYCGpICAt4CAsICDpYCArICCpoCHo4CAs4CAuICUmbmUmbm' + 'UmbmUmbmUmbmUmbmAuICAqICFpYCAq4CDpoCAqYCFpICAqYCUmbmNo6aAsYCCpoCD' + 'pYCAqICAtoCUmbmAt4CAqoCCpoCAroCHo4CAsYCAq4CAsICAs4CAp4CUmbmAtYCAq' + 'YCIooCHo4CAsICAr4CAqICEpYCAs4CAqICArICDpYCEpYCEpYCAr4CUmbmEpYCAs4' + 'CAtICAs4CAqYCUmbmAtoCAp4CCpoCDpYCAq4CArICAqoCAqYCAqYCAtYCAtoCDpYC' + 'At4CUmbmUmbmUmbmUmbmAt4CAsoCAsoCAp4CAp4CCpoCAsoCAt4CNo6aUmbmUmbmU' + 'mbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmAt4CAtYCCpoCAqICAroCAr4CUmbmUm' + 'bmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmb' + 'mUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm' + 'UmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmU' + 'mbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUm' + 'bmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmb' + 'mUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm' + 'UmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmU' + 'mbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUm' + 'bmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmb' + 'mUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm' + 'UmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm\n') + + raw_mask = binascii.a2b_base64( + '//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P/' + '/8P//8P//8P//8P//8P\n') + + raw_mask_inverted = binascii.a2b_base64( + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAA\n') + + raw_alpha = binascii.a2b_base64( + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////////////////////' + '/////////////////////////////////////////////w==\n') + + for opts, data in [[1, (raw_data, raw_mask, None)], + [1|4, (raw_data, raw_mask_inverted, None)], + [2, (raw_data, None, raw_alpha)]]: + + img_data = renderer.projected_raster_layer(layer, "", "", + (-24, 65, -23, 66), [0, 0], (20, 20), opts) + self.assertEquals(img_data, data) + def test_raster_no_projection(self): """Test BaseRenderer with raster layer and no projections @@ -278,6 +357,8 @@ layer = RasterLayer("raster layer", os.path.join("..", "Data", "iceland", "island.tif")) + layer.SetMaskType(layer.MASK_NONE) + map.AddLayer(layer) self.to_destroy.append(map) @@ -321,24 +402,8 @@ 'mUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm' 'UmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbmUmbm\n') - #print - #hexed = binascii.b2a_base64(renderer.raster_data[2][1]) - #while hexed: - #print repr(hexed[:61]) - #hexed = hexed[61:] - - - if versions['wxPython-tuple'] < (2,5,3): - raw_mask = binascii.a2b_base64( - 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' - 'AAAAAAAAAAAAAAAAAAA\n') - else: - raw_mask = binascii.a2b_base64( - '//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P//8P/' - '/8P//8P//8P//8P//8P\n') - self.assertEquals(renderer.raster_data, - (20,20,(raw_data, raw_mask, None))) + (20,20,(raw_data, None, None))) self.assertEquals(renderer.raster_format, "RAW") @@ -346,33 +411,6 @@ [('BeginDrawing',), ('SetFont', "label font"), ('EndDrawing',)]) - - if versions['wxPython-tuple'] >= (2,5,3): - layer.SetMaskType(layer.MASK_ALPHA) - renderer.render_map() - - #print - #hexed = binascii.b2a_base64(renderer.raster_data[2][2]) - #while hexed: - #print repr(hexed[:61]) - #hexed = hexed[61:] - raw_alpha = binascii.a2b_base64( - '/////////////////////////////////////////////////////////////' - '/////////////////////////////////////////////////////////////' - '/////////////////////////////////////////////////////////////' - '/////////////////////////////////////////////////////////////' - '/////////////////////////////////////////////////////////////' - '/////////////////////////////////////////////////////////////' - '/////////////////////////////////////////////////////////////' - '/////////////////////////////////////////////////////////////' - '/////////////////////////////////////////////w==\n') - self.assertEquals(renderer.raster_data, - (20,20,(raw_data, None, raw_alpha))) - - - layer.SetMaskType(layer.MASK_NONE) - renderer.render_map() - self.assertEquals(renderer.raster_data, (20,20,(raw_data, None, None))) def test_point_map_projection(self): """Test BaseRenderer with point layer and map projection""" From cvs at intevation.de Fri Feb 18 15:54:19 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 18 Feb 2005 15:54:19 +0100 (CET) Subject: jonathan: thuban/libraries/thuban gdalwarp.cpp,1.7,1.8 Message-ID: <20050218145419.5F39A102BF6@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban/libraries/thuban In directory doto:/tmp/cvs-serv11859/libraries/thuban Modified Files: gdalwarp.cpp Log Message: Refactored baserenderer.py and renderer.py to remove baserenderer.py's dependencies on wxPython. Added a new method projected_raster_layer() that returns a raster layer image in projected space. This must be implemented in classes derived from BaseRenderer. This also eliminates the dependency on gdal in baserenderer.py. Index: gdalwarp.cpp =================================================================== RCS file: /thubanrepository/thuban/libraries/thuban/gdalwarp.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- gdalwarp.cpp 16 Feb 2005 21:14:47 -0000 1.7 +++ gdalwarp.cpp 18 Feb 2005 14:54:17 -0000 1.8 @@ -29,6 +29,13 @@ ****************************************************************************** * * $Log$ + * Revision 1.8 2005/02/18 14:54:17 jonathan + * Refactored baserenderer.py and renderer.py to remove baserenderer.py's + * dependencies on wxPython. Added a new method projected_raster_layer() + * that returns a raster layer image in projected space. This must be + * implemented in classes derived from BaseRenderer. This also eliminates + * the dependency on gdal in baserenderer.py. + * * Revision 1.7 2005/02/16 21:14:47 jonathan * Further wxPython 2.5 changes using patches from Daniel Calvelo Aros * so that that wxproj doesn't crash. Added GUI support for selecting @@ -128,7 +135,6 @@ */ #include -#include #include "gdal.h" #include "gdal_alg.h" @@ -145,6 +151,7 @@ #define OPTS_MASK 1 #define OPTS_ALPHA 2 +#define OPTS_INVERT_MASK_BITS 4 CPL_CVSID("$Id$"); @@ -160,7 +167,7 @@ static double dfXRes=0.0, dfYRes=0.0; static int nForcePixels=0, nForceLines=0; static int bEnableDstAlpha = FALSE, bEnableSrcAlpha = FALSE; -static int bMakeMask, bMakeAlpha; +static int bMakeMask, bMakeAlpha, bInvertMask; const char *pszSrcFilename = NULL, *pszDstFilename = "MEM:::"; static PyMethodDef gdalwarp_methods[] = { @@ -491,11 +498,14 @@ { for (j=0; j < nRasterXSize;) { -#if wxCHECK_VERSION(2,5,3) - if (*tptr++ >= 128) c |= b; -#else - if (*tptr++ < 128) c |= b; -#endif + if (bInvertMask) + { + if (*tptr++ < 128) c |= b; + } + else + { + if (*tptr++ >= 128) c |= b; + } b <<= 1; if (!(++j & 7)) @@ -639,10 +649,8 @@ options = ( int )PyInt_AsLong( opts ); bMakeMask = (options & OPTS_MASK) == OPTS_MASK; - -#if wxCHECK_VERSION(2,5,3) bMakeAlpha = (options & OPTS_ALPHA) == OPTS_ALPHA; -#endif + bInvertMask = (options & OPTS_INVERT_MASK_BITS) == OPTS_INVERT_MASK_BITS; // FIXME: error if bMakeMask == bMaskAlpha From cvs at intevation.de Fri Feb 18 15:56:44 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 18 Feb 2005 15:56:44 +0100 (CET) Subject: jonathan: thuban ChangeLog,1.787,1.788 setup.py,1.48,1.49 Message-ID: <20050218145644.7BEEC100174@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv12342 Modified Files: ChangeLog setup.py Log Message: Forgot to remove wx_cs_params from the gdal compile options. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.787 retrieving revision 1.788 diff -u -d -r1.787 -r1.788 --- ChangeLog 18 Feb 2005 14:54:17 -0000 1.787 +++ ChangeLog 18 Feb 2005 14:56:42 -0000 1.788 @@ -1,5 +1,9 @@ 2005-02-18 Jonathan Coles + * setup.py: Remove wx_cs_params from gdal compile options. + +2005-02-18 Jonathan Coles + Refactored baserenderer.py and renderer.py to remove baserenderer.py's dependencies on wxPython. Added a new method projected_raster_layer() that returns a raster layer image in projected space. This must be Index: setup.py =================================================================== RCS file: /thubanrepository/thuban/setup.py,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- setup.py 16 Feb 2005 21:14:47 -0000 1.48 +++ setup.py 18 Feb 2005 14:56:42 -0000 1.49 @@ -1093,10 +1093,8 @@ self.extensions.append(Extension("Lib.gdalwarp", [ext_dir + "/thuban/gdalwarp.cpp"], include_dirs = gdal_cs_params[CS_INCDIRS] + - [ext_dir + "/thuban/"] + - wx_cs_params[CS_INCDIRS], - define_macros = gdal_cs_params[CS_DEFS] + - wx_cs_params[CS_DEFS], + [ext_dir + "/thuban/"], + define_macros = gdal_cs_params[CS_DEFS], library_dirs = gdal_cs_params[CS_LIBDIRS], libraries = gdal_cs_params[CS_LIBS])) From jonathan at jpcoles.com Fri Feb 18 16:04:05 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Fri, 18 Feb 2005 10:04:05 -0500 Subject: jonathan: thuban/test test_baserenderer.py, 1.10, 1.11 test_layer.py, 1.34, 1.35 In-Reply-To: References: <20050216211449.B1DEA102C24@lists.intevation.de> <1108646403.12009.83.camel@localhost.localdomain> <1108674231.12009.99.camel@localhost.localdomain> Message-ID: <1108739046.27129.12.camel@localhost.localdomain> Am Freitag, den 18.02.2005, 11:50 +0100 schrieb Bernhard Herzog: > > baserenderer will have to get those > > values before it calls ProjectRasterFile and then the tests that use > > baserenderer will fail because the call chain will use wxPython. > > There are at least two solutions: > > - BaseRenderer's draw_raster_layer method calls ProjectRasterFile > through a new method that can be overwritten by a derived class i went with this solution as i thought it would give the most flexibility. i was able to remove the wxPython dependencies from baserenderer.py and also the dependency on gdal. the new method projected_raster_layer() is overridden in MapRenderer. If a deriving class doesn't support raster projection (or gdal isn't present) the method may return None. The result (if not None) is passed to draw_raster_data. i added a new option bit to the options parameter in ProjectRasterFile which selects to invert the mask or not so the wxPython dependency was removed from gdalwarp as well. there are appropriate tests for the different options. --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== From jonathan at jpcoles.com Fri Feb 18 16:06:54 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Fri, 18 Feb 2005 10:06:54 -0500 Subject: map test broken Message-ID: <1108739214.27129.15.camel@localhost.localdomain> jan: you may have broken test_map.py with one of your recent commits. looks like there is a label layer object at the end of the first list. jpc at reisen:~/arbeit/intevation/devel5/thuban/test$ python test_map.py ...............F. ====================================================================== FAIL: __main__.TestMapWithContents.test_tree_info ---------------------------------------------------------------------- Traceback (most recent call last): File "test_map.py", line 275, in test_tree_info ('Map: Test Map', File "/usr/lib/python2.3/unittest.py", line 302, in failUnlessEqual raise self.failureException, \ AssertionError: ('Map: Test Map', ['Extent (lat-lon): (-24.5465, 63.2868, -13.4958, 66.5638)', 'Extent (projected): (608873, 7.01969e+06, 1.17356e+06, 7.44735e+06)', ('Projection', ['zone=26', 'proj=utm', 'ellps=clrk66']), , , ]) != ('Map: Test Map', ['Extent (lat-lon): (-24.5465, 63.2868, -13.4958, 66.5638)', 'Extent (projected): (608873, 7.01969e+06, 1.17356e+06, 7.44735e+06)', ('Projection', ['zone=26', 'proj=utm', 'ellps=clrk66']), , ]) --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== From bernhard at intevation.de Fri Feb 18 18:09:31 2005 From: bernhard at intevation.de (Bernhard Reiter) Date: Fri, 18 Feb 2005 18:09:31 +0100 Subject: seperating non-wx and wx based tests In-Reply-To: References: <20050216211449.B1DEA102C24@lists.intevation.de> <1108646403.12009.83.camel@localhost.localdomain> Message-ID: <20050218170931.GC16375@intevation.de> Am 17. Feb 2005 um 20:37:52 schrieb Bernhard Herzog: > However, if we do add test cases that really > need wxPython, they should be separated from the ones that don't. Not > sure how to organize that, but they should at least be in different > files. I would suggest different directories even. ;) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050218/287b2412/attachment.bin From bernhard at intevation.de Fri Feb 18 18:17:30 2005 From: bernhard at intevation.de (Bernhard Reiter) Date: Fri, 18 Feb 2005 18:17:30 +0100 Subject: Finishing the extension registry feature In-Reply-To: <20050217112539.GA26955@intevation.de> References: <20050217112539.GA26955@intevation.de> Message-ID: <20050218171730.GD16375@intevation.de> Am 17. Feb 2005 um 12:25:39 schrieb Jan-Oliver Wagner: > finally I really aim to finish the extension registry > feature. > > The most important remianing problem was that the __init__.py > of a extension should not contain any GUI relevant imports > or otherweise the test suite has a problem. > > On the other hand I wanted a single standard line in > thubanstart.py for each extension to load completely. > > My proposal now is to define a filename (Extensions/myname/all.py) > where all imports are done to fully integrate the extension > into Thuban. > Then, in ~/.thuban/thubanstart.py there are lines like: > import Extensions.gns2shp.all > > This allows for later automized loading of all available Extensions > (which is one of my goals). > > What do you think? Using a file has the advantage that this works similiar to how tests are found (magic filename). We could also change both to use a magic function in the package. Doing this for registration first and then later for tests. I tend to favour the magic function solution a little bit over the other, as we can later invent new magic functions for wx-dependent test or what ever without changing names all the time. On the other hand if there is a magic function then thuban needs to scan all packages in the Extensions directory and at least try to import the package to see what magic funcations it has. Seems okay to me. Note that will all solutions it should not be necessary to add an ".all" or prefix a "Entensions." to the import command. This is all very theoretic as you can just go an and improve it, I would say. Bernhard -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20050218/71c1c484/attachment.bin From bh at intevation.de Fri Feb 18 20:09:20 2005 From: bh at intevation.de (Bernhard Herzog) Date: Fri, 18 Feb 2005 20:09:20 +0100 Subject: jonathan: thuban/libraries/thuban gdalwarp.cpp,1.7,1.8 References: <20050218145419.5F39A102BF6@lists.intevation.de> Message-ID: cvs at intevation.de writes: > --- gdalwarp.cpp 16 Feb 2005 21:14:47 -0000 1.7 > +++ gdalwarp.cpp 18 Feb 2005 14:54:17 -0000 1.8 > @@ -491,11 +498,14 @@ > { > for (j=0; j < nRasterXSize;) > { > -#if wxCHECK_VERSION(2,5,3) > - if (*tptr++ >= 128) c |= b; > -#else > - if (*tptr++ < 128) c |= b; > -#endif > + if (bInvertMask) > + { > + if (*tptr++ < 128) c |= b; > + } > + else > + { > + if (*tptr++ >= 128) c |= b; > + } This is in the innermost loop. Wouldn't it be better to move the test for bInvertMask to where c is assigned to *(ptr++)? That way the test would only be made for every byte in the mask, not for every bit. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Fri Feb 18 20:28:47 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 18 Feb 2005 20:28:47 +0100 (CET) Subject: bh: thuban/test test_baserenderer.py,1.12,1.13 Message-ID: <20050218192847.C6AC6102C37@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/test In directory doto:/tmp/cvs-serv18899/test Modified Files: test_baserenderer.py Log Message: (TestBaseRenderer.setUp): Fix doc-string Index: test_baserenderer.py =================================================================== RCS file: /thubanrepository/thuban/test/test_baserenderer.py,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- test_baserenderer.py 18 Feb 2005 14:54:17 -0000 1.12 +++ test_baserenderer.py 18 Feb 2005 19:28:45 -0000 1.13 @@ -1,4 +1,4 @@ -# Copyright (C) 2003 by Intevation GmbH +# Copyright (C) 2003, 2005 by Intevation GmbH # Authors: # Bernhard Herzog # @@ -129,8 +129,8 @@ def setUp(self): """Set self.to_destroy to an empty list - Test should put all objects whose Destroy should be called atunittest.main - the end into this list so that they're destroyed in tearDown + Tests should put all objects whose Destroy should be called at + the end into this list so that they're destroyed in tearDown. """ self.to_destroy = [] From cvs at intevation.de Fri Feb 18 20:28:47 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 18 Feb 2005 20:28:47 +0100 (CET) Subject: bh: thuban ChangeLog,1.788,1.789 Message-ID: <20050218192847.E68C9102C39@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv18899 Modified Files: ChangeLog Log Message: (TestBaseRenderer.setUp): Fix doc-string Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.788 retrieving revision 1.789 diff -u -d -r1.788 -r1.789 --- ChangeLog 18 Feb 2005 14:56:42 -0000 1.788 +++ ChangeLog 18 Feb 2005 19:28:45 -0000 1.789 @@ -1,3 +1,8 @@ +2005-02-18 Bernhard Herzog + + * test/test_baserenderer.py (TestBaseRenderer.setUp): Fix + doc-string + 2005-02-18 Jonathan Coles * setup.py: Remove wx_cs_params from gdal compile options. From cvs at intevation.de Fri Feb 18 22:22:55 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 18 Feb 2005 22:22:55 +0100 (CET) Subject: jonathan: thuban ChangeLog,1.789,1.790 Message-ID: <20050218212255.80600102C37@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv21882 Modified Files: ChangeLog Log Message: Optimize the loop in gdalwarp which builds a mask. Handle the majority of an image in a loop, creating 8 bits at a time. Later, handle the edge case where less than 8 bits are packed. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.789 retrieving revision 1.790 diff -u -d -r1.789 -r1.790 --- ChangeLog 18 Feb 2005 19:28:45 -0000 1.789 +++ ChangeLog 18 Feb 2005 21:22:53 -0000 1.790 @@ -1,3 +1,10 @@ +2005-02-18 Jonathan Coles + + * libraries/thuban/gdalwarp.cpp (GetImageData): Optimize the loop + which builds a mask. Handle the majority of an image in a loop, + creating 8 bits at a time. Later, handle the edge case where less + than 8 bits are packed. + 2005-02-18 Bernhard Herzog * test/test_baserenderer.py (TestBaseRenderer.setUp): Fix From cvs at intevation.de Fri Feb 18 22:22:55 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 18 Feb 2005 22:22:55 +0100 (CET) Subject: jonathan: thuban/libraries/thuban gdalwarp.cpp,1.8,1.9 Message-ID: <20050218212255.82F30102C39@lists.intevation.de> Author: jonathan Update of /thubanrepository/thuban/libraries/thuban In directory doto:/tmp/cvs-serv21882/libraries/thuban Modified Files: gdalwarp.cpp Log Message: Optimize the loop in gdalwarp which builds a mask. Handle the majority of an image in a loop, creating 8 bits at a time. Later, handle the edge case where less than 8 bits are packed. Index: gdalwarp.cpp =================================================================== RCS file: /thubanrepository/thuban/libraries/thuban/gdalwarp.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- gdalwarp.cpp 18 Feb 2005 14:54:17 -0000 1.8 +++ gdalwarp.cpp 18 Feb 2005 21:22:53 -0000 1.9 @@ -29,6 +29,11 @@ ****************************************************************************** * * $Log$ + * Revision 1.9 2005/02/18 21:22:53 jonathan + * Optimize the loop in gdalwarp which builds a mask. Handle the majority of an + * image in a loop, creating 8 bits at a time. Later, handle the edge case where + * less than 8 bits are packed. + * * Revision 1.8 2005/02/18 14:54:17 jonathan * Refactored baserenderer.py and renderer.py to remove baserenderer.py's * dependencies on wxPython. Added a new method projected_raster_layer() @@ -496,31 +501,47 @@ for (i=0; i < nRasterYSize; i++) { - for (j=0; j < nRasterXSize;) + for (j=nRasterXSize; j >= 8; j -= 8) { - if (bInvertMask) - { - if (*tptr++ < 128) c |= b; - } + c=0; b=1; + if (*tptr++ >= 128) {c|=b;} b<<=1; + if (*tptr++ >= 128) {c|=b;} b<<=1; + if (*tptr++ >= 128) {c|=b;} b<<=1; + if (*tptr++ >= 128) {c|=b;} b<<=1; + if (*tptr++ >= 128) {c|=b;} b<<=1; + if (*tptr++ >= 128) {c|=b;} b<<=1; + if (*tptr++ >= 128) {c|=b;} b<<=1; + if (*tptr++ >= 128) {c|=b;} b<<=1; + + if (bInvertMask) + *(ptr++) = ~c; else - { - if (*tptr++ >= 128) c |= b; - } - - b <<= 1; - if (!(++j & 7)) - { - //if (c==0) empty_count++; *(ptr++) = c; - c = 0; b = 1; - } } - if (j & 7) + c=0; b=1; + switch (nRasterXSize & 7) { - //if (c==0) empty_count++; - *(ptr++) = c; - c = 0; b = 1; + case 7: if (*tptr++ >= 128) {c|=b;} b<<=1; + case 6: if (*tptr++ >= 128) {c|=b;} b<<=1; + case 5: if (*tptr++ >= 128) {c|=b;} b<<=1; + case 4: if (*tptr++ >= 128) {c|=b;} b<<=1; + case 3: if (*tptr++ >= 128) {c|=b;} b<<=1; + case 2: if (*tptr++ >= 128) {c|=b;} b<<=1; + case 1: + if (*tptr++ >= 128) {c|=b;} + b<<=1; + + // + // byte should be padded with 0's so + // it's not a simple inversion + // + if (bInvertMask) + *(ptr++) = ~c & (b-1); + else + *(ptr++) = c; + + default: break; } } From jonathan at jpcoles.com Fri Feb 18 22:22:45 2005 From: jonathan at jpcoles.com (Jonathan Coles) Date: Fri, 18 Feb 2005 16:22:45 -0500 Subject: jonathan: thuban/libraries/thuban gdalwarp.cpp,1.7,1.8 In-Reply-To: References: <20050218145419.5F39A102BF6@lists.intevation.de> Message-ID: <1108761765.27129.26.camel@localhost.localdomain> Am Freitag, den 18.02.2005, 20:09 +0100 schrieb Bernhard Herzog: > This is in the innermost loop. Wouldn't it be better to move the test > for bInvertMask to where c is assigned to *(ptr++)? That way the test > would only be made for every byte in the mask, not for every bit. yes, that was stupid. while i was fixing that i rewrote that inner loop so that it handles 8 bits at a time and then afterwards the edge cases where there are less than 8 bits to pack. this reduces the number of if's about 8x. --jonathan -- ===================================================================== Jonathan Coles http://www.jpcoles.com jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc ===================================================================== From cvs at intevation.de Tue Feb 22 12:09:34 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 22 Feb 2005 12:09:34 +0100 (CET) Subject: jan: thuban/test test_map.py,1.11,1.12 Message-ID: <20050222110934.9B693102C48@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/test In directory doto:/tmp/cvs-serv3371 Modified Files: test_map.py Log Message: (TestMapWithContents.test_tree_info): Added label layer for comparison. Index: test_map.py =================================================================== RCS file: /thubanrepository/thuban/test/test_map.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- test_map.py 28 Aug 2003 14:33:12 -0000 1.11 +++ test_map.py 22 Feb 2005 11:09:32 -0000 1.12 @@ -279,7 +279,8 @@ ('Projection', ['zone=26', 'proj=utm', 'ellps=clrk66']), self.poly_layer, - self.arc_layer])) + self.arc_layer, + self.map.LabelLayer()])) def test_forwarding_visibility(self): """Test Map's forwarding of Layer.SetVisible messages""" From cvs at intevation.de Tue Feb 22 12:10:02 2005 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 22 Feb 2005 12:10:02 +0100 (CET) Subject: jan: thuban ChangeLog,1.790,1.791 Message-ID: <20050222111002.64BEB102C48@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv3386 Modified Files: ChangeLog Log Message: Fixed bug in test suite. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.790 retrieving revision 1.791 diff -u -d -r1.790 -r1.791 --- ChangeLog 18 Feb 2005 21:22:53 -0000 1.790 +++ ChangeLog 22 Feb 2005 11:10:00 -0000 1.791 @@ -1,3 +1,8 @@ +2005-02-22 Jan-Oliver Wagner + + * test/test_map.py (TestMapWithContents.test_tree_info): + Added label layer for comparison. + 2005-02-18 Jonathan Coles * libraries/thuban/gdalwarp.cpp (GetImageData): Optimize the loop From jan at intevation.de Tue Feb 22 12:11:20 2005 From: jan at intevation.de (Jan-Oliver Wagner) Date: Tue, 22 Feb 2005 12:11:20 +0100 Subject: map test broken In-Reply-To: <1108739214.27129.15.camel@localhost.localdomain> References: <1108739214.27129.15.camel@localhost.localdomain> Message-ID: <20050222111120.GA31973@intevation.de> On Fri, Feb 18, 2005 at 10:06:54AM -0500, Jonathan Coles wrote: > jan: > > you may have broken test_map.py with one of your recent commits. looks > like there is a label layer object at the end of the first list. thank for the note. It is fixed now. Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From jan at intevation.de Thu Feb 24 23:40:28 2005 From: jan at intevation.de (Jan-Oliver Wagner) Date: Thu, 24 Feb 2005 23:40:28 +0100 Subject: Finishing the extension registry feature In-Reply-To: <20050218171730.GD16375@intevation.de> References: <20050217112539.GA26955@intevation.de> <20050218171730.GD16375@intevation.de> Message-ID: <20050224224028.GA17919@intevation.de> On Fri, Feb 18, 2005 at 06:17:30PM +0100, Bernhard Reiter wrote: > We could also change both to use a magic function in the package. > Doing this for registration first and then later for tests. > > I tend to favour the magic function solution a little bit over the > other, as we can later invent new magic functions for wx-dependent > test or what ever without changing names all the time. here is a improved approach. Less magic names and more automization via callbacks.