1 // Font demo.
2 //
3
4 #ifdef MSDOS
5 #pragma optimize("",off)
6 #endif
7
8 #include "plcdemos.h"
9
10 static int plptex_mode;
11
12 static PLOptionTable options[] = {
13 {
14 "plptex_mode",
15 NULL,
16 NULL,
17 &plptex_mode,
18 PL_OPT_BOOL,
19 "-plptex_mode",
20 "Replace normal plsym call by the largely equivalent plptex call for this example"
21 },
22 {
23 NULL, // option
24 NULL, // handler
25 NULL, // client data
26 NULL, // address of variable to set
27 0, // mode flag
28 NULL, // short syntax
29 NULL // long syntax
30 }
31 };
32
33
34 static int base[20] =
35 { 0, 100, 0, 100, 200, 500, 600, 700, 800, 900,
36 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900 };
37
38 //--------------------------------------------------------------------------
39 // main
40 //
41 // Displays the entire "plsym" symbol (font) set.
42 //--------------------------------------------------------------------------
43
44 int
main(int argc,char * argv[])45 main( int argc, char *argv[] )
46 {
47 char text[10];
48 int i, j, k, l;
49 PLFLT x, y;
50
51 // Parse and process command line arguments
52
53 plMergeOpts( options, "x07c options", NULL );
54 plparseopts( &argc, argv, PL_PARSE_FULL );
55
56 // Initialize plplot
57
58 plinit();
59
60 plfontld( 0 );
61 for ( l = 0; l < 20; l++ )
62 {
63 if ( l == 2 )
64 plfontld( 1 );
65 pladv( 0 );
66
67 // Set up viewport and window
68
69 plcol0( 2 );
70 plvpor( 0.15, 0.95, 0.1, 0.9 );
71 plwind( 0.0, 1.0, 0.0, 1.0 );
72
73 // Draw the grid using plbox
74
75 plbox( "bcg", 0.1, 0, "bcg", 0.1, 0 );
76
77 // Write the digits below the frame
78
79 plcol0( 15 );
80 for ( i = 0; i <= 9; i++ )
81 {
82 sprintf( text, "%d", i );
83 plmtex( "b", 1.5, ( 0.1 * i + 0.05 ), 0.5, text );
84 }
85
86 k = 0;
87 for ( i = 0; i <= 9; i++ )
88 {
89 // Write the digits to the left of the frame
90
91 sprintf( text, "%d", base[l] + 10 * i );
92 plmtex( "lv", 1.0, ( 0.95 - 0.1 * i ), 1.0, text );
93 for ( j = 0; j <= 9; j++ )
94 {
95 x = 0.1 * j + 0.05;
96 y = 0.95 - 0.1 * i;
97
98 // Display the symbols
99 if ( plptex_mode )
100 {
101 sprintf( text, "#(%1d)", base[l] + k );
102 plptex( x, y, 1.0, 0.0, 0.5, text );
103 }
104 else
105 {
106 plsym( 1, &x, &y, base[l] + k );
107 }
108 k = k + 1;
109 }
110 }
111
112 if ( l < 2 )
113 plmtex( "t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols (compact)" );
114 else
115 plmtex( "t", 1.5, 0.5, 0.5, "PLplot Example 7 - PLSYM symbols (extended)" );
116 }
117 plend();
118 exit( 0 );
119 }
120