From: <ai...@us...> - 2010-09-28 22:45:24
|
Revision: 11231 http://plplot.svn.sourceforge.net/plplot/?rev=11231&view=rev Author: airwin Date: 2010-09-28 22:45:18 +0000 (Tue, 28 Sep 2010) Log Message: ----------- Drop cmap1 color box option so that all colors are expressed with cmap0. That is a nice simplification as discussed on list. Improve handling of PL_LEGEND_NONE so that it overrides all other opt_array flags. Reorder/rename some arguments in a more rational manner. For example, the color box, line, and symbols for each legend entry are rendered in that order so put the arguments in that order as well. Modified Paths: -------------- trunk/examples/c/x04c.c trunk/include/plplot.h trunk/src/pllegend.c Modified: trunk/examples/c/x04c.c =================================================================== --- trunk/examples/c/x04c.c 2010-09-28 17:49:52 UTC (rev 11230) +++ trunk/examples/c/x04c.c 2010-09-28 22:45:18 UTC (rev 11231) @@ -54,8 +54,8 @@ PLINT line_styles[2]; PLINT line_widths[2]; PLINT symbol_numbers[2], symbol_colors[2], symbols[2]; - PLINT cmap0_colors[2], cmap_patterns[2]; - PLFLT symbol_scales[2], cmap_scales[2], cmap1_colors[2]; + PLINT box_colors[2], box_patterns[2]; + PLFLT symbol_scales[2], box_scales[2]; pladv( 0 ); @@ -137,20 +137,18 @@ symbol_numbers[1] = 4; symbols[0] = 3; symbols[1] = 3; - cmap0_colors[0] = 2; - cmap0_colors[1] = 3; - cmap1_colors[0] = 0.; - cmap1_colors[1] = 1.; - cmap_patterns[0] = 0; - cmap_patterns[1] = 3; - cmap_scales[0] = 0.5; - cmap_scales[1] = 0.5; + box_colors[0] = 2; + box_colors[1] = 3; + box_patterns[0] = 0; + box_patterns[1] = 3; + box_scales[0] = 0.5; + box_scales[1] = 0.5; plscol0a( 15, 32, 32, 32, 0.90 ); pllegend( PL_LEGEND_BACKGROUND, 0.57, 0.85, 0.06, 15, nlegend, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, + box_colors, box_patterns, box_scales, line_colors, line_styles, line_widths, - symbol_numbers, symbol_colors, symbol_scales, symbols, - cmap0_colors, cmap1_colors, cmap_patterns, cmap_scales ); + symbol_colors, symbol_scales, symbol_numbers, symbols ); } Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2010-09-28 17:49:52 UTC (rev 11230) +++ trunk/include/plplot.h 2010-09-28 22:45:18 UTC (rev 11231) @@ -1209,11 +1209,10 @@ /* Routine for drawing line, symbol, cmap0, or cmap1 legends */ // Flags for pllegend. -#define PL_LEGEND_NONE 0 -#define PL_LEGEND_LINE 1 -#define PL_LEGEND_SYMBOL 2 -#define PL_LEGEND_CMAP0 4 -#define PL_LEGEND_CMAP1 8 +#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 @@ -1222,11 +1221,10 @@ PLINT nlegend, PLINT *opt_array, PLFLT text_offset, PLFLT text_scale, PLFLT text_spacing, PLFLT text_justification, PLINT *text_colors, char **text, + PLINT *box_colors, PLINT *box_patterns, PLFLT *box_scales, PLINT *line_colors, PLINT *line_styles, PLINT *line_widths, - PLINT *symbol_numbers, PLINT *symbol_colors, - PLFLT *symbol_scales, PLINT *symbols, - PLINT *cmap0_colors, PLFLT * cmap1_colors, - PLINT *cmap_patterns, PLFLT *cmap_scales ); + PLINT *symbol_colors, PLFLT *symbol_scales, + PLINT *symbol_numbers, PLINT *symbols ); /* Sets position of the light source */ PLDLLIMPEXP void Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2010-09-28 17:49:52 UTC (rev 11230) +++ trunk/src/pllegend.c 2010-09-28 22:45:18 UTC (rev 11231) @@ -115,11 +115,11 @@ //! @param nlegend : number of legend entries //! @param opt_array : array of nlegend values of options to control //! each individual plotted area corresponding to a legend entry. If -//! the PL_LEGEND_NONE, PL_LEGEND_CMAP0, PL_LEGEND_CMAP1, -//! PL_LEGEND_LINE, and/or PL_LEGEND_SYMBOL bits are set, the plotted -//! area corresponding to a legend entry is specified with nothing; a -//! colored box (with the color of that box determined by either a -//! cmap0 index or a cmap1 value); a line; and/or a line of symbols +//! the PL_LEGEND_NONE bit is set, then nothing is plotted in the +//! plotted area. If the PL_LEGEND_COLOR_BOX, PL_LEGEND_LINE, and/or +//! PL_LEGEND_SYMBOL bits are set, the plotted area corresponding to a +//! legend entry is specified with a colored box; a line; and/or a +//! line of symbols //! @param text_offset : offset of the text area from the plot area in //! units of character width //! @param text_scale : character height scale for text annotations @@ -132,6 +132,13 @@ //! are allowed as well. //! @param text_colors : array of nlegend text colors (cmap0 indices). //! @param text : array of nlegend text annotations +//! @param box_colors : array of nlegend colors (cmap0 indices) for +//! the discrete colored boxes (PL_LEGEND_COLOR_BOX) +//! @param box_patterns : array of nlegend patterns (plpsty indices) +//! for the discrete colored boxes (PL_LEGEND_COLOR_BOX) +//! @param box_scales : array of nlegend scales (units of fraction of +//! character height) for the height of the discrete colored boxes +//! (PL_LEGEND_COLOR_BOX) //! @param line_colors : array of nlegend line colors (cmap0 indices) //! (PL_LEGEND_LINE) //! @param line_styles : array of nlegend line styles (plsty indices) @@ -145,15 +152,6 @@ //! symbol height (PL_LEGEND_SYMBOL) //! @param symbols : array of nlegend symbols (plpoin indices) //! (PL_LEGEND_SYMBOL) -//! @param cmap0_colors : array of nlegend colors (cmap0 indices) for -//! the discrete colored boxes (PL_LEGEND_CMAP0) -//! @param cmap1_colors : array of nlegend colors (cmap1 values) for -//! the discrete colored boxes (PL_LEGEND_CMAP1) -//! @param cmap_patterns : array of nlegend patterns (plpsty indices) -//! for the discrete colored boxes (PL_LEGEND_CMAP0 | PL_LEGEND_CMAP1) -//! @param cmap_scales : array of nlegend scales (units of fraction of -//! character height) for the height of the discrete colored boxes -//! (PL_LEGEND_CMAP0 | PL_LEGEND_CMAP1) //! //! N.B. the total width of the legend is made up of plplot_width + //! text_offset (converted to normalized subpage coordinates) + width @@ -170,11 +168,10 @@ PLINT nlegend, PLINT *opt_array, PLFLT text_offset, PLFLT text_scale, PLFLT text_spacing, PLFLT text_justification, PLINT *text_colors, char **text, + PLINT *box_colors, PLINT *box_patterns, PLFLT *box_scales, PLINT *line_colors, PLINT *line_styles, PLINT *line_widths, - PLINT *symbol_numbers, PLINT *symbol_colors, - PLFLT *symbol_scales, PLINT *symbols, - PLINT *cmap0_colors, PLFLT *cmap1_colors, - PLINT *cmap_patterns, PLFLT *cmap_scales ) + PLINT *symbol_colors, PLFLT *symbol_scales, + PLINT *symbol_numbers, PLINT *symbols ) { // Viewport world-coordinate limits @@ -188,7 +185,7 @@ // y-position of the current legend entry PLFLT ty, dty; // Positions of the legend entries - PLFLT dxs, *xs, *ys, xl[2], yl[2], xcmap[4], ycmap[4]; + PLFLT dxs, *xs, *ys, xl[2], yl[2], xbox[4], ybox[4]; PLINT i, j; // Active attributes to be saved and restored afterward. PLINT col0_save = plsc->icol0, @@ -205,7 +202,7 @@ PLFLT x_world_per_mm, y_world_per_mm, text_width0 = 0., text_width; PLFLT total_width_border, total_width, total_height; - PLINT some_lines = 0, some_symbols = 0, some_cmaps = 0; + PLINT some_boxes = 0, some_lines = 0, some_symbols = 0; PLINT max_symbol_numbers = 0; plgvpd( &xdmin_save, &xdmax_save, &ydmin_save, &ydmax_save ); @@ -219,6 +216,8 @@ for ( i = 0; i < nlegend; i++ ) { + if ( opt_array[i] & PL_LEGEND_COLOR_BOX ) + some_boxes = 1; if ( opt_array[i] & PL_LEGEND_LINE ) some_lines = 1; if ( opt_array[i] & PL_LEGEND_SYMBOL ) @@ -226,8 +225,6 @@ max_symbol_numbers = MAX( max_symbol_numbers, symbol_numbers[i] ); some_symbols = 1; } - if ( opt_array[i] & ( PL_LEGEND_CMAP0 | PL_LEGEND_CMAP1 ) ) - some_cmaps = 1; } plgvpw( &xmin, &xmax, &ymin, &ymax ); @@ -298,12 +295,12 @@ plot_x_end_world += total_width_border; text_x_world += total_width_border; - if ( some_cmaps ) + if ( some_boxes ) { - xcmap[0] = plot_x_world; - xcmap[1] = plot_x_world; - xcmap[2] = plot_x_end_world; - xcmap[3] = plot_x_end_world; + xbox[0] = plot_x_world; + xbox[1] = plot_x_world; + xbox[2] = plot_x_end_world; + xbox[3] = plot_x_end_world; } if ( some_lines ) @@ -341,49 +338,42 @@ plcol0( text_colors[i] ); plptex( text_x_world + text_justification * text_width0, ty, 0.1, 0.0, text_justification, text[i] ); - if ( opt_array[i] & PL_LEGEND_CMAP0 ) + if ( !( opt_array[i] & PL_LEGEND_NONE ) ) { - plcol0( cmap0_colors[i] ); - plpsty( cmap_patterns[i] ); - ycmap[0] = ty + 0.5 * dty * cmap_scales[i]; - ycmap[1] = ty - 0.5 * dty * cmap_scales[i]; - ycmap[2] = ty - 0.5 * dty * cmap_scales[i]; - ycmap[3] = ty + 0.5 * dty * cmap_scales[i]; - plfill( 4, xcmap, ycmap ); - } - if ( opt_array[i] & PL_LEGEND_CMAP1 ) - { - plcol1( cmap1_colors[i] ); - plpsty( cmap_patterns[i] ); - ycmap[0] = ty + 0.5 * dty * cmap_scales[i]; - ycmap[1] = ty - 0.5 * dty * cmap_scales[i]; - ycmap[2] = ty - 0.5 * dty * cmap_scales[i]; - ycmap[3] = ty + 0.5 * dty * cmap_scales[i]; - plfill( 4, xcmap, ycmap ); - } - if ( opt_array[i] & PL_LEGEND_LINE ) - { - plcol0( line_colors[i] ); - pllsty( line_styles[i] ); - plwid( line_widths[i] ); - yl[0] = ty; - yl[1] = ty; - plline( 2, xl, yl ); - pllsty( line_style_save ); - plwid( line_width_save ); - } + if ( opt_array[i] & PL_LEGEND_COLOR_BOX ) + { + plcol0( box_colors[i] ); + plpsty( box_patterns[i] ); + ybox[0] = ty + 0.5 * dty * box_scales[i]; + ybox[1] = ty - 0.5 * dty * box_scales[i]; + ybox[2] = ty - 0.5 * dty * box_scales[i]; + ybox[3] = ty + 0.5 * dty * box_scales[i]; + plfill( 4, xbox, ybox ); + } + if ( opt_array[i] & PL_LEGEND_LINE ) + { + plcol0( line_colors[i] ); + pllsty( line_styles[i] ); + plwid( line_widths[i] ); + yl[0] = ty; + yl[1] = ty; + plline( 2, xl, yl ); + pllsty( line_style_save ); + plwid( line_width_save ); + } - if ( opt_array[i] & PL_LEGEND_SYMBOL ) - { - plcol0( symbol_colors[i] ); - plssym( 0., symbol_scales[i] ); - dxs = ( plot_x_end_world - plot_x_world - symbol_width ) / (double) ( MAX( symbol_numbers[i], 2 ) - 1 ); - for ( j = 0; j < symbol_numbers[i]; j++ ) + if ( opt_array[i] & PL_LEGEND_SYMBOL ) { - xs[j] = plot_x_world + 0.5 * symbol_width + dxs * (double) j; - ys[j] = ty; + plcol0( symbol_colors[i] ); + plssym( 0., symbol_scales[i] ); + dxs = ( plot_x_end_world - plot_x_world - symbol_width ) / (double) ( MAX( symbol_numbers[i], 2 ) - 1 ); + for ( j = 0; j < symbol_numbers[i]; j++ ) + { + xs[j] = plot_x_world + 0.5 * symbol_width + dxs * (double) j; + ys[j] = ty; + } + plpoin( symbol_numbers[i], xs, ys, symbols[i] ); } - plpoin( symbol_numbers[i], xs, ys, symbols[i] ); } } if ( some_symbols ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |