From: <ai...@us...> - 2010-09-12 17:38:44
|
Revision: 11172 http://plplot.svn.sourceforge.net/plplot/?rev=11172&view=rev Author: airwin Date: 2010-09-12 17:38:38 +0000 (Sun, 12 Sep 2010) Log Message: ----------- Restyle source code according to our (uncrustify 0.55) standards. Modified Paths: -------------- trunk/bindings/f77/plstubs.h trunk/bindings/tcl/tclAPI.c trunk/drivers/cairo.c trunk/drivers/wingcc.c trunk/drivers/xwin.c trunk/examples/c/x04c.c trunk/src/plcore.c trunk/src/plctrl.c trunk/src/pllegend.c Modified: trunk/bindings/f77/plstubs.h =================================================================== --- trunk/bindings/f77/plstubs.h 2010-09-12 00:17:06 UTC (rev 11171) +++ trunk/bindings/f77/plstubs.h 2010-09-12 17:38:38 UTC (rev 11172) @@ -92,12 +92,12 @@ #endif #endif -#if defined( WIN32 ) /* Windows 32-bit */ -#if defined( IVF ) /* Intel Visual Fortran */ +#if defined ( WIN32 ) /* Windows 32-bit */ +#if defined ( IVF ) /* Intel Visual Fortran */ #define STUB_LINKAGE STUB_IVF -#elif defined ( CVF ) /* MSVC/CVF */ +#elif defined ( CVF ) /* MSVC/CVF */ #define STUB_LINKAGE STUB_U -#elif defined ( MSDOS ) /* MS-DOS based */ +#elif defined ( MSDOS ) /* MS-DOS based */ #define STUB_LINKAGE STUB_FORTRAN #elif defined ( _MSC_VER ) #define STUB_LINKAGE STUB_STDCALL Modified: trunk/bindings/tcl/tclAPI.c =================================================================== --- trunk/bindings/tcl/tclAPI.c 2010-09-12 00:17:06 UTC (rev 11171) +++ trunk/bindings/tcl/tclAPI.c 2010-09-12 17:38:38 UTC (rev 11172) @@ -3345,8 +3345,8 @@ Tcl_transform( PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer data ) { Tcl_Obj *objx, *objy; - int code; - double dx, dy; + int code; + double dx, dy; // Set Tcl x to x objx = Tcl_NewDoubleObj( x ); @@ -3419,13 +3419,13 @@ } else { - int len; + int len; const char *data = argc > 2 ? argv[2] : 0; tcl_xform_interp = interp; tcl_xform_procname = strdup( argv[1] ); - len = strlen( tcl_xform_template ) + strlen( tcl_xform_procname ); + len = strlen( tcl_xform_template ) + strlen( tcl_xform_procname ); tcl_xform_code = malloc( len ); sprintf( tcl_xform_code, tcl_xform_template, tcl_xform_procname ); Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-09-12 00:17:06 UTC (rev 11171) +++ trunk/drivers/cairo.c 2010-09-12 17:38:38 UTC (rev 11172) @@ -418,7 +418,7 @@ void plD_line_cairo( PLStream *pls, short x1a, short y1a, short x2a, short y2a ) { - PLCairo *aStream; + PLCairo *aStream; aStream = (PLCairo *) pls->dev; @@ -447,7 +447,7 @@ void plD_polyline_cairo( PLStream *pls, short *xa, short *ya, PLINT npts ) { - PLCairo *aStream; + PLCairo *aStream; aStream = (PLCairo *) pls->dev; @@ -1274,7 +1274,7 @@ void filled_polygon( PLStream *pls, short *xa, short *ya, PLINT npts ) { int i; - PLCairo *aStream; + PLCairo *aStream; aStream = (PLCairo *) pls->dev; @@ -1772,7 +1772,7 @@ break; case ClientMessage: // plexit("X Window closed"); - pls->stream_closed = TRUE; + pls->stream_closed = TRUE; aStream->exit_event_loop = 1; break; case Expose: Modified: trunk/drivers/wingcc.c =================================================================== --- trunk/drivers/wingcc.c 2010-09-12 00:17:06 UTC (rev 11171) +++ trunk/drivers/wingcc.c 2010-09-12 17:38:38 UTC (rev 11172) @@ -28,8 +28,8 @@ #include <string.h> #include <windows.h> #ifdef _WIN64 -#define GWL_USERDATA GWLP_USERDATA -#define GCL_HCURSOR GCLP_HCURSOR +#define GWL_USERDATA GWLP_USERDATA +#define GCL_HCURSOR GCLP_HCURSOR #endif #include "plplotP.h" @@ -257,7 +257,7 @@ else { pls = (PLStream *) GetWindowLongPtr( hwnd, GWL_USERDATA ); /* Try to get the address to pls for this window */ - if ( pls ) /* If we got it, then we will initialise this windows plplot private data area */ + if ( pls ) /* If we got it, then we will initialise this windows plplot private data area */ { dev = (wingcc_Dev *) pls->dev; } Modified: trunk/drivers/xwin.c =================================================================== --- trunk/drivers/xwin.c 2010-09-12 00:17:06 UTC (rev 11171) +++ trunk/drivers/xwin.c 2010-09-12 17:38:38 UTC (rev 11172) @@ -1484,11 +1484,10 @@ if ( event->xclient.data.l[0] == XInternAtom( xwd->display, "WM_DELETE_WINDOW", False ) ) { - pls->nopause = TRUE; - pls->stream_closed = TRUE; - dev->exit_eventloop = TRUE; + pls->nopause = TRUE; + pls->stream_closed = TRUE; + dev->exit_eventloop = TRUE; // plexit( "" ); - } } Modified: trunk/examples/c/x04c.c =================================================================== --- trunk/examples/c/x04c.c 2010-09-12 00:17:06 UTC (rev 11171) +++ trunk/examples/c/x04c.c 2010-09-12 17:38:38 UTC (rev 11172) @@ -46,10 +46,10 @@ int i; static PLFLT freql[101], ampl[101], phase[101]; PLFLT f0, freq; - char *names[2]; - int colors[2]; - int label_colors[2]; - int symbols[2]; + char *names[2]; + int colors[2]; + int label_colors[2]; + int symbols[2]; pladv( 0 ); @@ -109,18 +109,18 @@ plmtex( "r", 5.0, 0.5, 0.5, "Phase shift (degrees)" ); // Draw a legend - names[0] = "Amplitude"; - names[1] = "Phase shift"; - colors[0] = 2; - colors[1] = 3; + names[0] = "Amplitude"; + names[1] = "Phase shift"; + colors[0] = 2; + colors[1] = 3; label_colors[0] = 1; label_colors[1] = 1; pllegend( 0.3, 0.1, 0.95, 2, label_colors, names, colors, 0, NULL ); // Draw the points legend - plssym(0., 3.); - names[0] = ""; - names[1] = ""; + plssym( 0., 3. ); + names[0] = ""; + names[1] = ""; symbols[0] = -1; symbols[1] = 3; pllegend( 0.3, 0.1, 0.95, 2, label_colors, names, colors, 5, symbols ); Modified: trunk/src/plcore.c =================================================================== --- trunk/src/plcore.c 2010-09-12 00:17:06 UTC (rev 11171) +++ trunk/src/plcore.c 2010-09-12 17:38:38 UTC (rev 11172) @@ -133,7 +133,7 @@ plP_init( void ) { char * save_locale; - plsc->page_status = AT_EOP; + plsc->page_status = AT_EOP; plsc->stream_closed = FALSE; save_locale = plsave_set_locale(); @@ -169,9 +169,10 @@ if ( !skip_driver_eop ) { char *save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ - ( *plsc->dispatch_table->pl_eop )( (struct PLStream_struct *) plsc ); - } + if ( !plsc->stream_closed ) + { + ( *plsc->dispatch_table->pl_eop )( (struct PLStream_struct *) plsc ); + } plrestore_locale( save_locale ); } } @@ -201,9 +202,10 @@ if ( !skip_driver_bop ) { char *save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ - ( *plsc->dispatch_table->pl_bop )( (struct PLStream_struct *) plsc ); - } + if ( !plsc->stream_closed ) + { + ( *plsc->dispatch_table->pl_bop )( (struct PLStream_struct *) plsc ); + } plrestore_locale( save_locale ); } @@ -225,7 +227,8 @@ } save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_tidy )( (struct PLStream_struct *) plsc ); } plrestore_locale( save_locale ); @@ -247,7 +250,8 @@ if ( plsc->plbuf_write ) plbuf_state( plsc, op ); save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_state )( (struct PLStream_struct *) plsc, op ); } plrestore_locale( save_locale ); @@ -278,7 +282,8 @@ } save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_esc )( (struct PLStream_struct *) plsc, op, ptr ); } plrestore_locale( save_locale ); @@ -332,7 +337,8 @@ if ( plsc->dev_swin ) { char *save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_esc )( (struct PLStream_struct *) plsc, PLESC_SWIN, NULL ); } @@ -1226,7 +1232,8 @@ grline( short *x, short *y, PLINT npts ) { char *save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_line )( (struct PLStream_struct *) plsc, x[0], y[0], x[1], y[1] ); } @@ -1237,7 +1244,8 @@ grpolyline( short *x, short *y, PLINT npts ) { char *save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_polyline )( (struct PLStream_struct *) plsc, x, y, npts ); } @@ -1253,7 +1261,8 @@ plsc->dev_y = y; save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_esc )( (struct PLStream_struct *) plsc, PLESC_FILL, NULL ); } @@ -1269,7 +1278,8 @@ plsc->dev_y = y; save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_esc )( (struct PLStream_struct *) plsc, PLESC_GRADIENT, NULL ); } @@ -1668,10 +1678,11 @@ if ( plsc->dev_di ) { char *save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_esc )( (struct PLStream_struct *) plsc, PLESC_DI, NULL ); - } + } plrestore_locale( save_locale ); } @@ -1756,10 +1767,11 @@ if ( plsc->dev_di ) { char *save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ - ( *plsc->dispatch_table->pl_esc )( (struct PLStream_struct *) plsc, + if ( !plsc->stream_closed ) + { + ( *plsc->dispatch_table->pl_esc )( (struct PLStream_struct *) plsc, PLESC_DI, NULL ); - } + } plrestore_locale( save_locale ); } @@ -1881,10 +1893,11 @@ if ( plsc->dev_di ) { char *save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_esc )( (struct PLStream_struct *) plsc, PLESC_DI, NULL ); - } + } plrestore_locale( save_locale ); } @@ -2067,10 +2080,11 @@ if ( plsc->dev_flush ) { char *save_locale = plsave_set_locale(); - if ( !plsc->stream_closed ){ + if ( !plsc->stream_closed ) + { ( *plsc->dispatch_table->pl_esc )( (struct PLStream_struct *) plsc, PLESC_FLUSH, NULL ); - } + } plrestore_locale( save_locale ); } else Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2010-09-12 00:17:06 UTC (rev 11171) +++ trunk/src/plctrl.c 2010-09-12 17:38:38 UTC (rev 11172) @@ -1292,7 +1292,8 @@ for ( i = 0; i < *number_colors; i++ ) { - if (fgets( color_info, 30, fp ) == NULL) { + if ( fgets( color_info, 30, fp ) == NULL ) + { err = 1; break; } @@ -1472,8 +1473,9 @@ } } /* Check for new file format */ - if (fgets( color_info, 160, fp ) == NULL) { - snprintf( msgbuf, 1024, "Error reading cmap1 .pal file %s\n",filename); + if ( fgets( color_info, 160, fp ) == NULL ) + { + snprintf( msgbuf, 1024, "Error reading cmap1 .pal file %s\n", filename ); plwarn( msgbuf ); fclose( fp ); goto finish; @@ -1491,8 +1493,9 @@ plwarn( msgbuf ); rgb = TRUE; } - if (fgets( color_info, 160, fp ) == NULL) { - snprintf( msgbuf, 1024, "Error reading cmap1 .pal file %s\n",filename); + if ( fgets( color_info, 160, fp ) == NULL ) + { + snprintf( msgbuf, 1024, "Error reading cmap1 .pal file %s\n", filename ); plwarn( msgbuf ); fclose( fp ); goto finish; @@ -1523,8 +1526,9 @@ /* Old tk file format */ for ( i = 0; i < number_colors; i++ ) { - if (fgets( color_info, 160, fp ) == NULL) { - snprintf( msgbuf, 1024, "Error reading cmap1 .pal file %s\n",filename); + if ( fgets( color_info, 160, fp ) == NULL ) + { + snprintf( msgbuf, 1024, "Error reading cmap1 .pal file %s\n", filename ); plwarn( msgbuf ); fclose( fp ); goto finish; @@ -1569,8 +1573,9 @@ /* New floating point file version with support for alpha and rev values */ for ( i = 0; i < number_colors; i++ ) { - if (fgets( color_info, 160, fp ) == NULL) { - snprintf( msgbuf, 1024, "Error reading cmap1 .pal file %s\n",filename); + if ( fgets( color_info, 160, fp ) == NULL ) + { + snprintf( msgbuf, 1024, "Error reading cmap1 .pal file %s\n", filename ); plwarn( msgbuf ); fclose( fp ); goto finish; Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2010-09-12 00:17:06 UTC (rev 11171) +++ trunk/src/pllegend.c 2010-09-12 17:38:38 UTC (rev 11172) @@ -23,7 +23,8 @@ #include "plplotP.h" -PLFLT get_character_or_symbol_height(PLINT ifcharacter) { +PLFLT get_character_or_symbol_height( PLINT ifcharacter ) +{ // Character height in mm PLFLT default_mm, char_height_mm; // Normalized viewport limits @@ -40,16 +41,19 @@ PLFLT wxmin, wxmax, wymin, wymax; PLFLT world_y; - if(ifcharacter) { - plgchr(&default_mm, &char_height_mm); - } else { - default_mm = plsc->symdef; - char_height_mm = plsc->symht; + if ( ifcharacter ) + { + plgchr( &default_mm, &char_height_mm ); } - plgvpd(&vxmin, &vxmax, &vymin, &vymax); + else + { + default_mm = plsc->symdef; + char_height_mm = plsc->symht; + } + plgvpd( &vxmin, &vxmax, &vymin, &vymax ); vy = vymax - vymin; - plgspa(&mxmin, &mxmax, &mymin, &mymax); + plgspa( &mxmin, &mxmax, &mymin, &mymax ); mm_y = mymax - mymin; world_height_mm = mm_y * vy; @@ -59,16 +63,16 @@ // Normalized character height * World height (world) = // Character height (world) - plgvpw(&wxmin, &wxmax, &wymin, &wymax); + plgvpw( &wxmin, &wxmax, &wymin, &wymax ); world_y = wymax - wymin; - return(char_height_norm * world_y); + return ( char_height_norm * world_y ); } -#define normalized_to_world_x(nx) ((xmin) + (nx) * ((xmax) - (xmin))) -#define normalized_to_world_y(ny) ((ymin) + (ny) * ((ymax) - (ymin))) +#define normalized_to_world_x( nx ) ( ( xmin ) + ( nx ) * ( ( xmax ) - ( xmin ) ) ) +#define normalized_to_world_y( ny ) ( ( ymin ) + ( ny ) * ( ( ymax ) - ( ymin ) ) ) -// pllegend - Draw a legend using lines (nsymbols <=1 or symbols == NULL) or +// pllegend - Draw a legend using lines (nsymbols <=1 or symbols == NULL) or // points/symbols. // line_length: extent of lines or extent of nsymbols points/symbols // x, y: Normalized position of the legend in the plot window @@ -78,7 +82,8 @@ // colors: Line/point color for each legend entry // nsymbols: number of points/symbols to be drawn for each line_length // symbols: Symbol to draw for each legend entry. -void c_pllegend(PLFLT line_length, PLFLT x, PLFLT y, PLINT n, PLINT *text_colors, char **names, PLINT *colors, PLINT nsymbols, PLINT *symbols) { +void c_pllegend( PLFLT line_length, PLFLT x, PLFLT y, PLINT n, PLINT *text_colors, char **names, PLINT *colors, PLINT nsymbols, PLINT *symbols ) +{ // Active indexed drawing color PLINT old_col0; // Viewport world-coordinate limits @@ -97,83 +102,91 @@ // ifline is true if lines are to be drawn, false if points/symbols are // to be drawn. int ifline = nsymbols <= 1 || symbols == NULL; - if(symbols == NULL) nsymbols = 2; - nsymbols = MAX(2, nsymbols); + if ( symbols == NULL ) nsymbols = 2; + nsymbols = MAX( 2, nsymbols ); old_col0 = plsc->icol0; - plgvpw(&xmin, &xmax, &ymin, &ymax); + plgvpw( &xmin, &xmax, &ymin, &ymax ); // World coordinates for legend lines - line_x = x; - line_y = y; - line_x_end = line_x + line_length; - line_x_world = normalized_to_world_x(line_x); - line_y_world = normalized_to_world_y(line_y); - line_x_end_world = normalized_to_world_x(line_x_end); + line_x = x; + line_y = y; + line_x_end = line_x + line_length; + line_x_world = normalized_to_world_x( line_x ); + line_y_world = normalized_to_world_y( line_y ); + line_x_end_world = normalized_to_world_x( line_x_end ); // Get character height and width in world coordinates - character_height = get_character_or_symbol_height(1); - character_width = character_height*fabs((xmax-xmin)/(ymax-ymin)); + character_height = get_character_or_symbol_height( 1 ); + character_width = character_height * fabs( ( xmax - xmin ) / ( ymax - ymin ) ); // Get symbol width in world coordinates if symbols are plotted to // adjust ends of line of symbols. - if( ifline) { - symbol_width = 0.; - } else { - // 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(0)* - fabs((xmax-xmin)/(ymax-ymin)); + if ( ifline ) + { + symbol_width = 0.; } + else + { + // 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( 0 ) * + fabs( ( xmax - xmin ) / ( ymax - ymin ) ); + } // Get world-coordinate positions of the start of the legend text - text_x = line_x_end; - text_y = line_y; - text_x_world = normalized_to_world_x(text_x) + character_width; - text_y_world = normalized_to_world_y(text_y); + text_x = line_x_end; + text_y = line_y; + text_x_world = normalized_to_world_x( text_x ) + character_width; + text_y_world = normalized_to_world_y( text_y ); // Starting y position for legend entries ty = text_y_world - character_height; if ( ( ( xs = (PLFLT *) malloc( nsymbols * sizeof ( PLFLT ) ) ) == NULL ) || - ( ( ys = (PLFLT *) malloc( nsymbols * sizeof ( PLFLT ) ) ) == NULL ) ) - { - plexit( "pllegend: Insufficient memory" ); - } + ( ( ys = (PLFLT *) malloc( nsymbols * sizeof ( PLFLT ) ) ) == NULL ) ) + { + plexit( "pllegend: Insufficient memory" ); + } - dxs = (line_x_end_world - line_x_world - symbol_width)/(double) (nsymbols-1); - for (j=0; j<nsymbols; j++) { - xs[j] = line_x_world + 0.5*symbol_width + dxs*(double) j; - ys[j] = ty; + dxs = ( line_x_end_world - line_x_world - symbol_width ) / (double) ( nsymbols - 1 ); + for ( j = 0; j < nsymbols; j++ ) + { + xs[j] = line_x_world + 0.5 * symbol_width + dxs * (double) j; + ys[j] = ty; } // Draw each legend entry - for (i = 0; i < n; i++) { + for ( i = 0; i < n; i++ ) + { // Line for the legend - plcol0(colors[i]); - if (ifline) { + plcol0( colors[i] ); + if ( ifline ) + { // Draw lines - plline(nsymbols, xs, ys); + plline( nsymbols, xs, ys ); } - else { + else + { // Draw symbols - plpoin(nsymbols, xs, ys, symbols[i]); + plpoin( nsymbols, xs, ys, symbols[i] ); } // Label/name for the legend - plcol0(text_colors[i]); - plptex(text_x_world, ty, 0.0, 0.0, 0.0, names[i]); + plcol0( text_colors[i] ); + plptex( text_x_world, ty, 0.0, 0.0, 0.0, names[i] ); // Move to the next position - ty = ty - (1.5 * character_height); - for (j=0; j<nsymbols; j++) { - ys[j] = ty; - } + ty = ty - ( 1.5 * character_height ); + for ( j = 0; j < nsymbols; j++ ) + { + ys[j] = ty; + } } free( xs ); free( ys ); // Restore the previously active drawing color - plcol0(old_col0); + plcol0( old_col0 ); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |