On 2010-06-30 01:24-0400 [email protected] wrote:

>> I thought that maybe the 'mem' driver could be used in conjunction with
> pyGTK, but it seems that the 'plsmem' command is missing from the python
> bindings.
>
> I looked into this and confirmed that it is indeed missing:
> --
> .../plplot-5.9.6/buildnmake/bindings/python$ grep 'SWIGINTERN PyObject
> \*_wrap' plplotcmodulePYTHON_wrap.c
> SWIGINTERN PyObject *_wrap_plshade(PyObject *SWIGUNUSEDPARM(self),
> PyObject *args) {
> SWIGINTERN PyObject *_wrap_plslabelfunc(PyObject *SWIGUNUSEDPARM(self),
> PyObject *args) {
> SWIGINTERN PyObject *_wrap_plsmaj(PyObject *SWIGUNUSEDPARM(self), PyObject
> *args) {
>
> <----- plsmem should be here!!!! ----
>
> SWIGINTERN PyObject *_wrap_plsmin(PyObject *SWIGUNUSEDPARM(self), PyObject
> *args) {
> SWIGINTERN PyObject *_wrap_plsori(PyObject *SWIGUNUSEDPARM(self), PyObject
> *args) {
> --
>
> After some reading about SWIG I have some (minimal) understanding on how
> the bindings are automagically generated. It seems likely (to me anyhow)
> that the 'void *' in the prototype is causing this function (and others)
> to be left out of the bindings.
> --
> PLDLLIMPEXP void
> c_plsmem( PLINT maxx, PLINT maxy, void *plotmem );
> --
>
> I found this reference on how to tell swig to skip over such 'issues', but
> was unable to get it to work for me:
> http://www.swig.org/Doc1.3/Python.html#Python_nn64
>
> Does anyone have any suggestions?
>
> What I am thinking would be useful is that one could create a PIL 'RGB'
> object and pass that to plplot, or just pass a contiguous chunk of memory
> and then use 'Image.frombuffer' to convert it into a PIL image.

Hi Simon:

To help with the overview, here is how swig-generated code is organized
within PLplot.  The PLplot API is described for swig using
bindings/swig-support/plplotcapi.i.  Each of our swig-defined bindings
(currently python, java, and lua) uses this common file.

If you want to do something special for any of these languages in
this file, use the SWIG_PYTHON, SWIG_JAVA, and/or SWIG_LUA macros
that are defined in bindings/<language>/CMakeLists.txt where language
is python, java, or lua.

Here is the relevant stanza for plsmem from
bindings/swig-support/plplotcapi.i:

#if 0
/* plsmem not implemented because don't know how to make block
of memory available from python. */
%feature("autodoc", "Set the memory area to be plotted (with the 'mem'
driver).") plsmem

void
plsmem(PLINT maxx, PLINT maxy, void *plotmem);
#endif

So we have dropped plsmem from our python, java, and lua bindings due to
that #if 0.  The stated reason (don't know how to make block of memory
available from python) was put there when the file was first implemented for
python many years ago but actually that stated reason currently applies to
java and lua as well.  So if you want to uncomment it just for python
replace #if 0 by #ifdef SWIG_PYTHON.  However, that is only a trivial part
of the work involved.

The rest (for python) has to be done by modifying
bindings/python/plplotcmodule.i to teach swig how to pass a pointer to a
block of memory allocated by python to the C version of plsmem via
that routine's PLINT maxx, PLINT maxy, void *plotmem arguments.

Beyond that overview of swig-generated interfaces, I cannot help you because
I know very little about how you would use plsmem and the mem device even
within C code. For example, I could find no reference to plsmem in
examples/c/*.c.

Anyhow, if you get a python version of plsmem to work following the general
PLplot/swig implementation overview I have described, then I would be
pleased to accept your patch to bindings/python/plplotcmodule.i as well as
the trivial patch for bindings/swig-support/plplotcapi.i that I
mentioned above.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Plplot-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-general

Reply via email to