Re: [Plplot-devel] Multiple extcairo plot streams plot dimension problem

2008-10-24 Thread Hezekiah M. Carty
On Fri, Oct 24, 2008 at 2:49 AM, Werner Smekal <[EMAIL PROTECTED]> wrote:
> Hi,
>
>>
>> The problem is here:
>>
>> static PLFLT downscale = 0.;
>
>>
>>
>> This should be stored separately as part of each plot stream rather
>> than being a single static global variable.
>
> Yes, this variable needs to be moved to the PLcairo struct. A instance of
> this struct is saved into the dev variable of the plplot stream and then
> every stream has it's own downscale variable. I can fix that if nobody else
> does.

If not one has come up with a different patch yet, the attached patch
seems to fix the problem for the Cairo devices on my system.

Hez

-- 
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science
diff --git a/drivers/cairo.c b/drivers/cairo.c
index 31378ef..9deacf2 100644
--- a/drivers/cairo.c
+++ b/drivers/cairo.c
@@ -73,7 +73,6 @@ static int text_clipping;
 static int text_anti_aliasing;
 static int graphics_anti_aliasing;
 static int external_drawable;
-static PLFLT downscale = 0.;
 static DrvOpt cairo_options[] = {{"text_clipping", DRV_INT, &text_clipping, "Use text clipping (text_clipping=0|1)"},
  {"text_anti_aliasing", DRV_INT, &text_anti_aliasing, "Set desired text anti-aliasing (text_anti_aliasing=0|1|2|3). The numbers are in the same order as the cairo_antialias_t enumeration documented at http://cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t)"},
  {"graphics_anti_aliasing", DRV_INT, &graphics_anti_aliasing, "Set desired graphics anti-aliasing (graphics_anti_aliasing=0|1|2|3). The numbers are in the same order as the cairo_antialias_t enumeration documented at http://cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t"},
@@ -86,6 +85,7 @@ typedef struct {
   short text_clipping;
   short text_anti_aliasing;
   short graphics_anti_aliasing;
+  PLFLT downscale;
 #if defined(PLD_xcairo)
   short exit_event_loop;
   Display *XDisplay;
@@ -252,8 +252,8 @@ void plD_line_cairo(PLStream *pls, short x1a, short y1a, short x2a, short y2a)
 
   set_current_context(pls);
 
-  cairo_move_to(aStream->cairoContext, downscale * (double) x1a, downscale * (double) y1a);
-  cairo_line_to(aStream->cairoContext, downscale * (double) x2a, downscale * (double) y2a);
+  cairo_move_to(aStream->cairoContext, aStream->downscale * (double) x1a, aStream->downscale * (double) y1a);
+  cairo_line_to(aStream->cairoContext, aStream->downscale * (double) x2a, aStream->downscale * (double) y2a);
   cairo_stroke(aStream->cairoContext);
 }
 
@@ -404,12 +404,12 @@ void proc_str(PLStream *pls, EscText *args)
 
   /* Set up the clipping region if we are doing text clipping */
   if(aStream->text_clipping){
-cairo_rectangle(aStream->cairoContext, downscale * pls->clpxmi, downscale * pls->clpymi, downscale * (pls->clpxma - pls->clpxmi), downscale * (pls->clpyma - pls->clpymi));
+cairo_rectangle(aStream->cairoContext, aStream->downscale * pls->clpxmi, aStream->downscale * pls->clpymi, aStream->downscale * (pls->clpxma - pls->clpxmi), aStream->downscale * (pls->clpyma - pls->clpymi));
 cairo_clip(aStream->cairoContext);
   }
 
   /* Move to the string reference point */
-  cairo_move_to(aStream->cairoContext, downscale * (double) args->x, downscale * (double) args->y);
+  cairo_move_to(aStream->cairoContext, aStream->downscale * (double) args->x, aStream->downscale * (double) args->y);
 
   /* Invert the coordinate system so that the text is drawn right side up */
   cairoTransformMatrix = (cairo_matrix_t *) malloc (sizeof(cairo_matrix_t));
@@ -655,6 +655,8 @@ PLCairo *stream_and_font_setup(PLStream *pls, int interactive)
   int i;
   char *a;
   PLCairo *aStream;
+  PLFLT downscale;
+  downscale = 0.0;
 
   /* Stream setup */
   pls->termin = interactive; /* Interactive device */
@@ -699,6 +701,7 @@ PLCairo *stream_and_font_setup(PLStream *pls, int interactive)
 #endif
   aStream->cairoSurface = NULL;
   aStream->cairoContext = NULL;
+  aStream->downscale = downscale;
 
   /* Set text clipping off as this makes the driver pretty slow */
   aStream->text_clipping = 0;
@@ -763,9 +766,9 @@ void poly_line(PLStream *pls, short *xa, short *ya, PLINT npts)
 
   set_current_context(pls);
   
-  cairo_move_to(aStream->cairoContext, downscale * (double) xa[0], downscale * (double) ya[0]);
+  cairo_move_to(aStream->cairoContext, aStream->downscale * (double) xa[0], aStream->downscale * (double) ya[0]);
   for(i=1;icairoContext, downscale * (double) xa[i], downscale * (double) ya[i]);
+cairo_line_to(aStream->cairoContext, aStream->downscale * (double) xa[i], aStream->downscale * (double) ya[i]);
   }
 }
 
@@ -1076,8 +1079,8 @@ void plD_esc_xcairo(PLStream *pls, PLINT op, void *ptr)
   &x, &y, &w, &h, &b, &d);
 pls->xlength = w;
 pls->ylength = h;
-plP_setphy((PLINT) 0, (PLINT) (pls->xlength / downscale), (PLINT) 0, 
-  (PLINT) (pls->ylength / downscale));
+plP_setphy((PLINT) 0, (PLINT) (pls->xleng

Re: [Plplot-devel] Multiple extcairo plot streams plot dimension problem

2008-10-24 Thread Hazen Babcock

On Oct 24, 2008, at 2:22 PM, Hezekiah M. Carty wrote:

> On Fri, Oct 24, 2008 at 2:49 AM, Werner Smekal  
> <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>>>
>>> The problem is here:
>>>
>>> static PLFLT downscale = 0.;
>>
>>>
>>>
>>> This should be stored separately as part of each plot stream rather
>>> than being a single static global variable.
>>
>> Yes, this variable needs to be moved to the PLcairo struct. A  
>> instance of
>> this struct is saved into the dev variable of the plplot stream  
>> and then
>> every stream has it's own downscale variable. I can fix that if  
>> nobody else
>> does.
>
> If not one has come up with a different patch yet, the attached patch
> seems to fix the problem for the Cairo devices on my system.

Applied. Thanks!

-Hazen


-
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
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel


Re: [Plplot-devel] Multiple extcairo plot streams plot dimension problem

2008-10-24 Thread Hazen Babcock

On Oct 24, 2008, at 12:38 AM, Alan W. Irwin wrote:

> On 2008-10-23 23:28-0400 Hazen Babcock wrote:
>>
> Hi Hazen,
>
> The problem occurs in svg.c as well, and there may be others.

On closer inspection, the svg driver is pretty much riddled with this  
problem. You could have all kinds of strange things happen if you  
tried to use two or more svg streams concurrently, not the least of  
which would be that all your output would always go into the current  
stream and then it would likely crash when you closed one of the  
streams.

I was probably being lazy when I wrote it. I will try and fix it up  
in the next day or two.

-Hazen


-
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
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel


Re: [Plplot-devel] Multiple extcairo plot streams plot dimension problem

2008-10-24 Thread Hazen Babcock

On Oct 24, 2008, at 10:26 PM, Hazen Babcock wrote:

>
> On Oct 24, 2008, at 12:38 AM, Alan W. Irwin wrote:
>
>> On 2008-10-23 23:28-0400 Hazen Babcock wrote:
>>>
>> Hi Hazen,
>>
>> The problem occurs in svg.c as well, and there may be others.
>
> On closer inspection, the svg driver is pretty much riddled with this
> problem. You could have all kinds of strange things happen if you
> tried to use two or more svg streams concurrently, not the least of
> which would be that all your output would always go into the current
> stream and then it would likely crash when you closed one of the
> streams.
>
> I was probably being lazy when I wrote it. I will try and fix it up
> in the next day or two.

Ok. This was pretty straightforward if a little tedious. Tentatively  
this driver (rev 8965) should now be capable of dealing with multiple  
plotting streams simultaneously.

-Hazen


-
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
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel