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

📄 knobbox.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" */main()					/* file "KnobBox.c" */{    Pint	WorkstnID = 1;		/* workstation identifier */    Pint	ConnID;			/* connection identifier */    Pint	WorkstnType = POIDDX;	/* out/in, direct, dbl bfr, Xwindow */    Pstore	Store;			/* internal storage area */    Pint	*ConnectID;		/* returned from "pinq_ws_conn_type" */    Pint	SpecificType;		/* specific workstation type */    Pdisp_space_size3 WindowSize;	/* size of X window */    Pfloat	XwndwXmax, XwndwYmax;	/* temporary variables */    Pfloat	SliderWidth;		/* width of popup valuator sliders */    Pfloat	InterSliderX;		/* horizontal space between sliders */    Pfloat	SliderHeight;		/* height of popup valuator sliders */    Pfloat	InterSliderY;		/* vertical space between sliders */    Pfloat	ValLimits[18] = {		0.0, 10.0,  0.0, 10.0,  -1.0, 1.0,  -5.0, 5.0,  25.0, 35.0,		-0.20, -0.10,  -20.0, -10.0,  32.0, 33.0,  0.0, 100.0};    Plimit	SliderRect;		/* where the popup sliders go */    Pval_data	SliderData;		/* slider limits, colours */    Pint	Mouse = 1;		/* choice device for mouse */    Pin_status	Status;			/* choice input status */    Pint	Choice;			/* the choice returned */    Pfloat	Value;			/* the valuator value returned */    Pint	Error;			/* error-return variable */    int		Temp;			/* temporary variable */    int		I;			/* loop control variable */    popen_phigs((char *) stderr, 0);	/* errors go to "stderr" */    pescape_u4("/dev/screen/phigs_window", &ConnID);    popen_ws(WorkstnID, (void *) ConnID, WorkstnType);    printf("Knob box valuator ranges:\n");    for (I = 0; I < 9; I++) {	Temp = 6 + (I % 3) * 2 - I;	printf("  Knob %d: %+6.2f -> %+6.2f%s", Temp, ValLimits[Temp * 2],	  ValLimits[Temp * 2 + 1], (I % 3 == 2)?"\n":"");    }    printf("%s\n%s\n%s\n%s\n",      "Move the mouse into \"phigs_window\", and then turn some of the",      "knobs, noting the corresponding movement of the valuators' sliders.",      "Click the left mouse button (Button 1) to print the current values.",      "Press the [Break] key or click mouse Button 2 to quit the program.");    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,      &SpecificType);    if (Error) printf("Error %d in pinq_ws_conn_type.\n", Error), exit(1);    pinq_disp_space_size3(SpecificType, &Error, &WindowSize);    if (Error) printf("Error %d in pinq_disp_space_size3.\n", Error), exit(1);    XwndwXmax = WindowSize.size_dc.size_x;    XwndwYmax = WindowSize.size_dc.size_y;    SliderWidth  = 0.3 * XwndwXmax;    InterSliderX = (XwndwXmax - 3 * SliderWidth) * 0.25;    SliderHeight = 0.2 * XwndwYmax;    InterSliderY = (XwndwYmax - 3 * SliderHeight) * 0.25;    for (I = 0; I < 9; I++) {	SliderRect.x_min = (I % 3 + 1) * InterSliderX + (I % 3) * SliderWidth;	SliderRect.x_max = SliderRect.x_min + SliderWidth;	SliderRect.y_min = (I / 3 + 1) * InterSliderY + (I / 3) * SliderHeight;	SliderRect.y_max = SliderRect.y_min + SliderHeight;	SliderData.low_value = ValLimits[I * 2];	SliderData.high_value = ValLimits[I * 2 + 1];	SliderData.pets.pet_u1.slider_colr_ind = 1;	SliderData.pets.pet_u1.border_flag = 1;	SliderData.pets.pet_u1.border_colr_ind = 2;	SliderData.pets.pet_u1.scale_factor = 1.0;	pinit_val(WorkstnID,			/* workstation identifier */	  I + 10,				/*   valuator number */	  (ValLimits[I*2]+ValLimits[I*2+1])/2,	/*   initial: mid. of range*/	  -1,					/*   popup slider, attrs. */	  &SliderRect,				/*   where popup goes */	  &SliderData);				/*   popup's limits, colours */	pset_val_mode(WorkstnID, I + 10, POP_SAMPLE, PSWITCH_ECHO);    }    while (1) {	preq_choice(WorkstnID, Mouse, &Status, &Choice);	if (Status == PIN_STATUS_OK) {	    printf("Mouse button %d clicked.\n", Choice);	    for (I = 0; I < 9; I++) {		psample_val(WorkstnID, 16 + (I % 3) * 2 - I, &Value);		printf("  %+6.2f%s", Value, (I % 3 == 2)?"\n":"");	    }	    if (Choice == 2) {		printf("Mouse Button 2 clicked; terminating.\n");		break;	    }	}	else {	    if (Status == PIN_STATUS_NONE) {		printf("[Break] key pressed; terminating.\n");		break;	    }	}    }    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 + -