Index: ps.c =================================================================== --- ps.c (revision 34524) +++ ps.c (revision 34525) @@ -1248,161 +1248,6 @@ rnd_fprintf(global.f, "%mi %mi %mi %mi r\n", x1, y1, x2, y2); } -rnd_hid_attribute_t ps_calib_attribute_list[] = { - {"lprcommand", "Command to print", - RND_HATT_STRING, 0, 0, {0, 0, 0}, 0, 0}, -}; - -static const char *const calib_lines[] = { - "%!PS-Adobe-3.0\n", - "%%Title: Calibration Page\n", - "%%PageOrder: Ascend\n", - "%%Pages: 1\n", - "%%EndComments\n", - "\n", - "%%Page: Calibrate 1\n", - "72 72 scale\n", - "\n", - "0 setlinewidth\n", - "0.375 0.375 moveto\n", - "8.125 0.375 lineto\n", - "8.125 10.625 lineto\n", - "0.375 10.625 lineto\n", - "closepath stroke\n", - "\n", - "0.5 0.5 translate\n", - "0.001 setlinewidth\n", - "\n", - "/Times-Roman findfont 0.2 scalefont setfont\n", - "\n", - "/sign {\n", - " 0 lt { -1 } { 1 } ifelse\n", - "} def\n", - "\n", - "/cbar {\n", - " /units exch def\n", - " /x exch def\n", - " /y exch def \n", - "\n", - " /x x sign 0.5 mul def\n", - "\n", - " 0 setlinewidth\n", - " newpath x y 0.25 0 180 arc gsave 0.85 setgray fill grestore closepath stroke\n", - " newpath x 0 0.25 180 360 arc gsave 0.85 setgray fill grestore closepath stroke\n", - " 0.001 setlinewidth\n", - "\n", - " x 0 moveto\n", - " x y lineto\n", - "% -0.07 -0.2 rlineto 0.14 0 rmoveto -0.07 0.2 rlineto\n", - " x y lineto\n", - " -0.1 0 rlineto 0.2 0 rlineto\n", - " stroke\n", - " x 0 moveto\n", - "% -0.07 0.2 rlineto 0.14 0 rmoveto -0.07 -0.2 rlineto\n", - " x 0 moveto\n", - " -0.1 0 rlineto 0.2 0 rlineto\n", - " stroke\n", - "\n", - " x 0.1 add\n", - " y 0.2 sub moveto\n", - " units show\n", - "} bind def\n", - "\n", - "/y 9 def\n", - "/t {\n", - " /str exch def\n", - " 1.5 y moveto str show\n", - " /y y 0.25 sub def\n", - "} bind def\n", - "\n", - "(Please measure ONE of the horizontal lines, in the units indicated for)t\n", - "(that line, and enter that value as X. Similarly, measure ONE of the)t\n", - "(vertical lines and enter that value as Y. Measurements should be)t\n", - "(between the flat faces of the semicircles.)t\n", - "()t\n", - "(The large box is 10.25 by 7.75 inches)t\n", - "\n", - "/in { } bind def\n", - "/cm { 2.54 div } bind def\n", - "/mm { 25.4 div } bind def\n", - "\n", - 0 -}; - -static int guess(double val, double close_to, double *calib) -{ - if (val >= close_to * 0.9 && val <= close_to * 1.1) { - *calib = close_to / val; - return 0; - } - return 1; -} - -void ps_calibrate_1(rnd_hid_t *hid, double xval, double yval, int use_command) -{ - FILE *ps_cal_file; - int used_popen = 0, c; - - if (xval > 0 && yval > 0) { - if (guess(xval, 4, &global.calibration_x)) - if (guess(xval, 15, &global.calibration_x)) - if (guess(xval, 7.5, &global.calibration_x)) { - if (xval < 2) - global.ps_values[HA_xcalib].dbl = global.calibration_x = xval; - else - rnd_message(RND_MSG_ERROR, "X value of %g is too far off.\n" "Expecting it near: 1.0, 4.0, 15.0, 7.5\n", xval); - } - if (guess(yval, 4, &global.calibration_y)) - if (guess(yval, 20, &global.calibration_y)) - if (guess(yval, 10, &global.calibration_y)) { - if (yval < 2) - global.ps_values[HA_ycalib].dbl = global.calibration_y = yval; - else - rnd_message(RND_MSG_ERROR, "Y value of %g is too far off.\n" "Expecting it near: 1.0, 4.0, 20.0, 10.0\n", yval); - } - return; - } - - if (ps_calib_attribute_list[0].val.str == NULL) { - ps_calib_attribute_list[0].val.str = rnd_strdup("lpr"); - } - - if (rnd_attribute_dialog("ps_calibrate", ps_calib_attribute_list, 1, "Print Calibration Page", NULL)) - return; - - if (ps_calib_attribute_list[0].val.str == NULL) - return; - - if (use_command || strchr(ps_calib_attribute_list[0].val.str, '|')) { - const char *cmd = ps_calib_attribute_list[0].val.str; - while (*cmd == ' ' || *cmd == '|') - cmd++; - ps_cal_file = rnd_popen(&PCB->hidlib, cmd, "w"); - used_popen = 1; - } - else - ps_cal_file = rnd_fopen(&PCB->hidlib, ps_calib_attribute_list[0].val.str, "w"); - - for (c = 0; calib_lines[c]; c++) - fputs(calib_lines[c], ps_cal_file); - - fprintf(ps_cal_file, "4 in 0.5 (Y in) cbar\n"); - fprintf(ps_cal_file, "20 cm 1.5 (Y cm) cbar\n"); - fprintf(ps_cal_file, "10 in 2.5 (Y in) cbar\n"); - fprintf(ps_cal_file, "-90 rotate\n"); - fprintf(ps_cal_file, "4 in -0.5 (X in) cbar\n"); - fprintf(ps_cal_file, "15 cm -1.5 (X cm) cbar\n"); - fprintf(ps_cal_file, "7.5 in -2.5 (X in) cbar\n"); - - fprintf(ps_cal_file, "showpage\n"); - - fprintf(ps_cal_file, "%%%%EOF\n"); - - if (used_popen) - rnd_pclose(ps_cal_file); - else - fclose(ps_cal_file); -} static void ps_set_crosshair(rnd_hid_t *hid, rnd_coord_t x, rnd_coord_t y, int action) { } @@ -1435,7 +1280,6 @@ hid->fill_polygon_offs = ps_fill_polygon_offs; hid->fill_polygon = ps_fill_polygon; hid->fill_rect = ps_fill_rect; - hid->calibrate = NULL; hid->set_crosshair = ps_set_crosshair; ps_inited = 1;