1.8.3. DRAWING A CURVE WITH ANNOTATION USING THE PHIGS "TEXT" PRIMITIVE
#include <phigure.h>
main()
{
Pfloat zoom=0.8;
Pint ws_id=1, view_ind=1,
scene_id=10, segment_id=11, x_axis_id=12, y_axis_id=13;
Ppoint_list segments;
static Ptext_align annot_align = {PHOR_CTR,PVERT_BASE};
static Plimit viewport = {0.,1.,0.,1.}, domain={200.,400.,10.,20.};
static Ppoint points[5] = { {220.,12.}, {280.,14.}, {320.,13.},
{360.,16.}, {380.,15.} };
static Ppoint center_view = {0.5,0.5};
static Pvec offset = {0.,0.02};
static Ppoint3 axis_orig={200.,10.,0.0};
static Pint struct_ids[3];
static Pint_list struct_id_list = {3,struct_ids};
/* open PHIGURE and an X-Window type workstation (8887) */
topen_phigure (PDEF_ERR_FILE);
topen_ws (ws_id,PDEF_ERR_FILE,8887);
/* define 2D working domain */
tdomain(&domain);
/* build a structure with PHIGS */
popen_struct (segment_id);
segments.num_points = 5;
segments.points = points;
ppolyline (&segments);
pset_char_ht(0.03*(domain.y_max-domain.y_min));
pset_char_expan ( (domain.x_max-domain.x_min)/(domain.y_max-domain.y_min) );
ptext (&points[0],"P0");
ptext (&points[1],"P1");
ptext (&points[2],"P2");
ptext (&points[3],"P3");
ptext (&points[4],"P4");
pclose_struct ();
/* build two axes */
txy_linear_axis (x_axis_id, &axis_orig, 400., 0.0);
tyx_linear_axis (y_axis_id, &axis_orig, 20., 0.0);
/* define scene */
struct_ids[0] = segment_id;
struct_ids[1] = x_axis_id;
struct_ids[2] = y_axis_id;
tscene (scene_id,&struct_id_list,view_ind);
/* define centered 2D view */
tview2_center (ws_id,view_ind,¢er_view,zoom,&viewport);
/* plot on the workstation */
ppost_struct(ws_id,scene_id,1.);
predraw_all_structs(ws_id,PFLAG_ALWAYS);
/*close workstation and PHIGURE */
tclose_ws (ws_id);
tclose_phigure ();
}

This
example shows the use of the "text" primitive in a PHIGS structure. It also
demonstrates setting a character height equal to 3% of the domain when it is
not square. This % is multiplied by the height of the domain, and the
pset_char_expan function is called with the domain width/height ratio,
in order to compensate for the scene transformation.