Previous Next Up Title Contents Index Functions Index Top Library

1.9.4. EXAMPLE

#include <Xm/Xm.h>
#include <phigure.h>
#include "GPhigsW.h"

Pint  ws_id=1, view_ind=1;
Pfloat zoom=0.7;
Plimit viewport  = {0.,1.,0.,1.};
Ppoint view_center = {0.5,0.5};

/*------------------------------------------*/

void resize_phigure_CB(w,client_data,call_data)
	Widget w;
	XtPointer client_data,call_data;
{
	printf( " RESIZE \n");
	tupd_ws(ws_id,PFLAG_POSTPONE);
	tview2_center (ws_id,view_ind,&view_center,zoom,&viewport);
	predraw_all_structs(ws_id,PFLAG_ALWAYS);
}

/*------------------------------------------*/

void open_phigure_CB(w,client_data,call_data)
	Widget w;
	XtPointer client_data,call_data;
{
	Pint	scene_id=10, circle_id=11, x_axis_id=12, y_axis_id=13;
	Pfloat	circle_radius = 5.0;
	Tcircle circle;
	static	Plimit domain={10.,20.,10.,20.};
	static	Ppoint circle_center={15.,15.};
	static	Ppoint3 axis_orig={10.,10.,0.0};
	static	Pint struct_ids[3];
	static	Pint_list struct_id_list = {3,struct_ids};

	topen_ws  (1,PDEF_ERR_FILE,8887);

  tdomain(&domain);

	/* build circle */
	circle.type = TCENTER_RADIUS;
	circle.geometry.cr.c = circle_center;
	circle.geometry.cr.r = circle_radius;
	tcircle (circle_id,&circle);

	/* build two axes */
	txy_linear_axis (x_axis_id, &axis_orig, 20., 0.0);
	tyx_linear_axis (y_axis_id, &axis_orig, 20., 0.0);

	/* define scene */
	struct_ids[0] = circle_id;
	struct_ids[1] = x_axis_id;
	struct_ids[2] = y_axis_id;
	tscene (scene_id,&struct_id_list,view_ind);
	tset_text_font (scene_id,0,1);

	ppost_struct(ws_id,scene_id,1.);

	/* define centered view in 2D */
	tview2_center (ws_id,view_ind,&view_center,zoom,&viewport);

	predraw_all_structs(ws_id,PFLAG_ALWAYS);

}
/*------------------------------------------*/

main(argc,argv)
int argc; char **argv;
{
	Widget toplevel, phigure ;
	int    n, ac = 0;
	Arg    args[5] ;

	toplevel = XtInitialize (" ", "config_file", NULL, 0, &ac, NULL);

	topen_phigure(PDEF_ERR_FILE);
	n = 0;
	XtSetArg(args[n], XmNresizeWs, XmGPHIGS_RESIZE_WS); n++;
	phigure = XmCreateGPhigsW(toplevel,"PHIGURE",args,n);

	XtManageChild(phigure);
	XtAddCallback(phigure,XmNcreateDACallback,open_phigure_CB,NULL);
	XtAddCallback(phigure,XmNresizeDACallback,resize_phigure_CB,NULL);

	XtRealizeWidget  (toplevel);

	XtMainLoop();

}


Previous Next Up Title Contents Index Functions Index Top Library