?? knobbox.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 + -