#! /usr/bin/gawk -f # Last edited on 2006-04-26 08:52:55 by stolfi BEGIN { PROG_NAME = "add-default-center-radius"; PROG_DESC = "add center, radius, and stretch paramters to extract-gauge-image-set calls"; PROG_HELP = ( \ " " PROG_NAME " < {INFILE}.sh > {OUTFILE}.sh" \ ); PROG_INFO = ( \ "\nNAME" \ "\n " PROG_NAME " - " PROG_DESC "." \ "\n" \ "\nSYNOPSIS" \ "\n " PROG_HELP "" \ "\n" \ "\nDESCRIPTION" \ "\n Reads a file where each line is a call to" \ "\n extract-gauge-image-set(1). Adds to each call the" \ "\n three final arguments {RAD} {CTRX} {CTRY}" \ "\n (or replaces them if they are there already)." \ "\n The radius {RAD} is half the window width minus" \ "\n 2 pixels. The other two are half the widow width." \ "\nAUTHOR" \ "\n Created 2006-04-17 by Jorge Stolfi, Unicamp" \ ); } /^[ ]*[\#][\#]/ { # program-generated comments, discard: next; } /^[ ]*([\#]|$)/ { print; # Comment or blank line, copy unchanged and ignore: next; } // { if ((NF != 7) && (NF != 10)) { printf "%s\n## ** bad format\n", $0; next; } # Get command and arguments: cmd = $1; iname = $2; nlamps = $3; gname = $4; ctrh = $5; ctrv = $6; topv = $7; # Compute center and radius: trad = ctrv - topv; rad = trad - 3.0; ctrx = trad + 0.5; ctry = trad + 0.5; # Write new command: printf "%s %s %d %s %4d %4d %4d %7.2f %7.2f %7.2f\n", \ cmd, iname, nlamps, gname, ctrh, ctrv, topv, \ rad, ctrx, ctry; next; }