void stamp( fchar Setin, fint subnr ) /*----------------------------------------*/ /*----------------------------------------*/ { fchar info; float disp, coord, fjust; float size, newsize; char messbuf[200]; fchar Fshowstr; fmake( Fshowstr, 80 ); if (Fsetdim > Fsubdim) { (void) showcoord( Setin, &Fsubin[subnr], Faxnum, &Fsubdim, &Fsetdim, Fshowstr ); } else { Fshowstr = tofchar("Top"); } fmake( info, 40 ); pgqinf_c( tofchar( "NOW" ), info, &info.l ); sprintf( messbuf, "(%.*s) Set: %.*s, level: %.*s", nelc_c( info ), info.a, nelc_c( Setin ), Setin.a, nelc_c( Fshowstr ), Fshowstr.a ); coord = 0.5; fjust = 0.5; disp = 3.0; pgqch_c( &size ); newsize = 0.75; pgsch_c( &newsize ); (void) pgmtxt_c( tofchar("R"), &disp, &coord, &fjust, tofchar(messbuf) ); pgsch_c( &size ); }
/*-----main-----------*/ int main() { printf("%s",header); fmake(Fil3); getchar(); return 0; }
int main(int argc, char** argv) { int arg, i; char *mfile = NULL; for (arg = 1; arg < argc; ++arg) if (*argv[arg] == '-') { if ('f'==clower(argv[arg][1])) { if (++arg >= argc) { fprintf(stderr, "-f needs filename argument.\n"); return 1; } mfile = argv[arg]; } else opt_char(argv[arg][1]); } else if (modcount < MAXMODS) { if (argv[arg][0]) /* ignore trailing whitespace */ modnames[modcount++] = argv[arg]; } else { fprintf(stderr, "Too many module names.\n"); return 1; } if (mfile != NULL) { arg = fmake(mfile); if (arg == -1) fprintf(stderr, "\nCannot open makefile\n"); } else { for (i = 0; *mfiles[i]; ++i) if ((arg=fmake(mfiles[i])) != -1) break; if (!*mfiles[i]) fprintf(stderr, "\nCannot open makefile\n"); } if (debug) prtree(); return arg; }
void main() { double degree ; double coor[3] ; fint output ; fint prec ; fchar Fstring ; fmake( Fstring, 30 ) ; degree = 23.0 + 59.0/60.0 + 59.8/3600.0 ; degree *= 15.0 ; for( output = 0 ; output <= 1 ; output++ ){ for( prec = 0 ; prec <= 3 ; prec++ ){ hms_c( °ree, Fstring, coor, &prec, &output ) ; printf( "%s\n", Fstring.a ) ; printf( "coor: %d %d %.3f\n", (int)coor[0] , (int)coor[1] , coor[2] ) ; } } }
FILE *fopenC( char *filename, bool *appended ) /*--------------------------------------------------*/ /* Open file to write data extern. The */ /* macro 'fmake' must be available. */ /*--------------------------------------------------*/ { bool append; bool fileexist; fint dfault; fint n; fint nitems; fint agreed; FILE *fp = NULL; *appended = NO; dfault = HIDDEN; do { fchar Filename; fmake( Filename, FILENAMELEN ); n = usertext_c( Filename, &dfault, KEY_FILENAME, MES_FILENAME ); if (n == 0) return( NULL ); /* Copy string and add a nul */ filename[ sprintf( filename, "%.*s", nelc_c(Filename), Filename.a ) ]; fp = fopen( filename, "r" ); fileexist = (fp != NULL); if (fileexist) { /* The file exists */ nitems = 1; append = toflog(YES); /* Default is appending to existing file */ dfault = REQUEST; n = userlog_c( &append, &nitems, &dfault, KEY_APPEND, MES_APPEND ); append = tobool( append ); fclose( fp ); cancel_c( KEY_APPEND ); } else append = NO; if (fileexist && !append) { cancel_c( KEY_FILENAME ); agreed = NO; } else { fp = fopen(filename, "a"); /* Open for appending */ agreed = (fp != NULL); if (!agreed) reject_c( KEY_FILENAME, tofchar("Cannot open, try another!") ); } dfault = REQUEST; /* If something went wrong, unhide keywords */ } while (!agreed); *appended = append; return( fp ); }
static void delete_set( fchar Setin ) /*------------------------------------------------------------*/ /* PURPOSE: Delete set, but ask for confirmation first. */ /*------------------------------------------------------------*/ { bool ok; /* Confirm the deleting */ char messbuf[BIGSTORE]; fint nitems; fint dfault; fint r; int slen = nelc_c(Setin); r = 0; if ( !(tobool(gds_exist_c(Setin, &r))) ) { fchar Errstr; fmake( Errstr, BIGSTORE ); if (r < 0) { gds_errstr_c( Errstr, &r ); anyoutf( 1, "Set [%.*s] is not a valid GIPSY set! (%.*s)", slen, Setin.a, nelc_c(Errstr), Errstr.a ); sprintf( messbuf, "Invalid GIPSY set, delete anyway? Y/[N]" ); } else { anyoutf( 1, "Set [%.*s] does not exist!", slen, Setin.a ); return; } } else /*--------------------------------------------------*/ /* How many characters are left to display the file */ /* name in the process area? */ /*--------------------------------------------------*/ { int messlen; /* Length of message without set name */ messlen = strlen("Ok to delete ? Y/[N]"); if (slen+messlen+1 < PROCESS_AREA_LEN) sprintf( messbuf, "Ok to delete %.*s ? Y/[N]", slen, Setin.a ); else sprintf( messbuf, "Ok to delete %.*s...? Y/[N]", PROCESS_AREA_LEN-messlen-5, Setin.a ); } /* Ask confirmation */ ok = toflog( NO ); dfault = REQUEST; nitems = 1; r = userlog_c( &ok, &nitems, &dfault, KEY_OK, tofchar(messbuf) ); ok = tobool( ok ); r = 0; if (ok) { gds_delete_c( Setin, &r ); if (r < 0) { fchar Errstr; fmake( Errstr, BIGSTORE ); gds_errstr_c( Errstr, &r ); anyoutf( 1, "Set [%.*s] could not be deleted! (%.*s)", slen, Setin.a, nelc_c(Errstr), Errstr.a ); } } cancel_c( KEY_OK ); }
void drawbox( float Xmin, float Xmax, float Ymin, float Ymax, double *Fposition1, double *Fposition2 ) /*------------------------------------------------------------------------------ * Description: Draw box and labels etc. *------------------------------------------------------------------------------ */ { static float charsize; static float Xtick, Ytick; /* Tick values for plot box */ static fint Fnxsub, Fnysub; /* Subintervals of major coordinate interval */ static float delta; static fchar FXlabel, FYlabel, FTOPlabel; static char buf1[BIGSTORE]; /* Text buffers */ static char buf2[BIGSTORE]; static char buf3[BIGSTORE]; static float disp, coord, fjust; /* Determine position Y axis label */ static float Xminmax[2], Yminmax[2]; static fint Fdfault; static fint Fnumitems; static fint Fcolor; static fint Ffont; static int m; Fcolor = 1; /* Black color */ (void) pgsci_c( &Fcolor ); charsize = 1.0; (void) pgsch_c( &charsize ); (void) pgpage_c(); delta = fabs( Xmax - Xmin ) / 10.0; if (delta == 0.0) delta = 1.0; Xmin -= delta; Xmax += delta; delta = fabs( Ymax - Ymin ) / 10.0; if (delta == 0.0) delta = 1.0; Ymin -= delta; Ymax += delta; Xminmax[0] = Xmin; Xminmax[1] = Xmax; Fnumitems = 2; Fdfault = HIDDEN; Fr1 = userreal_c( Xminmax, &Fnumitems, &Fdfault, KEY_XMINMAX, MES_XMINMAX ); Xmin = Xminmax[0]; Xmax = Xminmax[1]; Yminmax[0] = Ymin; Yminmax[1] = Ymax; Fr1 = userreal_c( Yminmax, &Fnumitems, &Fdfault, KEY_YMINMAX, MES_YMINMAX ); Ymin = Yminmax[0]; Ymax = Yminmax[1]; (void) pgswin_c( &Xmin, &Xmax, &Ymin, &Ymax ); Xtick = 0.0; Ytick = 0.0; /* nx/nysub = the number of subintervals to divide the major coordinate interval into. If xtick=0.0 or nxsub=0, the number is chosen by PGBOX. */ Fcolor = 1; (void) pgsci_c( &Fcolor ); /* Default foreground */ Ffont = 1; (void) pgscf_c( &Ffont ); /* Normal font */ Fnxsub = 0; Fnysub = 0; (void) pgbox_c( tofchar("BCNST"), &Xtick, &Fnxsub, tofchar("BCNSTV"), &Ytick, &Fnysub ); fmake( FXlabel, BIGSTORE ); fmake( FYlabel, BIGSTORE ); fmake( FTOPlabel, BIGSTORE ); fmake( Fdataunits, BIGSTORE ); Fr1 = 0; (void) gdsd_rchar_c( Fsetin, tofchar("BUNIT"), &Fsetlevel, Fdataunits, &Fr1 ); sprintf( buf1, "Amplitude (%.*s)", nelc_c(Fdataunits), Fdataunits.a ); FYlabel = tofchar( buf1 ); sprintf( buf2, "Position index in slice" ); FXlabel = tofchar( buf2 ); sprintf( buf3, "One dimensional slice from ( " ); for (m = 0; m < (int) Fsubdim; m++) { sprintf( buf3, "%.*s%d,", strlen(buf3), buf3, (int) Fposition1[m] ); } sprintf( buf3, "%.*s ) to ( ", strlen(buf3)-1, buf3 ); for (m = 0; m < (int) Fsubdim; m++) { sprintf( buf3, "%.*s%d,", strlen(buf3), buf3, (int) Fposition2[m] ); } sprintf( buf3, "%.*s )", strlen(buf3)-1, buf3 ); FTOPlabel = tofchar( buf3 ); /* Select roman font for the labels */ Ffont = 2; /* Roman font */ (void) pgscf_c( &Ffont ); (void) pglab_c( FXlabel, tofchar(" "), FTOPlabel ); /* In pgbox a routine pgnumb is called. It converts numbers in */ /* strings to plot along the axes. For any number greater than */ /* 10000, the exponential format is used. For this format, put */ /* the Y-axis label more to the left ('disp'). */ /* coord gives the location of the character string along the */ /* specified edge of the viewport, as a fraction of the length */ /* of the edge. */ /* fjust controls justification of the string parallel to */ /* the specified edge of the viewport. If fjust = 0.5, the */ /* center of the string will be placed at coord. */ { static int len1, len2; static char smallbuf1[20]; static char smallbuf2[20]; sprintf( smallbuf1, "%f", Ymax ); sprintf( smallbuf2, "%f", Ymin ); len1 = strlen( smallbuf1 ); len2 = strlen( smallbuf2 ); len1 = MYMAX( len1, len2 ); if (len1 > 3) disp = 5.0; else disp = 3.0; coord = 0.5; fjust = 0.5; (void) pgmtxt_c( tofchar("L"), &disp, &coord, &fjust, FYlabel ); } }
void initplot( void ) /*------------------------------------------------------------------------------ * Description: Initialize plot software. Set viewport and output dimensions. * If output device is a printer, ask user for line width. *------------------------------------------------------------------------------ */ { static fint Funit; /* Ignored by 'pgbeg', use 0 */ static fchar Ffile; /* Device specification */ static fint Fnxysub[2]; /* Number of subdivisions */ static float width; /* Width of output on paper */ static float aspect; /* Aspect ratio of output on paper */ static float uservals[2]; /* Array version of above */ static fint Fnumitems; /* Use in userxxx routines */ static fint Fdfault; /* Use in userxxx routines */ static fint Fr1; /* Return value or level */ static fint len; /* Length of a string */ static fint Flinewidth; /* Width of lines on output device */ static fchar devtype; /* Device specified in 'pgbeg' */ static fint Ferrlev; static fint Foff; Funit = 0; /* Ignored by 'pgbeg' */ fmake( Ffile, 10 ); Ffile = tofchar( "?" ); /* 'pgbeg' will prompt the user to supply a string. */ Fnxysub[0] = 1; /* Default no subdivisions in plot */ Fnxysub[1] = 1; Fnumitems = 2; Fdfault = HIDDEN; Fr1 = userint_c( Fnxysub, &Fnumitems, &Fdfault, KEY_SUBDIV, MES_SUBDIV ); /* Set window and viewport */ Fr1 = pgbeg_c( &Funit, Ffile, &Fnxysub[0], &Fnxysub[1] ); if (Fr1 != 1) { Ferrlev = 4; error_c( &Ferrlev, tofchar("Cannot open output device") ); } /* No NEXTPAGE= keyword */ Foff = tobool( 0 ); (void) pgask_c( &Foff ); /* Change size of the view surface to a specified width */ /* and aspect ratio (=height/width) */ Fnumitems = 2; Fdfault = HIDDEN; uservals[0] = 0.0; uservals[1] = 1.0; Fr1 = userreal_c( uservals, &Fnumitems, &Fdfault, tofchar("PAPER="), tofchar("Give width(cm), aspect ratio: [0.0,1.0]") ); if (Fr1 > 0) { /* If width = 0.0 then the program will select the largest */ /* view surface */ width = uservals[0]; /* Convert from cm to inches */ width /= 2.54; aspect = uservals[1]; (void) pgpap_c( &width, &aspect ); } /* Get device-type code name of the current PGPLOT device */ /* If the destination is a printer (=every destination */ /* except the Tektronix device), use thick lines in the plot */ len = 20; finit(devtype, len); (void) pgqinf_c( tofchar("TYPE"), devtype, &len ); if (strncmp(devtype.a, "TEK4010", 6) == 0) { /* It is a Tektronix */ } else { Fnumitems = 1; Fdfault = HIDDEN; do { Flinewidth = 2; Fr1 = userint_c( &Flinewidth, &Fnumitems, &Fdfault, tofchar("LINEWIDTH="), tofchar("Give line width (1-21): [2]") ); agreed = ((Flinewidth >= 1) && (Flinewidth <= 21)); if (!agreed) { (void) reject_c( tofchar("LINEWIDTH="), tofchar("Invalid number") ); } } while (!agreed); (void) pgslw_c( &Flinewidth ); } { /* Set viewport */ static float Xl, Xr, Yb, Yt; Xl = 0.2; Xr = 0.9; Yb = 0.1; Yt = 0.9; (void) pgsvp_c(&Xl, &Xr, &Yb, &Yt); } }