1.8.1. DRAWING 2 AXES AND STRAIGHT SEGMENTS
/* include file containing the "define" and types specific to PHIGURE */
#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 points[2];
Ppoint_list segment;
static Plimit viewport = {0.,1., 0., 1.}, domain = {10., 20., 10., 20. };
static Ppoint view_center = {0.5, 0.5};
static Ppoint3 axis_orig = {10.0,10.0,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 domain */
tdomain (&domain);
/* build 2 axes */
txy_linear_axis (x_axis_id, &axis_orig, 20.0, 0.0);
tyx_linear_axis (y_axis_id, &axis_orig, 20.0, 0.0);
/* build a structure with PHIGS */
popen_struct (segment_id);
segment.num_points = 2;
segment.points = points;
points[0].x = 12.0; points[0].y = 13.0; /* point coordinates are in relation */
points[1].x = 14.0; points[1].y = 14.0; /* with the domain linked to the scene */
ppolyline(&segment);
points[0].x = 17.0; points[0].y = 18.0;
points[1].x = 18.0; points[1].y = 17.0;
ppolyline(&segment);
pclose_struct ();
/* 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 a centered 2D view */
tview2_center (ws_id, view_ind, &view_center, zoom, &viewport);
/* display scene on workstation */
ppost_struct (ws_id, scene_id, 1.0);
predraw_all_structs (ws_id, PFLAG_ALWAYS);
/* close workstation and PHIGURE */
tclose_ws (ws_id);
tclose_phigure ();
}
