From: <ai...@us...> - 2010-11-09 21:59:13
|
Revision: 11310 http://plplot.svn.sourceforge.net/plplot/?rev=11310&view=rev Author: airwin Date: 2010-11-09 21:59:06 +0000 (Tue, 09 Nov 2010) Log Message: ----------- Implement plstring which is designed to supersede plsymbol and plpoin when the glyph(s) you want to plot at each of the points can be expressed with a standard user input string. As with plmtex or plptex the standard input string can be UTF-8, or the ascii subset of UTF-8, or one of the standard PLplot text escape sequences. N.B. the use of plstring highlights that there are some vertical alignment issues with plptex (which is called internally by plstring) depending on the device driver that is being used. Change the API of pllegend to express the symbols (glyphs) used for each legend entry as a standard user input string (which allows pllegend to call plstring internally). Change the 4th and 26th example to use this new pllegend API and to also use plstring to plot the line in the non-legend part of the plot. Also, make the legend background colour more transparent (alpha changed from 0.90 to 0.70). Modified Paths: -------------- trunk/examples/c/x04c.c trunk/examples/c/x26c.c trunk/include/plplot.h trunk/src/pllegend.c trunk/src/plsym.c Modified: trunk/examples/c/x04c.c =================================================================== --- trunk/examples/c/x04c.c 2010-11-06 00:11:25 UTC (rev 11309) +++ trunk/examples/c/x04c.c 2010-11-09 21:59:06 UTC (rev 11310) @@ -47,13 +47,13 @@ static PLFLT freql[101], ampl[101], phase[101]; PLFLT f0, freq; PLINT nlegend; - char *text[2]; + char *text[2], *symbols[2]; PLINT opt_array[2]; PLINT text_colors[2]; PLINT line_colors[2]; PLINT line_styles[2]; PLINT line_widths[2]; - PLINT symbol_numbers[2], symbol_colors[2], symbols[2]; + PLINT symbol_numbers[2], symbol_colors[2]; PLFLT symbol_scales[2]; pladv( 0 ); @@ -110,7 +110,7 @@ plbox( "", 0.0, 0, "cmstv", 30.0, 3 ); plcol0( 3 ); plline( 101, freql, phase ); - plpoin( 101, freql, phase, 3 ); + plstring( 101, freql, phase, "*" ); plcol0( 3 ); plmtex( "r", 5.0, 0.5, 0.5, "Phase shift (degrees)" ); nlegend = 2; @@ -136,18 +136,18 @@ symbol_colors[1] = 3; symbol_scales[1] = 1.; symbol_numbers[1] = 4; - symbols[1] = 3; + symbols[1] = "*"; // from the above opt_arrays we can completely ignore everything // to do with boxes. - plscol0a( 15, 32, 32, 32, 0.90 ); + plscol0a( 15, 32, 32, 32, 0.70 ); pllegend( PL_LEGEND_BACKGROUND | PL_LEGEND_BOUNDING_BOX, - 0.0, 0.0, 0.06, 15, + 0.0, 0.0, 0.1, 15, 1, 1, 0, 0, nlegend, opt_array, 1.0, 1.0, 2.0, 1., text_colors, (const char **) text, NULL, NULL, NULL, line_colors, line_styles, line_widths, - symbol_colors, symbol_scales, symbol_numbers, symbols ); + symbol_colors, symbol_scales, symbol_numbers, (const char **) symbols ); } Modified: trunk/examples/c/x26c.c =================================================================== --- trunk/examples/c/x26c.c 2010-11-06 00:11:25 UTC (rev 11309) +++ trunk/examples/c/x26c.c 2010-11-09 21:59:06 UTC (rev 11310) @@ -155,8 +155,9 @@ PLINT line_colors[2]; PLINT line_styles[2]; PLINT line_widths[2]; - PLINT symbol_numbers[2], symbol_colors[2], symbols[2]; + PLINT symbol_numbers[2], symbol_colors[2]; PLFLT symbol_scales[2]; + char *symbols[2]; pladv( 0 ); @@ -212,7 +213,7 @@ plbox( "", 0.0, 0, "cmstv", 30.0, 3 ); plcol0( 3 ); plline( 101, freql, phase ); - plpoin( 101, freql, phase, 3 ); + plstring( 101, freql, phase, "*" ); plcol0( 3 ); plmtex( "r", 5.0, 0.5, 0.5, alty_label ); } @@ -235,18 +236,18 @@ symbol_colors[1] = 3; symbol_scales[1] = 1.; symbol_numbers[1] = 4; - symbols[1] = 3; + symbols[1] = "*"; // from the above opt_arrays we can completely ignore everything // to do with boxes. - plscol0a( 15, 32, 32, 32, 0.90 ); + plscol0a( 15, 32, 32, 32, 0.70 ); pllegend( PL_LEGEND_BACKGROUND | PL_LEGEND_BOUNDING_BOX, - 0.0, 0.0, 0.06, 15, + 0.0, 0.0, 0.10, 15, 1, 1, 0, 0, nlegend, opt_array, 1.0, 1.0, 2.0, 1., text_colors, (const char **) legend_text, NULL, NULL, NULL, line_colors, line_styles, line_widths, - symbol_colors, symbol_scales, symbol_numbers, symbols ); + symbol_colors, symbol_scales, symbol_numbers, (const char **) symbols ); } Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2010-11-06 00:11:25 UTC (rev 11309) +++ trunk/include/plplot.h 2010-11-09 21:59:06 UTC (rev 11310) @@ -764,6 +764,7 @@ #define plstar c_plstar #define plstart c_plstart #define plstransform c_plstransform +#define plstring c_plstring #define plstripa c_plstripa #define plstripc c_plstripc #define plstripd c_plstripd @@ -1237,7 +1238,7 @@ const PLINT *line_colors, const PLINT *line_styles, const PLINT *line_widths, const PLINT *symbol_colors, const PLFLT *symbol_scales, - const PLINT *symbol_numbers, const PLINT *symbols ); + const PLINT *symbol_numbers, const char **symbols ); // Sets position of the light source PLDLLIMPEXP void @@ -1737,6 +1738,15 @@ PLDLLIMPEXP void c_plstransform( void ( *coordinate_transform )( PLFLT, PLFLT, PLFLT*, PLFLT*, PLPointer ), PLPointer coordinate_transform_data ); +// Prints out the same string repeatedly at the n points in world +// coordinates given by the x and y arrays. Supersedes plpoin and +// plsymbol for the case where text refers to a unicode glyph either +// directly as UTF-8 or indirectly via the standard text escape +// sequences allowed for PLplot input strings. + +PLDLLIMPEXP void +c_plstring( PLINT n, PLFLT *x, PLFLT *y, const char *string ); + // Add a point to a stripchart. PLDLLIMPEXP void Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2010-11-06 00:11:25 UTC (rev 11309) +++ trunk/src/pllegend.c 2010-11-09 21:59:06 UTC (rev 11310) @@ -395,7 +395,7 @@ const PLINT *line_colors, const PLINT *line_styles, const PLINT *line_widths, const PLINT *symbol_colors, const PLFLT *symbol_scales, - const PLINT *symbol_numbers, const PLINT *symbols ) + const PLINT *symbol_numbers, const char **symbols ) { // Legend position @@ -414,8 +414,7 @@ line_style_save = plsc->line_style, line_width_save = plsc->width, pattern_save = plsc->patt; - PLFLT text_scale_save = plsc->chrht / plsc->chrdef, - symbol_scale_save = plsc->symht / plsc->symdef; + PLFLT text_scale_save = plsc->chrht / plsc->chrdef; // Saved external world coordinates of viewport. PLFLT xwmin_save, xwmax_save, ywmin_save, ywmax_save; // Saved external normalized coordinates of viewport. @@ -628,7 +627,7 @@ // AWI, no idea why must use 0.5 factor to get ends of symbol lines // to line up approximately correctly with plotted legend lines. // Factor should be unity. - symbol_width = 0.5 * get_character_or_symbol_height( FALSE ); + symbol_width = 0.5 * get_character_or_symbol_height( TRUE ); } // Draw each legend entry @@ -674,7 +673,7 @@ if ( opt_array[i] & PL_LEGEND_SYMBOL ) { plcol0( symbol_colors[i] ); - plssym( 0., symbol_scales[i] ); + plschr( 0., symbol_scales[i] ); dxs = ( plot_x_end_subpage - plot_x_subpage - symbol_width ) / (double) ( MAX( symbol_numbers[i], 2 ) - 1 ); for ( j = 0; j < symbol_numbers[i]; j++ ) { @@ -682,7 +681,7 @@ 0.5 * symbol_width + dxs * (double) j; ys[j] = ty; } - plpoin( symbol_numbers[i], xs, ys, symbols[i] ); + plstring( symbol_numbers[i], xs, ys, symbols[i] ); } } @@ -715,7 +714,6 @@ // Restore plcol0( col0_save ); plschr( 0., text_scale_save ); - plssym( 0., symbol_scale_save ); plpsty( pattern_save ); plvpor( xdmin_save, xdmax_save, ydmin_save, ydmax_save ); plwind( xwmin_save, xwmax_save, ywmin_save, ywmax_save ); Modified: trunk/src/plsym.c =================================================================== --- trunk/src/plsym.c 2010-11-06 00:11:25 UTC (rev 11309) +++ trunk/src/plsym.c 2010-11-09 21:59:06 UTC (rev 11310) @@ -78,6 +78,26 @@ plhrsh2( PLINT ch, PLINT x, PLINT y ); //-------------------------------------------------------------------------- +// void plstring() +// +// Prints out the same string repeatedly at the n points in world +// coordinates given by the x and y arrays. Supersedes plpoin and +// plsymbol for the case where text refers to a unicode glyph either +// directly as UTF-8 or indirectly via the standard text escape +// sequences allowed for PLplot input strings. +//-------------------------------------------------------------------------- + +void +c_plstring( PLINT n, PLFLT *x, PLFLT *y, const char *string ) +{ + PLINT i; + for ( i = 0; i < n; i++ ) + { + c_plptex( x[i], y[i], 1., 0., 0.5, string ); + } +} + +//-------------------------------------------------------------------------- // void plsym() // // Plots array y against x for n points using Hershey symbol "code". This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |