From: <and...@us...> - 2010-05-25 09:26:46
|
Revision: 11022 http://plplot.svn.sourceforge.net/plplot/?rev=11022&view=rev Author: andrewross Date: 2010-05-25 09:26:36 +0000 (Tue, 25 May 2010) Log Message: ----------- Add support for plstransform to d bindings. Update d versions of example 6, 7 and 19 consistent with C versions. Modified Paths: -------------- trunk/bindings/d/plplot.d trunk/examples/d/x06d.d trunk/examples/d/x07d.d trunk/examples/d/x19d.d Modified: trunk/bindings/d/plplot.d =================================================================== --- trunk/bindings/d/plplot.d 2010-05-25 09:25:49 UTC (rev 11021) +++ trunk/bindings/d/plplot.d 2010-05-25 09:26:36 UTC (rev 11022) @@ -1376,6 +1376,7 @@ alias c_plssym plssym; alias c_plstar plstar; //alias c_plstart plstart; +alias c_plstransform plstransform; alias c_plstripa plstripa; //alias c_plstripc plstripc; alias c_plstripd plstripd; @@ -1952,6 +1953,9 @@ /* Initialize PLplot, passing the device name and windows/page settings. */ void c_plstart( char *devname, PLINT nx, PLINT ny ); +/* Set the coordinate transform */ +void c_plstransform( void ( *coordinate_transform )( PLFLT, PLFLT, PLFLT*, PLFLT*, PLPointer ), PLPointer coordinate_transform_data ); + /* Add a point to a stripchart. */ void c_plstripa( PLINT id, PLINT pen, PLFLT x, PLFLT y ); Modified: trunk/examples/d/x06d.d =================================================================== --- trunk/examples/d/x06d.d 2010-05-25 09:25:49 UTC (rev 11021) +++ trunk/examples/d/x06d.d 2010-05-25 09:26:36 UTC (rev 11022) @@ -13,46 +13,65 @@ \*--------------------------------------------------------------------------*/ int main( char[][] args ) { + int maxfont; + /* Parse and process command line arguments */ plparseopts( args, PL_PARSE_FULL ); /* Initialize plplot */ plinit(); - pladv( 0 ); + for ( int kind_font = 0; kind_font < 2; kind_font++ ) + { + plfontld( kind_font ); + if ( kind_font == 0 ) + maxfont = 1; + else + maxfont = 4; - /* Set up viewport and window */ - plcol0( 2 ); - plvpor( 0.1, 1.0, 0.1, 0.9 ); - plwind( 0.0, 1.0, 0.0, 1.3 ); + for ( int font = 0; font < maxfont; font++ ) + { + plfont( font + 1 ); - /* Draw the grid using plbox */ - plbox( "bcg", 0.1, 0, "bcg", 0.1, 0 ); + pladv( 0 ); - /* Write the digits below the frame */ - plcol0( 15 ); - PLFLT[1] x, y; - for ( size_t i = 0; i <= 9; i++ ) - plmtex( "b", 1.5, ( 0.1 * i + 0.05 ), 0.5, format( "%d", i ) ); + /* Set up viewport and window */ + plcol0( 2 ); + plvpor( 0.1, 1.0, 0.1, 0.9 ); + plwind( 0.0, 1.0, 0.0, 1.3 ); + + /* Draw the grid using plbox */ + plbox( "bcg", 0.1, 0, "bcg", 0.1, 0 ); + + /* Write the digits below the frame */ + plcol0( 15 ); + PLFLT[1] x, y; + for ( size_t i = 0; i <= 9; i++ ) + plmtex( "b", 1.5, ( 0.1 * i + 0.05 ), 0.5, format( "%d", i ) ); - size_t k = 0; - for ( size_t i = 0; i <= 12; i++ ) - { - /* Write the digits to the left of the frame */ - plmtex( "lv", 1.0, ( 1.0 - ( 2 * i + 1 ) / 26.0 ), 1.0, format( "%d", 10 * i ) ); - for ( size_t j = 0; j <= 9; j++ ) - { - x[0] = 0.1 * j + 0.05; - y[0] = 1.25 - 0.1 * i; + size_t k = 0; + for ( size_t i = 0; i <= 12; i++ ) + { + /* Write the digits to the left of the frame */ + plmtex( "lv", 1.0, ( 1.0 - ( 2 * i + 1 ) / 26.0 ), 1.0, format( "%d", 10 * i ) ); + for ( size_t j = 0; j <= 9; j++ ) + { + x[0] = 0.1 * j + 0.05; + y[0] = 1.25 - 0.1 * i; - /* Display the symbols (plpoin expects that x and y are arrays so */ - /* pass pointers) */ - if ( k < 128 ) - plpoin( x, y, k ); - k = k + 1; - } + /* Display the symbols (plpoin expects that x and y */ + /* are arrays so pass pointers) */ + if ( k < 128 ) + plpoin( x, y, k ); + k = k + 1; + } + } + + if ( kind_font == 0 ) + plmtex( "t", 1.5, 0.5, 0.5, "PLplot Example 6 - plpoin symbols (compact)" ); + else + plmtex( "t", 1.5, 0.5, 0.5, "PLplot Example 6 - plpoin symbols (extended)" ); + } } - - plmtex( "t", 1.5, 0.5, 0.5, "PLplot Example 6 - plpoin symbols" ); plend(); return 0; } Modified: trunk/examples/d/x07d.d =================================================================== --- trunk/examples/d/x07d.d 2010-05-25 09:25:49 UTC (rev 11021) +++ trunk/examples/d/x07d.d 2010-05-25 09:26:36 UTC (rev 11022) @@ -6,7 +6,7 @@ import plplot; import std.string; -int[17] base = [ 0, 200, 500, 600, 700, 800, 900, +int[20] base = [ 0, 100, 0, 100, 200, 500, 600, 700, 800, 900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900]; @@ -26,9 +26,10 @@ /* Initialize plplot */ plinit(); - plfontld( 1 ); - for ( size_t l = 0; l < 17; l++ ) + plfontld( 0 ); + for ( size_t l = 0; l < 20; l++ ) { + if ( l == 2 ) plfontld( 1 ); pladv( 0 ); /* Set up viewport and window */ @@ -64,7 +65,10 @@ } } - plmtex( "t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols" ); + if ( l < 2 ) + plmtex( "t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols (compact)" ); + else + plmtex( "t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols (extended)" ); } plend(); return 0; Modified: trunk/examples/d/x19d.d =================================================================== --- trunk/examples/d/x19d.d 2010-05-25 09:25:49 UTC (rev 11021) +++ trunk/examples/d/x19d.d 2010-05-25 09:26:36 UTC (rev 11022) @@ -11,6 +11,17 @@ import plplot; extern ( C ) { + +void +map_transform( PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer data ) +{ + double radius; + + radius = 90.0 - y; + *xt = radius * cos( x * PI / 180.0 ); + *yt = radius * sin( x * PI / 180.0 ); +} + /*--------------------------------------------------------------------------*\ * mapform19 * @@ -135,6 +146,35 @@ pllsty( 2 ); plmeridians( &mapform19, 10.0, 10.0, 0.0, 360.0, -10.0, 80.0 ); + /* Polar, Northern hemisphere, this time with a PLplot-wide transform */ + + minx = 0; + maxx = 360; + + plstransform( &map_transform, null ); + + pllsty( 1 ); + plenv( -75., 75., -75., 75., 1, -1 ); + /* No need to set the map transform here as the global transform will be + * used. */ + plmap( null, "globe", minx, maxx, miny, maxy ); + + pllsty( 2 ); + plmeridians( null, 10.0, 10.0, 0.0, 360.0, -10.0, 80.0 ); + + /* Show Baltimore, MD on the map */ + plcol0( 2 ); + plssym( 0.0, 2.0 ); + PLFLT x[1] = -76.6125; + PLFLT y[1] = 39.2902778; + plpoin( x, y, 18 ); + plssym( 0.0, 1.0 ); + plptex( -76.6125, 43.0, 0.0, 0.0, 0.0, "Baltimore, MD" ); + + /* For C, this is how the global transform is cleared */ + plstransform( null, null ); + + plend(); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |