⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pickbox.c

📁 Intro/: Directory containing introductory examples. HelloWorld.c A simple program that draws a bo
💻 C
字号:
#include <phigs.h>			/* get HP-PHIGS definitions for C */#include <stdio.h>			/* get standard I/O definitions */#include <math.h>			/* link with library "-lm" */#define deg 			*3.1415926535897932384/180main()					/* file "PickBox.c" */{    Pint	WorkstnID = 1;		/* workstation identifier */    Pint	ConnID;			/* connection identifier */    Pint	WorkstnType = POIDDX;	/* out/in, direct, dbl bfr, Xwindow */    Pint	SpecType;		/* specific workstation type  */    Pint	UnitType;		/* device unit type */    Pint	Root = 2,LineSquare = 1;/* structure IDs (chosen by user) */    Pint	Trans1 = 3, Trans2 = 4;	/* structure IDs (chosen by user) */    static Ppoint	AreaPts[4] = {	{0.0, 0.0}, {0.0, 0.2}, {0.2, 0.2}, {0.2, 0.0}};    static Ppoint_list	Area = {4, AreaPts};    static Ppoint	LinePts[2] = {{0.2, 0.1}, {0.4, 0.1}};    static Ppoint_list	Line = {2, LinePts};    Pdisp_space_size3	DisplaySize;    /*--- picking variables ------------------------------------------------*/    Pint	Mouse = 1;			/* pointer device number */    Pint	PET;			/* prompt/echo type */    Pint	PathDepth = 5;		/* input pick path depth */    Pin_status	PickStatus;		/* return pick status */    Plimit3	EchoVolume;    Ppick_data3	PickData;    Ppick_path	PickPath;    Ppick_path_elem	PickPathElem[5];    Ppath_order	PathOrder;    Pfilter	Filter;		/* include and exclude filters */    Pint	Include[10], Exclude[10];    Pint	Names[10];	/* an array of Pint for NameList */    Pint_list	NameList;		/* namelist array for name sets */    Pint	Name1 = 1;		/* a name for the namelist */    /*--- miscellaneous items ----------------------------------------------*/    Ppoint	Point;			/* for various locations */    Pvec	Translation, Scaling;	/* for various transformations */    Pmatrix	Matrix;			/* transformation matrix */    Pstore	Store;			/* storage area */    Pint	*ConnectID;		/* connection identifier */    Pint	Error;			/* error-return variable */    Pint	Index;			/* loop control variable */    /*=== initialize =======================================================*/    popen_phigs((char *) stderr, 0);	/* errors go to "stderr" */    pescape_u4("/dev/screen/phigs_window", &ConnID);    popen_ws(WorkstnID, (void *) ConnID, WorkstnType);    /*--- define the structure with the line and square --------------------*/    popen_struct(LineSquare);    ppolyline(&Line);    pset_int_style(PSTYLE_SOLID);    pfill_area(&Area);    pclose_struct();    /*--- define first transformation structure ----------------------------*/    popen_struct(Trans1);    Point.x = Point.y = 0.0;    Translation.delta_x = Translation.delta_y = 0.2;    Scaling.delta_x = Scaling.delta_y = 1.0;    pbuild_tran_matrix(&Point, &Translation, 0.0 deg, &Scaling, &Error,      Matrix);    pset_local_tran(Matrix, PTYPE_REPLACE);    pexec_struct(LineSquare);    pclose_struct();    /*--- build second transformation structure ----------------------------*/    popen_struct(Trans2);    Point.x = Point.y = 0.0;    Translation.delta_x = Translation.delta_y = 0.8;    Scaling.delta_x = Scaling.delta_y = 1.0;    pbuild_tran_matrix(&Point, &Translation, 180.0 deg, &Scaling, &Error,      Matrix);    pset_local_tran(Matrix, PTYPE_REPLACE);    pexec_struct(LineSquare);    pclose_struct();    /*--- build root structure ---------------------------------------------*/    popen_struct(Root);    Names[0] = Name1;			/* put Name 1 in array */    NameList.num_ints = 1;    NameList.ints = Names;    padd_names_set(&NameList);    pset_pick_id(1);    pexec_struct(Trans1);    pexec_struct(Trans2);    Point.x = Point.y = 0.0;    Translation.delta_x = 0.2, Translation.delta_y = 0.8;    Scaling.delta_x = Scaling.delta_y = 1.0;    pbuild_tran_matrix(&Point, &Translation, -90.0 deg, &Scaling, &Error,      Matrix);    pset_local_tran(Matrix, PTYPE_REPLACE);    pset_pick_id(2);		/* set pick identifier */    pexec_struct(LineSquare);	/* execute structure */    Point.x = Point.y = 0.0;    Translation.delta_x = 0.8, Translation.delta_y = 0.2;    Scaling.delta_x = Scaling.delta_y = 1.0;    pbuild_tran_matrix(&Point, &Translation, 90.0 deg, &Scaling, &Error,      Matrix);    pset_local_tran(Matrix, PTYPE_REPLACE);    pexec_struct(LineSquare);    pclose_struct();    /*=== display the structure network ====================================*/    ppost_struct(WorkstnID, Root, 1.0);    predraw_all_structs(WorkstnID, PFLAG_ALWAYS);    pcreate_store(&Error, &Store);    if (Error) printf("Error %d in pcreate_store.\n", Error), exit(1);    pinq_ws_conn_type(WorkstnID, Store, &Error, (void *)&ConnectID, &SpecType);    if (Error) printf("Error %d in pinq_ws_conn_type.\n", Error), exit(1);    pinq_disp_space_size3(SpecType, &Error, &DisplaySize);    EchoVolume.x_min = DisplaySize.size_dc.size_x * 0.0; /* \		    */    EchoVolume.x_max = DisplaySize.size_dc.size_x * 1.0; /*  \	Echo volume */    EchoVolume.y_min = DisplaySize.size_dc.size_y * 0.0; /*   \ must be	    */    EchoVolume.y_max = DisplaySize.size_dc.size_y * 1.0; /*   / specified,  */    EchoVolume.z_min = DisplaySize.size_dc.size_z * 0.0; /*  / 	even though */    EchoVolume.z_max = DisplaySize.size_dc.size_z * 1.0; /* /	ignored.    */    PickStatus = PIN_STATUS_NO_IN;    PET = 1;    PickData.pets.pet_r1.highl_colr_ind = 2;    PickData.pets.pet_r1.x_dim = 0.005;    PickData.pets.pet_r1.y_dim = 0.005;    PickData.pets.pet_r1.z_dim = 2.0;    PickData.pets.pet_r1.draw_aperture = 1;    PickPath.path_list = PickPathElem;    pinit_pick3(WorkstnID, Mouse, PickStatus, &PickPath, PET, &EchoVolume,      &PickData, PORDER_TOP_FIRST);    Filter.incl_set.num_ints = 1;    Filter.incl_set.ints = Include;    Include[0] = Name1;		/* put Name 1 into the pick filter */    Filter.excl_set.num_ints = 0;    pset_pick_filter(WorkstnID, Mouse, &Filter);    printf("Ready for pick input; click on the background (or press the\n");    printf("[Break] key) to quit.\n");    while (1) {	preq_pick(WorkstnID, Mouse, PathDepth, &PickStatus, &PickPath);	printf("Pick-path depth: %d\n", PickPath.depth);	if (PickStatus == PIN_STATUS_OK) {	/* print pick path */	    for (Index = 0; Index < PickPath.depth; Index++) {		printf("  Structure No.:    %d\n",		  PickPath.path_list[Index].struct_id);		printf("    Pick ID:        %d\n",		  PickPath.path_list[Index].pick_id);		printf("    Element Offset: %d\n",		  PickPath.path_list[Index].elem_pos);	    }	}	else {	    printf("PickStatus: %d; terminating.\n", PickStatus);	    break;	}    }    pupd_ws(WorkstnID, PFLAG_PERFORM);    pclose_ws(WorkstnID);    pdel_store(&Error, &Store);    if (Error) printf("Error %d in pdel_store.\n", Error), exit(1);    pclose_phigs();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -