I have run across a problem using the extcairo driver and multiple,
differently dimensioned plots. The attached C program
ext-cairo-test-problem.c is a modified version of
examples/c/ext-cairo-test.c from the PLplot source tree and
illustrates the problem I am having.
To compile the attached code, you can use:
gcc ext-cairo-test-problem.c -o ext-cairo-test-problem `pkg-config
--cflags --libs plplotd cairo`
and:
gcc ext-cairo-test-workaround.c -o ext-cairo-test-workaround
`pkg-config --cflags --libs plplotd cairo`
They require that the extcairo driver is enabled. After the generated
executable is run, a test.ps file is generated. For the
ext-cairo-test-problem case, there are labels painted in the lower
left corner of the page. For the ext-cairo-test-workaround case, new
labels are superimposed over the original "x" "y" "title" labels, as
expected.
The basic steps to reproduce the problem:
1. Start an extcairo plot
2. Create a new plot stream with plmkstrm
3. Set the new plot stream to use extcairo and have different
dimensions than the original plot started in (1) using
plsetopt("geometry", "NEWXxNEWY")
4. End the new plot stream created in (2) with plend1
5. Plot something, now that PLplot is using plot (1) again as the
plotting target, and see how the coordinates are calculated
incorrectly.
I found a workaround, illustrated in ext-cairo-test-workaround.c,
which is done by adding the following steps:
4.1. Create another new stream, using the extcairo driver.
4.2. Set the new stream to have the same dimensions as the original
plot started in (1).
4.3. End the new plot stream created in (4.1) with plend1.
In this case, OR if the new stream created in (2) is initialized using
some other plot device (ex. psc), the problem does not come up.
This problem does not occur, as far as I can tell, for any other
driver combinations. png + psc, psc + pscairo, extcairo + psc and
other all work fine. extcairo + extcairo is where I run in to the
problem.
I have been digging through the PLplot code in an attempt to track
down the source of this problem for a better fix than the above
workaround but I have not had any luck so far. Any suggestions on how
to proceed? I am using the latest PLplot SVN.
Thanks,
Hez
--
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science
#include <stdio.h>
#include <cairo.h>
#include <cairo-ps.h>
#include <plplot.h>
int main(int argc, char *argv[])
{
cairo_surface_t *cairoSurface;
cairo_t *cairoContext;
int stream;
cairoSurface = cairo_ps_surface_create("test.ps", 720, 540);
cairoContext = cairo_create(cairoSurface);
plsdev("extcairo");
plinit();
pl_cmd(PLESC_DEVINIT, cairoContext);
plenv(0.0, 1.0, 0.0, 1.0, 1, 0);
pllab("x", "y", "title");
/* PROBLEM ILLUSTRATION START */
plmkstrm(&stream);
plsetopt("geometry", "200x200");
plsdev("extcairo");
plinit();
plend1();
pllab("bad x", "bad y", "bad title");
/* PROBLEM ILLUSTRATIN END */
plend();
cairo_destroy(cairoContext);
cairo_surface_destroy(cairoSurface);
}
#include <stdio.h>
#include <cairo.h>
#include <cairo-ps.h>
#include <plplot.h>
int main(int argc, char *argv[])
{
cairo_surface_t *cairoSurface;
cairo_t *cairoContext;
int stream;
cairoSurface = cairo_ps_surface_create("test.ps", 720, 540);
cairoContext = cairo_create(cairoSurface);
plsdev("extcairo");
plinit();
pl_cmd(PLESC_DEVINIT, cairoContext);
plenv(0.0, 1.0, 0.0, 1.0, 1, 0);
pllab("x", "y", "title");
/* PROBLEM ILLUSTRATION START */
plmkstrm(&stream);
plsetopt("geometry", "200x200");
plsdev("extcairo");
plinit();
plend1();
/* START WORKAROUND */
plmkstrm(&stream);
plsetopt("geometry", "720x540");
plsdev("extcairo");
plinit();
plend1();
/* END WORKAROUND */
pllab("expected x", "expected y", "expected title");
/* PROBLEM ILLUSTRATIN END */
plend();
cairo_destroy(cairoContext);
cairo_surface_destroy(cairoSurface);
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel