From: <and...@us...> - 2012-10-22 21:08:58
|
Revision: 12249 http://plplot.svn.sourceforge.net/plplot/?rev=12249&view=rev Author: andrewross Date: 2012-10-22 21:08:52 +0000 (Mon, 22 Oct 2012) Log Message: ----------- Enable colorbar support by default for example 16. Enable colorbar support in C++ and update C++ example 16 accordingly. Modified Paths: -------------- trunk/bindings/c++/plstream.cc trunk/bindings/c++/plstream.h trunk/examples/c/x16c.c trunk/examples/c++/x16.cc Modified: trunk/bindings/c++/plstream.cc =================================================================== --- trunk/bindings/c++/plstream.cc 2012-10-22 21:07:18 UTC (rev 12248) +++ trunk/bindings/c++/plstream.cc 2012-10-22 21:08:52 UTC (rev 12249) @@ -1013,18 +1013,24 @@ symbol_colors, symbol_scales, symbol_numbers, symbols ); } -void plstream::colorbar( PLINT /*position*/, PLINT /*opt*/, PLFLT /*x*/, PLFLT /*y*/, PLFLT /*length*/, PLFLT /*width*/, PLINT /*cont_color*/, PLINT /*cont_width*/, - PLFLT /*ticks*/, PLINT /*sub_ticks*/, - const char * /*axis_opts*/, const char * /*label*/, - PLINT /*n_colors*/, const PLFLT * /*colors*/, const PLFLT * /*values*/ ) +void plstream::colorbar( 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, + PLINT n_labels, PLINT *label_opts, const char *label[], + PLINT n_axes, const char *axis_opts[], + PLINT *n_values, const PLFLT * const *values ) { set_stream(); -#if 0 - plcolorbar( position, opt, x, y, length, width, - cont_color, cont_width, ticks, sub_ticks, axis_opts, - label, n_colors, colors, values ); -#endif + plcolorbar( p_colorbar_width, p_colorbar_height, opt, position, x, y, + x_length, y_length, bg_color, bb_color, bb_style, + low_cap_color, high_cap_color, cont_color, cont_width, + ticks, sub_ticks, n_labels, label_opts, label, + n_axes, axis_opts, n_values, values ); } Modified: trunk/bindings/c++/plstream.h =================================================================== --- trunk/bindings/c++/plstream.h 2012-10-22 21:07:18 UTC (rev 12248) +++ trunk/bindings/c++/plstream.h 2012-10-22 21:08:52 UTC (rev 12249) @@ -442,12 +442,17 @@ const PLINT *symbol_colors, const PLFLT *symbol_scales, const PLINT *symbol_numbers, const char **symbols ); - void colorbar( PLINT position, PLINT opt, PLFLT x, PLFLT y, PLFLT length, PLFLT width, PLINT cont_color, PLINT cont_width, + void colorbar( 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, - const char *axis_opts, const char *label, - PLINT n_colors, const PLFLT *colors, const PLFLT *values ); + PLINT n_labels, PLINT *label_opts, const char *label[], + PLINT n_axes, const char *axis_opts[], + PLINT *n_values, const PLFLT * const *values ); - // Sets position of the light source void lightsource( PLFLT x, PLFLT y, PLFLT z ); Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2012-10-22 21:07:18 UTC (rev 12248) +++ trunk/examples/c/x16c.c 2012-10-22 21:08:52 UTC (rev 12249) @@ -20,7 +20,7 @@ // front end other than the C one. // For now, don't show the colorbars while we are working out the API. -static int colorbar = 0; +static int colorbar = 1; // polar plot data #define PERIMETERPTS 100 Modified: trunk/examples/c++/x16.cc =================================================================== --- trunk/examples/c++/x16.cc 2012-10-22 21:07:18 UTC (rev 12248) +++ trunk/examples/c++/x16.cc 2012-10-22 21:08:52 UTC (rev 12249) @@ -46,6 +46,7 @@ static int nx; static int ny; static int exclude; + static int colorbar; const static int PERIMETERPTS; public: static PLFLT tr[]; @@ -54,11 +55,12 @@ static const char *notes[]; }; -int x16:: ns = 20; -int x16:: nx = 35; -int x16:: ny = 46; -int x16:: exclude = 0; -const int x16::PERIMETERPTS = 100; +int x16:: ns = 20; +int x16:: nx = 35; +int x16:: ny = 46; +int x16:: exclude = 0; +int x16:: colorbar = 1; +const int x16::PERIMETERPTS = 100; PLFLT x16:: tr[] = { 2. / ( nx - 1 ), 0.0, -1.0, 0.0, 2. / ( ny - 1 ), -1.0 }; @@ -150,7 +152,24 @@ PLFLT *clevel = new PLFLT[ns]; PLFLT *shedge = new PLFLT[ns + 1]; const int fill_width = 2, cont_color = 0, cont_width = 0; + PLFLT colorbar_width, colorbar_height; +#define NUM_AXES 1 + PLINT n_axis_opts = NUM_AXES; + const char *axis_opts[] = { + "bcvtm", + }; + PLINT num_values[NUM_AXES]; + PLFLT *values[NUM_AXES]; + PLFLT filler_values[2] = { 0.0, 1.0 }; +#define NUM_LABELS 1 + PLINT n_labels = NUM_LABELS; + PLINT label_opts[] = { + PL_COLORBAR_LABEL_BOTTOM, + }; + const char *labels[] = { + "Magnitude", + }; // plplot initialization @@ -240,6 +259,30 @@ cont_color, cont_width, plstream::fill, true, NULL, NULL ); + if ( colorbar ) + { + // Smaller text + pls->schr( 0.0, 0.75 ); + // Small ticks on the vertical axis + pls->smaj( 0.0, 0.5 ); + pls->smin( 0.0, 0.5 ); + + num_values[0] = ns + 1; + values[0] = shedge; + pls->colorbar( &colorbar_width, &colorbar_height, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.005, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, + cont_color, cont_width, 0.0, 0, + n_labels, label_opts, labels, + n_axis_opts, axis_opts, + num_values, (const PLFLT * const *) values ); + + // Reset text and tick sizes + pls->schr( 0.0, 1.0 ); + pls->smaj( 0.0, 1.0 ); + pls->smin( 0.0, 1.0 ); + } + pls->col0( 1 ); pls->box( "bcnst", 0.0, 0, "bcnstv", 0.0, 0 ); pls->col0( 2 ); @@ -262,6 +305,30 @@ cont_color, cont_width, plstream::fill, true, plstream::tr1, (void *) &cgrid1 ); + if ( colorbar ) + { + // Smaller text + pls->schr( 0.0, 0.75 ); + // Small ticks on the vertical axis + pls->smaj( 0.0, 0.5 ); + pls->smin( 0.0, 0.5 ); + + num_values[0] = ns + 1; + values[0] = shedge; + pls->colorbar( &colorbar_width, &colorbar_height, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.005, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, + cont_color, cont_width, 0.0, 0, + n_labels, label_opts, labels, + n_axis_opts, axis_opts, + num_values, (const PLFLT * const *) values ); + + // Reset text and tick sizes + pls->schr( 0.0, 1.0 ); + pls->smaj( 0.0, 1.0 ); + pls->smin( 0.0, 1.0 ); + } + pls->col0( 1 ); pls->box( "bcnst", 0.0, 0, "bcnstv", 0.0, 0 ); pls->col0( 2 ); @@ -285,6 +352,30 @@ cont_color, cont_width, plstream::fill, false, plstream::tr2, (void *) &cgrid2 ); + if ( colorbar ) + { + // Smaller text + pls->schr( 0.0, 0.75 ); + // Small ticks on the vertical axis + pls->smaj( 0.0, 0.5 ); + pls->smin( 0.0, 0.5 ); + + num_values[0] = ns + 1; + values[0] = shedge; + pls->colorbar( &colorbar_width, &colorbar_height, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.005, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, + cont_color, cont_width, 0.0, 0, + n_labels, label_opts, labels, + n_axis_opts, axis_opts, + num_values, (const PLFLT * const *) values ); + + // Reset text and tick sizes + pls->schr( 0.0, 1.0 ); + pls->smaj( 0.0, 1.0 ); + pls->smin( 0.0, 1.0 ); + } + pls->col0( 1 ); pls->box( "bcnst", 0.0, 0, "bcnstv", 0.0, 0 ); pls->col0( 2 ); @@ -309,6 +400,30 @@ 2, 3, plstream::fill, false, plstream::tr2, (void *) &cgrid2 ); + if ( colorbar ) + { + // Smaller text + pls->schr( 0.0, 0.75 ); + // Small ticks on the vertical axis + pls->smaj( 0.0, 0.5 ); + pls->smin( 0.0, 0.5 ); + + num_values[0] = ns + 1; + values[0] = shedge; + pls->colorbar( &colorbar_width, &colorbar_height, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.005, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, + 2, 3, 0.0, 0, + n_labels, label_opts, labels, + n_axis_opts, axis_opts, + num_values, (const PLFLT * const *) values ); + + // Reset text and tick sizes + pls->schr( 0.0, 1.0 ); + pls->smaj( 0.0, 1.0 ); + pls->smin( 0.0, 1.0 ); + } + pls->col0( 1 ); pls->box( "bcnst", 0.0, 0, "bcnstv", 0.0, 0 ); pls->col0( 2 ); @@ -379,6 +494,30 @@ cont_color, cont_width, plstream::fill, false, plstream::tr2, (void *) &cgrid2 ); + if ( colorbar ) + { + // Smaller text + pls->schr( 0.0, 0.75 ); + // Small ticks on the vertical axis + pls->smaj( 0.0, 0.5 ); + pls->smin( 0.0, 0.5 ); + + num_values[0] = ns + 1; + values[0] = shedge; + pls->colorbar( &colorbar_width, &colorbar_height, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + 0.005, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, + cont_color, cont_width, 0.0, 0, + n_labels, label_opts, labels, + n_axis_opts, axis_opts, + num_values, (const PLFLT * const *) values ); + + // Reset text and tick sizes + pls->schr( 0.0, 1.0 ); + pls->smaj( 0.0, 1.0 ); + pls->smin( 0.0, 1.0 ); + } + // Now we can draw the perimeter. (If do before, shade stuff may overlap.) for ( i = 0; i < PERIMETERPTS; i++ ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |