From: <ai...@us...> - 2011-04-30 19:11:50
|
Revision: 11737 http://plplot.svn.sourceforge.net/plplot/?rev=11737&view=rev Author: airwin Date: 2011-04-30 19:11:44 +0000 (Sat, 30 Apr 2011) Log Message: ----------- Specify prototype for label_box_custom rather than using default prototype. Hide this function from external use by _not_ specifying PLDLLIMPEXP qualifier. Modified Paths: -------------- trunk/include/plplotP.h trunk/src/plbox.c Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2011-04-30 18:37:28 UTC (rev 11736) +++ trunk/include/plplotP.h 2011-04-30 19:11:44 UTC (rev 11737) @@ -490,6 +490,11 @@ void pldtik( PLFLT vmin, PLFLT vmax, PLFLT *tick, PLINT *nsubt, PLBOOL ld ); +// Writes numeric labels on side(s) of box in custom locations + +void +label_box_custom( const char *xopt, PLINT n_xticks, const PLFLT *xticks, const char *yopt, PLINT n_yticks, const PLFLT *yticks ); + // Determine factor to convert date / time in seconds to more natural // units Modified: trunk/src/plbox.c =================================================================== --- trunk/src/plbox.c 2011-04-30 18:37:28 UTC (rev 11736) +++ trunk/src/plbox.c 2011-04-30 19:11:44 UTC (rev 11737) @@ -1515,7 +1515,7 @@ //-------------------------------------------------------------------------- void -label_box_custom( const char *xopt, PLINT n_xticks, PLFLT *xticks, const char *yopt, PLINT n_yticks, PLFLT *yticks ) +label_box_custom( const char *xopt, PLINT n_xticks, const PLFLT *xticks, const char *yopt, PLINT n_yticks, const PLFLT *yticks ) { static char string[STRING_LEN]; PLBOOL ldx, lfx, lix, llx, lmx, lnx, ltx, lox; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-05-01 19:27:27
|
Revision: 11739 http://plplot.svn.sourceforge.net/plplot/?rev=11739&view=rev Author: airwin Date: 2011-05-01 19:27:20 +0000 (Sun, 01 May 2011) Log Message: ----------- Add "u" (exactly like "b" except don't draw edge line) and "w" (exactly like "c" except don't draw edge line) options for xopt and yopt. These new "u" and "w" options are especially useful for plcolorbar where often the user does not want an edge line. Modified Paths: -------------- trunk/doc/docbook/src/api.xml trunk/src/plbox.c Modified: trunk/doc/docbook/src/api.xml =================================================================== --- trunk/doc/docbook/src/api.xml 2011-05-01 19:14:40 UTC (rev 11738) +++ trunk/doc/docbook/src/api.xml 2011-05-01 19:27:20 UTC (rev 11739) @@ -1060,6 +1060,16 @@ <literal>t</literal>: Draws major ticks. </para> </listitem> + <listitem> + <para> + <literal>u</literal>: Exactly like "b" except don't draw edge line. + </para> + </listitem> + <listitem> + <para> + <literal>w</literal>: Exactly like "c" except don't draw edge line. + </para> + </listitem> </itemizedlist> </para> </listitem> @@ -6300,7 +6310,7 @@ <sect1 id="pllegend" renderas="sect3"> <title> - <function>pllegend</function>: Plot legend using discretely annotated filled boxes, lines, and/or symbols + <function>pllegend</function>: Plot legend using discretely annotated filled boxes, lines, and/or lines of symbols </title> <para> Modified: trunk/src/plbox.c =================================================================== --- trunk/src/plbox.c 2011-05-01 19:14:40 UTC (rev 11738) +++ trunk/src/plbox.c 2011-05-01 19:27:20 UTC (rev 11739) @@ -93,8 +93,8 @@ // xopt and yopt are character strings which define the box as follows: // // a: Draw axis (X is horizontal line Y=0, Y is vertical line X=0) -// b: Draw bottom (X) or left (Y) edge of frame -// c: Draw top (X) or right (Y) edge of frame +// b: Draw bottom (X) or left (Y) frame of box +// c: Draw top (X) or right (Y) frame of box // d: Interpret axis as a date/time when writing labels // f: Always use fixed point numeric labels // g: Draws a grid at the major tick interval @@ -106,6 +106,8 @@ // o: Label text is generated by a user-defined function // t: Draw major tick marks // s: Draw minor tick marks +// u: like b except exclude drawing the edge. +// w: like c except exclude drawing the edge. // v: (for Y only) Label vertically // // xtick, ytick are the major tick intervals required, zero for @@ -120,8 +122,8 @@ const char *xopt, PLFLT xtick, PLINT nxsub, const char *yopt, PLFLT ytick, PLINT nysub ) { - PLBOOL lax, lbx, lcx, ldx, lgx, lix, llx, lsx, ltx; - PLBOOL lay, lby, lcy, ldy, lgy, liy, lly, lsy, lty; + PLBOOL lax, lbx, lcx, ldx, lgx, lix, llx, lsx, ltx, lux, lwx; + PLBOOL lay, lBy, lby, lCy, lcy, ldy, lgy, liy, lly, lsy, lty, luy, lwy; PLINT xmajor, xminor, ymajor, yminor; PLINT i, i1x, i2x, i3x, i4x, i1y, i2y, i3y, i4y; PLINT nxsub1, nysub1; @@ -166,6 +168,8 @@ llx = plP_stsearch( xopt, 'l' ); lsx = plP_stsearch( xopt, 's' ); ltx = plP_stsearch( xopt, 't' ); + lux = plP_stsearch( xopt, 'u' ); + lwx = plP_stsearch( xopt, 'w' ); lay = plP_stsearch( yopt, 'a' ); lby = plP_stsearch( yopt, 'b' ); @@ -176,6 +180,8 @@ lly = plP_stsearch( yopt, 'l' ); lsy = plP_stsearch( yopt, 's' ); lty = plP_stsearch( yopt, 't' ); + luy = plP_stsearch( xopt, 'u' ); + lwy = plP_stsearch( xopt, 'w' ); // Tick and subtick sizes in device coords @@ -241,12 +247,15 @@ i4y = ymajor; } -// Draw the bottom edge of the box +// Draw the bottom frame of the box - if ( lbx ) + if ( lbx || lux ) { - plP_movphy( vppxmi, vppymi ); - plP_draphy( vppxma, vppymi ); + if ( lbx ) + { + plP_movphy( vppxmi, vppymi ); + plP_draphy( vppxma, vppymi ); + } if ( ltx ) { if ( ldx ) @@ -288,12 +297,15 @@ } } -// Draw right-hand edge of box +// Draw right-hand frame of box - if ( lcy ) + if ( lcy || lwy ) { - plP_movphy( vppxma, vppymi ); - plP_draphy( vppxma, vppyma ); + if ( lcy ) + { + plP_movphy( vppxma, vppymi ); + plP_draphy( vppxma, vppyma ); + } if ( lty ) { if ( ldy ) @@ -335,12 +347,15 @@ } } -// Draw the top edge of the box +// Draw the top frame of the box - if ( lcx ) + if ( lcx || lwx ) { - plP_movphy( vppxma, vppyma ); - plP_draphy( vppxmi, vppyma ); + if ( lcx ) + { + plP_movphy( vppxma, vppyma ); + plP_draphy( vppxmi, vppyma ); + } if ( ltx ) { if ( ldx ) @@ -382,12 +397,15 @@ } } -// Draw left-hand edge of box +// Draw left-hand frame of box - if ( lby ) + if ( lby || luy ) { - plP_movphy( vppxmi, vppyma ); - plP_draphy( vppxmi, vppymi ); + if ( lby ) + { + plP_movphy( vppxmi, vppyma ); + plP_draphy( vppxmi, vppymi ); + } if ( lty ) { if ( ldy ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-05-01 20:08:09
|
Revision: 11741 http://plplot.svn.sourceforge.net/plplot/?rev=11741&view=rev Author: airwin Date: 2011-05-01 20:08:03 +0000 (Sun, 01 May 2011) Log Message: ----------- Control whether edges of colorbar box and caps are drawn using the PL_COLORBAR_(NOEDGE, EDGE) opt bits. The default is PL_COLORBAR_NOEDGE. For usage where the background color is not included in the color range (such as example 33) PL_COLORBAR_NOEDGE makes a nicer looking result. For usage where the background colour is included in the color range (such as example 16) PL_COLORBAR_EDGE makes a nicer looking result. Modified Paths: -------------- trunk/examples/c/x16c.c trunk/include/plplot.h trunk/src/pllegend.c Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-05-01 19:32:54 UTC (rev 11740) +++ trunk/examples/c/x16c.c 2011-05-01 20:08:03 UTC (rev 11741) @@ -241,9 +241,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, + plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bv", "", + cont_color, cont_width, 0.0, 0, "v", "", ns + 1, shedge ); // Reset text and tick sizes @@ -287,9 +287,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, + plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bv", "", + cont_color, cont_width, 0.0, 0, "v", "", ns + 1, shedge ); // Reset text and tick sizes @@ -333,9 +333,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, + plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bv", "", + cont_color, cont_width, 0.0, 0, "v", "", ns + 1, shedge ); // Reset text and tick sizes @@ -378,9 +378,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, + plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - 2, 3, 0.0, 0, "bv", "", + 2, 3, 0.0, 0, "v", "", ns + 1, shedge ); // Reset text and tick sizes @@ -474,7 +474,7 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, + plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, 0.06, 0.15, 0.03, 0.7, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bv", "", ns + 1, shedge ); Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2011-05-01 19:32:54 UTC (rev 11740) +++ trunk/include/plplot.h 2011-05-01 20:08:03 UTC (rev 11741) @@ -1257,6 +1257,8 @@ #define PL_COLORBAR_ORIENT_TOP 4096 #define PL_COLORBAR_ORIENT_LEFT 8192 #define PL_COLORBAR_ORIENT_BOTTOM 16384 +#define PL_COLORBAR_NOEDGE 32768 +#define PL_COLORBAR_EDGE 65536 // Routine for drawing discrete line, symbol, or cmap0 legends PLDLLIMPEXP void Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-05-01 19:32:54 UTC (rev 11740) +++ trunk/src/pllegend.c 2011-05-01 20:08:03 UTC (rev 11741) @@ -886,7 +886,9 @@ //-------------------------------------------------------------------------- //! Draw triangular end-caps for color bars. //! -//! @param orientation This enum variable defines the orientation of +//! @param opt If the PL_COLORBAR_NOEDGE/EDGE bit is set, draw (no edge)/(an edge) around +//! the triangle. +//! @param orientation This variable defines the orientation of //! the triangle. The triangle points to the right, up, left, or down //! if orientation contains PL_COLORBAR_ORIENT_RIGHT, //! PL_COLORBAR_ORIENT_TOP, PL_COLORBAR_ORIENT_LEFT, or @@ -899,7 +901,7 @@ //! void -draw_cap( PLINT orientation, PLFLT xmin, PLFLT xmax, +static draw_cap( PLINT opt, PLINT orientation, PLFLT xmin, PLFLT xmax, PLFLT ymin,PLFLT ymax, PLFLT color ) { // Save current drawing color. @@ -970,7 +972,8 @@ plcol0( col0_save ); // Draw cap outline - plline( 3, xs, ys ); + if ( opt & PL_COLORBAR_EDGE) + plline( 3, xs, ys ); // Restore window and viewport plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save ); @@ -983,14 +986,17 @@ //! @param opt This variable contains bits which control the overall //! colorbar. The orientation (direction of the maximum value) of the //! colorbar is specified with PL_COLORBAR_ORIENT_(RIGHT, TOP, LEFT, -//! BOTTOM). If none of those bits are specified, the default orientation -//! is toward the top, i.e., a vertical colorbar. The type of -//! colorbar can be specified with PL_COLORBAR_SHADE, -//! PL_COLORBAR_IMAGE or PL_COLORBAR_GRADIENT. The position of the -//! (optional) label/title can be specified with -//! PL_COLORBAR_LABEL_(LEFT|RIGHT|TOP|BOTTOM). If no label position -//! is specified then no label will be drawn. End-caps for the -//! colorbar can added with PL_COLORBAR_CAP_LOW and +//! BOTTOM). If none of those bits are specified, the default +//! orientation is toward the top, i.e., a vertical colorbar. Whether +//! the edges of the colour box and caps is not drawn or drawn (for +//! the current cmap0 color index) depends on PL_COLORBAR_(NOEDGE, +//! EDGE). If neither of these bits are specified, then by default +//! PL_COLORBAR_NOEDGE is assumed. The type of colorbar can be +//! specified with PL_COLORBAR_SHADE, PL_COLORBAR_IMAGE or +//! PL_COLORBAR_GRADIENT. The position of the (optional) label/title +//! can be specified with PL_COLORBAR_LABEL_(LEFT|RIGHT|TOP|BOTTOM). +//! If no label position is specified then no label will be drawn. +//! End-caps for the colorbar can added with PL_COLORBAR_CAP_LOW and //! PL_COLORBAR_CAP_HIGH. If a particular colorbar cap option is not //! specified then no cap will be drawn for that end. As a special //! case for PL_COLORBAR_SHADE, the option PL_COLORBAR_SHADE_LABEL can @@ -1034,7 +1040,7 @@ //! @param values Numeric values for the data range represented by the //! colorbar. For PL_COLORBAR_SHADE, this should include one value per break //! between segments. For PL_COLORBAR_IMAGE and PL_COLORBAR_GRADIENT this -//! include two values, one for the maximum value on the scale and one for the +//! includes two values, one for the maximum value on the scale and one for the //! minimum value. //! @@ -1088,7 +1094,7 @@ // For building axis option string PLINT max_opts = 25; char opt_string[max_opts]; - const char *tick_string; + const char *tick_string, *edge_string; // Draw a title char perp; @@ -1105,6 +1111,13 @@ opt = opt | PL_COLORBAR_ORIENT_RIGHT; } + // Do not draw edges of color box and caps by default. + if ( !( opt & PL_COLORBAR_NOEDGE || opt & PL_COLORBAR_EDGE ) ) + opt = opt | PL_COLORBAR_NOEDGE; + + //ToDo: Sanity checking on axis_opts to remove all axis opts + //(e.g, "b") that are controlled by other means. + min_value = values[0]; max_value = values[ n_values - 1 ]; @@ -1463,19 +1476,19 @@ // Draw a filled triangle (cap/arrow) at the low end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - draw_cap( PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, low_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, low_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { - draw_cap( PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, low_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, low_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_LEFT ) { - draw_cap( PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, low_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, low_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { - draw_cap( PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, low_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, low_cap_color ); } } if ( opt & PL_COLORBAR_CAP_HIGH ) @@ -1492,24 +1505,22 @@ // Draw a filled triangle (cap/arrow) at the high end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - draw_cap( PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, high_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, high_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { - draw_cap( PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, high_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, high_cap_color ); } if ( opt & PL_COLORBAR_ORIENT_LEFT ) { - draw_cap( PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, high_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, high_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { - draw_cap( PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, high_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, high_cap_color ); } } - tick_string = ""; - if ( opt & PL_COLORBAR_LABEL_LEFT ) { if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) @@ -1593,6 +1604,7 @@ // along an axis. if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) { + tick_string = ""; if ( position & PL_POSITION_LEFT ) { snprintf( opt_string, max_opts, "nt%s", axis_opts ); @@ -1627,15 +1639,19 @@ } // Draw the outline for the entire colorbar, tick marks, tick labels. + + if ( opt & PL_COLORBAR_EDGE ) + edge_string = "bc"; + else + edge_string = "uw"; + snprintf( opt_string, max_opts, "%s%s%s", edge_string, tick_string, axis_opts ); if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM) { - snprintf( opt_string, max_opts, "bc%s%s", tick_string, axis_opts ); - plbox( "bc", 0.0, 0, opt_string, ticks, sub_ticks ); + plbox( edge_string , 0.0, 0, opt_string, ticks, sub_ticks ); } else { - snprintf( opt_string, max_opts, "bc%s%s", tick_string, axis_opts ); - plbox( opt_string, ticks, sub_ticks, "bc", 0.0, 0 ); + plbox( opt_string, ticks, sub_ticks, edge_string, 0.0, 0 ); } // Restore previous plot characteristics. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2011-05-06 20:24:16
|
Revision: 11746 http://plplot.svn.sourceforge.net/plplot/?rev=11746&view=rev Author: andrewross Date: 2011-05-06 20:24:10 +0000 (Fri, 06 May 2011) Log Message: ----------- Changes to xwin driver to cache the background colour of the page so colour is correct if page is resized / redrawn. Modified Paths: -------------- trunk/drivers/xwin.c trunk/include/plxwd.h Modified: trunk/drivers/xwin.c =================================================================== --- trunk/drivers/xwin.c 2011-05-06 20:00:50 UTC (rev 11745) +++ trunk/drivers/xwin.c 2011-05-06 20:24:10 UTC (rev 11746) @@ -518,15 +518,17 @@ pthread_mutex_lock( &events_mutex ); #endif + dev->bgcolor = xwd->cmap0[0]; + if ( dev->write_to_window ) { - XSetWindowBackground( xwd->display, dev->window, xwd->cmap0[0].pixel ); - XSetBackground( xwd->display, dev->gc, xwd->cmap0[0].pixel ); + XSetWindowBackground( xwd->display, dev->window, dev->bgcolor.pixel ); + XSetBackground( xwd->display, dev->gc, dev->bgcolor.pixel ); XClearWindow( xwd->display, dev->window ); } if ( dev->write_to_pixmap ) { - XSetForeground( xwd->display, dev->gc, xwd->cmap0[0].pixel ); + XSetForeground( xwd->display, dev->gc, dev->bgcolor.pixel ); XFillRectangle( xwd->display, dev->pixmap, dev->gc, 0, 0, dev->width, dev->height ); XSetForeground( xwd->display, dev->gc, dev->curcolor.pixel ); @@ -2371,7 +2373,16 @@ // Initialize & redraw (to pixmap, if available). - plD_bop_xw( pls ); + if ( dev->write_to_pixmap ) + { + XSetForeground( xwd->display, dev->gc, dev->bgcolor.pixel ); + XFillRectangle( xwd->display, dev->pixmap, dev->gc, 0, 0, + dev->width, dev->height ); + XSetForeground( xwd->display, dev->gc, dev->curcolor.pixel ); + } + if ( dev->write_to_window ) { + XClearWindow( xwd->display, dev->window ); + } plRemakePlot( pls ); XSync( xwd->display, 0 ); @@ -2445,10 +2456,16 @@ // Initialize & redraw (to pixmap, if available). - if ( dev->write_to_pixmap ) + if ( dev->write_to_pixmap ) { dev->write_to_window = 0; - - plD_bop_xw( pls ); + XSetForeground( xwd->display, dev->gc, dev->bgcolor.pixel ); + XFillRectangle( xwd->display, dev->pixmap, dev->gc, 0, 0, + dev->width, dev->height ); + XSetForeground( xwd->display, dev->gc, dev->curcolor.pixel ); + } + if ( dev->write_to_window ) { + XClearWindow( xwd->display, dev->window ); + } plRemakePlot( pls ); XSync( xwd->display, 0 ); Modified: trunk/include/plxwd.h =================================================================== --- trunk/include/plxwd.h 2011-05-06 20:00:50 UTC (rev 11745) +++ trunk/include/plxwd.h 2011-05-06 20:24:10 UTC (rev 11746) @@ -107,6 +107,7 @@ #ifdef PL_HAVE_PTHREAD pthread_t updater; // The X events updater thread id #endif + XColor bgcolor; // Background color } XwDev; #endif // __PLXWD_H__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-05-12 20:24:33
|
Revision: 11748 http://plplot.svn.sourceforge.net/plplot/?rev=11748&view=rev Author: airwin Date: 2011-05-12 20:24:26 +0000 (Thu, 12 May 2011) Log Message: ----------- Improved handling of tick marks and numerical tick labels that gives the user more control. Modified Paths: -------------- trunk/examples/c/x16c.c trunk/examples/c/x33c.c trunk/src/pllegend.c Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-05-12 20:17:40 UTC (rev 11747) +++ trunk/examples/c/x16c.c 2011-05-12 20:24:26 UTC (rev 11748) @@ -243,7 +243,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "v", "", + cont_color, cont_width, 0.0, 0, "vt", "", ns + 1, shedge ); // Reset text and tick sizes @@ -289,7 +289,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "v", "", + cont_color, cont_width, 0.0, 0, "vt", "", ns + 1, shedge ); // Reset text and tick sizes @@ -335,7 +335,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "v", "", + cont_color, cont_width, 0.0, 0, "vt", "", ns + 1, shedge ); // Reset text and tick sizes @@ -380,7 +380,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - 2, 3, 0.0, 0, "v", "", + 2, 3, 0.0, 0, "vx", "", ns + 1, shedge ); // Reset text and tick sizes @@ -476,7 +476,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, 0.06, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bv", "", + cont_color, cont_width, 0.0, 0, "vt", "", ns + 1, shedge ); // Reset text and tick sizes Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-05-12 20:17:40 UTC (rev 11747) +++ trunk/examples/c/x33c.c 2011-05-12 20:24:26 UTC (rev 11748) @@ -199,29 +199,13 @@ } // Set appropriate labeling options - if ( opt & PL_COLORBAR_SHADE_LABEL ) + if ( cont_color == 0 || cont_width == 0 ) { - if ( vertical ) - axis_opts = "iv"; - else - axis_opts = "i"; + axis_opts = "tv"; } else { - if ( sub_ticks != 0 ) - { - if ( vertical ) - axis_opts = "stv"; - else - axis_opts = "st"; - } - else - { - if ( vertical ) - axis_opts = "tv"; - else - axis_opts = "t"; - } + axis_opts = "xv"; } sprintf( label, "%s, %s", @@ -865,4 +849,3 @@ plend(); exit( 0 ); } - Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-05-12 20:17:40 UTC (rev 11747) +++ trunk/src/pllegend.c 2011-05-12 20:24:26 UTC (rev 11748) @@ -884,6 +884,29 @@ // Code version with reorganized API for plcolorbar //-------------------------------------------------------------------------- +//! Remove specified ascii characters from null-terminated string. +//! +//! @param string Null-terminated string where specified characters +//! (if present) are removed. +//! @param characters Null-terminated string consisting of ascii characters +//! to be removed from string. + +void +static remove_characters( char *string, const char *characters ) +{ + size_t length = strlen(string); + size_t prefix_length = strcspn( string, characters ); + if ( prefix_length < length ) + { + // Remove first matching character by shifting tail of string + // (including null-terminator) down by one. + memmove( string+prefix_length, string+prefix_length+1, length - prefix_length ); + // Recurse to remove any remaining specified characters. + remove_characters( string, characters ); + } +} + +//-------------------------------------------------------------------------- //! Draw triangular end-caps for color bars. //! //! @param opt If the PL_COLORBAR_NOEDGE/EDGE bit is set, draw (no edge)/(an edge) around @@ -1094,7 +1117,9 @@ // For building axis option string PLINT max_opts = 25; char opt_string[max_opts]; - const char *tick_string, *edge_string; + const char *tick_label_string, *edge_string; + size_t length_axis_opts = strlen(axis_opts); + char *local_axis_opts; // Draw a title char perp; @@ -1115,9 +1140,19 @@ if ( !( opt & PL_COLORBAR_NOEDGE || opt & PL_COLORBAR_EDGE ) ) opt = opt | PL_COLORBAR_NOEDGE; - //ToDo: Sanity checking on axis_opts to remove all axis opts - //(e.g, "b") that are controlled by other means. + // local_axis_opts is local version that can be modified from + // const input version. + if ( ( local_axis_opts = (char *) malloc( (length_axis_opts + 1) * sizeof ( char ) ) ) == NULL ) + { + plexit( "plcolorbar: Insufficient memory" ); + } + strcpy(local_axis_opts, axis_opts); + + // Sanity checking on local_axis_opts to remove all control characters + // that are specified by other means inside this routine. + remove_characters(local_axis_opts, "BbCcMmNnUuWw"); + min_value = values[0]; max_value = values[ n_values - 1 ]; @@ -1521,6 +1556,7 @@ } } + // Write label. if ( opt & PL_COLORBAR_LABEL_LEFT ) { if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) @@ -1598,45 +1634,34 @@ plmtex( opt_string, label_offset, 0.5, 0.5, label ); } - // Draw labels and tick marks if this is a shade color bar + if ( position & PL_POSITION_LEFT || position & PL_POSITION_BOTTOM ) + { + tick_label_string = "n"; + } + else if ( position & PL_POSITION_RIGHT || position & PL_POSITION_TOP ) + { + tick_label_string = "m"; + } + + // Draw numerical labels and tick marks if this is a shade color bar // TODO: A better way to handle this would be to update the // internals of plbox to support custom tick and label positions // along an axis. + if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) { - tick_string = ""; - if ( position & PL_POSITION_LEFT ) - { - snprintf( opt_string, max_opts, "nt%s", axis_opts ); + snprintf( opt_string, max_opts, "%s%s", tick_label_string, local_axis_opts ); + if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT) + label_box_custom( opt_string, n_values, values, "", 0, NULL ); + else label_box_custom( "", 0, NULL, opt_string, n_values, values ); - } - else if ( position & PL_POSITION_RIGHT ) - { - snprintf( opt_string, max_opts, "mt%s", axis_opts ); - label_box_custom( "", 0, NULL, opt_string, n_values, values ); - } - else if ( position & PL_POSITION_TOP ) - { - snprintf( opt_string, max_opts, "mt%s", axis_opts ); - label_box_custom( opt_string, n_values, values, "", 0, NULL ); - } - else if ( position & PL_POSITION_BOTTOM ) - { - snprintf( opt_string, max_opts, "nt%s", axis_opts ); - label_box_custom( opt_string, n_values, values, "", 0, NULL ); - } + // Exclude tick labels for plbox call below since those tick + // labels have already been handled in a custom way above. + tick_label_string = ""; + // Exclude ticks for plbox call below since those tick marks + // have already been handled in a custom way above. + remove_characters(local_axis_opts, "TtXx"); } - else - { - if ( position & PL_POSITION_LEFT || position & PL_POSITION_BOTTOM ) - { - tick_string = "n"; - } - else if ( position & PL_POSITION_RIGHT || position & PL_POSITION_TOP ) - { - tick_string = "m"; - } - } // Draw the outline for the entire colorbar, tick marks, tick labels. @@ -1644,7 +1669,7 @@ edge_string = "bc"; else edge_string = "uw"; - snprintf( opt_string, max_opts, "%s%s%s", edge_string, tick_string, axis_opts ); + snprintf( opt_string, max_opts, "%s%s%s", edge_string, tick_label_string, local_axis_opts ); if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM) { plbox( edge_string , 0.0, 0, opt_string, ticks, sub_ticks ); @@ -1654,6 +1679,8 @@ plbox( opt_string, ticks, sub_ticks, edge_string, 0.0, 0 ); } + free(local_axis_opts); + // Restore previous plot characteristics. plcol0( col0_save ); plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-05-12 20:39:49
|
Revision: 11749 http://plplot.svn.sourceforge.net/plplot/?rev=11749&view=rev Author: airwin Date: 2011-05-12 20:39:42 +0000 (Thu, 12 May 2011) Log Message: ----------- Style recent changes. Modified Paths: -------------- trunk/drivers/xwin.c trunk/examples/c/x16c.c trunk/examples/c/x33c.c trunk/include/plplot.h trunk/include/plxwd.h trunk/src/plcore.c trunk/src/plimage.c trunk/src/pllegend.c trunk/src/plshade.c Modified: trunk/drivers/xwin.c =================================================================== --- trunk/drivers/xwin.c 2011-05-12 20:24:26 UTC (rev 11748) +++ trunk/drivers/xwin.c 2011-05-12 20:39:42 UTC (rev 11749) @@ -2380,8 +2380,9 @@ dev->width, dev->height ); XSetForeground( xwd->display, dev->gc, dev->curcolor.pixel ); } - if ( dev->write_to_window ) { - XClearWindow( xwd->display, dev->window ); + if ( dev->write_to_window ) + { + XClearWindow( xwd->display, dev->window ); } plRemakePlot( pls ); XSync( xwd->display, 0 ); @@ -2456,15 +2457,17 @@ // Initialize & redraw (to pixmap, if available). - if ( dev->write_to_pixmap ) { + if ( dev->write_to_pixmap ) + { dev->write_to_window = 0; XSetForeground( xwd->display, dev->gc, dev->bgcolor.pixel ); XFillRectangle( xwd->display, dev->pixmap, dev->gc, 0, 0, dev->width, dev->height ); XSetForeground( xwd->display, dev->gc, dev->curcolor.pixel ); } - if ( dev->write_to_window ) { - XClearWindow( xwd->display, dev->window ); + if ( dev->write_to_window ) + { + XClearWindow( xwd->display, dev->window ); } plRemakePlot( pls ); XSync( xwd->display, 0 ); Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-05-12 20:24:26 UTC (rev 11748) +++ trunk/examples/c/x16c.c 2011-05-12 20:39:42 UTC (rev 11749) @@ -242,9 +242,9 @@ plsmin( 0.0, 0.5 ); plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, - 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "vt", "", - ns + 1, shedge ); + 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, + cont_color, cont_width, 0.0, 0, "vt", "", + ns + 1, shedge ); // Reset text and tick sizes plschr( 0.0, 1.0 ); @@ -288,9 +288,9 @@ plsmin( 0.0, 0.5 ); plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, - 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "vt", "", - ns + 1, shedge ); + 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, + cont_color, cont_width, 0.0, 0, "vt", "", + ns + 1, shedge ); // Reset text and tick sizes plschr( 0.0, 1.0 ); @@ -334,9 +334,9 @@ plsmin( 0.0, 0.5 ); plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, - 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "vt", "", - ns + 1, shedge ); + 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, + cont_color, cont_width, 0.0, 0, "vt", "", + ns + 1, shedge ); // Reset text and tick sizes plschr( 0.0, 1.0 ); @@ -379,9 +379,9 @@ plsmin( 0.0, 0.5 ); plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, - 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - 2, 3, 0.0, 0, "vx", "", - ns + 1, shedge ); + 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, + 2, 3, 0.0, 0, "vx", "", + ns + 1, shedge ); // Reset text and tick sizes plschr( 0.0, 1.0 ); @@ -475,9 +475,9 @@ plsmin( 0.0, 0.5 ); plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, - 0.06, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "vt", "", - ns + 1, shedge ); + 0.06, 0.15, 0.03, 0.7, 0.0, 0.0, + cont_color, cont_width, 0.0, 0, "vt", "", + ns + 1, shedge ); // Reset text and tick sizes plschr( 0.0, 1.0 ); Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-05-12 20:24:26 UTC (rev 11748) +++ trunk/examples/c/x33c.c 2011-05-12 20:39:42 UTC (rev 11749) @@ -52,7 +52,7 @@ }; // Pick 5 arbitrary UTF-8 symbols useful for plotting points (✠✚✱✪✽✺✰✴✦). -static char *special_symbols[5] = { +static char *special_symbols[5] = { "✰", "✴", "✱", @@ -63,8 +63,8 @@ // plcolorbar options // Colorbar type options -#define COLORBAR_KINDS 4 -static PLINT colorbar_option_kinds[COLORBAR_KINDS] = { +#define COLORBAR_KINDS 4 +static PLINT colorbar_option_kinds[COLORBAR_KINDS] = { PL_COLORBAR_SHADE, PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_COLORBAR_IMAGE, @@ -78,8 +78,8 @@ }; // Which side of the page are we positioned relative to? -#define COLORBAR_POSITIONS 4 -static PLINT colorbar_position_options[COLORBAR_POSITIONS] = { +#define COLORBAR_POSITIONS 4 +static PLINT colorbar_position_options[COLORBAR_POSITIONS] = { PL_POSITION_LEFT, PL_POSITION_RIGHT, PL_POSITION_TOP, @@ -93,8 +93,8 @@ }; // Colorbar label positioning options -#define COLORBAR_LABELS 4 -static PLINT colorbar_label_options[COLORBAR_LABELS] = { +#define COLORBAR_LABELS 4 +static PLINT colorbar_label_options[COLORBAR_LABELS] = { PL_COLORBAR_LABEL_LEFT, PL_COLORBAR_LABEL_RIGHT, PL_COLORBAR_LABEL_TOP, @@ -108,14 +108,14 @@ }; // Colorbar cap options -#define COLORBAR_CAPS 4 -static PLINT colorbar_cap_options[COLORBAR_CAPS] = { +#define COLORBAR_CAPS 4 +static PLINT colorbar_cap_options[COLORBAR_CAPS] = { PL_COLORBAR_CAP_NONE, PL_COLORBAR_CAP_LOW, PL_COLORBAR_CAP_HIGH, PL_COLORBAR_CAP_LOW | PL_COLORBAR_CAP_HIGH }; -static const char *colorbar_cap_option_labels[COLORBAR_CAPS] = { +static const char *colorbar_cap_option_labels[COLORBAR_CAPS] = { "No caps", "Low cap", "High cap", @@ -151,30 +151,30 @@ plcolorbar_example_page( int kind_i, int label_i, int cap_i, PLINT cont_color, PLINT cont_width, PLINT n_values, PLFLT *values ) { // Parameters for the colorbars on this page - PLINT position_i, position, opt; - PLFLT x, y, x_length, y_length; - PLFLT ticks; - PLINT sub_ticks; - PLFLT low_cap_color, high_cap_color; - PLINT vertical; + PLINT position_i, position, opt; + PLFLT x, y, x_length, y_length; + PLFLT ticks; + PLINT sub_ticks; + PLFLT low_cap_color, high_cap_color; + PLINT vertical; const char *axis_opts; - char label[200]; - char title[200]; + char label[200]; + char title[200]; - ticks = 0.0; + ticks = 0.0; sub_ticks = 0; - low_cap_color = 0.0; + low_cap_color = 0.0; high_cap_color = 1.0; // Start a new page pladv( 0 ); // Draw one colorbar relative to each side of the page - for ( position_i = 0; position_i < COLORBAR_POSITIONS; position_i ++ ) + for ( position_i = 0; position_i < COLORBAR_POSITIONS; position_i++ ) { position = colorbar_position_options[position_i]; - opt = + opt = colorbar_option_kinds[kind_i] | colorbar_label_options[label_i] | colorbar_cap_options[cap_i]; @@ -184,16 +184,15 @@ // Set the offset position on the page if ( vertical ) { - x = 0.1; - y = 0.25; + x = 0.1; + y = 0.25; x_length = 0.05; y_length = 0.5; - } else { - x = 0.25; - y = 0.1; + x = 0.25; + y = 0.1; x_length = 0.5; y_length = 0.05; } @@ -209,8 +208,8 @@ } sprintf( label, "%s, %s", - colorbar_position_option_labels[position_i], - colorbar_label_option_labels[label_i] ); + colorbar_position_option_labels[position_i], + colorbar_label_option_labels[label_i] ); // Smaller text plschr( 0.0, 0.75 ); @@ -219,12 +218,12 @@ plsmin( 0.0, 0.5 ); plcolorbar( opt, position, - x, y, x_length, y_length, - low_cap_color, high_cap_color, - cont_color, cont_width, - ticks, sub_ticks, - axis_opts, label, - n_values, values ); + x, y, x_length, y_length, + low_cap_color, high_cap_color, + cont_color, cont_width, + ticks, sub_ticks, + axis_opts, label, + n_values, values ); // Reset text and tick sizes plschr( 0.0, 1.0 ); @@ -234,8 +233,8 @@ // Draw a page title sprintf( title, "%s - %s", - colorbar_option_kind_labels[kind_i], - colorbar_cap_option_labels[cap_i] ); + colorbar_option_kind_labels[kind_i], + colorbar_cap_option_labels[cap_i] ); plvpor( 0.0, 1.0, 0.0, 1.0 ); plwind( 0.0, 1.0, 0.0, 1.0 ); plptex( 0.5, 0.5, 0.0, 0.0, 0.5, title ); @@ -254,8 +253,8 @@ for ( cap_i = 0; cap_i < COLORBAR_CAPS; cap_i++ ) { plcolorbar_example_page( kind_i, label_i, cap_i, - cont_color, cont_width, - n_values, values ); + cont_color, cont_width, + n_values, values ); } } } @@ -821,7 +820,7 @@ if ( colorbar ) { // Use unsaturated green background colour to contrast with black caps. - plscolbg (70, 185, 70); + plscolbg( 70, 185, 70 ); // Color bar examples PLFLT values_small[2] = { 0.0, 1.0 }; PLFLT values_uneven[9] = { 0.0, 2.0, 2.6, 3.4, 6.0, 7.0, 8.0, 9.0, 10.0 }; @@ -832,7 +831,7 @@ plscmap1_range( 0.01, 0.99 ); // We can only test image and gradient colorbars with two element arrays - for ( i = 2; i < COLORBAR_KINDS; i ++ ) + for ( i = 2; i < COLORBAR_KINDS; i++ ) { plcolorbar_example( "cmap1_blue_yellow.pal", i, 0, 0, 2, values_small ); } Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2011-05-12 20:24:26 UTC (rev 11748) +++ trunk/include/plplot.h 2011-05-12 20:39:42 UTC (rev 11749) @@ -1222,43 +1222,43 @@ c_pllab( const char *xlabel, const char *ylabel, const char *tlabel ); //flags used for position argument of both pllegend and plcolorbar -#define PL_POSITION_LEFT 1 -#define PL_POSITION_RIGHT 2 -#define PL_POSITION_TOP 4 -#define PL_POSITION_BOTTOM 8 -#define PL_POSITION_INSIDE 16 -#define PL_POSITION_OUTSIDE 32 -#define PL_POSITION_VIEWPORT 64 -#define PL_POSITION_SUBPAGE 128 +#define PL_POSITION_LEFT 1 +#define PL_POSITION_RIGHT 2 +#define PL_POSITION_TOP 4 +#define PL_POSITION_BOTTOM 8 +#define PL_POSITION_INSIDE 16 +#define PL_POSITION_OUTSIDE 32 +#define PL_POSITION_VIEWPORT 64 +#define PL_POSITION_SUBPAGE 128 // Flags for pllegend. -#define PL_LEGEND_NONE 1 -#define PL_LEGEND_COLOR_BOX 2 -#define PL_LEGEND_LINE 4 -#define PL_LEGEND_SYMBOL 8 -#define PL_LEGEND_TEXT_LEFT 16 -#define PL_LEGEND_BACKGROUND 32 -#define PL_LEGEND_BOUNDING_BOX 64 -#define PL_LEGEND_ROW_MAJOR 128 +#define PL_LEGEND_NONE 1 +#define PL_LEGEND_COLOR_BOX 2 +#define PL_LEGEND_LINE 4 +#define PL_LEGEND_SYMBOL 8 +#define PL_LEGEND_TEXT_LEFT 16 +#define PL_LEGEND_BACKGROUND 32 +#define PL_LEGEND_BOUNDING_BOX 64 +#define PL_LEGEND_ROW_MAJOR 128 // Flags for plcolorbar -#define PL_COLORBAR_LABEL_LEFT 1 -#define PL_COLORBAR_LABEL_RIGHT 2 -#define PL_COLORBAR_LABEL_TOP 4 -#define PL_COLORBAR_LABEL_BOTTOM 8 -#define PL_COLORBAR_IMAGE 16 -#define PL_COLORBAR_SHADE 32 -#define PL_COLORBAR_GRADIENT 64 -#define PL_COLORBAR_CAP_NONE 128 -#define PL_COLORBAR_CAP_LOW 256 -#define PL_COLORBAR_CAP_HIGH 512 -#define PL_COLORBAR_SHADE_LABEL 1024 -#define PL_COLORBAR_ORIENT_RIGHT 2048 -#define PL_COLORBAR_ORIENT_TOP 4096 -#define PL_COLORBAR_ORIENT_LEFT 8192 -#define PL_COLORBAR_ORIENT_BOTTOM 16384 -#define PL_COLORBAR_NOEDGE 32768 -#define PL_COLORBAR_EDGE 65536 +#define PL_COLORBAR_LABEL_LEFT 1 +#define PL_COLORBAR_LABEL_RIGHT 2 +#define PL_COLORBAR_LABEL_TOP 4 +#define PL_COLORBAR_LABEL_BOTTOM 8 +#define PL_COLORBAR_IMAGE 16 +#define PL_COLORBAR_SHADE 32 +#define PL_COLORBAR_GRADIENT 64 +#define PL_COLORBAR_CAP_NONE 128 +#define PL_COLORBAR_CAP_LOW 256 +#define PL_COLORBAR_CAP_HIGH 512 +#define PL_COLORBAR_SHADE_LABEL 1024 +#define PL_COLORBAR_ORIENT_RIGHT 2048 +#define PL_COLORBAR_ORIENT_TOP 4096 +#define PL_COLORBAR_ORIENT_LEFT 8192 +#define PL_COLORBAR_ORIENT_BOTTOM 16384 +#define PL_COLORBAR_NOEDGE 32768 +#define PL_COLORBAR_EDGE 65536 // Routine for drawing discrete line, symbol, or cmap0 legends PLDLLIMPEXP void Modified: trunk/include/plxwd.h =================================================================== --- trunk/include/plxwd.h 2011-05-12 20:24:26 UTC (rev 11748) +++ trunk/include/plxwd.h 2011-05-12 20:39:42 UTC (rev 11749) @@ -107,7 +107,7 @@ #ifdef PL_HAVE_PTHREAD pthread_t updater; // The X events updater thread id #endif - XColor bgcolor; // Background color + XColor bgcolor; // Background color } XwDev; #endif // __PLXWD_H__ Modified: trunk/src/plcore.c =================================================================== --- trunk/src/plcore.c 2011-05-12 20:24:26 UTC (rev 11748) +++ trunk/src/plcore.c 2011-05-12 20:39:42 UTC (rev 11749) @@ -2706,8 +2706,8 @@ // cmap 1 - plsc->icol1 = plsr->icol1; - plsc->ncol1 = plsr->ncol1; + plsc->icol1 = plsr->icol1; + plsc->ncol1 = plsr->ncol1; plsc->cmap1_min = plsr->cmap1_min; plsc->cmap1_max = plsr->cmap1_max; if ( plsc->cmap1 != NULL ) Modified: trunk/src/plimage.c =================================================================== --- trunk/src/plimage.c 2011-05-12 20:24:26 UTC (rev 11748) +++ trunk/src/plimage.c 2011-05-12 20:39:42 UTC (rev 11749) @@ -247,8 +247,8 @@ } // Calculate the size of the color range to use - color_min = plsc->cmap1_min; - color_max = plsc->cmap1_max; + color_min = plsc->cmap1_min; + color_max = plsc->cmap1_max; color_range = color_max - color_min; // Go through the image values and scale them to fit in Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-05-12 20:24:26 UTC (rev 11748) +++ trunk/src/pllegend.c 2011-05-12 20:39:42 UTC (rev 11749) @@ -894,13 +894,13 @@ void static remove_characters( char *string, const char *characters ) { - size_t length = strlen(string); + size_t length = strlen( string ); size_t prefix_length = strcspn( string, characters ); if ( prefix_length < length ) { // Remove first matching character by shifting tail of string // (including null-terminator) down by one. - memmove( string+prefix_length, string+prefix_length+1, length - prefix_length ); + memmove( string + prefix_length, string + prefix_length + 1, length - prefix_length ); // Recurse to remove any remaining specified characters. remove_characters( string, characters ); } @@ -925,7 +925,7 @@ void static draw_cap( PLINT opt, PLINT orientation, PLFLT xmin, PLFLT xmax, - PLFLT ymin,PLFLT ymax, PLFLT color ) + PLFLT ymin, PLFLT ymax, PLFLT color ) { // Save current drawing color. PLINT col0_save = plsc->icol0; @@ -950,43 +950,43 @@ if ( orientation == PL_COLORBAR_ORIENT_RIGHT ) { - xs[0] = 0.; - ys[0] = 0.; - xs[1] = 1.; - ys[1] = 0.5; - xs[2] = 0.; - ys[2] = 1.; + xs[0] = 0.; + ys[0] = 0.; + xs[1] = 1.; + ys[1] = 0.5; + xs[2] = 0.; + ys[2] = 1.; } else if ( orientation == PL_COLORBAR_ORIENT_TOP ) { - xs[0] = 1.; - ys[0] = 0.; - xs[1] = 0.5; - ys[1] = 1.; - xs[2] = 0.; - ys[2] = 0.; + xs[0] = 1.; + ys[0] = 0.; + xs[1] = 0.5; + ys[1] = 1.; + xs[2] = 0.; + ys[2] = 0.; } else if ( orientation == PL_COLORBAR_ORIENT_LEFT ) { - xs[0] = 1.; - ys[0] = 1.; - xs[1] = 0.; - ys[1] = 0.5; - xs[2] = 1.; - ys[2] = 0.; + xs[0] = 1.; + ys[0] = 1.; + xs[1] = 0.; + ys[1] = 0.5; + xs[2] = 1.; + ys[2] = 0.; } else if ( orientation == PL_COLORBAR_ORIENT_BOTTOM ) { - xs[0] = 0.; - ys[0] = 1.; - xs[1] = 0.5; - ys[1] = 0.; - xs[2] = 1.; - ys[2] = 1.; + xs[0] = 0.; + ys[0] = 1.; + xs[1] = 0.5; + ys[1] = 0.; + xs[2] = 1.; + ys[2] = 1.; } else { - plexit( "draw_cap: internal error. Incorrect orientation"); + plexit( "draw_cap: internal error. Incorrect orientation" ); } plcol1( color ); @@ -995,7 +995,7 @@ plcol0( col0_save ); // Draw cap outline - if ( opt & PL_COLORBAR_EDGE) + if ( opt & PL_COLORBAR_EDGE ) plline( 3, xs, ys ); // Restore window and viewport @@ -1097,7 +1097,7 @@ PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save; // Active attributes to be saved and restored afterward. - PLINT col0_save = plsc->icol0; + PLINT col0_save = plsc->icol0; // Position of the color bar in normalized viewport (= normalized subpage // coordinates). @@ -1118,8 +1118,8 @@ PLINT max_opts = 25; char opt_string[max_opts]; const char *tick_label_string, *edge_string; - size_t length_axis_opts = strlen(axis_opts); - char *local_axis_opts; + size_t length_axis_opts = strlen( axis_opts ); + char *local_axis_opts; // Draw a title char perp; @@ -1130,10 +1130,10 @@ opt & PL_COLORBAR_ORIENT_LEFT || opt & PL_COLORBAR_ORIENT_BOTTOM ) ) { - if ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) - opt = opt | PL_COLORBAR_ORIENT_TOP; - else - opt = opt | PL_COLORBAR_ORIENT_RIGHT; + if ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) + opt = opt | PL_COLORBAR_ORIENT_TOP; + else + opt = opt | PL_COLORBAR_ORIENT_RIGHT; } // Do not draw edges of color box and caps by default. @@ -1142,16 +1142,16 @@ // local_axis_opts is local version that can be modified from // const input version. - if ( ( local_axis_opts = (char *) malloc( (length_axis_opts + 1) * sizeof ( char ) ) ) == NULL ) + if ( ( local_axis_opts = (char *) malloc( ( length_axis_opts + 1 ) * sizeof ( char ) ) ) == NULL ) { plexit( "plcolorbar: Insufficient memory" ); } - strcpy(local_axis_opts, axis_opts); + strcpy( local_axis_opts, axis_opts ); - + // Sanity checking on local_axis_opts to remove all control characters // that are specified by other means inside this routine. - remove_characters(local_axis_opts, "BbCcMmNnUuWw"); + remove_characters( local_axis_opts, "BbCcMmNnUuWw" ); min_value = values[0]; max_value = values[ n_values - 1 ]; @@ -1213,7 +1213,7 @@ wy_min = 0.0; wy_max = 1.0; } - else if ( opt & PL_COLORBAR_ORIENT_BOTTOM) + else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { wx_min = 0.0; wx_max = 1.0; @@ -1511,19 +1511,19 @@ // Draw a filled triangle (cap/arrow) at the low end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - draw_cap( opt, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, low_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, low_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { - draw_cap( opt, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, low_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, low_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_LEFT ) { - draw_cap( opt, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, low_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, low_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { - draw_cap( opt, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, low_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, low_cap_color ); } } if ( opt & PL_COLORBAR_CAP_HIGH ) @@ -1540,21 +1540,21 @@ // Draw a filled triangle (cap/arrow) at the high end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - draw_cap( opt, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, high_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, high_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { - draw_cap( opt, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, high_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, high_cap_color ); } if ( opt & PL_COLORBAR_ORIENT_LEFT ) { - draw_cap( opt, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, high_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, high_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { - draw_cap( opt, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, high_cap_color ); + draw_cap( opt, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, high_cap_color ); } - } + } // Write label. if ( opt & PL_COLORBAR_LABEL_LEFT ) @@ -1565,8 +1565,8 @@ label_offset += 4.0; else label_offset += 2.0; - perp = '\0'; - just = 0.5; + perp = '\0'; + just = 0.5; } else { @@ -1585,8 +1585,8 @@ label_offset += 4.0; else label_offset += 2.0; - perp = '\0'; - just = 0.5; + perp = '\0'; + just = 0.5; } else { @@ -1610,7 +1610,7 @@ label_offset += 4.0; else label_offset += 2.0; - perp = '\0'; + perp = '\0'; } snprintf( opt_string, max_opts, "t%c", perp ); plmtex( opt_string, label_offset, 0.5, 0.5, label ); @@ -1628,7 +1628,7 @@ label_offset += 4.0; else label_offset += 2.0; - perp = '\0'; + perp = '\0'; } snprintf( opt_string, max_opts, "b%c", perp ); plmtex( opt_string, label_offset, 0.5, 0.5, label ); @@ -1642,7 +1642,7 @@ { tick_label_string = "m"; } - + // Draw numerical labels and tick marks if this is a shade color bar // TODO: A better way to handle this would be to update the // internals of plbox to support custom tick and label positions @@ -1651,7 +1651,7 @@ if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) { snprintf( opt_string, max_opts, "%s%s", tick_label_string, local_axis_opts ); - if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT) + if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) label_box_custom( opt_string, n_values, values, "", 0, NULL ); else label_box_custom( "", 0, NULL, opt_string, n_values, values ); @@ -1660,7 +1660,7 @@ tick_label_string = ""; // Exclude ticks for plbox call below since those tick marks // have already been handled in a custom way above. - remove_characters(local_axis_opts, "TtXx"); + remove_characters( local_axis_opts, "TtXx" ); } // Draw the outline for the entire colorbar, tick marks, tick labels. @@ -1670,16 +1670,16 @@ else edge_string = "uw"; snprintf( opt_string, max_opts, "%s%s%s", edge_string, tick_label_string, local_axis_opts ); - if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM) + if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) { - plbox( edge_string , 0.0, 0, opt_string, ticks, sub_ticks ); + plbox( edge_string, 0.0, 0, opt_string, ticks, sub_ticks ); } - else + else { - plbox( opt_string, ticks, sub_ticks, edge_string, 0.0, 0 ); + plbox( opt_string, ticks, sub_ticks, edge_string, 0.0, 0 ); } - free(local_axis_opts); + free( local_axis_opts ); // Restore previous plot characteristics. plcol0( col0_save ); @@ -1896,7 +1896,7 @@ plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save ); // Active attributes to be saved and restored afterward. - PLINT col0_save = plsc->icol0; + PLINT col0_save = plsc->icol0; // Position of the color bar in normalized viewport (= normalized subpage // coordinates). @@ -2202,8 +2202,8 @@ label_offset += 4.0; else label_offset += 2.0; - perp = '\0'; - just = 0.5; + perp = '\0'; + just = 0.5; } else { @@ -2222,8 +2222,8 @@ label_offset += 4.0; else label_offset += 2.0; - perp = '\0'; - just = 0.5; + perp = '\0'; + just = 0.5; } else { @@ -2247,7 +2247,7 @@ label_offset += 4.0; else label_offset += 2.0; - perp = '\0'; + perp = '\0'; } snprintf( opt_string, max_opts, "t%c", perp ); plmtex( opt_string, label_offset, 0.5, 0.5, label ); @@ -2265,7 +2265,7 @@ label_offset += 4.0; else label_offset += 2.0; - perp = '\0'; + perp = '\0'; } snprintf( opt_string, max_opts, "b%c", perp ); plmtex( opt_string, label_offset, 0.5, 0.5, label ); Modified: trunk/src/plshade.c =================================================================== --- trunk/src/plshade.c 2011-05-12 20:24:26 UTC (rev 11748) +++ trunk/src/plshade.c 2011-05-12 20:39:42 UTC (rev 11749) @@ -251,8 +251,8 @@ PLFLT color_min, color_max, color_range; // Color range to use - color_min = plsc->cmap1_min; - color_max = plsc->cmap1_max; + color_min = plsc->cmap1_min; + color_max = plsc->cmap1_max; color_range = color_max - color_min; for ( i = 0; i < nlevel - 1; i++ ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-05-16 20:35:43
|
Revision: 11750 http://plplot.svn.sourceforge.net/plplot/?rev=11750&view=rev Author: airwin Date: 2011-05-16 20:35:36 +0000 (Mon, 16 May 2011) Log Message: ----------- User control of plcolorbar edge drawing using standard plbox "b", "c", "u", and "w" options rather than PL_COLORBAR_NOEDGE and PL_COLORBAR_EDGE opt bits. Modified Paths: -------------- trunk/examples/c/x16c.c trunk/examples/c/x33c.c trunk/include/plplot.h trunk/src/pllegend.c Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-05-12 20:39:42 UTC (rev 11749) +++ trunk/examples/c/x16c.c 2011-05-16 20:35:36 UTC (rev 11750) @@ -241,9 +241,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, + plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "vt", "", + cont_color, cont_width, 0.0, 0, "bcvt", "", ns + 1, shedge ); // Reset text and tick sizes @@ -287,9 +287,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, + plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "vt", "", + cont_color, cont_width, 0.0, 0, "bcvt", "", ns + 1, shedge ); // Reset text and tick sizes @@ -333,9 +333,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, + plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "vt", "", + cont_color, cont_width, 0.0, 0, "bcvt", "", ns + 1, shedge ); // Reset text and tick sizes @@ -378,9 +378,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, + plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - 2, 3, 0.0, 0, "vx", "", + 2, 3, 0.0, 0, "bcvx", "", ns + 1, shedge ); // Reset text and tick sizes @@ -474,9 +474,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_EDGE, PL_POSITION_RIGHT, + plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.06, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "vt", "", + cont_color, cont_width, 0.0, 0, "bcvt", "", ns + 1, shedge ); // Reset text and tick sizes Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-05-12 20:39:42 UTC (rev 11749) +++ trunk/examples/c/x33c.c 2011-05-16 20:35:36 UTC (rev 11750) @@ -200,11 +200,11 @@ // Set appropriate labeling options if ( cont_color == 0 || cont_width == 0 ) { - axis_opts = "tv"; + axis_opts = "uwtv"; } else { - axis_opts = "xv"; + axis_opts = "uwxv"; } sprintf( label, "%s, %s", Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2011-05-12 20:39:42 UTC (rev 11749) +++ trunk/include/plplot.h 2011-05-16 20:35:36 UTC (rev 11750) @@ -1257,8 +1257,6 @@ #define PL_COLORBAR_ORIENT_TOP 4096 #define PL_COLORBAR_ORIENT_LEFT 8192 #define PL_COLORBAR_ORIENT_BOTTOM 16384 -#define PL_COLORBAR_NOEDGE 32768 -#define PL_COLORBAR_EDGE 65536 // Routine for drawing discrete line, symbol, or cmap0 legends PLDLLIMPEXP void Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-05-12 20:39:42 UTC (rev 11749) +++ trunk/src/pllegend.c 2011-05-16 20:35:36 UTC (rev 11750) @@ -909,7 +909,7 @@ //-------------------------------------------------------------------------- //! Draw triangular end-caps for color bars. //! -//! @param opt If the PL_COLORBAR_NOEDGE/EDGE bit is set, draw (no edge)/(an edge) around +//! @param if_edge If if_edge is true/false, draw an edge/no edge around //! the triangle. //! @param orientation This variable defines the orientation of //! the triangle. The triangle points to the right, up, left, or down @@ -924,7 +924,7 @@ //! void -static draw_cap( PLINT opt, PLINT orientation, PLFLT xmin, PLFLT xmax, +static draw_cap( PLBOOL if_edge , PLINT orientation, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT color ) { // Save current drawing color. @@ -995,7 +995,7 @@ plcol0( col0_save ); // Draw cap outline - if ( opt & PL_COLORBAR_EDGE ) + if ( if_edge ) plline( 3, xs, ys ); // Restore window and viewport @@ -1010,16 +1010,13 @@ //! colorbar. The orientation (direction of the maximum value) of the //! colorbar is specified with PL_COLORBAR_ORIENT_(RIGHT, TOP, LEFT, //! BOTTOM). If none of those bits are specified, the default -//! orientation is toward the top, i.e., a vertical colorbar. Whether -//! the edges of the colour box and caps is not drawn or drawn (for -//! the current cmap0 color index) depends on PL_COLORBAR_(NOEDGE, -//! EDGE). If neither of these bits are specified, then by default -//! PL_COLORBAR_NOEDGE is assumed. The type of colorbar can be -//! specified with PL_COLORBAR_SHADE, PL_COLORBAR_IMAGE or -//! PL_COLORBAR_GRADIENT. The position of the (optional) label/title -//! can be specified with PL_COLORBAR_LABEL_(LEFT|RIGHT|TOP|BOTTOM). -//! If no label position is specified then no label will be drawn. -//! End-caps for the colorbar can added with PL_COLORBAR_CAP_LOW and +//! orientation is toward the top, i.e., a vertical colorbar. The +//! type of colorbar can be specified with PL_COLORBAR_SHADE, +//! PL_COLORBAR_IMAGE or PL_COLORBAR_GRADIENT. The position of the +//! (optional) label/title can be specified with +//! PL_COLORBAR_LABEL_(LEFT|RIGHT|TOP|BOTTOM). If no label position +//! is specified then no label will be drawn. End-caps for the +//! colorbar can added with PL_COLORBAR_CAP_LOW and //! PL_COLORBAR_CAP_HIGH. If a particular colorbar cap option is not //! specified then no cap will be drawn for that end. As a special //! case for PL_COLORBAR_SHADE, the option PL_COLORBAR_SHADE_LABEL can @@ -1120,6 +1117,7 @@ const char *tick_label_string, *edge_string; size_t length_axis_opts = strlen( axis_opts ); char *local_axis_opts; + PLBOOL if_edge; // Draw a title char perp; @@ -1136,10 +1134,6 @@ opt = opt | PL_COLORBAR_ORIENT_RIGHT; } - // Do not draw edges of color box and caps by default. - if ( !( opt & PL_COLORBAR_NOEDGE || opt & PL_COLORBAR_EDGE ) ) - opt = opt | PL_COLORBAR_NOEDGE; - // local_axis_opts is local version that can be modified from // const input version. if ( ( local_axis_opts = (char *) malloc( ( length_axis_opts + 1 ) * sizeof ( char ) ) ) == NULL ) @@ -1151,8 +1145,13 @@ // Sanity checking on local_axis_opts to remove all control characters // that are specified by other means inside this routine. - remove_characters( local_axis_opts, "BbCcMmNnUuWw" ); + remove_characters( local_axis_opts, "MmNn" ); + if_edge = plP_stsearch( local_axis_opts, 'b' ) && + !plP_stsearch( local_axis_opts, 'u' ) && + plP_stsearch( local_axis_opts, 'c' ) && + !plP_stsearch( local_axis_opts, 'w' ); + min_value = values[0]; max_value = values[ n_values - 1 ]; @@ -1511,19 +1510,19 @@ // Draw a filled triangle (cap/arrow) at the low end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - draw_cap( opt, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, low_cap_color ); + draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, low_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { - draw_cap( opt, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, low_cap_color ); + draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, low_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_LEFT ) { - draw_cap( opt, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, low_cap_color ); + draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, low_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { - draw_cap( opt, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, low_cap_color ); + draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, low_cap_color ); } } if ( opt & PL_COLORBAR_CAP_HIGH ) @@ -1540,19 +1539,19 @@ // Draw a filled triangle (cap/arrow) at the high end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - draw_cap( opt, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, high_cap_color ); + draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, high_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { - draw_cap( opt, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, high_cap_color ); + draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, high_cap_color ); } if ( opt & PL_COLORBAR_ORIENT_LEFT ) { - draw_cap( opt, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, high_cap_color ); + draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, high_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { - draw_cap( opt, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, high_cap_color ); + draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, high_cap_color ); } } @@ -1665,11 +1664,11 @@ // Draw the outline for the entire colorbar, tick marks, tick labels. - if ( opt & PL_COLORBAR_EDGE ) + if ( if_edge ) edge_string = "bc"; else edge_string = "uw"; - snprintf( opt_string, max_opts, "%s%s%s", edge_string, tick_label_string, local_axis_opts ); + snprintf( opt_string, max_opts, "%s%s", tick_label_string, local_axis_opts ); if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) { plbox( edge_string, 0.0, 0, opt_string, ticks, sub_ticks ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2011-05-17 22:16:36
|
Revision: 11751 http://plplot.svn.sourceforge.net/plplot/?rev=11751&view=rev Author: hezekiahcarty Date: 2011-05-17 22:16:30 +0000 (Tue, 17 May 2011) Log Message: ----------- Add drawing mode setting and getting support (no driver support yet) These two new functions allow a user to specify different drawing modes, such as replacing the current plot content with the drawing color, even if the drawing color is transparent (SOURCE in Cairo) or XOR drawing. This is only intended to be supported by output devices which support these operations directly. At least Cairo and Qt support the modes included in this commit, along with several others. Modified Paths: -------------- trunk/include/plplot.h trunk/include/plstrm.h trunk/src/plctrl.c Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2011-05-16 20:35:36 UTC (rev 11750) +++ trunk/include/plplot.h 2011-05-17 22:16:30 UTC (rev 11751) @@ -236,6 +236,8 @@ #define PLESC_END_RASTERIZE 33 // end rasterized rendering #define PLESC_ARC 34 // render an arc #define PLESC_GRADIENT 35 // render a gradient +#define PLESC_MODESET 36 // set drawing mode +#define PLESC_MODEGET 37 // get drawing mode // Alternative unicode text handling control characters #define PLTEXT_FONTCHANGE 0 // font change in the text stream @@ -667,6 +669,7 @@ #define plgdidev c_plgdidev #define plgdiori c_plgdiori #define plgdiplt c_plgdiplt +#define plgdrawmode c_plgdrawmode #define plgfam c_plgfam #define plgfci c_plgfci #define plgfnam c_plgfnam @@ -762,6 +765,7 @@ #define plsmem c_plsmem #define plsmema c_plsmema #define plsmin c_plsmin +#define plsdrawmode c_plsdrawmode #define plsori c_plsori #define plspage c_plspage #define plspal0 c_plspal0 @@ -1085,6 +1089,11 @@ PLDLLIMPEXP void c_plgdiplt( PLFLT *p_xmin, PLFLT *p_ymin, PLFLT *p_xmax, PLFLT *p_ymax ); +// Get the drawing mode + +PLDLLIMPEXP PLINT +c_plgdrawmode(); + // Get FCI (font characterization integer) PLDLLIMPEXP void @@ -1258,6 +1267,12 @@ #define PL_COLORBAR_ORIENT_LEFT 8192 #define PL_COLORBAR_ORIENT_BOTTOM 16384 +// Flags for drawing mode +#define PL_MODE_UNKNOWN 0 +#define PL_MODE_DEFAULT 1 +#define PL_MODE_REPLACE 2 +#define PL_MODE_XOR 4 + // Routine for drawing discrete line, symbol, or cmap0 legends PLDLLIMPEXP void c_pllegend( PLFLT *p_legend_width, PLFLT *p_legend_height, @@ -1737,6 +1752,10 @@ PLDLLIMPEXP void c_plsmin( PLFLT def, PLFLT scale ); +// Set the drawing mode +PLDLLIMPEXP void +c_plsdrawmode( PLINT mode ); + // Set orientation. Must be done before calling plinit. PLDLLIMPEXP void Modified: trunk/include/plstrm.h =================================================================== --- trunk/include/plstrm.h 2011-05-16 20:35:36 UTC (rev 11750) +++ trunk/include/plstrm.h 2011-05-17 22:16:30 UTC (rev 11751) @@ -793,6 +793,9 @@ PLFLT string_length; PLINT get_string_length; PLINT dev_eofill; + + // Drawing mode section + PLINT dev_modeset; } PLStream; //-------------------------------------------------------------------------- Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2011-05-16 20:35:36 UTC (rev 11750) +++ trunk/src/plctrl.c 2011-05-17 22:16:30 UTC (rev 11751) @@ -8,6 +8,7 @@ // Copyright (C) 2004 Rafael Laboissiere // Copyright (C) 2008 Hazen Babcock // Copyright (C) 2009 Alan W. Irwin +// Copyright (C) 2011 Hezekiah M. Carty // // This file is part of PLplot. // @@ -1820,6 +1821,57 @@ } //-------------------------------------------------------------------------- +//! Set drawing mode (depends on device support!) +//! +//! @param mode This determines which drawing mode to use. +//! +void +c_plsdrawmode( PLINT mode ) +{ + if ( !plsc->dev_modeset ) + { + plwarn( "plsdrawmode: Mode setting is not supported" ); + } + else if ( plsc->level > 0 ) + { + plP_esc( PLESC_MODESET, &mode ); + } + else + { + plwarn( "plsdrawmode: Initialize PLplot first" ); + } + return; +} + +//-------------------------------------------------------------------------- +//! Get drawing mode (depends on device support!) +//! +//! @returns Current drawing mode +//! +PLINT +c_plgdrawmode() +{ + PLINT mode; + + if ( !plsc->dev_modeset ) + { + plwarn( "plgdrawmode: Mode getting is not supported" ); + mode = PL_MODE_UNKNOWN; + } + else if ( plsc->level > 0 ) + { + plP_esc( PLESC_MODEGET, &mode ); + } + else + { + plwarn( "plsdrawmode: Initialize PLplot first" ); + mode = PL_MODE_UNKNOWN; + } + + return( mode ); +} + +//-------------------------------------------------------------------------- // void pltext() // // Switches to text screen. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-05-30 19:11:58
|
Revision: 11755 http://plplot.svn.sourceforge.net/plplot/?rev=11755&view=rev Author: airwin Date: 2011-05-30 19:11:52 +0000 (Mon, 30 May 2011) Log Message: ----------- Put the "m" and "n" axis_opts under user control rather than specifying them internally within the plcolorbar code. This change completes my goal of removing cross-talk between PL_POSITION_* bits (now reserved for specifying only the position of the colorbar) and other characteristics of the plcolorbar result. There is still a lot of work I have planned for plcolorbar. First on that agenda is to use the same positioning logic as is used for pllegend. This planned change is only possible because of the prior work of removing the cross-talk mentioned above. Modified Paths: -------------- trunk/examples/c/x16c.c trunk/examples/c/x33c.c trunk/src/pllegend.c Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-05-17 22:16:51 UTC (rev 11754) +++ trunk/examples/c/x16c.c 2011-05-30 19:11:52 UTC (rev 11755) @@ -243,7 +243,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bcvt", "", + cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); // Reset text and tick sizes @@ -289,7 +289,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bcvt", "", + cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); // Reset text and tick sizes @@ -335,7 +335,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bcvt", "", + cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); // Reset text and tick sizes @@ -380,7 +380,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - 2, 3, 0.0, 0, "bcvx", "", + 2, 3, 0.0, 0, "bcvxm", "", ns + 1, shedge ); // Reset text and tick sizes @@ -476,7 +476,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.06, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bcvt", "", + cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); // Reset text and tick sizes Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-05-17 22:16:51 UTC (rev 11754) +++ trunk/examples/c/x33c.c 2011-05-30 19:11:52 UTC (rev 11755) @@ -156,7 +156,7 @@ PLFLT ticks; PLINT sub_ticks; PLFLT low_cap_color, high_cap_color; - PLINT vertical; + PLINT vertical, ifn; const char *axis_opts; char label[200]; char title[200]; @@ -180,6 +180,7 @@ colorbar_cap_options[cap_i]; vertical = position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT; + ifn = position & PL_POSITION_LEFT || position & PL_POSITION_BOTTOM; // Set the offset position on the page if ( vertical ) @@ -197,15 +198,29 @@ y_length = 0.05; } - // Set appropriate labeling options + // Set appropriate labelling options. + if ( ifn ) + { if ( cont_color == 0 || cont_width == 0 ) { - axis_opts = "uwtv"; + axis_opts = "uwtvn"; } else { - axis_opts = "uwxv"; + axis_opts = "uwxvn"; } + } + else + { + if ( cont_color == 0 || cont_width == 0 ) + { + axis_opts = "uwtvm"; + } + else + { + axis_opts = "uwxvm"; + } + } sprintf( label, "%s, %s", colorbar_position_option_labels[position_i], Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-05-17 22:16:51 UTC (rev 11754) +++ trunk/src/pllegend.c 2011-05-30 19:11:52 UTC (rev 11755) @@ -1,9 +1,9 @@ // $Id$ -// pllegend(...) (which plots a discrete plot legend) and the static -// routines which support it. +// All routines that help to create a discrete legend (pllegend) or +// a continuous legend (plcolorbar). // -// Copyright (C) 2010 Hezekiah M. Carty -// Copyright (C) 2010 Alan W. Irwin +// Copyright (C) 2010-2011 Hezekiah M. Carty +// Copyright (C) 2010-2011 Alan W. Irwin // // This file is part of PLplot. // @@ -1114,7 +1114,7 @@ // For building axis option string PLINT max_opts = 25; char opt_string[max_opts]; - const char *tick_label_string, *edge_string; + const char *edge_string; size_t length_axis_opts = strlen( axis_opts ); char *local_axis_opts; PLBOOL if_edge; @@ -1142,11 +1142,6 @@ } strcpy( local_axis_opts, axis_opts ); - - // Sanity checking on local_axis_opts to remove all control characters - // that are specified by other means inside this routine. - remove_characters( local_axis_opts, "MmNn" ); - if_edge = plP_stsearch( local_axis_opts, 'b' ) && !plP_stsearch( local_axis_opts, 'u' ) && plP_stsearch( local_axis_opts, 'c' ) && @@ -1633,15 +1628,6 @@ plmtex( opt_string, label_offset, 0.5, 0.5, label ); } - if ( position & PL_POSITION_LEFT || position & PL_POSITION_BOTTOM ) - { - tick_label_string = "n"; - } - else if ( position & PL_POSITION_RIGHT || position & PL_POSITION_TOP ) - { - tick_label_string = "m"; - } - // Draw numerical labels and tick marks if this is a shade color bar // TODO: A better way to handle this would be to update the // internals of plbox to support custom tick and label positions @@ -1649,16 +1635,12 @@ if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) { - snprintf( opt_string, max_opts, "%s%s", tick_label_string, local_axis_opts ); if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) - label_box_custom( opt_string, n_values, values, "", 0, NULL ); + label_box_custom( local_axis_opts, n_values, values, "", 0, NULL ); else - label_box_custom( "", 0, NULL, opt_string, n_values, values ); - // Exclude tick labels for plbox call below since those tick - // labels have already been handled in a custom way above. - tick_label_string = ""; - // Exclude ticks for plbox call below since those tick marks - // have already been handled in a custom way above. + label_box_custom( "", 0, NULL, local_axis_opts, n_values, values ); + // Exclude ticks for plbox call below since those tick marks and + // associated labels have already been handled in a custom way above. remove_characters( local_axis_opts, "TtXx" ); } @@ -1668,14 +1650,13 @@ edge_string = "bc"; else edge_string = "uw"; - snprintf( opt_string, max_opts, "%s%s", tick_label_string, local_axis_opts ); if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) { - plbox( edge_string, 0.0, 0, opt_string, ticks, sub_ticks ); + plbox( edge_string, 0.0, 0, local_axis_opts, ticks, sub_ticks ); } else { - plbox( opt_string, ticks, sub_ticks, edge_string, 0.0, 0 ); + plbox( local_axis_opts, ticks, sub_ticks, edge_string, 0.0, 0 ); } free( local_axis_opts ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-05-30 20:23:34
|
Revision: 11757 http://plplot.svn.sourceforge.net/plplot/?rev=11757&view=rev Author: airwin Date: 2011-05-30 20:23:27 +0000 (Mon, 30 May 2011) Log Message: ----------- Style previous changes. Modified Paths: -------------- trunk/drivers/cairo.c trunk/examples/c/x33c.c trunk/examples/c/x34c.c trunk/include/plplot.h trunk/src/plctrl.c trunk/src/pllegend.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2011-05-30 20:16:51 UTC (rev 11756) +++ trunk/drivers/cairo.c 2011-05-30 20:23:27 UTC (rev 11757) @@ -613,7 +613,7 @@ //-------------------------------------------------------------------------- void get_mode( PLStream *pls, PLINT *mode ) { - PLCairo *aStream; + PLCairo *aStream; cairo_operator_t op; aStream = (PLCairo *) pls->dev; Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-05-30 20:16:51 UTC (rev 11756) +++ trunk/examples/c/x33c.c 2011-05-30 20:23:27 UTC (rev 11757) @@ -180,7 +180,7 @@ colorbar_cap_options[cap_i]; vertical = position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT; - ifn = position & PL_POSITION_LEFT || position & PL_POSITION_BOTTOM; + ifn = position & PL_POSITION_LEFT || position & PL_POSITION_BOTTOM; // Set the offset position on the page if ( vertical ) @@ -201,26 +201,26 @@ // Set appropriate labelling options. if ( ifn ) { - if ( cont_color == 0 || cont_width == 0 ) - { - axis_opts = "uwtvn"; + if ( cont_color == 0 || cont_width == 0 ) + { + axis_opts = "uwtvn"; + } + else + { + axis_opts = "uwxvn"; + } } else { - axis_opts = "uwxvn"; + if ( cont_color == 0 || cont_width == 0 ) + { + axis_opts = "uwtvm"; + } + else + { + axis_opts = "uwxvm"; + } } - } - else - { - if ( cont_color == 0 || cont_width == 0 ) - { - axis_opts = "uwtvm"; - } - else - { - axis_opts = "uwxvm"; - } - } sprintf( label, "%s, %s", colorbar_position_option_labels[position_i], Modified: trunk/examples/c/x34c.c =================================================================== --- trunk/examples/c/x34c.c 2011-05-30 20:16:51 UTC (rev 11756) +++ trunk/examples/c/x34c.c 2011-05-30 20:23:27 UTC (rev 11757) @@ -25,8 +25,8 @@ #include "plcdemos.h" // Drawing modes to demonstrate -#define NUM_MODES 3 -PLINT drawing_modes[NUM_MODES] = { +#define NUM_MODES 3 +PLINT drawing_modes[NUM_MODES] = { PL_MODE_DEFAULT, PL_MODE_REPLACE, PL_MODE_XOR Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2011-05-30 20:16:51 UTC (rev 11756) +++ trunk/include/plplot.h 2011-05-30 20:23:27 UTC (rev 11757) @@ -1268,10 +1268,10 @@ #define PL_COLORBAR_ORIENT_BOTTOM 0x4000 // Flags for drawing mode -#define PL_MODE_UNKNOWN 0 -#define PL_MODE_DEFAULT 1 -#define PL_MODE_REPLACE 2 -#define PL_MODE_XOR 4 +#define PL_MODE_UNKNOWN 0 +#define PL_MODE_DEFAULT 1 +#define PL_MODE_REPLACE 2 +#define PL_MODE_XOR 4 // Routine for drawing discrete line, symbol, or cmap0 legends PLDLLIMPEXP void Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2011-05-30 20:16:51 UTC (rev 11756) +++ trunk/src/plctrl.c 2011-05-30 20:23:27 UTC (rev 11757) @@ -1868,7 +1868,7 @@ mode = PL_MODE_UNKNOWN; } - return( mode ); + return ( mode ); } //-------------------------------------------------------------------------- Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-05-30 20:16:51 UTC (rev 11756) +++ trunk/src/pllegend.c 2011-05-30 20:23:27 UTC (rev 11757) @@ -1,5 +1,5 @@ // $Id$ -// All routines that help to create a discrete legend (pllegend) or +// All routines that help to create a discrete legend (pllegend) or // a continuous legend (plcolorbar). // // Copyright (C) 2010-2011 Hezekiah M. Carty @@ -924,7 +924,7 @@ //! void -static draw_cap( PLBOOL if_edge , PLINT orientation, PLFLT xmin, PLFLT xmax, +static draw_cap( PLBOOL if_edge, PLINT orientation, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT color ) { // Save current drawing color. @@ -1143,9 +1143,9 @@ strcpy( local_axis_opts, axis_opts ); if_edge = plP_stsearch( local_axis_opts, 'b' ) && - !plP_stsearch( local_axis_opts, 'u' ) && - plP_stsearch( local_axis_opts, 'c' ) && - !plP_stsearch( local_axis_opts, 'w' ); + !plP_stsearch( local_axis_opts, 'u' ) && + plP_stsearch( local_axis_opts, 'c' ) && + !plP_stsearch( local_axis_opts, 'w' ); min_value = values[0]; max_value = values[ n_values - 1 ]; @@ -1534,7 +1534,7 @@ // Draw a filled triangle (cap/arrow) at the high end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, high_cap_color ); + draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, high_cap_color ); } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-06-01 17:41:41
|
Revision: 11759 http://plplot.svn.sourceforge.net/plplot/?rev=11759&view=rev Author: airwin Date: 2011-06-01 17:41:34 +0000 (Wed, 01 Jun 2011) Log Message: ----------- Style changes: Remove whitespace just inside cast parentheses. This is the style we already have in most cases, but force this in all cases now for consistency. Force removal of any spaces between pointer stars. (i.e., "* *" ==> "**"). This is our uniform style now in any case (i.e. it introduces no source code changes). However, this change is needed for when (in the immediate future) we move to uncrustify-0.58 to work around an issue (all "**" instances were being changed to "* *" inside casts) for that version of uncrustify. Modified Paths: -------------- trunk/bindings/f77/sccont.c trunk/src/plcont.c trunk/src/plimage.c trunk/src/plshade.c trunk/src/plvect.c trunk/uncrustify.cfg Modified: trunk/bindings/f77/sccont.c =================================================================== --- trunk/bindings/f77/sccont.c 2011-05-31 09:02:36 UTC (rev 11758) +++ trunk/bindings/f77/sccont.c 2011-06-01 17:41:34 UTC (rev 11759) @@ -399,7 +399,7 @@ *shade_min, *shade_max, *sh_cmap, *sh_color, *sh_width, *min_color, *min_width, *max_color, *max_width, - c_plfill, rect, pltr, ( PLPointer ) ftr ); + c_plfill, rect, pltr, (PLPointer) ftr ); } //-------------------------------------------------------------------------- Modified: trunk/src/plcont.c =================================================================== --- trunk/src/plcont.c 2011-05-31 09:02:36 UTC (rev 11758) +++ trunk/src/plcont.c 2011-06-01 17:41:34 UTC (rev 11759) @@ -280,7 +280,7 @@ plP_drawor( tpx, tpy ); - if ( (int ) ( fabs( *distance / contlabel_space ) ) > *lastindex ) + if ( (int) ( fabs( *distance / contlabel_space ) ) > *lastindex ) { PLFLT scale, vec_x, vec_y, mx, my, dev_x, dev_y, off_x, off_y; @@ -294,8 +294,8 @@ vec_y = -vec_y; } - mx = (double ) plsc->wpxscl / (double ) plsc->phyxlen; - my = (double ) plsc->wpyscl / (double ) plsc->phyylen; + mx = (double) plsc->wpxscl / (double) plsc->phyxlen; + my = (double) plsc->wpyscl / (double) plsc->phyylen; dev_x = -my * vec_y / mx; dev_y = mx * vec_x / my; @@ -352,20 +352,20 @@ tmp = 0; if ( tmp >= 0.0 ) - exponent = (int ) tmp; + exponent = (int) tmp; else if ( tmp < 0.0 ) { tmp = -tmp; if ( floor( tmp ) < tmp ) - exponent = -(int ) ( floor( tmp ) + 1.0 ); + exponent = -(int) ( floor( tmp ) + 1.0 ); else - exponent = -(int ) ( floor( tmp ) ); + exponent = -(int) ( floor( tmp ) ); } mant = value / pow( 10.0, exponent ); if ( mant != 0.0 ) - mant = (int ) ( mant * pow( 10.0, prec - 1 ) + 0.5 * mant / fabs( mant ) ) / pow( 10.0, prec - 1 ); + mant = (int) ( mant * pow( 10.0, prec - 1 ) + 0.5 * mant / fabs( mant ) ) / pow( 10.0, prec - 1 ); snprintf( form, FORM_LEN, "%%.%df", prec - 1 ); snprintf( string, len, form, mant ); @@ -524,7 +524,7 @@ return; } - plfcont( plf2eval1, ( PLPointer ) f, + plfcont( plf2eval1, (PLPointer) f, nx, ny, kx, lx, ky, ly, clevel, nlevel, pltr, pltr_data ); } Modified: trunk/src/plimage.c =================================================================== --- trunk/src/plimage.c 2011-05-31 09:02:36 UTC (rev 11758) +++ trunk/src/plimage.c 2011-06-01 17:41:34 UTC (rev 11759) @@ -194,7 +194,7 @@ void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ), PLPointer pltr_data ) { - plfimagefr( plf2ops_c(), ( PLPointer ) idata, nx, ny, + plfimagefr( plf2ops_c(), (PLPointer) idata, nx, ny, xmin, xmax, ymin, ymax, zmin, zmax, valuemin, valuemax, pltr, pltr_data ); } Modified: trunk/src/plshade.c =================================================================== --- trunk/src/plshade.c 2011-05-31 09:02:36 UTC (rev 11758) +++ trunk/src/plshade.c 2011-06-01 17:41:34 UTC (rev 11759) @@ -333,7 +333,7 @@ void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ), PLPointer pltr_data ) { - plshade_int( plf2eval1, ( PLPointer ) a, + plshade_int( plf2eval1, (PLPointer) a, NULL, NULL, // plc2eval, (PLPointer) &cgrid, defined, MISSING_MIN_DEF, MISSING_MAX_DEF, nx, ny, xmin, Modified: trunk/src/plvect.c =================================================================== --- trunk/src/plvect.c 2011-05-31 09:02:36 UTC (rev 11758) +++ trunk/src/plvect.c 2011-06-01 17:41:34 UTC (rev 11759) @@ -217,6 +217,6 @@ void ( *pltr )( PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer ), PLPointer pltr_data ) { - plfvect( plf2eval1, ( PLPointer ) u, ( PLPointer ) v, + plfvect( plf2eval1, (PLPointer) u, (PLPointer) v, nx, ny, scale, pltr, pltr_data ); } Modified: trunk/uncrustify.cfg =================================================================== --- trunk/uncrustify.cfg 2011-05-31 09:02:36 UTC (rev 11758) +++ trunk/uncrustify.cfg 2011-06-01 17:41:34 UTC (rev 11759) @@ -250,7 +250,7 @@ sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force # Add or remove space between pointer stars '*' -sp_between_ptr_star = ignore # ignore/add/remove/force +sp_between_ptr_star = remove # ignore/add/remove/force # Add or remove space after pointer star '*', if followed by a word. sp_after_ptr_star = ignore # ignore/add/remove/force @@ -378,7 +378,7 @@ sp_after_cast = force # ignore/add/remove/force # Add or remove spaces inside cast parens -sp_inside_paren_cast = ignore # ignore/add/remove/force +sp_inside_paren_cast = remove # ignore/add/remove/force # Add or remove space between the type and open paren in a C++ cast, i.e. 'int(exp)' vs 'int (exp)' sp_cpp_cast_paren = ignore # ignore/add/remove/force This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-06-01 19:29:21
|
Revision: 11760 http://plplot.svn.sourceforge.net/plplot/?rev=11760&view=rev Author: airwin Date: 2011-06-01 19:29:11 +0000 (Wed, 01 Jun 2011) Log Message: ----------- Move from uncrustify 0.56 to 0.58. For this new version of uncrustify, we have regenerated uncrustify.cfg using the following commands: uncrustify -c uncrustify.cfg --update-config-with-doc > new_config_file mv new_config_file uncrustify.cfg 0.58 does more complete processing of spaces inside casts than was done for 0.56. So the vast majority of these source-code changes involve inserting spaces inside casts where none appeared before. e.g., (void*) ==> (void *) to be consistent with how, e.g., void * is styled for spacing outside casts. The remaining source code changes are almost entirely due to improved alignment processing for 0.58. Modified Paths: -------------- trunk/bindings/c++/plstream.h trunk/bindings/gnome2/lib/gcw-lib.c trunk/bindings/gnome2/lib/plplotcanvas.c trunk/bindings/java/plplotjavac.i trunk/bindings/lua/plplotluac.i trunk/bindings/ocaml/plplot_impl.c trunk/bindings/octave/plplot_octave.i trunk/bindings/python/plplotcmodule.i trunk/bindings/qt_gui/plqt.cpp trunk/bindings/tcl/tclAPI.c trunk/bindings/tcl/tclMatrix.c trunk/bindings/tk/Pltk_Init.c trunk/bindings/tk/plframe.c trunk/bindings/tk/plserver.c trunk/bindings/tk/tkshell.c trunk/bindings/tk-x-plat/Plplotter_Init.c trunk/bindings/tk-x-plat/plplotter.c trunk/bindings/wxwidgets/wxPLplotstream.cpp trunk/bindings/wxwidgets/wxPLplotwindow.cpp trunk/bindings/wxwidgets/wxPLplotwindow.h trunk/drivers/aqt.c trunk/drivers/cairo.c trunk/drivers/gcw.c trunk/drivers/pbm.c trunk/drivers/pdf.c trunk/drivers/qt.cpp trunk/drivers/svg.c trunk/drivers/tk.c trunk/drivers/tkwin.c trunk/drivers/wingcc.c trunk/drivers/wxwidgets.cpp trunk/drivers/wxwidgets_agg.cpp trunk/drivers/wxwidgets_app.cpp trunk/drivers/wxwidgets_dc.cpp trunk/drivers/wxwidgets_gc.cpp trunk/examples/c++/x08.cc trunk/examples/c++/x09.cc trunk/examples/c++/x11.cc trunk/examples/c++/x12.cc trunk/examples/c++/x14.cc trunk/examples/c++/x15.cc trunk/examples/c++/x16.cc trunk/examples/c++/x17.cc trunk/examples/c++/x18.cc trunk/examples/c++/x20.cc trunk/examples/c++/x21.cc trunk/examples/c++/x23.cc trunk/examples/d/x16d.d trunk/examples/tk/xtk01.c trunk/examples/tk/xtk02.c trunk/examples/tk/xtk04.c trunk/include/dirent_msvc.h trunk/include/pdf.h trunk/include/qt.h trunk/lib/csa/csa.c trunk/lib/csa/nan.h trunk/lib/nistcd/cd.c trunk/lib/nn/hash.c trunk/lib/nn/nan.h trunk/lib/nn/nnpi.c trunk/scripts/style_source.sh trunk/src/ltdl_win32.c trunk/src/plargs.c trunk/src/plcore.c trunk/src/plot3d.c trunk/uncrustify.cfg Modified: trunk/bindings/c++/plstream.h =================================================================== --- trunk/bindings/c++/plstream.h 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/c++/plstream.h 2011-06-01 19:29:11 UTC (rev 11760) @@ -86,7 +86,7 @@ //-------------------------------------------------------------------------- class PLDLLIMPEXP_CXX plstream { - PLINT stream; + PLINT stream; static PLINT active_streams; @@ -105,9 +105,9 @@ plstream( PLS::stream_id sid, PLINT strm = 0 ); plstream( PLINT _stream ) : stream( _stream ) {} plstream( PLINT nx /*=1*/, PLINT ny /*=1*/, - const char *driver = NULL, const char *file = NULL ); + const char *driver = NULL, const char *file = NULL ); plstream( PLINT nx /*=1*/, PLINT ny /*=1*/, PLINT r, PLINT g, PLINT b, - const char *driver = NULL, const char *file = NULL ); + const char *driver = NULL, const char *file = NULL ); virtual ~plstream(); Modified: trunk/bindings/gnome2/lib/gcw-lib.c =================================================================== --- trunk/bindings/gnome2/lib/gcw-lib.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/gnome2/lib/gcw-lib.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -90,8 +90,8 @@ #endif // Retrieve the device width and height - width = *(PLINT*) g_object_get_data( G_OBJECT( dev->canvas ), "canvas-width" ); - height = *(PLINT*) g_object_get_data( G_OBJECT( dev->canvas ), "canvas-height" ); + width = *(PLINT *) g_object_get_data( G_OBJECT( dev->canvas ), "canvas-width" ); + height = *(PLINT *) g_object_get_data( G_OBJECT( dev->canvas ), "canvas-height" ); // Allocate the background color gdk_colormap_alloc_color( dev->colormap, &( dev->bgcolor ), FALSE, TRUE ); @@ -664,8 +664,8 @@ gtk_window_set_focus( GTK_WINDOW( dev->window ), dev->notebook ); // Retrieve the canvas width and height - width = *(PLINT*) g_object_get_data( G_OBJECT( canvas ), "canvas-width" ); - height = *(PLINT*) g_object_get_data( G_OBJECT( canvas ), "canvas-height" ); + width = *(PLINT *) g_object_get_data( G_OBJECT( canvas ), "canvas-width" ); + height = *(PLINT *) g_object_get_data( G_OBJECT( canvas ), "canvas-height" ); // Size the window gtk_window_resize( GTK_WINDOW( dev->window ), width * ZOOM100 + 65, @@ -761,9 +761,9 @@ height += 1; // Attach the width and height to the canvas - if ( ( w = (PLINT*) malloc( sizeof ( gint ) ) ) == NULL ) + if ( ( w = (PLINT *) malloc( sizeof ( gint ) ) ) == NULL ) plwarn( "GCW driver <gcw_set_canvas_size>: Insufficient memory." ); - if ( ( h = (PLINT*) malloc( sizeof ( gint ) ) ) == NULL ) + if ( ( h = (PLINT *) malloc( sizeof ( gint ) ) ) == NULL ) plwarn( "GCW driver <gcw_set_canvas_size>: Insufficient memory." ); *w = width; *h = height; @@ -847,8 +847,8 @@ #endif // Retrieve the device width and height - width = *(PLINT*) g_object_get_data( G_OBJECT( canvas ), "canvas-width" ); - height = *(PLINT*) g_object_get_data( G_OBJECT( canvas ), "canvas-height" ); + width = *(PLINT *) g_object_get_data( G_OBJECT( canvas ), "canvas-width" ); + height = *(PLINT *) g_object_get_data( G_OBJECT( canvas ), "canvas-height" ); // Get the current magnification gnome_canvas_c2w( canvas, 1, 0, &curmag, &dum ); Modified: trunk/bindings/gnome2/lib/plplotcanvas.c =================================================================== --- trunk/bindings/gnome2/lib/plplotcanvas.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/gnome2/lib/plplotcanvas.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -76,8 +76,8 @@ { parent_class = g_type_class_peek( G_TYPE_OBJECT ); GObjectClass* gobject_class = G_OBJECT_CLASS( klass ); - gobject_class->dispose = (void*) plplot_canvas_dispose; - gobject_class->finalize = (void*) plplot_canvas_finalize; + gobject_class->dispose = (void *) plplot_canvas_dispose; + gobject_class->finalize = (void *) plplot_canvas_finalize; } void plplot_canvas_devinit( PlplotCanvas *self ) @@ -90,9 +90,9 @@ // plsc->hack = 1; - plsdev( "gcw" ); // Set the device - plinit(); // Initialize the device - plP_esc( PLESC_DEVINIT, (void*) self ); // Install into the driver + plsdev( "gcw" ); // Set the device + plinit(); // Initialize the device + plP_esc( PLESC_DEVINIT, (void *) self ); // Install into the driver } GType plplot_canvas_get_type() Modified: trunk/bindings/java/plplotjavac.i =================================================================== --- trunk/bindings/java/plplotjavac.i 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/java/plplotjavac.i 2011-06-01 19:29:11 UTC (rev 11760) @@ -591,7 +591,7 @@ // some really twisted stuff to allow calling a single precision library from python PyArrayObject* myArray_ContiguousFromObject( PyObject* in, int type, int mindims, int maxdims ) { - PyArrayObject* tmp = (PyArrayObject*) PyArray_ContiguousFromObject( in, PyArray_FLOAT, + PyArrayObject* tmp = (PyArrayObject *) PyArray_ContiguousFromObject( in, PyArray_FLOAT, mindims, maxdims ); if ( !tmp ) { @@ -599,7 +599,7 @@ if ( PyArray_Check( in ) ) { PyErr_Clear(); - tmp = (PyArrayObject*) PyArray_Cast( (PyArrayObject*) in, PyArray_FLOAT ); + tmp = (PyArrayObject *) PyArray_Cast( (PyArrayObject *) in, PyArray_FLOAT ); } } return tmp; Modified: trunk/bindings/lua/plplotluac.i =================================================================== --- trunk/bindings/lua/plplotluac.i 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/lua/plplotluac.i 2011-06-01 19:29:11 UTC (rev 11760) @@ -129,7 +129,7 @@ // With preceding count %typemap( in ) ( PLINT n, const PLINT * Array ) { - $2 = (PLINT*) LUA_get_int_num_array_var( L, $input, &$1 ); + $2 = (PLINT *) LUA_get_int_num_array_var( L, $input, &$1 ); if ( !$2 ) SWIG_fail; Alen = $1; @@ -143,7 +143,7 @@ // Trailing count and check consistency with previous %typemap( in ) ( const PLINT * ArrayCk, PLINT n ) ( int temp ) { - $1 = (PLINT*) LUA_get_int_num_array_var( L, $input, &temp ); + $1 = (PLINT *) LUA_get_int_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; if ( temp != Alen ) @@ -162,7 +162,7 @@ // No count but check consistency with previous %typemap( in ) const PLINT * ArrayCk( int temp ) { - $1 = (PLINT*) LUA_get_int_num_array_var( L, $input, &temp ); + $1 = (PLINT *) LUA_get_int_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; if ( temp != Alen ) @@ -176,7 +176,7 @@ // No count but check consistency with previous, or NULL %typemap( in ) const PLINT * ArrayCkNull( int temp ) { - $1 = (PLINT*) LUA_get_int_num_array_var( L, $input, &temp ); + $1 = (PLINT *) LUA_get_int_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; if ( temp != Alen ) @@ -191,7 +191,7 @@ // Weird case to allow argument to be one shorter than others %typemap( in ) const PLINT * ArrayCkMinus1( int temp ) { - $1 = (PLINT*) LUA_get_int_num_array_var( L, $input, &temp ); + $1 = (PLINT *) LUA_get_int_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; if ( temp < Alen - 1 ) @@ -204,7 +204,7 @@ %typemap( in ) const PLINT * ArrayCkMinus1Null( int temp ) { - $1 = (PLINT*) LUA_get_int_num_array_var( L, $input, &temp ); + $1 = (PLINT *) LUA_get_int_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; if ( temp < Alen - 1 ) @@ -220,7 +220,7 @@ // No length but remember size to check others %typemap( in ) const PLINT * Array( int temp ) { - $1 = (PLINT*) LUA_get_int_num_array_var( L, $input, &temp ); + $1 = (PLINT *) LUA_get_int_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; Alen = temp; @@ -239,7 +239,7 @@ %typemap( in ) ( PLINT n, const PLFLT * Array ) { int temp; - $2 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $2 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$2 ) SWIG_fail; $1 = Alen = temp; @@ -254,7 +254,7 @@ %typemap( in ) ( const PLFLT * ArrayCk, PLINT n ) { int temp; - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; if ( temp != Alen ) @@ -273,7 +273,7 @@ // no count, but check consistency with previous %typemap( in ) const PLFLT * ArrayCk( int temp ) { - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; if ( temp != Alen ) @@ -288,7 +288,7 @@ // no count, but check consistency with previous, or NULL %typemap( in ) const PLFLT * ArrayCkNull( int temp ) { - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; if ( temp != Alen ) @@ -303,7 +303,7 @@ // No length but remember size to check others %typemap( in ) const PLFLT * Array { int temp; - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; Alen = temp; @@ -318,7 +318,7 @@ %typemap( in ) ( const PLFLT * Array, PLINT n ) { int temp; - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; $2 = Alen = temp; @@ -332,7 +332,7 @@ // check consistency with X dimension of previous %typemap( in ) const PLFLT * ArrayCkX { int temp; - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; if ( temp != Xlen ) @@ -347,7 +347,7 @@ // check consistency with Y dimension of previous %typemap( in ) const PLFLT * ArrayCkY { int temp; - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; if ( temp != Ylen ) @@ -363,7 +363,7 @@ %typemap( in ) ( const PLFLT * ArrayX, PLINT nx ) { int temp; - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; $2 = Xlen = temp; @@ -377,7 +377,7 @@ // set X length for later consistency checking %typemap( in ) const PLFLT * ArrayX { int temp; - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; Xlen = temp; @@ -389,7 +389,7 @@ %typemap( in ) ( const PLFLT * ArrayY, PLINT ny ) { int temp; - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; $2 = Ylen = temp; @@ -403,7 +403,7 @@ // set Y length for later consistency checking %typemap( in ) const PLFLT * ArrayY { int temp; - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; Ylen = temp; @@ -611,7 +611,7 @@ { int temp, i; - $1 = (PLFLT*) LUA_get_double_num_array_var( L, $input, &temp ); + $1 = (PLFLT *) LUA_get_double_num_array_var( L, $input, &temp ); if ( !$1 ) SWIG_fail; $2 = Ylen = temp; @@ -675,7 +675,7 @@ } %typemap( in, checkfn = "lua_isstring" ) const char *message { - $1 = (char*) lua_tostring( L, $input ); + $1 = (char *) lua_tostring( L, $input ); } @@ -721,7 +721,7 @@ fprintf( stderr, "function `%s' must return a table as 2nd result", mapform_funcstr ); return; } - xtemp = (PLFLT*) LUA_get_double_num_array_var( myL, -2, &len ); + xtemp = (PLFLT *) LUA_get_double_num_array_var( myL, -2, &len ); if ( !xtemp || len != n ) { fprintf( stderr, "function `%s' must return a table of length%d", mapform_funcstr, n ); @@ -731,7 +731,7 @@ x[i] = xtemp[i]; LUA_FREE_ARRAY( xtemp ); - ytemp = (PLFLT*) LUA_get_double_num_array_var( myL, -1, &len ); + ytemp = (PLFLT *) LUA_get_double_num_array_var( myL, -1, &len ); if ( !ytemp || len != n ) { fprintf( stderr, "function `%s' must return a table of length%d", mapform_funcstr, n ); @@ -1036,7 +1036,7 @@ lua_pop( L, 1 ); // pop test element if ( gridmode == 1 ) { - cgrid1.xg = (PLFLT*) LUA_get_double_num_array_var( L, -1, &nx ); + cgrid1.xg = (PLFLT *) LUA_get_double_num_array_var( L, -1, &nx ); if ( !cgrid1.xg ) { lua_pop( L, 1 ); // pop "xg" @@ -1100,7 +1100,7 @@ lua_pop( L, 1 ); // pop "1" if ( gridmode == 1 ) { - cgrid1.yg = (PLFLT*) LUA_get_double_num_array_var( L, -1, &ny ); + cgrid1.yg = (PLFLT *) LUA_get_double_num_array_var( L, -1, &ny ); if ( !cgrid1.yg ) { lua_pop( L, 1 ); // pop "yg" @@ -1186,7 +1186,7 @@ lua_rawgeti( L, $input, i ); if ( lua_isstring( L, -1 ) ) { - $1[i - 1] = (char*) lua_tostring( L, -1 ); + $1[i - 1] = (char *) lua_tostring( L, -1 ); } else { @@ -1221,7 +1221,7 @@ lua_rawgeti( L, $input, i ); if ( lua_isstring( L, -1 ) ) { - $1[i - 1] = (char*) lua_tostring( L, -1 ); + $1[i - 1] = (char *) lua_tostring( L, -1 ); } else { @@ -1271,7 +1271,7 @@ lua_rawgeti( L, $input, i ); if ( lua_isstring( L, -1 ) ) { - $2[i] = (char*) lua_tostring( L, -1 ); + $2[i] = (char *) lua_tostring( L, -1 ); } else { Modified: trunk/bindings/ocaml/plplot_impl.c =================================================================== --- trunk/bindings/ocaml/plplot_impl.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/ocaml/plplot_impl.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -391,7 +391,7 @@ else { c_plcont( f, nx, ny, kx, lx, ky, ly, clevel, nlevel, - get_ml_plotter_func(), (void*) 1 ); + get_ml_plotter_func(), (void *) 1 ); } } @@ -421,7 +421,7 @@ shade_min, shade_max, sh_cmap, sh_color, sh_width, min_color, min_width, max_color, max_width, plfill, rectangular, - get_ml_plotter_func(), (void*) 1 ); + get_ml_plotter_func(), (void *) 1 ); } // @@ -460,7 +460,7 @@ cont_color, cont_width, plfill, rectangular, get_ml_plotter_func(), - (void*) 1 ); + (void *) 1 ); } // @@ -481,7 +481,7 @@ zmin, zmax, valuemin, valuemax, get_ml_plotter_func(), - (void*) 1 ); + (void *) 1 ); } // @@ -494,7 +494,7 @@ { c_plvect( u, v, nx, ny, scale, get_ml_plotter_func(), - (void*) 1 ); + (void *) 1 ); } // @@ -566,8 +566,8 @@ // Using "type + 1" because "type" is passed in as a variant type, so // the indexing starts from 0 rather than 1. - c_plgriddata( (double*) x, (double*) y, (double*) z, npts, (double*) xg, nptsx, - (double*) yg, nptsy, zg_local, Int_val( type ) + 1, + c_plgriddata( (double *) x, (double *) y, (double *) z, npts, (double *) xg, nptsx, + (double *) yg, nptsy, zg_local, Int_val( type ) + 1, Double_val( data ) ); // Allocate the X-dimension of the to-be-returned OCaml array @@ -878,8 +878,8 @@ double tx; double ty; PLcGrid grid; - grid.xg = (double*) xg; - grid.yg = (double*) yg; + grid.xg = (double *) xg; + grid.yg = (double *) yg; grid.nx = Wosize_val( xg ) / Double_wosize; grid.ny = Wosize_val( yg ) / Double_wosize; pltr1( Double_val( x ), Double_val( y ), &tx, &ty, ( PLPointer ) & grid ); @@ -914,12 +914,12 @@ c_xg = malloc( length1 * sizeof ( double* ) ); for ( i = 0; i < length1; i++ ) { - c_xg[i] = (double*) Field( xg, i ); + c_xg[i] = (double *) Field( xg, i ); } c_yg = malloc( length1 * sizeof ( double* ) ); for ( i = 0; i < length1; i++ ) { - c_yg[i] = (double*) Field( yg, i ); + c_yg[i] = (double *) Field( yg, i ); } grid.xg = c_xg; grid.yg = c_yg; Modified: trunk/bindings/octave/plplot_octave.i =================================================================== --- trunk/bindings/octave/plplot_octave.i 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/octave/plplot_octave.i 2011-06-01 19:29:11 UTC (rev 11760) @@ -1572,7 +1572,7 @@ // if that element is going to be unused). // leave room for null termination. max_length = 1; - tmp_cstring = (char*) ""; + tmp_cstring = (char *) ""; } } else Modified: trunk/bindings/python/plplotcmodule.i =================================================================== --- trunk/bindings/python/plplotcmodule.i 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/python/plplotcmodule.i 2011-06-01 19:29:11 UTC (rev 11760) @@ -128,7 +128,7 @@ // some really twisted stuff to allow calling a single precision library from python PyArrayObject* myIntArray_ContiguousFromObject( PyObject* in, int type, int mindims, int maxdims ) { - PyArrayObject* tmp = (PyArrayObject*) PyArray_ContiguousFromObject( in, PyArray_PLINT, + PyArrayObject* tmp = (PyArrayObject *) PyArray_ContiguousFromObject( in, PyArray_PLINT, mindims, maxdims ); if ( !tmp ) { @@ -136,7 +136,7 @@ if ( PyArray_Check( in ) ) { PyErr_Clear(); - tmp = (PyArrayObject*) PyArray_Cast( (PyArrayObject*) in, PyArray_PLINT ); + tmp = (PyArrayObject *) PyArray_Cast( (PyArrayObject *) in, PyArray_PLINT ); } } return tmp; @@ -156,7 +156,7 @@ if ( tmp == NULL ) return NULL; $1 = Alen = tmp->dimensions[0]; - $2 = (PLINT*) tmp->data; + $2 = (PLINT *) tmp->data; } %typemap( freearg ) ( PLINT n, const PLINT * Array ) { @@ -175,7 +175,7 @@ return NULL; } $2 = tmp->dimensions[0]; - $1 = (PLINT*) tmp->data; + $1 = (PLINT *) tmp->data; } %typemap( freearg ) ( const PLINT * ArrayCk, PLINT n ) { @@ -193,7 +193,7 @@ PyErr_SetString( PyExc_ValueError, "Vectors must be same length." ); return NULL; } - $1 = (PLINT*) tmp->data; + $1 = (PLINT *) tmp->data; } %typemap( freearg ) const PLINT * ArrayCk { Py_DECREF( tmp$argnum );} @@ -208,7 +208,7 @@ PyErr_SetString( PyExc_ValueError, "Vectors must be same length." ); return NULL; } - $1 = (PLINT*) tmp->data; + $1 = (PLINT *) tmp->data; } %typemap( freearg ) const PLINT * ArrayCkNull { Py_DECREF( tmp$argnum );} @@ -223,7 +223,7 @@ PyErr_SetString( PyExc_ValueError, "Vector must be at least length of others minus 1." ); return NULL; } - $1 = (PLINT*) tmp->data; + $1 = (PLINT *) tmp->data; } %typemap( freearg ) const PLINT * ArrayCkMinus1 { Py_DECREF( tmp$argnum );} @@ -237,7 +237,7 @@ PyErr_SetString( PyExc_ValueError, "Vector must be at least length of others minus 1." ); return NULL; } - $1 = (PLINT*) tmp->data; + $1 = (PLINT *) tmp->data; } %typemap( freearg ) const PLINT * ArrayCkMinus1Null { Py_DECREF( tmp$argnum );} @@ -248,7 +248,7 @@ if ( tmp == NULL ) return NULL; Alen = tmp->dimensions[0]; - $1 = (PLINT*) tmp->data; + $1 = (PLINT *) tmp->data; } %typemap( freearg ) const PLINT * Array { Py_DECREF( tmp$argnum );} @@ -262,7 +262,7 @@ // some really twisted stuff to allow calling a single precision library from python PyArrayObject* myArray_ContiguousFromObject( PyObject* in, int type, int mindims, int maxdims ) { - PyArrayObject* tmp = (PyArrayObject*) PyArray_ContiguousFromObject( in, PyArray_FLOAT, + PyArrayObject* tmp = (PyArrayObject *) PyArray_ContiguousFromObject( in, PyArray_FLOAT, mindims, maxdims ); if ( !tmp ) { @@ -270,7 +270,7 @@ if ( PyArray_Check( in ) ) { PyErr_Clear(); - tmp = (PyArrayObject*) PyArray_Cast( (PyArrayObject*) in, PyArray_FLOAT ); + tmp = (PyArrayObject *) PyArray_Cast( (PyArrayObject *) in, PyArray_FLOAT ); } } return tmp; @@ -290,7 +290,7 @@ if ( tmp == NULL ) return NULL; $1 = Alen = tmp->dimensions[0]; - $2 = (PLFLT*) tmp->data; + $2 = (PLFLT *) tmp->data; } %typemap( freearg ) ( PLINT n, const PLFLT * Array ) { @@ -308,7 +308,7 @@ PyErr_SetString( PyExc_ValueError, "Vectors must be same length." ); return NULL; } - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; $2 = tmp->dimensions[0]; } %typemap( freearg ) ( const PLFLT * ArrayCk, PLINT n ) @@ -327,7 +327,7 @@ PyErr_SetString( PyExc_ValueError, "Vectors must be same length." ); return NULL; } - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) const PLFLT * ArrayCk { Py_DECREF( tmp$argnum );} @@ -342,7 +342,7 @@ PyErr_SetString( PyExc_ValueError, "Vectors must be same length." ); return NULL; } - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) const PLFLT * ArrayCkNull { Py_DECREF( tmp$argnum );} @@ -357,7 +357,7 @@ PyErr_SetString( PyExc_ValueError, "Vectors must be same length." ); return NULL; } - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) const PLFLT * ArrayCkX { Py_DECREF( tmp$argnum );} @@ -372,7 +372,7 @@ PyErr_SetString( PyExc_ValueError, "Vectors must be same length." ); return NULL; } - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) const PLFLT * ArrayCkY { Py_DECREF( tmp$argnum );} @@ -384,7 +384,7 @@ return NULL; Xlen = tmp->dimensions[0]; $2 = Xlen; - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) ( const PLFLT * ArrayX, PLINT nx ) { @@ -398,7 +398,7 @@ if ( tmp == NULL ) return NULL; Xlen = tmp->dimensions[0]; - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) const PLFLT * ArrayX { Py_DECREF( tmp$argnum );} @@ -410,7 +410,7 @@ return NULL; Ylen = tmp->dimensions[0]; $2 = Ylen; - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) ( const PLFLT * ArrayY, PLINT ny ) { @@ -424,7 +424,7 @@ if ( tmp == NULL ) return NULL; Ylen = tmp->dimensions[0]; - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) const PLFLT * ArrayY { Py_DECREF( tmp$argnum );} @@ -436,7 +436,7 @@ if ( tmp == NULL ) return NULL; $2 = tmp->dimensions[0]; - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) ( const PLFLT * Array, PLINT n ) { @@ -450,7 +450,7 @@ if ( tmp == NULL ) return NULL; Alen = tmp->dimensions[0]; - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) const PLFLT * Array { Py_DECREF( tmp$argnum );} @@ -469,9 +469,9 @@ $2 = tmp->dimensions[0]; $3 = tmp->dimensions[1]; size = sizeof ( PLFLT ) * $3; - $1 = (PLFLT**) malloc( sizeof ( PLFLT* ) * $2 ); + $1 = (PLFLT **) malloc( sizeof ( PLFLT* ) * $2 ); for ( i = 0; i < $2; i++ ) - $1[i] = (PLFLT*) ( tmp->data + i * size ); + $1[i] = (PLFLT *) ( tmp->data + i * size ); } %typemap( freearg ) ( const PLFLT * *MatrixCk, PLINT nx, PLINT ny ) { @@ -489,9 +489,9 @@ Xlen = $2 = tmp->dimensions[0]; Ylen = $3 = tmp->dimensions[1]; size = sizeof ( PLFLT ) * $3; - $1 = (PLFLT**) malloc( sizeof ( PLFLT* ) * $2 ); + $1 = (PLFLT **) malloc( sizeof ( PLFLT* ) * $2 ); for ( i = 0; i < $2; i++ ) - $1[i] = (PLFLT*) ( tmp->data + i * size ); + $1[i] = (PLFLT *) ( tmp->data + i * size ); } %typemap( freearg ) ( const PLFLT * *Matrix, PLINT nx, PLINT ny ) { @@ -509,9 +509,9 @@ Xlen = tmp->dimensions[0]; Ylen = tmp->dimensions[1]; size = sizeof ( PLFLT ) * Ylen; - $1 = (PLFLT**) malloc( sizeof ( PLFLT* ) * Xlen ); + $1 = (PLFLT **) malloc( sizeof ( PLFLT* ) * Xlen ); for ( i = 0; i < Xlen; i++ ) - $1[i] = (PLFLT*) ( tmp->data + i * size ); + $1[i] = (PLFLT *) ( tmp->data + i * size ); } %typemap( freearg ) const PLFLT * *Matrix { Py_DECREF( tmp$argnum ); @@ -526,7 +526,7 @@ return NULL; Xlen = $2 = tmp->dimensions[0]; Ylen = $3 = tmp->dimensions[1]; - $1 = (PLFLT*) tmp->data; + $1 = (PLFLT *) tmp->data; } %typemap( freearg ) ( const PLFLT * Matrix, PLINT nx, PLINT ny ) { @@ -546,9 +546,9 @@ return NULL; } size = sizeof ( PLFLT ) * Ylen; - $1 = (PLFLT**) malloc( sizeof ( PLFLT* ) * Xlen ); + $1 = (PLFLT **) malloc( sizeof ( PLFLT* ) * Xlen ); for ( i = 0; i < Xlen; i++ ) - $1[i] = (PLFLT*) ( tmp->data + i * size ); + $1[i] = (PLFLT *) ( tmp->data + i * size ); } %typemap( freearg ) const PLFLT * *MatrixCk { Py_DECREF( tmp$argnum ); @@ -568,9 +568,9 @@ return NULL; } size = sizeof ( PLFLT ) * Ylen; - $1 = (PLFLT**) malloc( sizeof ( PLFLT* ) * Xlen ); + $1 = (PLFLT **) malloc( sizeof ( PLFLT* ) * Xlen ); for ( i = 0; i < Xlen; i++ ) - $1[i] = (PLFLT*) ( tmp->data + i * size ); + $1[i] = (PLFLT *) ( tmp->data + i * size ); } %typemap( freearg ) PLFLT * *OutMatrixCk { Py_DECREF( tmp$argnum ); @@ -657,9 +657,9 @@ PyErr_SetString( PyExc_ValueError, "Expected a sequence of two arrays." ); return NULL; } - pltr_xg = (PyArrayObject*) myArray_ContiguousFromObject( PySequence_Fast_GET_ITEM( input, 0 ), + pltr_xg = (PyArrayObject *) myArray_ContiguousFromObject( PySequence_Fast_GET_ITEM( input, 0 ), PyArray_PLFLT, 1, 1 ); - pltr_yg = (PyArrayObject*) myArray_ContiguousFromObject( PySequence_Fast_GET_ITEM( input, 1 ), + pltr_yg = (PyArrayObject *) myArray_ContiguousFromObject( PySequence_Fast_GET_ITEM( input, 1 ), PyArray_PLFLT, 1, 1 ); if ( pltr_xg == 0 || pltr_yg == 0 ) { @@ -684,8 +684,8 @@ return NULL; } } - tmpGrid1.xg = (PLFLT*) pltr_xg->data; - tmpGrid1.yg = (PLFLT*) pltr_yg->data; + tmpGrid1.xg = (PLFLT *) pltr_xg->data; + tmpGrid1.yg = (PLFLT *) pltr_yg->data; return &tmpGrid1; } @@ -705,9 +705,9 @@ PyErr_SetString( PyExc_ValueError, "Expected a sequence of two arrays." ); return NULL; } - pltr_xg = (PyArrayObject*) myArray_ContiguousFromObject( PySequence_Fast_GET_ITEM( input, 0 ), + pltr_xg = (PyArrayObject *) myArray_ContiguousFromObject( PySequence_Fast_GET_ITEM( input, 0 ), PyArray_PLFLT, 2, 2 ); - pltr_yg = (PyArrayObject*) myArray_ContiguousFromObject( PySequence_Fast_GET_ITEM( input, 1 ), + pltr_yg = (PyArrayObject *) myArray_ContiguousFromObject( PySequence_Fast_GET_ITEM( input, 1 ), PyArray_PLFLT, 2, 2 ); if ( pltr_xg == 0 || pltr_yg == 0 ) { @@ -739,12 +739,12 @@ } } size = sizeof ( PLFLT ) * tmpGrid2.ny; - tmpGrid2.xg = (PLFLT**) malloc( sizeof ( PLFLT* ) * tmpGrid2.nx ); + tmpGrid2.xg = (PLFLT **) malloc( sizeof ( PLFLT* ) * tmpGrid2.nx ); for ( i = 0; i < tmpGrid2.nx; i++ ) - tmpGrid2.xg[i] = (PLFLT*) ( pltr_xg->data + i * size ); - tmpGrid2.yg = (PLFLT**) malloc( sizeof ( PLFLT* ) * tmpGrid2.nx ); + tmpGrid2.xg[i] = (PLFLT *) ( pltr_xg->data + i * size ); + tmpGrid2.yg = (PLFLT **) malloc( sizeof ( PLFLT* ) * tmpGrid2.nx ); for ( i = 0; i < tmpGrid2.nx; i++ ) - tmpGrid2.yg[i] = (PLFLT*) ( pltr_yg->data + i * size ); + tmpGrid2.yg[i] = (PLFLT *) ( pltr_yg->data + i * size ); return &tmpGrid2; } @@ -858,7 +858,7 @@ PyArrayObject *tmp; // the data argument is acutally a pointer to a python object - pdata = (PyObject*) data; + pdata = (PyObject *) data; if ( data == NULL ) { pdata = Py_None; @@ -902,7 +902,7 @@ } else { - PLFLT* t = (PLFLT*) tmp->data; + PLFLT* t = (PLFLT *) tmp->data; *tx = t[0]; *ty = t[1]; Py_XDECREF( tmp ); @@ -921,7 +921,7 @@ PLFLT fresult = 0.0; // the data argument is acutally a pointer to a python object - pdata = (PyObject*) data; + pdata = (PyObject *) data; if ( python_f2eval ) // if not something is terribly wrong { // hold a reference to the data object Py_XINCREF( pdata ); @@ -960,7 +960,7 @@ // the data argument is acutally a pointer to a python object if ( data ) - pdata = (PyObject*) data; + pdata = (PyObject *) data; else pdata = Py_None; if ( python_label ) // if not something is terribly wrong @@ -1013,7 +1013,7 @@ n = 1; // the data argument is acutally a pointer to a python object - pdata = (PyObject*) data; + pdata = (PyObject *) data; if ( data == NULL ) { pdata = Py_None; @@ -1190,7 +1190,7 @@ break; case CB_Python: Py_XINCREF( input ); - result = (PLPointer*) input; + result = (PLPointer *) input; break; default: fprintf( stderr, "pltr_type is invalid\n" ); @@ -1231,7 +1231,7 @@ } else { - if ( !PyCallable_Check( (PyObject*) $input ) ) + if ( !PyCallable_Check( (PyObject *) $input ) ) { PyErr_SetString( PyExc_ValueError, "pltr argument must be callable" ); return NULL; @@ -1259,7 +1259,7 @@ } else { - if ( !PyCallable_Check( (PyObject*) $input ) ) + if ( !PyCallable_Check( (PyObject *) $input ) ) { PyErr_SetString( PyExc_ValueError, "coordinate transform argument must be callable" ); return NULL; @@ -1282,7 +1282,7 @@ } else { - if ( !PyCallable_Check( (PyObject*) $input ) ) + if ( !PyCallable_Check( (PyObject *) $input ) ) { PyErr_SetString( PyExc_ValueError, "mapform argument must be callable" ); return NULL; @@ -1345,14 +1345,14 @@ } else { - if ( !PyCallable_Check( (PyObject*) $input ) ) + if ( !PyCallable_Check( (PyObject *) $input ) ) { PyErr_SetString( PyExc_ValueError, "pltr argument must be callable" ); return NULL; } // hold a reference to it - Py_XINCREF( (PyObject*) $input ); - python_f2eval = (PyObject*) $input; + Py_XINCREF( (PyObject *) $input ); + python_f2eval = (PyObject *) $input; // this function handles calling the python function $1 = do_f2eval_callback; } @@ -1376,14 +1376,14 @@ } else { - if ( !PyCallable_Check( (PyObject*) $input ) ) + if ( !PyCallable_Check( (PyObject *) $input ) ) { PyErr_SetString( PyExc_ValueError, "label_func argument must be callable" ); return NULL; } // hold a reference to it - Py_XINCREF( (PyObject*) $input ); - python_label = (PyObject*) $input; + Py_XINCREF( (PyObject *) $input ); + python_label = (PyObject *) $input; // this function handles calling the python function $1 = do_label_callback; } Modified: trunk/bindings/qt_gui/plqt.cpp =================================================================== --- trunk/bindings/qt_gui/plqt.cpp 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/qt_gui/plqt.cpp 2011-06-01 19:29:11 UTC (rev 11760) @@ -304,7 +304,7 @@ case '#': - currentString.append( QString( (QChar*) &( text[i] ), 1 ) ); + currentString.append( QString( (QChar *) &( text[i] ), 1 ) ); break; default: @@ -1503,20 +1503,20 @@ void plsetqtdev( QtExtWidget* widget ) { - plsc->dev = (void*) widget; + plsc->dev = (void *) widget; widget->setPLStream( plsc ); } void plsetqtdev( QtExtWidget* widget, int argc, char** argv ) { - plparseopts( &argc, (const char**) argv, PL_PARSE_FULL ); - plsc->dev = (void*) widget; + plparseopts( &argc, (const char **) argv, PL_PARSE_FULL ); + plsc->dev = (void *) widget; widget->setPLStream( plsc ); } void plfreeqtdev() { - delete ( (QtExtWidget*) plsc->dev ); + delete ( (QtExtWidget *) plsc->dev ); plsc->dev = NULL; } #endif Modified: trunk/bindings/tcl/tclAPI.c =================================================================== --- trunk/bindings/tcl/tclAPI.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/tcl/tclAPI.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -470,7 +470,7 @@ Tcl_ResetResult( interp ); } else - libDir = (char*) Tcl_GetVar( interp, "pllibrary", TCL_GLOBAL_ONLY ); + libDir = (char *) Tcl_GetVar( interp, "pllibrary", TCL_GLOBAL_ONLY ); } #ifdef TCL_DIR @@ -555,7 +555,7 @@ // Can be used with either Tcl-DP or TK Tcl_CreateCommand( interp, "wait_until", (Tcl_CmdProc *) plWait_Until, - (ClientData) NULL, (Tcl_CmdDeleteProc*) NULL ); + (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); return TCL_OK; } @@ -591,7 +591,7 @@ for ( cmdInfoPtr = Cmds; cmdInfoPtr->name != NULL; cmdInfoPtr++ ) { Tcl_CreateCommand( interp, cmdInfoPtr->name, cmdInfoPtr->proc, - (ClientData) NULL, (Tcl_CmdDeleteProc*) NULL ); + (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); } // Define the flags as variables in the PLPLOT namespace Modified: trunk/bindings/tcl/tclMatrix.c =================================================================== --- trunk/bindings/tcl/tclMatrix.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/tcl/tclMatrix.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -319,7 +319,7 @@ } matPtr->tracing = 1; Tcl_TraceVar( interp, matPtr->name, TCL_TRACE_UNSETS, - (Tcl_VarTraceProc*) DeleteMatrixVar, (ClientData) matPtr ); + (Tcl_VarTraceProc *) DeleteMatrixVar, (ClientData) matPtr ); } // Create matrix operator @@ -327,8 +327,8 @@ #ifdef DEBUG fprintf( stderr, "Creating Matrix operator of name %s\n", matPtr->name ); #endif - Tcl_CreateCommand( interp, matPtr->name, (Tcl_CmdProc*) MatrixCmd, - (ClientData) matPtr, (Tcl_CmdDeleteProc*) DeleteMatrixCmd ); + Tcl_CreateCommand( interp, matPtr->name, (Tcl_CmdProc *) MatrixCmd, + (ClientData) matPtr, (Tcl_CmdDeleteProc *) DeleteMatrixCmd ); // Store pointer to interpreter to handle bizarre uses of multiple // interpreters (e.g. as in [incr Tcl]) Modified: trunk/bindings/tk/Pltk_Init.c =================================================================== --- trunk/bindings/tk/Pltk_Init.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/tk/Pltk_Init.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -70,14 +70,14 @@ // plframe -- PLplot graphing widget - Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc*) plFrameCmd, - (ClientData) NULL, (Tcl_CmdDeleteProc*) NULL ); + Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc *) plFrameCmd, + (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); // host_id -- returns host IP number. Only for use with Tcl-DP #ifdef PLD_dp - Tcl_CreateCommand( interp, "host_id", (Tcl_CmdProc*) plHost_ID, - (ClientData) NULL, (Tcl_CmdDeleteProc*) NULL ); + Tcl_CreateCommand( interp, "host_id", (Tcl_CmdProc *) plHost_ID, + (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); #endif // Set up auto_path Modified: trunk/bindings/tk/plframe.c =================================================================== --- trunk/bindings/tk/plframe.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/tk/plframe.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -455,7 +455,7 @@ plFramePtr->devName[i] = NULL; } ndev = NDEV; - plgFileDevs( (const char***) &plFramePtr->devDesc, (const char ***) &plFramePtr->devName, &ndev ); + plgFileDevs( (const char ***) &plFramePtr->devDesc, (const char ***) &plFramePtr->devName, &ndev ); // Start up event handlers and other good stuff @@ -471,7 +471,7 @@ plFramePtr->widgetCmd = #endif Tcl_CreateCommand( interp, Tk_PathName( plFramePtr->tkwin ), - (Tcl_CmdProc*) PlFrameWidgetCmd, (ClientData) plFramePtr, (Tcl_CmdDeleteProc*) NULL ); + (Tcl_CmdProc *) PlFrameWidgetCmd, (ClientData) plFramePtr, (Tcl_CmdDeleteProc *) NULL ); #ifdef HAVE_ITCL Itk_SetWidgetCommand( plFramePtr->tkwin, plFramePtr->widgetCmd ); #endif @@ -2253,7 +2253,7 @@ dbug_enter( "ConfigurePlFrame" ); if ( Tk_ConfigureWidget( interp, tkwin, configSpecs, - argc, (CONST char**) argv, (char *) plFramePtr, flags ) != TCL_OK ) + argc, (CONST char **) argv, (char *) plFramePtr, flags ) != TCL_OK ) { return TCL_ERROR; } Modified: trunk/bindings/tk/plserver.c =================================================================== --- trunk/bindings/tk/plserver.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/tk/plserver.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -233,7 +233,7 @@ tcl_cmd( interp, "rename exit tkexit" ); Tcl_CreateCommand( interp, "exit", (Tcl_CmdProc *) plExitCmd, - (ClientData) mainWindow, (Tcl_CmdDeleteProc*) NULL ); + (ClientData) mainWindow, (Tcl_CmdDeleteProc *) NULL ); // Define the flags as variables in the PLPLOT namespace Modified: trunk/bindings/tk/tkshell.c =================================================================== --- trunk/bindings/tk/tkshell.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/tk/tkshell.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -44,25 +44,25 @@ // plframe -- PLplot graphing widget - Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc*) plFrameCmd, - (ClientData) main, (Tcl_CmdDeleteProc*) NULL ); + Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc *) plFrameCmd, + (ClientData) main, (Tcl_CmdDeleteProc *) NULL ); // matrix -- matrix support command - Tcl_CreateCommand( interp, "matrix", (Tcl_CmdProc*) Tcl_MatrixCmd, - (ClientData) main, (Tcl_CmdDeleteProc*) NULL ); + Tcl_CreateCommand( interp, "matrix", (Tcl_CmdProc *) Tcl_MatrixCmd, + (ClientData) main, (Tcl_CmdDeleteProc *) NULL ); // wait_until -- waits for a specific condition to arise // Can be used with either Tcl-DP or TK - Tcl_CreateCommand( interp, "wait_until", (Tcl_CmdProc*) plWait_Until, - (ClientData) NULL, (Tcl_CmdDeleteProc*) NULL ); + Tcl_CreateCommand( interp, "wait_until", (Tcl_CmdProc *) plWait_Until, + (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); // host_id -- returns host IP number. Only for use with Tcl-DP #ifdef PLD_dp - Tcl_CreateCommand( interp, "host_id", (Tcl_CmdProc*) plHost_ID, - (ClientData) NULL, (Tcl_CmdDeleteProc*) NULL ); + Tcl_CreateCommand( interp, "host_id", (Tcl_CmdProc *) plHost_ID, + (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); #endif // Set up auto_path Modified: trunk/bindings/tk-x-plat/Plplotter_Init.c =================================================================== --- trunk/bindings/tk-x-plat/Plplotter_Init.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/tk-x-plat/Plplotter_Init.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -87,8 +87,8 @@ // plframe -- PLplot graphing widget - Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc*) plPlotterCmd, - (ClientData) NULL, (Tcl_CmdDeleteProc*) NULL ); + Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc *) plPlotterCmd, + (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); Tcl_PkgProvide( interp, "Plplotter", VERSION ); return TCL_OK; Modified: trunk/bindings/tk-x-plat/plplotter.c =================================================================== --- trunk/bindings/tk-x-plat/plplotter.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/tk-x-plat/plplotter.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -377,8 +377,8 @@ plPlotterPtr->interp = interp; plPlotterPtr->widgetCmd = Tcl_CreateCommand( interp, Tk_PathName( plPlotterPtr->tkwin ), - (Tcl_CmdProc*) PlPlotterWidgetCmd, (ClientData) plPlotterPtr, - (Tcl_CmdDeleteProc*) NULL ); + (Tcl_CmdProc *) PlPlotterWidgetCmd, (ClientData) plPlotterPtr, + (Tcl_CmdDeleteProc *) NULL ); plPlotterPtr->xorGC = NULL; plPlotterPtr->border = NULL; plPlotterPtr->cursor = None; @@ -454,7 +454,7 @@ // for active plot ActiveState( plPlotterPtr, 1 ); - if ( ConfigurePlPlotter( interp, plPlotterPtr, argc - 2, (CONST char**) argv + 2, 0 ) != TCL_OK ) + if ( ConfigurePlPlotter( interp, plPlotterPtr, argc - 2, (CONST char **) argv + 2, 0 ) != TCL_OK ) { Tk_DestroyWindow( plPlotterPtr->tkwin ); return TCL_ERROR; @@ -905,7 +905,7 @@ { Tcl_CancelIdleCall( DisplayPlPlotter, (ClientData) plPlotterPtr ); } - Tk_EventuallyFree( (ClientData) plPlotterPtr, (Tcl_FreeProc*) DestroyPlPlotter ); + Tk_EventuallyFree( (ClientData) plPlotterPtr, (Tcl_FreeProc *) DestroyPlPlotter ); break; case MapNotify: Modified: trunk/bindings/wxwidgets/wxPLplotstream.cpp =================================================================== --- trunk/bindings/wxwidgets/wxPLplotstream.cpp 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/wxwidgets/wxPLplotstream.cpp 2011-06-01 19:29:11 UTC (rev 11760) @@ -90,10 +90,10 @@ if ( m_backend == wxPLPLOT_BACKEND_AGG ) { m_image = new wxImage( m_width, m_height ); - cmd( PLESC_DEVINIT, (void*) m_image ); + cmd( PLESC_DEVINIT, (void *) m_image ); } else - cmd( PLESC_DEVINIT, (void*) m_dc ); + cmd( PLESC_DEVINIT, (void *) m_dc ); } @@ -130,20 +130,20 @@ { delete m_image; m_image = new wxImage( width, height ); - cmd( PLESC_DEVINIT, (void*) m_image ); + cmd( PLESC_DEVINIT, (void *) m_image ); } wxSize size( width, height ); - cmd( PLESC_RESIZE, (void*) &size ); + cmd( PLESC_RESIZE, (void *) &size ); } else { wxSize size( width, height ); - cmd( PLESC_RESIZE, (void*) &size ); + cmd( PLESC_RESIZE, (void *) &size ); if ( m_image ) { delete m_image; m_image = new wxImage( width, height ); - cmd( PLESC_DEVINIT, (void*) m_image ); + cmd( PLESC_DEVINIT, (void *) m_image ); } } Modified: trunk/bindings/wxwidgets/wxPLplotwindow.cpp =================================================================== --- trunk/bindings/wxwidgets/wxPLplotwindow.cpp 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/wxwidgets/wxPLplotwindow.cpp 2011-06-01 19:29:11 UTC (rev 11760) @@ -59,7 +59,7 @@ MemPlotDCBitmap = new wxBitmap( bitmapWidth, bitmapHeight, -1 ); MemPlotDC->SelectObject( *MemPlotDCBitmap ); - m_stream = new wxPLplotstream( (wxDC*) MemPlotDC, m_width, m_height, pl_style ); + m_stream = new wxPLplotstream( (wxDC *) MemPlotDC, m_width, m_height, pl_style ); m_stream->cmd( PLESC_GETBACKEND, &m_backend ); m_backend = 1 << ( m_backend + 2 ); Modified: trunk/bindings/wxwidgets/wxPLplotwindow.h =================================================================== --- trunk/bindings/wxwidgets/wxPLplotwindow.h 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/bindings/wxwidgets/wxPLplotwindow.h 2011-06-01 19:29:11 UTC (rev 11760) @@ -36,8 +36,8 @@ { public: wxPLplotwindow( wxWindow * parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - int pl_style = wxPLPLOT_NONE ); //!< Constructor. + const wxSize& size = wxDefaultSize, long style = 0, + int pl_style = wxPLPLOT_NONE ); //!< Constructor. ~wxPLplotwindow( void ); //!< Deconstructor. void RenewPlot( void ); //!< Redo plot. Modified: trunk/drivers/aqt.c =================================================================== --- trunk/drivers/aqt.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/drivers/aqt.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -474,7 +474,7 @@ break; case PLESC_GETC: // get cursor position [adapter renderPlot]; // needed to give the user something to click on - get_cursor( pls, (PLGraphicsIn*) ptr ); + get_cursor( pls, (PLGraphicsIn *) ptr ); break; case PLESC_SWIN: // set window parameters break; @@ -799,7 +799,7 @@ // printf("new font : %s\n", new_font); - AQT_FontLookup[i].pfont = (unsigned char*) new_font; + AQT_FontLookup[i].pfont = (unsigned char *) new_font; } } } Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/drivers/cairo.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -1174,7 +1174,7 @@ { int bytes_written; - bytes_written = fwrite( data, 1, length, (FILE*) filePointer ); + bytes_written = fwrite( data, 1, length, (FILE *) filePointer ); if ( bytes_written == length ) { return CAIRO_STATUS_SUCCESS; @@ -1942,7 +1942,7 @@ case PLESC_GETC: // get cursor position blit_to_x( pls, 0.0, 0.0, pls->xlength, pls->ylength ); XFlush( aStream->XDisplay ); - xcairo_get_cursor( pls, (PLGraphicsIn*) ptr ); + xcairo_get_cursor( pls, (PLGraphicsIn *) ptr ); break; case PLESC_DEVINIT: { // Set external drawable Window rootwin; @@ -3256,7 +3256,7 @@ InvalidateRect( aStream->hwnd, NULL, TRUE ); break; case PLESC_GETC: - handle_locate( pls, (PLGraphicsIn*) ptr ); + handle_locate( pls, (PLGraphicsIn *) ptr ); break; default: plD_esc_cairo( pls, op, ptr ); Modified: trunk/drivers/gcw.c =================================================================== --- trunk/drivers/gcw.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/drivers/gcw.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -360,7 +360,7 @@ if ( dev->use_pixmap && !dev->use_persistence ) // Write to bg pixmap { - if ( ( gdkpoints = (GdkPoint*) malloc( npts * sizeof ( GdkPoint ) ) ) == NULL ) + if ( ( gdkpoints = (GdkPoint *) malloc( npts * sizeof ( GdkPoint ) ) ) == NULL ) { plabort( "GCW driver <plD_polyline_gcw>: Could not create gdkpoints" ); return; @@ -531,8 +531,8 @@ group = dev->group_hidden; // Retrieve the device width and height of the canvas - width = *(PLINT*) g_object_get_data( G_OBJECT( canvas ), "canvas-width" ); - height = *(PLINT*) g_object_get_data( G_OBJECT( canvas ), "canvas-height" ); + width = *(PLINT *) g_object_get_data( G_OBJECT( canvas ), "canvas-width" ); + height = *(PLINT *) g_object_get_data( G_OBJECT( canvas ), "canvas-height" ); if ( dev->pixmap_has_data ) { @@ -601,7 +601,7 @@ // Destroy the old visible group if ( GNOME_IS_CANVAS_GROUP( dev->group_visible ) ) { - gtk_object_destroy( (GtkObject*) ( dev->group_visible ) ); + gtk_object_destroy( (GtkObject *) ( dev->group_visible ) ); dev->group_visible = NULL; } @@ -871,7 +871,7 @@ if ( dev->use_pixmap && !dev->use_persistence ) // Write to a pixmap { - if ( ( gdkpoints = (GdkPoint*) malloc( pls->dev_npts * sizeof ( GdkPoint ) ) ) == NULL ) + if ( ( gdkpoints = (GdkPoint *) malloc( pls->dev_npts * sizeof ( GdkPoint ) ) ) == NULL ) { plabort( "GCW driver <fill_polygon>: Could not create gdkpoints" ); return; Modified: trunk/drivers/pbm.c =================================================================== --- trunk/drivers/pbm.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/drivers/pbm.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -277,7 +277,7 @@ plD_bop_pbm( PLStream *pls ) { int i, j, k; - cmap = (char*) malloc( pls->xlength * pls->ylength * 3 ); + cmap = (char *) malloc( pls->xlength * pls->ylength * 3 ); for ( i = 0; i < pls->ylength; i++ ) for ( j = 0; j < pls->xlength; j++ ) { Modified: trunk/drivers/pdf.c =================================================================== --- trunk/drivers/pdf.c 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/drivers/pdf.c 2011-06-01 19:29:11 UTC (rev 11760) @@ -190,10 +190,10 @@ pdfdev* dev; // allocate memory for the device storage - dev = (pdfdev*) calloc( 1, sizeof ( pdfdev ) ); + dev = (pdfdev *) calloc( 1, sizeof ( pdfdev ) ); if ( dev == NULL ) plexit( "Insufficient memory\n" ); - pls->dev = (void*) dev; + pls->dev = (void *) dev; // Check for and set up driver options plParseDrvOpts( pdf_options ); @@ -296,7 +296,7 @@ //-------------------------------------------------------------------------- void plD_bop_pdf( PLStream *pls ) { - pdfdev * dev = (pdfdev*) pls->dev; + pdfdev * dev = (pdfdev *) pls->dev; HPDF_REAL width, height; pls->page++; @@ -374,7 +374,7 @@ //-------------------------------------------------------------------------- void plD_tidy_pdf( PLStream *pls ) { - pdfdev* dev = (pdfdev*) pls->dev; + pdfdev* dev = (pdfdev *) pls->dev; // save the document to a stream HPDF_SaveToStream( dev->pdf ); @@ -430,7 +430,7 @@ poly_line( pls, pls->dev_x, pls->dev_y, pls->dev_npts, 1 ); break; case PLESC_HAS_TEXT: // render text - process_string( pls, (EscText*) ptr ); + process_string( pls, (EscText *) ptr ); break; } } @@ -443,7 +443,7 @@ //-------------------------------------------------------------------------- void poly_line( PLStream *pls, short *xa, short *ya, PLINT npts, short fill ) { - pdfdev* dev = (pdfdev*) pls->dev; + pdfdev* dev = (pdfdev *) pls->dev; PLINT i; HPDF_Page_SetLineWidth( dev->page, (HPDF_REAL) ( pls->width ) ); @@ -531,12 +531,12 @@ HPDF_Page_SetTextRenderingMode( dev->page, HPDF_FILL ); HPDF_Page_SetRGBFill( dev->page, dev->textRed, dev->textGreen, dev->textBlue ); HPDF_Page_MoveTextPos( dev->page, dev->textWidth, dev->yOffset ); - HPDF_Page_ShowText( dev->page, (char*) type1_string ); // TODO: this conversion must be wrong + HPDF_Page_ShowText( dev->page, (char *) type1_string ); // TODO: this conversion must be wrong HPDF_Page_EndText( dev->page ); } // determine text width and height - dev->textWidth += HPDF_Page_TextWidth( dev->page, (char*) type1_string ); // TODO: this conversion must be wrong + dev->textWidth += HPDF_Page_TextWidth( dev->page, (char *) type1_string ); // TODO: this conversion must be wrong th = (HPDF_REAL) ( HPDF_Font_GetCapHeight( dev->m_font ) * dev->fontSize * dev->fontScale / 1000.0 ); dev->textHeight = dev->textHeight > ( th + dev->yOffset ) ? dev->textHeight : ( th + dev->yOffset ); @@ -788,7 +788,7 @@ //-------------------------------------------------------------------------- void process_string( PLStream* pls, EscText* args ) { - pdfdev * dev = (pdfdev*) pls->dev; + pdfdev * dev = (pdfdev *) pls->dev; PLFLT rotation, shear, stride; HPDF_REAL cos_rot, sin_rot, cos_shear, sin_shear; Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2011-06-01 17:41:34 UTC (rev 11759) +++ trunk/drivers/qt.cpp 2011-06-01 19:29:11 UTC (rev 11760) @@ -280,8 +280,8 @@ if ( pls->xlength <= 0 || pls->ylength <= 0 ) { pls->dev = new QtRasterDevice; - pls->xlength = (PLINT) ( ( (QtRasterDevice*) ( pls->dev ) )->m_dWidth ); - pls->ylength = (PLINT) ( ( (QtRasterDevice*) ( pls->dev ) )->m_dHeight ); + pls->xlength = (PLINT) ( ( (QtRasterDevice *) ( pls->dev ) )->m_dWidth ); + pls->ylength = (PLINT) ( ( (QtRasterDevice *) ( pls->dev ) )->m_dHeight ); } else { @@ -290,18 +290,18 @@ ( (QtRasterDevice *) pls->dev )->setPLStream( pls ); if ( isMaster ) - handler.setMasterDevice( (QtRasterDevice*) ( pls->dev ) ); + handler.setMasterDevice( (QtRasterDevice *) ( pls->dev ) ); if ( pls->xlength > pls->ylength ) - ( (QtRasterDevice*) ( pls->dev ) )->downscale = (PLFLT) pls->xlength / (PLFLT) ( PIXELS_X - 1 ); + ( (QtRasterDevice *) ( pls->dev ) )->downscale = (PLFLT) pls->xlength / (PLFLT) ( PIXELS_X - 1 ); else - ( (QtRasterDevice*) ( pls->dev ) )->downscale = (PLFLT) pls->ylength / (PLFLT) PIXELS_Y; + ( (QtRasterDevice *) ( pls->dev ) )->downscale = (PLFLT) pls->ylength / (PLFLT) PIXELS_Y; - plP_setphy( (PLINT) 0, (PLINT) ( pls->xlength / ( (QtRasterDevice*) ( pls->dev ) )->downscale ), (PLINT) 0, (PLINT) ( pls->ylength / ( (QtRasterDevice*) ( pls->dev ) )->downscale ) ); + plP_setphy( (PLINT) 0, (PLINT) ( pls->xlength / ( (QtRasterDevice *) ( pls->dev ) )->downscale ), (PLINT) 0, (PLINT) ( pls->ylength / ( (QtRasterDevice *) ( pls->dev ) )->downscale ) ); - plP_setpxl( dpi / 25.4 / ( (QtRasterDevice*) ( pls->dev ) )->downscale, dpi / 25.4 / ( (QtRasterDevice*) ( pls->dev ) )->downscale ); + plP_setpxl( dpi / 25.4 / ( (QtRasterDevice *) ( pls->dev ) )->downscale, dpi / 25.4 / ( (QtRasterDevice *) ( pls->dev ) )->downscale ); - ( (QtRasterDevice*) ( pls->dev ) )->setResolution( dpi ); + ( (QtRasterDevice *) ( pls->dev ) )->setResolution( dpi ); // Initialize family file info plFamInit( pls ); @@ -321,7 +321,7 @@ void plD_line_rasterqt( PLStream * pls, short x1a, short y1a, short x2a, short y2a ) { - QtRasterDevice* widget = (QtRasterDevice*) pls->dev; + QtRasterDevice* widget = (QtRasterDevice *) pls->dev; if ( widget != NULL && qt_family_check( pls ) ) { @@ -448,11 +448,11 @@ break; case PLSTATE_COLOR0: - ( (QtPLDriver*) widget )->QtPLDriver::setColor( pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a ); + ( (QtPLDriver *) widget )->QtPLDriver::setColor( pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a ); break; case PLSTATE_COLOR1: - ( (QtPLDriver*) widget )->QtPLDriver::setColor( pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a ); + ( (QtPLDriver *) widget )->QtPLDriver::setColor( pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a ); break; @@ -462,7 +462,7 @@ void plD_tidy_rasterqt( PLStream * pls ) { - QtRasterDevice * widget = (QtRasterDevice*) pls->dev; + QtRasterDevice * widget = (QtRasterDevice *) pls->dev; if ( widget != NULL ) { @@ -701,8 +701,8 @@ if ( pls->xlength <= 0 || pls->ylength <= 0 ) { pls->dev = new QtSVGDevice; - pls->xlength = (int) ( ( (QtSVGDevice*) ( pls->dev ) )->m_dWidth ); - pls->ylength = (int) ( ( (QtSVGDevice*) ( pls->dev ) )->m_dHeight ); + pls->xlength = (int) ( ( (QtSVGDevice *) ( pls->dev ) )->m_dWidth ); + pls->ylength = (int) ( ( (QtSVGDevice *) ( pls->dev ) )->m_dHeight ); } else { @@ -711,16 +711,16 @@ ( (QtSVGDevice *) pls->dev )->setPLStream( pls ); if ( isMaster ) - handler.setMasterDevice( (QtSVGDevice*) ( pls->dev ) ); + handler.setMasterDevice( (QtSVGDevice *) ( pls->dev ) ); if ( pls->xlength > pls->ylength ) - ( (QtSVGDevice*) ( pls->dev ) )->downscale = (PLFLT) pls-... [truncated message content] |
From: <ai...@us...> - 2011-06-09 16:31:41
|
Revision: 11763 http://plplot.svn.sourceforge.net/plplot/?rev=11763&view=rev Author: airwin Date: 2011-06-09 16:31:34 +0000 (Thu, 09 Jun 2011) Log Message: ----------- API change for plcolorbar that adds functionality that is already available in pllegend. New arguments to return bounding box size of colorbar, specify a background color for the area contained by the bounding box (if the PL_COLORBAR_BACKGROUND bit is set in opt), and specify the line color and line style of a boundary line for the bounding box (if the PL_COLORBAR_BOUNDING_BOX bit is set in opt). Add internal infrastructure to support complete position functionality that is the same (except for defaults) as already implemented in pllegend. ToDo: the new position functionality is a work in progress with some remaining coordinate transformation issues so, for example, the size of the bounding box is currently only correct in the simplest cases, the bounding box is not yet plotted in the correct place, and the caps are also not yet plotted in the correct place with the correct size. But the 16th and 33rd examples do build without errors and run (using the -colorbar option) without showstopper errors such as segfaults. Modified Paths: -------------- trunk/examples/c/x16c.c trunk/examples/c/x33c.c trunk/include/plplot.h trunk/src/pllegend.c Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-06-02 00:02:22 UTC (rev 11762) +++ trunk/examples/c/x16c.c 2011-06-09 16:31:34 UTC (rev 11763) @@ -136,6 +136,7 @@ PLcGrid2 cgrid2; PLINT fill_width = 2, cont_color = 0, cont_width = 0; + PLFLT colorbar_width, colorbar_height; // Parse and process command line arguments @@ -241,8 +242,10 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, - 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, + plcolorbar( &colorbar_width, &colorbar_height, +// PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_BOUNDING_BOX, 0, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); @@ -287,8 +290,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, - 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, + plcolorbar( &colorbar_width, &colorbar_height, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); @@ -333,8 +337,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, - 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, + plcolorbar( &colorbar_width, &colorbar_height, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); @@ -378,8 +383,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, - 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, + plcolorbar( &colorbar_width, &colorbar_height, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, 2, 3, 0.0, 0, "bcvxm", "", ns + 1, shedge ); @@ -474,8 +480,9 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, - 0.06, 0.15, 0.03, 0.7, 0.0, 0.0, + plcolorbar( &colorbar_width, &colorbar_height, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.06, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-06-02 00:02:22 UTC (rev 11762) +++ trunk/examples/c/x33c.c 2011-06-09 16:31:34 UTC (rev 11763) @@ -160,6 +160,7 @@ const char *axis_opts; char label[200]; char title[200]; + PLFLT colorbar_width, colorbar_height; ticks = 0.0; sub_ticks = 0; @@ -232,9 +233,11 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); - plcolorbar( opt, position, + plcolorbar( &colorbar_width, &colorbar_height, + opt, position, x, y, x_length, y_length, low_cap_color, high_cap_color, + 0, 1, 1, cont_color, cont_width, ticks, sub_ticks, axis_opts, label, Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2011-06-02 00:02:22 UTC (rev 11762) +++ trunk/include/plplot.h 2011-06-09 16:31:34 UTC (rev 11763) @@ -1266,6 +1266,8 @@ #define PL_COLORBAR_ORIENT_TOP 0x1000 #define PL_COLORBAR_ORIENT_LEFT 0x2000 #define PL_COLORBAR_ORIENT_BOTTOM 0x4000 +#define PL_COLORBAR_BACKGROUND 0x8000 +#define PL_COLORBAR_BOUNDING_BOX 0x10000 // Flags for drawing mode #define PL_MODE_UNKNOWN 0 @@ -1292,8 +1294,10 @@ // Routine for drawing continous colour legends PLDLLIMPEXP void -c_plcolorbar( PLINT position, PLINT opt, - PLFLT x, PLFLT y, PLFLT x_length, PLFLT y_length, +c_plcolorbar( PLFLT *p_colorbar_width, PLFLT *p_colorbar_height, + PLINT opt, PLINT position, PLFLT x, PLFLT y, + PLFLT x_length, PLFLT y_length, + PLINT bg_color, PLINT bb_color, PLINT bb_style, PLFLT low_cap_color, PLFLT high_cap_color, PLINT cont_color, PLINT cont_width, PLFLT ticks, PLINT sub_ticks, Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-06-02 00:02:22 UTC (rev 11762) +++ trunk/src/pllegend.c 2011-06-09 16:31:34 UTC (rev 11763) @@ -337,7 +337,12 @@ //-------------------------------------------------------------------------- //! Convert from adopted X coordinate to normalized subpage X -//! coordinate. See pllegend documentation for definition of adopted +//! coordinate. The *_adopted variables are the normalized subpage +//! limits of the adopted viewport which is either the external +//! viewport (PL_POSITION_VIEWPORT bit set in the position parameter) +//! or the subpage itself (PL_POSITION_SUBPAGE bit set in the position +//! parameter, in which case this is an identity transform). See +//! pllegend documentation for more details concerning the adopted //! coordinates. //! //! @param nx Adopted X coordinate. @@ -347,7 +352,12 @@ //-------------------------------------------------------------------------- //! Convert from normalized subpage X coordinate to adopted X -//! coordinate. See pllegend documentation for definition of adopted +//! coordinate. The *_adopted variables are the normalized subpage +//! limits of the adopted viewport which is either the external +//! viewport (PL_POSITION_VIEWPORT bit set in the position parameter) +//! or the subpage itself (PL_POSITION_SUBPAGE bit set in the position +//! parameter, in which case this is an identity transform). See +//! pllegend documentation for more details concerning the adopted //! coordinates. //! //! @param nx Normalized subpage X coordinate. @@ -357,7 +367,12 @@ //-------------------------------------------------------------------------- //! Convert from adopted Y coordinate to normalized subpage Y -//! coordinate. See pllegend documentation for definition of adopted +//! coordinate. The *_adopted variables are the normalized subpage +//! limits of the adopted viewport which is either the external +//! viewport (PL_POSITION_VIEWPORT bit set in the position parameter) +//! or the subpage itself (PL_POSITION_SUBPAGE bit set in the position +//! parameter, in which case this is an identity transform). See +//! pllegend documentation for more details concerning the adopted //! coordinates. //! //! @param ny Adopted Y coordinate. @@ -367,7 +382,12 @@ //-------------------------------------------------------------------------- //! Convert from normalized subpage Y coordinate to adopted Y -//! coordinate. See pllegend documentation for definition of adopted +//! coordinate. The *_adopted variables are the normalized subpage +//! limits of the adopted viewport which is either the external +//! viewport (PL_POSITION_VIEWPORT bit set in the position parameter) +//! or the subpage itself (PL_POSITION_SUBPAGE bit set in the position +//! parameter, in which case this is an identity transform). See +//! pllegend documentation for more details concerning the adopted //! coordinates. //! //! @param ny Normalized subpage Y coordinate. @@ -406,19 +426,21 @@ //! Otherwise, plot the legend entries in column-major order. //! @param position This variable contains bits which control the //! overall position of the legend and the definition of the adopted -//! coordinates used for positions. The combination of the -//! PL_POSITION_LEFT, PL_POSITION_RIGHT, PL_POSITION_TOP, -//! PL_POSITION_BOTTOM, PL_POSITION_INSIDE, and PL_POSITION_OUTSIDE -//! bits specifies one of the 16 possible standard positions (the 4 -//! corners and 4 side centers for both the inside and outside cases) -//! of the legend relative to the adopted coordinate system. The -//! adopted coordinates are normalized viewport coordinates if the -//! PL_POSITION_VIEWPORT bit is set or normalized subpage coordinates -//! if the PL_POSITION_SUBPAGE bit is set. Default position bits: If -//! none of PL_POSITION_LEFT, PL_POSITION_RIGHT, PL_POSITION_TOP, or -//! PL_POSITION_BOTTOM are set, then use the combination of -//! PL_POSITION_RIGHT and PL_POSITION_TOP. If neither of -//! PL_POSITION_INSIDE or PL_POSITION_OUTSIDE is set, use +//! coordinates used for positions just like what is done for the +//! position argument for plcolorbar. Note, however, that the defaults +//! for the position bits (see below) are different than the plcolorbar +//! case. The combination of the PL_POSITION_LEFT, PL_POSITION_RIGHT, +//! PL_POSITION_TOP, PL_POSITION_BOTTOM, PL_POSITION_INSIDE, and +//! PL_POSITION_OUTSIDE bits specifies one of the 16 possible standard +//! positions (the 4 corners and 4 side centers for both the inside +//! and outside cases) of the legend relative to the adopted +//! coordinate system. The adopted coordinates are normalized +//! viewport coordinates if the PL_POSITION_VIEWPORT bit is set or +//! normalized subpage coordinates if the PL_POSITION_SUBPAGE bit is +//! set. Default position bits: If none of PL_POSITION_LEFT, +//! PL_POSITION_RIGHT, PL_POSITION_TOP, or PL_POSITION_BOTTOM are set, +//! then the combination of PL_POSITION_RIGHT and PL_POSITION_TOP. If +//! neither of PL_POSITION_INSIDE or PL_POSITION_OUTSIDE is set, use //! PL_POSITION_INSIDE. If neither of PL_POSITION_VIEWPORT or //! PL_POSITION_SUBPAGE is set, use PL_POSITION_VIEWPORT. //! @param x X offset of the legend position in adopted coordinates @@ -619,13 +641,13 @@ if ( position & PL_POSITION_SUBPAGE ) plvpor( 0., 1., 0., 1. ); - // xdmin_adopted, etc., are the adopted coordinates within the - // current sub-page used for all coordinate transformations. - // If position & PL_POSITION_VIEWPORT is true, these coordinates - // are the external relative viewport coordinates. + // xdmin_adopted, etc., are the adopted limits of the coordinates + // within the current sub-page used for all coordinate + // transformations. + // If position & PL_POSITION_VIEWPORT is true, these limits + // are the external relative viewport limits. // If position & PL_POSITION_SUBPAGE is true, these // coordinates are the relative subpage coordinates. - plgvpsp( &xdmin_adopted, &xdmax_adopted, &ydmin_adopted, &ydmax_adopted ); // xwmin_save, etc., are the external world coordinates corresponding @@ -636,7 +658,7 @@ // be clipped at sub-page boundaries. plvpor( 0., 1., 0., 1. ); - // Internal window coordinates are the same as normalized internal + // Internal world coordinates are the same as normalized internal // viewport coordinates which are the same as normalized subpage coordinates. plwind( 0., 1., 0., 1. ); @@ -916,10 +938,14 @@ //! if orientation contains PL_COLORBAR_ORIENT_RIGHT, //! PL_COLORBAR_ORIENT_TOP, PL_COLORBAR_ORIENT_LEFT, or //! PL_COLORBAR_ORIENT_BOTTOM bits. -//! @param xmin Minimum X coordinate of rectangle inscribing the triangle. -//! @param xmax Maximum X coordinate of rectangle inscribing the triangle. -//! @param ymin Minimum Y coordinate of rectangle inscribing the triangle. -//! @param ymax Minimum Y coordinate of rectangle inscribing the triangle. +//! @param xmin Minimum world X coordinate of rectangle +//! inscribing the triangle. +//! @param xmax Maximum world X coordinate of rectangle +//! inscribing the triangle. +//! @param ymin Minimum world Y coordinate of rectangle +//! inscribing the triangle. +//! @param ymax Maximum world Y coordinate of rectangle +//! inscribing the triangle. //! @param color Color (color palette 1) used to fill the end cap. //! @@ -929,60 +955,50 @@ { // Save current drawing color. PLINT col0_save = plsc->icol0; + PLFLT xhalf = 0.5 * ( xmin + xmax ); + PLFLT yhalf = 0.5 * ( ymin + ymax ); - // Save window and viewport - // Saved normalized coordinates of viewport. - PLFLT xdmin_save, xdmax_save, ydmin_save, ydmax_save; - // Saved world coordinates of viewport. - PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save; - // Points for the triangle + // World coordinates for the triangle. Due to setup in the + // plcolorbar routine that calls this, these are also normalized + // subpage coordinates. PLFLT xs[3]; PLFLT ys[3]; - plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save ); - plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save ); - - // The viewport is the specified rectangle that inscribes the - // triangle. The world coordinates are chosen to make drawing of - // that triangle convenient. - plvpor( xmin, xmax, ymin, ymax ); - plwind( 0.0, 1.0, 0.0, 1.0 ); - if ( orientation == PL_COLORBAR_ORIENT_RIGHT ) { - xs[0] = 0.; - ys[0] = 0.; - xs[1] = 1.; - ys[1] = 0.5; - xs[2] = 0.; - ys[2] = 1.; + xs[0] = xmin; + ys[0] = ymin; + xs[1] = xmax; + ys[1] = yhalf; + xs[2] = xmin; + ys[2] = ymax; } else if ( orientation == PL_COLORBAR_ORIENT_TOP ) { - xs[0] = 1.; - ys[0] = 0.; - xs[1] = 0.5; - ys[1] = 1.; - xs[2] = 0.; - ys[2] = 0.; + xs[0] = xmax; + ys[0] = ymin; + xs[1] = xhalf; + ys[1] = ymax; + xs[2] = xmin; + ys[2] = ymin; } else if ( orientation == PL_COLORBAR_ORIENT_LEFT ) { - xs[0] = 1.; - ys[0] = 1.; - xs[1] = 0.; - ys[1] = 0.5; - xs[2] = 1.; - ys[2] = 0.; + xs[0] = xmax; + ys[0] = ymax; + xs[1] = xmin; + ys[1] = yhalf; + xs[2] = xmax; + ys[2] = ymin; } else if ( orientation == PL_COLORBAR_ORIENT_BOTTOM ) { - xs[0] = 0.; - ys[0] = 1.; - xs[1] = 0.5; - ys[1] = 0.; - xs[2] = 1.; - ys[2] = 1.; + xs[0] = xmin; + ys[0] = ymax; + xs[1] = xhalf; + ys[1] = ymin; + xs[2] = xmax; + ys[2] = ymax; } else { @@ -997,10 +1013,6 @@ // Draw cap outline if ( if_edge ) plline( 3, xs, ys ); - - // Restore window and viewport - plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save ); - plwind( xwmin_save, xwmax_save, ywmin_save, ywmax_save ); } //-------------------------------------------------------------------------- @@ -1025,18 +1037,43 @@ //! TODO: This should be expanded to support custom placement of tick //! marks and tick labels at custom value locations for any colorbar //! type. -//! @param position This variable defines the placement of the colorbar on the -//! subpage. The position can be one of PL_POSITION_TOP, -//! PL_POSITION_BOTTOM, PL_POSITION_LEFT or PL_POSITION_RIGHT. The colorbar -//! will be drawn perpendicular to the given side of the subpage. -//! @param x Colorbar displacement distance along/away from the horizonal axis -//! in normalized subpage coordinates. -//! @param y Colorbar displacement distance along/away from the vertical axis -//! in normalized subpage coordinates. -//! @param x_length Length of the colorbar in the X direction in -//! adopted coordinates. -//! @param y_length Length of the colorbar in the Y direction in -//! adopted coordinates. +//! @param position This variable contains bits which control the +//! overall position of the legend and the definition of the adopted +//! coordinates used for positions just like what is done for the +//! position argument for pllegend. Note, however, that the defaults +//! for the position bits (see below) are different than the pllegend +//! case. The combination of the PL_POSITION_LEFT, PL_POSITION_RIGHT, +//! PL_POSITION_TOP, PL_POSITION_BOTTOM, PL_POSITION_INSIDE, and +//! PL_POSITION_OUTSIDE bits specifies one of the 16 possible standard +//! positions (the 4 corners and 4 side centers for both the inside +//! and outside cases) of the legend relative to the adopted +//! coordinate system. The adopted coordinates are normalized +//! viewport coordinates if the PL_POSITION_VIEWPORT bit is set or +//! normalized subpage coordinates if the PL_POSITION_SUBPAGE bit is +//! set. Default position bits: If none of PL_POSITION_LEFT, +//! PL_POSITION_RIGHT, PL_POSITION_TOP, or PL_POSITION_BOTTOM are set, +//! then use PL_POSITION_RIGHT. If neither of PL_POSITION_INSIDE or +//! PL_POSITION_OUTSIDE is set, use PL_POSITION_OUTSIDE. If neither +//! of PL_POSITION_VIEWPORT or PL_POSITION_SUBPAGE is set, use +//! PL_POSITION_VIEWPORT. +//! @param x X offset of the legend position in adopted coordinates +//! from the specified standard position of the legend. For positive +//! x, the direction of motion away from the standard position is +//! inward/outward from the standard corner positions or standard left +//! or right positions if the PL_POSITION_INSIDE/PL_POSITION_OUTSIDE +//! bit is set in position. For the standard top or bottom positions, +//! the direction of motion for positive x is toward positive X. +//! @param y Y offset of the legend position in adopted coordinates +//! from the specified standard position of the legend. For positive +//! y, the direction of motion away from the standard position is +//! inward/outward from the standard corner positions or standard top +//! or bottom positions if the PL_POSITION_INSIDE/PL_POSITION_OUTSIDE +//! bit is set in position. For the standard left or right positions, +//! the direction of motion for positive y is toward positive Y. +//! @param x_length Length of the body of the colorbar in the X +//! direction in adopted coordinates. +//! @param y_length Length of the body of the colorbar in the Y +//! direction in adopted coordinates. //! @param low_cap_color Color of the low-end color bar cap, if it is drawn. //! @param high_cap_color Color of the high-end color bar cap, if it is drawn. //! @param cont_color Contour color for PL_COLORBAR_SHADE plots. This is @@ -1048,15 +1085,10 @@ //! @param ticks Spacing of major ticks, as for plbox. //! @param sub_ticks Number of subticks, as for plbox. //! @param axis_opts Axis options for the colorbar's major axis, as for plbox. -//! @param label Text label for the colorbar. No title is drawn if no label -//! position is specified in pos. +//! @param label Text label for the colorbar. No label is drawn if no +//! label position is specified with one of the +//! PL_COLORBAR_LABEL_(LEFT|RIGHT|TOP|BOTTOM) bits in opt. //! @param n_values Number of elements in the values array. -//! @param colors Colors (color map 1) used to draw the colorbar. If this is a -//! PL_COLORBAR_SHADE bar then there should be one entry per break between -//! segments. If this -//! is a PL_COLORBAR_IMAGE or PL_COLORBAR_GRADIENT bar then there should be two -//! elements - one to specify the high end and one to specify the low end. -//! This should have (n_values - 1) elements. //! @param values Numeric values for the data range represented by the //! colorbar. For PL_COLORBAR_SHADE, this should include one value per break //! between segments. For PL_COLORBAR_IMAGE and PL_COLORBAR_GRADIENT this @@ -1065,8 +1097,10 @@ //! void -c_plcolorbar( PLINT opt, PLINT position, - PLFLT x, PLFLT y, PLFLT x_length, PLFLT y_length, +c_plcolorbar( PLFLT *p_colorbar_width, PLFLT *p_colorbar_height, + PLINT opt, PLINT position, PLFLT x, PLFLT y, + PLFLT x_length, PLFLT y_length, + PLINT bg_color, PLINT bb_color, PLINT bb_style, PLFLT low_cap_color, PLFLT high_cap_color, PLINT cont_color, PLINT cont_width, PLFLT ticks, PLINT sub_ticks, @@ -1080,24 +1114,26 @@ // Assumes that the values array is sorted from smallest to largest // OR from largest to smallest. PLFLT min_value, max_value; - // Height of the cap in normalized coordinates + // Height of the cap in adopted coordinates // ToDo: Use better value related to size of color bar. PLFLT cap_height = 0.05; // Min and max colors PLFLT min_color, max_color; - // Saved normalized coordinates of viewport. + // Saved external world coordinates of viewport. + PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save; + // Saved external normalized coordinates of viewport. + // (These are actual values used only for the restore.) PLFLT xdmin_save, xdmax_save, ydmin_save, ydmax_save; + // Limits of adopted coordinates used to calculate all coordinate + // transformations. + PLFLT xdmin_adopted, xdmax_adopted, ydmin_adopted, ydmax_adopted; - // Saved world coordinates of viewport. - PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save; - // Active attributes to be saved and restored afterward. PLINT col0_save = plsc->icol0; - // Position of the color bar in normalized viewport (= normalized subpage - // coordinates). + // Position of the color bar in adopted coordinates. PLFLT vx_min, vx_max, vy_min, vy_max; PLFLT wx_min, wx_max, wy_min, wy_max; @@ -1111,17 +1147,92 @@ // How far away from the axis should the label be drawn? PLFLT label_offset; - // For building axis option string - PLINT max_opts = 25; - char opt_string[max_opts]; + // For building plmtex option string. + PLINT max_opts = 25; + char opt_string[max_opts]; + char perp; + + // axis option strings. const char *edge_string; size_t length_axis_opts = strlen( axis_opts ); char *local_axis_opts; PLBOOL if_edge; - // Draw a title - char perp; + // positional data. + PLFLT colorbar_width, colorbar_height, + colorbar_width_vc, colorbar_height_vc, + x_colorbar_position, y_colorbar_position, + xsign, ysign, + plot_x, plot_y, + plot_x_subpage, plot_y_subpage; + // Default position flags and sanity checks for position flags. + if ( !( position & PL_POSITION_RIGHT ) && !( position & PL_POSITION_LEFT ) && !( position & PL_POSITION_TOP ) && !( position & PL_POSITION_BOTTOM ) ) + { + position = position | PL_POSITION_RIGHT; + } + else if ( ( position & PL_POSITION_RIGHT ) && ( position & PL_POSITION_LEFT ) ) + { + plabort( "plcolorbar: PL_POSITION_RIGHT and PL_POSITION_LEFT cannot be simultaneously set." ); + return; + } + + else if ( ( position & PL_POSITION_TOP ) && ( position & PL_POSITION_BOTTOM ) ) + { + plabort( "plcolorbar: PL_POSITION_TOP and PL_POSITION_BOTTOM cannot be simultaneously set." ); + return; + } + + if ( !( position & PL_POSITION_INSIDE ) && !( position & PL_POSITION_OUTSIDE ) ) + { + position = position | PL_POSITION_OUTSIDE; + } + else if ( ( position & PL_POSITION_INSIDE ) && ( position & PL_POSITION_OUTSIDE ) ) + { + plabort( "plcolorbar: PL_POSITION_INSIDE and PL_POSITION_OUTSIDE cannot be simultaneously set." ); + return; + } + + if ( !( position & PL_POSITION_VIEWPORT ) && !( position & PL_POSITION_SUBPAGE ) ) + { + position = position | PL_POSITION_VIEWPORT; + } + else if ( ( position & PL_POSITION_VIEWPORT ) && ( position & PL_POSITION_SUBPAGE ) ) + { + plabort( "plcolorbar: PL_POSITION_VIEWPORT and PL_POSITION_SUBPAGE cannot be simultaneously set." ); + return; + } + + // xdmin_save, etc., are the actual external relative viewport + // coordinates within the current sub-page used only for + // restoration at the end. + plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save ); + + // Choose adopted coordinates. + if ( position & PL_POSITION_SUBPAGE ) + plvpor( 0., 1., 0., 1. ); + + // xdmin_adopted, etc., are the adopted limits of the coordinates + // within the current sub-page used for all coordinate + // transformations. + // If position & PL_POSITION_VIEWPORT is true, these limits + // are the external relative viewport limits. + // If position & PL_POSITION_SUBPAGE is true, these + // coordinates are the relative subpage coordinates. + plgvpsp( &xdmin_adopted, &xdmax_adopted, &ydmin_adopted, &ydmax_adopted ); + + // xwmin_save, etc., are the external world coordinates corresponding + // to the external viewport boundaries. + plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save ); + + // Internal viewport corresponds to sub-page so that all parts of the + // colorbar will be clipped at sub-page boundaries. + plvpor( 0., 1., 0., 1. ); + + // Internal world coordinates are the same as normalized internal + // viewport coordinates which are the same as normalized subpage coordinates. + plwind( 0., 1., 0., 1. ); + // Default orientation. if ( !( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_TOP || @@ -1153,9 +1264,64 @@ // Assumes that the colors array is sorted from smallest to largest. plgcmap1_range( &min_color, &max_color ); - plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save ); - plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save ); + // Total width and height of colorbar bounding box in normalized subpage + // coordinates. + colorbar_width = adopted_to_subpage_x( x_length ) - adopted_to_subpage_x( 0. ); + colorbar_height = adopted_to_subpage_y( y_length ) - adopted_to_subpage_y( 0. ); + // Total width and height of colorbar bounding box in adopted subpage + // coordinates. + colorbar_width_vc = subpage_to_adopted_x( colorbar_width ) - subpage_to_adopted_x( 0. ); + colorbar_height_vc = subpage_to_adopted_y( colorbar_height ) - subpage_to_adopted_y( 0. ); + *p_colorbar_width = colorbar_width_vc; + *p_colorbar_height = colorbar_height_vc; + legend_position( position, colorbar_width_vc, colorbar_height_vc, &x_colorbar_position, &y_colorbar_position, &xsign, &ysign ); + plot_x = x * xsign + x_colorbar_position; + plot_y = y * ysign + y_colorbar_position; + // Normalized subpage coordinates for colorbar plots + plot_x_subpage = adopted_to_subpage_x( plot_x ); + plot_y_subpage = adopted_to_subpage_y( plot_y ); + if ( opt & PL_COLORBAR_BACKGROUND ) + { + PLFLT xbg[4] = { + plot_x_subpage, + plot_x_subpage, + plot_x_subpage + colorbar_width, + plot_x_subpage + colorbar_width, + }; + PLFLT ybg[4] = { + plot_y_subpage, + plot_y_subpage - colorbar_height, + plot_y_subpage - colorbar_height, + plot_y_subpage, + }; + plpsty( 0 ); + plcol0( bg_color ); + plfill( 4, xbg, ybg ); + plcol0( col0_save ); + } + + if ( opt & PL_COLORBAR_BOUNDING_BOX ) + { + PLFLT xbb[5] = { + plot_x_subpage, + plot_x_subpage, + plot_x_subpage + colorbar_width, + plot_x_subpage + colorbar_width, + plot_x_subpage, + }; + PLFLT ybb[5] = { + plot_y_subpage, + plot_y_subpage - colorbar_height, + plot_y_subpage - colorbar_height, + plot_y_subpage, + plot_y_subpage, + }; + pllsty( bb_style ); + plcol0( bb_color ); + plline( 5, xbb, ybb ); + plcol0( col0_save ); + } // Specify the proper viewport ranges along the requested side // of the subpage if ( position & PL_POSITION_LEFT ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-06-12 18:03:15
|
Revision: 11764 http://plplot.svn.sourceforge.net/plplot/?rev=11764&view=rev Author: airwin Date: 2011-06-12 18:03:08 +0000 (Sun, 12 Jun 2011) Log Message: ----------- Fix minor bug in pllegend routine where line style changes could be propagated outside the routine. Drop old version of plcolorbar code since the examples have long since been inconsistent with that version. Improve specification of cap proportions using cap_angle, the angle in degrees of the angle of the cap triangle that points in the direction of the orientation of the cap. Correctly position boundary box and caps according to the new positioning scheme. This last is an interim commit to preserve my current work, and there are a lot more changes to come to correctly position bar, tickmarks and numerical labels for that bar, and the descriptive text. Also, the boundary box currently just refers to the inner bar without extensions (yet) due to caps, numerical labels, and the descriptive text. The result builds without issues, and examples 16 and 33 run with with no run-time errors for the case where the -colorbar option is used. Modified Paths: -------------- trunk/examples/c/x16c.c trunk/examples/c/x33c.c trunk/src/pllegend.c Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-06-09 16:31:34 UTC (rev 11763) +++ trunk/examples/c/x16c.c 2011-06-12 18:03:08 UTC (rev 11764) @@ -243,9 +243,9 @@ plsmin( 0.0, 0.5 ); plcolorbar( &colorbar_width, &colorbar_height, -// PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_BOUNDING_BOX, 0, - PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, - 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_BOUNDING_BOX, 0, +// PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.026, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-06-09 16:31:34 UTC (rev 11763) +++ trunk/examples/c/x33c.c 2011-06-12 18:03:08 UTC (rev 11764) @@ -186,15 +186,15 @@ // Set the offset position on the page if ( vertical ) { - x = 0.1; - y = 0.25; + x = 0.0; + y = 0.0; x_length = 0.05; y_length = 0.5; } else { - x = 0.25; - y = 0.1; + x = 0.0; + y = 0.0; x_length = 0.5; y_length = 0.05; } @@ -233,11 +233,13 @@ plsmaj( 0.0, 0.5 ); plsmin( 0.0, 0.5 ); + plvpor( 0.1, 0.9, 0.1, 0.9 ); + plwind( 0.0, 1.0, 0.0, 1.0 ); plcolorbar( &colorbar_width, &colorbar_height, - opt, position, + opt | PL_COLORBAR_BOUNDING_BOX, position, x, y, x_length, y_length, + 0, 1, 1, low_cap_color, high_cap_color, - 0, 1, 1, cont_color, cont_width, ticks, sub_ticks, axis_opts, label, Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-06-09 16:31:34 UTC (rev 11763) +++ trunk/src/pllegend.c 2011-06-12 18:03:08 UTC (rev 11764) @@ -776,6 +776,7 @@ plcol0( bb_color ); plline( 5, xbb, ybb ); plcol0( col0_save ); + pllsty( line_style_save ); } if ( opt & PL_LEGEND_TEXT_LEFT ) @@ -901,10 +902,6 @@ return; } -#define PL_COLORBAR_NEW_API -#ifdef PL_COLORBAR_NEW_API -// Code version with reorganized API for plcolorbar - //-------------------------------------------------------------------------- //! Remove specified ascii characters from null-terminated string. //! @@ -1114,10 +1111,25 @@ // Assumes that the values array is sorted from smallest to largest // OR from largest to smallest. PLFLT min_value, max_value; - // Height of the cap in adopted coordinates - // ToDo: Use better value related to size of color bar. - PLFLT cap_height = 0.05; + // Length of cap in orientation direction + PLFLT cap_extent; + // The colorbar cap is an equilateral triangle with cap_angle + // the angle (in degrees) of the unequal angle pointing in the + // direction of the orientation of the cap. In other words, + // cap_angle completely controls the shape of the triangle, but + // not its scale. + PLFLT cap_angle = 90.; + // Ratio of length of cap in orientation direction + // to the width of the bar (and cap) in the direction + // perpendicular to the orientation in physical coordinates + // (i.e., independent of aspect ratio). + PLFLT cap_ratio = 0.5 / tan( PI / 360. * cap_angle ); + + // aspect ratio of physical area of subpage. + PLFLT aspspp = ( ( plsc->sppxma - plsc->sppxmi ) / plsc->xpmm ) / + ( ( plsc->sppyma - plsc->sppymi ) / plsc->ypmm ); + // Min and max colors PLFLT min_color, max_color; @@ -1126,12 +1138,14 @@ // Saved external normalized coordinates of viewport. // (These are actual values used only for the restore.) PLFLT xdmin_save, xdmax_save, ydmin_save, ydmax_save; + // Limits of adopted coordinates used to calculate all coordinate // transformations. PLFLT xdmin_adopted, xdmax_adopted, ydmin_adopted, ydmax_adopted; // Active attributes to be saved and restored afterward. - PLINT col0_save = plsc->icol0; + PLINT col0_save = plsc->icol0, + line_style_save = plsc->line_style; // Position of the color bar in adopted coordinates. PLFLT vx_min, vx_max, vy_min, vy_max; @@ -1160,6 +1174,7 @@ // positional data. PLFLT colorbar_width, colorbar_height, + bar_width, bar_height, colorbar_width_vc, colorbar_height_vc, x_colorbar_position, y_colorbar_position, xsign, ysign, @@ -1225,14 +1240,6 @@ // to the external viewport boundaries. plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save ); - // Internal viewport corresponds to sub-page so that all parts of the - // colorbar will be clipped at sub-page boundaries. - plvpor( 0., 1., 0., 1. ); - - // Internal world coordinates are the same as normalized internal - // viewport coordinates which are the same as normalized subpage coordinates. - plwind( 0., 1., 0., 1. ); - // Default orientation. if ( !( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_TOP || @@ -1264,10 +1271,16 @@ // Assumes that the colors array is sorted from smallest to largest. plgcmap1_range( &min_color, &max_color ); + // Width and height of just the bar (i.e., excluding caps, numerical tick + // labels, and text) in normalized subpage coordinates. + bar_width = adopted_to_subpage_x( x_length ) - adopted_to_subpage_x( 0. ); + bar_height = adopted_to_subpage_y( y_length ) - adopted_to_subpage_y( 0. ); // Total width and height of colorbar bounding box in normalized subpage // coordinates. - colorbar_width = adopted_to_subpage_x( x_length ) - adopted_to_subpage_x( 0. ); - colorbar_height = adopted_to_subpage_y( y_length ) - adopted_to_subpage_y( 0. ); + // FIXME. Need to add caps + numerical tick labels + text to + // these calculations. + colorbar_width = bar_width; + colorbar_height = bar_height; // Total width and height of colorbar bounding box in adopted subpage // coordinates. colorbar_width_vc = subpage_to_adopted_x( colorbar_width ) - subpage_to_adopted_x( 0. ); @@ -1281,47 +1294,6 @@ plot_x_subpage = adopted_to_subpage_x( plot_x ); plot_y_subpage = adopted_to_subpage_y( plot_y ); - if ( opt & PL_COLORBAR_BACKGROUND ) - { - PLFLT xbg[4] = { - plot_x_subpage, - plot_x_subpage, - plot_x_subpage + colorbar_width, - plot_x_subpage + colorbar_width, - }; - PLFLT ybg[4] = { - plot_y_subpage, - plot_y_subpage - colorbar_height, - plot_y_subpage - colorbar_height, - plot_y_subpage, - }; - plpsty( 0 ); - plcol0( bg_color ); - plfill( 4, xbg, ybg ); - plcol0( col0_save ); - } - - if ( opt & PL_COLORBAR_BOUNDING_BOX ) - { - PLFLT xbb[5] = { - plot_x_subpage, - plot_x_subpage, - plot_x_subpage + colorbar_width, - plot_x_subpage + colorbar_width, - plot_x_subpage, - }; - PLFLT ybb[5] = { - plot_y_subpage, - plot_y_subpage - colorbar_height, - plot_y_subpage - colorbar_height, - plot_y_subpage, - plot_y_subpage, - }; - pllsty( bb_style ); - plcol0( bb_color ); - plline( 5, xbb, ybb ); - plcol0( col0_save ); - } // Specify the proper viewport ranges along the requested side // of the subpage if ( position & PL_POSITION_LEFT ) @@ -1657,6 +1629,20 @@ label_offset = 0.0; // Draw end-caps + + // Internal viewport corresponds to sub-page so that all parts of the + // colorbar will be clipped at sub-page boundaries. + plvpor( 0., 1., 0., 1. ); + + // Internal world coordinates are the same as normalized internal + // viewport coordinates which are the same as normalized subpage coordinates. + plwind( 0., 1., 0., 1. ); + + if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) + cap_extent = cap_ratio * bar_height / aspspp; + else + cap_extent = cap_ratio * bar_width * aspspp; + if ( opt & PL_COLORBAR_CAP_LOW ) { // Add an extra offset for the label so it does not bump in to the @@ -1670,21 +1656,25 @@ } // Draw a filled triangle (cap/arrow) at the low end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) - { - draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, low_cap_color ); - } + draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT, + plot_x_subpage - cap_extent, plot_x_subpage, + plot_y_subpage - bar_height, plot_y_subpage, + low_cap_color ); else if ( opt & PL_COLORBAR_ORIENT_TOP ) - { - draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, low_cap_color ); - } + draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM, + plot_x_subpage, plot_x_subpage + bar_width, + plot_y_subpage - bar_height - cap_extent, plot_y_subpage - bar_height, + low_cap_color ); else if ( opt & PL_COLORBAR_ORIENT_LEFT ) - { - draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, low_cap_color ); - } + draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT, + plot_x_subpage + bar_width, plot_x_subpage + bar_width + cap_extent, + plot_y_subpage - bar_height, plot_y_subpage, + low_cap_color ); else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) - { - draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, low_cap_color ); - } + draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP, + plot_x_subpage, plot_x_subpage + bar_width, + plot_y_subpage, plot_y_subpage + cap_extent, + low_cap_color ); } if ( opt & PL_COLORBAR_CAP_HIGH ) { @@ -1699,106 +1689,35 @@ } // Draw a filled triangle (cap/arrow) at the high end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) - { - draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT, vx_max, vx_max + cap_height, vy_min, vy_max, high_cap_color ); - } + draw_cap( if_edge, PL_COLORBAR_ORIENT_RIGHT, + plot_x_subpage + bar_width, plot_x_subpage + bar_width + cap_extent, + plot_y_subpage - bar_height, plot_y_subpage, + high_cap_color ); else if ( opt & PL_COLORBAR_ORIENT_TOP ) - { - draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP, vx_min, vx_max, vy_max, vy_max + cap_height, high_cap_color ); - } - if ( opt & PL_COLORBAR_ORIENT_LEFT ) - { - draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT, vx_min - cap_height, vx_min, vy_min, vy_max, high_cap_color ); - } + draw_cap( if_edge, PL_COLORBAR_ORIENT_TOP, + plot_x_subpage, plot_x_subpage + bar_width, + plot_y_subpage, plot_y_subpage + cap_extent, + high_cap_color ); + else if ( opt & PL_COLORBAR_ORIENT_LEFT ) + draw_cap( if_edge, PL_COLORBAR_ORIENT_LEFT, + plot_x_subpage - cap_extent, plot_x_subpage, + plot_y_subpage - bar_height, plot_y_subpage, + high_cap_color ); else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) - { - draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM, vx_min, vx_max, vy_min - cap_height, vy_min, high_cap_color ); - } + draw_cap( if_edge, PL_COLORBAR_ORIENT_BOTTOM, + plot_x_subpage, plot_x_subpage + bar_width, + plot_y_subpage - bar_height - cap_extent, plot_y_subpage - bar_height, + high_cap_color ); } - // Write label. - if ( opt & PL_COLORBAR_LABEL_LEFT ) - { - if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) - { - if ( position & PL_POSITION_LEFT ) - label_offset += 4.0; - else - label_offset += 2.0; - perp = '\0'; - just = 0.5; - } - else - { - label_offset += 1.5; - perp = 'v'; - just = 1.0; - } - snprintf( opt_string, max_opts, "l%c", perp ); - plmtex( opt_string, label_offset, 0.5, just, label ); - } - else if ( opt & PL_COLORBAR_LABEL_RIGHT ) - { - if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) - { - if ( position & PL_POSITION_RIGHT ) - label_offset += 4.0; - else - label_offset += 2.0; - perp = '\0'; - just = 0.5; - } - else - { - label_offset += 1.5; - perp = 'v'; - just = 0.0; - } - snprintf( opt_string, max_opts, "r%c", perp ); - plmtex( opt_string, label_offset, 0.5, just, label ); - } - else if ( opt & PL_COLORBAR_LABEL_TOP ) - { - if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) - { - label_offset += 1.5; - perp = '\0'; - } - else - { - if ( position & PL_POSITION_TOP ) - label_offset += 4.0; - else - label_offset += 2.0; - perp = '\0'; - } - snprintf( opt_string, max_opts, "t%c", perp ); - plmtex( opt_string, label_offset, 0.5, 0.5, label ); - } - else if ( opt & PL_COLORBAR_LABEL_BOTTOM ) - { - if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) - { - label_offset += 1.5; - perp = '\0'; - } - else - { - if ( position & PL_POSITION_BOTTOM ) - label_offset += 4.0; - else - label_offset += 2.0; - perp = '\0'; - } - snprintf( opt_string, max_opts, "b%c", perp ); - plmtex( opt_string, label_offset, 0.5, 0.5, label ); - } - // Draw numerical labels and tick marks if this is a shade color bar // TODO: A better way to handle this would be to update the // internals of plbox to support custom tick and label positions // along an axis. + plvpor( vx_min, vx_max, vy_min, vy_max ); + plwind( wx_min, wx_max, wy_min, wy_max ); + if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) { if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) @@ -1827,522 +1746,10 @@ free( local_axis_opts ); - // Restore previous plot characteristics. - plcol0( col0_save ); - plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save ); - plwind( xwmin_save, xwmax_save, ywmin_save, ywmax_save ); - - return; -} - -#else -// Code version without reorganized API for plcolorbar -//-------------------------------------------------------------------------- -//! Draw triangular end-caps for color bars. -//! -//! @param position This variable defines the placement of the colorbar on the -//! subpage. The position can be one of PL_POSITION_TOP, -//! PL_POSITION_BOTTOM, PL_POSITION_LEFT or PL_POSITION_RIGHT. The colorbar -//! will be drawn perpendicular to the given side of the subpage. -//! @param opt This variable can be PL_COLORBAR_CAP_LOW or -//! PL_COLORBAR_CAP_HIGH, indicating whether we are drawing a low-end cap or a -//! high-end cap. -//! @param a1 First primary coordinate for the end cap base. If position -//! is PL_POSITION_LEFT or PL_POSITION_RIGHT then a1 and a2 are x coordinates. -//! if position is PL_POSITION_TOP or PL_POSITION_BOTTOM then a1 and a2 are y -//! coordinates. (a1, b) and (a2, b) OR (b, a1) and (b, a2) define the base of -//! the triangular cap. -//! @param a2 Second primary coordinate for the end cap base. -//! @param b Secondary coordinate for the end cap base. If a1 and a2 are x, -//! b is y. If a1 and a2 are y, b is x. -//! @param color Color (color palette 1) used to fill the end cap. -//! - -void -draw_cap( PLINT position, PLINT opt, PLFLT a1, PLFLT a2, PLFLT b, PLFLT color ) -{ - // Height the cap in normalized coordinates - PLFLT cap_height = 0.05; - - // Save drawing color - PLINT col0_save = plsc->icol0; - - // Save window and viewport - // Saved normalized coordinates of viewport. - PLFLT xdmin_save, xdmax_save, ydmin_save, ydmax_save; - // Saved world coordinates of viewport. - PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save; - plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save ); - plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save ); - - // Use the entire sub-page, and make world coordinates 0.0 -> 1.0 - // This way the location and orientation of the cap can be easily - // defined by a combination of position, opt, a1, a2 and b. - plvpor( 0.0, 1.0, 0.0, 1.0 ); - plwind( 0.0, 1.0, 0.0, 1.0 ); - - // Points for the triangle - PLFLT xs[3]; - PLFLT ys[3]; - - plcol1( color ); - - if ( opt & PL_COLORBAR_CAP_LOW ) - { - if ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) - { - // Draw the cap on the bottom - xs[0] = a1; - ys[0] = b; - xs[2] = a2; - ys[2] = b; - xs[1] = ( xs[0] + xs[2] ) / 2.0; - ys[1] = ys[0] - cap_height; - - plfill( 3, xs, ys ); - } - else if ( position & PL_POSITION_TOP || position & PL_POSITION_BOTTOM ) - { - // Draw the cap on the left - xs[0] = b; - ys[0] = a1; - xs[2] = b; - ys[2] = a2; - xs[1] = xs[0] - cap_height; - ys[1] = ( ys[0] + ys[2] ) / 2.0; - - plfill( 3, xs, ys ); - } - } - else if ( opt & PL_COLORBAR_CAP_HIGH ) - { - if ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) - { - // Draw the cap on the top - xs[0] = a1; - ys[0] = b; - xs[2] = a2; - ys[2] = b; - xs[1] = ( xs[0] + xs[2] ) / 2.0; - ys[1] = ys[0] + cap_height; - - plfill( 3, xs, ys ); - } - else if ( position & PL_POSITION_TOP || position & PL_POSITION_BOTTOM ) - { - // Draw the cap on the right - xs[0] = b; - ys[0] = a1; - xs[2] = b; - ys[2] = a2; - xs[1] = xs[0] + cap_height; - ys[1] = ( ys[0] + ys[2] ) / 2.0; - - plfill( 3, xs, ys ); - } - } - - // Restore the drawing color - plcol0( col0_save ); - - // Draw cap outline - plline( 3, xs, ys ); - - // Restore window and viewport - plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save ); - plwind( xwmin_save, xwmax_save, ywmin_save, ywmax_save ); -} - -//-------------------------------------------------------------------------- -//! Plot color bar for image, shade or gradient plots. -//! -//! @param opt This variable contains bits which control the overall colorbar. -//! The type of colorbar can be specified with PL_COLORBAR_SHADE, -//! PL_COLORBAR_IMAGE or PL_COLORBAR_GRADIENT. The position of the (optional) -//! label/title can be specified with -//! PL_COLORBAR_LABEL_(LEFT|RIGHT|TOP|BOTTOM). If no label position is -//! specified then no label will be drawn. End-caps for the colorbar can -//! added with PL_COLORBAR_CAP_LOW and PL_COLORBAR_CAP_HIGH. If a particular -//! colorbar cap option is not specified then no cap will be drawn for that -//! end. As a special case for PL_COLORBAR_SHADE, the option -//! PL_COLORBAR_SHADE_LABEL can be specified. If this option is provided then -//! any tick marks and tick labels will be placed at the breaks between shaded -//! segments. TODO: This should be expanded to support custom placement of -//! tick marks and tick labels at custom value locations for any colorbar type. -//! @param position This variable defines the placement of the colorbar on the -//! subpage. The position can be one of PL_POSITION_TOP, -//! PL_POSITION_BOTTOM, PL_POSITION_LEFT or PL_POSITION_RIGHT. The colorbar -//! will be drawn perpendicular to the given side of the subpage. -//! @param x Colorbar displacement distance along/away from the horizonal axis -//! in normalized subpage coordinates. -//! @param y Colorbar displacement distance along/away from the vertical axis -//! in normalized subpage coordinates. -//! @param length Length of the colorbar along its major axis (ex. along the -//! top of the subpage if pos is PL_POSITION_TOP) in normalized subpage -//! coordinates. -//! @param width Width of the colorbar along the minor axis (ex. fraction of -//! the vertical subpage size if pos is PL_POSITION_TOP) in normalized subpage -//! coordinates. -//! @param low_cap_color Color of the low-end color bar cap, if it is drawn. -//! @param high_cap_color Color of the high-end color bar cap, if it is drawn. -//! @param cont_color Contour color for PL_COLORBAR_SHADE plots. This is -//! passed directly to plshades, so it will be interpreted according to the -//! design of plshades. -//! @param cont_width Contour width for PL_COLORBAR_SHADE plots. This is -//! passed directly to plshades, so it will be interpreted according to the -//! design of plshades. -//! @param ticks Spacing of major ticks, as for plbox. -//! @param sub_ticks Number of subticks, as for plbox. -//! @param axis_opts Axis options for the colorbar's major axis, as for plbox. -//! @param label Text label for the colorbar. No title is drawn if no label -//! position is specified in pos. -//! @param n_values Number of elements in the values array. -//! @param colors Colors (color map 1) used to draw the colorbar. If this is a -//! PL_COLORBAR_SHADE bar then there should be one entry per break between -//! segments. If this -//! is a PL_COLORBAR_IMAGE or PL_COLORBAR_GRADIENT bar then there should be two -//! elements - one to specify the high end and one to specify the low end. -//! This should have (n_values - 1) elements. -//! @param values Numeric values for the data range represented by the -//! colorbar. For PL_COLORBAR_SHADE, this should include one value per break -//! between segments. For PL_COLORBAR_IMAGE and PL_COLORBAR_GRADIENT this -//! include two values, one for the maximum value on the scale and one for the -//! minimum value. -//! - -void -c_plcolorbar( PLINT opt, PLINT position, - PLFLT x, PLFLT y, PLFLT length, PLFLT width, - PLFLT low_cap_color, PLFLT high_cap_color, - PLINT cont_color, PLINT cont_width, - PLFLT ticks, PLINT sub_ticks, - const char *axis_opts, const char *label, - PLINT n_values, const PLFLT *values ) -{ - // Justification of label text - PLFLT just; - - // Min and max values - // Assumes that the values array is sorted from smallest to largest - // OR from largest to smallest. - PLFLT min_value, max_value; - min_value = values[0]; - max_value = values[ n_values - 1 ]; - - // Min and max colors - // Assumes that the colors array is sorted from smallest to largest. - PLFLT min_color, max_color; - plgcmap1_range( &min_color, &max_color ); - - // Saved normalized coordinates of viewport. - PLFLT xdmin_save, xdmax_save, ydmin_save, ydmax_save; - // Saved world coordinates of viewport. - PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save; - plgvpsp( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save ); - plgvpw( &xwmin_save, &xwmax_save, &ywmin_save, &ywmax_save ); - - // Active attributes to be saved and restored afterward. - PLINT col0_save = plsc->icol0; - - // Position of the color bar in normalized viewport (= normalized subpage - // coordinates). - PLFLT vx_min, vx_max, vy_min, vy_max; - PLFLT wx_min, wx_max, wy_min, wy_max; - // Build the proper viewport and window dimension along the requested side - // of the subpage - if ( position & PL_POSITION_LEFT ) - { - vx_min = x; - vy_min = y; - vx_max = vx_min + width; - vy_max = vy_min + length; - wx_min = 0.0; - wy_min = min_value; - wx_max = 1.0; - wy_max = max_value; - } - else if ( position & PL_POSITION_RIGHT ) - { - vx_min = 1.0 - x - width; - vy_min = y; - vx_max = vx_min + width; - vy_max = vy_min + length; - wx_min = 0.0; - wy_min = min_value; - wx_max = 1.0; - wy_max = max_value; - } - else if ( position & PL_POSITION_TOP ) - { - vx_min = x; - vy_min = 1.0 - y - width; - vx_max = vx_min + length; - vy_max = vy_min + width; - wx_min = min_value; - wy_min = 0.0; - wx_max = max_value; - wy_max = 1.0; - } - else if ( position & PL_POSITION_BOTTOM ) - { - vx_min = x; - vy_min = y; - vx_max = vx_min + length; - vy_max = vy_min + width; - wx_min = min_value; - wy_min = 0.0; - wx_max = max_value; - wy_max = 1.0; - } - else - { - plabort( "plcolorbar: Invalid or missing side" ); - } - - // The window used to draw the colorbar should take up the whole viewport - plvpor( vx_min, vx_max, vy_min, vy_max ); - plwind( wx_min, wx_max, wy_min, wy_max ); - - // The data to plot - PLFLT **color_data; - // Setting up the data for display - PLINT i, j, ni, nj, n_steps; - PLFLT step_size; - - // What kind of color bar are we making? - if ( opt & PL_COLORBAR_IMAGE ) - { - // Interpolate - // TODO: Should this be decided with an extra opt option instead of by - // counting n_values? - if ( n_values == 2 ) - { - // Use the same number of steps as there are steps in - // color palette 1. - // TODO: Determine a better way to specify the steps here? - n_steps = plsc->ncol1; - step_size = ( max_value - min_value ) / (PLFLT) n_steps; - if ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) - { - ni = 2; - nj = n_steps; - plAlloc2dGrid( &color_data, ni, nj ); - for ( i = 0; i < ni; i++ ) - { - for ( j = 0; j < nj; j++ ) - { - color_data[i][j] = min_value + (PLFLT) j * step_size; - } - } - } - else if ( position & PL_POSITION_TOP || position & PL_POSITION_BOTTOM ) - { - ni = n_steps; - nj = 2; - plAlloc2dGrid( &color_data, ni, nj ); - for ( i = 0; i < ni; i++ ) - { - for ( j = 0; j < nj; j++ ) - { - color_data[i][j] = min_value + (PLFLT) i * step_size; - } - } - } - else - { - plabort( "plcolorbar: Invalid side" ); - } - } - // No interpolation - use values array as-is - else - { - n_steps = n_values; - // Use the provided values in this case. - if ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) - { - ni = 2; - nj = n_steps; - plAlloc2dGrid( &color_data, ni, nj ); - for ( i = 0; i < ni; i++ ) - { - for ( j = 0; j < nj; j++ ) - { - color_data[i][j] = values[j]; - } - } - } - else if ( position & PL_POSITION_TOP || position & PL_POSITION_BOTTOM ) - { - ni = n_steps; - nj = 2; - plAlloc2dGrid( &color_data, ni, nj ); - for ( i = 0; i < ni; i++ ) - { - for ( j = 0; j < nj; j++ ) - { - color_data[i][j] = values[i]; - } - } - } - else - { - plabort( "plcolorbar: Invalid side" ); - } - } - // Draw the color bar - plimage( (const PLFLT **) color_data, ni, nj, wx_min, wx_max, wy_min, wy_max, - min_value, max_value, wx_min, wx_max, wy_min, wy_max ); - plFree2dGrid( color_data, ni, nj ); - } - else if ( opt & PL_COLORBAR_SHADE ) - { - // Transform grid - // The transform grid is used to make the size of the shaded segments - // scale relative to other segments. For example, if segment A - // makes up 10% of the scale and segment B makes up 20% of the scale - // then segment B will be twice the length of segment A. - PLcGrid grid; - PLFLT grid_axis[2] = { 0.0, 1.0 }; - n_steps = n_values; - // Use the provided values. - if ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) - { - grid.xg = grid_axis; - grid.yg = (PLFLT *) values; - grid.nx = 2; - grid.ny = n_steps; - ni = 2; - nj = n_steps; - plAlloc2dGrid( &color_data, ni, nj ); - for ( i = 0; i < ni; i++ ) - { - for ( j = 0; j < nj; j++ ) - { - color_data[i][j] = values[j]; - } - } - } - else if ( position & PL_POSITION_TOP || position & PL_POSITION_BOTTOM ) - { - grid.xg = (PLFLT *) values; - grid.yg = grid_axis; - grid.nx = n_steps; - grid.ny = 2; - ni = n_steps; - nj = 2; - plAlloc2dGrid( &color_data, ni, nj ); - for ( i = 0; i < ni; i++ ) - { - for ( j = 0; j < nj; j++ ) - { - color_data[i][j] = values[i]; - } - } - } - else - { - plabort( "plcolorbar: Invalid side" ); - } - - // Draw the color bar - plshades( (const PLFLT **) color_data, ni, nj, NULL, wx_min, wx_max, wy_min, wy_max, - values, n_steps, 0, cont_color, cont_width, plfill, TRUE, - pltr1, (void *) ( &grid ) ); - plFree2dGrid( color_data, ni, nj ); - } - else if ( opt & PL_COLORBAR_GRADIENT ) - { - PLFLT xs[4], ys[4]; - xs[0] = wx_min; - ys[0] = wy_min; - xs[1] = wx_max; - ys[1] = wy_min; - xs[2] = wx_max; - ys[2] = wy_max; - xs[3] = wx_min; - ys[3] = wy_max; - PLFLT angle; - // Make sure the gradient runs in the proper direction - if ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) - { - // Top to bottom - angle = 90.0; - } - else if ( position & PL_POSITION_TOP || position & PL_POSITION_BOTTOM ) - { - // Left to right - angle = 0.0; - } - else - { - plabort( "plcolorbar: Invalid side" ); - } - plgradient( 4, xs, ys, angle ); - } - - // Restore the previous drawing color to use for outlines and text - plcol0( col0_save ); - - // How far away from the axis should the label be drawn? - PLFLT label_offset; - label_offset = 0.0; - - // Draw end-caps - if ( opt & PL_COLORBAR_CAP_LOW ) - { - // Add an extra offset for the label so it does not bump in to the - // cap if the label is placed on the same side as the cap. - if ( ( ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) && - opt & PL_COLORBAR_LABEL_BOTTOM ) || - ( ( position & PL_POSITION_TOP || position & PL_POSITION_BOTTOM ) && - opt & PL_COLORBAR_LABEL_LEFT ) ) - { - label_offset += 2.5; - } - // Draw a filled triangle (cap/arrow) at the low end of the scale - if ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) - { - draw_cap( position, PL_COLORBAR_CAP_LOW, vx_min, vx_max, vy_min, low_cap_color ); - } - else if ( position & PL_POSITION_BOTTOM || position & PL_POSITION_TOP ) - { - draw_cap( position, PL_COLORBAR_CAP_LOW, vy_min, vy_max, vx_min, low_cap_color ); - } - } - if ( opt & PL_COLORBAR_CAP_HIGH ) - { - // Add an extra offset for the label so it does not bump in to the - // cap if the label is placed on the same side as the cap. - if ( ( ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) && - opt & PL_COLORBAR_LABEL_TOP ) || - ( ( position & PL_POSITION_TOP || position & PL_POSITION_BOTTOM ) && - opt & PL_COLORBAR_LABEL_RIGHT ) ) - { - label_offset += 2.5; - } - // Draw a filled triangle (cap/arrow) at the high end of the scale - if ( position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT ) - { - draw_cap( position, PL_COLORBAR_CAP_HIGH, vx_min, vx_max, vy_max, high_cap_color ); - } - else if ( position & PL_POSITION_BOTTOM || position & PL_POSITION_TOP ) - { - draw_cap( position, PL_COLORBAR_CAP_HIGH, vy_min, vy_max, vx_max, high_cap_color ); - } - } - - // For building axis option string - PLINT max_opts = 25; - char opt_string[max_opts]; - const char *tick_string; - - tick_string = ""; - - // Draw a title - char perp; + // Write label. if ( opt & PL_COLORBAR_LABEL_LEFT ) { - if ( position & PL_POSITION_RIGHT || position & PL_POSITION_LEFT ) + if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) { if ( position & PL_POSITION_LEFT ) label_offset += 4.0; @@ -2362,7 +1769,7 @@ } else if ( opt & PL_COLORBAR_LABEL_RIGHT ) { - if ( position & PL_POSITION_RIGHT || position & PL_POSITION_LEFT ) + if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) { if ( position & PL_POSITION_RIGHT ) label_offset += 4.0; @@ -2382,7 +1789,7 @@ } else if ( opt & PL_COLORBAR_LABEL_TOP ) { - if ( position & PL_POSITION_RIGHT || position & PL_POSITION_LEFT ) + if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) { label_offset += 1.5; perp = '\0'; @@ -2400,7 +1807,7 @@ } else if ( opt & PL_COLORBAR_LABEL_BOTTOM ) { - if ( position & PL_POSITION_RIGHT || position & PL_POSITION_LEFT ) + if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) { label_offset += 1.5; perp = '\0'; @@ -2417,66 +1824,56 @@ plmtex( opt_string, label_offset, 0.5, 0.5, label ); } - // Draw labels and tick marks if this is a shade color bar - // TODO: A better way to handle this would be to update the - // internals of plbox to support custom tick and label positions - // along an axis. - if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) + // Internal viewport corresponds to sub-page so that all parts of the + // colorbar will be clipped at sub-page boundaries. + plvpor( 0., 1., 0., 1. ); + + // Internal world coordinates are the same as normalized internal + // viewport coordinates which are the same as normalized subpage coordinates. + plwind( 0., 1., 0., 1. ); + + if ( opt & PL_COLORBAR_BACKGROUND ) { - if ( position & PL_POSITION_LEFT ) - { - snprintf( opt_string, max_opts, "nt%s", axis_opts ); - label_box_custom( "", 0, NULL, opt_string, n_values, values ); - } - else if ( position & PL_POSITION_RIGHT ) - { - snprintf( opt_string, max_opts, "mt%s", axis_opts ); - label_box_custom( "", 0, NULL, opt_string, n_values, values ); - } - else if ( position & PL_POSITION_TOP ) - { - snprintf( opt_string, max_opts, "mt%s", axis_opts ); - label_box_custom( opt_string, n_values, values, "", 0, NULL ); - } - else if ( position & PL_POSITION_BOTTOM ) - { - snprintf( opt_string, max_opts, "nt%s", axis_opts ); - label_box_custom( opt_string, n_values, values, "", 0, NULL ); - } + PLFLT xbg[4] = { + plot_x_subpage, + plot_x_subpage, + plot_x_subpage + colorbar_width, + plot_x_subpage + colorbar_width, + }; + PLFLT ybg[4] = { + plot_y_subpage, + plot_y_subpage - colorbar_height, + plot_y_subpage - colorbar_height, + plot_y_subpage, + }; + plpsty( 0 ); + plcol0( bg_color ); + plfill( 4, xbg, ybg ); + plcol0( col0_save ); } - else - { - if ( position & PL_POSITION_LEFT || position & PL_POSITION_BOTTOM ) - { - tick_string = "n"; - } - else if ( position & PL_POSITION_RIGHT || position & PL_POSITION_TOP ) - { - tick_string = "m"; - } - } - // Draw the outline for the entire colorbar, tick marks, tick labels. - if ( position & PL_POSITION_LEFT ) + if ( opt & PL_COLORBAR_BOUNDING_BOX ) { - snprintf( opt_string, max_opts, "bc%s%s", tick_string, axis_opts ); - plbox( "bc", ticks, sub_ticks, opt_string, ticks, sub_ticks ); + PLFLT xbb[5] = { + plot_x_subpage, + plot_x_subpage, + plot_x_subpage + colorbar_width, + plot_x_subpage + colorbar_width, + plot_x_subpage, + }; + PLFLT ybb[5] = { + plot_y_subpage, + plot_y_subpage - colorbar_height, + plot_y_subpage - colorbar_height, + plot_y_subpage, + plot_y_subpage, + }; + pllsty( bb_style ); + plcol0( bb_color ); + plline( 5, xbb, ybb ); + plcol0( col0_save ); + pllsty( line_style_save ); } - else if ( position & PL_POSITION_RIGHT ) - { - snprintf( opt_string, max_opts, "bc%s%s", tick_string, axis_opts ); - plbox( "bc", 0.0, 0, opt_string, ticks, sub_ticks ); - } - else if ( position & PL_POSITION_TOP ) - { - snprintf( opt_string, max_opts, "bc%s%s", tick_string, axis_opts ); - plbox( opt_string, ticks, sub_ticks, "bc", 0.0, 0 ); - } - else if ( position & PL_POSITION_BOTTOM ) - { - snprintf( opt_string, max_opts, "bc%s%s", tick_string, axis_opts ); - plbox( opt_string, ticks, sub_ticks, "bc", 0.0, 0 ); - } // Restore previous plot characteristics. plcol0( col0_save ); @@ -2485,5 +1882,3 @@ return; } - -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-06-12 23:51:13
|
Revision: 11766 http://plplot.svn.sourceforge.net/plplot/?rev=11766&view=rev Author: airwin Date: 2011-06-12 23:51:06 +0000 (Sun, 12 Jun 2011) Log Message: ----------- Update colorbar, tickmarks and numerical labels, and text to use the new positioning scheme for plcolorbar. ToDo: there is still work required to understand and fix the positioning of the shades case of colorbar and to expand the bounding box to account for more than just the core colorbar. However, if you ignore the shades case (i.e., focus on just the image and gradient cases) for example 33, the results look reasonable again so I am getting there. Modified Paths: -------------- trunk/examples/c/x16c.c trunk/src/pllegend.c Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-06-12 18:25:19 UTC (rev 11765) +++ trunk/examples/c/x16c.c 2011-06-12 23:51:06 UTC (rev 11766) @@ -292,7 +292,7 @@ plcolorbar( &colorbar_width, &colorbar_height, PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, - 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, + 0.026, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); @@ -339,7 +339,7 @@ plcolorbar( &colorbar_width, &colorbar_height, PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, - 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, + 0.026, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); @@ -385,7 +385,7 @@ plcolorbar( &colorbar_width, &colorbar_height, PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, - 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, + 0.026, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, 2, 3, 0.0, 0, "bcvxm", "", ns + 1, shedge ); @@ -482,7 +482,7 @@ plcolorbar( &colorbar_width, &colorbar_height, PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, - 0.06, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, + 0.026, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-06-12 18:25:19 UTC (rev 11765) +++ trunk/src/pllegend.c 2011-06-12 23:51:06 UTC (rev 11766) @@ -1148,7 +1148,6 @@ line_style_save = plsc->line_style; // Position of the color bar in adopted coordinates. - PLFLT vx_min, vx_max, vy_min, vy_max; PLFLT wx_min, wx_max, wy_min, wy_max; // The data to plot @@ -1294,72 +1293,48 @@ plot_x_subpage = adopted_to_subpage_x( plot_x ); plot_y_subpage = adopted_to_subpage_y( plot_y ); - // Specify the proper viewport ranges along the requested side - // of the subpage - if ( position & PL_POSITION_LEFT ) - { - vx_min = x; - vy_min = y; - } - else if ( position & PL_POSITION_RIGHT ) - { - vx_min = 1.0 - x - x_length; - vy_min = y; - } - else if ( position & PL_POSITION_TOP ) - { - vx_min = x; - vy_min = 1.0 - y - y_length; - } - else if ( position & PL_POSITION_BOTTOM ) - { - vx_min = x; - vy_min = y; - } - else - { - plabort( "plcolorbar: Invalid PL_POSITION_* bits" ); - } - vx_max = vx_min + x_length; - vy_max = vy_min + y_length; - // Specify the proper window ranges depending on orientation. if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - wx_min = min_value; - wx_max = max_value; - wy_min = 0.0; - wy_max = 1.0; + wx_min = plot_x_subpage; + wx_max = plot_x_subpage + bar_width; + wy_min = plot_y_subpage - bar_height; + wy_max = plot_y_subpage; } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { - wx_min = 0.0; - wx_max = 1.0; - wy_min = min_value; - wy_max = max_value; + wx_min = plot_x_subpage; + wx_max = plot_x_subpage + bar_width; + wy_min = plot_y_subpage - bar_height; + wy_max = plot_y_subpage; } else if ( opt & PL_COLORBAR_ORIENT_LEFT ) { - wx_min = max_value; - wx_max = min_value; - wy_min = 0.0; - wy_max = 1.0; + wx_max = plot_x_subpage; + wx_min = plot_x_subpage + bar_width; + wy_min = plot_y_subpage - bar_height; + wy_max = plot_y_subpage; } else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { - wx_min = 0.0; - wx_max = 1.0; - wy_min = max_value; - wy_max = min_value; + wx_min = plot_x_subpage; + wx_max = plot_x_subpage + bar_width; + wy_max = plot_y_subpage - bar_height; + wy_min = plot_y_subpage; } else { plabort( "plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" ); } - plvpor( vx_min, vx_max, vy_min, vy_max ); - plwind( wx_min, wx_max, wy_min, wy_max ); + // Internal viewport corresponds to sub-page so that all parts of the + // colorbar will be clipped at sub-page boundaries. + plvpor( 0., 1., 0., 1. ); + // Internal world coordinates are the same as normalized internal + // viewport coordinates which are the same as normalized subpage coordinates. + plwind( 0., 1., 0., 1. ); + // What kind of color bar are we making? if ( opt & PL_COLORBAR_IMAGE ) { @@ -1630,14 +1605,6 @@ // Draw end-caps - // Internal viewport corresponds to sub-page so that all parts of the - // colorbar will be clipped at sub-page boundaries. - plvpor( 0., 1., 0., 1. ); - - // Internal world coordinates are the same as normalized internal - // viewport coordinates which are the same as normalized subpage coordinates. - plwind( 0., 1., 0., 1. ); - if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) cap_extent = cap_ratio * bar_height / aspspp; else @@ -1715,7 +1682,41 @@ // internals of plbox to support custom tick and label positions // along an axis. - plvpor( vx_min, vx_max, vy_min, vy_max ); + plvpor( wx_min, wx_max, wy_min, wy_max ); + // Specify the proper window ranges depending on orientation. + if ( opt & PL_COLORBAR_ORIENT_RIGHT ) + { + wx_min = min_value; + wx_max = max_value; + wy_min = 0.0; + wy_max = 1.0; + } + else if ( opt & PL_COLORBAR_ORIENT_TOP ) + { + wx_min = 0.0; + wx_max = 1.0; + wy_min = min_value; + wy_max = max_value; + } + else if ( opt & PL_COLORBAR_ORIENT_LEFT ) + { + wx_min = max_value; + wx_max = min_value; + wy_min = 0.0; + wy_max = 1.0; + } + else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) + { + wx_min = 0.0; + wx_max = 1.0; + wy_min = max_value; + wy_max = min_value; + } + else + { + plabort( "plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" ); + } + plwind( wx_min, wx_max, wy_min, wy_max ); if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-06-13 16:17:04
|
Revision: 11767 http://plplot.svn.sourceforge.net/plplot/?rev=11767&view=rev Author: airwin Date: 2011-06-13 16:16:57 +0000 (Mon, 13 Jun 2011) Log Message: ----------- Adjust viewport and windows coordinate limits consistently so that image, gradient, and shades colorbars now all have good positioning and clip results according to the new positioning scheme. ToDo: Make bounding box correspond to extent of text outside the core colorbar and modify colorbar part of example 33 to (a) pack more results per page, and (b) demonstrate the new colorbar functionality that has been recently introduced. Modified Paths: -------------- trunk/examples/c/x16c.c trunk/examples/c/x33c.c trunk/src/pllegend.c Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-06-12 23:51:06 UTC (rev 11766) +++ trunk/examples/c/x16c.c 2011-06-13 16:16:57 UTC (rev 11767) @@ -243,8 +243,7 @@ plsmin( 0.0, 0.5 ); plcolorbar( &colorbar_width, &colorbar_height, - PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_BOUNDING_BOX, 0, -// PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, 0.026, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-06-12 23:51:06 UTC (rev 11766) +++ trunk/examples/c/x33c.c 2011-06-13 16:16:57 UTC (rev 11767) @@ -236,7 +236,7 @@ plvpor( 0.1, 0.9, 0.1, 0.9 ); plwind( 0.0, 1.0, 0.0, 1.0 ); plcolorbar( &colorbar_width, &colorbar_height, - opt | PL_COLORBAR_BOUNDING_BOX, position, + opt, position, x, y, x_length, y_length, 0, 1, 1, low_cap_color, high_cap_color, Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-06-12 23:51:06 UTC (rev 11766) +++ trunk/src/pllegend.c 2011-06-13 16:16:57 UTC (rev 11767) @@ -1148,6 +1148,7 @@ line_style_save = plsc->line_style; // Position of the color bar in adopted coordinates. + PLFLT vx_min, vx_max, vy_min, vy_max; PLFLT wx_min, wx_max, wy_min, wy_max; // The data to plot @@ -1296,45 +1297,58 @@ // Specify the proper window ranges depending on orientation. if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - wx_min = plot_x_subpage; - wx_max = plot_x_subpage + bar_width; - wy_min = plot_y_subpage - bar_height; - wy_max = plot_y_subpage; + vx_min = plot_x_subpage; + vx_max = plot_x_subpage + bar_width; + vy_min = plot_y_subpage - bar_height; + vy_max = plot_y_subpage; + wx_min = min_value; + wx_max = max_value; + wy_min = 0.0; + wy_max = 1.0; } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { - wx_min = plot_x_subpage; - wx_max = plot_x_subpage + bar_width; - wy_min = plot_y_subpage - bar_height; - wy_max = plot_y_subpage; + vx_min = plot_x_subpage; + vx_max = plot_x_subpage + bar_width; + vy_min = plot_y_subpage - bar_height; + vy_max = plot_y_subpage; + wx_min = 0.0; + wx_max = 1.0; + wy_min = min_value; + wy_max = max_value; } else if ( opt & PL_COLORBAR_ORIENT_LEFT ) { - wx_max = plot_x_subpage; - wx_min = plot_x_subpage + bar_width; - wy_min = plot_y_subpage - bar_height; - wy_max = plot_y_subpage; + vx_min = plot_x_subpage; + vx_max = plot_x_subpage + bar_width; + vy_min = plot_y_subpage - bar_height; + vy_max = plot_y_subpage; + wx_min = max_value; + wx_max = min_value; + wy_min = 0.0; + wy_max = 1.0; } else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { - wx_min = plot_x_subpage; - wx_max = plot_x_subpage + bar_width; - wy_max = plot_y_subpage - bar_height; - wy_min = plot_y_subpage; + vx_min = plot_x_subpage; + vx_max = plot_x_subpage + bar_width; + vy_min = plot_y_subpage - bar_height; + vy_max = plot_y_subpage; + wx_min = 0.0; + wx_max = 1.0; + wy_min = max_value; + wy_max = min_value; } else { plabort( "plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" ); } - // Internal viewport corresponds to sub-page so that all parts of the - // colorbar will be clipped at sub-page boundaries. - plvpor( 0., 1., 0., 1. ); + // Viewport and world coordinate ranges for all but cap and + // bounding-box areas. + plvpor( vx_min, vx_max, vy_min, vy_max ); + plwind( wx_min, wx_max, wy_min, wy_max ); - // Internal world coordinates are the same as normalized internal - // viewport coordinates which are the same as normalized subpage coordinates. - plwind( 0., 1., 0., 1. ); - // What kind of color bar are we making? if ( opt & PL_COLORBAR_IMAGE ) { @@ -1605,6 +1619,10 @@ // Draw end-caps + // Viewport and world coordinate ranges for cap and bounding-box areas. + plvpor( 0., 1., 0., 1. ); + plwind( 0., 1., 0., 1. ); + if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) cap_extent = cap_ratio * bar_height / aspspp; else @@ -1682,41 +1700,9 @@ // internals of plbox to support custom tick and label positions // along an axis. - plvpor( wx_min, wx_max, wy_min, wy_max ); - // Specify the proper window ranges depending on orientation. - if ( opt & PL_COLORBAR_ORIENT_RIGHT ) - { - wx_min = min_value; - wx_max = max_value; - wy_min = 0.0; - wy_max = 1.0; - } - else if ( opt & PL_COLORBAR_ORIENT_TOP ) - { - wx_min = 0.0; - wx_max = 1.0; - wy_min = min_value; - wy_max = max_value; - } - else if ( opt & PL_COLORBAR_ORIENT_LEFT ) - { - wx_min = max_value; - wx_max = min_value; - wy_min = 0.0; - wy_max = 1.0; - } - else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) - { - wx_min = 0.0; - wx_max = 1.0; - wy_min = max_value; - wy_max = min_value; - } - else - { - plabort( "plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" ); - } - + // Viewport and world coordinate ranges for all but cap and + // bounding-box areas. + plvpor( vx_min, vx_max, vy_min, vy_max ); plwind( wx_min, wx_max, wy_min, wy_max ); if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) @@ -1825,12 +1811,8 @@ plmtex( opt_string, label_offset, 0.5, 0.5, label ); } - // Internal viewport corresponds to sub-page so that all parts of the - // colorbar will be clipped at sub-page boundaries. + // Viewport and world coordinate ranges for cap and bounding-box areas. plvpor( 0., 1., 0., 1. ); - - // Internal world coordinates are the same as normalized internal - // viewport coordinates which are the same as normalized subpage coordinates. plwind( 0., 1., 0., 1. ); if ( opt & PL_COLORBAR_BACKGROUND ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2011-06-17 14:00:02
|
Revision: 11772 http://plplot.svn.sourceforge.net/plplot/?rev=11772&view=rev Author: hbabcock Date: 2011-06-17 13:59:51 +0000 (Fri, 17 Jun 2011) Log Message: ----------- Add (lightly tested) string length functionality to the Qt driver. Modified Paths: -------------- trunk/bindings/qt_gui/plqt.cpp trunk/drivers/qt.cpp Modified: trunk/bindings/qt_gui/plqt.cpp =================================================================== --- trunk/bindings/qt_gui/plqt.cpp 2011-06-15 17:06:26 UTC (rev 11771) +++ trunk/bindings/qt_gui/plqt.cpp 2011-06-17 13:59:51 UTC (rev 11772) @@ -325,6 +325,7 @@ drawTextInPicture( &p, currentString ); p.end(); + return res; } @@ -356,6 +357,12 @@ QPicture picText = getTextPicture( fci, txt->unicode_array, txt->unicode_array_len, pls->chrht ); picDpi = picText.logicalDpiY(); + if ( pls->get_string_length ) + { + pls->string_length = ((PLFLT) xOffset / picDpi) * 25.4; + return; + } + m_painterP->setClipping( true ); m_painterP->setClipRect( QRect( (int) ( pls->clpxmi * downscale ), (int) ( m_dHeight - pls->clpyma * downscale ), (int) ( ( pls->clpxma - pls->clpxmi ) * downscale ), (int) ( ( pls->clpyma - pls->clpymi ) * downscale ) ), Qt::ReplaceClip ); @@ -874,7 +881,35 @@ void QtPLWidget::drawText( EscText* txt ) { + if ( pls->get_string_length ) + { + PLUNICODE fci; + QPicture picText; + double picDpi; + PLUNICODE *text; + + plgfci( &fci ); + text = new PLUNICODE[txt->unicode_array_len]; + memcpy( text, txt->unicode_array, txt->unicode_array_len * sizeof ( PLUNICODE ) ); + picText = getTextPicture( fci, + text, + txt->unicode_array_len, + pls->chrht); + // + // I'm assuming that y_fact is 1.0 here, as it is impossible + // to know in advance (or so I believe). When the text is + // rendered "for real" it will be: pls->chrht * y_fact. + // + // Hazen 6/2011 + // + picDpi = picText.logicalDpiY(); + pls->string_length = ((PLFLT) xOffset / picDpi) * 25.4; + free(text); + return; + } + BufferElement el; + el.Element = TEXT; el.Data.TextStruct = new struct TextStruct_; el.Data.TextStruct->x = txt->x * downscale; Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2011-06-15 17:06:26 UTC (rev 11771) +++ trunk/drivers/qt.cpp 2011-06-17 13:59:51 UTC (rev 11772) @@ -267,6 +267,7 @@ pls->page = 0; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations // Needs to be true only because of multi-stream case bool isMaster = initQtApp( true ); @@ -694,6 +695,7 @@ pls->page = 0; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations // Needs to be true only because of multi-stream case bool isMaster = initQtApp( true ); @@ -978,6 +980,7 @@ pls->page = 0; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations // QPrinter devices won't create if there is no QApplication declared... // Needs to be true only because of multi-stream case @@ -1288,6 +1291,7 @@ pls->termin = 1; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations widget->setVisible( true ); widget->resize( plsc->xlength, plsc->ylength ); @@ -1513,6 +1517,7 @@ pls->termin = 0; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations } // @@ -1708,6 +1713,7 @@ pls->page = 0; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations // Needs to be true only because of multi-stream case bool isMaster = initQtApp( true ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-06-20 18:03:10
|
Revision: 11773 http://plplot.svn.sourceforge.net/plplot/?rev=11773&view=rev Author: airwin Date: 2011-06-20 18:03:03 +0000 (Mon, 20 Jun 2011) Log Message: ----------- Style previous changes. Modified Paths: -------------- trunk/bindings/qt_gui/plqt.cpp trunk/drivers/qt.cpp Modified: trunk/bindings/qt_gui/plqt.cpp =================================================================== --- trunk/bindings/qt_gui/plqt.cpp 2011-06-17 13:59:51 UTC (rev 11772) +++ trunk/bindings/qt_gui/plqt.cpp 2011-06-20 18:03:03 UTC (rev 11773) @@ -359,7 +359,7 @@ if ( pls->get_string_length ) { - pls->string_length = ((PLFLT) xOffset / picDpi) * 25.4; + pls->string_length = ( (PLFLT) xOffset / picDpi ) * 25.4; return; } @@ -884,27 +884,27 @@ if ( pls->get_string_length ) { PLUNICODE fci; - QPicture picText; - double picDpi; - PLUNICODE *text; + QPicture picText; + double picDpi; + PLUNICODE *text; plgfci( &fci ); - text = new PLUNICODE[txt->unicode_array_len]; - memcpy( text, txt->unicode_array, txt->unicode_array_len * sizeof ( PLUNICODE ) ); + text = new PLUNICODE[txt->unicode_array_len]; + memcpy( text, txt->unicode_array, txt->unicode_array_len * sizeof ( PLUNICODE ) ); picText = getTextPicture( fci, - text, - txt->unicode_array_len, - pls->chrht); - // - // I'm assuming that y_fact is 1.0 here, as it is impossible - // to know in advance (or so I believe). When the text is - // rendered "for real" it will be: pls->chrht * y_fact. - // - // Hazen 6/2011 - // - picDpi = picText.logicalDpiY(); - pls->string_length = ((PLFLT) xOffset / picDpi) * 25.4; - free(text); + text, + txt->unicode_array_len, + pls->chrht ); + // + // I'm assuming that y_fact is 1.0 here, as it is impossible + // to know in advance (or so I believe). When the text is + // rendered "for real" it will be: pls->chrht * y_fact. + // + // Hazen 6/2011 + // + picDpi = picText.logicalDpiY(); + pls->string_length = ( (PLFLT) xOffset / picDpi ) * 25.4; + free( text ); return; } Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2011-06-17 13:59:51 UTC (rev 11772) +++ trunk/drivers/qt.cpp 2011-06-20 18:03:03 UTC (rev 11773) @@ -262,11 +262,11 @@ pls->dev_flush = 1; // Driver does not have a clear capability so use (good) PLplot core // fallback for that instead. - pls->dev_clear = 0; - pls->termin = 0; - pls->page = 0; - pls->dev_text = 1; // want to draw text - pls->dev_unicode = 1; // want unicode + pls->dev_clear = 0; + pls->termin = 0; + pls->page = 0; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode pls->has_string_length = 1; // Driver supports string length calculations // Needs to be true only because of multi-stream case @@ -690,11 +690,11 @@ pls->dev_flush = 1; // Driver does not have a clear capability so use (good) PLplot core // fallback for that instead. - pls->dev_clear = 0; - pls->termin = 0; - pls->page = 0; - pls->dev_text = 1; // want to draw text - pls->dev_unicode = 1; // want unicode + pls->dev_clear = 0; + pls->termin = 0; + pls->page = 0; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode pls->has_string_length = 1; // Driver supports string length calculations // Needs to be true only because of multi-stream case @@ -975,11 +975,11 @@ pls->dev_flush = 1; // Driver does not have a clear capability so use (good) PLplot core // fallback for that instead. - pls->dev_clear = 0; - pls->termin = 0; - pls->page = 0; - pls->dev_text = 1; // want to draw text - pls->dev_unicode = 1; // want unicode + pls->dev_clear = 0; + pls->termin = 0; + pls->page = 0; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode pls->has_string_length = 1; // Driver supports string length calculations // QPrinter devices won't create if there is no QApplication declared... @@ -1287,10 +1287,10 @@ pls->dev_flush = 1; // Driver does not have a clear capability so use (good) PLplot core // fallback for that instead. - pls->dev_clear = 0; - pls->termin = 1; - pls->dev_text = 1; // want to draw text - pls->dev_unicode = 1; // want unicode + pls->dev_clear = 0; + pls->termin = 1; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode pls->has_string_length = 1; // Driver supports string length calculations widget->setVisible( true ); @@ -1513,10 +1513,10 @@ pls->dev_flush = 1; // Driver does not have a clear capability so use (good) PLplot core // fallback for that instead. - pls->dev_clear = 0; - pls->termin = 0; - pls->dev_text = 1; // want to draw text - pls->dev_unicode = 1; // want unicode + pls->dev_clear = 0; + pls->termin = 0; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode pls->has_string_length = 1; // Driver supports string length calculations } @@ -1708,11 +1708,11 @@ pls->dev_flush = 1; // Driver does not have a clear capability so use (good) PLplot core // fallback for that instead. - pls->dev_clear = 0; - pls->termin = 0; - pls->page = 0; - pls->dev_text = 1; // want to draw text - pls->dev_unicode = 1; // want unicode + pls->dev_clear = 0; + pls->termin = 0; + pls->page = 0; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode pls->has_string_length = 1; // Driver supports string length calculations // Needs to be true only because of multi-stream case This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-06-20 22:09:40
|
Revision: 11774 http://plplot.svn.sourceforge.net/plplot/?rev=11774&view=rev Author: airwin Date: 2011-06-20 22:09:33 +0000 (Mon, 20 Jun 2011) Log Message: ----------- Implement infrastructure for bounding-box calculation for plbox, label_box, and label_box_custom (including decorations such as inverted tick marks and numerical tick labels). Use this infrastructure to help calculate the position of the complete colorbar (including decorations) and its bounding box. For now, the revised example 33 shows the effects of inverted tick marks on position and bounding box of the complete colorbar. ToDo: for now, I have only implemented and tested the inverted tick mark case as a proof of concept for the plbox bounding-box infrastructure. Thus, additional work needs to be done to include the numerical tick labels in the bounding box for plbox. Also, the colorbar label (if present) is independent of plbox so must be included independently into the bounding box calculation for the complete colorbar. Modified Paths: -------------- trunk/examples/c/x33c.c trunk/include/plstrm.h trunk/src/plbox.c trunk/src/pllegend.c Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-06-20 18:03:03 UTC (rev 11773) +++ trunk/examples/c/x33c.c 2011-06-20 22:09:33 UTC (rev 11774) @@ -204,7 +204,7 @@ { if ( cont_color == 0 || cont_width == 0 ) { - axis_opts = "uwtvn"; + axis_opts = "uwtivn"; } else { @@ -215,7 +215,7 @@ { if ( cont_color == 0 || cont_width == 0 ) { - axis_opts = "uwtvm"; + axis_opts = "uwtivm"; } else { @@ -238,7 +238,7 @@ // Set interesting background colour. plscol0a( 15, 0, 0, 0, 0.20 ); plcolorbar( &colorbar_width, &colorbar_height, - opt|PL_COLORBAR_BOUNDING_BOX|PL_COLORBAR_BACKGROUND, position, + opt | PL_COLORBAR_BOUNDING_BOX | PL_COLORBAR_BACKGROUND, position, x, y, x_length, y_length, 15, 1, 1, low_cap_color, high_cap_color, Modified: trunk/include/plstrm.h =================================================================== --- trunk/include/plstrm.h 2011-06-20 18:03:03 UTC (rev 11773) +++ trunk/include/plstrm.h 2011-06-20 22:09:33 UTC (rev 11774) @@ -796,6 +796,13 @@ // Drawing mode section PLINT dev_modeset; + + // Calculate bounding-box limits rather than plot box? + PLBOOL if_boxbb; + // Bounding box limits in mm for box including decorations + // (inverted tick marks and numerical tick labels if either is + // present). + PLFLT boxbb_xmin, boxbb_xmax, boxbb_ymin, boxbb_ymax; } PLStream; //-------------------------------------------------------------------------- Modified: trunk/src/plbox.c =================================================================== --- trunk/src/plbox.c 2011-06-20 18:03:03 UTC (rev 11773) +++ trunk/src/plbox.c 2011-06-20 22:09:33 UTC (rev 11774) @@ -156,6 +156,16 @@ vppymi = plsc->vppymi; vppyma = plsc->vppyma; + if ( plsc->if_boxbb ) + { + // Bounding-box limits for the box in mm before corrections + // for decorations are applied. + plsc->boxbb_xmin = plsc->vppxmi / plsc->xpmm; + plsc->boxbb_xmax = plsc->vppxma / plsc->xpmm; + plsc->boxbb_ymin = plsc->vppymi / plsc->ypmm; + plsc->boxbb_ymax = plsc->vppyma / plsc->ypmm; + } + // Convert world coordinates to physical xp0 = plP_wcpcx( x0 ); @@ -202,13 +212,14 @@ ytick1 = lly ? 1.0 : ytick; plP_xgvpw( &vpwxmin, &vpwxmax, &vpwymin, &vpwymax ); -// n.b. large change; vpwxmi always numerically less than vpwxma, and +// vpwxmi always numerically less than vpwxma, and // similarly for vpwymi vpwxmi = ( vpwxmax > vpwxmin ) ? vpwxmin : vpwxmax; vpwxma = ( vpwxmax > vpwxmin ) ? vpwxmax : vpwxmin; vpwymi = ( vpwymax > vpwymin ) ? vpwymin : vpwymax; vpwyma = ( vpwymax > vpwymin ) ? vpwymax : vpwymin; +// Plot axes only if they are inside viewport. lax = lax && vpwymi < y0 && y0 < vpwyma; lay = lay && vpwxmi < x0 && x0 < vpwxma; @@ -253,294 +264,309 @@ i4y = ymajor; } + if ( plsc->if_boxbb ) + { + // Carefully follow logic below (and above) for the case where + // an inverted major tick mark is written (in the X direction + // for a Y axis and vice versa). Ignore minor tick marks + // which are assumed to be smaller. Ignore axes and grids + // which are all contained within the viewport. + if ( lix && ( lbx || lux ) && ( ltx && !lxx ) ) + plsc->boxbb_ymin -= xmajor / plsc->ypmm; + if ( liy && ( lcy || lwy ) && ( lty && !lxy ) ) + plsc->boxbb_xmax += ymajor / plsc->xpmm; + if ( lix && ( lcx || lwx ) && ( ltx && !lxx ) ) + plsc->boxbb_ymax += xmajor / plsc->ypmm; + if ( liy && ( lby || luy ) && ( lty && !lxy ) ) + plsc->boxbb_xmin -= ymajor / plsc->xpmm; + } + else + { // Draw the bottom frame of the box - if ( lbx || lux ) - { - if ( !lux ) + if ( lbx || lux ) { - plP_movphy( vppxmi, vppymi ); - plP_draphy( vppxma, vppymi ); - } - if ( ltx && !lxx ) - { - if ( ldx ) + if ( !lux ) { - pldtfac( vpwxmi, vpwxma, &factor, &tstart ); - tp = xtick1 * ( floor( ( vpwxmi - tstart ) / xtick1 ) ) + tstart; + plP_movphy( vppxmi, vppymi ); + plP_draphy( vppxma, vppymi ); } - else - tp = xtick1 * floor( vpwxmi / xtick1 ); - for (;; ) + if ( ltx && !lxx ) { - tn = tp + xtick1; - if ( lsx ) + if ( ldx ) { - if ( llx ) + pldtfac( vpwxmi, vpwxma, &factor, &tstart ); + tp = xtick1 * ( floor( ( vpwxmi - tstart ) / xtick1 ) ) + tstart; + } + else + tp = xtick1 * floor( vpwxmi / xtick1 ); + for (;; ) + { + tn = tp + xtick1; + if ( lsx ) { - for ( i = 0; i <= 7; i++ ) + if ( llx ) { - temp = tp + xlog[i]; - if ( BETW( temp, vpwxmi, vpwxma ) ) - plxtik( plP_wcpcx( temp ), vppymi, i1x, i2x ); + for ( i = 0; i <= 7; i++ ) + { + temp = tp + xlog[i]; + if ( BETW( temp, vpwxmi, vpwxma ) ) + plxtik( plP_wcpcx( temp ), vppymi, i1x, i2x ); + } } - } - else - { - for ( i = 1; i <= nxsub1 - 1; i++ ) + else { - temp = tp + i * xtick1 / nxsub1; - if ( BETW( temp, vpwxmi, vpwxma ) ) - plxtik( plP_wcpcx( temp ), vppymi, i1x, i2x ); + for ( i = 1; i <= nxsub1 - 1; i++ ) + { + temp = tp + i * xtick1 / nxsub1; + if ( BETW( temp, vpwxmi, vpwxma ) ) + plxtik( plP_wcpcx( temp ), vppymi, i1x, i2x ); + } } } + if ( !BETW( tn, vpwxmi, vpwxma ) ) + break; + plxtik( plP_wcpcx( tn ), vppymi, i3x, i4x ); + tp = tn; } - if ( !BETW( tn, vpwxmi, vpwxma ) ) - break; - plxtik( plP_wcpcx( tn ), vppymi, i3x, i4x ); - tp = tn; } } - } -// Draw right-hand frame of box +// Draw the right-hand frame of box - if ( lcy || lwy ) - { - if ( !lwy ) + if ( lcy || lwy ) { - plP_movphy( vppxma, vppymi ); - plP_draphy( vppxma, vppyma ); - } - if ( lty && !lxy ) - { - if ( ldy ) + if ( !lwy ) { - pldtfac( vpwymi, vpwyma, &factor, &tstart ); - tp = ytick1 * ( floor( ( vpwymi - tstart ) / ytick1 ) ) + tstart; + plP_movphy( vppxma, vppymi ); + plP_draphy( vppxma, vppyma ); } - else - tp = ytick1 * floor( vpwymi / ytick1 ); - for (;; ) + if ( lty && !lxy ) { - tn = tp + ytick1; - if ( lsy ) + if ( ldy ) { - if ( lly ) + pldtfac( vpwymi, vpwyma, &factor, &tstart ); + tp = ytick1 * ( floor( ( vpwymi - tstart ) / ytick1 ) ) + tstart; + } + else + tp = ytick1 * floor( vpwymi / ytick1 ); + for (;; ) + { + tn = tp + ytick1; + if ( lsy ) { - for ( i = 0; i <= 7; i++ ) + if ( lly ) { - temp = tp + xlog[i]; - if ( BETW( temp, vpwymi, vpwyma ) ) - plytik( vppxma, plP_wcpcy( temp ), i2y, i1y ); + for ( i = 0; i <= 7; i++ ) + { + temp = tp + xlog[i]; + if ( BETW( temp, vpwymi, vpwyma ) ) + plytik( vppxma, plP_wcpcy( temp ), i2y, i1y ); + } } - } - else - { - for ( i = 1; i <= nysub1 - 1; i++ ) + else { - temp = tp + i * ytick1 / nysub1; - if ( BETW( temp, vpwymi, vpwyma ) ) - plytik( vppxma, plP_wcpcy( temp ), i2y, i1y ); + for ( i = 1; i <= nysub1 - 1; i++ ) + { + temp = tp + i * ytick1 / nysub1; + if ( BETW( temp, vpwymi, vpwyma ) ) + plytik( vppxma, plP_wcpcy( temp ), i2y, i1y ); + } } } + if ( !BETW( tn, vpwymi, vpwyma ) ) + break; + plytik( vppxma, plP_wcpcy( tn ), i4y, i3y ); + tp = tn; } - if ( !BETW( tn, vpwymi, vpwyma ) ) - break; - plytik( vppxma, plP_wcpcy( tn ), i4y, i3y ); - tp = tn; } } - } // Draw the top frame of the box - if ( lcx || lwx ) - { - if ( !lwx ) + if ( lcx || lwx ) { - plP_movphy( vppxma, vppyma ); - plP_draphy( vppxmi, vppyma ); - } - if ( ltx && !lxx ) - { - if ( ldx ) + if ( !lwx ) { - pldtfac( vpwxmi, vpwxma, &factor, &tstart ); - tp = xtick1 * ( floor( ( vpwxma - tstart ) / xtick1 ) + 1 ) + tstart; + plP_movphy( vppxma, vppyma ); + plP_draphy( vppxmi, vppyma ); } - else - tp = xtick1 * ( floor( vpwxma / xtick1 ) + 1 ); - for (;; ) + if ( ltx && !lxx ) { - tn = tp - xtick1; - if ( lsx ) + if ( ldx ) { - if ( llx ) + pldtfac( vpwxmi, vpwxma, &factor, &tstart ); + tp = xtick1 * ( floor( ( vpwxma - tstart ) / xtick1 ) + 1 ) + tstart; + } + else + tp = xtick1 * ( floor( vpwxma / xtick1 ) + 1 ); + for (;; ) + { + tn = tp - xtick1; + if ( lsx ) { - for ( i = 7; i >= 0; i-- ) + if ( llx ) { - temp = tn + xlog[i]; - if ( BETW( temp, vpwxmi, vpwxma ) ) - plxtik( plP_wcpcx( temp ), vppyma, i2x, i1x ); + for ( i = 7; i >= 0; i-- ) + { + temp = tn + xlog[i]; + if ( BETW( temp, vpwxmi, vpwxma ) ) + plxtik( plP_wcpcx( temp ), vppyma, i2x, i1x ); + } } - } - else - { - for ( i = nxsub1 - 1; i >= 1; i-- ) + else { - temp = tn + i * xtick1 / nxsub1; - if ( BETW( temp, vpwxmi, vpwxma ) ) - plxtik( plP_wcpcx( temp ), vppyma, i2x, i1x ); + for ( i = nxsub1 - 1; i >= 1; i-- ) + { + temp = tn + i * xtick1 / nxsub1; + if ( BETW( temp, vpwxmi, vpwxma ) ) + plxtik( plP_wcpcx( temp ), vppyma, i2x, i1x ); + } } } + if ( !BETW( tn, vpwxmi, vpwxma ) ) + break; + plxtik( plP_wcpcx( tn ), vppyma, i4x, i3x ); + tp = tn; } - if ( !BETW( tn, vpwxmi, vpwxma ) ) - break; - plxtik( plP_wcpcx( tn ), vppyma, i4x, i3x ); - tp = tn; } } - } -// Draw left-hand frame of box +// Draw the left-hand frame of box - if ( lby || luy ) - { - if ( !luy ) + if ( lby || luy ) { - plP_movphy( vppxmi, vppyma ); - plP_draphy( vppxmi, vppymi ); - } - if ( lty && !lxy ) - { - if ( ldy ) + if ( !luy ) { - pldtfac( vpwymi, vpwyma, &factor, &tstart ); - tp = ytick1 * ( floor( ( vpwymi - tstart ) / ytick1 ) + 1 ) + tstart; + plP_movphy( vppxmi, vppyma ); + plP_draphy( vppxmi, vppymi ); } - else - tp = ytick1 * ( floor( vpwyma / ytick1 ) + 1 ); - for (;; ) + if ( lty && !lxy ) { - tn = tp - ytick1; - if ( lsy ) + if ( ldy ) { - if ( lly ) + pldtfac( vpwymi, vpwyma, &factor, &tstart ); + tp = ytick1 * ( floor( ( vpwymi - tstart ) / ytick1 ) + 1 ) + tstart; + } + else + tp = ytick1 * ( floor( vpwyma / ytick1 ) + 1 ); + for (;; ) + { + tn = tp - ytick1; + if ( lsy ) { - for ( i = 7; i >= 0; i-- ) + if ( lly ) { - temp = tn + xlog[i]; - if ( BETW( temp, vpwymi, vpwyma ) ) - plytik( vppxmi, plP_wcpcy( temp ), i1y, i2y ); + for ( i = 7; i >= 0; i-- ) + { + temp = tn + xlog[i]; + if ( BETW( temp, vpwymi, vpwyma ) ) + plytik( vppxmi, plP_wcpcy( temp ), i1y, i2y ); + } } - } - else - { - for ( i = nysub1 - 1; i >= 1; i-- ) + else { - temp = tn + i * ytick1 / nysub1; - if ( BETW( temp, vpwymi, vpwyma ) ) - plytik( vppxmi, plP_wcpcy( temp ), i1y, i2y ); + for ( i = nysub1 - 1; i >= 1; i-- ) + { + temp = tn + i * ytick1 / nysub1; + if ( BETW( temp, vpwymi, vpwyma ) ) + plytik( vppxmi, plP_wcpcy( temp ), i1y, i2y ); + } } } + if ( !BETW( tn, vpwymi, vpwyma ) ) + break; + plytik( vppxmi, plP_wcpcy( tn ), i3y, i4y ); + tp = tn; } - if ( !BETW( tn, vpwymi, vpwyma ) ) - break; - plytik( vppxmi, plP_wcpcy( tn ), i3y, i4y ); - tp = tn; } } - } -// Draw the horizontal axis - - if ( lax ) - { - plP_movphy( vppxmi, (PLINT) yp0 ); - plP_draphy( vppxma, (PLINT) yp0 ); - if ( ltx && !lxx ) + // Draw the horizontal axis. + if ( lax ) { - tp = xtick1 * floor( vpwxmi / xtick1 ); - for (;; ) + plP_movphy( vppxmi, (PLINT) yp0 ); + plP_draphy( vppxma, (PLINT) yp0 ); + if ( ltx && !lxx ) { - tn = tp + xtick1; - if ( lsx ) + tp = xtick1 * floor( vpwxmi / xtick1 ); + for (;; ) { - if ( llx ) + tn = tp + xtick1; + if ( lsx ) { - for ( i = 0; i <= 7; i++ ) + if ( llx ) { - temp = tp + xlog[i]; - if ( BETW( temp, vpwxmi, vpwxma ) ) - plxtik( plP_wcpcx( temp ), (PLINT) yp0, xminor, xminor ); + for ( i = 0; i <= 7; i++ ) + { + temp = tp + xlog[i]; + if ( BETW( temp, vpwxmi, vpwxma ) ) + plxtik( plP_wcpcx( temp ), (PLINT) yp0, xminor, xminor ); + } } - } - else - { - for ( i = 1; i <= nxsub1 - 1; i++ ) + else { - temp = tp + i * xtick1 / nxsub1; - if ( BETW( temp, vpwxmi, vpwxma ) ) - plxtik( plP_wcpcx( temp ), (PLINT) yp0, xminor, xminor ); + for ( i = 1; i <= nxsub1 - 1; i++ ) + { + temp = tp + i * xtick1 / nxsub1; + if ( BETW( temp, vpwxmi, vpwxma ) ) + plxtik( plP_wcpcx( temp ), (PLINT) yp0, xminor, xminor ); + } } } + if ( !BETW( tn, vpwxmi, vpwxma ) ) + break; + plxtik( plP_wcpcx( tn ), (PLINT) yp0, xmajor, xmajor ); + tp = tn; } - if ( !BETW( tn, vpwxmi, vpwxma ) ) - break; - plxtik( plP_wcpcx( tn ), (PLINT) yp0, xmajor, xmajor ); - tp = tn; } } - } -// Draw the vertical axis - - if ( lay ) - { - plP_movphy( (PLINT) xp0, vppymi ); - plP_draphy( (PLINT) xp0, vppyma ); - if ( lty && !lxy ) + // Draw the vertical axis. + if ( lay ) { - tp = ytick1 * floor( vpwymi / ytick1 ); - for (;; ) + plP_movphy( (PLINT) xp0, vppymi ); + plP_draphy( (PLINT) xp0, vppyma ); + if ( lty && !lxy ) { - tn = tp + ytick1; - if ( lsy ) + tp = ytick1 * floor( vpwymi / ytick1 ); + for (;; ) { - if ( lly ) + tn = tp + ytick1; + if ( lsy ) { - for ( i = 0; i <= 7; i++ ) + if ( lly ) { - temp = tp + xlog[i]; - if ( BETW( temp, vpwymi, vpwyma ) ) - plytik( (PLINT) xp0, plP_wcpcy( temp ), yminor, yminor ); + for ( i = 0; i <= 7; i++ ) + { + temp = tp + xlog[i]; + if ( BETW( temp, vpwymi, vpwyma ) ) + plytik( (PLINT) xp0, plP_wcpcy( temp ), yminor, yminor ); + } } - } - else - { - for ( i = 1; i <= nysub1 - 1; i++ ) + else { - temp = tp + i * ytick1 / nysub1; - if ( BETW( temp, vpwymi, vpwyma ) ) - plytik( (PLINT) xp0, plP_wcpcy( temp ), yminor, yminor ); + for ( i = 1; i <= nysub1 - 1; i++ ) + { + temp = tp + i * ytick1 / nysub1; + if ( BETW( temp, vpwymi, vpwyma ) ) + plytik( (PLINT) xp0, plP_wcpcy( temp ), yminor, yminor ); + } } } + if ( !BETW( tn, vpwymi, vpwyma ) ) + break; + plytik( (PLINT) xp0, plP_wcpcy( tn ), ymajor, ymajor ); + tp = tn; } - if ( !BETW( tn, vpwymi, vpwyma ) ) - break; - plytik( (PLINT) xp0, plP_wcpcy( tn ), ymajor, ymajor ); - tp = tn; } } + + // Draw grids. + grid_box( xopt, xtick1, nxsub1, yopt, ytick1, nysub1 ); } -// Draw grids - - grid_box( xopt, xtick1, nxsub1, yopt, ytick1, nysub1 ); - -// Write labels - + // Write labels. label_box( xopt, xtick1, yopt, ytick1 ); // Restore the clip limits to viewport edge @@ -1368,7 +1394,7 @@ lxy = plP_stsearch( yopt, 'x' ); plP_xgvpw( &vpwxmin, &vpwxmax, &vpwymin, &vpwymax ); -// n.b. large change; vpwxmi always numerically less than vpwxma, and +// vpwxmi always numerically less than vpwxma, and // similarly for vpwymi vpwxmi = ( vpwxmax > vpwxmin ) ? vpwxmin : vpwxmax; vpwxma = ( vpwxmax > vpwxmin ) ? vpwxmax : vpwxmin; @@ -1376,160 +1402,165 @@ vpwyma = ( vpwymax > vpwymin ) ? vpwymax : vpwymin; // Write horizontal label(s) - - if ( ( lmx || lnx ) && ( ltx || lxx ) ) + if ( plsc->if_boxbb ) { - PLINT xmode, xprec, xdigmax, xdigits, xscale; + } + else + { + if ( ( lmx || lnx ) && ( ltx || lxx ) ) + { + PLINT xmode, xprec, xdigmax, xdigits, xscale; - plgxax( &xdigmax, &xdigits ); - pldprec( vpwxmi, vpwxma, xtick1, lfx, &xmode, &xprec, xdigmax, &xscale ); - timefmt = plP_gtimefmt(); + plgxax( &xdigmax, &xdigits ); + pldprec( vpwxmi, vpwxma, xtick1, lfx, &xmode, &xprec, xdigmax, &xscale ); + timefmt = plP_gtimefmt(); - if ( ldx ) - { - pldtfac( vpwxmi, vpwxma, &factor, &tstart ); - tp = xtick1 * ( 1. + floor( ( vpwxmi - tstart ) / xtick1 ) ) + tstart; - } - else - tp = xtick1 * ( 1. + floor( vpwxmi / xtick1 ) ); - for ( tn = tp; BETW( tn, vpwxmi, vpwxma ); tn += xtick1 ) - { if ( ldx ) { - strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig ); + pldtfac( vpwxmi, vpwxma, &factor, &tstart ); + tp = xtick1 * ( 1. + floor( ( vpwxmi - tstart ) / xtick1 ) ) + tstart; } else + tp = xtick1 * ( 1. + floor( vpwxmi / xtick1 ) ); + for ( tn = tp; BETW( tn, vpwxmi, vpwxma ); tn += xtick1 ) { - plform( PL_X_AXIS, tn, xscale, xprec, string, STRING_LEN, llx, lfx, lox ); + if ( ldx ) + { + strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig ); + } + else + { + plform( PL_X_AXIS, tn, xscale, xprec, string, STRING_LEN, llx, lfx, lox ); + } + height = lix ? 1.75 : 1.5; + pos = ( vpwxmax > vpwxmin ) ? + ( tn - vpwxmi ) / ( vpwxma - vpwxmi ) : + ( vpwxma - tn ) / ( vpwxma - vpwxmi ); + if ( lnx ) + plmtex( "b", height, pos, 0.5, string ); + if ( lmx ) + plmtex( "t", height, pos, 0.5, string ); } - height = lix ? 1.75 : 1.5; - pos = ( vpwxmax > vpwxmin ) ? - ( tn - vpwxmi ) / ( vpwxma - vpwxmi ) : - ( vpwxma - tn ) / ( vpwxma - vpwxmi ); - if ( lnx ) - plmtex( "b", height, pos, 0.5, string ); - if ( lmx ) - plmtex( "t", height, pos, 0.5, string ); - } - xdigits = 2; - plsxax( xdigmax, xdigits ); + xdigits = 2; + plsxax( xdigmax, xdigits ); - // Write separate exponential label if mode = 1. + // Write separate exponential label if mode = 1. - if ( !llx && !ldx && !lox && xmode ) - { - // Assume label data is for placement of exponents if no custom - // label function is provided. - if ( plsc->label_data ) + if ( !llx && !ldx && !lox && xmode ) { - height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; - pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; - just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just; + // Assume label data is for placement of exponents if no custom + // label function is provided. + if ( plsc->label_data ) + { + height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; + pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; + just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just; + } + else + { + height = 3.2; + pos = 1.0; + just = 0.5; + } + snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) xscale ); + if ( lnx ) + plmtex( "b", height, pos, just, string ); + if ( lmx ) + plmtex( "t", height, pos, just, string ); } - else - { - height = 3.2; - pos = 1.0; - just = 0.5; - } - snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) xscale ); - if ( lnx ) - plmtex( "b", height, pos, just, string ); - if ( lmx ) - plmtex( "t", height, pos, just, string ); } - } // Write vertical label(s) - if ( ( lmy || lny ) && ( lty || lxy ) ) - { - PLINT ymode, yprec, ydigmax, ydigits, yscale; + if ( ( lmy || lny ) && ( lty || lxy ) ) + { + PLINT ymode, yprec, ydigmax, ydigits, yscale; - plgyax( &ydigmax, &ydigits ); - pldprec( vpwymi, vpwyma, ytick1, lfy, &ymode, &yprec, ydigmax, &yscale ); + plgyax( &ydigmax, &ydigits ); + pldprec( vpwymi, vpwyma, ytick1, lfy, &ymode, &yprec, ydigmax, &yscale ); - ydigits = 0; - if ( ldy ) - { - pldtfac( vpwymi, vpwyma, &factor, &tstart ); - tp = ytick1 * ( 1. + floor( ( vpwymi - tstart ) / ytick1 ) ) + tstart; - } - else - tp = ytick1 * ( 1. + floor( vpwymi / ytick1 ) ); - for ( tn = tp; BETW( tn, vpwymi, vpwyma ); tn += ytick1 ) - { + ydigits = 0; if ( ldy ) { - strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig ); + pldtfac( vpwymi, vpwyma, &factor, &tstart ); + tp = ytick1 * ( 1. + floor( ( vpwymi - tstart ) / ytick1 ) ) + tstart; } else + tp = ytick1 * ( 1. + floor( vpwymi / ytick1 ) ); + for ( tn = tp; BETW( tn, vpwymi, vpwyma ); tn += ytick1 ) { - plform( PL_Y_AXIS, tn, yscale, yprec, string, STRING_LEN, lly, lfy, loy ); - } - pos = ( vpwymax > vpwymin ) ? - ( tn - vpwymi ) / ( vpwyma - vpwymi ) : - ( vpwyma - tn ) / ( vpwyma - vpwymi ); - if ( lny ) - { - if ( lvy ) + if ( ldy ) { - height = liy ? 1.0 : 0.5; - plmtex( "lv", height, pos, 1.0, string ); + strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig ); } else { - height = liy ? 1.75 : 1.5; - plmtex( "l", height, pos, 0.5, string ); + plform( PL_Y_AXIS, tn, yscale, yprec, string, STRING_LEN, lly, lfy, loy ); } - } - if ( lmy ) - { - if ( lvy ) + pos = ( vpwymax > vpwymin ) ? + ( tn - vpwymi ) / ( vpwyma - vpwymi ) : + ( vpwyma - tn ) / ( vpwyma - vpwymi ); + if ( lny ) { - height = liy ? 1.0 : 0.5; - plmtex( "rv", height, pos, 0.0, string ); + if ( lvy ) + { + height = liy ? 1.0 : 0.5; + plmtex( "lv", height, pos, 1.0, string ); + } + else + { + height = liy ? 1.75 : 1.5; + plmtex( "l", height, pos, 0.5, string ); + } } - else + if ( lmy ) { - height = liy ? 1.75 : 1.5; - plmtex( "r", height, pos, 0.5, string ); + if ( lvy ) + { + height = liy ? 1.0 : 0.5; + plmtex( "rv", height, pos, 0.0, string ); + } + else + { + height = liy ? 1.75 : 1.5; + plmtex( "r", height, pos, 0.5, string ); + } } + ydigits = MAX( ydigits, (PLINT) strlen( string ) ); } - ydigits = MAX( ydigits, (PLINT) strlen( string ) ); - } - if ( !lvy ) - ydigits = 2; + if ( !lvy ) + ydigits = 2; - plsyax( ydigmax, ydigits ); + plsyax( ydigmax, ydigits ); - // Write separate exponential label if mode = 1. + // Write separate exponential label if mode = 1. - if ( !lly && !ldy && !loy && ymode ) - { - snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale ); - if ( plsc->label_data ) + if ( !lly && !ldy && !loy && ymode ) { - height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; - pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; - just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just; - } - else - { - offset = 0.02; - height = 2.0; - if ( lny ) + snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale ); + if ( plsc->label_data ) { - pos = 0.0 - offset; - just = 1.0; + height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; + pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; + just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just; } - if ( lmy ) + else { - pos = 1.0 + offset; - just = 0.0; + offset = 0.02; + height = 2.0; + if ( lny ) + { + pos = 0.0 - offset; + just = 1.0; + } + if ( lmy ) + { + pos = 1.0 + offset; + just = 0.0; + } } + plmtex( "t", height, pos, just, string ); } - plmtex( "t", height, pos, just, string ); } } } @@ -1602,195 +1633,223 @@ vpwymi = ( vpwymax > vpwymin ) ? vpwymin : vpwymax; vpwyma = ( vpwymax > vpwymin ) ? vpwymax : vpwymin; + if ( plsc->if_boxbb ) + { + PLINT xmajor = MAX( ROUND( plsc->majht * plsc->ypmm ), 1 ); + PLINT ymajor = MAX( ROUND( plsc->majht * plsc->xpmm ), 1 ); + // Bounding-box limits for the box in mm before corrections + // for decorations are applied. + plsc->boxbb_xmin = plsc->vppxmi / plsc->xpmm; + plsc->boxbb_xmax = plsc->vppxma / plsc->xpmm; + plsc->boxbb_ymin = plsc->vppymi / plsc->ypmm; + plsc->boxbb_ymax = plsc->vppyma / plsc->ypmm; + // Carefully follow logic below for the case where + // an inverted major tick mark is written (in the X direction + // for a Y axis and vice versa). Ignore minor tick marks + // which are assumed to be smaller. + if ( lix && ( lmx || lnx ) && ( ltx && !lxx ) ) + { + plsc->boxbb_ymin -= xmajor / plsc->ypmm; + plsc->boxbb_ymax += xmajor / plsc->ypmm; + } + if ( liy && ( lmy || lny ) && ( lty && !lxy ) ) + { + plsc->boxbb_xmin -= ymajor / plsc->xpmm; + plsc->boxbb_xmax += ymajor / plsc->xpmm; + } + } + else + { // Write horizontal label(s) - if ( ( lmx || lnx ) && ( ltx || lxx ) ) - { - PLINT xmode, xprec, xscale; - PLFLT x_spacing, x_spacing_tmp; + if ( ( lmx || lnx ) && ( ltx || lxx ) ) + { + PLINT xmode, xprec, xscale; + PLFLT x_spacing, x_spacing_tmp; - // Determine spacing between ticks - // Use the x-size of the window - x_spacing = vpwxma - vpwxmi; - if ( n_xticks > 1 ) - { - // Use the smallest space between ticks - for ( i = 1; i < n_xticks; i++ ) + // Determine spacing between ticks + // Use the x-size of the window + x_spacing = vpwxma - vpwxmi; + if ( n_xticks > 1 ) { - x_spacing_tmp = fabs( xticks[i] - xticks[i - 1] ); - x_spacing = MIN( x_spacing, x_spacing_tmp ); + // Use the smallest space between ticks + for ( i = 1; i < n_xticks; i++ ) + { + x_spacing_tmp = fabs( xticks[i] - xticks[i - 1] ); + x_spacing = MIN( x_spacing, x_spacing_tmp ); + } } - } - plgxax( &xdigmax, &xdigits ); - pldprec( vpwxmi, vpwxma, x_spacing, lfx, &xmode, &xprec, xdigmax, &xscale ); - timefmt = plP_gtimefmt(); + plgxax( &xdigmax, &xdigits ); + pldprec( vpwxmi, vpwxma, x_spacing, lfx, &xmode, &xprec, xdigmax, &xscale ); + timefmt = plP_gtimefmt(); - // Loop through all of the tick marks - for ( i = 0; i < n_xticks; i++ ) - { - tn = xticks[i]; - if ( BETW( tn, vpwxmi, vpwxma ) ) + // Loop through all of the tick marks + for ( i = 0; i < n_xticks; i++ ) { - if ( ldx ) + tn = xticks[i]; + if ( BETW( tn, vpwxmi, vpwxma ) ) { - strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig ); + if ( !lxx ) + { + plwxtik( tn, vpwymin, FALSE, !lix ); + plwxtik( tn, vpwymax, FALSE, lix ); + } + if ( ldx ) + { + strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig ); + } + else + { + plform( PL_X_AXIS, tn, xscale, xprec, string, STRING_LEN, llx, lfx, lox ); + } + height = lix ? 1.75 : 1.5; + pos = ( vpwxmax > vpwxmin ) ? + ( tn - vpwxmi ) / ( vpwxma - vpwxmi ) : + ( vpwxma - tn ) / ( vpwxma - vpwxmi ); + if ( lnx ) + plmtex( "b", height, pos, 0.5, string ); + if ( lmx ) + plmtex( "t", height, pos, 0.5, string ); } + } + xdigits = 2; + plsxax( xdigmax, xdigits ); + + // Write separate exponential label if mode = 1. + + if ( !llx && !ldx && !lox && xmode ) + { + // Assume label data is for placement of exponents if no custom + // label function is provided. + if ( plsc->label_data ) + { + height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; + pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; + just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just; + } else { - plform( PL_X_AXIS, tn, xscale, xprec, string, STRING_LEN, llx, lfx, lox ); + height = 3.2; + pos = 1.0; + just = 0.5; } - height = lix ? 1.75 : 1.5; - pos = ( vpwxmax > vpwxmin ) ? - ( tn - vpwxmi ) / ( vpwxma - vpwxmi ) : - ( vpwxma - tn ) / ( vpwxma - vpwxmi ); + snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) xscale ); if ( lnx ) - plmtex( "b", height, pos, 0.5, string ); + plmtex( "b", height, pos, just, string ); if ( lmx ) - plmtex( "t", height, pos, 0.5, string ); - if ( !lxx ) - { - plwxtik( tn, vpwymin, FALSE, !lix ); - plwxtik( tn, vpwymax, FALSE, lix ); - } + plmtex( "t", height, pos, just, string ); } } - xdigits = 2; - plsxax( xdigmax, xdigits ); - // Write separate exponential label if mode = 1. +// Write vertical label(s) - if ( !llx && !ldx && !lox && xmode ) + if ( ( lmy || lny ) && ( lty || lxy ) ) { - // Assume label data is for placement of exponents if no custom - // label function is provided. - if ( plsc->label_data ) - { - height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; - pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; - just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just; - } - else - { - height = 3.2; - pos = 1.0; - just = 0.5; - } - snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) xscale ); - if ( lnx ) - plmtex( "b", height, pos, just, string ); - if ( lmx ) - plmtex( "t", height, pos, just, string ); - } - } + PLINT ymode, yprec, yscale; + PLFLT y_spacing, y_spacing_tmp; -// Write vertical label(s) - - if ( ( lmy || lny ) && ( lty || lxy ) ) - { - PLINT ymode, yprec, yscale; - PLFLT y_spacing, y_spacing_tmp; - - // Determine spacing between ticks - // Use the y-size of the window - y_spacing = vpwyma - vpwymi; - if ( n_yticks > 1 ) - { - // Use the smallest space between ticks - for ( i = 1; i < n_yticks; i++ ) + // Determine spacing between ticks + // Use the y-size of the window + y_spacing = vpwyma - vpwymi; + if ( n_yticks > 1 ) { - y_spacing_tmp = fabs( yticks[i] - yticks[i - 1] ); - y_spacing = MIN( y_spacing, y_spacing_tmp ); + // Use the smallest space between ticks + for ( i = 1; i < n_yticks; i++ ) + { + y_spacing_tmp = fabs( yticks[i] - yticks[i - 1] ); + y_spacing = MIN( y_spacing, y_spacing_tmp ); + } } - } - plgyax( &ydigmax, &ydigits ); - pldprec( vpwymi, vpwyma, y_spacing, lfy, &ymode, &yprec, ydigmax, &yscale ); - timefmt = plP_gtimefmt(); + plgyax( &ydigmax, &ydigits ); + pldprec( vpwymi, vpwyma, y_spacing, lfy, &ymode, &yprec, ydigmax, &yscale ); + timefmt = plP_gtimefmt(); - ydigits = 0; - for ( i = 0; i < n_yticks; i++ ) - { - tn = yticks[i]; - if ( BETW( tn, vpwymi, vpwyma ) ) + ydigits = 0; + for ( i = 0; i < n_yticks; i++ ) { - if ( ldy ) + tn = yticks[i]; + if ( BETW( tn, vpwymi, vpwyma ) ) { - strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig ); - } - else - { - plform( PL_Y_AXIS, tn, yscale, yprec, string, STRING_LEN, lly, lfy, loy ); - } - pos = ( vpwymax > vpwymin ) ? - ( tn - vpwymi ) / ( vpwyma - vpwymi ) : - ( vpwyma - tn ) / ( vpwyma - vpwymi ); - if ( lny ) - { - if ( lvy ) + if ( !lxy ) { - height = liy ? 1.0 : 0.5; - plmtex( "lv", height, pos, 1.0, string ); + plwytik( vpwxmin, tn, FALSE, !liy ); + plwytik( vpwxmax, tn, FALSE, liy ); } + if ( ldy ) + { + strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig ); + } else { - height = liy ? 1.75 : 1.5; - plmtex( "l", height, pos, 0.5, string ); + plform( PL_Y_AXIS, tn, yscale, yprec, string, STRING_LEN, lly, lfy, loy ); } - } - if ( lmy ) - { - if ( lvy ) + pos = ( vpwymax > vpwymin ) ? + ( tn - vpwymi ) / ( vpwyma - vpwymi ) : + ( vpwyma - tn ) / ( vpwyma - vpwymi ); + if ( lny ) { - height = liy ? 1.0 : 0.5; - plmtex( "rv", height, pos, 0.0, string ); + if ( lvy ) + { + height = liy ? 1.0 : 0.5; + plmtex( "lv", height, pos, 1.0, string ); + } + else + { + height = liy ? 1.75 : 1.5; + plmtex( "l", height, pos, 0.5, string ); + } } - else + if ( lmy ) { - height = liy ? 1.75 : 1.5; - plmtex( "r", height, pos, 0.5, string ); + if ( lvy ) + { + height = liy ? 1.0 : 0.5; + plmtex( "rv", height, pos, 0.0, string ); + } + else + { + height = liy ? 1.75 : 1.5; + plmtex( "r", height, pos, 0.5, string ); + } } + ydigits = MAX( ydigits, (PLINT) strlen( string ) ); } - ydigits = MAX( ydigits, (PLINT) strlen( string ) ); - if ( !lxy ) - { - plwytik( vpwxmin, tn, FALSE, !liy ); - plwytik( vpwxmax, tn, FALSE, liy ); - } } - } - if ( !lvy ) - ydigits = 2; + if ( !lvy ) + ydigits = 2; - plsyax( ydigmax, ydigits ); + plsyax( ydigmax, ydigits ); - // Write separate exponential label if mode = 1. + // Write separate exponential label if mode = 1. - if ( !lly && !ldy && !loy && ymode ) - { - snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale ); - if ( plsc->label_data ) + if ( !lly && !ldy && !loy && ymode ) { - height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; - pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; - just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just; - } - else - { - offset = 0.02; - height = 2.0; - if ( lny ) + snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale ); + if ( plsc->label_data ) { - pos = 0.0 - offset; - just = 1.0; + height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp; + pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos; + just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just; } - if ( lmy ) + else { - pos = 1.0 + offset; - just = 0.0; + offset = 0.02; + height = 2.0; + if ( lny ) + { + pos = 0.0 - offset; + just = 1.0; + } + if ( lmy ) + { + pos = 1.0 + offset; + just = 0.0; + } } + plmtex( "t", height, pos, just, string ); } - plmtex( "t", height, pos, just, string ); } } Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-06-20 18:03:03 UTC (rev 11773) +++ trunk/src/pllegend.c 2011-06-20 22:09:33 UTC (rev 11774) @@ -1012,6 +1012,64 @@ plline( 3, xs, ys ); } +static void +draw_box( PLBOOL if_bb, PLINT opt, const char *axis_opts, PLBOOL if_edge, + PLFLT ticks, PLINT sub_ticks, PLINT n_values, const PLFLT *values ) +{ + // axis option strings. + const char *edge_string; + size_t length_axis_opts = strlen( axis_opts ); + char *local_axis_opts; + + // local_axis_opts is local version that can be modified from + // const input version. + if ( ( local_axis_opts = (char *) malloc( ( length_axis_opts + 1 ) * sizeof ( char ) ) ) == NULL ) + { + plexit( "draw_box: Insufficient memory" ); + } + strcpy( local_axis_opts, axis_opts ); + + plsc->if_boxbb = if_bb; + // Draw numerical labels and tick marks if this is a shade color bar + // TODO: A better way to handle this would be to update the + // internals of plbox to support custom tick and label positions + // along an axis. + + if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) + { + if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) + label_box_custom( local_axis_opts, n_values, values, "", 0, NULL ); + else + label_box_custom( "", 0, NULL, local_axis_opts, n_values, values ); + if ( if_bb ) + { + plsc->if_boxbb = FALSE; + return; + } + // Exclude ticks for plbox call below since those tick marks and + // associated labels have already been handled in a custom way above. + remove_characters( local_axis_opts, "TtXx" ); + } + + // Draw the outline for the entire colorbar, tick marks, tick labels. + + if ( if_edge ) + edge_string = "bc"; + else + edge_string = "uw"; + if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) + { + plbox( edge_string, 0.0, 0, local_axis_opts, ticks, sub_ticks ); + } + else + { + plbox( local_axis_opts, ticks, sub_ticks, edge_string, 0.0, 0 ); + } + plsc->if_boxbb = FALSE; + + free( local_axis_opts ); +} + //-------------------------------------------------------------------------- //! Plot color bar for image, shade or gradient plots. //! @@ -1183,19 +1241,19 @@ PLFLT label_offset = 0.; // For building plmtex option string. - PLINT max_opts = 25; - char opt_string[max_opts]; - char perp; + PLINT max_opts = 25; + char opt_string[max_opts]; + char perp; - // axis option strings. - const char *edge_string; - size_t length_axis_opts = strlen( axis_opts ); - char *local_axis_opts; - PLBOOL if_edge; + PLBOOL if_edge; // Character height in x and y normalized subpage coordinates. PLFLT character_height_x, character_height_y; + // Ratio of normalized subpage coordinates to mm coordinates in + // x and y. + PLFLT ncxpmm, ncypmm; + // Default position flags and sanity checks for position flags. if ( !( position & PL_POSITION_RIGHT ) && !( position & PL_POSITION_LEFT ) && !( position & PL_POSITION_TOP ) && !( position & PL_POSITION_BOTTOM ) ) { @@ -1267,19 +1325,11 @@ opt = opt | PL_COLORBAR_ORIENT_RIGHT; } - // local_axis_opts is local version that can be modified from - // const input version. - if ( ( local_axis_opts = (char *) malloc( ( length_axis_opts + 1 ) * sizeof ( char ) ) ) == NULL ) - { - plexit( "plcolorbar: Insufficient memory" ); - } - strcpy( local_axis_opts, axis_opts ); + if_edge = plP_stsearch( axis_opts, 'b' ) && + !plP_stsearch( axis_opts, 'u' ) && + plP_stsearch( axis_opts, 'c' ) && + !plP_stsearch( axis_opts, 'w' ); - if_edge = plP_stsearch( local_axis_opts, 'b' ) && - !plP_stsearch( local_axis_opts, 'u' ) && - plP_stsearch( local_axis_opts, 'c' ) && - !plP_stsearch( local_axis_opts, 'w' ); - min_value = values[0]; max_value = values[ n_values - 1 ]; @@ -1288,14 +1338,12 @@ // Width and height of the undecorated colorbar in normalized // subpage coordinates. - colorbar_width = adopted_to_subpage_x( x_length ) - - adopted_to_subpage_x( 0. ); + colorbar_width = adopted_to_subpage_x( x_length ) - + adopted_to_subpage_x( 0. ); colorbar_height = adopted_to_subpage_y( y_length ) - adopted_to_subpage_y( 0. ); // width and height of colorbar bounding box in normalized subpage // coordinates. Caps taken care of. - // FIXME. Need to add inverted tickmarks + numerical tick labels + text to - // these calculations. if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) { cap_extent = cap_ratio * colorbar_height / aspspp; @@ -1305,27 +1353,77 @@ cap_extent = cap_ratio * colorbar_width * aspspp; } - colorbar_width_bb = colorbar_width; - colorbar_height_bb = colorbar_height; + // Specify the proper window ranges for colorbar depending on + // orientation. + if ( opt & PL_COLORBAR_ORIENT_RIGHT ) + { + wx_min = min_value; + wx_max = max_value; + wy_min = 0.0; + wy_max = 1.0; + } + else if ( opt & PL_COLORBAR_ORIENT_TOP ) + { + wx_min = 0.0; + wx_max = 1.0; + wy_min = min_value; + wy_max = max_value; + } + else if ( opt & PL_COLORBAR_ORIENT_LEFT ) + { + wx_min = max_value; + wx_max = min_value; + wy_min = 0.0; + wy_max = 1.0; + } + else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) + { + wx_min = 0.0; + wx_max = 1.0; + wy_min = max_value; + wy_max = min_value; + } + else + { + plabort( "plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" ); + } + // Viewport is correct size, but has an incorrect offset compared + // to the final result, but this should not affect the bounding + // box range or offsets calculated just below. + plvpor( 0., colorbar_width, 0., colorbar_height ); + plwind( wx_min, wx_max, wy_min, wy_max ); + + // Calculate the bounding box for decorated (i.e., including tick + // marks + numerical tick labels) box. + draw_box( TRUE, opt, axis_opts, if_edge, + ticks, sub_ticks, n_values, values ); + ncxpmm = plsc->xpmm / ( plsc->sppxma - plsc->sppxmi ); + ncypmm = plsc->ypmm / ( plsc->sppyma - plsc->sppymi ); + colorbar_width_bb = ( plsc->boxbb_xmax - plsc->boxbb_xmin ) * ncxpmm; + colorbar_height_bb = ( plsc->boxbb_ymax - plsc->boxbb_ymin ) * ncypmm; + // Offsets of upper left corner relative to plvpor coordinates of that + // point which are (0., colorbar_height), see above. + dx_subpage += -plsc->boxbb_xmin * ncxpmm; + dy_subpage -= plsc->boxbb_ymax * ncypmm - colorbar_height; if ( opt & PL_COLORBAR_CAP_LOW ) { if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { colorbar_width_bb += cap_extent; - dx_subpage += cap_extent; + dx_subpage += cap_extent; } - if (opt & PL_COLORBAR_ORIENT_TOP ) + if ( opt & PL_COLORBAR_ORIENT_TOP ) { colorbar_height_bb += cap_extent; } - if (opt & PL_COLORBAR_ORIENT_LEFT ) + if ( opt & PL_COLORBAR_ORIENT_LEFT ) { colorbar_width_bb += cap_extent; } - if (opt & PL_COLORBAR_ORIENT_BOTTOM ) + if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { colorbar_height_bb += cap_extent; - dy_subpage -= cap_extent; + dy_subpage -= cap_extent; } } if ( opt & PL_COLORBAR_CAP_HIGH ) @@ -1334,25 +1432,25 @@ { colorbar_width_bb += cap_extent; } - if (opt & PL_COLORBAR_ORIENT_TOP ) + if ( opt & PL_COLORBAR_ORIENT_TOP ) { colorbar_height_bb += cap_extent; - dy_subpage -= cap_extent; + dy_subpage -= cap_extent; } - if (opt & PL_COLORBAR_ORIENT_LEFT ) + if ( opt & PL_COLORBAR_ORIENT_LEFT ) { colorbar_width_bb += cap_extent; - dx_subpage += cap_extent; + dx_subpage += cap_extent; } - if (opt & PL_COLORBAR_ORIENT_BOTTOM ) + if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { colorbar_height_bb += cap_extent; } } // Total width and height of colorbar bounding box in adopted subpage // coordinates. - colorbar_width_vc = subpage_to_adopted_x( colorbar_width_bb ) - - subpage_to_adopted_x( 0. ); + colorbar_width_vc = subpage_to_adopted_x( colorbar_width_bb ) - + subpage_to_adopted_x( 0. ); colorbar_height_vc = subpage_to_adopted_y( colorbar_height_bb ) - subpage_to_adopted_y( 0. ); *p_colorbar_width = colorbar_width_vc; @@ -1368,17 +1466,14 @@ plot_x_subpage = plot_x_subpage_bb + dx_subpage; plot_y_subpage = plot_y_subpage_bb + dy_subpage; - // Specify the proper window ranges depending on orientation. + // Specify the proper viewport ranges for colorbar depending on + // orientation. if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { vx_min = plot_x_subpage; vx_max = plot_x_subpage + colorbar_width; vy_min = plot_y_subpage - colorbar_height; vy_max = plot_y_subpage; - wx_min = min_value; - wx_max = max_value; - wy_min = 0.0; - wy_max = 1.0; } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { @@ -1386,10 +1481,6 @@ vx_max = plot_x_subpage + colorbar_width; vy_min = plot_y_subpage - colorbar_height; vy_max = plot_y_subpage; - wx_min = 0.0; - wx_max = 1.0; - wy_min = min_value; - wy_max = max_value; } else if ( opt & PL_COLORBAR_ORIENT_LEFT ) { @@ -1397,10 +1488,6 @@ vx_max = plot_x_subpage + colorbar_width; vy_min = plot_y_subpage - colorbar_height; vy_max = plot_y_subpage; - wx_min = max_value; - wx_max = min_value; - wy_min = 0.0; - wy_max = 1.0; } else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { @@ -1408,10 +1495,6 @@ vx_max = plot_x_subpage + colorbar_width; vy_min = plot_y_subpage - colorbar_height; vy_max = plot_y_subpage; - wx_min = 0.0; - wx_max = 1.0; - wy_min = max_value; - wy_max = min_value; } else { @@ -1730,12 +1813,12 @@ if ( ( opt & PL_COLORBAR_ORIENT_RIGHT && opt & PL_COLORBAR_LABEL_LEFT ) || ( opt & PL_COLORBAR_ORIENT_LEFT && opt & PL_COLORBAR_LABEL_RIGHT ) ) { - label_offset += cap_extent/character_height_x; + label_offset += cap_extent / character_height_x; } if ( ( opt & PL_COLORBAR_ORIENT_TOP && opt & PL_COLORBAR_LABEL_BOTTOM ) || ( opt & PL_COLORBAR_ORIENT_BOTTOM && opt & PL_COLORBAR_LABEL_TOP ) ) { - label_offset += cap_extent/character_height_y; + label_offset += cap_extent / character_height_y; } // Draw a filled triangle (cap/arrow) at the low end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) @@ -1766,12 +1849,12 @@ if ( ( opt & PL_COLO... [truncated message content] |
From: <ai...@us...> - 2011-06-21 18:08:15
|
Revision: 11776 http://plplot.svn.sourceforge.net/plplot/?rev=11776&view=rev Author: airwin Date: 2011-06-21 18:08:09 +0000 (Tue, 21 Jun 2011) Log Message: ----------- Update bounding box to include both vertical and horizontal components of numerical labelling exponents for horizontal axes. Example 33 confirms this improvement is working properly. This completes the bounding box calculation for horizontal axes of plbox. ToDo: Need to implement similar functionality for vertical axes of plbox, horizontal and vertical axes of custom labels, and overall colorbar label. Modified Paths: -------------- trunk/examples/c/x33c.c trunk/src/plbox.c Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-06-21 16:43:35 UTC (rev 11775) +++ trunk/examples/c/x33c.c 2011-06-21 18:08:09 UTC (rev 11776) @@ -844,9 +844,9 @@ // Use unsaturated green background colour to contrast with black caps. plscolbg( 70, 185, 70 ); // Color bar examples - PLFLT values_small[2] = { 0.0, 1.0 }; - PLFLT values_uneven[9] = { 0.0, 2.0, 2.6, 3.4, 6.0, 7.0, 8.0, 9.0, 10.0 }; - PLFLT values_even[9] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + PLFLT values_small[2] = { 0.0e-200, 1.0e-200 }; + PLFLT values_uneven[9] = { 0.0e-200, 2.0e-200, 2.6e-200, 3.4e-200, 6.0e-200, 7.0e-200, 8.0e-200, 9.0e-200, 10.0e-200 }; + PLFLT values_even[9] = { 0.0e-200, 1.0e-200, 2.0e-200, 3.0e-200, 4.0e-200, 5.0e-200, 6.0e-200, 7.0e-200, 8.0e-200 }; // Cut out the greatest and smallest bits of the color spectrum to // leave colors for the end caps. Modified: trunk/src/plbox.c =================================================================== --- trunk/src/plbox.c 2011-06-21 16:43:35 UTC (rev 11775) +++ trunk/src/plbox.c 2011-06-21 18:08:09 UTC (rev 11776) @@ -1455,7 +1455,8 @@ if ( plsc->if_boxbb ) { string_length_mm = plstrl( string ); - pos_mm = ( plsc->vppxmi + pos * ( plsc->vppxma - plsc->vppxmi ) ) / + pos_mm = ( plsc->vppxmi + pos * + ( plsc->vppxma - plsc->vppxmi ) ) / plsc->xpmm; } if ( lnx ) @@ -1516,10 +1517,21 @@ // Bottom axis exponent. if ( plsc->if_boxbb ) { - // FIXME: Add Y bounding box calculations for - // exponent. - // FIXME: Add X bounding box calculations for - // exponent that slops over the end of the axis. + // Height of zero corresponds to character centred on edge + // so should add 0.5 to height to obtain bounding box edge + // in direction away from edge if no exponent. + // Add an additional offset to make exponent fit. + height_mm = ( height + 0.9 ) * char_height_mm; + plsc->boxbb_ymin = MIN( plsc->boxbb_ymin, plsc->vppymi / + plsc->ypmm - height_mm ); + string_length_mm = plstrl( string ); + pos_mm = ( plsc->vppxmi + pos * + ( plsc->vppxma - plsc->vppxmi ) ) / + plsc->xpmm; + plsc->boxbb_xmin = MIN( plsc->boxbb_xmin, + pos_mm - 0.5 * string_length_mm ); + plsc->boxbb_xmax = MAX( plsc->boxbb_xmax, + pos_mm + 0.5 * string_length_mm ); } else { @@ -1531,10 +1543,21 @@ // Top axis exponent. if ( plsc->if_boxbb ) { - // FIXME: Add Y bounding box calculations for - // exponent. - // FIXME: Add X bounding box calculations for - // exponent that slops over the end of the axis. + // Height of zero corresponds to character centred on edge + // so should add 0.5 to height to obtain bounding box edge + // in direction away from edge if no exponent. + // Add an additional offset to make exponent fit. + height_mm = ( height + 1.4 ) * char_height_mm; + plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma / + plsc->ypmm + height_mm ); + string_length_mm = plstrl( string ); + pos_mm = ( plsc->vppxmi + pos * + ( plsc->vppxma - plsc->vppxmi ) ) / + plsc->xpmm; + plsc->boxbb_xmin = MIN( plsc->boxbb_xmin, + pos_mm - 0.5 * string_length_mm ); + plsc->boxbb_xmax = MAX( plsc->boxbb_xmax, + pos_mm + 0.5 * string_length_mm ); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-07-03 17:06:24
|
Revision: 11783 http://plplot.svn.sourceforge.net/plplot/?rev=11783&view=rev Author: airwin Date: 2011-07-03 17:06:18 +0000 (Sun, 03 Jul 2011) Log Message: ----------- Implement a private plP_script_scale function that calculates scale values for font size and magnitude of the vertical offset associated with superscripts/subscripts. Currently, the font scale and offset calculations associated with superscripts and subscripts are done in an idiosyncratic (and often incorrect) way in various locations within the core code and drivers. plP_script_scale is designed to consolidate those bits of logic in one place where the calculation is done correctly. As a first use of this new logic, use plP_script_scale for the Hershey font superscripts/subscripts. plP_script_scale produces completely symmetrical vertical offsets between superscripts and subscripts. Therefore, this change corrects a very long-standing error (since before 1993) in the vertical offset of the Hershey subscripts which previously were not consistent with the magnitude of the vertical offsets of the superscripts. Modified Paths: -------------- trunk/include/plplotP.h trunk/src/plsym.c Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2011-07-01 06:27:21 UTC (rev 11782) +++ trunk/include/plplotP.h 2011-07-03 17:06:18 UTC (rev 11783) @@ -620,6 +620,14 @@ PLDLLIMPEXP void difilt_clip( PLINT *, PLINT * ); +// Calculate scale of font size and scale of magnitude of vertical +// offset associated with superscripts and subscripts. + +PLDLLIMPEXP void +plP_script_scale( PLBOOL ifupper, PLINT *level, + PLFLT *old_scale, PLFLT *scale, + PLFLT *old_offset, PLFLT *offset); + // Driver draws text void Modified: trunk/src/plsym.c =================================================================== --- trunk/src/plsym.c 2011-07-01 06:27:21 UTC (rev 11782) +++ trunk/src/plsym.c 2011-07-03 17:06:18 UTC (rev 11783) @@ -787,6 +787,7 @@ PLINT ch, i, length, level = 0, style, oline = 0, uline = 0; PLFLT width = 0., xorg = 0., yorg = 0., def, ht, dscale, scale; + PLFLT old_sscale, sscale, old_soffset, soffset; plgchr( &def, &ht ); dscale = 0.05 * ht; @@ -802,17 +803,19 @@ for ( i = 0; i < length; i++ ) { ch = symbol[i]; - if ( ch == -1 ) // super-script + if ( ch == -1 ) // superscript { - level++; - yorg += 16.0 * scale; - scale = dscale * pow( 0.75, (double) ABS( level ) ); + plP_script_scale( TRUE, &level, + &old_sscale, &sscale, &old_soffset, &soffset); + yorg = 16.0*dscale*soffset; + scale = dscale * sscale; } - else if ( ch == -2 ) // sub-script + else if ( ch == -2 ) // subscript { - level--; - scale = dscale * pow( 0.75, (double) ABS( level ) ); - yorg -= 16.0 * scale; + plP_script_scale( FALSE, &level, + &old_sscale, &sscale, &old_soffset, &soffset); + yorg = -16.0*dscale*soffset; + scale = dscale * sscale; } else if ( ch == -3 ) // back-char xorg -= width * scale; @@ -1229,6 +1232,74 @@ } //-------------------------------------------------------------------------- +//! Calculate scale of font size and scale of magnitude of vertical +//! offset associated with superscripts and subscripts. +//! Notes on arguments: ifupper must be either TRUE or FALSE on every +//! call to plP_script_scale. The contents of the location pointed to +//! by the level pointer must be zero on the first call to +//! plP_script_scale, but not modified externally from then on. The +//! contents of the locations pointed to by all other pointer +//! arguments are initialized internally, and should not be modified +//! externally. +//! +//! @param ifupper Value which is TRUE if superscripting, i.e., if +//! incrementing the previous level, and FALSE if subscripting, i.e., +//! decrementing the previous level. +//! @param level Pointer to a location which contains the value of the +//! superscript/subscript level. That value is 0, +-1, +-2, etc., for +//! no superscript/subscript, the first level of +//! superscript/subscript, the second level of superscript/subscript, +//! etc. Before the call the value is the old level, and after the +//! call the value will be incremented (ifupper TRUE) or decremented +//! (ifupper FALSE) from the previous value. +//! @param old_scale A pointer to a location that contains after the +//! call the old font size scale value. +//! @param scale A pointer to a location that contains after the call +//! the font size scale value. This value is 0.75^{|level|} where +//! |level| is the magnitude of the value of the superscript/subscript +//! level after the call. +//! @param old_offset A pointer to a location that contains after the +//! call the old value of the magnitude of the superscript/subscript +//! offset. +//! @param offset A pointer to a location that contains after the call +//! the value of the magnitude of the superscript/subscript offset +//! which is zero for |level|=0 and sum_{i=1}^{i=|level|} 0.75^{i-1}, +//! otherwise. + +void +plP_script_scale( PLBOOL ifupper, PLINT *level, + PLFLT *old_scale, PLFLT *scale, + PLFLT *old_offset, PLFLT *offset) +{ + if (*level == 0) + { + *old_scale = 1.; + *old_offset = 0.; + } + else + { + *old_scale = *scale; + *old_offset = *offset; + } + if((*level >=0 && ifupper) || (*level <=0 && !ifupper)) + { + // If superscript of subscript moves further away from centerline.... + *scale = 0.75 * *old_scale; + *offset = *old_offset + *old_scale; + } + else + { + // If superscript of subscript moves closer to centerline.... + *scale = *old_scale/0.75; + *offset = *old_offset - *scale; + } + if(ifupper) + (*level)++; + else + (*level)--; +} + +//-------------------------------------------------------------------------- // void c_plfont(ifont) // // Sets the global font flag to 'ifont'. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-07-04 19:54:25
|
Revision: 11785 http://plplot.svn.sourceforge.net/plplot/?rev=11785&view=rev Author: airwin Date: 2011-07-04 19:54:19 +0000 (Mon, 04 Jul 2011) Log Message: ----------- Style previous changes. Modified Paths: -------------- trunk/include/plplotP.h trunk/src/plsym.c Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2011-07-04 19:37:47 UTC (rev 11784) +++ trunk/include/plplotP.h 2011-07-04 19:54:19 UTC (rev 11785) @@ -625,9 +625,9 @@ PLDLLIMPEXP void plP_script_scale( PLBOOL ifupper, PLINT *level, - PLFLT *old_scale, PLFLT *scale, - PLFLT *old_offset, PLFLT *offset); - + PLFLT *old_scale, PLFLT *scale, + PLFLT *old_offset, PLFLT *offset ); + // Driver draws text void Modified: trunk/src/plsym.c =================================================================== --- trunk/src/plsym.c 2011-07-04 19:37:47 UTC (rev 11784) +++ trunk/src/plsym.c 2011-07-04 19:54:19 UTC (rev 11785) @@ -787,7 +787,7 @@ PLINT ch, i, length, level = 0, style, oline = 0, uline = 0; PLFLT width = 0., xorg = 0., yorg = 0., def, ht, dscale, scale; - PLFLT old_sscale, sscale, old_soffset, soffset; + PLFLT old_sscale, sscale, old_soffset, soffset; plgchr( &def, &ht ); dscale = 0.05 * ht; @@ -805,17 +805,17 @@ ch = symbol[i]; if ( ch == -1 ) // superscript { - plP_script_scale( TRUE, &level, - &old_sscale, &sscale, &old_soffset, &soffset); - yorg = 16.0*dscale*soffset; - scale = dscale * sscale; + plP_script_scale( TRUE, &level, + &old_sscale, &sscale, &old_soffset, &soffset ); + yorg = 16.0 * dscale * soffset; + scale = dscale * sscale; } else if ( ch == -2 ) // subscript { - plP_script_scale( FALSE, &level, - &old_sscale, &sscale, &old_soffset, &soffset); - yorg = -16.0*dscale*soffset; - scale = dscale * sscale; + plP_script_scale( FALSE, &level, + &old_sscale, &sscale, &old_soffset, &soffset ); + yorg = -16.0 * dscale * soffset; + scale = dscale * sscale; } else if ( ch == -3 ) // back-char xorg -= width * scale; @@ -1268,35 +1268,35 @@ void plP_script_scale( PLBOOL ifupper, PLINT *level, - PLFLT *old_scale, PLFLT *scale, - PLFLT *old_offset, PLFLT *offset) + PLFLT *old_scale, PLFLT *scale, + PLFLT *old_offset, PLFLT *offset ) { - if (*level == 0) - { - *old_scale = 1.; - *old_offset = 0.; - } - else - { - *old_scale = *scale; - *old_offset = *offset; - } - if((*level >=0 && ifupper) || (*level <=0 && !ifupper)) - { - // If superscript of subscript moves further away from centerline.... - *scale = 0.75 * *old_scale; - *offset = *old_offset + *old_scale; - } - else - { - // If superscript of subscript moves closer to centerline.... - *scale = *old_scale/0.75; - *offset = *old_offset - *scale; - } - if(ifupper) - (*level)++; - else - (*level)--; + if ( *level == 0 ) + { + *old_scale = 1.; + *old_offset = 0.; + } + else + { + *old_scale = *scale; + *old_offset = *offset; + } + if ( ( *level >= 0 && ifupper ) || ( *level <= 0 && !ifupper ) ) + { + // If superscript of subscript moves further away from centerline.... + *scale = 0.75 * *old_scale; + *offset = *old_offset + *old_scale; + } + else + { + // If superscript of subscript moves closer to centerline.... + *scale = *old_scale / 0.75; + *offset = *old_offset - *scale; + } + if ( ifupper ) + ( *level )++; + else + ( *level )--; } //-------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2011-07-06 02:28:58
|
Revision: 11795 http://plplot.svn.sourceforge.net/plplot/?rev=11795&view=rev Author: airwin Date: 2011-07-06 02:28:50 +0000 (Wed, 06 Jul 2011) Log Message: ----------- Include drivers/psttf.cc in list of C++ source files to style. (This file was inadvertently left out from the original list of source files to style.) Many changes were introduced by the styling of psttfc.cc, but the results are the same as for the previous unstyled file. Modified Paths: -------------- trunk/drivers/psttf.cc trunk/scripts/style_source.sh Modified: trunk/drivers/psttf.cc =================================================================== --- trunk/drivers/psttf.cc 2011-07-06 02:23:16 UTC (rev 11794) +++ trunk/drivers/psttf.cc 2011-07-06 02:28:50 UTC (rev 11795) @@ -1,39 +1,39 @@ -/* $Id$ +// $Id$ +// +// PLplot PostScript device driver using LASi to provide fonts +// based on original ps.c PostScript driver +// +// Copyright (C) 1992, 2001 Geoffrey Furnish +// Copyright (C) 1992, 1993, 1994, 1995, 2001 Maurice LeBrun +// Copyright (C) 2000-2011 Alan W. Irwin +// Copyright (C) 2001, 2002 Joao Cardoso +// Copyright (C) 2001, 2003, 2004 Rafael Laboissiere +// Copyright (C) 2004, 2005 Thomas J. Duck +// Copyright (C) 2005, 2006 Andrew Ross +// +// This file is part of PLplot. +// +// PLplot is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// PLplot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public License +// along with PLplot; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// +// - PLplot PostScript device driver using LASi to provide fonts - based on original ps.c PostScript driver - - Copyright (C) 1992, 2001 Geoffrey Furnish - Copyright (C) 1992, 1993, 1994, 1995, 2001 Maurice LeBrun - Copyright (C) 2000-2011 Alan W. Irwin - Copyright (C) 2001, 2002 Joao Cardoso - Copyright (C) 2001, 2003, 2004 Rafael Laboissiere - Copyright (C) 2004, 2005 Thomas J. Duck - Copyright (C) 2005, 2006 Andrew Ross - - This file is part of PLplot. - - PLplot is free software; you can redistribute it and/or modify - it under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - PLplot is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with PLplot; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - #include "plDevs.h" #define DEBUG -#if defined(PLD_psttf) +#if defined ( PLD_psttf ) #define NEED_PLDEBUG #include "plplotP.h" @@ -47,218 +47,222 @@ #include <fstream> #include <LASi.h> -/* Define macro to truncate small values to zero - prevents - * * printf printing -0.000 */ -#define TRMFLT(a) ((fabs(a)<5.0e-4) ? 0.0 : (a)) +// Define macro to truncate small values to zero - prevents +// * printf printing -0.000 +#define TRMFLT( a ) ( ( fabs( a ) < 5.0e-4 ) ? 0.0 : ( a ) ) using namespace LASi; using namespace std; -/* Device info */ +// Device info -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_psttf = - "psttf:PostScript File (monochrome):0:psttf:55:psttfm\n" - "psttfc:PostScript File (color):0:psttf:56:psttfc\n"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_psttf = + "psttf:PostScript File (monochrome):0:psttf:55:psttfm\n" + "psttfc:PostScript File (color):0:psttf:56:psttfc\n"; -/* Prototypes for functions in this file. */ +// Prototypes for functions in this file. -void plD_dispatch_init_psttfm ( PLDispatchTable *pdt ); -void plD_dispatch_init_psttfc ( PLDispatchTable *pdt ); +void plD_dispatch_init_psttfm( PLDispatchTable *pdt ); +void plD_dispatch_init_psttfc( PLDispatchTable *pdt ); -static char *ps_getdate (void); -static void ps_init (PLStream *); -static void fill_polygon (PLStream *pls); -static void proc_str (PLStream *, EscText *); -static void esc_purge (char *, char *); +static char *ps_getdate( void ); +static void ps_init( PLStream * ); +static void fill_polygon( PLStream *pls ); +static void proc_str( PLStream *, EscText * ); +static void esc_purge( char *, char * ); -#define OUTBUF_LEN 128 -static char outbuf[OUTBUF_LEN]; -static int text = 1; -static int color; -static int hrshsym = 0; +#define OUTBUF_LEN 128 +static char outbuf[OUTBUF_LEN]; +static int text = 1; +static int color; +static int hrshsym = 0; -/* Font style and weight lookup tables */ +// Font style and weight lookup tables -#define N_Pango_Lookup 5 +#define N_Pango_Lookup 5 const char * DefaultFamilyLookup[N_Pango_Lookup] = { - "sans", - "serif", - "monospace", - "sans,serif", - "sans,serif" + "sans", + "serif", + "monospace", + "sans,serif", + "sans,serif" }; const char * EnvFamilyLookup[N_Pango_Lookup] = { - "PLPLOT_FREETYPE_SANS_FAMILY", - "PLPLOT_FREETYPE_SERIF_FAMILY", - "PLPLOT_FREETYPE_MONO_FAMILY", - "PLPLOT_FREETYPE_SCRIPT_FAMILY", - "PLPLOT_FREETYPE_SYMBOL_FAMILY" + "PLPLOT_FREETYPE_SANS_FAMILY", + "PLPLOT_FREETYPE_SERIF_FAMILY", + "PLPLOT_FREETYPE_MONO_FAMILY", + "PLPLOT_FREETYPE_SCRIPT_FAMILY", + "PLPLOT_FREETYPE_SYMBOL_FAMILY" }; -#define FAMILY_LOOKUP_LEN 1024 -char FamilyLookup[N_Pango_Lookup][FAMILY_LOOKUP_LEN]; +#define FAMILY_LOOKUP_LEN 1024 +char FamilyLookup[N_Pango_Lookup][FAMILY_LOOKUP_LEN]; const FontWeight WeightLookup[2] = { - NORMAL_WEIGHT, - BOLD + NORMAL_WEIGHT, + BOLD }; -const FontStyle StyleLookup[3] = { - NORMAL_STYLE, - ITALIC, - OBLIQUE +const FontStyle StyleLookup[3] = { + NORMAL_STYLE, + ITALIC, + OBLIQUE }; -static DrvOpt ps_options[] = {{"text", DRV_INT, &text, "Use Postscript text (text=0|1)"}, - {"color", DRV_INT, &color, "Use color (color=0|1)"}, - {"hrshsym", DRV_INT, &hrshsym, "Use Hershey symbol set (hrshsym=0|1)"}, - {NULL, DRV_INT, NULL, NULL}}; +static DrvOpt ps_options[] = { { "text", DRV_INT, &text, "Use Postscript text (text=0|1)" }, + { "color", DRV_INT, &color, "Use color (color=0|1)" }, + { "hrshsym", DRV_INT, &hrshsym, "Use Hershey symbol set (hrshsym=0|1)" }, + { NULL, DRV_INT, NULL, NULL } }; -/* text > 0 uses some postscript tricks, namely a transformation matrix - that scales, rotates (with slanting) and offsets text strings. - It has yet some bugs for 3d plots. */ +// text > 0 uses some postscript tricks, namely a transformation matrix +// that scales, rotates (with slanting) and offsets text strings. +// It has yet some bugs for 3d plots. static void psttf_dispatch_init_helper( PLDispatchTable *pdt, - const char *menustr, const char *devnam, - int type, int seq, plD_init_fp init ) + const char *menustr, const char *devnam, + int type, int seq, plD_init_fp init ) { #ifndef ENABLE_DYNDRIVERS pdt->pl_MenuStr = menustr; pdt->pl_DevName = devnam; #endif - pdt->pl_type = type; - pdt->pl_seq = seq; + pdt->pl_type = type; + pdt->pl_seq = seq; pdt->pl_init = init; - pdt->pl_line = (plD_line_fp) plD_line_psttf; + pdt->pl_line = (plD_line_fp) plD_line_psttf; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_psttf; - pdt->pl_eop = (plD_eop_fp) plD_eop_psttf; - pdt->pl_bop = (plD_bop_fp) plD_bop_psttf; - pdt->pl_tidy = (plD_tidy_fp) plD_tidy_psttf; - pdt->pl_state = (plD_state_fp) plD_state_psttf; - pdt->pl_esc = (plD_esc_fp) plD_esc_psttf; + pdt->pl_eop = (plD_eop_fp) plD_eop_psttf; + pdt->pl_bop = (plD_bop_fp) plD_bop_psttf; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_psttf; + pdt->pl_state = (plD_state_fp) plD_state_psttf; + pdt->pl_esc = (plD_esc_fp) plD_esc_psttf; } -void plD_dispatch_init_psttfm ( PLDispatchTable *pdt ) +void plD_dispatch_init_psttfm( PLDispatchTable *pdt ) { psttf_dispatch_init_helper( pdt, - "PostScript File (monochrome)", "psttf", - plDevType_FileOriented, 55, - (plD_init_fp) plD_init_psttfm ); + "PostScript File (monochrome)", "psttf", + plDevType_FileOriented, 55, + (plD_init_fp) plD_init_psttfm ); } -void plD_dispatch_init_psttfc ( PLDispatchTable *pdt ) +void plD_dispatch_init_psttfc( PLDispatchTable *pdt ) { psttf_dispatch_init_helper( pdt, - "PostScript File (color)", "psttfc", - plDevType_FileOriented, 56, - (plD_init_fp) plD_init_psttfc ); + "PostScript File (color)", "psttfc", + plDevType_FileOriented, 56, + (plD_init_fp) plD_init_psttfc ); } -/*--------------------------------------------------------------------------*\ - * plD_init_psttf() - * - * Initialize device. -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// plD_init_psttf() +// +// Initialize device. +//-------------------------------------------------------------------------- void -plD_init_psttfm(PLStream *pls) +plD_init_psttfm( PLStream *pls ) { - color = 0; - pls->color = 0; /* Not a color device */ + color = 0; + pls->color = 0; // Not a color device - plParseDrvOpts(ps_options); - if (color) - pls->color = 1; /* But user wants color */ - ps_init(pls); + plParseDrvOpts( ps_options ); + if ( color ) + pls->color = 1; // But user wants color + ps_init( pls ); } void -plD_init_psttfc(PLStream *pls) +plD_init_psttfc( PLStream *pls ) { - color = 1; - pls->color = 1; /* Is a color device */ - plParseDrvOpts(ps_options); + color = 1; + pls->color = 1; // Is a color device + plParseDrvOpts( ps_options ); - if (!color) - pls->color = 0; /* But user does not want color */ - ps_init(pls); + if ( !color ) + pls->color = 0; // But user does not want color + ps_init( pls ); } -#define MAX_NUM_TRIES 10 +#define MAX_NUM_TRIES 10 static void -ps_init(PLStream *pls) +ps_init( PLStream *pls ) { - int i; - char *a; + int i; + char *a; PSDev *dev; - PostscriptDocument *doc; + PostscriptDocument *doc; PLFLT pxlx, pxly; - /* Set default values - 7.5 x 10 [inches] (72 points = 1 inch) */ - if (pls->xlength <= 0 || pls->ylength <=0) { - pls->xlength = 540; - pls->ylength = 720; + // Set default values - 7.5 x 10 [inches] (72 points = 1 inch) + if ( pls->xlength <= 0 || pls->ylength <= 0 ) + { + pls->xlength = 540; + pls->ylength = 720; } - if (pls->xdpi <= 0) pls->xdpi = 72.; - if (pls->ydpi <= 0) pls->ydpi = 72.; + if ( pls->xdpi <= 0 ) + pls->xdpi = 72.; + if ( pls->ydpi <= 0 ) + pls->ydpi = 72.; - pxlx = YPSSIZE/LPAGE_X; - pxly = XPSSIZE/LPAGE_Y; + pxlx = YPSSIZE / LPAGE_X; + pxly = XPSSIZE / LPAGE_Y; - if (text) - { - pls->dev_text = 1; /* want to draw text */ - pls->dev_unicode = 1; /* want unicode */ - if(hrshsym) pls->dev_hrshsym = 1; /* want Hershey symbols */ - } + if ( text ) + { + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode + if ( hrshsym ) + pls->dev_hrshsym = 1; // want Hershey symbols + } - pls->dev_fill0 = 1; /* Can do solid fills */ + pls->dev_fill0 = 1; // Can do solid fills -/* Initialize family file info */ +// Initialize family file info - plFamInit(pls); + plFamInit( pls ); -/* Prompt for a file name if not already set */ - - plOpenFile(pls); +// Prompt for a file name if not already set -/* Create postscript document object */ - if (pls->psdoc != NULL) - delete (PostscriptDocument *) pls->psdoc; + plOpenFile( pls ); +// Create postscript document object + if ( pls->psdoc != NULL ) + delete (PostscriptDocument *) pls->psdoc; + pls->psdoc = new PostscriptDocument(); - doc = (PostscriptDocument *) (pls->psdoc); + doc = (PostscriptDocument *) ( pls->psdoc ); doc->osBody() << fixed; - doc->osBody().precision(3); + doc->osBody().precision( 3 ); -/* Allocate and initialize device-specific data */ +// Allocate and initialize device-specific data - if (pls->dev != NULL) - free((void *) pls->dev); + if ( pls->dev != NULL ) + free( (void *) pls->dev ); - pls->dev = calloc(1, (size_t) sizeof(PSDev)); - if (pls->dev == NULL) - plexit("ps_init: Out of memory."); + pls->dev = calloc( 1, (size_t) sizeof ( PSDev ) ); + if ( pls->dev == NULL ) + plexit( "ps_init: Out of memory." ); dev = (PSDev *) pls->dev; dev->xold = PL_UNDEFINED; dev->yold = PL_UNDEFINED; - plP_setpxl(pxlx, pxly); + plP_setpxl( pxlx, pxly ); - dev->llx = XPSSIZE; - dev->lly = YPSSIZE; - dev->urx = 0; - dev->ury = 0; + dev->llx = XPSSIZE; + dev->lly = YPSSIZE; + dev->urx = 0; + dev->ury = 0; dev->ptcnt = 0; -/* Rotate by 90 degrees since portrait mode addressing is used */ +// Rotate by 90 degrees since portrait mode addressing is used dev->xmin = 0; dev->ymin = 0; @@ -267,60 +271,64 @@ dev->xlen = dev->xmax - dev->xmin; dev->ylen = dev->ymax - dev->ymin; - plP_setphy(dev->xmin, dev->xmax, dev->ymin, dev->ymax); + plP_setphy( dev->xmin, dev->xmax, dev->ymin, dev->ymax ); -/* If portrait mode is specified, then set up an additional rotation - * transformation with aspect ratio allowed to adjust via freeaspect. - * Default orientation is landscape (ORIENTATION == 3 or 90 deg rotation - * counter-clockwise from portrait). (Legacy PLplot used seascape - * which was equivalent to ORIENTATION == 1 or 90 deg clockwise rotation - * from portrait.) */ +// If portrait mode is specified, then set up an additional rotation +// transformation with aspect ratio allowed to adjust via freeaspect. +// Default orientation is landscape (ORIENTATION == 3 or 90 deg rotation +// counter-clockwise from portrait). (Legacy PLplot used seascape +// which was equivalent to ORIENTATION == 1 or 90 deg clockwise rotation +// from portrait.) - if (pls->portrait) { - plsdiori((PLFLT)(4 - ORIENTATION)); - pls->freeaspect = 1; + if ( pls->portrait ) + { + plsdiori( (PLFLT) ( 4 - ORIENTATION ) ); + pls->freeaspect = 1; } - // File table for font families using either environment variables + // File table for font families using either environment variables // or defaults. - for (i=0;i<N_Pango_Lookup;i++) { - if ( (a = getenv(EnvFamilyLookup[i])) != NULL ) { - strncpy(FamilyLookup[i],a,FAMILY_LOOKUP_LEN-1); - FamilyLookup[i][FAMILY_LOOKUP_LEN-1] = '\0'; - } - else { - strncpy(FamilyLookup[i],DefaultFamilyLookup[i],FAMILY_LOOKUP_LEN); - FamilyLookup[i][FAMILY_LOOKUP_LEN-1] = '\0'; - } + for ( i = 0; i < N_Pango_Lookup; i++ ) + { + if ( ( a = getenv( EnvFamilyLookup[i] ) ) != NULL ) + { + strncpy( FamilyLookup[i], a, FAMILY_LOOKUP_LEN - 1 ); + FamilyLookup[i][FAMILY_LOOKUP_LEN - 1] = '\0'; + } + else + { + strncpy( FamilyLookup[i], DefaultFamilyLookup[i], FAMILY_LOOKUP_LEN ); + FamilyLookup[i][FAMILY_LOOKUP_LEN - 1] = '\0'; + } } - } -/*--------------------------------------------------------------------------*\ - * writeHeader() - * - * Write plplot postscript commands into the header -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// writeHeader() +// +// Write plplot postscript commands into the header +//-------------------------------------------------------------------------- void -writeHeader(PLStream *pls) { - PostscriptDocument *doc = (PostscriptDocument *) (pls->psdoc); +writeHeader( PLStream *pls ) +{ + PostscriptDocument *doc = (PostscriptDocument *) ( pls->psdoc ); doc->osHeader() << "%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; - + doc->osHeader() << "%%Title: PLplot Graph\n"; doc->osHeader() << "%%Creator: PLplot Version " << VERSION << "\n"; doc->osHeader() << "%%CreationDate: " << ps_getdate() << "\n"; doc->osHeader() << "%%Pages: (atend)\n"; doc->osHeader() << "%%EndComments\n\n"; -/* Definitions */ -/* Save VM state */ +// Definitions +// Save VM state doc->osHeader() << "/PSSave save def\n"; -/* Define a dictionary and start using it */ +// Define a dictionary and start using it doc->osHeader() << "/PSDict 200 dict def\n"; doc->osHeader() << "PSDict begin\n"; @@ -337,37 +345,37 @@ doc->osHeader() << " ( ) cvs print\n"; doc->osHeader() << " } def\n"; -/* n @copies - */ +// n @copies - doc->osHeader() << "/@copies\n"; doc->osHeader() << " {\n"; doc->osHeader() << " /#copies exch def\n"; doc->osHeader() << " } def\n"; -/* - @start - -- start everything */ +// - @start - -- start everything doc->osHeader() << "/@start\n"; doc->osHeader() << " {\n"; doc->osHeader() << " vmstatus pop /@VMused exch def pop\n"; doc->osHeader() << " } def\n"; -/* - @end - -- finished */ +// - @end - -- finished doc->osHeader() << "/@end\n"; doc->osHeader() << " {flush\n"; doc->osHeader() << " end\n"; doc->osHeader() << " PSSave restore\n"; doc->osHeader() << " } def\n"; - -/* bop - -- begin a new page */ -/* Only fill background if we are using color and if the bg isn't white */ +// bop - -- begin a new page +// Only fill background if we are using color and if the bg isn't white + doc->osHeader() << "/bop\n"; doc->osHeader() << " {\n"; doc->osHeader() << " /SaveImage save def\n"; doc->osHeader() << " } def\n"; -/* - eop - -- end a page */ +// - eop - -- end a page doc->osHeader() << "/eop\n"; doc->osHeader() << " {\n"; @@ -375,31 +383,31 @@ doc->osHeader() << " SaveImage restore\n"; doc->osHeader() << " } def\n"; -/* Set line parameters */ - +// Set line parameters + doc->osHeader() << "/@line\n"; doc->osHeader() << " {0 setlinecap\n"; doc->osHeader() << " 0 setlinejoin\n"; doc->osHeader() << " 1 setmiterlimit\n"; doc->osHeader() << " } def\n"; -/* d @hsize - horizontal clipping dimension */ +// d @hsize - horizontal clipping dimension doc->osHeader() << "/@hsize {/hs exch def} def\n"; doc->osHeader() << "/@vsize {/vs exch def} def\n"; -/* d @hoffset - shift for the plots */ +// d @hoffset - shift for the plots doc->osHeader() << "/@hoffset {/ho exch def} def\n"; doc->osHeader() << "/@voffset {/vo exch def} def\n"; -/* Set line width */ +// Set line width doc->osHeader() << "/lw " << (int) ( - (pls->width < MIN_WIDTH) ? DEF_WIDTH : - (pls->width > MAX_WIDTH) ? MAX_WIDTH : pls->width) << " def\n"; + ( pls->width < MIN_WIDTH ) ? DEF_WIDTH : + ( pls->width > MAX_WIDTH ) ? MAX_WIDTH : pls->width ) << " def\n"; -/* Setup user specified offsets, scales, sizes for clipping */ +// Setup user specified offsets, scales, sizes for clipping doc->osHeader() << "/@SetPlot\n"; doc->osHeader() << " {\n"; @@ -408,15 +416,15 @@ doc->osHeader() << " lw setlinewidth\n"; doc->osHeader() << " } def\n"; -/* Setup x & y scales */ - +// Setup x & y scales + doc->osHeader() << "/XScale\n"; doc->osHeader() << " {hs " << YPSSIZE << " div} def\n"; doc->osHeader() << "/YScale\n"; doc->osHeader() << " {vs " << XPSSIZE << " div} def\n"; - -/* Macro definitions of common instructions, to keep output small */ +// Macro definitions of common instructions, to keep output small + doc->osHeader() << "/M {moveto} def\n"; doc->osHeader() << "/D {lineto} def\n"; doc->osHeader() << "/A {0.5 0 360 arc} def\n"; @@ -433,12 +441,12 @@ doc->osHeader() << "/R {rotate} def\n"; doc->osHeader() << "/B {Z " << XMIN << " " << YMIN << " M " << XMIN << " " << YMAX << " D " << XMAX << " " << YMAX << " D " << XMAX << " " << YMIN << " D " << XMIN << " " << YMIN << " closepath} def\n"; doc->osHeader() << "/CL {newpath M D D D closepath clip} def\n"; - -/* End of dictionary definition */ +// End of dictionary definition + doc->osHeader() << "end\n\n"; -/* Set up the plots */ +// Set up the plots doc->osHeader() << "PSDict begin\n"; doc->osHeader() << "@start\n"; @@ -452,99 +460,102 @@ doc->osHeader() << "@SetPlot\n" << endl; } -/*--------------------------------------------------------------------------*\ - * plD_line_psttf() - * - * Draw a line in the current color from (x1,y1) to (x2,y2). -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// plD_line_psttf() +// +// Draw a line in the current color from (x1,y1) to (x2,y2). +//-------------------------------------------------------------------------- void -plD_line_psttf(PLStream *pls, short x1a, short y1a, short x2a, short y2a) +plD_line_psttf( PLStream *pls, short x1a, short y1a, short x2a, short y2a ) { PSDev *dev = (PSDev *) pls->dev; PostscriptDocument *doc = (PostscriptDocument *) pls->psdoc; PLINT x1 = x1a, y1 = y1a, x2 = x2a, y2 = y2a; -/* Rotate by 90 degrees */ +// Rotate by 90 degrees - plRotPhy(ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, &x1, &y1); - plRotPhy(ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, &x2, &y2); + plRotPhy( ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, &x1, &y1 ); + plRotPhy( ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, &x2, &y2 ); - if (x1 == dev->xold && y1 == dev->yold && dev->ptcnt < 40) { - if (pls->linepos + 12 > LINELENGTH) { - doc->osBody() << '\n'; - pls->linepos = 0; - } - else - doc->osBody() << ' '; + if ( x1 == dev->xold && y1 == dev->yold && dev->ptcnt < 40 ) + { + if ( pls->linepos + 12 > LINELENGTH ) + { + doc->osBody() << '\n'; + pls->linepos = 0; + } + else + doc->osBody() << ' '; - snprintf(outbuf, OUTBUF_LEN, "%d %d D", x2, y2); - dev->ptcnt++; - pls->linepos += 12; + snprintf( outbuf, OUTBUF_LEN, "%d %d D", x2, y2 ); + dev->ptcnt++; + pls->linepos += 12; } - else { + else + { doc->osBody() << " Z\n"; - pls->linepos = 0; + pls->linepos = 0; - if (x1 == x2 && y1 == y2) /* must be a single dot, draw a circle */ - snprintf(outbuf, OUTBUF_LEN, "%d %d A", x1, y1); - else - snprintf(outbuf, OUTBUF_LEN, "%d %d M %d %d D", x1, y1, x2, y2); - dev->llx = MIN(dev->llx, x1); - dev->lly = MIN(dev->lly, y1); - dev->urx = MAX(dev->urx, x1); - dev->ury = MAX(dev->ury, y1); - dev->ptcnt = 1; - pls->linepos += 24; + if ( x1 == x2 && y1 == y2 ) // must be a single dot, draw a circle + snprintf( outbuf, OUTBUF_LEN, "%d %d A", x1, y1 ); + else + snprintf( outbuf, OUTBUF_LEN, "%d %d M %d %d D", x1, y1, x2, y2 ); + dev->llx = MIN( dev->llx, x1 ); + dev->lly = MIN( dev->lly, y1 ); + dev->urx = MAX( dev->urx, x1 ); + dev->ury = MAX( dev->ury, y1 ); + dev->ptcnt = 1; + pls->linepos += 24; } - dev->llx = MIN(dev->llx, x2); - dev->lly = MIN(dev->lly, y2); - dev->urx = MAX(dev->urx, x2); - dev->ury = MAX(dev->ury, y2); + dev->llx = MIN( dev->llx, x2 ); + dev->lly = MIN( dev->lly, y2 ); + dev->urx = MAX( dev->urx, x2 ); + dev->ury = MAX( dev->ury, y2 ); doc->osBody() << outbuf; - pls->bytecnt += 1 + strlen(outbuf); - dev->xold = x2; - dev->yold = y2; + pls->bytecnt += 1 + strlen( outbuf ); + dev->xold = x2; + dev->yold = y2; } -/*--------------------------------------------------------------------------*\ - * plD_polyline_psttf() - * - * Draw a polyline in the current color. -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// plD_polyline_psttf() +// +// Draw a polyline in the current color. +//-------------------------------------------------------------------------- void -plD_polyline_psttf(PLStream *pls, short *xa, short *ya, PLINT npts) +plD_polyline_psttf( PLStream *pls, short *xa, short *ya, PLINT npts ) { PLINT i; - for (i = 0; i < npts - 1; i++) - plD_line_psttf(pls, xa[i], ya[i], xa[i + 1], ya[i + 1]); + for ( i = 0; i < npts - 1; i++ ) + plD_line_psttf( pls, xa[i], ya[i], xa[i + 1], ya[i + 1] ); } -/*--------------------------------------------------------------------------*\ - * plD_eop_psttf() - * - * End of page. -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// plD_eop_psttf() +// +// End of page. +//-------------------------------------------------------------------------- void -plD_eop_psttf(PLStream *pls) +plD_eop_psttf( PLStream *pls ) { PostscriptDocument *doc = (PostscriptDocument *) pls->psdoc; doc->osBody() << " S\neop\n"; } -/*--------------------------------------------------------------------------*\ - * plD_bop_psttf() - * - * Set up for the next page. - * Advance to next family file if necessary (file output). -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// plD_bop_psttf() +// +// Set up for the next page. +// Advance to next family file if necessary (file output). +//-------------------------------------------------------------------------- void -plD_bop_psttf(PLStream *pls) +plD_bop_psttf( PLStream *pls ) { PSDev *dev = (PSDev *) pls->dev; PostscriptDocument *doc = (PostscriptDocument *) pls->psdoc; @@ -552,47 +563,48 @@ dev->xold = PL_UNDEFINED; dev->yold = PL_UNDEFINED; - if (!pls->termin) - plGetFam(pls); + if ( !pls->termin ) + plGetFam( pls ); pls->page++; - if (pls->family) + if ( pls->family ) doc->osBody() << "%%Page: " << (int) pls->page << " 1\n"; else - doc->osBody() << "%%Page: " << (int) pls->page << " " << (int) pls->page << "\n"; + doc->osBody() << "%%Page: " << (int) pls->page << " " << (int) pls->page << "\n"; doc->osBody() << "bop\n"; - if (pls->color) { - PLFLT r, g, b; - if (pls->cmap0[0].r != 0xFF || - pls->cmap0[0].g != 0xFF || - pls->cmap0[0].b != 0xFF ) { + if ( pls->color ) + { + PLFLT r, g, b; + if ( pls->cmap0[0].r != 0xFF || + pls->cmap0[0].g != 0xFF || + pls->cmap0[0].b != 0xFF ) + { + r = ( (PLFLT) pls->cmap0[0].r ) / 255.; + g = ( (PLFLT) pls->cmap0[0].g ) / 255.; + b = ( (PLFLT) pls->cmap0[0].b ) / 255.; - r = ((PLFLT) pls->cmap0[0].r) / 255.; - g = ((PLFLT) pls->cmap0[0].g) / 255.; - b = ((PLFLT) pls->cmap0[0].b) / 255.; - - doc->osBody() << "B " << r << " " << g << " " << b << " C F\n"; - } + doc->osBody() << "B " << r << " " << g << " " << b << " C F\n"; + } } pls->linepos = 0; -/* This ensures the color and line width are set correctly at the beginning of - each page */ +// This ensures the color and line width are set correctly at the beginning of +// each page - plD_state_psttf(pls, PLSTATE_COLOR0); - plD_state_psttf(pls, PLSTATE_WIDTH); + plD_state_psttf( pls, PLSTATE_COLOR0 ); + plD_state_psttf( pls, PLSTATE_WIDTH ); } -/*--------------------------------------------------------------------------*\ - * plD_tidy_psttf() - * - * Close graphics file or otherwise clean up. -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// plD_tidy_psttf() +// +// Close graphics file or otherwise clean up. +//-------------------------------------------------------------------------- void -plD_tidy_psttf(PLStream *pls) +plD_tidy_psttf( PLStream *pls ) { PSDev *dev = (PSDev *) pls->dev; PostscriptDocument *doc = (PostscriptDocument *) pls->psdoc; @@ -606,122 +618,128 @@ dev->urx += XOFFSET; dev->ury += YOFFSET; -/* changed for correct Bounding boundaries Jan Thorbecke okt 1993*/ -/* occurs from the integer truncation -- postscript uses fp arithmetic */ +// changed for correct Bounding boundaries Jan Thorbecke okt 1993 +// occurs from the integer truncation -- postscript uses fp arithmetic dev->urx += 1; dev->ury += 1; - if (pls->family) + if ( pls->family ) doc->osFooter() << "%%Pages: 1\n"; else doc->osFooter() << "%%Pages: " << (int) pls->page << "\n"; doc->osFooter() << "@end" << endl; -/* Now write the rest of the header */ - writeHeader(pls); +// Now write the rest of the header + writeHeader( pls ); -/* Write out postscript document to file and close*/ - /* For C++ stream we first need to close the file using - the C FILE * handle, then reopen as a ofstream. Yuck! */ - if (! strcmp(pls->FileName,"-")) { - doc->write(cout,dev->llx,dev->lly,dev->urx,dev->ury); +// Write out postscript document to file and close + // For C++ stream we first need to close the file using +// the C FILE * handle, then reopen as a ofstream. Yuck! + if ( !strcmp( pls->FileName, "-" ) ) + { + doc->write( cout, dev->llx, dev->lly, dev->urx, dev->ury ); } - else { - plCloseFile( pls ); - ofstream out; - out.open(pls->FileName); - doc->write(out,dev->llx,dev->lly,dev->urx,dev->ury); - out.close(); + else + { + plCloseFile( pls ); + ofstream out; + out.open( pls->FileName ); + doc->write( out, dev->llx, dev->lly, dev->urx, dev->ury ); + out.close(); } delete doc; pls->psdoc = NULL; - } -/*--------------------------------------------------------------------------*\ - * plD_state_psttf() - * - * Handle change in PLStream state (color, pen width, fill attribute, etc). -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// plD_state_psttf() +// +// Handle change in PLStream state (color, pen width, fill attribute, etc). +//-------------------------------------------------------------------------- -void -plD_state_psttf(PLStream *pls, PLINT op) +void +plD_state_psttf( PLStream *pls, PLINT op ) { PSDev *dev = (PSDev *) pls->dev; PostscriptDocument *doc = (PostscriptDocument *) pls->psdoc; - switch (op) { + switch ( op ) + { + case PLSTATE_WIDTH: { + int width = + ( pls->width < MIN_WIDTH ) ? DEF_WIDTH : + ( pls->width > MAX_WIDTH ) ? MAX_WIDTH : pls->width; - case PLSTATE_WIDTH:{ - int width = - (pls->width < MIN_WIDTH) ? DEF_WIDTH : - (pls->width > MAX_WIDTH) ? MAX_WIDTH : pls->width; + doc->osBody() << " S\n" << width << " W"; - doc->osBody() << " S\n" << width << " W"; - - dev->xold = PL_UNDEFINED; - dev->yold = PL_UNDEFINED; - break; + dev->xold = PL_UNDEFINED; + dev->yold = PL_UNDEFINED; + break; } case PLSTATE_COLOR0: - if (! pls->color) { - doc->osBody() << " S\n" << (pls->icol0 ? 0.0 : 1.0) << " G"; - break; - } - /* else fallthrough */ + if ( !pls->color ) + { + doc->osBody() << " S\n" << ( pls->icol0 ? 0.0 : 1.0 ) << " G"; + break; + } + // else fallthrough case PLSTATE_COLOR1: - if (pls->color) { - PLFLT r = ((PLFLT) pls->curcolor.r) / 255.0; - PLFLT g = ((PLFLT) pls->curcolor.g) / 255.0; - PLFLT b = ((PLFLT) pls->curcolor.b) / 255.0; + if ( pls->color ) + { + PLFLT r = ( (PLFLT) pls->curcolor.r ) / 255.0; + PLFLT g = ( (PLFLT) pls->curcolor.g ) / 255.0; + PLFLT b = ( (PLFLT) pls->curcolor.b ) / 255.0; - doc->osBody() << " S\n" << r << " " << g << " " << b << " C"; - } - else { - PLFLT r = ((PLFLT) pls->curcolor.r) / 255.0; - doc->osBody() << " S\n" << 1.0 - r << " G"; - } - break; + doc->osBody() << " S\n" << r << " " << g << " " << b << " C"; + } + else + { + PLFLT r = ( (PLFLT) pls->curcolor.r ) / 255.0; + doc->osBody() << " S\n" << 1.0 - r << " G"; + } + break; } -/* Reinitialize current point location. */ +// Reinitialize current point location. - if (dev->xold != PL_UNDEFINED && dev->yold != PL_UNDEFINED) { - doc->osBody() << " " << (int)dev->xold << " " << (int)dev->yold << " M \n"; + if ( dev->xold != PL_UNDEFINED && dev->yold != PL_UNDEFINED ) + { + doc->osBody() << " " << (int) dev->xold << " " << (int) dev->yold << " M \n"; } } -/*--------------------------------------------------------------------------*\ - * plD_esc_psttf() - * - * Escape function. -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// plD_esc_psttf() +// +// Escape function. +//-------------------------------------------------------------------------- void -plD_esc_psttf(PLStream *pls, PLINT op, void *ptr) +plD_esc_psttf( PLStream *pls, PLINT op, void *ptr ) { - switch (op) { + switch ( op ) + { case PLESC_FILL: - fill_polygon(pls); - break; + fill_polygon( pls ); + break; case PLESC_HAS_TEXT: - proc_str(pls, (EscText *)ptr); - break; + proc_str( pls, (EscText *) ptr ); + break; } } -/*--------------------------------------------------------------------------*\ - * fill_polygon() - * - * Fill polygon described in points pls->dev_x[] and pls->dev_y[]. - * Only solid color fill supported. -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// fill_polygon() +// +// Fill polygon described in points pls->dev_x[] and pls->dev_y[]. +// Only solid color fill supported. +//-------------------------------------------------------------------------- static void -fill_polygon(PLStream *pls) +fill_polygon( PLStream *pls ) { PSDev *dev = (PSDev *) pls->dev; PostscriptDocument *doc = (PostscriptDocument *) pls->psdoc; @@ -730,68 +748,71 @@ doc->osBody() << " Z\n"; - for (n = 0; n < pls->dev_npts; n++) { - x = pls->dev_x[ix++]; - y = pls->dev_y[iy++]; + for ( n = 0; n < pls->dev_npts; n++ ) + { + x = pls->dev_x[ix++]; + y = pls->dev_y[iy++]; -/* Rotate by 90 degrees */ +// Rotate by 90 degrees - plRotPhy(ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, &x, &y); + plRotPhy( ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, &x, &y ); -/* First time through start with a x y moveto */ +// First time through start with a x y moveto - if (n == 0) { - snprintf(outbuf, OUTBUF_LEN, "N %d %d M", x, y); - dev->llx = MIN(dev->llx, x); - dev->lly = MIN(dev->lly, y); - dev->urx = MAX(dev->urx, x); - dev->ury = MAX(dev->ury, y); - doc->osBody() << outbuf; - pls->bytecnt += strlen(outbuf); - continue; - } + if ( n == 0 ) + { + snprintf( outbuf, OUTBUF_LEN, "N %d %d M", x, y ); + dev->llx = MIN( dev->llx, x ); + dev->lly = MIN( dev->lly, y ); + dev->urx = MAX( dev->urx, x ); + dev->ury = MAX( dev->ury, y ); + doc->osBody() << outbuf; + pls->bytecnt += strlen( outbuf ); + continue; + } - if (pls->linepos + 21 > LINELENGTH) { - doc->osBody() << '\n'; - pls->linepos = 0; - } - else - doc->osBody() << ' '; + if ( pls->linepos + 21 > LINELENGTH ) + { + doc->osBody() << '\n'; + pls->linepos = 0; + } + else + doc->osBody() << ' '; - pls->bytecnt++; + pls->bytecnt++; - snprintf(outbuf, OUTBUF_LEN, "%d %d D", x, y); - dev->llx = MIN(dev->llx, x); - dev->lly = MIN(dev->lly, y); - dev->urx = MAX(dev->urx, x); - dev->ury = MAX(dev->ury, y); + snprintf( outbuf, OUTBUF_LEN, "%d %d D", x, y ); + dev->llx = MIN( dev->llx, x ); + dev->lly = MIN( dev->lly, y ); + dev->urx = MAX( dev->urx, x ); + dev->ury = MAX( dev->ury, y ); - doc->osBody() << outbuf; - pls->bytecnt += strlen(outbuf); - pls->linepos += 21; + doc->osBody() << outbuf; + pls->bytecnt += strlen( outbuf ); + pls->linepos += 21; } dev->xold = PL_UNDEFINED; dev->yold = PL_UNDEFINED; doc->osBody() << " F "; } -/*--------------------------------------------------------------------------*\ - * ps_getdate() - * - * Get the date and time -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// ps_getdate() +// +// Get the date and time +//-------------------------------------------------------------------------- static char * -ps_getdate(void) +ps_getdate( void ) { - int len; + int len; time_t t; - char *p; + char *p; - t = time((time_t *) 0); - p = ctime(&t); - len = strlen(p); - *(p + len - 1) = '\0'; /* zap the newline character */ + t = time( (time_t *) 0 ); + p = ctime( &t ); + len = strlen( p ); + *( p + len - 1 ) = '\0'; // zap the newline character return p; } @@ -803,477 +824,499 @@ // other devices. # define RISE_FACTOR 0.6 -/*--------------------------------------------------------------------------*\ - * proc_str() - * - * Prints postscript strings. - * N.B. Now unicode only, no string access! - * -\*--------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// proc_str() +// +// Prints postscript strings. +// N.B. Now unicode only, no string access! +// +//-------------------------------------------------------------------------- void -proc_str (PLStream *pls, EscText *args) +proc_str( PLStream *pls, EscText *args ) { - PLFLT *t = args->xform, tt[4]; /* Transform matrices */ - PLFLT theta, shear, stride; /* Rotation angle and shear from the matrix */ - PLFLT ft_ht, offset; /* Font height and offset */ - PLFLT cs,sn; - PSDev *dev = (PSDev *) pls->dev; - PostscriptDocument *doc = (PostscriptDocument *) pls->psdoc; - char *font, esc; - FontStyle style; - FontWeight weight; - /* Be generous. Used to store lots of font changes which take - * 3 characters per change.*/ - #define PROC_STR_STRING_LENGTH 1000 - char *strp, str[PROC_STR_STRING_LENGTH], *cur_strp, - cur_str[PROC_STR_STRING_LENGTH]; - float font_factor = 1.4; - PLINT clxmin, clxmax, clymin, clymax; /* Clip limits */ - PLINT clipx[4],clipy[4]; /* Current clip limits */ + PLFLT *t = args->xform, tt[4]; // Transform matrices + PLFLT theta, shear, stride; // Rotation angle and shear from the matrix + PLFLT ft_ht, offset; // Font height and offset + PLFLT cs, sn; + PSDev *dev = (PSDev *) pls->dev; + PostscriptDocument *doc = (PostscriptDocument *) pls->psdoc; + char *font, esc; + FontStyle style; + FontWeight weight; + // Be generous. Used to store lots of font changes which take + // 3 characters per change. + #define PROC_STR_STRING_LENGTH 1000 + char *strp, str[PROC_STR_STRING_LENGTH], *cur_strp, + cur_str[PROC_STR_STRING_LENGTH]; + float font_factor = 1.4; + PLINT clxmin, clxmax, clymin, clymax; // Clip limits + PLINT clipx[4], clipy[4]; // Current clip limits - PLFLT scale = 1., up = 0.; /* Font scaling and shifting parameters */ + PLFLT scale = 1., up = 0.; // Font scaling and shifting parameters - double lineSpacing, xAdvance, ymintmp, ymaxtmp, ymin, ymax, xmin, xmax; - PLINT xx[4], yy[4]; + double lineSpacing, xAdvance, ymintmp, ymaxtmp, ymin, ymax, xmin, xmax; + PLINT xx[4], yy[4]; - FT_Data *FT; + FT_Data *FT; - /* unicode only! so test for it. */ - if (args->unicode_array_len>0) - { + // unicode only! so test for it. + if ( args->unicode_array_len > 0 ) + { + FT = (FT_Data *) pls->FT; + int j, s, f; + char *fonts[PROC_STR_STRING_LENGTH]; + FontStyle styles[PROC_STR_STRING_LENGTH]; + FontWeight weights[PROC_STR_STRING_LENGTH]; + const PLUNICODE *cur_text; + PLUNICODE fci; + unsigned char fontfamily, fontstyle, fontweight; + PLFLT old_sscale, sscale, old_soffset, soffset, dup; + PLINT level = 0; - FT = (FT_Data *) pls->FT; - int j,s,f; - char *fonts[PROC_STR_STRING_LENGTH]; - FontStyle styles[PROC_STR_STRING_LENGTH]; - FontWeight weights[PROC_STR_STRING_LENGTH]; - const PLUNICODE *cur_text; - PLUNICODE fci; - unsigned char fontfamily, fontstyle, fontweight; - PLFLT old_sscale, sscale, old_soffset, soffset, dup; - PLINT level = 0; + // translate from unicode into type 1 font index. + // + // Choose the font family, style, variant, and weight using + // the FCI (font characterization integer). + // - /* translate from unicode into type 1 font index. */ - /* - * Choose the font family, style, variant, and weight using - * the FCI (font characterization integer). - */ + plgesc( &esc ); + plgfci( &fci ); + plP_fci2hex( fci, &fontfamily, PL_FCI_FAMILY ); + plP_fci2hex( fci, &fontstyle, PL_FCI_STYLE ); + plP_fci2hex( fci, &fontweight, PL_FCI_WEIGHT ); + font = (char *) FamilyLookup[fontfamily]; + weight = WeightLookup[fontweight]; + style = StyleLookup[fontstyle]; + // Need to add some error checking here + if ( false ) + { + fprintf( stderr, "fci = 0x%x, font name pointer = NULL \n", fci ); + plabort( "proc_str: FCI inconsistent with TrueTypeLookup; " + "internal PLplot error" ); + return; + } + //pldebug("proc_str", "fci = 0x%x, font name = %s\n", fci, font); + cur_text = args->unicode_array; + for ( f = s = j = 0; j < args->unicode_array_len; j++ ) + { + if ( cur_text[j] & PL_FCI_MARK ) + { + // process an FCI by saving it and escaping cur_str + // with an escff to make it a 2-character escape + // that is not used in legacy Hershey code + // + if ( ( f < PROC_STR_STRING_LENGTH ) && ( s + 3 < PROC_STR_STRING_LENGTH ) ) + { + plP_fci2hex( cur_text[j], &fontfamily, PL_FCI_FAMILY ); + plP_fci2hex( cur_text[j], &fontstyle, PL_FCI_STYLE ); + plP_fci2hex( cur_text[j], &fontweight, PL_FCI_WEIGHT ); + fonts[f] = (char *) FamilyLookup[fontfamily]; + weights[f] = WeightLookup[fontweight]; + styles[f] = StyleLookup[fontstyle]; + if ( fonts[f] == NULL ) + { + fprintf( stderr, "string-supplied FCI = 0x%x, font name pointer = NULL \n", cur_text[j] ); + plabort( "proc_str: string-supplied FCI inconsistent with font lookup;" ); + return; + } + //pldebug("proc_str", "string-supplied FCI = 0x%x, font name = %s\n", cur_text[j], fonts[f]); + cur_str[s++] = esc; + cur_str[s++] = 'f'; + cur_str[s++] = 'f'; + f++; + } + } + else if ( s + 1 < PROC_STR_STRING_LENGTH ) + { + s += ucs4_to_utf8( cur_text[j], &cur_str[s] ); + //pldebug("proc_str", "unicode = 0x%x, type 1 code = %d\n", +// cur_text[j], cur_str[j]); + } + } + cur_str[s] = '\0'; - plgesc(&esc); - plgfci(&fci); - plP_fci2hex(fci,&fontfamily,PL_FCI_FAMILY); - plP_fci2hex(fci,&fontstyle,PL_FCI_STYLE); - plP_fci2hex(fci,&fontweight,PL_FCI_WEIGHT); - font = (char *) FamilyLookup[fontfamily]; - weight = WeightLookup[fontweight]; - style = StyleLookup[fontstyle]; - /* Need to add some error checking here */ - if (false) { - fprintf(stderr, "fci = 0x%x, font name pointer = NULL \n", fci); - plabort("proc_str: FCI inconsistent with TrueTypeLookup; " - "internal PLplot error"); - return; - } - /*pldebug("proc_str", "fci = 0x%x, font name = %s\n", fci, font);*/ - cur_text = args->unicode_array; - for (f=s=j=0; j < args->unicode_array_len; j++) { - if (cur_text[j] & PL_FCI_MARK) { - /* process an FCI by saving it and escaping cur_str - * with an escff to make it a 2-character escape - * that is not used in legacy Hershey code - */ - if ((f < PROC_STR_STRING_LENGTH) && (s+3 < PROC_STR_STRING_LENGTH)) { - plP_fci2hex(cur_text[j],&fontfamily,PL_FCI_FAMILY); - plP_fci2hex(cur_text[j],&fontstyle,PL_FCI_STYLE); - plP_fci2hex(cur_text[j],&fontweight,PL_FCI_WEIGHT); - fonts[f] = (char *) FamilyLookup[fontfamily]; - weights[f] = WeightLookup[fontweight]; - styles[f] = StyleLookup[fontstyle]; - if (fonts[f] == NULL) { - fprintf(stderr, "string-supplied FCI = 0x%x, font name pointer = NULL \n", cur_text[j]); - plabort("proc_str: string-supplied FCI inconsistent with font lookup;"); - return; - } - /*pldebug("proc_str", "string-supplied FCI = 0x%x, font name = %s\n", cur_text[j], fonts[f]);*/ - cur_str[s++] = esc; - cur_str[s++] = 'f'; - cur_str[s++] = 'f'; - f++; - } - } - else if (s+1 < PROC_STR_STRING_LENGTH) { - s += ucs4_to_utf8(cur_text[j],&cur_str[s]); - /*pldebug("proc_str", "unicode = 0x%x, type 1 code = %d\n", - cur_text[j], cur_str[j]);*/ - } - } - cur_str[s] = '\0'; - - /* finish previous polyline */ - - dev->xold = PL_UNDEFINED; - dev->yold = PL_UNDEFINED; - - /* Determine the font height */ - ft_ht = pls->chrht * 72.0/25.4; /* ft_ht in points, ht is in mm */ - - - /* The transform matrix has only rotations and shears; extract them */ + // finish previous polyline + + dev->xold = PL_UNDEFINED; + dev->yold = PL_UNDEFINED; + + // Determine the font height + ft_ht = pls->chrht * 72.0 / 25.4; // ft_ht in points, ht is in mm + + + // The transform matrix has only rotations and shears; extract them plRotationShear( t, &theta, &shear, &stride ); - cs = cos(theta); - sn = sin(theta); - tt[0] = t[0]*cs + t[2]*sn; - tt[1] = t[1]*cs + t[3]*sn; - tt[2] = -t[0]*sn + t[2]*cs; - tt[3] = -t[1]*sn + t[3]*cs; - - /* - * Reference point conventions: - * If base = 0, it is aligned with the center of the text box - * If base = 1, it is aligned with the baseline of the text box - * If base = 2, it is aligned with the top of the text box - * - * Currently plplot only uses base=0 - * Postscript uses base=1 - * - * We must calculate the difference between the two and apply the offset. - */ - - if (args->base == 2) /* not supported by plplot */ - offset = ENLARGE * ft_ht / 2.; /* half font height */ - else if (args->base == 1) - offset = 0.; - else - offset = -ENLARGE * ft_ht / 2.; - - /* Determine the adjustment for page orientation */ - theta -= PI/2.*pls->diorot; - args->y += (int) (offset*cos(theta)); - args->x -= (int) (offset*sin(theta)); - - /* ps driver is rotated by default */ - plRotPhy(ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, - &(args->x), &(args->y)); - - /* Correct for the fact ps driver uses landscape by default */ - theta += PI/2.; - - /* Output */ - /* Set clipping */ - clipx[0]=pls->clpxmi; - clipx[2]=pls->clpxma; - clipy[0]=pls->clpymi; - clipy[2]=pls->clpyma; - clipx[1]=clipx[2]; - clipy[1]=clipy[0]; - clipx[3]=clipx[0]; - clipy[3]=clipy[2]; - difilt(clipx, clipy, 4, &clxmin, &clxmax, &clymin, &clymax); - plRotPhy(ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, - &clipx[0], &clipy[0]); - plRotPhy(ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, - &clipx[1], &clipy[1]); - plRotPhy(ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, - &clipx[2], &clipy[2]); - plRotPhy(ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, - &clipx[3], &clipy[3]); - doc->osBody() << " gsave " << clipx[0] << " " << clipy[0] << " " << - clipx[1] << " " << clipy[1] << " " << clipx[2] << " " << - clipy[2] << " " << clipx[3] << " " << clipy[3] << " CL\n"; - - /* move to string reference point */ - doc->osBody() << " " << args->x << " " << args->y << " M\n"; - - /* Save the current position and set the string rotation */ - doc->osBody() << "gsave " << TRMFLT(theta*180./PI) << " R\n"; + cs = cos( theta ); + sn = sin( theta ); + tt[0] = t[0] * cs + t[2] * sn; + tt[1] = t[1] * cs + t[3] * sn; + tt[2] = -t[0] * sn + t[2] * cs; + tt[3] = -t[1] * sn + t[3] * cs; - doc->osBody() << "[" << TRMFLT(tt[0]) << " " << TRMFLT(tt[2]) << " " << TRMFLT(tt[1]) - << " " << TRMFLT(tt[3]) << " 0 0] concat\n"; - - xmax = 0; - /* Dummy run through the string first to work out the - * length, including any font changes */ - cur_strp = cur_str; - f = 0; - do { - strp = str; - - if (*cur_strp == esc) { - cur_strp++; - - if (*cur_strp == esc) { /* <esc><esc> */ - *strp++ = *cur_strp++; - } - else if (*cur_strp == 'f') { - cur_strp++; - if (*cur_strp++ != 'f') { - /* escff occurs because of logic above. But any suffix - * other than "f" should never happen. */ - plabort("proc_str, internal PLplot logic error;" - "wrong escf escape sequence"); - return; - } - font = fonts[f]; - style = styles[f]; - weight = weights[f]; - f++; - continue; - } - else switch (*cur_strp++) { - - case 'd': //subscript - case 'D': - plP_script_scale( FALSE, &level, - &old_sscale, &sscale, &old_soffset, &soffset ); - scale = sscale; - // The correction for the difference in magnitude - // between the baseline and middle coordinate systems - // for subscripts should be - // -0.5*(base font size - superscript/subscript font size). - dup = -0.5 * ( 1.0 - sscale ); - up = -font_factor * ENLARGE * ft_ht * (RISE_FACTOR * soffset + dup); - break; - - case 'u': //superscript - case 'U': - plP_script_scale( TRUE, &level, - &old_sscale, &sscale, &old_soffset, &soffset ); - scale = sscale; - // The correction for the difference in magnitude - // between the baseline and middle coordinate systems - // for superscripts should be - // 0.5*(base font size - superscript/subscript font size). - dup = 0.5 * ( 1.0 - sscale ); - up = font_factor * ENLARGE * ft_ht * (RISE_FACTOR * soffset + dup); - break; - - /* ignore the next sequences */ - - case '+': - case '-': - case 'b': - case 'B': - plwarn("'+', '-', and 'b/B' text escape sequences not processed."); - break; - } - } - - /* copy from current to next token, adding a postscript escape - * char '\' if necessary - */ - while(*cur_strp && *cur_strp != esc) { - *strp++ = *cur_strp++; - } - *strp = '\0'; - - // if(fabs(up)<0.001) up = 0.; /* Watch out for small differences */ - - /* Set the font size */ - doc->setFont(font,style,weight); - doc->setFontSize(font_factor*ENLARGE*ft_ht*scale); - doc->get_dimensions((const char *)str, &lineSpacing, &xAdvance, &ymintmp, &ymaxtmp); - xmax += xAdvance; + // + // Reference point conventions: + // If base = 0, it is aligned with the center of the text box + // If base = 1, it is aligned with the baseline of the text box + // If base = 2, it is aligned with the top of the text box + // + // Currently plplot only uses base=0 + // Postscript uses base=1 + // + // We must calculate the difference between the two and apply the offset. + // - }while(*cur_strp); - - // Use the length of the string to calculate offset - // Also used later for bounding box - xmin = -xmax*args->just; - xmax = xmin; - ymin = 0; - ymax = 0; + if ( args->base == 2 ) // not supported by plplot + offset = ENLARGE * ft_ht / 2.; // half font height + else if ( args->base == 1 ) + offset = 0.; + else + offset = -ENLARGE * ft_ht / 2.; - /* Reset parameters */ + // Determine the adjustment for page orientation + theta -= PI / 2. * pls->diorot; + args->y += (int) ( offset * cos( theta ) ); + args->x -= (int) ( offset * sin( theta ) ); + + // ps driver is rotated by default + plRotPhy( ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, + &( args->x ), &( args->y ) ); + + // Correct for the fact ps driver uses landscape by default + theta += PI / 2.; + + // Output + // Set clipping + clipx[0] = pls->clpxmi; + clipx[2] = pls->clpxma; + clipy[0] = pls->clpymi; + clipy[2] = pls->clpyma; + clipx[1] = clipx[2]; + clipy[1] = clipy[0]; + clipx[3] = clipx[0]; + clipy[3] = clipy[2]; + difilt( clipx, clipy, 4, &clxmin, &clxmax, &clymin, &clymax ); + plRotPhy( ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, + &clipx[0], &clipy[0] ); + plRotPhy( ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, + &clipx[1], &clipy[1] ); + plRotPhy( ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, + &clipx[2], &clipy[2] ); + plRotPhy( ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, + &clipx[3], &clipy[3] ); + doc->osBody() << " gsave " << clipx[0] << " " << clipy[0] << " " << + clipx[1] << " " << clipy[1] << " " << clipx[2] << " " << + clipy[2] << " " << clipx[3] << " " << clipy[3] << " CL\n"; + + // move to string reference point + doc->osBody() << " " << args->x << " " << args->y << " M\n"; + + // Save the current position and set the string rotation + doc->osBody() << "gsave " << TRMFLT( theta * 180. / PI ) << " R\n"; + + doc->osBody() << "[" << TRMFLT( tt[0] ) << " " << TRMFLT( tt[2] ) << " " << TRMFLT( tt[1] ) + << " " << TRMFLT( tt[3] ) << " 0 0] concat\n"; + + xmax = 0; + // Dummy run through the string first to work out the + // length, including any font changes + cur_strp = cur_str; + f = 0; + do + { + strp = str; + + if ( *cur_strp == esc ) + { + cur_strp++; + + if ( *cur_strp == esc ) // <esc><esc> + { + *strp++ = *cur_strp++; + } + else if ( *cur_strp == 'f' ) + { + cur_strp++; + if ( *cur_strp++ != 'f' ) + { + // escff occurs because of logic above. But any suffix + // other than "f" should never happen. + plabort( "proc_str, internal PLplot logic error;" + "wrong escf escape sequence" ); + return; + } + font = fonts[f]; + style = styles[f]; + weight = weights[f]; + f++; + continue; + } + else + switch ( *cur_strp++ ) + { + case 'd': //subscript + case 'D': + plP_script_scale( FALSE, &level, + &old_sscale, &sscale, &old_soffset, &soffset ); + scale = sscale; + // The correction for the difference in magnitude + // between the baseline and middle coordinate systems + // for subscripts should be + // -0.5*(base font size - superscript/subscript font size). + dup = -0.5 * ( 1.0 - sscale ); + up = -font_factor * ENLARGE * ft_ht * ( RISE_FACTOR * soffset + dup ); + break; + + case 'u': //superscript + case 'U': + plP_script_scale( TRUE, &level, + &old_sscale, &sscale, &old_soffset, &soffset ); + scale = sscale; + // The correction for the difference in magnitude + // between the baseline and middle coordinate systems + // for superscripts should be + // 0.5*(base font size - superscript/subscript font size). + dup = 0.5 * ( 1.0 - sscale ); + up = font_factor * ENLARGE * ft_ht * ( RISE_FACTOR * soffset + dup ); + break; + + // ignore the next sequences + + case '+': + case '-': + case 'b': + case 'B': + plwarn( "'+', '-', and 'b/B' text escape sequences not processed." ); + break; + } + } + + // copy from current to next token, adding a postscript escape + // char '\' if necessary + // + while ( *cur_strp && *cur_strp != esc ) + { + *strp++ = *cur_strp++; + } + *strp = '\0'; + + // if(fabs(up)<0.001) up = 0.; /* Watch out for small differences */ + + // Set the font size + doc->setFont( font, style, weight ); + doc->setFontSize( font_factor * ENLARGE * ft_ht * scale ); + doc->get_dimensions( (const char *) str, &lineSpacing, &xAdvance, &ymintmp, &ymaxtmp ); + xmax += xAdvance; + } while ( *cur_strp ); + + // Use the length of the string to calculate offset + // Also used later fo... [truncated message content] |
From: <hba...@us...> - 2011-08-01 18:31:07
|
Revision: 11835 http://plplot.svn.sourceforge.net/plplot/?rev=11835&view=rev Author: hbabcock Date: 2011-08-01 18:30:57 +0000 (Mon, 01 Aug 2011) Log Message: ----------- Changes for the 5.9.9 release. Modified Paths: -------------- trunk/OLD-README.release trunk/README.release Modified: trunk/OLD-README.release =================================================================== --- trunk/OLD-README.release 2011-08-01 17:57:28 UTC (rev 11834) +++ trunk/OLD-README.release 2011-08-01 18:30:57 UTC (rev 11835) @@ -1,3 +1,1302 @@ +PLplot Release 5.9.8 +~~~~~~~~~~~~~~~~~~~~ +This is a development release of PLplot. It represents the ongoing efforts +of the community to improve the PLplot plotting package. Development +releases in the 5.9.x series will be available every few months. The next +stable release will be 5.10.0. + + If you encounter a problem that is not already documented in the +PROBLEMS file or on our bugtracker, then please send bug reports to PLplot +developers via the mailing lists at +http://sourceforge.net/mail/?group_id=2915 (preferred) or on our bugtracker +at http://sourceforge.net/tracker/?group_id=2915&atid=102915. + + Please see the license under which this software is distributed +(LGPL), and the disclaimer of all warranties, given in the COPYING.LIB +file. + +Official Notices for Users. + +(5.9.8) For unicode-aware devices we now follow what is done for the +Hershey font case for epsilon, theta, and phi. This means the #ge, +#gh, and #gf escapes now give users the Greek lunate epsilon, the +ordinary Greek lower case theta, and the Greek symbol phi for Unicode +fonts just like has occurred since the dawn of PLplot history for the +Hershey font case. Previously these legacy escapes were assigned to +ordinary Greek lower-case epsilon, the Greek symbol theta (= script +theta), and the ordinary Greek lower case phi for unicode fonts +inconsistently with what occurred for Hershey fonts. This change gets +rid of this inconsistency, that is the #g escapes should give the best +unicode approximation to the Hershey glyph result that is possible for +unicode-aware devices. + +In general we encourage users of unicode-aware devices who might +dislike the Greek glyph Hershey-lookalike choices they get with the +legacy #g escapes to use instead either PLplot unicode escapes (e.g., +"#[0x03b5]" for ordinary Greek lower-case epsilon, see page 3 of +example 23) or better yet, UTF-8 strings (e.g., "ε") to specify +exactly what unicode glyph they want. + +(5.9.8) The full set of PLplot constants have been made available to +our Fortran 95 users as part of the plplot module. This means those +users will have to remove any parameter statements where they have +previously defined the PLplot constants (whose names typically start +with "PL_" for themselves. For a complete list of the affected +constants, see the #defines in swig-support/plplotcapi.i which are +used internally to help generate the plplot module. See also Index +item 2.51 below. + +(5.9.8) There has been widespread const modifier changes in the API +for libplplotd and libplplotcxxd. Those backwards-incompatible API +changes are indicated in the usual way by a soversion bump in those +two libraries which will force all apps and libraries that depend on +those two libraries to be rebuilt. + +Specifically, we have changed the following arguments in the C library +(libplplotd) case + +type * name1 ==> const type * name1 +type * name2 ==> const type ** name2 + +and the following arguments in the C++ library (libplplotcxxd) case + +type * name1 ==> const type * name1 +type * name1 ==> const type * const * name2 + +where name1 is the name of a singly dimensioned array whose values are +not changed internally by the PLplot libraries and name2 is the name +of a doubly dimensioned array whose values are not changed internally +by the PLplot libraries. + +The general documentation and safety justification for such const +modifier changes to our API is given in +http://www.cprogramming.com/tutorial/const_correctness.html. +Essentially, the above const modifier changes constitute our guarantee +that the associated arrays are not changed internally by the PLplot +libraries. + +Although it is necessary to rebuild all apps and libraries that depend +on libplplotd and/or libplplotcxxd, that rebuild should be possible +with unchanged source code without build errors in all cases. For C +apps and libraries (depending on libplplotd) there will be additional +build warnings due to a limitation in the C standard discussed at +http://c-faq.com/ansi/constmismatch.html unless all doubly dimensioned +arrays (but not singly dimensioned) are explicitly cast to (const type +**). However, such source code changes will not be necessary to avoid +warning messages for the C++ (libplplotcxxd) change because of the +double use of const in the above "const type * const * name2" change. + +(5.9.8) The plarc API has changed in release 5.9.8. The plarc API now +has a rotation parameter which will eventually allow for rotated arcs. +PLplot does not currently support rotated arcs, but the plarc function +signature has been modified to avoid changing the API when this +functionality is added. + +(5.9.6) We have retired the pbm driver containing the pbm (actually +portable pixmap) file device. This device is quite primitive and +poorly maintained. It ignores unicode fonts (i.e., uses the Hershey +font fallback), falls back to ugly software fills, doesn't support +alpha transparency, etc. It also has a serious run-time issue with +example 2 (double free detected by glibc) which probably indicates +some fundamental issue with the 100 colours in cmap0 for that +example. For those who really need portable pixmap results, we suggest +using the ImageMagick convert programme, e.g., "convert +examples/x24c01.pngqt test.ppm" or "convert examples/x24c01.pngcairo +test.ppm" to produce good-looking portable pixmap results from our +best png device results. + +(5.9.6) We have retired the linuxvga driver containing the linuxvga +interactive device. This device is quite primitive, difficult to +test, and poorly maintained. It ignores unicode fonts (i.e., uses the +Hershey font fallback), falls back to ugly software fills, doesn't +support alpha transparency, etc. It is Linux only, can only be run as +root, and svgalib (the library used by linuxsvga) is not supported by +some mainstream (e.g., Intel) chipsets. All of these characteristics +make it difficult to even test this device much less use it for +anything serious. Finally, it has had a well-known issue for years +(incorrect colours) which has never been fixed indicating nobody is +interested in maintaining this device. + +(5.9.6) We have retired our platform support of djgpp that used to +reside in sys/dos/djgpp. The developer (Andrew Roach) who used to +maintain those support files for djgpp feels that the djgpp platform +is no longer actively developed, and he no longer uses djgpp himself. + +(5.9.6) We have changed plpoin results for ascii codes 92, 94, and 95 +from centred dot, degree symbol, and centred dot glyphs to the correct +backslash, caret, and underscore glyphs that are associated with those +ascii indices. This change is consistent with the documentation of +plpoin and solves a long-standing issue with backslash, caret, and +underscore ascii characters in character strings used for example by +pl[mp]tex. Those who need access to a centred dot with plpoin should +use index 1. The degree symbol is no longer accessible with plpoin, +but it is available in ordinary text input to PLplot as Hershey escape +"#(718)", where 718 is the Hershey index of the degree symbol, unicode +escape "#[0x00B0]" where 0x00B0 is the unicode index for the degree +symbol or direct UTF8 unicode string "°". + +(5.9.6) We have retired the gcw device driver and the related gnome2 +and pygcw bindings since these are unmaintained and there are good +replacements. These components of PLplot were deprecated as of +release 5.9.3. A good replacement for the gcw device is either the +xcairo or qtwidget device. A good replacement for the gnome2 bindings +is the externally supplied XDrawable or Cairo context associated with +the xcairo device and the extcairo device (see +examples/c/README.cairo). A good replacement for pygcw is our new +pyqt4 bindings for PLplot. + +(5.9.6) We have deprecated support for the python Numeric array +extensions. Numeric is no longer maintained and users of Numeric are +advised to migrate to numpy. Numpy has been the standard for PLplot +for some time. If numpy is not present PLplot will now disable python +by default. If you still require Numeric support in the short term +then set USE_NUMERIC to ON in cmake. The PLplot support for Numeric +will be dropped in a future release. + +(5.9.5) We have removed pyqt3 access to PLplot and replaced it by +pyqt4 access to PLplot (see details below). + +(5.9.5) The only method of specifying a non-default compiler (and +associated compiler options) that we support is the environment +variable approach, e.g., + +export CC='gcc -g -fvisibility=hidden' +export CXX='g++ -g -fvisibility=hidden' +export FC='gfortran -g -fvisibility=hidden' + +All other CMake methods of specifying a non-default compiler and +associated compiler options will not be supported until CMake bug 9220 +is fixed, see discussion below of the soft-landing re-implementation +for details. + +(5.9.5) We have retired the hpgl driver (containing the hp7470, +hp7580, and lj_hpgl devices), the impress driver (containing the imp +device), the ljii driver (containing the ljii and ljiip devices), and +the tek driver (containing the conex, mskermit, tek4107, tek4107f, +tek4010, tek4010f, versaterm, vlt, and xterm devices). Retirement +means we have removed the build options which would allow these +devices to build and install. Recent tests have shown a number of +run-time issues (hpgl, impress, and ljii) or build-time issues (tek) +with these devices, and as far as we know there is no more user +interest in them. Therefore, we have decided to retire these devices +rather than fix them. + +(5.9.4) We have deprecated the pbm device driver (containing the pbm +device) because glibc detects a catastrophic double free. + +(5.9.3) Our build system requires CMake version 2.6.0 or higher. + +(5.9.3) We have deprecated the gcw device driver and the related +gnome2 and pygcw bindings since these are essentially unmaintained. +For example, the gcw device and associated bindings still depends on +the plfreetype approach for accessing unicode fonts which has known +issues (inconsistent text offsets, inconvenient font setting +capabilities, and incorrect rendering of CTL languages). To avoid +these issues we advise using the xcairo device and the externally +supplied XDrawable or Cairo context associated with the xcairo device +and the extcairo device (see examples/c/README.cairo) instead. If you +still absolutely must use -dev gcw or the related gnome2 or pygcw +bindings despite the known problems, then they can still be accessed +by setting PLD_gcw, ENABLE_gnome2, and/or ENABLE_pygcw to ON. + +(5.9.3) We have deprecated the gd device driver which implements the +png, jpeg, and gif devices. This device driver is essentially +unmaintained. For example, it still depends on the plfreetype approach +for accessing unicode fonts which has known issues (inconsistent text +offsets, inconvenient font setting capabilities, and incorrect +rendering of CTL languages). To avoid these issues for PNG format, we +advise using the pngcairo or pngqt devices. To avoid these issues for +the JPEG format, we advise using the jpgqt device. PNG is normally +considered a better raster format than GIF, but if you absolutely +require GIF format, we advise using the pngcairo or pngqt devices and +then downgrading the results to the GIF format using the ImageMagick +"convert" application. For those platforms where libgd (the +dependency of the gd device driver) is accessible while the required +dependencies of the cairo and/or qt devices are not accessible, you +can still use these deprecated devices by setting PLD_png, PLD_jpeg, +or PLD_gif to ON. + +(5.9.3) We have re-enabled the tk, itk, and itcl components of PLplot +by default that were disabled by default as of release 5.9.1 due to +segfaults. The cause of the segfaults was a bug (now fixed) in how +pthread support was implemented for the Tk-related components of +PLplot. + +(5.9.2) We have set HAVE_PTHREAD (now called PL_HAVE_PTHREAD as of +release 5.9.8) to ON by default for all platforms other than Darwin. +Darwin will follow later once it appears the Apple version of X +supports it. + +(5.9.1) We have removed our previously deprecated autotools-based +build system. Instead, use the CMake-based build system following the +directions in the INSTALL file. + +(5.9.1) We no longer support Octave-2.1.73 which has a variety of +run-time issues in our tests of the Octave examples on different +platforms. In contrast our tests show we get good run-time results +with all our Octave examples for Octave-3.0.1. Also, that is the +recommended stable version of Octave at +http://www.gnu.org/software/octave/download.html so that is the only +version of Octave we support at this time. + +(5.9.1) We have decided for consistency sake to change the PLplot +stream variables plsc->vpwxmi, plsc->vpwxma, plsc->vpwymi, and +plsc->vpwyma and the results returned by plgvpw to reflect the exact +window limit values input by users using plwind. Previously to this +change, the stream variables and the values returned by plgvpw +reflected the internal slightly expanded range of window limits used +by PLplot so that the user's specified limits would be on the graph. +Two users noted this slight difference, and we agree with them it +should not be there. Note that internally, PLplot still uses the +expanded ranges so most users results will be identical. However, you +may notice some small changes to your plot results if you use these +stream variables directly (only possible in C/C++) or use plgvpw. + +INDEX + +-1. Important changes we should have mentioned in previous release announcements. + +-1.1 Add full bindings and examples for the D language. + +0. Tests made for release 5.9.8 + +1. Changes relative to PLplot 5.9.7 (the previous development release) + +1.1 The plstring and plstring3 functions have been added +1.2 The pllegend API has been finalized +1.3 Octave bindings now implemented with swig +1.4 Documentation redone for our swig-generated Python and Octave bindings +1.5 Support large polygons +1.6 Complete set of PLplot parameters now available for Fortran + +2. Changes relative to PLplot 5.8.0 (the previous stable release) + +2.1 All autotools-related files have now been removed +2.2 Build system bug fixes +2.3 Build system improvements +2.4 Implement build-system infrastructure for installed Ada bindings and +examples +2.5 Code cleanup +2.6 Date / time labels for axes +2.7 Alpha value support +2.8 New PLplot functions +2.9 External libLASi library improvements affecting our psttf device +2.10 Improvements to the cairo driver family +2.11 wxWidgets driver improvements +2.12 pdf driver improvements +2.13 svg driver improvements +2.14 Ada language support +2.15 OCaml language support +2.16 Perl/PDL language support +2.17 Update to various language bindings +2.18 Update to various examples +2.19 Extension of our test framework +2.20 Rename test subdirectory to plplot_test +2.21 Website support files updated +2.22 Internal changes to function visibility +2.23 Dynamic driver support in Windows +2.24 Documentation updates +2.25 libnistcd (a.k.a. libcd) now built internally for -dev cgm +2.26 get-drv-info now changed to test-drv-info +2.27 Text clipping now enabled by default for the cairo devices +2.28 A powerful qt device driver has been implemented +2.29 The PLplot API is now accessible from Qt GUI applications +2.30 NaN / Inf support for some PLplot functions +2.31 Various bug fixes +2.32 Cairo driver improvements +2.33 PyQt changes +2.34 Color Palettes +2.35 Re-implementation of a "soft landing" when a bad/missing compiler is +detected +2.36 Make PLplot aware of LC_NUMERIC locale +2.37 Linear gradients have been implemented +2.38 Cairo Windows driver implemented +2.39 Custom axis labeling implemented +2.40 Universal coordinate transform implemented +2.41 Support for arbitrary storage of 2D user data +2.42 Font improvements +2.42 Alpha value support for plotting in memory. +2.43 Add a Qt device for in memory plotting. +2.44 Add discrete legend capability. +2.45 Add full bindings and examples for the D language. +2.46 The plstring and plstring3 functions have been added +2.47 The pllegend API has been finalized +2.48 Octave bindings now implemented with swig +2.49 Documentation redone for our swig-generated Python and Octave bindings +2.50 Support large polygons +2.51 Complete set of PLplot parameters now available for Fortran +2.52 The plarc function has been added + +-1. Important changes we should have mentioned in previous release announcements. + +-1.1 Add full bindings and examples for the D language. + +As of release 5.9.5 we added full bindings and examples for the D +language. The results for the D examples are generally consistent +with the corresponding C examples which helps to verify the D +bindings. + +Since the release of 5.9.5 it has come to our attention that the +version of gdc supplied with several recent versions of Ubuntu has a +very serious bug on 64-bit systems (see +https://bugs.launchpad.net/ubuntu/+source/gdc-4.2/+bug/235955) which +causes several of the plplot D examples to crash. If this affects you, +you are recommended to disable the d bindings or switch to an +alternative d compiler (the Digital Mars compiler is reported to be +good). + + +0. Tests made for release 5.9.8 + +See +http://www.miscdebris.net/plplot_wiki/index.php?title=Testing_PLplot#Testing_Reports +for a summary table of all testing done for PLplot-5.9.8. + + +1. Changes relative to PLplot 5.9.7 (the previous development release) + +1.1 The plstring and plstring3 functions have been added + +The plstring function largely supersedes plpoin and plsym +because many(!) more glyphs are accessible with plstring. The glyph +is specified with a PLplot user string. As with plmtex and plptex, +the user string can contain FCI escapes to determine the font, UTF-8 +code to determine the glyph or else PLplot escapes for Hershey or +unicode text to determine the glyph. Standard examples 4 and 26 use +plstring. + +The plstring3 function largely supersedes plpoin3 for the same (access +to many more glyphs) reasons. Standard example 18 uses plstring3. + +1.2 The pllegend API has been finalized + +The function pllegend allows users to create a discrete plot legend +with a plotted colored box, line, and/or line of symbols for each +annotated legend entry. The pllegend function was first made +available for 5.9.7. Due to feedback from early adopters of pllegend, +we have now added substantially to the pllegend capabilities. and we +now believe pllegend is ready for prime time. The pllegend +capabilities are documented in our docbook documentation and +demonstrated in standard examples 4, 26, and 33. + +N.B. The current set of changes required a backwards-incompatible +change to the pllegend API. This requires users who tried this new +functionality for 5.9.7 to reprogramme their pllegend calls. Since +the pllegend API was labelled experimental for 5.9.7, we will not be +bumping the soversions of the affected PLplot libraries. + +1.3 Octave bindings now implemented with swig + +Octave is a powerful platform that demands a first-class PLplot +solution, but we were finding it difficult to realize that goal +because we were running up against limitations of the previous +matwrap-generated Octave bindings. Accordingly, a swig-generated +version of the Octave bindings has now been implemented that builds on +the prior matwrapped bindings effort but also extends it with, e.g., +bindings for plstring, plstring3, pllegend, and plcolorbar. These new +octave bindings (which now completely replace the prior matwrapped +bindings) make it possible to run examples 4, 18, 26, and 33 (all of +which have now have been updated to use those functions) and get +consistent results with the corresponding C examples. + +Like the matwrapped bindings before it, the new swig-generated octave +bindings currently do not have a number of the PLplot functions +wrapped (e.g., "plmap") that are needed by standard example 19. +However, because of the power of swig we now have some confidence we +can solve this issue in the future. + +1.4 Documentation redone for our swig-generated Python and Octave bindings + +Through the docstring %feature, swig can generate documentation +strings for certain of the languages it supports (currently Python, +Octave, and Ruby). We have now removed all such hand-crafted swig +documentation data from bindings/swig-support/plplotcapi.i and +replaced it with generated documentation in the file +bindings/swig-support/swig_documentation.i. That file is generated +from doc/docbook/src/api.xml using the perl script +doc/docbook/bin/api2swigdoc.pl. The build system Unix target +"check_swig_documentation" now runs that script and compares results +with bindings/swig-support/swig_documentation.i in the source tree to +make sure that latter file is consistent with any changes that might +have occurred in doc/docbook/src/api.xml. + +The resulting Octave and Python user-documentation (obtained by 'help +<PLplot_command_name>' in Octave and 'print ("%s" % +<PLplot_command_name>.__doc__)' in Python is much more detailed than +what was available before using the hand-crafted documentation. If we +ever decided to generate PLplot bindings for Ruby with swig, this +high-quality user-documentation would be available for that language +as well. + +1.5 Support large polygons + +Previous releases had an implicit limitation with respect to the +number of vertices in a polygon. This was due to the use of statically +defined arrays (to avoid allocating and freeing memory for each polygon +to be drawn). Jos\xE9 Luis Garc\xEDa Pallero found this limitation and +provided patches to eliminate this limitation. The strategy is +that for small polygons, the original statically defined arrays +are used and for large polygons new arrays are allocated and freed. +This strategy has been applied to all relevant source files. + +1.6 Complete set of PLplot parameters now available for Fortran + +The #defines in bindings/swig-support/plplotcapi.i (which are +consistent with those in include/plplot.h) define the complete set of +important PLplot constants (whose names typically start with "PL_"). +We have implemented automatic methods of transforming that complete +set of #defines into Fortran parameters that can be used from either +Fortran 77 or Fortran 95. + +For Fortran 77, the user must insert an + + include 'plplot_parameters.h' + +statement in every function/subroutine/main programme where he expects +to use PLplot constants (whose names typically start with "PL_". (See +examples/f77/*.fm4 for examples of this method). When compiling he +must also insert the appropriate -I option to find this file (in +bindings/f77/ in the source tree and currently in +$prefix/lib/fortran/include/plplot$version in the install tree +although that install location may be subject to change). Note, the +above method does not interfere with existing apps which have +necessarily been forced to define the needed PLplot constants for +themselves. But for future f77 use, the above statement is +more convenient and much less subject to error than a whole bunch of +parameter statements for the required constants. + +For Fortran 95, the complete set of parameters are made available as +part of the plplot module. So access to this complete set of +parameters is automatic wherever the "use plplot" statement is used. +This is extremely convenient for new Fortran 95 apps that use PLplot, +but, in general, changes will have to be made for existing apps. (See +announcement XX above for the details). + +2. Changes relative to PLplot 5.8.0 (the previous stable release) + +2.1 All autotools-related files have now been removed + +CMake is now the only supported build system. It has been tested on +Linux / Unix, Mac OS-X and Windows platforms. + +2.2 Build system bug fixes + +Various fixes include the following: + +Ctest will now work correctly when the build tree path includes symlinks. + +Dependencies for swig generated files fixed so they are not rebuilt every +time make is called. + +Various dependency fixes to ensure that parallel builds (using make -j) +work under unix. + +2.3 Build system improvements + +We now transform link flag results delivered to the CMake environment by +pkg-config into the preferred CMake form of library information. The +practical effect of this improvement is that external libraries in +non-standard locations now have their rpath options set correctly for our +build system both for the build tree and the install tree so you don't have +to fiddle with LD_LIBRARY_PATH, etc. + +2.4 Implement build-system infrastructure for installed Ada bindings and +examples + +Install source files, library information files, and the plplotada library +associated with the Ada bindings. Configure and install the pkg-config file +for the plplotada library. Install the Ada examples and a configured Makefile +to build them in the install tree. + +2.5 Code cleanup + +The PLplot source code has been cleaned up to make consistent use of +(const char *) and (char *) throughout. Some API functions have changed +to use const char * instead of char * to make it clear that the strings +are not modified by the function. The C and C++ examples have been updated +consistent with this. These changes fix a large number of warnings +with gcc-4.2. Note: this should not require programs using PLplot to be +recompiled as it is not a binary API change. + +There has also been some cleanup of include files in the C++ examples +so the code will compile with the forthcoming gcc-4.3. + +2.6 Date / time labels for axes + +PLplot now allows date / time labels to be used on axes. A new option +('d') is available for the xopt and yopt arguments to plbox which +indicates that the axis should be interpreted as a date / time. Similarly +there is a new range of options for plenv to select date / time labels. +The time format is seconds since the epoch (usually 1 Jan 1970). This +format is commonly used on most systems. The C gmtime routine can be +used to calculate this for a given date and time. The format for the +labels is controlled using a new pltimefmt function, which takes a +format string. All formatting is done using the C strftime function. +See documentation for available options on your platform. Example 29 +demonstrates the new capabilities. + +N.B. Our reliance on C library POSIX time routines to (1) convert from +broken-down time to time-epoch, (2) to convert from time-epoch to +broken-down time, and (3) to format results with strftime have proved +problematic for non-C languages which have time routines of variable +quality. Also, it is not clear that even the POSIX time routines are +available on Windows. So we have plans afoot to implement high-quality +versions of (1), (2), and (3) with additional functions to get/set the epoch +in the PLplot core library itself. These routines should work on all C +platforms and should also be uniformly accessible for all our language +bindings. + +WARNING..... Therefore, assuming these plans are implemented, the present +part of our date/time PLplot API that uses POSIX time routines will be +changed. + +2.7 Alpha value support + +PLplot core has been modified to support a transparency or alpha value +channel for each color in color map 0 and 1. In addition a number of new +functions were added the PLplot API so that the user can both set and query +alpha values for color in the two color maps. These functions have the same +name as their non-alpha value equivalents, but with a an "a" added to the +end. Example 30 demonstrates some different ways to use these functions +and the effects of alpha values, at least for those drivers that support alpha +values. This change should have no effect on the device drivers that do not +currently support alpha values. Currently only the cairo, qt, gd, wxwidgets and +aquaterm drivers support alpha values. There are some limitations with the gd +driver due to transparency support in the underlying libgd library. + +2.8 New PLplot functions + +An enhanced version of plimage, plimagefr has been added. This allows images +to be plotted using coordinate transformation, and also for the dynamic range +of the plotted values to be altered. Example 20 has been modified to +demonstrate this new functionality. + +To ensure consistent results in example 21 between different platforms and +language bindings PLplot now includes a small random number generator within +the library. plrandd will return a PLFLT random number in the range 0.0-1.0. +plseed will allow the random number generator to be seeded. + +2.9 External libLASi library improvements affecting our psttf device + +Our psttf device depends on the libLASi library. libLASi-1.1.0 has just been +released at http://sourceforge.net/svn/?group_id=187113 . We recommend +using this latest version of libLASi for building PLplot and the psttf +device since this version of libLASi is more robust against glyph +information returned by pango/cairo/fontconfig that on rare occasions is not +suitable for use by libLASi. + +2.10 Improvements to the cairo driver family + +Jonathan Woithe improved the xcairo driver so that it can optionally be +used with an external user supplied X Drawable. This enables a nice +separation of graphing (PLplot) and window management (Gtk, etc..). Doug +Hunt fixed the bugs that broke the memcairo driver and it is now fully +functional. Additionally, a new extcairo driver was added that will plot +into a user supplied cairo context. + +2.11 wxWidgets driver improvements + +Complete reorganization of the driver code. A new backend was added, based +on the wxGraphicsContext class, which is available for wxWidgets 2.8.4 +and later. This backend produces antialized output similar to the +AGG backend but has no dependency on the AGG library. The basic wxDC +backend and the wxGraphicsContext backend process the text output +on their own, which results in much nicer plots than with the standard +Hershey fonts and is much faster than using the freetype library. New +options were introduced in the wxWidgets driver: + - backend: Choose backend: (0) standard, (1) using AGG library, + (2) using wxGraphicsContext + - hrshsym: Use Hershey symbol set (hrshsym=0|1) + - text: Use own text routines (text=0|1) + - freetype: Use FreeType library (freetype=0|1) +The option "text" changed its meaning, since it enabled the FreeType library +support, while now the option enables the driver's own text routines. + +Some other features were added: + * the wxWidgets driver now correctly clears the background (or parts of it) + * transparency support was added + * the "locate mode" (already available in the xwin and tk driver) was + implemented, where graphics input events are processed and translated + to world coordinates + +2.12 pdf driver improvements + +The pdf driver (which is based on the haru library http://www.libharu.org) +processes the text output now on its own. So far only the Adobe Type1 +fonts are supported. TrueType font support will follow. Full unicode +support will follow after the haru library will support unicode strings. The +driver is now able to produce A4, letter, A5 and A3 pages. The Hershey font +may be used only for symbols. Output can now be compressed, resulting in +much smaller file sizes. +Added new options: + - text: Use own text routines (text=0|1) + - compress: Compress pdf output (compress=0|1) + - hrshsym: Use Hershey symbol set (hrshsym=0|1) + - pagesize: Set page size (pagesize=A4|letter|A3|A5) + +2.13 svg driver improvements + +This device driver has had the following improvements: schema for generated +file now validates properly at http://validator.w3.org/ for the +automatically detected document type of SVG 1.1; -geometry option now works; +alpha channel transparency has been implemented; file familying for +multipage examples has been implemented; coordinate scaling has been +implemented so that full internal PLplot resolution is used; extraneous +whitespace and line endings that were being injected into text in error have +now been removed; and differential correction to string justification is now +applied. + +The result of these improvements is that our SVG device now gives the +best-looking results of all our devices. However, currently you must be +careful of which SVG viewer or editor you try because a number of them have +some bugs that need to be resolved. For example, there is a librsvg bug in +text placement (http://bugzilla.gnome.org/show_bug.cgi?id=525023) that +affects all svg use within GNOME as well as the ImageMagick "display" +application. However, at least the latest konqueror and firefox as well as +inkscape and scribus-ng (but not scribus!) give outstanding looking results +for files generated by our svg device driver. + +2.14 Ada language support + +We now have a complete Ada bindings implemented for PLplot. We also have a +complete set of our standard examples implemented in Ada which give results +that are identical with corresponding results for the C standard examples. +This is an excellent test of a large subset of the Ada bindings. We now +enable Ada by default for our users and request widespread testing of this +new feature. + +2.15 OCaml language support + +Thanks primarily to Hezekiah M. Carty's efforts we now have a complete OCaml +bindings implemented for PLplot. We also have a complete set of our standard +examples implemented in OCaml which give results that are identical with +corresponding results for the C standard examples. This is an excellent test +of a large subset of the OCaml bindings. We now enable OCaml by default for +our users and request widespread testing of this new feature. + +2.16 Perl/PDL language support + +Thanks to Doug Hunt's efforts the external Perl/PDL module, +PDL::Graphics::PLplot version 0.46 available at +http://search.cpan.org/dist/PDL-Graphics-PLplot has been brought up to date +to give access to recently added PLplot API. The instructions for how to +install this module on top of an official PDL release are given in +examples/perl/README.perldemos. Doug has also finished implementing a +complete set of standard examples in Perl/PDL which are part of PLplot and +which produce identical results to their C counterparts if the above updated +module has been installed. Our build system tests the version of +PDL::Graphics::PLplot that is available, and if it is not 0.46 or later, the +list of Perl/PDL examples that are run as part of our standard tests is +substantially reduced to avoid examples that use the new functionality. In +sum, if you use PDL::Graphics::PLplot version 0.46 or later the full +complement of PLplot commands is available to you from Perl/PDL, but +otherwise not. + +2.17 Updates to various language bindings + +A concerted effort has been made to bring all the language bindings up to +date with recently added functions. Ada, C++, f77, f95, Java, OCaml, Octave, +Perl/PDL, Python, and Tcl now all support the common PLplot API (with the +exception of the mapping functions which are not yet implemented for all +bindings due to technical issues.) This is a significant step forward for +those using languages other than C. + +2.18 Updates to various examples + +To help test the updates to the language bindings the examples have been +thoroughly checked. Ada, C, C++, f77, f95, and OCaml now contain a full set +of non-interactive tests (examples 1-31 excluding 14 and 17). Java, Octave, +Python and Tcl are missing example 19 because of the issue with the mapping +functions. The examples have also been checked to ensure consistent results +between different language bindings. Currently there are still some minor +differences in the results for the tcl examples, probably due to rounding +errors. Some of the Tcl examples (example 21) require Tcl version 8.5 for +proper support for NaNs. + +Also new is an option for the plplot_test.sh script to run the examples +using a debugging command. This is enabled using the --debug option. The +default it to use the valgrind memory checker. This has highlighted at +least one memory leaks in PLplot which have been fixed. It is not part +of the standard ctest tests because it can be _very_ slow for a complete +set of language bindings and device drivers. + +2.19 Extension of our test framework + +The standard test suite for PLplot now carries out a comparison of the +stdout output (especially important for example 31 which tests most of our +set and get functions) and PostScript output for different languages as a +check. Thanks to the addition of example 31, the inclusion of examples 14 +and 17 in the test suite and other recent extensions of the other +examples we now have rigourous testing in place for almost the entirety +of our common API. This extensive testing framework has already helped +us track down a number of bugs, and it should make it much easier for us +to maintain high quality for our ongoing PLplot releases. + +2.20 Rename test subdirectory to plplot_test + +This change was necessary to quit clashing with the "make test" target which +now works for the first time ever (by executing ctest). + +2.21 Website support files updated + +Our new website content is generated with PHP and uses CSS (cascaded style +sheets) to implement a consistent style. This new approach demanded lots of +changes in the website support files that are used to generate and upload +our website and which are automatically included with the release. + +2.22 Internal changes to function visibility + +The internal definitions of functions in PLplot have been significantly +tidied up to allow the use of the -fvisibility=hidden option with newer +versions of gcc. This prevents internal functions from being exported +to the user where possible. This extends the existing support for this +on windows. + +2.23 Dynamic driver support in Windows + +An interface based on the ltdl library function calls was established +which allows to open and close dynamic link libraries (DLL) during +run-time and call functions from these libraries. As a consequence +drivers can now be compiled into single DLLs separate from the core +PLplot DLL also in Windows. The cmake option ENABLE_DYNDRIVERS is now +ON by default for Windows if a shared PLplot library is built. + +2.24 Documentation updates + +The DocBook documentation has been updated to include many of the +C-specific functions (for example plAlloc2dGrid) which are not part +of the common API, but are used in the examples and may be helpful +for PLplot users. + +2.25 libnistcd (a.k.a. libcd) now built internally for -dev cgm + +CGM format is a long-established (since 1987) open standard for vector +graphics that is supported by w3c (see http://www.w3.org/Graphics/WebCGM/). +PLplot has long had a cgm device driver which depended on the (mostly) +public domain libcd library that was distributed in the mid 90's by National +Institute of Standards and Technology (NIST) and which is still available +from http://www.pa.msu.edu/ftp/pub/unix/cd1.3.tar.gz. As a convenience +to our -dev cgm users, we have brought that +source code in house under lib/nistcd and now build libnistcd routinely +as part of our ordinary builds. The only changes we have made to the +cd1.3 source code is visibility changes in cd.h and swapping the sense of +the return codes for the test executables so that 0 is returned on success +and 1 on failure. If you want to test libnistcd on your platform, +please run + +make test_nistcd + +in the top-level build tree. (That tests runs all the test executables +that are built as part of cd1.3 and compares the results that are generated +with the *.cgm files that are supplied as part of cd1.3.) + +Two applications that convert and/or display CGM results on Linux are +ralcgm (which is called by the ImageMagick convert and display applications) +and uniconvertor. + +Some additional work on -dev cgm is required to implement antialiasing and +non-Hershey fonts, but both those should be possible using libnistcd according +to the text that is shown by lib/nistcd/cdtext.cgm and lib/nistcd/cdexp1.cgm. + +2.26 get-drv-info now changed to test-drv-info + +To make cross-building much easier for PLplot we now configure the *.rc +files that are used to describe our various dynamic devices rather than +generating the required *.rc files with get-drv-info. We have changed the +name of get-drv-info to test-drv-info. That name is more appropriate +because that executable has always tested dynamic loading of the driver +plug-ins as well as generating the *.rc files from the information gleaned +from that dynamic loading. Now, we simply run test-drv-info as an option +(defaults to ON unless cross-building is enabled) and compare the resulting +*.rc file with the one configured by cmake to be sure the dynamic device +has been built correctly. + +2.27 Text clipping now enabled by default for the cairo devices + +When correct text clipping was first implemented for cairo devices, it was +discovered that the libcairo library of that era (2007-08) did that clipping +quite inefficiently so text clipping was disabled by default. Recent tests +of text clipping for the cairo devices using libcairo 1.6.4 (released in +2008-04) shows text clipping is quite efficient now. Therefore, it is now +enabled by default. If you notice a significant slowdown for some libcairo +version prior to 1.6.4 you can use the option -drvopt text_clipping=0 for +your cairo device plots (and accept the improperly clipped text results that +might occur with that option). Better yet, use libcairo 1.6.4 or later. + +2.28 A powerful qt device driver has been implemented + +Thanks to the efforts of Alban Rochel of the QSAS team, we now have a new qt +device driver which delivers the following 9 (!) devices: qtwidget, bmpqt, +jpgqt, pngqt, ppmqt, tiffqt, epsqt, pdfqt, and svgqt. qtwidget is an +elementary interactive device where, for now, the possible interactions +consist of resizing the window and right clicking with the mouse (or hitting +<return> to be consistent with other PLplot interactive devices) to control +paging. The qtwidget overall size is expressed in pixels. bmpqt, jpgqt, +pngqt, ppmqt, and tiffqt are file devices whose overall sizes are specified +in pixels and whose output is BMP (Windows bitmap), JPEG, PNG, PPM (portable +pixmap), and TIFF (tagged image file format) formatted files. epsqt, pdfqt, +svgqt are file devices whose overall sizes are specified in points (1/72 of +an inch) and whose output is EPS (encapsulated PostScript), PDF, and SVG +formatted files. The qt device driver is based on the powerful facilities +of Qt4 so all qt devices implement variable opacity (alpha channel) effects +(see example 30). The qt devices also use system unicode fonts, and deal +with CTL (complex text layout) languages automatically without any +intervention required by the user. (To show this, try qt device results +from examples 23 [mathematical symbols] and 24 [CTL languages].) + +Our exhaustive Linux testing of the qt devices (which consisted of detailed +comparisons for all our standard examples between qt device results and the +corresponding cairo device results) indicates this device driver is mature, +but testing on other platforms is requested to confirm that maturity. Qt-4.5 +(the version we used for most of our tests) has some essential SVG +functionality so we recommend that version (downloadable from +http://www.qtsoftware.com/downloads for Linux, Mac OS X, and Windows) for +svgqt. One of our developers found that pdfqt was orders of magnitude +slower than the other qt devices for Qt-4.4.3 on Ubuntu 8.10 installed on a +64 bit box. That problem was completely cured by moving to the downloadable +Qt-4.5 version. However, we have also had good Qt-4.4.3 pdfqt reports on +other platforms. One of our developers also found that all first pages of +examples were black for just the qtwidget device for Qt-4.5.1 on Mac OS X. +From the other improvements we see in Qt-4.5.1 relative to Qt-4.4.3 we +assume this black first page for qtwidget problem also exists for Qt-4.4.3, +but we haven't tested that combination. + +In sum, Qt-4.4.3 is worth trying if it is already installed on your machine, +but if you run into any difficulty with it please switch to Qt-4.5.x (once +Qt-4.5.x is installed all you have to do is to put the 4.5.x version of +qmake in your path, and cmake does the rest). If the problem persists for +Qt-4.5, then it is worth reporting a qt bug. + +2.29 The PLplot API is now accessible from Qt GUI applications + +This important new feature has been implemented by Alban Rochel of the QSAS +team as a spin-off of the qt device driver project using the extqt device +(which constitutes the tenth qt device). See examples/c++/README.qt_example +for a brief description of a simple Qt example which accesses the PLplot API +and which is built in the installed examples tree using the pkg-config +approach. Our build system has been enhanced to configure the necessary +plplotd-qt.pc file. + +2.30 NaN / Inf support for some PLplot functions + +Some PLplot now correctly handle Nan or Inf values in the data to be plotted. +Line plotting (plline etc) and image plotting (plimage, plimagefr) will +now ignore NaN / Inf values. Currently some of the contour plotting / 3-d +routines do not handle NaN / Inf values. This functionality will +depend on whether the language binding used supports NaN / Inf values. + +2.31 Various bug fixes + +Various bugs in the 5.9.3 release have been fixed including: + +- Include missing file needed for the aqt driver on Mac OS X +- Missing library version number for nistcd +- Fixes for the qt examples with dynamic drivers disabled +- Fixes to several tcl examples so they work with plserver +- Fix pkg-config files to work correctly with Debug / Release build types set +- Make fortran command line argument parsing work with shared libraries on Windows + +2.32 Cairo driver improvements + +Improvements to the cairo driver to give better results for bitmap +formats when used with anti-aliasing file viewers. + +2.33 PyQt changes + +Years ago we got a donation of a hand-crafted pyqt3 interface to PLplot +(some of the functions in plplot_widgetmodule.c in bindings/python) and a +proof-of-concept example (prova.py and qplplot.py in examples/python), but +this code did not gain any developer interest and was therefore not +understood or maintained. Recently one of our core developers has +implemented a sip-generated pyqt4 interface to PLplot (controlled by +plplot_pyqt4.sip in bindings/qt_gui/pyqt4) that builds without problems as a +python extension module, and a good-looking pyqt4 example (pyqt4_example.py +in examples/python) that works well. Since this pyqt4 approach is +maintained by a PLplot developer it appears to have a good future, and we +have therefore decided to concentrate on pyqt4 and remove the pyqt3 PLplot +interface and example completely. + +2.34 Color Palettes + +Support has been added to PLplot for user defined color palette files. +These files can be loaded at the command line using the -cmap0 or +-cmap1 commands, or via the API using the plspal0 and plspal1 commands. +The commands cmap0 / plspal0 are used to load cmap0 type files which +specify the colors in PLplot's color table 0. The commands cmap1 / +plspal1 are used to load cmap1 type files which specify PLplot's color +table 1. Examples of both types of files can be found in either the +plplot-source/data directory or the PLplot installed directory +(typically /usr/local/share/plplotx.y.z/ on Linux). + +2.35 Reimplementation of a "soft landing" when a bad/missing compiler is +detected + +The PLplot core library is written in C so our CMake-based build system will +error out if it doesn't detect a working C compiler. However all other +compiled languages (Ada, C++, D, Fortran, Java, and OCaml) we support are +optional. If a working compiler is not available, we give a "soft landing" +(give a warning message, disable the optional component, and keep going). +The old implementation of the soft landing was not applied consistently (C++ +was unnecessarily mandatory before) and also caused problems for ccmake (a +CLI front-end to the cmake application) and cmake-gui (a CMake GUI front-end +to the cmake application) which incorrectly dropped languages as a result +even when there was a working compiler. + +We now have completely reimplemented the soft landing logic. The result +works well for cmake, ccmake, and cmake-gui. The one limitation of this new +method that we are aware of is it only recognizes either the default +compiler chosen by the generator or else a compiler specified by the +environment variable approach (see Official Notice XII above). Once CMake +bug 9220 has been fixed (so that the OPTIONAL signature of the +enable_language command actually works without erroring out), then our +soft-landing approach (which is a workaround for bug 9220) will be replaced +by the OPTIONAL signature of enable_language, and all CMake methods of +specifying compilers and compiler options will automatically be recognized +as a result. + +2.36 Make PLplot aware of LC_NUMERIC locale + +For POSIX-compliant systems, locale is set globally so any external +applications or libraries that use the PLplot library or any external +libraries used by the PLplot library or PLplot device drivers could +potentially change the LC_NUMERIC locale used by PLplot to anything those +external applications and libraries choose. The principal consequence of +such choice is the decimal separator could be a comma (for some locales) +rather than the period assumed for the "C" locale. For previous versions of +PLplot a comma decimal separator would have lead to a large number of +errors, but this issue is now addressed with a side benefit that our plots +now have the capability of displaying the comma (e.g., in axis labels) for +the decimal separator for those locales which require that. + +If you are not satisfied with the results for the default PLplot locale set +by external applications and libraries, then you can now choose the +LC_NUMERIC locale for PLplot by (a) specifying the new -locale command-line +option for PLplot (if you do not specify that option, a default locale is +chosen depending on applications and libraries external to PLplot (see +comments above), and (b) setting an environment variable (LC_ALL, +LC_NUMERIC, or LANG on Linux, for example) to some locale that has been +installed on your system. On Linux, to find what locales are installed, use +the "locale -a" option. The "C" locale is always installed, but usually +there is also a principal locale that works on a platform such as +en_US.UTF8, nl_NL.UTF8, etc. Furthermore, it is straightforward to build +and install any additional locale you desire. (For example, on Debian Linux +you do that by running "dpkg-reconfigure locales".) + +Normally, users will not use the -locale option since the period +decimal separator that you get for the normal LC_NUMERIC default "C" +locale used by external applications and libraries is fine for their needs. +However, if the resulting decimal separator is not what the user +wants, then they would do something like the following to (a) use a period +decimal separator for command-line input and plots: + +LC_ALL=C examples/c/x09c -locale -dev psc -o test.psc -ori 0.5 + +or (b) use a comma decimal separator for command-line input and plots: + +LC_ALL=nl_NL.UTF8 examples/c/x09c -locale -dev psc -o test.psc -ori 0,5 + +N.B. in either case if the wrong separator is used for input (e.g., -ori 0,5 +in the first case or -ori 0.5 in the second) the floating-point conversion +(using atof) is silently terminated at the wrong separator for the locale, +i.e., the fractional part of the number is silently dropped. This is +obviously not ideal, but on the other hand there are relatively few +floating-point command-line options for PLplot, and we also expect those who +use the -locale option to specifically ask for a given separator for plots +(e.g., axis labels) will then use it for command-line input of +floating-point values as well. + +Certain critical areas of the PLplot library (e.g., our colour palette file +reading routines and much of the code in our device drivers) absolutely +require a period for the decimal separator. We now protect those critical +areas by saving the normal PLplot LC_NUMERIC locale (established with the +above -locale option or by default by whatever is set by external +applications or libraries), setting the LC_NUMERIC "C" locale, executing the +critical code, then restoring back to the normal PLplot LC_NUMERIC locale. +Previous versions of PLplot did not have this protection of the critical +areas so were vulnerable to default LC_NUMERIC settings of external +applications that resulted in a comma decimal separator that did not work +correctly for the critical areas. + +2.37 Linear gradients have been implemented + +The new plgradient routine draws a linear gradient (based on the +current colour map 1) at a specified angle with the x axis for a +specified polygon. Standard examples 25 and 30 now demonstrate use of +plgradient. Some devices use a software fallback to render the +gradient. This fallback is implemented with plshades which uses a +series of rectangles to approximate the gradient. Tiny alignment +issues for those rectangles relative to the pixel grid may look +problematic for transparency gradients. To avoid that issue, we try +to use native gradient capability whenever that is possible for any of +our devices. Currently, this has been implemented for our svg, qt, +and cairo devices. The result is nice-looking smooth transparency +gradients for those devices, for, e.g., example 30, page 2. + +2.38 Cairo Windows driver implemented + +A cairo Windows driver has been implemented. This provides an +interactive cairo driver for Windows similar to xcairo on Linux. +Work to improve its functionality is ongoing. + +2.39 Custom axis labeling implemented + +Axis text labels can now be customized using the new plslabelfunc function. +This allows a user to specify what text should be draw at a given position +along a plot axis. Example 19 has been updated to illustrate this function's +use through labeling geographic coordinates in degrees North, South, East and +West. + +2.40 Universal coordinate transform implemented + +A custom coordinate transformation function can be set using plstransform. +This transformation function affects all subsequent plot function calls which +work with plot window coordinates. Testing and refinement of this support is +ongoing. + +2.41 Support for arbitrary storage of 2D user data + +This improvement courtesy of David MacMahon adds support for arbitrary +storage of 2D user data. This is very similar to the technique employed +by some existing functions (e.g. plfcont and plfshade) that use "evaluator" +functions to access 2D user data that is stored in an arbtrary format. +The new approach extends the concept of a user-supplied (or predefined) +"evaluator" function to a group of user-supplied (or predefined) "operator" +functions. The operator functions provide for various operations on the +arbitrarily stored 2D data including: get, set, +=, -=, *=, /=, isnan, +minmax, and f2eval. + +To facilitate the passing of an entire family of operator functions (via +function pointers), a plf2ops_t structure is defined to contain a +pointer to each type of operator function. Predefined operator +functions are defined for several common 2D data storage techniques. +Variables (of type plf2ops_t) containing function pointers for these +operator functions are also defined. + +New variants of functions that accept 2D data are created. The new +variants accept the 2D data as two parameters: a pointer to a plf2ops_t +structure containing (pointers to) suitable operator functions and a +PLPointer to the actual 2D data store. Existing functions that accept +2D data are modified to simply pass their parameters to the +corresponding new variant of the function, along with a pointer to the +suitable predefined plf2ops_t stucture of operator function pointers. + +The list of functions for which new variants are created is: +c_plimage, c_plimagefr, c_plmesh, c_plmeshc, c_plot3d, c_plot3dc, +c_plot3dcl, c_plshade1, c_plshades, c_plsurf3d, and c_plsurf3dl, and +c_plgriddata. The new variants are named the same as their +corresponding existing function except that the "c_" prefix is changed +to "plf" (e.g. the new variant of c_plmesh is called plfmesh). + +Adds plfvect declaration to plplot.h and changes the names (and only the +names) of some plfvect arguments to make them slightly clearer. In +order to maintain backwards API compatibility, this function and the +other existing functions that use "evaluator" functions are NOT changed +to use the new operator functions. + +Makes plplot.h and libplplot consistent vis-a-vis pltr0f and pltr2d. +Moves the definitions of pltr2f (already declared in plplot.h) from the +sccont.c files of the FORTRAN 77 and Fortran 95 bindings into plcont.c. +Removes pltr0f declaration from plplot.h. + +Changes x08c.c to demonstrate use of new support for arbitrary storage +of 2D data arrays. Shows how to do surface plots with the following +four types of 2D data arrays: + +1) PLFLT z[nx][ny]; +2) PLfGrid2 z; +3) PLFLT z[nx*ny]; /* row major order */ +4) PLFLT z[nx*ny]; /* column major order */ + +2.42 Font improvements + +We have added the underscore to the Hershey glyphs (thanks to David +MacMahon) and slightly rearranged the ascii index to the Hershey +indices so that plpoin now generates the complete set of printable +ascii characters in the correct order for the Hershey fonts (and therefore +the Type1 and TrueType fonts as well). + +We have improved how we access TrueType and Type1 fonts via the Hershey +font index (used by plpoin, plsym, and the Hershey escape sequences in pl*tex +commands). We have added considerably to the Hershey index to Unicode index +translation table both for the compact and extended Hershey indexing scheme, +and we have adopted the standard Unicode to Type1 index translation tables +from http://unicode.org/Public/MAPPINGS/VENDORS/ADOBE/. + +We have also dropped the momentary switch to symbol font that was +implemented in the PLplot core library. That switch was designed to partially +compensate for the lack of symbol glyphs in the standard Type1 fonts. That +was a bad design because it affected TrueType font devices as well as +the desired Type1 font devices. To replace this bad idea we now +change from Type1 standard fonts to the Type1 Symbol font (and vice +versa) whenever there is a glyph lookup failure in the Type1 font +device drivers (ps and pdf). + +2.42 Alpha value support for plotting in memory. + +The function plsmema() was added to the PLplot API. This allows the user +to supply a RGBA formatted array that PLplot can use to do in memory +plotting with alpha value support. At present only the memcairo device +is capable of using RGBA formatted memory. The mem device, at least +for the time being, only supports RGB formatted memory and will exit +if the user attempts to give it RGBA formatted memory to plot in. + +2.43 Add a Qt device for in memory plotting. + +A new device called memqt has been added for in memory plotting using +Qt. This device is the Qt equivalent of the memcairo device. + +2.44 Add discrete legend capability. + +A new routine called pllegend has been added to our core C API. +(N.B. This is an experimental API that may be subject to further +change as we gain more experience with it.) This routine creates a +discrete plot legend with a plotted box, line, and/or line of symbols +for each annotated legend entry. Th... [truncated message content] |
From: <hba...@us...> - 2011-08-01 18:33:21
|
Revision: 11838 http://plplot.svn.sourceforge.net/plplot/?rev=11838&view=rev Author: hbabcock Date: 2011-08-01 18:33:15 +0000 (Mon, 01 Aug 2011) Log Message: ----------- Update webpage info for the current release. Modified Paths: -------------- trunk/doc/Doxyfile.in trunk/www/examples.php Modified: trunk/doc/Doxyfile.in =================================================================== --- trunk/doc/Doxyfile.in 2011-08-01 18:32:41 UTC (rev 11837) +++ trunk/doc/Doxyfile.in 2011-08-01 18:33:15 UTC (rev 11838) @@ -32,7 +32,7 @@ # if some version control system is used. # Requires updating for every release. -PROJECT_NUMBER = 5.9.7 +PROJECT_NUMBER = 5.9.8 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. Modified: trunk/www/examples.php =================================================================== --- trunk/www/examples.php 2011-08-01 18:32:41 UTC (rev 11837) +++ trunk/www/examples.php 2011-08-01 18:33:15 UTC (rev 11838) @@ -216,7 +216,7 @@ echo <<<END <h3>Examples</h3> <p>These examples were generated with the pngcairo device and - reflect the status of PLplot-5.9.7.</p> + reflect the status of PLplot-5.9.8.</p> <p>Select a thumbnail to view full-size image and source code.</p> <p> END; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |