From: <hba...@us...> - 2007-06-03 02:14:53
|
Revision: 7706 http://plplot.svn.sourceforge.net/plplot/?rev=7706&view=rev Author: hbabcock Date: 2007-06-02 19:14:54 -0700 (Sat, 02 Jun 2007) Log Message: ----------- Changed the xwinttf driver so that it plays more nicely with multiple open streams drawing at the same time. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-06-03 00:37:37 UTC (rev 7705) +++ trunk/drivers/cairo.c 2007-06-03 02:14:54 UTC (rev 7706) @@ -39,39 +39,38 @@ #include <X11/Xutil.h> #include <X11/cursorfont.h> - /* PLplot header files */ #include "plplotP.h" #include "drivers.h" //--------------------------------------------- -// Constants & globel (to this file) variables +// Constants & global (to this file) variables //--------------------------------------------- #define MAX_STRING_LEN 500 #define MAX_MARKUP_LEN MAX_STRING_LEN * 10 +typedef struct { + cairo_surface_t *cairoSurface; + cairo_t *cairoContext; + Display *XDisplay; + Window XWindow; +} PLCairo; + /* xwintff specific constants and variables */ -#define MAXPAGES 50 #define DPI 72 #define XWINTTF_DEFAULT_X 720 #define XWINTTF_DEFAULT_Y 540 -char* plD_DEVICE_INFO_cairo = "xwinttf:TrueType X Windows Driver:1:cairo:59:xwinttf"; - -static int currentPage = -1; static int XScreen; -static Display *XDisplay = NULL; -static Window rootWindow ; -static Window XWindow[MAXPAGES]; +static Window rootWindow; static int windowXSize = XWINTTF_DEFAULT_X; static int windowYSize = XWINTTF_DEFAULT_Y; -static cairo_surface_t *cairoSurface[MAXPAGES]; -static cairo_t *cairoContext[MAXPAGES]; +char* plD_DEVICE_INFO_cairo = "xwinttf:TrueType X Windows Driver:1:cairo:59:xwinttf\n"; //----------------------------------------------- // Font style and weight lookup tables (copied @@ -172,14 +171,20 @@ { int i; char *a; + char plotTitle[40]; + Visual *defaultVisual; + XGCValues values; + cairo_matrix_t *flipVertical; + PLCairo *aStream; - pls->termin = 1; /* Interactive device */ - pls->dev_flush = 1; /* Handles flushes */ - pls->color = 1; /* Supports color */ - pls->dev_text = 1; /* Handles text */ - pls->dev_unicode = 1; /* Wants unicode text */ + // Stream setup + pls->termin = 1; /* Interactive device */ + pls->dev_flush = 1; /* Handles flushes */ + pls->color = 1; /* Supports color */ + pls->dev_text = 1; /* Handles text */ + pls->dev_unicode = 1; /* Wants unicode text */ pls->page = 0; - pls->dev_fill0 = 1; /* Supports hardware solid fills */ + pls->dev_fill0 = 1; /* Supports hardware solid fills */ plP_setpxl(DPI/25.4, DPI/25.4); @@ -191,14 +196,43 @@ plP_setphy((PLINT) 0, (PLINT) pls->xlength, (PLINT) 0, (PLINT) pls->ylength); } - XDisplay = XOpenDisplay(NULL); - if(XDisplay == NULL){ + // Allocate a cairo stream structure + aStream = malloc(sizeof(PLCairo)); + + // X Windows setup + aStream->XDisplay = NULL; + aStream->XDisplay = XOpenDisplay(NULL); + if(aStream->XDisplay == NULL){ printf("Failed to open X Windows display\n"); // some sort of error here } - XScreen = DefaultScreen(XDisplay); - rootWindow = RootWindow(XDisplay, XScreen); + XScreen = DefaultScreen(aStream->XDisplay); + rootWindow = RootWindow(aStream->XDisplay, XScreen); + + // Initialize plot title + sprintf(plotTitle, "PLplot"); + + // Create a X Window. + aStream->XWindow = XCreateSimpleWindow(aStream->XDisplay, rootWindow, 0, 0, windowXSize, windowYSize, + 1, BlackPixel(aStream->XDisplay, XScreen), BlackPixel(aStream->XDisplay, XScreen)); + XStoreName(aStream->XDisplay, aStream->XWindow, plotTitle); + XSelectInput(aStream->XDisplay, aStream->XWindow, NoEventMask); + XMapWindow(aStream->XDisplay, aStream->XWindow); + // Create an cairo surface & context that are associated with the X window. + defaultVisual = DefaultVisual(aStream->XDisplay, 0); + aStream->cairoSurface = cairo_xlib_surface_create(aStream->XDisplay, aStream->XWindow, defaultVisual, windowXSize, windowYSize); + aStream->cairoContext = cairo_create(aStream->cairoSurface); + + // Invert the coordinate system so the graphs are drawn right side up. + flipVertical = (cairo_matrix_t *) malloc (sizeof(cairo_matrix_t)); + cairo_matrix_init(flipVertical, 1.0, 0.0, 0.0, -1.0, 0.0, windowYSize); + cairo_set_matrix(aStream->cairoContext, flipVertical); + free(flipVertical); + + // Save the pointer to the structure in the PLplot stream + pls->dev = aStream; + // Initialize font table with either enviroment variables or defaults. // This was copied from the psttf driver. for(i=0;i<NPANGOLOOKUP;i++){ @@ -209,12 +243,6 @@ strcpy(familyLookup[i],defaultFamilyLookup[i]); } } - - // Set all cairo pointers to NULL - for(i=0;i<MAXPAGES;i++){ - cairoSurface[i] = NULL; - cairoContext[i] = NULL; - } } //---------------------------------------------------------------------- @@ -225,46 +253,17 @@ void plD_bop_xwinttf(PLStream *pls) { - char plotTitle[40]; - cairo_matrix_t *flipVertical; - Visual *defaultVisual; - XGCValues values; + PLCairo *aStream; - // Increment the page number. - currentPage++; - if(currentPage > MAXPAGES){ - currentPage = 0; - } - pls->page++; + aStream = (PLCairo *)pls->dev; - // Initialize plot title - sprintf(plotTitle, "PLplot (%d)", currentPage); - - // Create a X Window. - XWindow[currentPage] = XCreateSimpleWindow(XDisplay, rootWindow, 0, 0, windowXSize, windowYSize, - 1, BlackPixel(XDisplay, XScreen), BlackPixel(XDisplay, XScreen)); - XStoreName(XDisplay, XWindow[currentPage], plotTitle); - XSelectInput(XDisplay, XWindow[currentPage], NoEventMask); - XMapWindow(XDisplay, XWindow[currentPage]); - - // Create an cairo surface & context that are associated with the window. - defaultVisual = DefaultVisual(XDisplay, 0); - cairoSurface[currentPage] = cairo_xlib_surface_create(XDisplay, XWindow[currentPage], defaultVisual, windowXSize, windowYSize); - cairoContext[currentPage] = cairo_create(cairoSurface[currentPage]); - // Fill in the window with the background color. - cairo_rectangle(cairoContext[currentPage], 0.0, 0.0, windowXSize, windowYSize); - cairo_set_source_rgb(cairoContext[currentPage], + cairo_rectangle(aStream->cairoContext, 0.0, 0.0, windowXSize, windowYSize); + cairo_set_source_rgb(aStream->cairoContext, (double)pls->cmap0[0].r/255.0, (double)pls->cmap0[0].g/255.0, (double)pls->cmap0[0].b/255.0); - cairo_fill(cairoContext[currentPage]); - - // Invert the coordinate system so the graphs are drawn right side up. - flipVertical = (cairo_matrix_t *) malloc (sizeof(cairo_matrix_t)); - cairo_matrix_init(flipVertical, 1.0, 0.0, 0.0, -1.0, 0.0, windowYSize); - cairo_set_matrix(cairoContext[currentPage], flipVertical); - free(flipVertical); + cairo_fill(aStream->cairoContext); } //--------------------------------------------------------------------- @@ -275,11 +274,15 @@ void plD_line_xwinttf(PLStream *pls, short x1a, short y1a, short x2a, short y2a) { + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + set_current_context(pls); - cairo_move_to(cairoContext[currentPage], (double) x1a, (double) y1a); - cairo_line_to(cairoContext[currentPage], (double) x2a, (double) y2a); - cairo_stroke(cairoContext[currentPage]); + cairo_move_to(aStream->cairoContext, (double) x1a, (double) y1a); + cairo_line_to(aStream->cairoContext, (double) x2a, (double) y2a); + cairo_stroke(aStream->cairoContext); } //--------------------------------------------------------------------- @@ -290,8 +293,12 @@ void plD_polyline_xwinttf(PLStream *pls, short *xa, short *ya, PLINT npts) { + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + poly_line(pls, xa, ya, npts); - cairo_stroke(cairoContext[currentPage]); + cairo_stroke(aStream->cairoContext); } //--------------------------------------------------------------------- @@ -302,7 +309,13 @@ void plD_eop_xwinttf(PLStream *pls) { - XFlush(XDisplay); + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + + XFlush(aStream->XDisplay); + printf("Key <Return> to finish\n"); + getc(stdin); } //--------------------------------------------------------------------- @@ -313,20 +326,20 @@ void plD_tidy_xwinttf(PLStream *pls) { - int i; + PLCairo *aStream; - printf("Key <Return> to finish\n"); - getc(stdin); + aStream = (PLCairo *)pls->dev; - for(i=0;i<MAXPAGES;i++){ - if(cairoContext[i] != NULL){ - cairo_destroy(cairoContext[i]); - cairo_surface_destroy(cairoSurface[i]); - } - } + // Free the cairo context and surface. + cairo_destroy(aStream->cairoContext); + cairo_surface_destroy(aStream->cairoSurface); - XCloseDisplay(XDisplay); - free(XDisplay); + // Close the window and the display. + XFlush(aStream->XDisplay); + XDestroyWindow(aStream->XDisplay, aStream->XWindow); + + XCloseDisplay(aStream->XDisplay); + free(aStream->XDisplay); } //--------------------------------------------------------------------- @@ -350,20 +363,24 @@ void plD_esc_xwinttf(PLStream *pls, PLINT op, void *ptr) { + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + switch(op) { - case PLESC_FILL: // filled polygon + case PLESC_FILL: // filled polygon poly_line(pls, pls->dev_x, pls->dev_y, pls->dev_npts); - cairo_fill(cairoContext[currentPage]); + cairo_fill(aStream->cairoContext); break; case PLESC_HAS_TEXT: // render rext proc_str(pls, (EscText *) ptr); break; - case PLESC_FLUSH: // forced update of the window - XFlush(XDisplay); + case PLESC_FLUSH: // forced update of the window + XFlush(aStream->XDisplay); break; - case PLESC_GETC: // get cursor position - XFlush(XDisplay); + case PLESC_GETC: // get cursor position + XFlush(aStream->XDisplay); get_cursor(pls, (PLGraphicsIn*)ptr); break; } @@ -385,7 +402,10 @@ cairo_matrix_t *cairoTransformMatrix; PangoLayout *layout; PangoFontDescription *fontDescription; + PLCairo *aStream; + aStream = (PLCairo *)pls->dev; + set_current_context(pls); // Check that we got unicode, warning message and return if not @@ -407,22 +427,22 @@ textWithPangoMarkup = ucs4_to_pango_markup_format(args->unicode_array, args->unicode_array_len, fontSize); // Create the Pango text layout so we can figure out how big it is - layout = pango_cairo_create_layout(cairoContext[currentPage]); + layout = pango_cairo_create_layout(aStream->cairoContext); pango_layout_set_markup(layout, textWithPangoMarkup, -1); // fontDescription = pango_font_description_from_string(fontString); // pango_layout_set_font_description(layout, fontDescription); pango_layout_get_pixel_size(layout, &textXExtent, &textYExtent); // Move to the string reference point - cairo_move_to(cairoContext[currentPage], (double) args->x, (double) args->y); + cairo_move_to(aStream->cairoContext, (double) args->x, (double) args->y); // Save current transform matrix - cairo_save(cairoContext[currentPage]); + cairo_save(aStream->cairoContext); // Invert the coordinate system so that the text is drawn right side up cairoTransformMatrix = (cairo_matrix_t *) malloc (sizeof(cairo_matrix_t)); cairo_matrix_init(cairoTransformMatrix, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0); - cairo_transform(cairoContext[currentPage], cairoTransformMatrix); + cairo_transform(aStream->cairoContext, cairoTransformMatrix); // Extract rotation angle and shear from the PLplot tranformation matrix. // Compute sines and cosines of the angles as an optimization. @@ -438,19 +458,19 @@ cos_rot * sin_shear + sin_rot, -sin_rot * sin_shear + cos_rot, 0,0); - cairo_transform(cairoContext[currentPage], cairoTransformMatrix); + cairo_transform(aStream->cairoContext, cairoTransformMatrix); free(cairoTransformMatrix); // Move to the text starting point - cairo_rel_move_to(cairoContext[currentPage], + cairo_rel_move_to(aStream->cairoContext, (double)(-1.0 * args->just * (double)textXExtent), (double)(-0.5 * textYExtent)); // Render the text - pango_cairo_show_layout(cairoContext[currentPage], layout); + pango_cairo_show_layout(aStream->cairoContext, layout); // Restore the transform matrix to its state prior to the text transform. - cairo_restore(cairoContext[currentPage]); + cairo_restore(aStream->cairoContext); // Free the layout object and the markup string. g_object_unref(layout); @@ -636,18 +656,21 @@ { XEvent mouseEvent; Cursor xHairCursor; + PLCairo *aStream; + aStream = (PLCairo *)pls->dev; + // Initialize PLplot mouse event structure plGinInit(gin); // Create cross hair cursor & switch to using it - xHairCursor = XCreateFontCursor(XDisplay, XC_crosshair); - XDefineCursor(XDisplay, XWindow[currentPage], xHairCursor); + xHairCursor = XCreateFontCursor(aStream->XDisplay, XC_crosshair); + XDefineCursor(aStream->XDisplay, aStream->XWindow, xHairCursor); // Get the next mouse button release event - XSelectInput(XDisplay, XWindow[currentPage], ButtonReleaseMask); - XMaskEvent(XDisplay, ButtonReleaseMask, &mouseEvent); - XSelectInput(XDisplay, XWindow[currentPage], NoEventMask); + XSelectInput(aStream->XDisplay, aStream->XWindow, ButtonReleaseMask); + XMaskEvent(aStream->XDisplay, ButtonReleaseMask, &mouseEvent); + XSelectInput(aStream->XDisplay, aStream->XWindow, NoEventMask); // Update PLplot's mouse event structure gin->button = 0; @@ -657,8 +680,8 @@ gin->dY = (PLFLT)mouseEvent.xbutton.y/((PLFLT)(pls->ylength)); // Switch back to normal cursor - XUndefineCursor(XDisplay, XWindow[currentPage]); - XFlush(XDisplay); + XUndefineCursor(aStream->XDisplay, aStream->XWindow); + XFlush(aStream->XDisplay); } //--------------------------------------------------------------------- @@ -670,15 +693,19 @@ void set_current_context(PLStream *pls) { - cairo_set_source_rgb(cairoContext[currentPage], + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + + cairo_set_source_rgb(aStream->cairoContext, (double)pls->curcolor.r/255.0, (double)pls->curcolor.g/255.0, (double)pls->curcolor.b/255.0); // In Cairo, zero width lines are not hairlines, they are completely invisible. if(pls->width < 1){ - cairo_set_line_width(cairoContext[currentPage], 1.0); + cairo_set_line_width(aStream->cairoContext, 1.0); } else{ - cairo_set_line_width(cairoContext[currentPage], (double) pls->width); + cairo_set_line_width(aStream->cairoContext, (double) pls->width); } } @@ -693,11 +720,14 @@ void poly_line(PLStream *pls, short *xa, short *ya, PLINT npts) { int i; + PLCairo *aStream; + aStream = (PLCairo *)pls->dev; + set_current_context(pls); - cairo_move_to(cairoContext[currentPage], (double) xa[0], (double) ya[0]); + cairo_move_to(aStream->cairoContext, (double) xa[0], (double) ya[0]); for(i=1;i<npts;i++){ - cairo_line_to(cairoContext[currentPage], (double) xa[i], (double) ya[i]); + cairo_line_to(aStream->cairoContext, (double) xa[i], (double) ya[i]); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-06-09 01:23:03
|
Revision: 7711 http://plplot.svn.sourceforge.net/plplot/?rev=7711&view=rev Author: hbabcock Date: 2007-06-08 18:23:04 -0700 (Fri, 08 Jun 2007) Log Message: ----------- It appears that XCloseDisplay also frees the memory associated with the display structure/object, so the extra call the 'free' that causes problems on some platforms was removed. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-06-05 14:56:44 UTC (rev 7710) +++ trunk/drivers/cairo.c 2007-06-09 01:23:04 UTC (rev 7711) @@ -793,7 +793,6 @@ XDestroyWindow(aStream->XDisplay, aStream->XWindow); XCloseDisplay(aStream->XDisplay); - free(aStream->XDisplay); } //--------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-06-10 03:48:39
|
Revision: 7712 http://plplot.svn.sourceforge.net/plplot/?rev=7712&view=rev Author: hbabcock Date: 2007-06-09 20:48:32 -0700 (Sat, 09 Jun 2007) Log Message: ----------- Added support for family mode to the pngcairo driver. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-06-09 01:23:04 UTC (rev 7711) +++ trunk/drivers/cairo.c 2007-06-10 03:48:32 UTC (rev 7712) @@ -246,7 +246,7 @@ void plD_tidy_cairo(PLStream *pls) { PLCairo *aStream; - + aStream = (PLCairo *)pls->dev; // Free the cairo context and surface. @@ -1101,7 +1101,8 @@ void plD_dispatch_init_pngcairo (PLDispatchTable *pdt); void plD_init_pngcairo (PLStream *); -void plD_tidy_pngcairo (PLStream *); +void plD_bop_pngcairo (PLStream *); +void plD_eop_pngcairo (PLStream *); //--------------------------------------------------------------------- // dispatch_init_init() @@ -1109,7 +1110,7 @@ // Initialize device dispatch table //---------------------------------------------------------------------- -// svgcairo +// pngcairo void plD_dispatch_init_pngcairo(PLDispatchTable *pdt) { #ifndef ENABLE_DYNDRIVERS @@ -1117,13 +1118,13 @@ pdt->pl_DevName = "pngcairo"; #endif pdt->pl_type = plDevType_Interactive; - pdt->pl_seq = 62; + pdt->pl_seq = 63; pdt->pl_init = (plD_init_fp) plD_init_pngcairo; pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; - pdt->pl_eop = (plD_eop_fp) plD_eop_cairo; - pdt->pl_bop = (plD_bop_fp) plD_bop_cairo; - pdt->pl_tidy = (plD_tidy_fp) plD_tidy_pngcairo; + pdt->pl_eop = (plD_eop_fp) plD_eop_pngcairo; + pdt->pl_bop = (plD_bop_fp) plD_bop_pngcairo; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_cairo; pdt->pl_state = (plD_state_fp) plD_state_cairo; pdt->pl_esc = (plD_esc_fp) plD_esc_cairo; } @@ -1138,46 +1139,84 @@ { PLCairo *aStream; - printf("Cairo memory device called\n"); - // Setup the PLStream and the font lookup table stream_and_font_setup(pls, 0); - // Allocate a cairo stream structure - aStream = malloc(sizeof(PLCairo)); + // Initialize family file info + plFamInit(pls); // Prompt for a file name if not already set, and close the file // since we just need the name, not an open file. plOpenFile(pls); - if(pls->OutFile != NULL){ fclose(pls->OutFile); } - // Create a cairo surface & context for PNG file. - aStream->cairoSurface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, (double)pls->xlength, (double)pls->ylength); - aStream->cairoContext = cairo_create(aStream->cairoSurface); + // Allocate a cairo stream structure. + // + // NOTE: The check below is necessary since, in family mode, this function + // will be called multiple times. While you might think that it is + // sufficient to update what *should* be the only pointer to the contents + // of pls->dev, i.e. the pointer pls->dev itself, it appears that + // something else somewhere else is also pointing to pls->dev. If you + // change what pls->dev points to then you will get a "bus error", from + // which I infer the existence of a said bad stale pointer. + // + if(pls->dev == NULL){ + aStream = malloc(sizeof(PLCairo)); + } else { + aStream = pls->dev; + } // Save the pointer to the structure in the PLplot stream pls->dev = aStream; + // Create a new cairo surface & context for PNG file. + aStream->cairoSurface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, (double)pls->xlength, (double)pls->ylength); + aStream->cairoContext = cairo_create(aStream->cairoSurface); + // Invert the surface so that the graphs are drawn right side up. rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); } +//---------------------------------------------------------------------- +// plD_bop_pngcairo() +// +// PNG: Set up for the next page. +//---------------------------------------------------------------------- + +void plD_bop_pngcairo(PLStream *pls) +{ + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + + // Plot familying stuff. Not really understood, just copying gd.c + plGetFam(pls); + pls->famadv = 1; + pls->page++; + + // Fill in the window with the background color. + cairo_rectangle(aStream->cairoContext, 0.0, 0.0, pls->xlength, pls->ylength); + cairo_set_source_rgb(aStream->cairoContext, + (double)pls->cmap0[0].r/255.0, + (double)pls->cmap0[0].g/255.0, + (double)pls->cmap0[0].b/255.0); + cairo_fill(aStream->cairoContext); +} + //--------------------------------------------------------------------- -// plD_tidy_pngcairo() +// plD_eop_pngcairo() // -// PNG: Close graphics file or otherwise clean up. +// PNG: End of page. //--------------------------------------------------------------------- -void plD_tidy_pngcairo(PLStream *pls) +void plD_eop_pngcairo(PLStream *pls) { PLCairo *aStream; aStream = (PLCairo *)pls->dev; + if(pls->OutFile != NULL){ fclose(pls->OutFile); } cairo_surface_write_to_png(aStream->cairoSurface, (const char *)pls->FileName); - - plD_tidy_cairo(pls); } - + #endif @@ -1201,7 +1240,7 @@ // Initialize device dispatch table //---------------------------------------------------------------------- -// svgcairo +// memcairo void plD_dispatch_init_memcairo(PLDispatchTable *pdt) { #ifndef ENABLE_DYNDRIVERS @@ -1209,7 +1248,7 @@ pdt->pl_DevName = "memcairo"; #endif pdt->pl_type = plDevType_Interactive; - pdt->pl_seq = 63; + pdt->pl_seq = 64; pdt->pl_init = (plD_init_fp) plD_init_memcairo; pdt->pl_line = (plD_line_fp) plD_line_cairo; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_cairo; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-06-17 02:19:38
|
Revision: 7717 http://plplot.svn.sourceforge.net/plplot/?rev=7717&view=rev Author: hbabcock Date: 2007-06-16 19:19:39 -0700 (Sat, 16 Jun 2007) Log Message: ----------- Fixed math problem that caused text to be incorrectly sheared by the cairo drivers? Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-06-15 08:59:46 UTC (rev 7716) +++ trunk/drivers/cairo.c 2007-06-17 02:19:39 UTC (rev 7717) @@ -303,7 +303,7 @@ float fontSize; int textXExtent, textYExtent; char *textWithPangoMarkup; - PLFLT rotation, shear, cos_rot, sin_rot, sin_shear; + PLFLT rotation, shear, cos_rot, sin_rot, tan_shear; cairo_matrix_t *cairoTransformMatrix; PangoLayout *layout; PangoFontDescription *fontDescription; @@ -354,18 +354,18 @@ plRotationShear(args->xform, &rotation, &shear); cos_rot = cos(rotation); sin_rot = sin(rotation); - sin_shear = sin(shear); + tan_shear = tan(shear); // Apply the transform matrix - cairo_matrix_init(cairoTransformMatrix, + cairo_matrix_init(cairoTransformMatrix, cos_rot, -sin_rot, - cos_rot * sin_shear + sin_rot, - -sin_rot * sin_shear + cos_rot, + cos_rot * tan_shear + sin_rot, + -sin_rot * tan_shear + cos_rot, 0,0); cairo_transform(aStream->cairoContext, cairoTransformMatrix); free(cairoTransformMatrix); - + // Move to the text starting point cairo_rel_move_to(aStream->cairoContext, (double)(-1.0 * args->just * (double)textXExtent), @@ -606,7 +606,6 @@ PLCairo *aStream; aStream = (PLCairo *)pls->dev; - cairo_set_source_rgb(aStream->cairoContext, (double)pls->curcolor.r/255.0, (double)pls->curcolor.g/255.0, @@ -1157,7 +1156,7 @@ // of pls->dev, i.e. the pointer pls->dev itself, it appears that // something else somewhere else is also pointing to pls->dev. If you // change what pls->dev points to then you will get a "bus error", from - // which I infer the existence of a said bad stale pointer. + // which I infer the existence of said bad stale pointer. // if(pls->dev == NULL){ aStream = malloc(sizeof(PLCairo)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-06 01:40:59
|
Revision: 7778 http://plplot.svn.sourceforge.net/plplot/?rev=7778&view=rev Author: hbabcock Date: 2007-08-05 18:40:59 -0700 (Sun, 05 Aug 2007) Log Message: ----------- Fixed the cairo file drivers so that they would use the PLplot provided file stream rather than closing this stream and then opening their own. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-04 17:00:14 UTC (rev 7777) +++ trunk/drivers/cairo.c 2007-08-06 01:40:59 UTC (rev 7778) @@ -142,6 +142,7 @@ /* General */ void stream_and_font_setup(PLStream *, int); +cairo_status_t write_to_stream(void *, unsigned char *, unsigned int); /* String processing */ @@ -530,7 +531,7 @@ //--------------------------------------------------------------------- // close_span_tag // -// Close a span tag & brings us down to zero sub/super-script level +// Close a span tag & brings us down to zero sub/super-script level. //--------------------------------------------------------------------- void close_span_tag(char *pangoMarkupString, int upDown) @@ -552,6 +553,26 @@ } //--------------------------------------------------------------------- +// write_to_stream() +// +// Writes data to a open file stream. This function is passed to the +// Cairo file IO devices. +//--------------------------------------------------------------------- + +cairo_status_t write_to_stream(void *filePointer, unsigned char *data, unsigned int length) +{ + int bytes_written; + + bytes_written = fwrite(data, 1, length, (FILE*) filePointer); + if(bytes_written == length){ + return CAIRO_STATUS_SUCCESS; + } + else{ + return CAIRO_STATUS_WRITE_ERROR; + } +} + +//--------------------------------------------------------------------- // stream_and_font_setup() // // Initializes the PLStream structure for the cairo devices. @@ -920,13 +941,11 @@ // Allocate a cairo stream structure aStream = malloc(sizeof(PLCairo)); - // Prompt for a file name if not already set, and close the file - // since we just need the name, not an open file. + // Prompt for a file name if not already set. plOpenFile(pls); - if(pls->OutFile != NULL){ fclose(pls->OutFile); } // Create an cairo surface & context for PDF file. - aStream->cairoSurface = cairo_pdf_surface_create((const char *)pls->FileName, (double)pls->xlength, (double)pls->ylength); + aStream->cairoSurface = cairo_pdf_surface_create_for_stream((cairo_write_func_t)write_to_stream, pls->OutFile, (double)pls->xlength, (double)pls->ylength); aStream->cairoContext = cairo_create(aStream->cairoSurface); // Save the pointer to the structure in the PLplot stream @@ -993,13 +1012,11 @@ // Allocate a cairo stream structure aStream = malloc(sizeof(PLCairo)); - // Prompt for a file name if not already set, and close the file - // since we just need the name, not an open file. + // Prompt for a file name if not already set. plOpenFile(pls); - if(pls->OutFile != NULL){ fclose(pls->OutFile); } // Create an cairo surface & context for PS file. - aStream->cairoSurface = cairo_ps_surface_create((const char *)pls->FileName, (double)pls->xlength, (double)pls->ylength); + aStream->cairoSurface = cairo_ps_surface_create_for_stream((cairo_write_func_t)write_to_stream, pls->OutFile, (double)pls->xlength, (double)pls->ylength); aStream->cairoContext = cairo_create(aStream->cairoSurface); // Save the pointer to the structure in the PLplot stream @@ -1012,6 +1029,7 @@ // rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0); } + #endif @@ -1069,13 +1087,11 @@ // Allocate a cairo stream structure aStream = malloc(sizeof(PLCairo)); - // Prompt for a file name if not already set, and close the file - // since we just need the name, not an open file. + // Prompt for a file name if not already set. plOpenFile(pls); - if(pls->OutFile != NULL){ fclose(pls->OutFile); } // Create an cairo surface & context for SVG file. - aStream->cairoSurface = cairo_svg_surface_create((const char *)pls->FileName, (double)pls->xlength, (double)pls->ylength); + aStream->cairoSurface = cairo_svg_surface_create_for_stream((cairo_write_func_t)write_to_stream, pls->OutFile, (double)pls->xlength, (double)pls->ylength); aStream->cairoContext = cairo_create(aStream->cairoSurface); // Save the pointer to the structure in the PLplot stream @@ -1212,8 +1228,7 @@ PLCairo *aStream; aStream = (PLCairo *)pls->dev; - if(pls->OutFile != NULL){ fclose(pls->OutFile); } - cairo_surface_write_to_png(aStream->cairoSurface, (const char *)pls->FileName); + cairo_surface_write_to_png_stream(aStream->cairoSurface, (cairo_write_func_t)write_to_stream, pls->OutFile); } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-07 04:19:51
|
Revision: 7781 http://plplot.svn.sourceforge.net/plplot/?rev=7781&view=rev Author: hbabcock Date: 2007-08-06 21:19:50 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Fixed postscript plotting so that plot would have the right bounding box & appear right side up when viewed with gv on a linux box. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-06 23:10:22 UTC (rev 7780) +++ trunk/drivers/cairo.c 2007-08-07 04:19:50 UTC (rev 7781) @@ -1023,10 +1023,10 @@ pls->dev = aStream; // Rotate the surface to landscape. - rotate_cairo_surface(pls, 0.0, -1.0, -1.0, 0.0, pls->ylength, pls->ylength); + // rotate_cairo_surface(pls, 0.0, -1.0, -1.0, 0.0, pls->ylength, pls->ylength); // Invert the surface so that the graphs are drawn right side up. - // rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0); + rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0, pls->ylength); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-08 00:29:16
|
Revision: 7783 http://plplot.svn.sourceforge.net/plplot/?rev=7783&view=rev Author: hbabcock Date: 2007-08-07 17:29:19 -0700 (Tue, 07 Aug 2007) Log Message: ----------- Fixed postscript output to be drawn in landscape mode. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-07 07:20:49 UTC (rev 7782) +++ trunk/drivers/cairo.c 2007-08-08 00:29:19 UTC (rev 7783) @@ -1016,17 +1016,17 @@ plOpenFile(pls); // Create an cairo surface & context for PS file. - aStream->cairoSurface = cairo_ps_surface_create_for_stream((cairo_write_func_t)write_to_stream, pls->OutFile, (double)pls->xlength, (double)pls->ylength); + aStream->cairoSurface = cairo_ps_surface_create_for_stream((cairo_write_func_t)write_to_stream, pls->OutFile, (double)pls->ylength, (double)pls->xlength); aStream->cairoContext = cairo_create(aStream->cairoSurface); // Save the pointer to the structure in the PLplot stream pls->dev = aStream; // Rotate the surface to landscape. - // rotate_cairo_surface(pls, 0.0, -1.0, -1.0, 0.0, pls->ylength, pls->ylength); + rotate_cairo_surface(pls, 0.0, -1.0, -1.0, 0.0, pls->ylength, pls->xlength); // Invert the surface so that the graphs are drawn right side up. - rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0, pls->ylength); + // rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0, pls->ylength); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-08 01:09:28
|
Revision: 7784 http://plplot.svn.sourceforge.net/plplot/?rev=7784&view=rev Author: hbabcock Date: 2007-08-07 18:09:29 -0700 (Tue, 07 Aug 2007) Log Message: ----------- Tell PLplot that the plots are 10x larger than they actually are so that when they are rendered by high resolution drivers such as postscript the plots appear nice and smooth. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-08 00:29:19 UTC (rev 7783) +++ trunk/drivers/cairo.c 2007-08-08 01:09:29 UTC (rev 7784) @@ -51,6 +51,7 @@ //--------------------------------------------------------------------- #define DPI 72 +#define DOWNSCALE 0.1 #define PLCAIRO_DEFAULT_X 720 #define PLCAIRO_DEFAULT_Y 540 @@ -203,8 +204,8 @@ set_current_context(pls); - cairo_move_to(aStream->cairoContext, (double) x1a, (double) y1a); - cairo_line_to(aStream->cairoContext, (double) x2a, (double) y2a); + cairo_move_to(aStream->cairoContext, DOWNSCALE * (double) x1a, DOWNSCALE * (double) y1a); + cairo_line_to(aStream->cairoContext, DOWNSCALE * (double) x2a, DOWNSCALE * (double) y2a); cairo_stroke(aStream->cairoContext); } @@ -327,7 +328,7 @@ } // Calculate the font size (in pixels) - fontSize = pls->chrht * DPI/25.4; + fontSize = pls->chrht * DPI/25.4 * DOWNSCALE; // Convert the escape characters into the appropriate Pango markup textWithPangoMarkup = ucs4_to_pango_markup_format(args->unicode_array, args->unicode_array_len, fontSize); @@ -340,7 +341,7 @@ pango_layout_get_pixel_size(layout, &textXExtent, &textYExtent); // Move to the string reference point - cairo_move_to(aStream->cairoContext, (double) args->x, (double) args->y); + cairo_move_to(aStream->cairoContext, DOWNSCALE * (double) args->x, DOWNSCALE * (double) args->y); // Save current transform matrix cairo_save(aStream->cairoContext); @@ -599,7 +600,7 @@ pls->xlength = PLCAIRO_DEFAULT_X; pls->ylength = PLCAIRO_DEFAULT_Y; } - plP_setphy((PLINT) 0, (PLINT) pls->xlength, (PLINT) 0, (PLINT) pls->ylength); + plP_setphy((PLINT) 0, (PLINT) pls->xlength / DOWNSCALE, (PLINT) 0, (PLINT) pls->ylength / DOWNSCALE); // Initialize font table with either enviroment variables or defaults. // This was copied from the psttf driver. @@ -656,9 +657,9 @@ set_current_context(pls); - cairo_move_to(aStream->cairoContext, (double) xa[0], (double) ya[0]); + cairo_move_to(aStream->cairoContext, DOWNSCALE * (double) xa[0], DOWNSCALE * (double) ya[0]); for(i=1;i<npts;i++){ - cairo_line_to(aStream->cairoContext, (double) xa[i], (double) ya[i]); + cairo_line_to(aStream->cairoContext, DOWNSCALE * (double) xa[i], DOWNSCALE * (double) ya[i]); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-08 01:55:06
|
Revision: 7785 http://plplot.svn.sourceforge.net/plplot/?rev=7785&view=rev Author: hbabcock Date: 2007-08-07 18:55:06 -0700 (Tue, 07 Aug 2007) Log Message: ----------- Tweaked the rescaling so that things are drawn with the right physical coordinates (example 10). Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-08 01:09:29 UTC (rev 7784) +++ trunk/drivers/cairo.c 2007-08-08 01:55:06 UTC (rev 7785) @@ -328,7 +328,7 @@ } // Calculate the font size (in pixels) - fontSize = pls->chrht * DPI/25.4 * DOWNSCALE; + fontSize = pls->chrht * DPI/25.4; // Convert the escape characters into the appropriate Pango markup textWithPangoMarkup = ucs4_to_pango_markup_format(args->unicode_array, args->unicode_array_len, fontSize); @@ -594,7 +594,7 @@ pls->page = 0; pls->dev_fill0 = 1; /* Supports hardware solid fills */ - plP_setpxl(DPI/25.4, DPI/25.4); + plP_setpxl(DPI/25.4/DOWNSCALE, DPI/25.4/DOWNSCALE); if (pls->xlength <= 0 || pls->ylength <= 0){ pls->xlength = PLCAIRO_DEFAULT_X; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-16 02:05:09
|
Revision: 7804 http://plplot.svn.sourceforge.net/plplot/?rev=7804&view=rev Author: hbabcock Date: 2007-08-15 19:05:11 -0700 (Wed, 15 Aug 2007) Log Message: ----------- Added support for portrait mode to the pscairo driver. Plot orientations and aspect ratios follow that of the ps driver. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-15 23:02:28 UTC (rev 7803) +++ trunk/drivers/cairo.c 2007-08-16 02:05:11 UTC (rev 7804) @@ -1023,11 +1023,13 @@ // Save the pointer to the structure in the PLplot stream pls->dev = aStream; - // Rotate the surface to landscape. - rotate_cairo_surface(pls, 0.0, -1.0, -1.0, 0.0, pls->ylength, pls->xlength); + // Handle portrait or landscape + if(pls->portrait){ + rotate_cairo_surface(pls, (float)(pls->ylength)/(float)(pls->xlength), 0.0, 0.0, -(float)(pls->xlength)/(float)(pls->ylength), 0.0, pls->xlength); + } else { + rotate_cairo_surface(pls, 0.0, -1.0, -1.0, 0.0, pls->ylength, pls->xlength); + } - // Invert the surface so that the graphs are drawn right side up. - // rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0, pls->ylength); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-16 03:19:07
|
Revision: 7805 http://plplot.svn.sourceforge.net/plplot/?rev=7805&view=rev Author: hbabcock Date: 2007-08-15 20:19:06 -0700 (Wed, 15 Aug 2007) Log Message: ----------- A first pass at adding text clipping to the cairo drivers. This makes them a lot slower though, so perhaps this should be optional? Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-16 02:05:11 UTC (rev 7804) +++ trunk/drivers/cairo.c 2007-08-16 03:19:06 UTC (rev 7805) @@ -340,12 +340,16 @@ // pango_layout_set_font_description(layout, fontDescription); pango_layout_get_pixel_size(layout, &textXExtent, &textYExtent); + // Save current transform matrix & clipping region + cairo_save(aStream->cairoContext); + + // Setup the clipping region + cairo_rectangle(aStream->cairoContext, DOWNSCALE * pls->clpxmi, DOWNSCALE * pls->clpymi, DOWNSCALE * (pls->clpxma - pls->clpxmi), 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); - // Save current transform matrix - cairo_save(aStream->cairoContext); - // Invert the coordinate system so that the text is drawn right side up cairoTransformMatrix = (cairo_matrix_t *) malloc (sizeof(cairo_matrix_t)); cairo_matrix_init(cairoTransformMatrix, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-16 03:51:52
|
Revision: 7806 http://plplot.svn.sourceforge.net/plplot/?rev=7806&view=rev Author: hbabcock Date: 2007-08-15 20:51:50 -0700 (Wed, 15 Aug 2007) Log Message: ----------- Added support for the -ori option. Commented out text clipping for the time being. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-16 03:19:06 UTC (rev 7805) +++ trunk/drivers/cairo.c 2007-08-16 03:51:50 UTC (rev 7806) @@ -344,8 +344,8 @@ cairo_save(aStream->cairoContext); // Setup the clipping region - cairo_rectangle(aStream->cairoContext, DOWNSCALE * pls->clpxmi, DOWNSCALE * pls->clpymi, DOWNSCALE * (pls->clpxma - pls->clpxmi), DOWNSCALE * (pls->clpyma - pls->clpymi)); - cairo_clip(aStream->cairoContext); + // cairo_rectangle(aStream->cairoContext, DOWNSCALE * pls->clpxmi, DOWNSCALE * pls->clpymi, DOWNSCALE * (pls->clpxma - pls->clpxmi), 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); @@ -358,6 +358,7 @@ // Extract rotation angle and shear from the PLplot tranformation matrix. // Compute sines and cosines of the angles as an optimization. plRotationShear(args->xform, &rotation, &shear); + rotation -= pls->diorot * 3.14159 / 2.0; cos_rot = cos(rotation); sin_rot = sin(rotation); tan_shear = tan(shear); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-17 00:44:32
|
Revision: 7808 http://plplot.svn.sourceforge.net/plplot/?rev=7808&view=rev Author: hbabcock Date: 2007-08-16 17:44:34 -0700 (Thu, 16 Aug 2007) Log Message: ----------- Portrait mode tweaks of pscairo. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-16 07:49:05 UTC (rev 7807) +++ trunk/drivers/cairo.c 2007-08-17 00:44:34 UTC (rev 7808) @@ -1030,11 +1030,10 @@ // Handle portrait or landscape if(pls->portrait){ - rotate_cairo_surface(pls, (float)(pls->ylength)/(float)(pls->xlength), 0.0, 0.0, -(float)(pls->xlength)/(float)(pls->ylength), 0.0, pls->xlength); - } else { - rotate_cairo_surface(pls, 0.0, -1.0, -1.0, 0.0, pls->ylength, pls->xlength); + plsdiori(1); + pls->freeaspect = 1; } - + rotate_cairo_surface(pls, 0.0, -1.0, -1.0, 0.0, pls->ylength, pls->xlength); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-18 00:07:22
|
Revision: 7812 http://plplot.svn.sourceforge.net/plplot/?rev=7812&view=rev Author: hbabcock Date: 2007-08-17 17:07:24 -0700 (Fri, 17 Aug 2007) Log Message: ----------- Added a text clipping option to the Cairo devices. The user can now turn on text clipping by specifying text_clipping=1. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-17 07:24:39 UTC (rev 7811) +++ trunk/drivers/cairo.c 2007-08-18 00:07:24 UTC (rev 7812) @@ -58,9 +58,14 @@ #define MAX_STRING_LEN 500 #define MAX_MARKUP_LEN MAX_STRING_LEN * 10 +static int text_clipping; +static DrvOpt cairo_options[] = {{"text_clipping", DRV_INT, &text_clipping, "Use text clipping (text_clipping=0|1)"}, + {NULL, DRV_INT, NULL, NULL}}; + typedef struct { cairo_surface_t *cairoSurface; cairo_t *cairoContext; + short text_clipping; #if defined(PLD_xcairo) Display *XDisplay; Window XWindow; @@ -142,7 +147,7 @@ /* General */ -void stream_and_font_setup(PLStream *, int); +PLCairo *stream_and_font_setup(PLStream *, int); cairo_status_t write_to_stream(void *, unsigned char *, unsigned int); /* String processing */ @@ -343,9 +348,11 @@ // Save current transform matrix & clipping region cairo_save(aStream->cairoContext); - // Setup the clipping region - // cairo_rectangle(aStream->cairoContext, DOWNSCALE * pls->clpxmi, DOWNSCALE * pls->clpymi, DOWNSCALE * (pls->clpxma - pls->clpxmi), DOWNSCALE * (pls->clpyma - pls->clpymi)); - // cairo_clip(aStream->cairoContext); + // 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_clip(aStream->cairoContext); + } // Move to the string reference point cairo_move_to(aStream->cairoContext, DOWNSCALE * (double) args->x, DOWNSCALE * (double) args->y); @@ -583,12 +590,15 @@ // // Initializes the PLStream structure for the cairo devices. // Initializes the font lookup table. +// Checks for cairo specific user options. +// Returns a new PLCairo structure. //--------------------------------------------------------------------- -void stream_and_font_setup(PLStream *pls, int interactive) +PLCairo *stream_and_font_setup(PLStream *pls, int interactive) { int i; char *a; + PLCairo *aStream; // Stream setup pls->termin = interactive; /* Interactive device */ @@ -619,6 +629,23 @@ } } } + + // Allocate a cairo stream structure + aStream = malloc(sizeof(PLCairo)); + + // Set text clipping off as this makes the driver pretty slow + aStream->text_clipping = 0; + text_clipping = 0; + + // Check for cairo specific options + plParseDrvOpts(cairo_options); + + // Turn on text clipping if the user desires this + if(text_clipping){ + aStream->text_clipping = 1; + } + + return aStream; } //--------------------------------------------------------------------- @@ -746,11 +773,8 @@ PLCairo *aStream; // Setup the PLStream and the font lookup table - stream_and_font_setup(pls, 1); + aStream = stream_and_font_setup(pls, 1); - // Allocate a cairo stream structure - aStream = malloc(sizeof(PLCairo)); - // X Windows setup aStream->XDisplay = NULL; aStream->XDisplay = XOpenDisplay(NULL); @@ -942,11 +966,8 @@ PLCairo *aStream; // Setup the PLStream and the font lookup table - stream_and_font_setup(pls, 0); + aStream = stream_and_font_setup(pls, 0); - // Allocate a cairo stream structure - aStream = malloc(sizeof(PLCairo)); - // Prompt for a file name if not already set. plOpenFile(pls); @@ -1013,11 +1034,8 @@ PLCairo *aStream; // Setup the PLStream and the font lookup table - stream_and_font_setup(pls, 0); + aStream = stream_and_font_setup(pls, 0); - // Allocate a cairo stream structure - aStream = malloc(sizeof(PLCairo)); - // Prompt for a file name if not already set. plOpenFile(pls); @@ -1089,11 +1107,8 @@ PLCairo *aStream; // Setup the PLStream and the font lookup table - stream_and_font_setup(pls, 0); + aStream = stream_and_font_setup(pls, 0); - // Allocate a cairo stream structure - aStream = malloc(sizeof(PLCairo)); - // Prompt for a file name if not already set. plOpenFile(pls); @@ -1161,17 +1176,8 @@ { PLCairo *aStream; - // Setup the PLStream and the font lookup table - stream_and_font_setup(pls, 0); - - // Initialize family file info - plFamInit(pls); - - // Prompt for a file name if not already set, and close the file - // since we just need the name, not an open file. - plOpenFile(pls); - - // Allocate a cairo stream structure. + // Setup the PLStream and the font lookup table and allocate a cairo + // stream structure. // // NOTE: The check below is necessary since, in family mode, this function // will be called multiple times. While you might think that it is @@ -1182,11 +1188,18 @@ // which I infer the existence of said bad stale pointer. // if(pls->dev == NULL){ - aStream = malloc(sizeof(PLCairo)); + aStream = stream_and_font_setup(pls, 0); } else { + stream_and_font_setup(pls, 0); aStream = pls->dev; } + // Initialize family file info + plFamInit(pls); + + // Prompt for a file name if not already set. + plOpenFile(pls); + // Save the pointer to the structure in the PLplot stream pls->dev = aStream; @@ -1296,11 +1309,8 @@ pls->ylength = pls->phyyma; // Setup the PLStream and the font lookup table - stream_and_font_setup(pls, 0); + aStream = stream_and_font_setup(pls, 0); - // Allocate a cairo stream structure - aStream = malloc(sizeof(PLCairo)); - // Check that user supplied us with some memory to draw in if(pls->dev == NULL){ plexit("Must call plsmem first to set user plotting area!"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-27 15:40:47
|
Revision: 7822 http://plplot.svn.sourceforge.net/plplot/?rev=7822&view=rev Author: hbabcock Date: 2007-08-26 17:42:29 -0700 (Sun, 26 Aug 2007) Log Message: ----------- Changed cairo text transform so that it would preserve the height of a character rather than the distance between the upper and lower baselines of the text. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-26 15:14:24 UTC (rev 7821) +++ trunk/drivers/cairo.c 2007-08-27 00:42:29 UTC (rev 7822) @@ -321,7 +321,7 @@ float fontSize; int textXExtent, textYExtent; char *textWithPangoMarkup; - PLFLT rotation, shear, cos_rot, sin_rot, tan_shear; + PLFLT rotation, shear, cos_rot, sin_rot, cos_shear, sin_shear, tan_shear; cairo_matrix_t *cairoTransformMatrix; PangoLayout *layout; PangoFontDescription *fontDescription; @@ -379,14 +379,18 @@ rotation -= pls->diorot * 3.14159 / 2.0; cos_rot = cos(rotation); sin_rot = sin(rotation); - tan_shear = tan(shear); + cos_shear = cos(shear); + sin_shear = sin(shear); + // tan_shear = tan(shear); // Apply the transform matrix cairo_matrix_init(cairoTransformMatrix, cos_rot, -sin_rot, - cos_rot * tan_shear + sin_rot, - -sin_rot * tan_shear + cos_rot, + // cos_rot * tan_shear + sin_rot, + // -sin_rot * tan_shear + cos_rot, + cos_rot * sin_shear + sin_rot * cos_shear, + -sin_rot * sin_shear + cos_rot * cos_shear, 0,0); cairo_transform(aStream->cairoContext, cairoTransformMatrix); free(cairoTransformMatrix); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2007-08-27 15:51:32
|
Revision: 7821 http://plplot.svn.sourceforge.net/plplot/?rev=7821&view=rev Author: airwin Date: 2007-08-26 08:14:24 -0700 (Sun, 26 Aug 2007) Log Message: ----------- Better general handling of driver-dependent #includes + add new driver-dependent #includes for pscairo, pdfcairo, and svgcairo. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-22 15:06:43 UTC (rev 7820) +++ trunk/drivers/cairo.c 2007-08-26 15:14:24 UTC (rev 7821) @@ -31,21 +31,32 @@ #include <math.h> #include <cairo.h> -#include <cairo-xlib.h> #include <pango/pangocairo.h> -//#if defined(PLD_xcairo) +// PLplot header files + +#include "plplotP.h" +#include "drivers.h" + +// Driver-dependent includes +#if defined(PLD_xcairo) +#include <cairo-xlib.h> #include <X11/X.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/cursorfont.h> -//#endif +#endif +#if defined(PLD_pdfcairo) +#include <cairo-pdf.h> +#endif +#if defined(PLD_pscairo) +#include <cairo-ps.h> +#endif +#if defined(PLD_svgcairo) +#include <cairo-svg.h> +#endif -// PLplot header files -#include "plplotP.h" -#include "drivers.h" - //--------------------------------------------------------------------- // Constants & global (to this file) variables //--------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-28 04:31:24
|
Revision: 7823 http://plplot.svn.sourceforge.net/plplot/?rev=7823&view=rev Author: hbabcock Date: 2007-08-27 21:31:24 -0700 (Mon, 27 Aug 2007) Log Message: ----------- Added driver options so that you can adjust text aliasing (text_aliasing) and graphics aliasing (non_text_aliasing). The choices for both of these options are described here: http://cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t. Also some code cleanup. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-27 00:42:29 UTC (rev 7822) +++ trunk/drivers/cairo.c 2007-08-28 04:31:24 UTC (rev 7823) @@ -70,19 +70,26 @@ #define MAX_MARKUP_LEN MAX_STRING_LEN * 10 static int text_clipping; +static int text_aliasing; +static int non_text_aliasing; + static DrvOpt cairo_options[] = {{"text_clipping", DRV_INT, &text_clipping, "Use text clipping (text_clipping=0|1)"}, + {"text_aliasing", DRV_INT, &text_aliasing, "Set desired text aliasing (text_aliasing=0|1|2|3)"}, + {"non_text_aliasing", DRV_INT, &non_text_aliasing, "Set desired non-text (i.e. graphics) aliasing (non_text_aliasing=0|1|2|3)"}, {NULL, DRV_INT, NULL, NULL}}; typedef struct { - cairo_surface_t *cairoSurface; - cairo_t *cairoContext; - short text_clipping; + cairo_surface_t *cairoSurface; + cairo_t *cairoContext; + short text_clipping; + short text_aliasing; + short non_text_aliasing; #if defined(PLD_xcairo) - Display *XDisplay; - Window XWindow; + Display *XDisplay; + Window XWindow; #endif #if defined(PLD_memcairo) - unsigned char *memory; + unsigned char *memory; #endif } PLCairo; @@ -321,8 +328,10 @@ float fontSize; int textXExtent, textYExtent; char *textWithPangoMarkup; - PLFLT rotation, shear, cos_rot, sin_rot, cos_shear, sin_shear, tan_shear; + PLFLT rotation, shear, cos_rot, sin_rot, cos_shear, sin_shear; cairo_matrix_t *cairoTransformMatrix; + cairo_font_options_t *cairoFontOptions; + PangoContext *context; PangoLayout *layout; PangoFontDescription *fontDescription; PLCairo *aStream; @@ -352,10 +361,16 @@ // Create the Pango text layout so we can figure out how big it is layout = pango_cairo_create_layout(aStream->cairoContext); pango_layout_set_markup(layout, textWithPangoMarkup, -1); - // fontDescription = pango_font_description_from_string(fontString); - // pango_layout_set_font_description(layout, fontDescription); pango_layout_get_pixel_size(layout, &textXExtent, &textYExtent); + // Set font aliasing + context = pango_layout_get_context(layout); + cairoFontOptions = cairo_font_options_create(); + cairo_font_options_set_antialias(cairoFontOptions, aStream->text_aliasing); + pango_cairo_context_set_font_options(context, cairoFontOptions); + pango_layout_context_changed(layout); + cairo_font_options_destroy(cairoFontOptions); + // Save current transform matrix & clipping region cairo_save(aStream->cairoContext); @@ -381,14 +396,11 @@ sin_rot = sin(rotation); cos_shear = cos(shear); sin_shear = sin(shear); - // tan_shear = tan(shear); // Apply the transform matrix cairo_matrix_init(cairoTransformMatrix, cos_rot, -sin_rot, - // cos_rot * tan_shear + sin_rot, - // -sin_rot * tan_shear + cos_rot, cos_rot * sin_shear + sin_rot * cos_shear, -sin_rot * sin_shear + cos_rot * cos_shear, 0,0); @@ -651,6 +663,8 @@ // Set text clipping off as this makes the driver pretty slow aStream->text_clipping = 0; text_clipping = 0; + text_aliasing = 0; // use default text aliasing by default + non_text_aliasing = 0; // use default graphics aliasing by default // Check for cairo specific options plParseDrvOpts(cairo_options); @@ -660,6 +674,10 @@ aStream->text_clipping = 1; } + // Record users desired text and graphics aliasing + aStream->text_aliasing = text_aliasing; + aStream->non_text_aliasing = non_text_aliasing; + return aStream; } @@ -820,6 +838,9 @@ // Invert the surface so that the graphs are drawn right side up. rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); + + // Set graphics aliasing + cairo_set_antialias(aStream->cairoContext, aStream->non_text_aliasing); } //--------------------------------------------------------------------- @@ -995,6 +1016,9 @@ // Invert the surface so that the graphs are drawn right side up. rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); + + // Set graphics aliasing + cairo_set_antialias(aStream->cairoContext, aStream->non_text_aliasing); } #endif @@ -1136,6 +1160,9 @@ // Invert the surface so that the graphs are drawn right side up. rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); + + // Set graphics aliasing + cairo_set_antialias(aStream->cairoContext, aStream->non_text_aliasing); } #endif @@ -1224,6 +1251,9 @@ // Invert the surface so that the graphs are drawn right side up. rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); + + // Set graphics aliasing + cairo_set_antialias(aStream->cairoContext, aStream->non_text_aliasing); } //---------------------------------------------------------------------- @@ -1344,6 +1374,9 @@ // Invert the surface so that the graphs are drawn right side up. rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); + + // Set graphics aliasing + cairo_set_antialias(aStream->cairoContext, aStream->non_text_aliasing); } //--------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-08-29 01:30:09
|
Revision: 7824 http://plplot.svn.sourceforge.net/plplot/?rev=7824&view=rev Author: hbabcock Date: 2007-08-28 18:30:07 -0700 (Tue, 28 Aug 2007) Log Message: ----------- Added a more extensive description of the cairo aliasing options. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-28 04:31:24 UTC (rev 7823) +++ trunk/drivers/cairo.c 2007-08-29 01:30:07 UTC (rev 7824) @@ -74,8 +74,8 @@ static int non_text_aliasing; static DrvOpt cairo_options[] = {{"text_clipping", DRV_INT, &text_clipping, "Use text clipping (text_clipping=0|1)"}, - {"text_aliasing", DRV_INT, &text_aliasing, "Set desired text aliasing (text_aliasing=0|1|2|3)"}, - {"non_text_aliasing", DRV_INT, &non_text_aliasing, "Set desired non-text (i.e. graphics) aliasing (non_text_aliasing=0|1|2|3)"}, + {"text_aliasing", DRV_INT, &text_aliasing, "Set desired text aliasing (text_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)"}, + {"non_text_aliasing", DRV_INT, &non_text_aliasing, "Set desired non-text (i.e. graphics) aliasing (non_text_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"}, {NULL, DRV_INT, NULL, NULL}}; typedef struct { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-09-01 16:18:16
|
Revision: 7825 http://plplot.svn.sourceforge.net/plplot/?rev=7825&view=rev Author: hbabcock Date: 2007-09-01 09:17:56 -0700 (Sat, 01 Sep 2007) Log Message: ----------- Changed the names of the text and graphics anti-aliasing flags. text_aliasing -> text_anti_aliasing, non_text_aliasing -> graphics_anti_aliasing. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-08-29 01:30:07 UTC (rev 7824) +++ trunk/drivers/cairo.c 2007-09-01 16:17:56 UTC (rev 7825) @@ -70,20 +70,20 @@ #define MAX_MARKUP_LEN MAX_STRING_LEN * 10 static int text_clipping; -static int text_aliasing; -static int non_text_aliasing; +static int text_anti_aliasing; +static int graphics_anti_aliasing; static DrvOpt cairo_options[] = {{"text_clipping", DRV_INT, &text_clipping, "Use text clipping (text_clipping=0|1)"}, - {"text_aliasing", DRV_INT, &text_aliasing, "Set desired text aliasing (text_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)"}, - {"non_text_aliasing", DRV_INT, &non_text_aliasing, "Set desired non-text (i.e. graphics) aliasing (non_text_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"}, + {"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"}, {NULL, DRV_INT, NULL, NULL}}; typedef struct { cairo_surface_t *cairoSurface; cairo_t *cairoContext; short text_clipping; - short text_aliasing; - short non_text_aliasing; + short text_anti_aliasing; + short graphics_anti_aliasing; #if defined(PLD_xcairo) Display *XDisplay; Window XWindow; @@ -366,7 +366,7 @@ // Set font aliasing context = pango_layout_get_context(layout); cairoFontOptions = cairo_font_options_create(); - cairo_font_options_set_antialias(cairoFontOptions, aStream->text_aliasing); + cairo_font_options_set_antialias(cairoFontOptions, aStream->text_anti_aliasing); pango_cairo_context_set_font_options(context, cairoFontOptions); pango_layout_context_changed(layout); cairo_font_options_destroy(cairoFontOptions); @@ -663,8 +663,8 @@ // Set text clipping off as this makes the driver pretty slow aStream->text_clipping = 0; text_clipping = 0; - text_aliasing = 0; // use default text aliasing by default - non_text_aliasing = 0; // use default graphics aliasing by default + text_anti_aliasing = 0; // use 'default' text aliasing by default + graphics_anti_aliasing = 0; // use 'default' graphics aliasing by default // Check for cairo specific options plParseDrvOpts(cairo_options); @@ -675,8 +675,8 @@ } // Record users desired text and graphics aliasing - aStream->text_aliasing = text_aliasing; - aStream->non_text_aliasing = non_text_aliasing; + aStream->text_anti_aliasing = text_anti_aliasing; + aStream->graphics_anti_aliasing = graphics_anti_aliasing; return aStream; } @@ -840,7 +840,7 @@ rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); // Set graphics aliasing - cairo_set_antialias(aStream->cairoContext, aStream->non_text_aliasing); + cairo_set_antialias(aStream->cairoContext, aStream->graphics_anti_aliasing); } //--------------------------------------------------------------------- @@ -1018,7 +1018,7 @@ rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); // Set graphics aliasing - cairo_set_antialias(aStream->cairoContext, aStream->non_text_aliasing); + cairo_set_antialias(aStream->cairoContext, aStream->graphics_anti_aliasing); } #endif @@ -1162,7 +1162,7 @@ rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); // Set graphics aliasing - cairo_set_antialias(aStream->cairoContext, aStream->non_text_aliasing); + cairo_set_antialias(aStream->cairoContext, aStream->graphics_anti_aliasing); } #endif @@ -1253,7 +1253,7 @@ rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); // Set graphics aliasing - cairo_set_antialias(aStream->cairoContext, aStream->non_text_aliasing); + cairo_set_antialias(aStream->cairoContext, aStream->graphics_anti_aliasing); } //---------------------------------------------------------------------- @@ -1376,7 +1376,7 @@ rotate_cairo_surface(pls, 1.0, 0.0, 0.0, -1.0, 0.0, pls->ylength); // Set graphics aliasing - cairo_set_antialias(aStream->cairoContext, aStream->non_text_aliasing); + cairo_set_antialias(aStream->cairoContext, aStream->graphics_anti_aliasing); } //--------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2007-09-06 07:54:37
|
Revision: 7834 http://plplot.svn.sourceforge.net/plplot/?rev=7834&view=rev Author: airwin Date: 2007-09-06 00:54:41 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Use same default font names as psttf device driver. Remove "if(familyLookup[i] == NULL){" logic since i is not defined. (This bug fix is required to get same font selection as psttf device driver. In particular the font environment variables don't work at all without this bug fix.) Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-09-06 05:59:27 UTC (rev 7833) +++ trunk/drivers/cairo.c 2007-09-06 07:54:41 UTC (rev 7834) @@ -122,11 +122,11 @@ #define NPANGOLOOKUP 5 const char *defaultFamilyLookup[NPANGOLOOKUP] = { - "Sans", - "Serif", - "Monospace", - "Sans", - "Sans" + "Arial,Bitstream-Vera-Sans,sans", + "Times-Roman,Bitstream-Vera-Serif,serif", + "Courier,Bitstream-Vera-Sans-Mono,monospace", + "Arial,Bitstream-Vera-Sans,sans,serif", + "Arial,Bitstream-Vera-Sans,sans,serif" }; const char *envFamilyLookup[NPANGOLOOKUP] = { @@ -646,15 +646,13 @@ // Initialize font table with either enviroment variables or defaults. // This was copied from the psttf driver. - if(familyLookup[i] == NULL){ - for(i=0;i<NPANGOLOOKUP;i++){ - if((a = getenv(envFamilyLookup[i])) != NULL){ - strcpy(familyLookup[i],a); - } - else { - strcpy(familyLookup[i],defaultFamilyLookup[i]); - } + for(i=0;i<NPANGOLOOKUP;i++){ + if((a = getenv(envFamilyLookup[i])) != NULL){ + strcpy(familyLookup[i],a); } + else { + strcpy(familyLookup[i],defaultFamilyLookup[i]); + } } // Allocate a cairo stream structure This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-09-07 02:03:25
|
Revision: 7836 http://plplot.svn.sourceforge.net/plplot/?rev=7836&view=rev Author: hbabcock Date: 2007-09-06 19:03:28 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Fixed to properly handle double escapes. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-09-06 21:55:11 UTC (rev 7835) +++ trunk/drivers/cairo.c 2007-09-07 02:03:28 UTC (rev 7836) @@ -485,6 +485,7 @@ } i++; if (ucs4[i] == (PLUNICODE)plplotEsc){ // a escape character to display + ucs4_to_utf8(ucs4[i],utf8); strcat(pangoMarkupString, utf8); i++; continue; @@ -739,7 +740,6 @@ aStream = (PLCairo *)pls->dev; - // Invert the coordinate system so the graphs are drawn right side up. matrix = (cairo_matrix_t *) malloc (sizeof(cairo_matrix_t)); cairo_matrix_init(matrix, x11, x12, x21, x22, x0, y0); cairo_transform(aStream->cairoContext, matrix); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-09-07 02:25:22
|
Revision: 7837 http://plplot.svn.sourceforge.net/plplot/?rev=7837&view=rev Author: hbabcock Date: 2007-09-06 19:25:25 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Added support for plot buffering/plreplot. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-09-07 02:03:28 UTC (rev 7836) +++ trunk/drivers/cairo.c 2007-09-07 02:25:25 UTC (rev 7837) @@ -636,6 +636,7 @@ pls->dev_unicode = 1; /* Wants unicode text */ pls->page = 0; pls->dev_fill0 = 1; /* Supports hardware solid fills */ + pls->plbuf_write = 1; /* Activate plot buffer */ plP_setpxl(DPI/25.4/DOWNSCALE, DPI/25.4/DOWNSCALE); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-09-07 03:54:45
|
Revision: 7838 http://plplot.svn.sourceforge.net/plplot/?rev=7838&view=rev Author: hbabcock Date: 2007-09-06 20:54:48 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Added expose event handling to xcairo. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-09-07 02:25:25 UTC (rev 7837) +++ trunk/drivers/cairo.c 2007-09-07 03:54:48 UTC (rev 7838) @@ -85,6 +85,7 @@ short text_anti_aliasing; short graphics_anti_aliasing; #if defined(PLD_xcairo) + short exit_event_loop; Display *XDisplay; Window XWindow; #endif @@ -816,7 +817,8 @@ } XScreen = DefaultScreen(aStream->XDisplay); rootWindow = RootWindow(aStream->XDisplay, XScreen); - + aStream->exit_event_loop = 0; + // Initialize plot title sprintf(plotTitle, "PLplot"); @@ -850,13 +852,42 @@ void plD_eop_xcairo(PLStream *pls) { + int number_chars; + long event_mask; + char event_string[10]; + KeySym keysym; + XComposeStatus cs; + XEvent event; PLCairo *aStream; aStream = (PLCairo *)pls->dev; XFlush(aStream->XDisplay); - printf("Key <Return> to finish\n"); - getc(stdin); + + // Loop, handling selected events, till the user elects to close the plot. + printf("Click on the plot and key <Return> to exit.\n"); + event_mask = ButtonPressMask | KeyPressMask | ExposureMask; + XSelectInput(aStream->XDisplay, aStream->XWindow, event_mask); + while(!aStream->exit_event_loop){ + XWindowEvent(aStream->XDisplay, aStream->XWindow, event_mask, &event); + switch(event.type){ + case KeyPress: + number_chars = XLookupString((XKeyEvent *)&event, event_string, 10, &keysym, &cs); + event_string[number_chars] = '\0'; + if(keysym == XK_Return){ + aStream->exit_event_loop = 1; + } + break; + case Expose: + plD_bop_cairo(pls); + plRemakePlot(pls); + XFlush(aStream->XDisplay); + break; + } + } + + // printf("Key <Return> to finish\n"); + //getc(stdin); } //--------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2007-09-07 18:01:24
|
Revision: 7839 http://plplot.svn.sourceforge.net/plplot/?rev=7839&view=rev Author: airwin Date: 2007-09-07 11:01:26 -0700 (Fri, 07 Sep 2007) Log Message: ----------- Bugfix. #include <X11/keysym.h> for the PLD_xcairo case so that XK_* symbol definitions (e.g., XK_Return) are defined. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-09-07 03:54:48 UTC (rev 7838) +++ trunk/drivers/cairo.c 2007-09-07 18:01:26 UTC (rev 7839) @@ -33,7 +33,7 @@ #include <cairo.h> #include <pango/pangocairo.h> -// PLplot header files +// PLplot header files (must occur before driver-dependent includes) #include "plplotP.h" #include "drivers.h" @@ -45,6 +45,7 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/cursorfont.h> +#include <X11/keysym.h> #endif #if defined(PLD_pdfcairo) #include <cairo-pdf.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2007-09-07 23:07:41
|
Revision: 7845 http://plplot.svn.sourceforge.net/plplot/?rev=7845&view=rev Author: hbabcock Date: 2007-09-07 16:07:45 -0700 (Fri, 07 Sep 2007) Log Message: ----------- Fix issue where xcairo would go through all the pages in a multiple page plot after the return key had been pressed once. Modified Paths: -------------- trunk/drivers/cairo.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2007-09-07 22:21:10 UTC (rev 7844) +++ trunk/drivers/cairo.c 2007-09-07 23:07:45 UTC (rev 7845) @@ -886,6 +886,7 @@ break; } } + aStream->exit_event_loop = 0; // printf("Key <Return> to finish\n"); //getc(stdin); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |