/[opencvs]/eyes/plottest2.c
ViewVC logotype

Contents of /eyes/plottest2.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Tue Apr 16 13:59:15 2013 UTC (5 years, 3 months ago) by hib
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
Added hpgl2 routines and bitmap_to_hpgl2 - this allows
us to use the vector mode to print out 600 dots per inch
on the hp designjet 600.  It is kind of a folloy, but it is a use of what I have versus what I dont have.
I only made a 36 x 1/2 inch strip so far.  This has no scaling defined so it
should be asolute.  the print area is about 3 inches smaller (or more) than the printer size. Also,  the printer margins is not even.  But hey,
it probably works.

Right now I am testing a 2.3 inch long strip which will take 20 minutes to run.
And then there is the question of if the plotter can handle millions
of vector commands - which we just don't know yet.
If it can't then there might be a way to send it in blocks - I guess blocks of 12 million or so because that is the memory size of the plotter I got.
1 #include <stdio.h>
2 #include <plot.h>
3 #include <math.h>
4 #define SIZE 100.0 /* nominal size of user coordinate frame */
5 #define EXPAND 2.2 /* expansion factor for elliptical box */
6
7 void draw_boxed_string (plPlotter *plotter,
8 char *s, double size, double angle)
9 {
10 double true_size, width;
11
12 pl_ftextangle_r (plotter, angle); /* set text angle (degrees) */
13 true_size = pl_ffontsize_r (plotter, size); /* set font size */
14 width = pl_flabelwidth_r (plotter, s); /* compute width of string */
15 pl_fellipserel_r (plotter, 0.0, 0.0,
16 EXPAND * 0.5 * width, EXPAND * 0.5 * true_size,
17 angle); /* draw surrounding ellipse */
18 pl_alabel_r (plotter, 'c', 'c', s); /* draw centered text string */
19 }
20
21 int main()
22 {
23 plPlotter *plotter;
24 plPlotterParams *plotter_params;
25 int i;
26
27 /* set a Plotter parameter */
28 plotter_params = pl_newplparams ();
29 // pl_setplparam (plotter_params, "BITMAPSIZE", "900x1200");
30 // pl_setplparam (plotter_params, "PAGESIZE","letter");
31 pl_setplparam (plotter_params, "PAGESIZE",
32 "e,xsize=35.0in,xoffset=0.0in,ysize=43.0in,yoffset=0.0in");
33
34 /* create a Postscript Plotter that writes to standard output */
35 if ((plotter = pl_newpl_r ("hpgl", stdin, stdout, stderr,
36 plotter_params)) == NULL)
37 {
38 fprintf (stderr, "Couldn't create Plotter\n");
39 return 1;
40 }
41
42 if (pl_openpl_r (plotter) < 0) /* open Plotter */
43 {
44 fprintf (stderr, "Couldn't open Plotter\n");
45 return 1;
46 }
47 /* specify user coor system */
48 pl_fspace_r (plotter, 0.,0.,36.,48.); // backwards
49 // pl_fspace_r (plotter, 0.,1000.,1000.,0.);
50 pl_pencolorname_r (plotter, "black"); /* use blue pen */
51 pl_fillcolorname_r (plotter, "white"); /* set white fill color */
52 pl_filltype_r (plotter, 1); /* fill ellipses with fill color */
53 /* choose a Postscript font */
54 pl_fmove_r (plotter, 36.-8.,24.);
55 pl_fontsize_r(plotter,9.);
56 pl_ftextangle_r (plotter, 90); /* set text angle (degrees) */
57 pl_alabel_r(plotter,'c','c',"\\HE \\HE");
58 pl_fontname_r (plotter, "Arc");
59 pl_fmove_r (plotter, 36.-29.,24.);
60 pl_fontsize_r(plotter,8.);
61 pl_ftextangle_r (plotter, 90); /* set text angle (degrees) */
62 pl_alabel_r(plotter,'c','c',"Welcome");
63 pl_fmove_r (plotter, 36.-18.,24.);
64 pl_fontsize_r(plotter,8.);
65 pl_ftextangle_r (plotter, 90); /* set text angle (degrees) */
66 pl_alabel_r(plotter,'c','c',"Back");
67 pl_fmove_r (plotter, 36.-8.,24.);
68 pl_fontsize_r(plotter,9.);
69 pl_ftextangle_r (plotter, 90); /* set text angle (degrees) */
70 pl_alabel_r(plotter,'c','c',"Qi She");
71
72
73 pl_flinewidth_r (plotter, (1.0/50.0)); /* set line thickness */
74 {
75 int i;
76 int size=76;
77 for (i=0;i<size;i++) {
78 double cx,cy;
79 double angle;
80 angle = 3.1415927*2.0*(double)(i)/(double)(size);
81 cy = 24. + 7. *cos(angle);
82 cx = (36.-18.) + 7. * 0.6666666666 *sin(angle);
83 double x,y;
84 y = 24. - 24. * cos(angle);
85 x = (36.-18.) + 18. * sin(angle);
86
87 pl_fmove_r(plotter,cx,cy);
88 pl_fcont_r(plotter,x,y);
89 }
90
91 }
92
93 if (pl_closepl_r (plotter) < 0) /* close Plotter */
94 {
95 fprintf (stderr, "Couldn't close Plotter\n");
96 return 1;
97 }
98 if (pl_deletepl_r (plotter) < 0) /* delete Plotter */
99 {
100 fprintf (stderr, "Couldn't delete Plotter\n");
101 return 1;
102 }
103 return 0;
104 }
105
106

  ViewVC Help
Powered by ViewVC 1.1.5