------- Received: from VMB.BRL.MIL by VMB.BRL.MIL id aa00106; 18 Aug 88 20:39 EDT Received: from VMB.BRL.MIL by VMB.brl.MIL id aa01422; 18 Aug 88 17:38 EDT Received: from smoke.brl.mil by VMB.BRL.MIL id aa01365; 18 Aug 88 17:27 EDT Received: from orville.nas.nasa.gov by SMOKE.BRL.MIL id aa10004; 18 Aug 88 17:18 EDT Received: Thu, 18 Aug 88 14:18:29 PDT by orville.nas.nasa.gov (5.59/1.2) Date: Thu, 18 Aug 88 14:18:29 PDT From: "David A. Tristram" Message-Id: <8808182118.AA25270@orville.nas.nasa.gov> To: info-iris@BRL.MIL Subject: Panel Library User Interface Cc: dat@orville.nas.nasa.gov To IRIS application Developers: The following 6 messages are source for the "Panel Library", a user interface package for 2400's through the 4D/70GT. After unsharing, edit the make file to uncomment the definitions for options for your hardware. Then type make. Note: not all demos exhibit 'correct' behaviour, this is because some of them are not really complete programs but just examples of some technique. If you use this software please send notification to the address below, you can get upgrades and news that way, and I can score some points here. Also, send bug reports, fixes, complaints, mods, extensions, flames, etc. David A Tristram NASA Ames Research Center MS 258-5 Moffett Field, CA 94035 415 694 4404 dat@orville.nas.nasa.gov ------- Received: from VMB.BRL.MIL by VMB.BRL.MIL id aa01476; 18 Aug 88 17:49 EDT Received: from VMB.BRL.MIL by VMB.brl.MIL id ab01422; 18 Aug 88 17:38 EDT Received: from smoke.brl.mil by VMB.BRL.MIL id ab01365; 18 Aug 88 17:27 EDT Received: from orville.nas.nasa.gov by SMOKE.BRL.MIL id aa10067; 18 Aug 88 17:21 EDT Received: Thu, 18 Aug 88 14:20:00 PDT by orville.nas.nasa.gov (5.59/1.2) Date: Thu, 18 Aug 88 14:20:00 PDT From: "David A. Tristram" Message-Id: <8808182120.AA25292@orville.nas.nasa.gov> To: info-iris@BRL.MIL Subject: panel01/06 #!/bin/sh # shar: Shell Archiver (v1.22) # # This is part 1 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # # Run the following text with /bin/sh to create: # Makefile # README # VERSION # button.c # colormod.c # demo.c # demo10.c # demo11.c # demo12.c # demo13.c # demo14.c # demo15.c # demo16.c # demo17.c # demo18.c # demo19.c # demo2.c # demo20.c # demo21.c # demo22.c # demo23.c # demo24.c # demo25.c # demo26.c # demo3.c # demo4.c # demo5.c # demo6.c # demo7.c # demo8.c # demo9.c # dial.c # ep.c # epslideroid.c # eric.c # fade.c # g_gets.c # gets.c # mouse.c # palette.c # panel.c # panel.h # puck.c # script.c # slider.c # slideroid.c # stoa.c # strip.c # typein.c # typeout.c # if test -r s2_seq_.tmp then echo "Must unpack archives in sequence!" next=`cat s2_seq_.tmp`; echo "Please unpack part $next next" exit 1; fi sed 's/^X//' << 'SHAR_EOF' > Makefile && X# X# IRIS_4D flags X# X#CFLAGS= -g -DDEBUG -DIRIS_4D X#CFLAGS= -g -DIRIS_4D X#CFLAGS= -g -DIRIS_4D X#ARFLAGS= rsv X#RANLIB= ar ts X# X# IRIS_GT flags X# XCFLAGS= -g -DDEBUG -DIRIS_4D -DIRIS_NEWS -DIRIS_GT XCFLAGS= -g -DIRIS_4D -DIRIS_NEWS -DIRIS_GT XARFLAGS= rsv XRANLIB= ar ts X# X# IRIS_3000 flags X# X#CFLAGS= -g -DDEBUG X#CFLAGS= -g X#ARFLAGS= rv X#RANLIB= ranlib X# X# X# installation destinations X# XINCLUDEDIR= /usr/local/include XLIBDIR= /usr/local/lib X# X# products X# XINCLUDE= panel.h XLIB= libpanel.a X# X# compilation control X# XINCLUDES= -I. XLIBS= -lgl -lm XLIBOBJS= ${LIB}(panel.o) ${LIB}(puck.o) ${LIB}(slider.o) ${LIB}(g_gets.o) \ X ${LIB}(strip.o) ${LIB}(button.o) ${LIB}(typein.o) ${LIB}(typeout.o) \ X ${LIB}(mouse.o) ${LIB}(slideroid.o) ${LIB}(palette.o) \ X ${LIB}(dial.o) X XDEMOSO= demo.o demo2.o demo3.o demo4.o demo5.o \ X demo6.o demo7.o demo8.o demo9.o demo10.o \ X demo11.o demo12.o demo13.o demo14.o demo15.o \ X demo16.o demo17.o demo18.o demo19.o demo20.o demo21.o \ X demo22.o demo23.o demo24.o demo25.o demo26.o XDEMOSO= demo25.o demo26.o XAPPS= ep stoa X XDEMOS= ${DEMOSO:.o=} X Xall: ${LIB} ${DEMOS} ${APPS} X X${APPS}: panel.h X X.PRECIOUS: ${LIB} X X${LIB}: ${LIBOBJS} panel.h X ${RANLIB} ${LIB} X X${LIBOBJS}: X ${CC} -c ${CFLAGS} $< X ${LD} -r $*.o X /bin/mv a.out $*.o X ${AR} ${ARFLAGS} $@ $*.o X X${DEMOS}: ${LIB} X ${CC} -c ${CFLAGS} $@.c X ${CC} ${CFLAGS} ${LDFLAGS} $@.o -o $@ ${LIB} ${LIBS} X X${DEMOSO}: panel.h X X.o: ${LIB} X ${CC} ${CFLAGS} ${LDFLAGS} $@.o -o $@ ${LIB} ${LIBS} X Xep: ep.o script.o colormod.o fade.o ${LIB} panel.h X cc -o ep ep.o colormod.o fade.o script.o libpanel.a -lgl -lm X X#ep: ep.u colormod.o fade.o ${LIB} panel.h X# cc -O3 -p -o ep ep.u colormod.o fade.o libpanel.a -lgl -lm X# X#ep.u: ep.c X# ${CC} -O3 ${INCLUDES} -j ep.c X# ${CC} ${CFLAGS} -DDEBUG ${INCLUDES} -c ep.c X X.c.o: X cc ${CFLAGS} -c $< ${INCLUDES} X Xstoa: stoa.o ${LIB} panel.h X cc -o stoa stoa.o libpanel.a -lgl -lm X Xclean: X -rm -f *.o X Xclobber: clean X -rm ${DEMOS} ${LIB} ep stoa X Xinstall: X cp ${LIB} ${LIBDIR} X ${RANLIB} ${LIBDIR}/${LIB} X cp ${INCLUDE} ${INCLUDEDIR} X SHAR_EOF chmod 0644 Makefile || echo "restore of Makefile fails" sed 's/^X//' << 'SHAR_EOF' > README && XThis is the panel library, a set of routines used for building "control Xpanel" interfaces to interactive graphic applications. These routines Xlet you assemble "actuators" like sliders, buttons, stripcharts, and Xtypeouts into control panels that live on separate mex windows. As the Xuser mouses the actuators, values accessable to the applications programmer, X(THAT'S YOU!) appear in predefined structures. You can also set the values Xand watch the positions or states of the actuators change. You can Xcustomize the actuators in many ways because alot of their properties are Xcontrolled by indirect functions that you can replace with your own. In Xfact, you can add new actuators without changing any of the panel library Xcode because the initialization function is one of these indirect guys! XSomeday all this will be nicely documented, but until then, hopefully you Xcan get something out of the 20 or so demo programs. Try ep, the Xpsychedelic electro-paint program. Have fun. X X David A Tristram X NASA Ames Research Center X Numerical Aerodynamic Simulation Systems Division X Moffett Field, CA 94035 X 415-694-4404 X dat@ames-nas.ARPA X Xps: g_gets.c is useful in its own right, get strings from a graphics X program, thanks for preliminary work by Diana Choi. X XOperating Notes: X XTo see the panels, run the sgi utility makemap to load reasonable Xvalues into the color map. The colors can be changed either by Xbashing the entries that are used, or changing the global variables Xpnl_normal_color, pnl_highlight_color, pnl_other_color, etc. X X XAdding Your Own Actuators. X XTo add your own actuators, you only have to support a couple of Xfunctional interfaces. The basic functions are drawX and my_X. XDrawX draws the actuator in a standard 2D coordinate system, and my_X Xis initialization code. If your actuator is going to be mouse Xsensitive, it also needs a newvalX function. In this and the Xfollowing discussion, X stands for the name of your new actuator, and Xmy_ is a short prefix intended to help avoid collisions in a user's Xname space. X XAdditional functions you may need for your actuator are addX, which Xgetes executed when the actuator is added to a panel, ie., after the Xuser has had an opportunity to customize its properties, and fixX, Xwhich is used to bring an actuator's internal state up-to-date with Xrespect to its environment. X XSo, to add an actuator type you would do something like this: X XStart a new source file beginning with X X#include X#include X Xthat is called .c where is the name or some Xshortened form of the generic type of actuator you are adding. For Xexample, let's say you are adding an actuator called a dial consisting Xof a circular pointer that you can turn with the mouse. Your source Xfile might be called dial.c X XIn your source file you need to support the following functions: X Xvoid drawdial(a, p) XActuator *a; XPanel *p; X{ X/* The actuator's drawfunc gets called by dopanel() after normal mouse X * event handling has be performed if the actuators dirtycnt is X * non-zero. The dirtycnt gets set automatically whenever an actuator X * is selected, and may also be set by the user. Fixact() also sets X * the dirtycnt. */ X X/* In drawdial goes code to actually draw the dial. In the panel X * library it is assumed that all actuators are rectangular, so you X * might want to make some kind of background rectangle to indicate X * the mouseable region. On the iris it looks better to put an X * outline around things. Look at the code for the other actuators X * for the names of the colors to use. The actuators that come with X * the panel library are drawn using a coordinate system that is X * supposed to make it easier for the user to lay out control X * panels. Sliders, for example, are just under one unit wide and six X * units high. This allows the user to plunk his sliders down at X * integer grid points and have the panel look okay. There are some X * manifest constants for the dimensions of the little spaces that X * show up between actuators. Use the val field of the Actuator X * structure you get the pointer to when drawdial() is called to X * determine what position to draw the dial in. If your actuator X * allows labels add a line like X X if (a->label) drawlabel(a, p); X X * at the end of the function. X */ X} X Xvoid my_dial(a) XActuator *a; X{ X/* this is initialization code that converts a generic actuator X * structure to one that implements your kind of actuator. You have X * to tie all your functions to the actuator here. */ X X a->type=MY_DIAL; /* an integer for your dials > PNL_MAXACT */ X X a->w=MY_DIAL_WIDTH; /* like maybe 2.0-PNL_DIM_1 */ X a->h=MY_DIAL_HEIGHT; /* these are default dimensions, that X the user can bash */ X X/* you may want to do other initialization here, for example, you can X * set the labeltype to one of the five predefined types. If your X * actuator has a special internal data structure, space for it should X * be allocated for it here. X */ X X/* if you have other functions then they go here. like maybe: */ X/* a->newvalfunc=newvaldial; */ X/* a->addfunc=adddial; */ X a->drawfunc=drawdial; X} X X Xvoid newvaldial(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ X/* the newvalfunc for an actuator if first called when the mouse X * button goes down and the mouse is within the rectangular region X * defined by the actuator's x, y, w, and h. It is then called X * repeatedly while the mouse button remains down. When the mouse X * button goes up, the newvalfunc is called once again. */ X X/* Sx and sy are screen (pixel) coordinates of the mouse relative to X * the origin of the panel. To get floating point coordinates X * relative to the origin of your actuator, use: */ X X mapw2(p->vobj,sx,sy,&wx,&wy); X wx-=a->x; X wy-=a->y; X X/* Now you have to come up with some way to map the wx and wy to a new X * value for your actuator. Sliders, for example, take wy and scale X * it to a fraction of the total height of the slider, and then X * interpolate minval and maxval to come up with val. For a dial you X * might add the step of determining the angular distance from some X * index mark, and use that as your interpolation fraction. You will X * notice that this is the inverse of the mapping that you made for X * drawdial. X */ X X/* some actuators (toggle buttons, for example) have different X * behavior when first moused. You can examine the panel library X * global variables pnl_justup and pnl_justdown to discriminate these X * states. */ X} X Xvoid Xadddial(a, p) XActuator *a; XPanel *p; X{ X/* Dial actuators don't need an addfunc, but some actuators do special X * processing when they are added to a panel. Stripcharts, for X * example, malloc space to store their histories. If the user X * desires, the storage capacity of a stripchart may be increased by X * bumping the value of one of the fields in the stripchart's data X * area. Then, when the stripchart is added to a panel, its addfunc X * is called which does the malloc. Another example is the radio X * button. When it is added to a panel, its address is added to a X * list of radio buttons that are forming a group. The list is a X * field called group in the actuator structure and you can use that X * field to provide special interaction among a set of like actuators. X */ X} X X XTo use the new actuator, my_dial has to be declared as an external Xreference. When the user calls mkact() the argument to mkact Xis a pointer to this my_dial. The other functions are all scoped Xlocally to dial.c and need not appear in the user code. SHAR_EOF chmod 0644 README || echo "restore of README fails" sed 's/^X//' << 'SHAR_EOF' > VERSION && X7 SHAR_EOF chmod 0644 VERSION || echo "restore of VERSION fails" sed 's/^X//' << 'SHAR_EOF' > button.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include "panel.h" X Xvoid _newvalbutton(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ X a->val=pnl_mousedown; X} X Xvoid _newvaltogglebutton(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ X if (pnl_justdown) a->val=(a->val!=0.0)?0.0:1.0; X} X Xvoid _newvalradiobutton(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ XActuator *b; X X if (pnl_justdown) a->val=1.0; X for (b=a->group;(b!=a);b=b->group) { X b->val=0.0; X b->dirtycnt=2; X } X} X Xvoid X_addradiobutton(a, p) XActuator *a; XPanel *p; X{ X addtogroup(a, p); X} X Xvoid X_drawbutton(a, p) XActuator *a; XPanel *p; X{ X if (a->active) { X color(pnl_highlight_color); X } else { X color(pnl_normal_color); X } X rectf(a->x,a->y,a->x+a->w,a->y+a->h); X color(pnl_outline_color); X rect(a->x,a->y,a->x+a->w,a->y+a->h); X if (a->label) drawlabel(a, p); X} X Xvoid X_drawtogglebutton(a, p) XActuator *a; XPanel *p; X{ X if (a->val!=0.0) { X color(pnl_highlight_color); X } else { X color(pnl_normal_color); X } X rectf(a->x,a->y,a->x+a->w,a->y+a->h); X color(pnl_outline_color); X rect(a->x,a->y,a->x+a->w,a->y+a->h); X if (a->val!=0.0) { X move2(a->x,a->y); X draw2(a->x+a->w,a->y+a->h); X move2(a->x,a->y+a->h); X draw2(a->x+a->w,a->y); X } X if (a->label) drawlabel(a, p); X} X Xvoid X_drawwidebuttonshape(a, p, style) XActuator *a; XPanel *p; Xint style; X{ X if (style==PNL_FILLED) { X move2(0.0,0.0); X rpmv2(PNL_DIM_2, 0.0); X rpdr2(a->w-2.0*PNL_DIM_2, 0.0); X rpdr2(PNL_DIM_2, PNL_DIM_2); X rpdr2(0.0, a->h-2.0*PNL_DIM_2); X rpdr2(-PNL_DIM_2, PNL_DIM_2); X rpdr2(-(a->w-2.0*PNL_DIM_2), 0.0); X rpdr2(-PNL_DIM_2, -PNL_DIM_2); X rpdr2(0.0, -(a->h-2.0*PNL_DIM_2)); X pclos(); X } else { X move2(0.0,0.0); X rmv2(PNL_DIM_2, 0.0); X rdr2(a->w-2.0*PNL_DIM_2, 0.0); X rdr2(PNL_DIM_2, PNL_DIM_2); X rdr2(0.0, a->h-2.0*PNL_DIM_2); X rdr2(-PNL_DIM_2, PNL_DIM_2); X rdr2(-(a->w-2.0*PNL_DIM_2), 0.0); X rdr2(-PNL_DIM_2, -PNL_DIM_2); X rdr2(0.0, -(a->h-2.0*PNL_DIM_2)); X rdr2(PNL_DIM_2, -PNL_DIM_2); X } X} X Xvoid X_drawwidebutton(a, p) XActuator *a; XPanel *p; X{ X pushmatrix(); X translate(a->x,a->y,0.0); X X if (!a->active) X color(pnl_normal_color); X else X color(pnl_highlight_color); X X _drawwidebuttonshape(a, p, PNL_FILLED); X color(pnl_outline_color); X _drawwidebuttonshape(a, p, PNL_OPEN); X X if (a->label&&(p->ppu>pnl_char_threshold)) { X if (!a->active) X color(pnl_outline_color); X else X color(pnl_normal_color); X cmov2(a->lx,a->ly+a->ld); X charstr(a->label); X } X X popmatrix(); X} X Xvoid Xpnl_button(a) XActuator *a; X{ X a->type=PNL_BUTTON; X X a->w=PNL_BUTTON_EDGE; X a->h=PNL_BUTTON_EDGE; X a->labeltype=PNL_LABEL_RIGHT; X a->newvalfunc=_newvalbutton; X a->drawfunc=_drawbutton; X} X Xvoid Xpnl_radio_button(a) XActuator *a; X{ X a->type=PNL_RADIO_BUTTON; X X a->w=PNL_BUTTON_EDGE; X a->h=PNL_BUTTON_EDGE; X a->labeltype=PNL_LABEL_RIGHT; X a->addfunc=_addradiobutton; X a->newvalfunc=_newvalradiobutton; X a->drawfunc=_drawtogglebutton; X} X Xvoid Xpnl_toggle_button(a) XActuator *a; X{ X a->type=PNL_TOGGLE_BUTTON; X X a->w=PNL_BUTTON_EDGE; X a->h=PNL_BUTTON_EDGE; X a->labeltype=PNL_LABEL_RIGHT; X a->newvalfunc=_newvaltogglebutton; X a->drawfunc=_drawtogglebutton; X} X Xvoid Xpnl_wide_button(a) XActuator *a; X{ X a->type=PNL_WIDE_BUTTON; X X a->w=PNL_WIDE_BUTTON_WIDTH; X a->h=PNL_WIDE_BUTTON_HEIGHT; X a->labeltype=PNL_LABEL_CENTER; X a->newvalfunc=_newvalbutton; X a->drawfunc=_drawwidebutton; X} X SHAR_EOF chmod 0644 button.c || echo "restore of button.c fails" sed 's/^X//' << 'SHAR_EOF' > colormod.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X/* X * colormod - X * Define some transforms between different color models. X * X * X * Henry Moreton and Paul Haeberli - 1984 X */ X#include "math.h" X#include "stdio.h" X X/* X * Defines for colors used by window manager tools X * X * Paul Haeberli - 1984 X * X * (a subset, dat) X */ X X#define COLORSYS_RGB 1 X#define COLORSYS_CMY 2 X#define COLORSYS_HSV 3 X#define COLORSYS_HLS 4 X#define COLORSYS_YIQ 5 X X#define max(x,y) ((x) > (y) ? (x) : (y)) X#define min(x,y) ((x) < (y) ? (x) : (y)) X Xint rgb_to_rgb(); X Xstatic int (*tofunc)() = rgb_to_rgb; Xstatic int (*fromfunc)() = rgb_to_rgb; Xstatic int colorsys = COLORSYS_RGB; X X/* X * Convert FROM various formats TO rgb. X * X * X */ Xirgb_to_rgb( ir, ig, ib, r, g, b) Xint ir, ig, ib; Xfloat *r, *g, *b; X{ X *r = ir / 255.0; X *g = ig / 255.0; X *b = ib / 255.0; X} X Xcmy_to_rgb ( c, m, y, r, g, b) Xfloat c, m, y; Xfloat *r, *g, *b; X{ X *r = 1.0 - c; X *g = 1.0 - m; X *b = 1.0 - y; X} X Xstatic float value(n1, n2, hue) Xfloat n1, n2, hue; X{ X if (hue > 360) X hue -= 360; X if (hue < 0) X hue += 360; X if (hue < 60) X return(n1 + (n2 - n1)*(hue/60.0)); X if (hue < 180) X return(n2); X if (hue < 240) X return(n1 + (n2 - n1)*((240 - hue)/60.0)); X return(n1); X} X Xhls_to_rgb (h, l, s, r, g, b) Xfloat h, l, s; Xfloat *r, *g, *b; X{ X float m1, m2; X X h *= 360.0; X if (l <= 0.5) X m2 = l * (1 + s); X else X m2 = l + s - l*s; X m1 = 2*l - m2; X if (s == 0) X *r = *g = *b = l; X else { X *r = value(m1, m2, h + 120.0); X *g = value(m1, m2, h); X *b = value(m1, m2, h - 120.0); X } X} X Xhsv_to_rgb( h, s, v, r, g, b) Xfloat h, s, v; Xfloat *r, *g, *b; X{ X int i; X float f, p, q, t; X X h *= 360.0; X if (s == 0) { X *r = v; X *g = v; X *b = v; X } else { X if (h == 360) X h = 0; X h /= 60; X i = (int) floor(h); X f = h - i; X p = v*(1 - s); X q = v*(1 - (s*f)); X t = v*(1 - (s*(1 - f))); X switch (i) { X case 0 : X *r = v; X *g = t; X *b = p; X break; X case 1 : X *r = q; X *g = v; X *b = p; X break; X case 2 : X *r = p; X *g = v; X *b = t; X break; X case 3 : X *r = p; X *g = q; X *b = v; X break; X case 4 : X *r = t; X *g = p; X *b = v; X break; X case 5 : X *r = v; X *g = p; X *b = q; X break; X } X } X} X Xyiq_to_rgb (y, i, q, r, g, b) Xfloat y, i, q; Xfloat *r, *g, *b; X{ X/* X i = (i * 1.2) - 0.6; X q = (q * 1.04) - 0.52; X */ X *r = 1.0 * y + 0.948262 * i + 0.624013 * q; X *g = 1.0 * y + -0.276066 * i + -0.63981 * q; X *b = 1.0 * y + -1.10545 * i + 1.72986 * q; X X} X X/* X * Convert FROM rgb TO rgb. X * X * X */ Xrgb_to_rgb( fr, fg, fb, tr, tg, tb) Xfloat fr, fg, fb; Xfloat *tr, *tg, *tb; X{ X *tr = fr; X *tg = fg; X *tb = fb; X} X X/* X * Convert TO various formats FROM rgb. X * X * X */ Xrgb_to_cmy( r, g, b, c, m, y) Xfloat r, g, b; Xfloat *c, *m, *y; X{ X *c = 1.0 - r; X *m = 1.0 - g; X *y = 1.0 - b; X} X Xrgb_to_irgb( r, g, b, ir, ig, ib) Xfloat r, g, b; Xint *ir, *ig, *ib; X{ X *ir = (int) (r * 255.0); X *ig = (int) (g * 255.0); X *ib = (int) (b * 255.0); X} X Xrgb_to_hls( r, g, b, h, l, s) Xfloat r, g, b; Xfloat *h, *l, *s; X{ X float rc, gc, bc; X float maxcol, mincol; X X maxcol = max( r, max( g, b)); X mincol = min( r, min( g, b)); X *l = (mincol + maxcol) / 2; /* lightness */ X if (maxcol == mincol) { /* achromatic case */ X *s = 0; /* *h is undefined in the achromatic case */ X *h = 0; X } else { X if (*l <= 0.5) X *s = (maxcol - mincol) / (maxcol + mincol); X else X *s = (maxcol - mincol) / (2 - maxcol - mincol); X X /* find hue */ X rc = (maxcol - r) / (maxcol - mincol); X gc = (maxcol - g) / (maxcol - mincol); X bc = (maxcol - b) / (maxcol - mincol); X if (r == maxcol) X *h = bc - gc; X else if (g == maxcol) X *h = 2 + rc - bc; X else X *h = 4 + gc - rc; X X *h *= 60.0; X if ( *h < 0.0) X *h += 360.0; X *h /= 360.0; X } X} X Xrgb_to_hsv (r, g, b, lh, ls, lv) Xfloat r, g, b; Xfloat *lh, *ls, *lv; X{ X float h, s, v; X float cmax, cmin; X float rc, gc, bc; X X /* find the cmax and cmin of r g b */ X cmax = r; cmin = r; X cmax = (g > cmax ? g : cmax); X cmin = (g < cmin ? g : cmin); X cmax = (b > cmax ? b : cmax); X cmin = (b < cmin ? b : cmin); X v = cmax; /* value */ X if (cmax != 0) X s = (cmax - cmin) / cmax; X else { X s = 0; X h = 0; X } X X if (s == 0) X h = -1; X else { X rc = (cmax - r)/(cmax - cmin); X gc = (cmax - g)/(cmax - cmin); X bc = (cmax - b)/(cmax - cmin); X if (r == cmax) X h = bc - gc; X else X if (g == cmax) X h = 2.0 + rc - bc; X else X h = 4.0 + gc - rc; X h = h * 60.0; X if (h < 0.0) X h += 360.0; X } X *ls = s; X *lh = h/360.0; X *lv = v; X} X Xrgb_to_yiq (r, g, b, y, i, q) Xfloat r, g, b; Xfloat *y, *i, *q; X{ X *y = (0.3 * r + 0.59 * g + 0.11 * b); X *i = ((0.6 * r + -0.28 * g + -0.32 * b)); X *q = ((0.21 * r + -0.52 * g + 0.31 * b)); X} X Xsetcolorsys(sys) X{ X switch(sys) { X case COLORSYS_RGB: tofunc = rgb_to_rgb; X fromfunc = rgb_to_rgb; X colorsys = sys; X break; X case COLORSYS_CMY: tofunc = cmy_to_rgb; X fromfunc = rgb_to_cmy; X colorsys = sys; X break; X case COLORSYS_HSV: tofunc = hsv_to_rgb; X fromfunc = rgb_to_hsv; X colorsys = sys; X break; X case COLORSYS_HLS: tofunc = hls_to_rgb; X fromfunc = rgb_to_hls; X colorsys = sys; X break; X case COLORSYS_YIQ: tofunc = yiq_to_rgb; X fromfunc = rgb_to_yiq; X colorsys = sys; X break; X default: fprintf(stderr,"bad color system no %d\n",sys); X break; X } X} X Xgetcolorsys(sys) X{ X return colorsys; X} X Xtorgb(r,g,b,tr,tg,tb) Xfloat r, g, b; Xfloat *tr, *tg, *tb; X{ X tofunc(r,g,b,tr,tg,tb); X} X Xfromrgb(r,g,b,tr,tg,tb) Xfloat r, g, b; Xfloat *tr, *tg, *tb; X{ X fromfunc(r,g,b,tr,tg,tb); X} X SHAR_EOF chmod 0644 colormod.c || echo "restore of colormod.c fails" sed 's/^X//' << 'SHAR_EOF' > demo.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1, *b2, *b3; X XPanel X*defpanel(); X Xmain() X{ XActuator *a; XPanel *panel; X X foreground(); X winopen("demo"); X X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X panel=defpanel(); X X for (;;) { X a=dopanel(); X if (a==b1) { X exit(0); X } X X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X X pushmatrix(); X translate(s1->val,s2->val,0.0); X color(BLACK); X clear(); X color(WHITE); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X XPanel X*defpanel() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="demo"; X panel->ppu=50.0; X X s1=mkact(pnl_hslider); X s1->label="y position"; X s1->x=1.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X addact(s1, panel); X X s2=mkact(pnl_vslider); X s2->label="x position"; X s2->x=0.0; X s2->y=0.0; X s2->minval= -1.0; X s2->maxval=1.0; X addact(s2, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo.c || echo "restore of demo.c fails" sed 's/^X//' << 'SHAR_EOF' > demo10.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X/* X * Stepmap -> A simple program which draws an empty window and then X * uses a control panel with a pair of radio buttons, a X * button, and a slider, to control which color the X * background is drawn it. X */ X X#include X#include X#include X#include "panel.h" X X#define MIN_COLOR 0 /* Limit the range of the background */ X#define MAX_COLOR 1023 X#define MIN_RGB 0 X#define MAX_RGB 255 X X#define METER_SIZE 2.0 X Xint Next_Color = 0; /* Color to draw the background in */ Xint Delta = 1; /* 1 if Up pushed, -1 if Down pushed */ Xchar Amount[5]; /* Label for color slider */ X XPanel *My_Panel; XActuator *Color_Slider; /* Pointer to color slider */ XActuator *Toggle_Button; /* Pointer to animate toggle */ XActuator *Red_Meter; /* Pointer to meter structure */ XActuator *Green_Meter; XActuator *Blue_Meter; XActuator *Red_Strip; XActuator *Blue_Strip; XActuator *Green_Strip; X#define STRIP " " Xchar Red_Label[20] = "Red=xxx"; Xchar Blue_Label[20] = "Blue=xxx"; Xchar Green_Label[20] = "Green=xxx"; Xchar Red_S_Label[20] = STRIP; Xchar Blue_S_Label[20] = STRIP; Xchar Green_S_Label[20] = STRIP; X Xvoid My_Draw() /* Simply erase in the background color */ X{ X color(Next_Color); X clear(); X swapbuffers(); X} X Xvoid Set_Meters() X{ X short red, green, blue; X getmcolor(Next_Color,&red,&green,&blue); X Red_Meter->val = red; X Red_Meter->dirtycnt = 2; X Blue_Meter->val = blue; X Blue_Meter->dirtycnt = 2; X Green_Meter->val = green; X Green_Meter->dirtycnt = 2; X X Red_Strip->val=red; fixact(Red_Strip); X Green_Strip->val=green; fixact(Green_Strip); X Blue_Strip->val=blue; fixact(Blue_Strip); X X sprintf(Red_Label,"Red=%d",red); X sprintf(Green_Label,"Green=%d",green); X sprintf(Blue_Label,"Blue=%d",blue); X sprintf(Red_S_Label,"Red=(%d,%d)", X (int)Red_Strip->minval, (int)Red_Strip->maxval); X sprintf(Green_S_Label,"Green=(%d,%d)", X (int)Green_Strip->minval, (int)Green_Strip->maxval); X sprintf(Blue_S_Label,"Blue=(%d,%d)", X (int)Blue_Strip->minval, (int)Blue_Strip->maxval); X} X Xvoid Eraser() /* Pick the color to erase */ X{ /* Called indirectly by STEP button */ X X Next_Color += Delta; /* Go to next color */ X X if (Next_Color < MIN_COLOR) /* Make sure it is in range */ X Next_Color = MAX_COLOR; X if (Next_Color > MAX_COLOR) X Next_Color = MIN_COLOR; X X Color_Slider->val = Next_Color; /* Update the slider */ X Color_Slider->dirtycnt = 2; X Set_Meters(); X sprintf(Amount,"%4d",Next_Color); /* And its label */ X} X Xvoid setup() /* Cause STEP to step up */ X{ /* Called by Up radio button */ X Delta = 1; X} X Xvoid setdown() X{ /* Cause STEP to step down */ X Delta = -1; /* Called by Down radio button */ X} X Xvoid Slider_Color() X{ X Next_Color = Color_Slider->val; X Set_Meters(); X sprintf(Amount,"%4d",Next_Color); X} X Xvoid My_Exit() /* Clean up and Exit */ X{ /* Called by Exit button */ X exit(0); X} X XPanel *Make_Panel() /* Prepare the control panel */ X{ X Panel *p; X Actuator *a; X X My_Panel = p = mkpanel(); /* Control Panel */ X p->label="Map Stepper"; X X a = mkact(pnl_wide_button); /* Exit button */ X a->label = "exit"; X a->x = 11.4; X a->y = 0.0; X a->downfunc=My_Exit; X addact(a, p); X X Color_Slider = mkact(pnl_vslider); /* Color Slider */ X sprintf(Amount,"%4d",Next_Color); X Color_Slider->label = Amount; X Color_Slider->x = 0.0; X Color_Slider->y = 0.0; X Color_Slider->minval = MIN_COLOR; X Color_Slider->maxval = MAX_COLOR; X Color_Slider->val = 0.0; X Color_Slider->activefunc = Slider_Color; X addact(Color_Slider, p); X X Red_Meter = a = mkact(pnl_analog_bar); /* Red Analog meter */ X a->label = Red_Label; X a->x = 1.0; X a->y = 0.0; X a->minval = MIN_RGB; X a->maxval = MAX_RGB; X addact(a, p); X X Blue_Meter = a = mkact(pnl_meter); /* Blue Analog Meter */ X a->label = Blue_Label; X a->x = 1.0; X a->y = 4.2; X a->minval = MIN_RGB; X a->maxval = MAX_RGB; X addact(a, p); X X Green_Meter = a = mkact(pnl_meter); /* Green Analog Meter */ X a->label = Green_Label; X a->x = 1.0; X a->y = 2.1; X a->minval = MIN_RGB; X a->maxval = MAX_RGB; X addact(a, p); X X Red_Strip = a = mkact(pnl_scale_chart); X a->label = Red_S_Label; X a->x = 4.0; X a->y = 0.0; X a->minval = MIN_RGB; X a->maxval = MAX_RGB; X addact(a, p); X X Blue_Strip = a = mkact(pnl_scale_chart); X a->label = Blue_S_Label; X a->x = 4.0; X a->y = 4.2; X ((Stripchart *)a->data)->Bind_Low = TRUE; X addact(a, p); X X Green_Strip = a = mkact(pnl_strip_chart); X a->label = Green_S_Label; X a->x = 4.0; X a->y = 2.1; X a->minval = MIN_RGB; X a->maxval = MAX_RGB; X addact(a, p); X X a= mkact(pnl_button); /* Step button */ X a->label = "Step"; X a->x = 11.4; X a->y = 1.0; X a->activefunc=Eraser; X addact(a, p); X X Toggle_Button = mkact(pnl_toggle_button); X Toggle_Button->label = "Animate"; X Toggle_Button->x = 11.4; X Toggle_Button->y = 0.5; X addact(Toggle_Button, p); X X a=mkact(pnl_radio_button); /* UP button */ X a->label = "UP"; X a->val = 1.0; X a->x = 11.4; X a->y = 2.5; X a->downfunc = setup; X setup(); X addact(a, p); X X a=mkact(pnl_radio_button); /* Down button */ X a->label = "DOWN"; X a->x = 11.4; X a->y = 2.0; X a->downfunc = setdown; X addact(a, p); X X endgroup(p); /* Finish up, jack */ X Set_Meters(); X} X X#define Draw_Twice My_Draw(); My_Draw(); X Xmain() X{ X foreground(); /* Only for debugging */ X keepaspect(1,1); X winopen("My Panel"); /* Window to draw in */ X doublebuffer(); /* Run double buffered */ X gconfig(); X X Make_Panel(); /* Initiate the panel */ X needredraw(); /* Force it to be drawn */ X X ortho2(0.0,1.0,0.0,1.0); X Draw_Twice; /* Initial draw of my output */ X while (1) { /* Classic busy loop */ X if (Toggle_Button->val == 1.0) { X Eraser(); X } X if (dopanel()) { /* Some panel activity occured */ X do { X My_Draw(); /* Redraw with new parameters */ X } while (dopanel()); /* As long as panel activity occurs */ X My_Draw(); /* Redraw with new parameters */ X drawpanel(); /* Redraw the panel */ X My_Draw(); X } X if (userredraw()) { /* Moved or reshaped my window */ X reshapeviewport(); X ortho2(0.0,1.0,0.0,1.0); X Draw_Twice; X } X My_Draw(); X } X} SHAR_EOF chmod 0644 demo10.c || echo "restore of demo10.c fails" sed 's/^X//' << 'SHAR_EOF' > demo11.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include "panel.h" X Xmain() X{ Xint i; Xchar *s; X X foreground(); X winopen(); X doublebuffer(); X gconfig(); X drawit(); X for (;;) { X cmov2i(100,100); X s=g_getstring(WHITE, BLUE, RED, "Edit this string", 30); X printf("s=%x ",s); X for (i=0;i<10;i++) printf("[%3d] ",s[i]); X printf("\n"); X if (s) printf("%s\n",s); X drawit(); X } X} X Xdrawit() X{ X color(BLACK); X clear(); X cmov2i(100,100); X color(RED); X charstr("Edit this string"); X swapbuffers(); X} SHAR_EOF chmod 0644 demo11.c || echo "restore of demo11.c fails" sed 's/^X//' << 'SHAR_EOF' > demo12.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1, *b2, *b3, *b4, *rb1, *rb2, *rb3; X XPanel X*defpanel1(), *defpanel2(), *defpanel3(); X Xmain() X{ XActuator *a; XPanel *panel1; XPanel *panel2; Xshort col=RED; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X defpanel3(); X X for (;;) { X a=dopanel(); X if (a==b1) exit(0); X if (a==b4) dumppanel(); X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X if (a==rb1) col=CYAN; X if (a==rb2) col=GREEN; X if (a==rb3) col=RED; X X pushmatrix(); X translate(s1->val,s2->val,0.0); X color(BLACK); X clear(); X color(col); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X XPanel X*defpanel1() X{ XActuator *a; XPanel *panel; X X panel=mkpanel(); X panel->label="panel one"; X panel->ppu=50.0; X X s1=mkact(pnl_hslider); X s1->label="y position"; X s1->x=1.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X addact(s1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X a=mkact(pnl_typein); X a->x=4.0; X a->y=2.0; X a->labeltype=PNL_LABEL_TOP; X a->label="a typein window"; X PNL_ACCESS(Typein,a,str)="Edit This String"; X addact(a,panel); X X return panel; X} X XPanel X*defpanel2() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel two"; X panel->ppu=50.0; X X s2=mkact(pnl_vslider); X s2->label="x position"; X s2->x=0.0; X s2->y=0.0; X s2->minval= -1.0; X s2->maxval=1.0; X addact(s2, panel); X X b4=mkact(pnl_button); X b4->label="dumppanel"; X b4->x=1.0; X b4->y=1.5; X addact(b4, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X return panel; X} X XPanel X*defpanel3() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel three"; X panel->ppu=50.0; X X rb3=mkact(pnl_radio_button); X rb3->label="red"; X rb3->x=1.0; X rb3->y=2.0; X rb3->val=1.0; X addact(rb3, panel); X X rb2=mkact(pnl_radio_button); X rb2->label="green"; X rb2->x=1.0; X rb2->y=1.5; X addact(rb2, panel); X X rb1=mkact(pnl_radio_button); X rb1->label="cyan"; X rb1->x=1.0; X rb1->y=1.0; X addact(rb1, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo12.c || echo "restore of demo12.c fails" sed 's/^X//' << 'SHAR_EOF' > demo13.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1, *b2, *b3, *b4, *rb1, *rb2, *rb3; X XPanel X*defpanel1(), *defpanel2(), *defpanel3(); X Xmain() X{ XActuator *a; XPanel *panel1; XPanel *panel2; Xshort col=RED; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X defpanel3(); X X for (;;) { X a=dopanel(); X if (a==b1) exit(0); X if (a==b4) dumppanel(); X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X if (a==rb1) col=CYAN; X if (a==rb2) col=GREEN; X if (a==rb3) col=RED; X X pushmatrix(); X translate(s1->val,s2->val,0.0); X color(BLACK); X clear(); X color(col); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X XPanel X*defpanel1() X{ XActuator *a; XPanel *panel; X X panel=mkpanel(); X panel->ppu=40.0; X X s1=mkact(pnl_filled_hslider); X s1->label="y position"; X s1->x=1.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X addact(s1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X a=mkact(pnl_typein); X a->x=4.0; X a->y=2.0; X PNL_ACCESS(Typein,a,str)="Edit This String"; X addact(a,panel); X X return panel; X} X XPanel X*defpanel2() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel two"; X panel->ppu=50.0; X X s2=mkact(pnl_filled_vslider); X s2->label="x position"; X s2->x=0.0; X s2->y=0.0; X s2->minval= -1.0; X s2->maxval=1.0; X addact(s2, panel); X X b4=mkact(pnl_button); X b4->label="dumppanel"; X b4->x=1.0; X b4->y=1.5; X addact(b4, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X return panel; X} X XPanel X*defpanel3() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel three"; X panel->ppu=50.0; X X rb3=mkact(pnl_radio_button); X rb3->label="red"; X rb3->x=1.0; X rb3->y=2.0; X rb3->val=1.0; X addact(rb3, panel); X X rb2=mkact(pnl_radio_button); X rb2->label="green"; X rb2->x=1.0; X rb2->y=1.5; X addact(rb2, panel); X X rb1=mkact(pnl_radio_button); X rb1->label="cyan"; X rb1->x=1.0; X rb1->y=1.0; X addact(rb1, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo13.c || echo "restore of demo13.c fails" sed 's/^X//' << 'SHAR_EOF' > demo14.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1, *b2, *b3, *b4, *rb1, *rb2, *rb3; X XPanel X*defpanel1(), *defpanel2(), *defpanel3(); X Xmain() X{ XActuator *a; XPanel *panel1; XPanel *panel2; Xshort col=RED; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X defpanel3(); X X for (;;) { X a=dopanel(); X if (a==b1) exit(0); X if (a==b4) dumppanel(); X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X if (a==rb1) col=CYAN; X if (a==rb2) col=GREEN; X if (a==rb3) col=RED; X X pushmatrix(); X translate(PNL_ACCESS(Puck, s1, x),PNL_ACCESS(Puck, s1, y),0.0); X color(BLACK); X clear(); X color(col); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X XPanel X*defpanel1() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel one"; X panel->ppu=50.0; X X s1=mkact(pnl_puck); X s1->label="position"; X s1->x=4.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X addact(s1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X return panel; X} X XPanel X*defpanel2() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel two"; X panel->ppu=50.0; X X b4=mkact(pnl_button); X b4->label="dumppanel"; X b4->x=1.0; X b4->y=1.5; X addact(b4, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X return panel; X} X XPanel X*defpanel3() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel three"; X panel->ppu=50.0; X X rb3=mkact(pnl_radio_button); X rb3->label="red"; X rb3->x=1.0; X rb3->y=2.0; X rb3->val=1.0; X addact(rb3, panel); X X rb2=mkact(pnl_radio_button); X rb2->label="green"; X rb2->x=1.0; X rb2->y=1.5; X addact(rb2, panel); X X rb1=mkact(pnl_radio_button); X rb1->label="cyan"; X rb1->x=1.0; X rb1->y=1.0; X addact(rb1, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo14.c || echo "restore of demo14.c fails" sed 's/^X//' << 'SHAR_EOF' > demo15.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1, *b2, *b3, *b4, *rb1, *rb2, *rb3; X XPanel X*defpanel1(), *defpanel2(), *defpanel3(); X XCoord posx=0.0, posy=0.0, savx=0.0, savy=0.0; X Xmain() X{ XActuator *a; XPanel *panel1; XPanel *panel2; Xshort col=RED; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X defpanel3(); X X for (;;) { X a=dopanel(); X if (a==b1) exit(0); X if (a==b4) dumppanel(); X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X if (a==rb1) col=CYAN; X if (a==rb2) col=GREEN; X if (a==rb3) col=RED; X X pushmatrix(); X translate(posx, posy, 0.0); X color(BLACK); X clear(); X color(col); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X Xvoid Xdeltapos(a) XActuator *a; X{ X posx=savx+PNL_ACCESS(Puck, a, x); X posy=savy+PNL_ACCESS(Puck, a, y); X} X Xvoid Xbakepos(a) XActuator *a; X{ X savx=posx; X savy=posy; X} X XPanel X*defpanel1() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel one"; X panel->ppu=50.0; X X s1=mkact(pnl_floating_puck); X s1->label="position"; X s1->x=4.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X s1->activefunc=deltapos; X s1->upfunc=bakepos; X addact(s1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X return panel; X} X XPanel X*defpanel2() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel two"; X panel->ppu=50.0; X X b4=mkact(pnl_button); X b4->label="dumppanel"; X b4->x=1.0; X b4->y=1.5; X addact(b4, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X return panel; X} X XPanel X*defpanel3() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel three"; X panel->ppu=50.0; X X rb3=mkact(pnl_radio_button); X rb3->label="red"; X rb3->x=1.0; X rb3->y=2.0; X rb3->val=1.0; X addact(rb3, panel); X X rb2=mkact(pnl_radio_button); X rb2->label="green"; X rb2->x=1.0; X rb2->y=1.5; X addact(rb2, panel); X X rb1=mkact(pnl_radio_button); X rb1->label="cyan"; X rb1->x=1.0; X rb1->y=1.0; X addact(rb1, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo15.c || echo "restore of demo15.c fails" sed 's/^X//' << 'SHAR_EOF' > demo16.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1, *b2, *b3, *b4, *rb1, *rb2, *rb3; X XPanel X*defpanel1(), *defpanel2(), *defpanel3(); X XCoord posx=0.0, posy=0.0, savx=0.0, savy=0.0; X Xmain() X{ XActuator *a; XPanel *panel1; XPanel *panel2; Xshort col=RED; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X defpanel3(); X X for (;;) { X a=dopanel(); X if (a==b1) exit(0); X if (a==b4) dumppanel(); X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X if (a==rb1) col=CYAN; X if (a==rb2) col=GREEN; X if (a==rb3) col=RED; X X pushmatrix(); X translate(posx, posy, 0.0); X color(BLACK); X clear(); X color(col); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X Xvoid Xdeltapos(a) XActuator *a; X{ X posx=savx+PNL_ACCESS(Puck, a, x); X posy=savy+PNL_ACCESS(Puck, a, y); X} X Xvoid Xbakepos(a) XActuator *a; X{ X savx=posx; X savy=posy; X} X XPanel X*defpanel1() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel one"; X panel->ppu=50.0; X X s1=mkact(pnl_rubber_puck); X s1->label="position"; X s1->x=4.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X s1->activefunc=deltapos; X s1->upfunc=bakepos; X addact(s1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X return panel; X} X XPanel X*defpanel2() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel two"; X panel->ppu=50.0; X X b4=mkact(pnl_button); X b4->label="dumppanel"; X b4->x=1.0; X b4->y=1.5; X addact(b4, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X return panel; X} X XPanel X*defpanel3() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel three"; X panel->ppu=50.0; X X rb3=mkact(pnl_radio_button); X rb3->label="red"; X rb3->x=1.0; X rb3->y=2.0; X rb3->val=1.0; X addact(rb3, panel); X X rb2=mkact(pnl_radio_button); X rb2->label="green"; X rb2->x=1.0; X rb2->y=1.5; X addact(rb2, panel); X X rb1=mkact(pnl_radio_button); X rb1->label="cyan"; X rb1->x=1.0; X rb1->y=1.0; X addact(rb1, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo16.c || echo "restore of demo16.c fails" sed 's/^X//' << 'SHAR_EOF' > demo17.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include "panel.h" X XActuator *poemwindow; XPanel *defpanel(); X X#define POEM_WINDOW_BUFSIZ 16386 X#define POEM \ X"Mary had a little spam.\n\ XIt felt as good as gold.\n\ XAnd when she left it out at night,\n\ XIt shivered in the cold." X X Xmain() X{ X foreground(); X noport(); X winopen("typeout demo"); X winconstraints(); X winconstraints(); X doublebuffer(); X gconfig(); X X defpanel(); X X for (;;) { X dopanel(); X swapbuffers(); X } X} X Xvoid Xcleanexit() X{ X exit(0); X} X Xvoid Xaddtext(a) XActuator *a; X{ X strcat(PNL_ACCESS(Typeout, poemwindow, buf), "\n"); X strcat(PNL_ACCESS(Typeout, poemwindow, buf), X PNL_ACCESS(Typein, a, str)); X X fixact(poemwindow); X} X XPanel X*defpanel() X{ XActuator *a; XPanel *p; X X p=mkpanel(); X p->label="typeout demo"; X p->x=200; X p->y=100; X X a=mkact(pnl_wide_button); X a->x=1.5; X a->y= -2.0; X a->label="exit"; X a->upfunc=cleanexit; X addact(a,p); X X a=mkact(pnl_typein); X a->x=1.0; X a->y=0.0; X a->upfunc=addtext; X a->label="a typein actuator"; X PNL_ACCESS(Typein,a,len)=60; X PNL_ACCESS(Typein,a,str)="Edit This String"; X X addact(a,p); X X poemwindow=mkact(pnl_typeout); X poemwindow->x=1.0; X poemwindow->y=1.0; X poemwindow->labeltype=PNL_LABEL_TOP; X poemwindow->label="a typeout actuator"; X PNL_ACCESS(Typeout,poemwindow,size)=POEM_WINDOW_BUFSIZ; X addact(poemwindow,p); /* addact does the malloc */ X strcpy(PNL_ACCESS(Typeout,poemwindow,buf), POEM); X fixact(poemwindow); /* bake in the string */ X} X SHAR_EOF chmod 0644 demo17.c || echo "restore of demo17.c fails" sed 's/^X//' << 'SHAR_EOF' > demo18.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *filewindow; XPanel *defpanel(); X X#define FILE_WINDOW_BUFSIZ 16386 X Xmain() X{ X foreground(); X noport(); X winopen("typeout demo"); X winconstraints(); X winconstraints(); X X doublebuffer(); X gconfig(); X X defpanel(); X X for (;;) { X dopanel(); X swapbuffers(); X } X} X Xvoid Xcleanexit() X{ X exit(0); X} X Xvoid Xgetfile(a) XActuator *a; X{ XFILE *stream; Xint n=0; XTypein *adin=(Typein *)a->data; XTypeout *adout=(Typeout *)filewindow->data; Xchar *p=adout->buf; X X stream=fopen(adin->str, "r"); X if (!stream) { X strcpy(adout->buf,"can't open file"); X goto end; X } X X do { X n=fread(p,sizeof(char), X FILE_WINDOW_BUFSIZ-(p-adout->buf),stream); X p+=n; X } while (n>0); X *p='\0'; /* mark the end */ X fclose(stream); X Xend: X adout->start=0; X adout->dot=0; X fixact(filewindow); /* bake changes, mark dirty */ X} X XPanel X*defpanel() X{ XActuator *a; XPanel *p; X X p=mkpanel(); X p->label="file viewer"; X p->x=200; X p->y=100; X X a=mkact(pnl_wide_button); X a->x=6.0; X a->y=0.0; X a->label="exit"; X a->upfunc=cleanexit; X addact(a,p); SHAR_EOF echo "End of part 1, continue with part 2" echo "2" > s2_seq_.tmp exit 0 ------- Received: from VMB.BRL.MIL by VMB.BRL.MIL id ac01476; 18 Aug 88 17:49 EDT Received: from VMB.BRL.MIL by VMB.brl.MIL id ad01422; 18 Aug 88 17:38 EDT Received: from smoke.brl.mil by VMB.BRL.MIL id aa01368; 18 Aug 88 17:28 EDT Received: from orville.nas.nasa.gov by SMOKE.BRL.MIL id aa10080; 18 Aug 88 17:21 EDT Received: Thu, 18 Aug 88 14:20:15 PDT by orville.nas.nasa.gov (5.59/1.2) Date: Thu, 18 Aug 88 14:20:15 PDT From: "David A. Tristram" Message-Id: <8808182120.AA25311@orville.nas.nasa.gov> To: info-iris@BRL.MIL Subject: panel02/06 #!/bin/sh # this is part 2 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file demo18.c continued # CurArch=2 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 sed 's/^X//' << 'SHAR_EOF' >> demo18.c X X a=mkact(pnl_typein); X a->x=2.0; X a->y=1.0; X a->upfunc=getfile; X a->label="file"; X a->labeltype=PNL_LABEL_LEFT; X PNL_ACCESS(Typein,a,len)=60; X addact(a,p); X X filewindow=mkact(pnl_typeout); X filewindow->x=0.0; X filewindow->y=2.0; X PNL_ACCESS(Typeout,filewindow,col)=80; X PNL_ACCESS(Typeout,filewindow,lin)=40; X PNL_ACCESS(Typeout,filewindow,size)=FILE_WINDOW_BUFSIZ; X addact(filewindow,p); X} X SHAR_EOF chmod 0644 demo18.c || echo "restore of demo18.c fails" sed 's/^X//' << 'SHAR_EOF' > demo19.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *messagewindow,*gridfiletypein,*solnfiletypein; XPanel *defpanel(); X Xmain() X{ X foreground(); X noport(); X winopen("typeout demo"); X winconstraints(); X winconstraints(); X X doublebuffer(); X gconfig(); X X defpanel(); X X for (;;) { X dopanel(); X swapbuffers(); X } X} X Xvoid Xcleanexit() X{ X exit(0); X} X Xvoid Xcancelfunc() X{ X exit(0); X} X Xvoid Xopenfiles(a) XActuator *a; X{ Xint gridfd, solnfd; Xint n=0; XTypein *adgrid=(Typein *)gridfiletypein->data; XTypein *adsoln=(Typein *)solnfiletypein->data; XTypeout *adout=(Typeout *)messagewindow->data; Xchar *p=adout->buf; X X if (!strcmp(adgrid->str,"")) { X ringbell(); X tprint(messagewindow,"null grid file name"); X return; X } X X if (!strcmp(adsoln->str,"")) { X ringbell(); X tprint(messagewindow,"null solution file name"); X return; X } X X gridfd=open(adgrid->str, O_RDONLY); X if (gridfd<0) { X tprint(messagewindow,"can't open grid file"); X return; X } X X solnfd=open(adsoln->str, O_RDONLY); X if (solnfd<0) { X tprint(messagewindow,"can't open solution file"); X return; X } X} X XPanel X*defpanel() X{ XActuator *a; XPanel *p; X X p=mkpanel(); X p->label="file window"; X p->x=200; X p->y=100; X X a=mkact(pnl_wide_button); X a->x=1.0; X a->y=0.0; X a->label="ok"; X a->upfunc=openfiles; X addact(a,p); X X a=mkact(pnl_wide_button); X a->x=6.0; X a->y=0.0; X a->label="cancel"; X a->upfunc=cancelfunc; X addact(a,p); X X gridfiletypein=mkact(pnl_typein); X gridfiletypein->x=1.0; X gridfiletypein->y=1.0; X gridfiletypein->label="grid file"; X gridfiletypein->labeltype=PNL_LABEL_LEFT; X PNL_ACCESS(Typein,gridfiletypein,len)=60; X addact(gridfiletypein,p); X X solnfiletypein=mkact(pnl_typein); X solnfiletypein->x=1.0; X solnfiletypein->y=1.5; X solnfiletypein->label="solution file"; X solnfiletypein->labeltype=PNL_LABEL_LEFT; X PNL_ACCESS(Typein,solnfiletypein,len)=60; X addact(solnfiletypein,p); X X messagewindow=mkact(pnl_typeout); X messagewindow->x=0.0; X messagewindow->y=2.5; X messagewindow->label="messages"; X PNL_ACCESS(Typeout,messagewindow,col)=80; X PNL_ACCESS(Typeout,messagewindow,lin)=20; X addact(messagewindow,p); X} X SHAR_EOF chmod 0644 demo19.c || echo "restore of demo19.c fails" sed 's/^X//' << 'SHAR_EOF' > demo2.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1; X XPanel X*defpanel(); X Xmain() X{ XActuator *a; XPanel *panel; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X panel=defpanel(); X X for (;;) { X a=dopanel(); X if (a==b1) { X exit(0); X } X s2->w=s1->val*10.0; X s2->dirtycnt=2; X panel->dirtycnt=2; /* because we are modifying the layout */ X pushmatrix(); X translate(s1->val,s2->val,0.0); X color(BLACK); X clear(); X color(WHITE); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X XPanel X*defpanel() X{ XPanel *panel; X X panel=mkpanel(); X X s1=mkact(pnl_slider); X s1->label="slider 1"; X s1->x=0.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X addact(s1, panel); X X s2=mkact(pnl_slider); X s2->label="slider 2"; X s2->x=1.0; X s2->y=0.0; X s2->minval= -1.0; X s2->maxval=1.0; X addact(s2, panel); X X b1=mkact(pnl_button); X b1->label="button 1"; X b1->x=2.0; X b1->y=0.0; X addact(b1, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo2.c || echo "restore of demo2.c fails" sed 's/^X//' << 'SHAR_EOF' > demo20.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1, *b2, *b3, *b4, X *b5, *b6, *b7, *b8, *b9, *b10, *rb1, *rb2, *rb3; X XPanel X*defpanel1(), *defpanel2(), *defpanel3(); X Xmain() X{ XActuator *a; XPanel *panel1; XPanel *panel2; Xshort col=RED; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X defpanel3(); X X for (;;) { X a=dopanel(); X if (a==b1) exit(0); X if (a==b4) dumppanel(); X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X if (a==rb1) col=CYAN; X if (a==rb2) col=GREEN; X if (a==rb3) col=RED; X X pushmatrix(); X translate(PNL_ACCESS(Puck, s1, x),PNL_ACCESS(Puck, s1, y),0.0); X color(BLACK); X clear(); X color(col); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X Xvoid Xbeginscript() X{ X pnl_beginwritescript("panel.script"); X} X Xvoid Xappendscript() X{ X pnl_beginappendscript("panel.script"); X} X Xvoid Xendscript() X{ X pnl_endwritescript(); X} X Xvoid Xreadscript() X{ X pnl_beginreadscript("panel.script"); X} X Xvoid Xstopscript() X{ X pnl_endreadscript(); X} X XPanel X*defpanel1() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel one"; X panel->ppu=50.0; X X s1=mkact(pnl_puck); X s1->label="position"; X s1->x=4.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X addact(s1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X return panel; X} X XPanel X*defpanel2() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel two"; X panel->ppu=50.0; X X b10=mkact(pnl_button); X b10->label="dump state"; X b10->x=1.0; X b10->y=4.5; X b10->downfunc=dumpstate; X addact(b10, panel); X X b5=mkact(pnl_button); X b5->label="begin script"; X b5->x=1.0; X b5->y=4.0; X b5->downfunc=beginscript; X addact(b5, panel); X X b6=mkact(pnl_button); X b6->label="end script"; X b6->x=1.0; X b6->y=3.5; X b6->downfunc=endscript; X addact(b6, panel); X X b9=mkact(pnl_button); X b9->label="append to script"; X b9->x=1.0; X b9->y=3.0; X b9->downfunc=appendscript; X addact(b9, panel); X X b7=mkact(pnl_button); X b7->label="read script"; X b7->x=1.0; X b7->y=2.5; X b7->downfunc=readscript; X addact(b7, panel); X X b8=mkact(pnl_button); X b8->label="stop reading script"; X b8->x=1.0; X b8->y=2.0; X b8->downfunc=stopscript; X addact(b8, panel); X X b4=mkact(pnl_button); X b4->label="dumppanel"; X b4->x=1.0; X b4->y=1.5; X addact(b4, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X return panel; X} X XPanel X*defpanel3() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel three"; X panel->ppu=50.0; X X rb3=mkact(pnl_radio_button); X rb3->label="red"; X rb3->x=1.0; X rb3->y=2.0; X rb3->val=1.0; X addact(rb3, panel); X X rb2=mkact(pnl_radio_button); X rb2->label="green"; X rb2->x=1.0; X rb2->y=1.5; X addact(rb2, panel); X X rb1=mkact(pnl_radio_button); X rb1->label="cyan"; X rb1->x=1.0; X rb1->y=1.0; X addact(rb1, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo20.c || echo "restore of demo20.c fails" sed 's/^X//' << 'SHAR_EOF' > demo21.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *m, *b1, *b2, *b3; X XPanel X*defpanel(); X Xmain() X{ XActuator *a; XPanel *panel; XMouse *md; X X foreground(); X winopen("demo"); X X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X panel=defpanel(); X md=(Mouse *)m->data; X X for (;;) { X a=dopanel(); X if (a==b1) { X exit(0); X } X X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X X pushmatrix(); X translate(md->x/(float)XMAXSCREEN, md->y/(float)YMAXSCREEN,0.0); X X color(BLACK); X clear(); X color(WHITE); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X XPanel X*defpanel() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="demo"; X panel->ppu=50.0; X X m=mkact(pnl_mouse); X addact(m, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo21.c || echo "restore of demo21.c fails" sed 's/^X//' << 'SHAR_EOF' > demo22.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1, *b2, *b3; X XPanel X*defpanel(); X Xmain() X{ XActuator *a; XPanel *panel; X X foreground(); X winopen("demo"); X X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X panel=defpanel(); X X for (;;) { X a=dopanel(); X if (a==b1) { X exit(0); X } X X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X X pushmatrix(); X translate(s1->val,s2->val,0.0); X color(BLACK); X clear(); X color(WHITE); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X XPanel X*defpanel() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="demo"; X X s1=mkact(pnl_slideroid); X s1->label="x position"; X s1->x=0.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X addact(s1, panel); X X s2=mkact(pnl_slideroid); X s2->label="y position"; X s2->x=2.0; X s2->y=0.0; X s2->minval= -1.0; X s2->maxval=1.0; X addact(s2, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=3.0; X addact(b1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=3.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=4.0; X addact(b3, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo22.c || echo "restore of demo22.c fails" sed 's/^X//' << 'SHAR_EOF' > demo23.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *s3, *b1, *b2, *b3; X Xvoid defpanel(); X Xmain() X{ XActuator *a; Xshort col=RED; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X defpanel(); X X for (;;) { X a=dopanel(); X if (a==b1) s1->visible= !(b1->val==1.0); X if (a==b2) s2->visible= !(b2->val==1.0); X if (a==b3) s3->visible= !(b3->val==1.0); X X color(BLACK); X clear(); X swapbuffers(); X } X} X X Xvoid Xdefpanel() X{ XPanel *p; X X p=mkpanel(); X p->label="fixpanel demo"; X p->ppu=50.0; X p->upfunc=p->fixfunc; X X s1=mkact(pnl_slider); X s1->label="slider 1"; X s1->x=4.0; X s1->y=0.0; X addact(s1, p); X X s2=mkact(pnl_hslider); X s2->label="slider 2"; X s2->x=0.0; X s2->y= -2.0; X addact(s2, p); X X s3=mkact(pnl_slider); X s3->label="slider 3"; X s3->x= -2.0; X s3->y=0.0; X addact(s3, p); X X b1=mkact(pnl_toggle_button); X b1->label="slider 1"; X b1->x=1.0; X b1->y=1.0; X addact(b1, p); X X b2=mkact(pnl_toggle_button); X b2->label="slider 2"; X b2->x=1.0; X b2->y=1.5; X addact(b2, p); X X b3=mkact(pnl_toggle_button); X b3->label="slider 3"; X b3->x=1.0; X b3->y=2.0; X addact(b3, p); X} X SHAR_EOF chmod 0644 demo23.c || echo "restore of demo23.c fails" sed 's/^X//' << 'SHAR_EOF' > demo24.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include X#include "panel.h" X X#define BACK_COLOR_INDEX 99 X#define MAX_INTENSITY 255.0 X X XActuator *pal; X Xint cur_index = BACK_COLOR_INDEX; X Xfloat back_r; Xfloat back_g; Xfloat back_b; X XActuator *back_r_label; XActuator *back_g_label; XActuator *back_b_label; X XActuator *back_r_slider; XActuator *back_g_slider; XActuator *back_b_slider; X X Xmain() X{ X void make_back_color_panel(); X X X X foreground(); X noport(); X winopen("Testpan"); X doublebuffer(); X gconfig(); X mapcolor(BACK_COLOR_INDEX, 250, 200, 150); X make_back_color_panel(); X X X while (1) X { X dopanel(); X swapbuffers(); X } X X} X Xvoid make_back_color_panel() X{ X extern Actuator *back_r_slider; X extern Actuator *back_g_slider; X extern Actuator *back_b_slider; X X extern Actuator *back_r_label; X extern Actuator *back_g_label; X extern Actuator *back_b_label; X X Panel *back_color_panel; X short r; X short g; X short b; X static char rchar[10]; X static char gchar[10]; X static char bchar[10]; X static char cbuf[20]; X X void update_back_color(); X X extern Actuator *pal; X X Actuator *map; X void set_cur_index(); X X X getmcolor(BACK_COLOR_INDEX, &r, &g, &b); X X back_color_panel = mkpanel(); X back_color_panel -> label = "Background"; X back_color_panel -> ppu = 40; X X sprintf(rchar, "%3.0f%%", (float) (100.0 * r / MAX_INTENSITY)); X back_r_label = mkact(pnl_label); X back_r_label -> label = rchar; X back_r_label -> y = 3.05; X addact(back_r_label, back_color_panel); X X sprintf(gchar, "%3.0f%%", (float) (100.0 * g / MAX_INTENSITY)); X back_g_label = mkact(pnl_label); X back_g_label -> label = gchar; X back_g_label -> x = 1.0; X back_g_label -> y = 3.05; X addact(back_g_label, back_color_panel); X X sprintf(bchar, "%3.0f%%", (float) (100.0 * b / MAX_INTENSITY)); X back_b_label = mkact(pnl_label); X back_b_label -> label = bchar; X back_b_label -> x = 2.0; X back_b_label -> y = 3.05; X addact(back_b_label, back_color_panel); X X back_r_slider = mkact(pnl_slider); X back_r_slider -> label = "R"; X back_r_slider -> minval = 0.0; X back_r_slider -> maxval = MAX_INTENSITY; X back_r_slider -> val = (float) r; X back_r_slider -> h = 3.0; X back_r_slider -> u = (char *) back_r_label; X back_r_slider -> activefunc = update_back_color; X addact(back_r_slider, back_color_panel); X X back_g_slider = mkact(pnl_slider); X back_g_slider -> label = "G"; X back_g_slider -> minval = 0.0; X back_g_slider -> maxval = MAX_INTENSITY; X back_g_slider -> val = (float) g; X back_g_slider -> x = 1.0; X back_g_slider -> h = 3.0; X back_g_slider -> u = (char *) back_g_label; X back_g_slider -> activefunc = update_back_color; X addact(back_g_slider, back_color_panel); X X back_b_slider = mkact(pnl_slider); X back_b_slider -> label = "B"; X back_b_slider -> minval = 0.0; X back_b_slider -> maxval = MAX_INTENSITY; X back_b_slider -> val = (float) b; X back_b_slider -> x = 2.0; X back_b_slider -> h = 3.0; X back_b_slider -> u = (char *) back_b_label; X back_b_slider -> activefunc = update_back_color; X addact(back_b_slider, back_color_panel); X X pal = mkact(pnl_palette); X sprintf(cbuf, "Index = %4d", BACK_COLOR_INDEX); X pal -> label = cbuf; X pal -> minval = (float) BACK_COLOR_INDEX; X pal -> maxval = (float) BACK_COLOR_INDEX; X pal -> y = 4.0; X pal -> w = 3.0; X pal -> h = 3.0; X addact(pal, back_color_panel); X X map = mkact(pnl_palette); X map -> minval = 0.0; X map -> maxval = 1023.0; X map -> x = -1.0; X map -> activefunc = set_cur_index; X addact(map, back_color_panel); X X X} X Xvoid update_back_color(a) XActuator *a; X{ X switch (*a->label) X { X case 'R': X back_r = a -> val; X break; X X case 'G': X back_g = a -> val; X break; X X case 'B': X back_b = a -> val; X break; X X default: X return; X } X X mapcolor( (Colorindex) cur_index, X (Colorindex) back_r, X (Colorindex) back_g, X (Colorindex) back_b); X X sprintf(((Actuator *)(a -> u)) -> label, "%3.0f%%", X (100.0 * a -> val / MAX_INTENSITY)); X fixact(a -> u); X X} X X Xvoid set_cur_index(a) XActuator *a; X{ X extern int cur_index; X X static char rchar[10]; X static char gchar[10]; X static char bchar[10]; X static char cbuf[20]; X X short r; X short g; X short b; X X extern float back_r; X extern float back_g; X extern float back_b; X X extern Actuator *back_r_label; X extern Actuator *back_g_label; X extern Actuator *back_b_label; X extern Actuator *back_r_slider; X extern Actuator *back_g_slider; X extern Actuator *back_b_slider; X X cur_index = (int) (pal -> minval = pal -> maxval = a -> val); X sprintf(cbuf, "Index = %4d", cur_index); X pal->label = cbuf; X fixact(pal); X X getmcolor((Colorindex) cur_index, &r, &g, &b); X X back_r_slider->val = back_r = (float) r; X back_g_slider->val = back_g = (float) g; X back_b_slider->val = back_b = (float) b; X fixact(back_r_slider); X fixact(back_g_slider); X fixact(back_b_slider); X X sprintf(rchar, "%3.0f%%", (100.0 * back_r / MAX_INTENSITY)); X back_r_label -> label = rchar; X fixact(back_r_label); X X sprintf(gchar, "%3.0f%%", (100.0 * back_g / MAX_INTENSITY)); X back_g_label -> label = gchar; X fixact(back_g_label); X X sprintf(bchar, "%3.0f%%", (100.0 * back_b / MAX_INTENSITY)); X back_b_label -> label = bchar; X fixact(back_b_label); X X} SHAR_EOF chmod 0644 demo24.c || echo "restore of demo24.c fails" sed 's/^X//' << 'SHAR_EOF' > demo25.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *d1, *d2, *b1, *b2, *b3; X XPanel X*defpanel(); X Xmain() X{ XActuator *a; XPanel *panel; X X foreground(); X winopen("demo"); X X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X panel=defpanel(); X X for (;;) { X a=dopanel(); X if (a==b1) { X exit(0); X } X X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X X pushmatrix(); X translate(d1->val,d2->val,0.0); X color(BLACK); X clear(); X color(WHITE); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X XPanel X*defpanel() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="demo"; X panel->ppu=50.0; X X d1=mkact(pnl_dial); X d1->label="y position"; X d1->x= -2.0; X d1->y= 1.5; X d1->minval= -1.0; X d1->maxval=1.0; X addact(d1, panel); X X d2=mkact(pnl_dial); X d2->label="x position"; X d2->x= -2.0; X d2->y=0.0; X d2->minval= -1.0; X d2->maxval=1.0; X addact(d2, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo25.c || echo "restore of demo25.c fails" sed 's/^X//' << 'SHAR_EOF' > demo26.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XPanel X*defpanel(); X Xmain() X{ X Actuator *a; X Panel *panel; X X foreground(); X noport(); X winopen("demo"); X X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X panel=defpanel(); X X for (;;) { X dopanel(); X swapbuffers(); X } X} X X#define MKBIGBUTTON() \ X a=mkact(pnl_wide_button); \ X a->w=1.0-PNL_DIM_1; \ X a->h=1.0-PNL_DIM_1; \ X a->x=x; \ X a->y=(y-=d); \ X addact(a, p) X X#define MKDIAL() \ X a=mkact(pnl_dial); \ X a->x=(x+=d); \ X a->y=y; \ X addact(a, p) X XPanel X*defpanel() X{ X Actuator *a; X Panel *p; X Coord y, x, d=1.0; X X p=mkpanel(); X p->label="demo"; X p->ppu=50.0; X X x=0.0; X y=0.0; X X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X X x=1.0; X y=1.0; X X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X X x=2.0; X y=1.0; X X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X X x=3.0; X y=1.0; X X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X X x=4.0; X y=1.0; X X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X X x=5.0; X y=0.0; X X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X MKBIGBUTTON(); X X x= -1.0; X y= -6.0; X X MKDIAL(); X MKDIAL(); X MKDIAL(); X MKDIAL(); X MKDIAL(); X MKDIAL(); X X return p; X} X SHAR_EOF chmod 0644 demo26.c || echo "restore of demo26.c fails" sed 's/^X//' << 'SHAR_EOF' > demo3.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1, *b2, *b3; X XPanel X*defpanel1(), *defpanel2(); X Xmain() X{ XActuator *a; XPanel *panel1; XPanel *panel2; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X X for (;;) { X a=dopanel(); X if (a==b1) { X exit(0); X } X X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X X pushmatrix(); X translate(s1->val,s2->val,0.0); X color(BLACK); X clear(); X color(WHITE); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X XPanel X*defpanel1() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel1"; X panel->ppu=50.0; X X s1=mkact(pnl_hslider); X s1->label="y position"; X s1->x=1.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X addact(s1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X return panel; X} X XPanel X*defpanel2() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel2"; X panel->ppu=50.0; X X s2=mkact(pnl_vslider); X s2->label="x position"; X s2->x=0.0; X s2->y=0.0; X s2->minval= -1.0; X s2->maxval=1.0; X addact(s2, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo3.c || echo "restore of demo3.c fails" sed 's/^X//' << 'SHAR_EOF' > demo4.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *s1, *s2, *b1, *b2, *b3, *b4, *rb1, *rb2, *rb3; X XPanel X*defpanel1(), *defpanel2(), *defpanel3(); X Xmain() X{ XActuator *a; XPanel *panel1; XPanel *panel2; Xshort col=RED; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X defpanel3(); X X for (;;) { X a=dopanel(); X if (a==b1) exit(0); X if (a==b4) dumppanel(); X if (a==b2) { X b3->val=b2->val; X b3->dirtycnt=2; X } X if (a==rb1) col=CYAN; X if (a==rb2) col=GREEN; X if (a==rb3) col=RED; X X pushmatrix(); X translate(s1->val,s2->val,0.0); X color(BLACK); X clear(); X color(col); X drawit(); X swapbuffers(); X popmatrix(); X } X} X X Xdrawit() X{ X rectf(-.10,-.10,.10,.10); X} X X XPanel X*defpanel1() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel one"; X panel->ppu=50.0; X X s1=mkact(pnl_hslider); X s1->label="y position"; X s1->x=1.0; X s1->y=0.0; X s1->minval= -1.0; X s1->maxval=1.0; X addact(s1, panel); X X b2=mkact(pnl_toggle_button); X b2->label="push me"; X b2->x=1.0; X b2->y=1.5; X addact(b2, panel); X X b3=mkact(pnl_toggle_button); X b3->label="I push myself"; X b3->x=1.0; X b3->y=2.0; X addact(b3, panel); X X return panel; X} X XPanel X*defpanel2() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel two"; X panel->ppu=50.0; X X s2=mkact(pnl_vslider); X s2->label="x position"; X s2->x=0.0; X s2->y=0.0; X s2->minval= -1.0; X s2->maxval=1.0; X addact(s2, panel); X X b4=mkact(pnl_button); X b4->label="dumppanel"; X b4->x=1.0; X b4->y=1.5; X addact(b4, panel); X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X return panel; X} X XPanel X*defpanel3() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel three"; X panel->ppu=50.0; X X rb3=mkact(pnl_radio_button); X rb3->label="red"; X rb3->x=1.0; X rb3->y=2.0; X rb3->val=1.0; X addact(rb3, panel); X X rb2=mkact(pnl_radio_button); X rb2->label="green"; X rb2->x=1.0; X rb2->y=1.5; X addact(rb2, panel); X X rb1=mkact(pnl_radio_button); X rb1->label="cyan"; X rb1->x=1.0; X rb1->y=1.0; X addact(rb1, panel); X X return panel; X} X SHAR_EOF chmod 0644 demo4.c || echo "restore of demo4.c fails" sed 's/^X//' << 'SHAR_EOF' > demo5.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XActuator *sy, *sx, *sd, *b1, *b2, *b3, *b4, *rb1, *rb2, *rb3; X XPanel X*defpanel1(), *defpanel2(), *defpanel3(); X Xmain() X{ XActuator *a; Xshort col=RED; X X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X defpanel3(); X X needredraw(); X X drawit(col); X swapbuffers(); X drawit(col); X X for (;;) { X a=dopanel(); X if (userredraw()||a) { Xredo: X if (a==b1) exit(0); X if (a==b4) dumppanel(); X if (a==rb1) col=CYAN; X if (a==rb2) col=GREEN; X if (a==rb3) col=RED; X X drawit(col); X swapbuffers(); X X if (a=dopanel()) goto redo; X X drawit(col); X swapbuffers(); X drawit(col); X swapbuffers(); X } X swapbuffers(); X } X} X X Xdrawit(col) XColorindex col; X{ XCoord x,y; X X color(BLACK); X clear(); X color(col); X X for (x= -1.0;x<1.0;x+=sd->val) X for (y= -1.0;y<1.0;y+=sd->val) { X move2(sx->val,sy->val); X draw2(x,y); X } X} X X XPanel X*defpanel1() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="position"; X X sy=mkact(pnl_vslider); X sy->label="y"; X sy->x=0.0; X sy->y=0.0; X sy->minval= -1.0; X sy->maxval=1.0; X addact(sy, panel); X X sx=mkact(pnl_hslider); X sx->label="x position i said - x position"; X sx->x=0.0; X sx->y=1.0; X sx->minval= -1.0; X sx->maxval=1.0; X addact(sx, panel); X} X XPanel X*defpanel2() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="frob it"; X X sd=mkact(pnl_vslider); X sd->label="density"; X sd->x=1.0; X sd->y=0.0; X sd->minval=0.01; X sd->maxval=0.2; X sd->val=0.1; X addact(sd, panel); X} X XPanel X*defpanel3() X{ XPanel *panel; X X panel=mkpanel(); X panel->label="panel three"; X X b1=mkact(pnl_button); X b1->label="exit"; X b1->x=1.0; X b1->y=1.0; X addact(b1, panel); X X rb3=mkact(pnl_radio_button); X rb3->label="red"; X rb3->x=1.0; X rb3->y=3.0; X rb3->val=1.0; X addact(rb3, panel); X X rb2=mkact(pnl_radio_button); X rb2->label="green"; X rb2->x=1.0; X rb2->y=2.5; X addact(rb2, panel); X X rb1=mkact(pnl_radio_button); X rb1->label="cyan"; X rb1->x=1.0; X rb1->y=2.0; X addact(rb1, panel); X X endgroup(panel); X} SHAR_EOF chmod 0644 demo5.c || echo "restore of demo5.c fails" sed 's/^X//' << 'SHAR_EOF' > demo6.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XPanel X*defpanel1(), *defpanel2(); X Xvoid (*drawfunc)(); Xvoid (*savedfunc)(); Xlong snorkseed; Xshort col; X Xmain() X{ X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X X needredraw(); X X#ifdef IRIS_4D X (*drawfunc)(); X for (;;) { X drawpanel(); X if (userredraw()) (*drawfunc)(); X } X#else IRIS_4D X (*drawfunc)(); X (*drawfunc)(); X for (;;) { X drawpanel(); X if (userredraw()) { X (*drawfunc)(); X (*drawfunc)(); /* must have even number here */ X } X swapbuffers(); X } X#endif IRIS_4D X} X Xvoid Xsetcol(a) XActuator *a; X{ X if (!strcmp(a->label,"green")) col=GREEN; X if (!strcmp(a->label,"cyan")) col=CYAN; X if (!strcmp(a->label,"red")) col=RED; X} X Xvoid Xcleanexit() X{ X exit(0); X} X Xvoid Xdrawstar() X{ X color(BLACK); X clear(); X color(col); X move2(-0.6,-0.7); X draw2( 0.0, 0.7); X draw2( 0.6,-0.7); X draw2(-0.7, 0.2); X draw2( 0.7, 0.2); X draw2(-0.6,-0.7); X X swapbuffers(); X} X Xvoid Xdrawcross() X{ X color(BLACK); X clear(); X color(col); X rect(-0.2,-0.7, 0.2, 0.7); X rect(-0.7,-0.2, 0.7, 0.2); X X swapbuffers(); X} X Xvoid Xdrawsnork() X{ Xint i; Xfloat x,y; X X srand(snorkseed); X X color(BLACK); X clear(); X color(col); X move2(0.0,0.0); X for (i=0;i<100;i++) { X x=(float)(rand()%500-250)/275.0; X y=(float)(rand()%500-250)/275.0; X draw2(x,y); X } X X swapbuffers(); X} X Xvoid setstar() { drawfunc=drawstar; } Xvoid setcross() { drawfunc=drawcross; } Xvoid setsnork() { drawfunc=drawsnork; } Xvoid savefunc() { savedfunc=drawfunc; } Xvoid newsnork() { X setsnork(); X snorkseed+=3; X} Xvoid restorefunc() { Xprintf("restoring old drawfunc\n"); X drawfunc=savedfunc; X#ifdef IRIS_4D X (*drawfunc)(); X#else IRIS_4D X (*drawfunc)(); X (*drawfunc)(); X#endif IRIS_4D X} Xvoid setgreen() { col=GREEN; } Xvoid setred() { col=RED; } Xvoid setcyan() { col=CYAN; } X XPanel X*defpanel1() X{ XPanel *p; XActuator *a; X X p=mkpanel(); X p->label="colors"; X X a=mkact(pnl_label); X a->label="color controls"; X a->x=0.0; X a->y=4.0; X addact(a, p); X X a=mkact(pnl_button); X a->label="exit"; X a->x=1.0; X a->y=1.0; X a->labeltype=PNL_LABEL_BOTTOM; X a->downfunc=cleanexit; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="red"; X a->x=1.0; X a->y=3.0; X a->downfunc=setred; X a->val=1.0; X setred(); X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="green"; X a->x=1.0; X a->y=2.5; X a->downfunc=setgreen; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="cyan"; X a->x=1.0; X a->y=2.0; X a->downfunc=setcyan; X addact(a, p); X X endgroup(p); X} X XPanel X*defpanel2() X{ XPanel *p; XActuator *a; X X p=mkpanel(); X p->label="shapes"; X X a=mkact(pnl_label); X a->label="shape controls"; X a->x=0.0; X a->y=4.0; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="star"; X a->x=1.0; X a->y=3.0; X a->downfunc=setstar; X a->val=1.0; X setstar(); X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="cross"; X a->x=1.0; X a->y=2.5; X a->downfunc=setcross; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="snork"; X a->x=1.0; X a->y=2.0; X a->downfunc=setsnork; X addact(a, p); X X endgroup(p); X X a=mkact(pnl_button); X a->label="newsnork"; X a->x=1.0; X a->y=1.5; X a->downfunc=savefunc; X a->activefunc=newsnork; X a->upfunc=restorefunc; X addact(a, p); X} X SHAR_EOF chmod 0644 demo6.c || echo "restore of demo6.c fails" sed 's/^X//' << 'SHAR_EOF' > demo7.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XPanel X*defpanel1(), *defpanel2(); X Xvoid (*drawfunc)(); Xvoid (*savedfunc)(); Xlong snorkseed; Xshort col; X Xmain() X{ X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X X needredraw(); X X#ifdef IRIS_4D X (*drawfunc)(); X for (;;) { X if (dopanel()) (*drawfunc)(); X if (userredraw()) (*drawfunc)(); X } X#else IRIS_4D X (*drawfunc)(); X (*drawfunc)(); X for (;;) { X if (dopanel()) { X do { X (*drawfunc)(); X } while (dopanel()); X (*drawfunc)(); X drawpanel(); X (*drawfunc)(); X (*drawfunc)(); X X /* must have even number here */ X } X if (userredraw()) { X (*drawfunc)(); X (*drawfunc)(); /* must have even number here */ X } X swapbuffers(); X } X#endif IRIS_4D X} X Xvoid Xsetcol(a) XActuator *a; X{ X if (!strcmp(a->label,"green")) col=GREEN; X if (!strcmp(a->label,"cyan")) col=CYAN; X if (!strcmp(a->label,"red")) col=RED; X} X Xvoid Xcleanexit() X{ X exit(0); X} X Xvoid Xdrawstar() X{ X color(BLACK); X clear(); X color(col); X move2(-0.6,-0.7); X draw2( 0.0, 0.7); X draw2( 0.6,-0.7); X draw2(-0.7, 0.2); X draw2( 0.7, 0.2); X draw2(-0.6,-0.7); X X swapbuffers(); X} X Xvoid Xdrawcross() X{ X color(BLACK); X clear(); X color(col); X rect(-0.2,-0.7, 0.2, 0.7); X rect(-0.7,-0.2, 0.7, 0.2); X X swapbuffers(); X} X Xvoid Xdrawsnork() X{ Xint i; Xfloat x,y; X X srand(snorkseed); X X color(BLACK); X clear(); X color(col); X move2(0.0,0.0); X for (i=0;i<100;i++) { X x=(float)(rand()%500-250)/275.0; X y=(float)(rand()%500-250)/275.0; X draw2(x,y); X } X X swapbuffers(); X} X Xvoid setstar() { drawfunc=drawstar; } Xvoid setcross() { drawfunc=drawcross; } Xvoid setsnork() { drawfunc=drawsnork; } Xvoid savefunc() { savedfunc=drawfunc; } Xvoid newsnork() { X setsnork(); X snorkseed+=3; X} Xvoid restorefunc(a) { drawfunc=savedfunc; } Xvoid setgreen() { col=GREEN; } Xvoid setred() { col=RED; } Xvoid setcyan() { col=CYAN; } X XPanel X*defpanel1() X{ XPanel *p; XActuator *a; X X p=mkpanel(); X p->label="colors"; X X a=mkact(pnl_label); X a->label="color controls"; X a->x=0.0; X a->y=4.0; X addact(a, p); X X a=mkact(pnl_button); X a->label="exit"; X a->x=1.0; X a->y=1.0; X a->labeltype=PNL_LABEL_BOTTOM; X a->downfunc=cleanexit; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="red"; X a->x=1.0; X a->y=3.0; X a->downfunc=setcol; X a->val=1.0; X setred(); X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="green"; X a->x=1.0; X a->y=2.5; X a->downfunc=setgreen; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="cyan"; X a->x=1.0; X a->y=2.0; X a->downfunc=setcyan; X addact(a, p); X X endgroup(p); X} X XPanel X*defpanel2() X{ XPanel *p; XActuator *a; X X p=mkpanel(); X p->label="shapes"; X X a=mkact(pnl_label); X a->label="shape controls"; X a->x=0.0; X a->y=4.0; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="star"; X a->x=1.0; X a->y=3.0; X a->downfunc=setstar; X a->val=1.0; X setstar(); X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="cross"; X a->x=1.0; X a->y=2.5; X a->downfunc=setcross; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="snork"; X a->x=1.0; X a->y=2.0; X a->downfunc=setsnork; X addact(a, p); X X endgroup(p); X X a=mkact(pnl_button); X a->label="newsnork"; X a->x=1.0; X a->y=1.5; X a->downfunc=savefunc; X a->activefunc=newsnork; X a->upfunc=restorefunc; X addact(a, p); X} X SHAR_EOF chmod 0644 demo7.c || echo "restore of demo7.c fails" sed 's/^X//' << 'SHAR_EOF' > demo8.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XPanel X*defpanel1(), *defpanel2(); X Xvoid (*drawfunc)(); Xvoid (*savedfunc)(); Xlong snorkseed; Xshort col; X Xmain() X{ X foreground(); X winopen("demo"); X doublebuffer(); X gconfig(); X X ortho2(-1.0,1.0,-1.0,1.0); X X defpanel1(); X defpanel2(); X X needredraw(); X X#ifdef IRIS_4D X (*drawfunc)(); X for (;;) { X if (dopanel()) { X do { X (*drawfunc)(); X } while (dopanel()); X (*drawfunc)(); X } X if (userredraw()) { X reshapeviewport(); X ortho2(-1.0,1.0,-1.0,1.0); X (*drawfunc)(); X } X } X#else IRIS_4D X (*drawfunc)(); X (*drawfunc)(); X for (;;) { X if (dopanel()) { X do { X (*drawfunc)(); X } while (dopanel()); X (*drawfunc)(); X drawpanel(); X (*drawfunc)(); X (*drawfunc)(); X X /* must have even number here */ X } X if (userredraw()) { X reshapeviewport(); X ortho2(-1.0,1.0,-1.0,1.0); X (*drawfunc)(); X (*drawfunc)(); /* must have even number here */ X } X swapbuffers(); X } X#endif IRIS_4D X} X Xvoid Xsetcol(a) XActuator *a; X{ X if (!strcmp(a->label,"green")) col=GREEN; X if (!strcmp(a->label,"cyan")) col=CYAN; X if (!strcmp(a->label,"red")) col=RED; X} X Xvoid Xcleanexit() X{ X exit(0); X} X Xvoid Xdrawstar() X{ X color(BLACK); X clear(); X color(col); X move2(-0.6,-0.7); X draw2( 0.0, 0.7); X draw2( 0.6,-0.7); X draw2(-0.7, 0.2); X draw2( 0.7, 0.2); X draw2(-0.6,-0.7); X X swapbuffers(); X} X Xvoid Xdrawcross() X{ X color(BLACK); X clear(); X color(col); X rect(-0.2,-0.7, 0.2, 0.7); X rect(-0.7,-0.2, 0.7, 0.2); X X swapbuffers(); X} X Xvoid Xdrawsnork() X{ Xint i; Xfloat x,y; X X srand(snorkseed); X X color(BLACK); X clear(); X color(col); X move2(0.0,0.0); X for (i=0;i<100;i++) { X x=(float)(rand()%500-250)/275.0; X y=(float)(rand()%500-250)/275.0; X draw2(x,y); X } X X swapbuffers(); X} X Xvoid setstar() { drawfunc=drawstar; } Xvoid setcross() { drawfunc=drawcross; } Xvoid setsnork() { drawfunc=drawsnork; } Xvoid savefunc() { savedfunc=drawfunc; } Xvoid newsnork() { X setsnork(); X snorkseed+=3; X} Xvoid restorefunc(a) { drawfunc=savedfunc; } Xvoid setgreen() { col=GREEN; } Xvoid setred() { col=RED; } Xvoid setcyan() { col=CYAN; } X XPanel X*defpanel1() X{ XPanel *p; XActuator *a; X X p=mkpanel(); X p->label="colors"; X X a=mkact(pnl_label); X a->label="color controls"; X a->x=1.0; X a->y=4.0; X addact(a, p); X X a=mkact(pnl_wide_button); X a->label="exit"; X a->x=1.0; X a->y=1.0; X a->downfunc=cleanexit; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="red"; X a->x=1.0; X a->y=3.0; X a->downfunc=setcol; X a->val=1.0; X setred(); X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="green"; X a->x=1.0; X a->y=2.5; X a->downfunc=setgreen; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="cyan"; X a->x=1.0; X a->y=2.0; X a->downfunc=setcyan; X addact(a, p); X X endgroup(p); X} X XPanel X*defpanel2() X{ XPanel *p; XActuator *a; X X p=mkpanel(); X p->label="shapes"; X X a=mkact(pnl_label); X a->label="shape controls"; X a->x=1.0; X a->y=4.0; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="star"; X a->x=1.0; X a->y=3.0; X a->downfunc=setstar; X a->val=1.0; X setstar(); X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="cross"; X a->x=1.0; X a->y=2.5; X a->downfunc=setcross; X addact(a, p); X X a=mkact(pnl_radio_button); X a->label="snork"; X a->x=1.0; X a->y=2.0; X a->downfunc=setsnork; X addact(a, p); X X endgroup(p); X X a=mkact(pnl_wide_button); X a->label="make new snorks"; X a->w=4.0; X a->x=1.0; X a->y=1.0; X a->downfunc=savefunc; X a->activefunc=newsnork; X a->upfunc=restorefunc; X addact(a, p); X} X SHAR_EOF chmod 0644 demo8.c || echo "restore of demo8.c fails" sed 's/^X//' << 'SHAR_EOF' > demo9.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include "panel.h" X Xstruct view /* user-defined struct with an Actuator as its FIRST element */ X{ X Actuator act; X float x_angle; X float y_angle; X float z_angle; X}; X X Xfunc (v) Xstruct view *v; /* here the parameter is a user-defined structure */ X{ X printf("it is %f\n", v->x_angle); X} X Xcallit (a) XActuator *a; /* and here its an Actuator */ X{ X (*a->downfunc)(a); X} X Xmain() X{ Xstruct view *v = PNL_MKUSERACT (view, pnl_button); X X v->act.label = "test"; X v->x_angle = 10.0; X v->y_angle = 20.0; X v->z_angle = 30.0; X X v->act.downfunc = (void (*)()) func; X X callit (v); X} X X SHAR_EOF chmod 0644 demo9.c || echo "restore of demo9.c fails" sed 's/^X//' << 'SHAR_EOF' > dial.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X X#define FINE_CONTROL_FACTOR 0.05 X X#define PNL_VAL_TO_WORLD(val, min, max, dist) \ X (((val)-(min))/((max)-(min))*(dist)) X X#define PNL_WORLD_TO_VAL(x, min, max, dist) \ X ((x)/(dist)*((max)-(min))+(min)) X Xvoid _newvaldial(a,p,sx,sy) X Actuator *a; X Panel *p; X Screencoord sx,sy; X{ X Dial *ad=(Dial *)a->data; X Coord wx, wy; X float theta, dtheta; X X if (!a->active) return; X X mapw2(p->vobj,sx,sy,&wx,&wy); X X theta = atan2(wx-a->x-a->w/2.0, wy-a->y-a->h/2.0); X X if (pnl_justdown) { X ad->wsave = theta; X if (!pnl_controlkey) X a->val=PNL_WORLD_TO_VAL(theta, (a->minval+a->maxval)/2.0, X a->maxval, ad->winds*PI); X } X X dtheta=theta-ad->wsave; X if (dtheta> PI) dtheta-=2.0*PI;; X if (dtheta<-PI) dtheta+=2.0*PI; X X if (pnl_controlkey) X a->val+=ad->finefactor X *PNL_WORLD_TO_VAL(dtheta, 0.0, a->maxval-a->minval, ad->winds*2.0*PI); X else X a->val+=PNL_WORLD_TO_VAL(dtheta, 0.0, X a->maxval-a->minval, ad->winds*2.0*PI); X a->val=RANGE(a->val, a->maxval, a->minval); X X ad->wsave=theta; X} X Xvoid X_drawdial(a, p) XActuator *a; XPanel *p; X{ X float thetadeg; X Dial *ad=(Dial *)a->data; X X pushmatrix(); X X translate(a->x,a->y,0.0); X X color(pnl_other_color); X rectf(0.0,0.0,a->w,a->h); X color(pnl_outline_color); X rect(0.0,0.0,a->w,a->h); X color(pnl_normal_color); X circf(a->w/2.0, a->h/2.0, MIN(a->w/2.0, a->h/2.0)-PNL_DIM_3); X color(pnl_outline_color); X circ(a->w/2.0, a->h/2.0, MIN(a->w/2.0, a->h/2.0)-PNL_DIM_3); X X translate(a->w/2.0, a->h/2.0, 0.0); X X thetadeg=PNL_VAL_TO_WORLD(a->val, a->minval, a->maxval, X ad->winds*2.0*PI)*180.0/PI; X rot(-thetadeg+ad->winds*180.0+90.0, 'z'); X X color(pnl_highlight_color); X rectf(0.0,-PNL_DIM_4, MIN(a->w/2.0, a->h/2.0)-PNL_DIM_3, PNL_DIM_4); X color(pnl_outline_color); X rectf(0.0,-PNL_DIM_4, MIN(a->w/2.0, a->h/2.0)-PNL_DIM_3, PNL_DIM_4); X X popmatrix(); X if (a->label) drawlabel(a, p); X} X Xvoid X_hitdial() X{ X} X Xvoid Xpnl_dial(a) XActuator *a; X{ X Dial *ad; X X a->type=PNL_DIAL; X X a->data = alloc(sizeof(Dial)); X a->datasize = sizeof(Dial); X ad=(Dial *)a->data; X ad->wsave=0.0; X ad->finefactor=FINE_CONTROL_FACTOR; X ad->winds=PNL_DIAL_WINDS; X X a->labeltype=PNL_LABEL_BOTTOM; X X a->w=PNL_DIAL_EDGE; X a->h=PNL_DIAL_EDGE; X a->newvalfunc=_newvaldial; X a->drawfunc=_drawdial; X} X SHAR_EOF chmod 0644 dial.c || echo "restore of dial.c fails" sed 's/^X//' << 'SHAR_EOF' > ep.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include X#include X X#define MAXCOLORS 4096 /* for simplicity just make the storage */ X /* the size of the whole map */ X#define MARGIN 5 X#define WINSIZE (YMAXSCREEN-(2*MARGIN)-PNL_TITLE_BAR_HEIGHT) X#define NPNTS 128 X#define BASECOLOR 512 X#define FATLINEWIDTH 3 X#define NORMALLINEWIDTH 1 X#define SQRT3 1.7320508 X X/* #define ABS(x) ((x)<0?-(x):(x))*/ X Xlong /* position and size of regularscreen window */ SHAR_EOF echo "End of part 2, continue with part 3" echo "3" > s2_seq_.tmp exit 0 ------- Received: from VMB.BRL.MIL by VMB.BRL.MIL id ad01476; 18 Aug 88 17:49 EDT Received: from VMB.BRL.MIL by VMB.brl.MIL id ae01422; 18 Aug 88 17:38 EDT Received: from smoke.brl.mil by VMB.BRL.MIL id ab01368; 18 Aug 88 17:28 EDT Received: from orville.nas.nasa.gov by SMOKE.BRL.MIL id aa10084; 18 Aug 88 17:21 EDT Received: Thu, 18 Aug 88 14:20:30 PDT by orville.nas.nasa.gov (5.59/1.2) Date: Thu, 18 Aug 88 14:20:30 PDT From: "David A. Tristram" Message-Id: <8808182120.AA25315@orville.nas.nasa.gov> To: info-iris@BRL.MIL Subject: panel03/06 #!/bin/sh # this is part 3 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file ep.c continued # CurArch=3 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 sed 's/^X//' << 'SHAR_EOF' >> ep.c X regx = MARGIN, X regy = MARGIN, X regw = WINSIZE, X regh = WINSIZE; X Xint bkg=BLACK; /* the background of the data window */ Xint n; /* what one are we drawing now? */ Xfloat t; /* how far are we toward the next triangle? */ Xint nlimit; /* how many do we draw? */ Xint ncolors;/* how many colors do we get? */ Xint basecolor;/* lowest color that we use */ X XPanel *panel; X XActuator *positionpuck, *speedslider, *zoomslider, *wheelslider, *twistslider, X *flipslider, *spinslider, *armslider, *wristslider, *smearbutton, X *zbufbutton, *smoothbutton, *outlinebutton, *sizeslider, X *stopbutton, *fillbutton, *nslider, *fatlinebutton, *fullbutton, X *maprangeslider, *maprateslider, *fadebutton, *ribbonbutton; X XActuator *spectrumbutton, *contourbutton, *bandbutton; X Xstruct resetbutton { X Actuator button; X Actuator *targetact; X float *targetvar; X float varinitval; X}; X Xvoid Xload_spectrum_map() X{ Xfloat h, s, v, r, g, b, x; Xint i, ir, ig, ib; X X x = 0.0; X for (i=0; itargetact->val!=b->targetact->initval) { X b->targetact->val=b->targetact->initval; X fixact(b->targetact); X } else if (b->targetvar) { X *b->targetvar=b->varinitval; X } X} X Xstatic short savR[MAXCOLORS], savG[MAXCOLORS], savB[MAXCOLORS]; X Xsavecolors() X{ Xint i; X X for (i=0;ival==1.0) { X if (a->val==1.0) { X frontbuffer(FALSE); X backbuffer(TRUE); X } else { X frontbuffer(TRUE); X backbuffer(TRUE); X } X } X} X Xvoid Xsetsmear(a) XActuator *a; X{ X if (a->val==1.0) { X if (smoothbutton->val!=1.0) { X if (stopbutton->val!=1.0) { X color(bkg); X clear(); X drawit(); X } X frontbuffer(TRUE); X backbuffer(TRUE); X } X } else { X frontbuffer(FALSE); X backbuffer(TRUE); X } X} X Xvoid Xsetzbuf(a) XActuator *a; X{ X if (a->val!=1.0) { X zbuffer(FALSE); X } else { X zbuffer(TRUE); X zclear(); X } X} X Xvoid Xfullscreen(a) XActuator *a; X{ X if (stopbutton->val==1.0) { /* a bit of a hack, but expressed nicely */ X a->val=0.0; X fixact(a); X return; X } X getorigin(®x, ®y); X getsize(®w, ®h); X winconstraints(); X winposition(0, XMAXSCREEN, 0, YMAXSCREEN); X reshapeviewport(); X perspective(300, (float)XMAXSCREEN/(float)YMAXSCREEN, 0.01, 10000.0); X polarview(10.0, 0, 0, 0); X#ifdef IRIS_GT X lsetdepth(0x0, 0x7fffff); X#else IRIS_GT X setdepth(0x0000,0x3fff); X#endif IRIS_GT X winpop(); X color(bkg); X clear(); X swapbuffers(); X color(bkg); X clear(); X swapbuffers(); X} X Xvoid Xregularscreen() X{ X fullbutton->val=0.0; X fixact(fullbutton); X X winposition(regx, regx+regw, regy, regy+regh); X reshapeviewport(); X perspective(300, 1.0, 0.01, 10000.0); X polarview(10.0, 0, 0, 0); X#ifdef IRIS_GT X lsetdepth(0x0, 0x7fffff); X#else IRIS_GT X setdepth(0x0000,0x3fff); X#endif IRIS_GT X keepaspect(1, 1); X winconstraints(); X X color(bkg); X clear(); X swapbuffers(); X panel->dirtycnt=2; X drawpanel(); X color(bkg); X clear(); X swapbuffers(); X} X Xvoid Xtogglefullscreen(a) XActuator *a; X{ X static fullscreenmode=FALSE; X X if (!fullscreenmode) { X fullscreen(a); X fullscreenmode=TRUE; X } else { X regularscreen(a); X fullscreenmode=FALSE; X } X} X Xfloat wheel, dwheel; Xfloat *x, *y, *dzoom, *arm, *wrist, *dtwist, *flip, *spin; XBoolean *outline, *fatline, *fill; Xfloat *size; Xfloat gflip, dflip, gspin, dspin, gcol; Xfloat *maprange, *maprate; XCoord square[][2] = { X {-0.1, -0.1}, X { 0.1, -0.1}, X { 0.1, 0.1}, X {-0.1, 0.1} X}; X XCoord triangle[][2] = { X { 0.0, 0.0 }, X { 0.2, 0.0 }, X { 0.1, SQRT3/10.0 } X}; X Xmain() X{ X Actuator *a; X Device dev; X short val; X int h, i, j, mexwin; X int itmp; X float tmp; X Boolean newn; X X wheel=0.0; X x=(float *)calloc(NPNTS, sizeof(float)); X y=(float *)calloc(NPNTS, sizeof(float)); X dzoom=(float *)calloc(NPNTS, sizeof(float)); X arm=(float *)calloc(NPNTS, sizeof(float)); X wrist=(float *)calloc(NPNTS, sizeof(float)); X dtwist=(float *)calloc(NPNTS, sizeof(float)); X flip=(float *)calloc(NPNTS, sizeof(float)); X spin=(float *)calloc(NPNTS, sizeof(float)); X outline=(Boolean *)calloc(NPNTS, sizeof(Boolean)); X fatline=(Boolean *)calloc(NPNTS, sizeof(Boolean)); X fill=(Boolean *)calloc(NPNTS, sizeof(Boolean)); X size=(float *)calloc(NPNTS, sizeof(float)); X maprange=(float *)calloc(NPNTS, sizeof(float)); X maprate=(float *)calloc(NPNTS, sizeof(float)); X X#ifdef DEBUG X foreground(); X#endif DEBUG X prefposition(regx, regx+regw, regy, regy+regh); X winopen("ep"); X winconstraints(); X keepaspect(1, 1); X winconstraints(); /* make the window reshapeable */ X winattach(); X mexwin=winget(); X X doublebuffer(); X gconfig(); X X needredraw(); X defpanel(); X X switch (getplanes()) { X case 4: X ncolors=15; X basecolor=1; X maprangeslider->minval=0.0; X maprangeslider->maxval=10.0; X fixact(maprangeslider); X pnl_background_color = 8; X pnl_white_color = 4; X pnl_normal_color = 9; X pnl_other_color = 7; X pnl_highlight_color = 4; X pnl_outline_color = 11; X break; X case 8: X ncolors=128; X basecolor=128; X break; X case 12: X default: X ncolors=128; X basecolor=512; X break; X } X savecolors(); X X load_spectrum_map(); X color(bkg); X clear(); X swapbuffers(); X clear(); X X#ifdef IRIS_4D X shademodel(FLAT); X concave(FALSE); X#endif IRIS_4D X#ifdef IRIS_GT X glcompat(GLC_OLDPOLYGON, FALSE); X#endif IRIS_GT X X perspective(300, 1.0, 0.01, 1000000.0); X polarview(10.0, 0, 0, 0); X /* lookat(0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0); */ X#ifdef IRIS_GT X lsetdepth(0x0, 0x7fffff); X#else IRIS_GT X setdepth(0x0000,0x3fff); X#endif IRIS_GT X X n=0; X t=0.0; X gcol=BASECOLOR+ncolors/2; X X for (;;) { X X a=dopanel(); X if (stopbutton->val==1.0) { X if (smearbutton->val!=1.0) { X color(bkg); X clear(); X } X drawit(); X swapbuffers(); X do { X a=dopanel(); X if (!a) sginap(0); X swapbuffers(); X } while (stopbutton->val==1.0); X } X X if (fullbutton->val==1.0 X && getbutton(LEFTMOUSE)) regularscreen(); X X t+=speedslider->val; X newn=FALSE; X if (t>=1.0) newn=TRUE; X n+=floor(t); X t=fmod(t,1.0); X X x[n%NPNTS]=PNL_ACCESS(Puck,positionpuck,x); X y[n%NPNTS]=PNL_ACCESS(Puck,positionpuck,y); X dzoom[n%NPNTS]=zoomslider->val; X arm[n%NPNTS]=armslider->val; X wrist[n%NPNTS]=wristslider->val; X dwheel=speedslider->val*wheelslider->val; X dtwist[n%NPNTS]=twistslider->val; X nlimit=(int)nslider->val; X outline[n%NPNTS]=outlinebutton->val==1.0; X fatline[n%NPNTS]=fatlinebutton->val==1.0; X fill[n%NPNTS]=fillbutton->val==1.0; X size[n%NPNTS]=sizeslider->val; X maprange[n%NPNTS]=maprangeslider->val; X gcol+=speedslider->val*maprateslider->val; X while(gcol=basecolor+ncolors) gcol-=ncolors; X X if (newn) { X dflip=flipslider->val; X dspin=spinslider->val; X X gflip=fmod(gflip+dflip,360.0); X flip[n%NPNTS]=gflip; X X gspin=fmod(gspin+dspin,360.0); X spin[n%NPNTS]=gspin; X } X X/* winset(mexwin); */ X if (userredraw()) { X reshapeviewport(); X if (fullbutton->val==1.0) X perspective(300, (float)XMAXSCREEN/(float)YMAXSCREEN, 0.01, 10000.0); X else X perspective(300, 1.0, 0.01, 10000.0); X polarview(10.0, 0, 0, 0); X#ifdef IRIS_GT X lsetdepth(0x0, 0x7fffff); X#else IRIS_GT X setdepth(0x0000,0x3fff); X#endif IRIS_GT X } X X wheel=fmod(wheel-dwheel,360.0); X/* fprintf(stderr, "wheel:%f dwheel:%f\n", wheel, dwheel); */ X X if (smearbutton->val!=1.0) { X color(bkg); X clear(); X } else { X if (fadebutton->val==1.0) fadebackground(bkg, 1); X if (smoothbutton->val==1.0) { X drawit(); X swapbuffers(); X if (fadebutton->val==1.0) fadebackground(bkg, 0); X drawpanel(); X } X } X X drawit(); X swapbuffers(); X } X} X Xfloat Xtwixt(i,x,t) Xint i; Xfloat *x; Xfloat t; X{ Xint j=i-1; X X if (j<0) j+=NPNTS; X return x[i]*t+x[j]*(1.0-t); X} X Xfloat Xfoldtwixt(i,x,t) Xint i; Xfloat *x; Xfloat t; X{ X float r; X float d; X int j=i-1; X X if (j<0) j+=NPNTS; X d=x[i]-x[j]; X if (d> 180.0) r=x[i]*t+(x[j]+360.0)*(1.0-t); X else if (d<-180.0) r=(x[i]+360.0)*t+x[j]*(1.0-t); X else r=x[i]*t+x[j]*(1.0-t); X X return r; X} X Xdrawit() X{ Xint i,j; Xint outlinecolor; Xfloat tx,ty,tdzoom,tarm,twrist,tsize; Xfloat tspin,tflip,tdtwist; Xfloat col; X X if (ribbonbutton->val==1.0) { X drawribbons(); return; X } X if (zbufbutton->val==1.0) zclear(); X col=gcol; X X pushmatrix(); X#ifdef FLOAT_ROTATE X rot(wheel, 'x'); X#else X rotate((int)(10.0*wheel), 'x'); X#endif X X for (i=n;i>n-nlimit;i--) { X j=i%NPNTS; X if (j<0) j+=NPNTS; X if (j>NPNTS-1) j-=NPNTS; X X tx=twixt(j,x,t); X ty=twixt(j,y,t); X tdzoom=twixt(j,dzoom,t); X tarm=twixt(j,arm,t); X twrist=twixt(j,wrist,t); X tsize=twixt(j,size,t); X tspin=foldtwixt(j,spin,t); X tflip=foldtwixt(j,flip,t); X tdtwist=twixt(j,dtwist,t); X X color((int)col); X if (outline[j]) { X outlinecolor=((int)col+ncolors/2); X if (outlinecolor>=basecolor+ncolors) outlinecolor-=ncolors; X } X col-=maprange[j]; X while(col=basecolor+ncolors) col-=ncolors; X X if (fatline[j]) { X linewidth(FATLINEWIDTH); X } else { X linewidth(NORMALLINEWIDTH); X } X X pushmatrix(); X translate(tx, ty, 0.0); X#ifdef FLOAT_ROTATE X rot(tspin, 'z'); X#else FLOAT_ROTATE X rotate((int)(10.0*tspin), 'z'); X#endif FLOAT_ROTATE X translate(0.0,tarm,0.0); X#ifdef FLOAT_ROTATE X rot(tflip, 'y'); X#else FLOAT_ROTATE X rotate((int)(10.0*tflip), 'y'); X#endif FLOAT_ROTATE X translate(twrist,0.0,0.0); X scale(tsize,tsize,1.0); X if (fill[j]) polf2(3, triangle); X if (outline[j]) { X color(outlinecolor); X poly2(3, triangle); X color((int)col); X } X popmatrix(); X X scale(1.0, -1.0, 1.0); X X pushmatrix(); X translate(tx, ty, 0.0); X#ifdef FLOAT_ROTATE X rot(tspin, 'z'); X#else FLOAT_ROTATE X rotate((int)(10.0*tspin), 'z'); X#endif FLOAT_ROTATE X translate(0.0,tarm,0.0); X#ifdef FLOAT_ROTATE X rot(tflip, 'y'); X#else FLOAT_ROTATE X rotate((int)(10.0*tflip), 'y'); X#endif FLOAT_ROTATE X translate(twrist,0.0,0.0); X scale(tsize,tsize,1.0); X if (fill[j]) polf2(3, triangle); X if (outline[j]) { X color(outlinecolor); X poly2(3, triangle); X color((int)col); X } X popmatrix(); X X#ifdef FLOAT_ROTATE X rot(180.0, 'z'); X#else FLOAT_ROTATE X rotate((int)(10.0*180.0), 'z'); X#endif FLOAT_ROTATE X X pushmatrix(); X translate(tx, ty, 0.0); X#ifdef FLOAT_ROTATE X rot(tspin, 'z'); X#else FLOAT_ROTATE X rotate((int)(10.0*tspin), 'z'); X#endif FLOAT_ROTATE X translate(0.0,tarm,0.0); X#ifdef FLOAT_ROTATE X rot(tflip, 'y'); X#else FLOAT_ROTATE X rotate((int)(10.0*tflip), 'y'); X#endif FLOAT_ROTATE X translate(twrist,0.0,0.0); X scale(tsize,tsize,1.0); X if (fill[j]) polf2(3, triangle); X if (outline[j]) { X color(outlinecolor); X poly2(3, triangle); X color((int)col); X } X popmatrix(); X X scale(1.0, -1.0, 1.0); X X pushmatrix(); X translate(tx, ty, 0.0); X#ifdef FLOAT_ROTATE X rot(tspin, 'z'); X#else FLOAT_ROTATE X rotate((int)(10.0*tspin), 'z'); X#endif FLOAT_ROTATE X translate(0.0,tarm,0.0); X#ifdef FLOAT_ROTATE X rot(tflip, 'y'); X#else FLOAT_ROTATE X rotate((int)(10.0*tflip), 'y'); X#endif FLOAT_ROTATE X translate(twrist,0.0,0.0); X scale(tsize,tsize,1.0); X if (fill[j]) polf2(3, triangle); X if (outline[j]) { X color(outlinecolor); X poly2(3, triangle); X color((int)col); X } X popmatrix(); X X#ifdef FLOAT_ROTATE X rot(tdtwist, 'z'); X#else FLOAT_ROTATE X rotate((int)(10.0*tdtwist), 'z'); X#endif FLOAT_ROTATE X translate(0.0, 0.0, tdzoom); X X } X popmatrix(); X} X Xdrawribbons() X{ X#ifdef IRIS_GT X int ii,i,j; X int outlinecolor; X float tx,ty,tdzoom,tarm,twrist,tsize; X float tspin,tflip,tdtwist; X float col; X X if (zbufbutton->val==1.0) zclear(); X X pushmatrix(); X#ifdef FLOAT_ROTATE X rot(wheel, 'x'); X#else X rotate((int)(10.0*wheel), 'x'); X#endif X X for (ii=0;ii<4;ii++) { X col=gcol; X pushmatrix(); X bgntmesh(); X for (i=n;i>n-nlimit;i--) { X j=i%NPNTS; X if (j<0) j+=NPNTS; X if (j>NPNTS-1) j-=NPNTS; X X tx=twixt(j,x,t); X ty=twixt(j,y,t); X tdzoom=twixt(j,dzoom,t); X tarm=twixt(j,arm,t); X twrist=twixt(j,wrist,t); X tsize=twixt(j,size,t); X tspin=foldtwixt(j,spin,t); X tflip=foldtwixt(j,flip,t); X tdtwist=twixt(j,dtwist,t); X X color((int)col); X if (outline[j]) { X outlinecolor=((int)col+ncolors/2); X if (outlinecolor>=basecolor+ncolors) outlinecolor-=ncolors; X } X col-=maprange[j]; X while(col=basecolor+ncolors) col-=ncolors; X X if (fatline[j]) { X linewidth(FATLINEWIDTH); X } else { X linewidth(NORMALLINEWIDTH); X } X X pushmatrix(); X translate(tx, ty, 0.0); X#ifdef FLOAT_ROTATE X rot(tspin, 'z'); X#else FLOAT_ROTATE X rotate((int)(10.0*tspin), 'z'); X#endif FLOAT_ROTATE X translate(0.0,tarm,0.0); X#ifdef FLOAT_ROTATE X rot(tflip, 'y'); X#else FLOAT_ROTATE X rotate((int)(10.0*tflip), 'y'); X#endif FLOAT_ROTATE X translate(twrist,0.0,0.0); X scale(tsize,tsize,1.0); X v2f(&triangle[0][0]); v3f(&triangle[1][0]); X popmatrix(); X X#ifdef FLOAT_ROTATE X if (ii<2) rot(tdtwist, 'z'); X else rot(-tdtwist, 'z'); X#else FLOAT_ROTATE X if (ii<2) rotate((int)(10.0*tdtwist), 'z'); X else rotate((int)(-10.0*tdtwist), 'z'); X#endif FLOAT_ROTATE X translate(0.0, 0.0, tdzoom); X X } X popmatrix(); X X if (ii%2) X scale(1.0, -1.0, 1.0); X else X rotate(1800, 'z'); X X } X endtmesh(); X popmatrix(); X#endif IRIS_GT X} X Xdefpanel() X{ XActuator *a; Xstruct resetbutton *rb; XCoord y, dy=0.5; X X initscriptpanel(); X X panel=mkpanel(); X#ifdef IRIS_4D X panel->ppu=40.0; X#else X panel->ppu=38.0; X#endif X panel->label="electro-paint"; X X a=mkact(pnl_label); X a->x=0.2; X a->y=17.5; X a->label="...by Dave Tristram"; X addact(a,panel); X X a=mkact(pnl_wide_button); X a->x=0.0; X a->y=0.0; X a->label="exit"; X a->upfunc=cleanexit; X addact(a,panel); X X y=3.0; X X outlinebutton=mkact(pnl_toggle_button); X outlinebutton->label="outline (O)"; X outlinebutton->labeltype=PNL_LABEL_LEFT; X outlinebutton->x=4.5; X outlinebutton->y=(y-=dy); X outlinebutton->key=OKEY; X addact(outlinebutton,panel); X X fatlinebutton=mkact(pnl_toggle_button); X fatlinebutton->label="fat lines (I)"; X fatlinebutton->labeltype=PNL_LABEL_LEFT; X fatlinebutton->x=4.5; X fatlinebutton->y=(y-=dy); X fatlinebutton->key=IKEY; X addact(fatlinebutton,panel); X X fillbutton=mkact(pnl_toggle_button); X fillbutton->label="fill (U)"; X fillbutton->labeltype=PNL_LABEL_LEFT; X fillbutton->x=4.5; X fillbutton->y=(y-=dy); X fillbutton->val=1.0; X fillbutton->key=UKEY; X addact(fillbutton,panel); X X ribbonbutton=mkact(pnl_toggle_button); X ribbonbutton->label="ribbons (R)"; X ribbonbutton->labeltype=PNL_LABEL_LEFT; X ribbonbutton->x=4.5; X ribbonbutton->y=(y-=dy); X ribbonbutton->key=RKEY; X addact(ribbonbutton,panel); X X smoothbutton=mkact(pnl_toggle_button); X smoothbutton->label="smooth (M)"; X smoothbutton->labeltype=PNL_LABEL_LEFT; X smoothbutton->x=4.5; X smoothbutton->y=(y-=dy); X smoothbutton->downfunc=setsmooth; X smoothbutton->key=MKEY; X addact(smoothbutton,panel); X X smearbutton=mkact(pnl_toggle_button); X smearbutton->label="smear (Q)"; X smearbutton->labeltype=PNL_LABEL_LEFT; X smearbutton->x=4.5; X smearbutton->y=(y-=dy); X smearbutton->downfunc=setsmear; X smearbutton->key=QKEY; X addact(smearbutton,panel); X X fadebutton=mkact(pnl_toggle_button); X fadebutton->label="fade (W)"; X fadebutton->labeltype=PNL_LABEL_LEFT; X fadebutton->x=4.5; X fadebutton->y=(y-=dy); X fadebutton->key=WKEY; X addact(fadebutton,panel); X X zbufbutton=mkact(pnl_toggle_button); X zbufbutton->label="z-buf"; X zbufbutton->labeltype=PNL_LABEL_LEFT; X zbufbutton->x=4.5; X zbufbutton->y=(y-=dy); X zbufbutton->downfunc=setzbuf; X addact(zbufbutton,panel); X X stopbutton=mkact(pnl_toggle_button); X stopbutton->label="stop (S)"; X stopbutton->labeltype=PNL_LABEL_LEFT; X stopbutton->x=4.5; X stopbutton->y=(y-=dy); X stopbutton->key= SKEY; X addact(stopbutton,panel); X X fullbutton=mkact(pnl_toggle_button); X fullbutton->label="full screen (F)"; X fullbutton->labeltype=PNL_LABEL_LEFT; X fullbutton->x=4.5; X fullbutton->y=(y-=dy); X fullbutton->downfunc=togglefullscreen; X fullbutton->key=FKEY; X addact(fullbutton,panel); X X positionpuck=mkact(pnl_floating_puck); X positionpuck->x=0.0; X positionpuck->y=1.5; X addact(positionpuck,panel); X X#define MK_EP_SLIDER(Mname,Mlabel,Mx,My,Mmin,Mmax,Mval,Mvar) \ X Mname/**/slider=mkact(pnl_dvslider); \ X Mname/**/slider->label=Mlabel; \ X Mname/**/slider->labeltype=PNL_LABEL_BOTTOM; \ X Mname/**/slider->x=(Mx); \ X Mname/**/slider->y=(My); \ X Mname/**/slider->val=(Mval); \ X Mname/**/slider->minval=(Mmin); \ X Mname/**/slider->maxval=(Mmax); \ X addact(Mname/**/slider,panel); \ X \ X rb=PNL_MKUSERACT(resetbutton, pnl_wide_button); \ X rb->targetact=Mname/**/slider; \ X rb->targetvar=Mvar; \ X rb->varinitval=0.0; \ X rb->button.label="R"; \ X rb->button.w=PNL_SLIDER_WIDTH; \ X rb->button.h=PNL_BUTTON_EDGE; \ X rb->button.x=Mx; \ X rb->button.y=(My)+PNL_SLIDER_HEIGHT+PNL_DIM_2; \ X rb->button.downfunc=resetact; \ X addact((Actuator *)rb, panel); X X X MK_EP_SLIDER(zoom,"zoom", 0.0, 3.5, -0.5, 0.5, 0.0, NULL); X MK_EP_SLIDER(twist,"twst", 1.0, 3.5, -100.0, 100.0, 0.0, NULL); X MK_EP_SLIDER(speed,"spd", 2.0, 3.5, 0.0, 1.0, 1.0, NULL); X MK_EP_SLIDER(n,"n", 3.0, 3.5, 1.0,NPNTS.0-1.0 ,32.0, NULL); X MK_EP_SLIDER(maprate,"rat", 4.0, 3.5, -20.0, 20.0, 1.0, NULL); X MK_EP_SLIDER(maprange,"rng",5.0, 3.5, 0.0, 100.0, 1.0, NULL); X X MK_EP_SLIDER(wheel,"whl", 0.0, 10.5, -60.0, 60.0, 0.0, &wheel); X MK_EP_SLIDER(spin,"spn", 1.0, 10.5, -20.0, 20.0, 0.0, &gspin); X rb->varinitval=15.0; /* initial value for gspin */ X resetact(rb); X MK_EP_SLIDER(flip,"flp", 2.0, 10.5, -20.0, 20.0, 0.0, &gflip); X MK_EP_SLIDER(arm,"arm", 3.0, 10.5, 0.0, 3.0, 0.0, NULL); X MK_EP_SLIDER(wrist,"wrst", 4.0, 10.5, 0.0, 3.0, 0.0, NULL); X MK_EP_SLIDER(size,"sz", 5.0, 10.5, 0.1, 10.0, 1.0, NULL); X X} X SHAR_EOF chmod 0644 ep.c || echo "restore of ep.c fails" sed 's/^X//' << 'SHAR_EOF' > epslideroid.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include X#include X X#define MAXCOLORS 4096 /* for simplicity just make the storage */ X /* the size of the whole map */ X#define MARGIN 5 X#define WINSIZE (YMAXSCREEN-(2*MARGIN)) X#define NPNTS 128 X#define BASECOLOR 512 X#define FATLINEWIDTH 3 X#define NORMALLINEWIDTH 1 X#define SQRT3 1.7320508 X X#define ABS(x) ((x)<0?-(x):(x)) X Xlong /* position and size of regularscreen window */ X regx = MARGIN, X regy = MARGIN, X regw = WINSIZE, X regh = WINSIZE; X Xint bkg=BLACK; /* the background of the data window */ Xint n; /* what one are we drawing now? */ Xfloat t; /* how far are we toward the next triangle? */ Xint nlimit; /* how many do we draw? */ Xint ncolors;/* how many colors do we get? */ Xint basecolor;/* lowest color that we use */ X XPanel *panel; X XActuator *positionpuck, *speedslider, *zoomslider, *wheelslider, *twistslider, X *flipslider, *spinslider, *armslider, *wristslider, *smearbutton, X *zbufbutton, *smoothbutton, *outlinebutton, *sizeslider, X *stopbutton, *fillbutton, *nslider, *fatlinebutton, *fullbutton, X *maprangeslider, *maprateslider, *fadebutton; X XActuator *spectrumbutton, *contourbutton, *bandbutton; X Xstruct resetbutton { X Actuator button; X Actuator *targetact; X float *targetvar; X float varinitval; X}; X Xvoid Xload_spectrum_map() X{ Xfloat h, s, v, r, g, b, x; Xint i, ir, ig, ib; X X x = 0.0; X for (i=0; itargetact->val!=b->targetact->initval) { X b->targetact->val=b->targetact->initval; X fixact(b->targetact); X } else if (b->targetvar) { X *b->targetvar=b->varinitval; X } X} X Xstatic short savR[MAXCOLORS], savG[MAXCOLORS], savB[MAXCOLORS]; X Xsavecolors() X{ Xint i; X X for (i=0;ival==1.0) { X if (a->val==1.0) { X frontbuffer(FALSE); X backbuffer(TRUE); X } else { X frontbuffer(TRUE); X backbuffer(TRUE); X } X } X} X Xvoid Xsetsmear(a) XActuator *a; X{ X if (a->val==1.0) { X if (smoothbutton->val!=1.0) { X if (stopbutton->val!=1.0) { X color(bkg); X clear(); X drawit(); X } X frontbuffer(TRUE); X backbuffer(TRUE); X } X } else { X frontbuffer(FALSE); X backbuffer(TRUE); X } X} X Xvoid Xsetzbuf(a) XActuator *a; X{ X if (a->val!=1.0) { X zbuffer(FALSE); X } else { X zbuffer(TRUE); X zclear(); X } X} X Xvoid Xfullscreen(a) XActuator *a; X{ X if (stopbutton->val==1.0) { /* a bit of a hack, but expressed nicely */ X a->val=0.0; X fixact(a); X return; X } X getorigin(®x, ®y); X getsize(®w, ®h); X winposition(0, XMAXSCREEN, 0, YMAXSCREEN); X reshapeviewport(); X perspective(300, (float)XMAXSCREEN/(float)YMAXSCREEN, 0.01, 10000.0); X polarview(10.0, 0, 0, 0); X setdepth(0x0000,0x3fff); X winpop(); X color(bkg); X clear(); X swapbuffers(); X color(bkg); X clear(); X swapbuffers(); X} X Xvoid Xregularscreen() X{ X fullbutton->val=0.0; X fixact(fullbutton); X X winposition(regx, regx+regw, regy, regy+regh); X reshapeviewport(); X perspective(300, 1.0, 0.01, 10000.0); X polarview(10.0, 0, 0, 0); X setdepth(0xc000,0x3fff); X X color(bkg); X clear(); X swapbuffers(); X panel->dirtycnt=2; X drawpanel(); X color(bkg); X clear(); X swapbuffers(); X} X Xfloat wheel, dwheel; Xfloat *x, *y, *dzoom, *arm, *wrist, *dtwist, *flip, *spin; XBoolean *outline, *fatline, *fill; Xfloat *size; Xfloat gflip, dflip, gspin, dspin, gcol; Xfloat *maprange, *maprate; XCoord square[][2] = { X {-0.1, -0.1}, X { 0.1, -0.1}, X { 0.1, 0.1}, X {-0.1, 0.1} X}; X XCoord triangle[][2] = { X { 0.0, 0.0 }, X { 0.2, 0.0 }, X { 0.1, SQRT3/10.0 } X}; X Xmain() X{ X Actuator *a; X Device dev; X short val; X int h, i, j, mexwin; X int itmp; X float tmp; X Boolean newn; X X wheel=0.0; X x=(float *)calloc(NPNTS, sizeof(float)); X y=(float *)calloc(NPNTS, sizeof(float)); X dzoom=(float *)calloc(NPNTS, sizeof(float)); X arm=(float *)calloc(NPNTS, sizeof(float)); X wrist=(float *)calloc(NPNTS, sizeof(float)); X dtwist=(float *)calloc(NPNTS, sizeof(float)); X flip=(float *)calloc(NPNTS, sizeof(float)); X spin=(float *)calloc(NPNTS, sizeof(float)); X outline=(Boolean *)calloc(NPNTS, sizeof(Boolean)); X fatline=(Boolean *)calloc(NPNTS, sizeof(Boolean)); X fill=(Boolean *)calloc(NPNTS, sizeof(Boolean)); X size=(float *)calloc(NPNTS, sizeof(float)); X maprange=(float *)calloc(NPNTS, sizeof(float)); X maprate=(float *)calloc(NPNTS, sizeof(float)); X X#ifdef DEBUG X foreground(); X#endif DEBUG X prefposition(regx, regx+regw, regy, regy+regh); X winopen("ep"); X keepaspect(1, 1); X winconstraints(); /* make the window reshapeable */ X winattach(); X mexwin=winget(); X X doublebuffer(); X gconfig(); X X needredraw(); X defpanel(); X X switch (getplanes()) { X case 4: X ncolors=15; X basecolor=1; X maprangeslider->minval=0.0; X maprangeslider->maxval=10.0; X fixact(maprangeslider); X pnl_background_color = 8; X pnl_white_color = 4; X pnl_normal_color = 9; X pnl_other_color = 7; X pnl_highlight_color = 4; X pnl_outline_color = 11; X break; X case 8: X ncolors=128; X basecolor=128; X break; X case 12: X default: X ncolors=128; X basecolor=512; X break; X } X savecolors(); X X load_spectrum_map(); X color(bkg); X clear(); X swapbuffers(); X clear(); X X#ifdef IRIS_4D X shademodel(FLAT); X concave(FALSE); X#endif IRIS_4D X X perspective(300, 1.0, 0.01, 1000000.0); X polarview(10.0, 0, 0, 0); X /* lookat(0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0); */ X setdepth(0xc000,0x3fff); X X n=0; X t=0.0; X gcol=BASECOLOR+ncolors/2; X X for (;;) { X X a=dopanel(); X if (stopbutton->val==1.0) { X if (smearbutton->val!=1.0) { X color(bkg); X clear(); X } X drawit(); X swapbuffers(); X do { X a=dopanel(); X if (!a) sginap(0); X swapbuffers(); X } while (stopbutton->val==1.0); X } X X if (fullbutton->val==1.0 X && getbutton(LEFTMOUSE)) regularscreen(); X X t+=speedslider->val; X newn=FALSE; X if (t>=1.0) newn=TRUE; X n+=floor(t); X t=fmod(t,1.0); X X x[n%NPNTS]=PNL_ACCESS(Puck,positionpuck,x); X y[n%NPNTS]=PNL_ACCESS(Puck,positionpuck,y); X dzoom[n%NPNTS]=zoomslider->val; X arm[n%NPNTS]=armslider->val; X wrist[n%NPNTS]=wristslider->val; X dwheel=speedslider->val*wheelslider->val; X dtwist[n%NPNTS]=twistslider->val; X nlimit=(int)nslider->val; X outline[n%NPNTS]=outlinebutton->val==1.0; X fatline[n%NPNTS]=fatlinebutton->val==1.0; X fill[n%NPNTS]=fillbutton->val==1.0; X size[n%NPNTS]=sizeslider->val; X maprange[n%NPNTS]=maprangeslider->val; X gcol+=speedslider->val*maprateslider->val; X while(gcol=basecolor+ncolors) gcol-=ncolors; X X if (newn) { X dflip=flipslider->val; X dspin=spinslider->val; X X gflip=fmod(gflip+dflip,360.0); X flip[n%NPNTS]=gflip; X X gspin=fmod(gspin+dspin,360.0); X spin[n%NPNTS]=gspin; X } X X/* winset(mexwin); */ X if (userredraw()) { X reshapeviewport(); X if (fullbutton->val==1.0) X perspective(300, (float)XMAXSCREEN/(float)YMAXSCREEN, 0.01, 10000.0); X else X perspective(300, 1.0, 0.01, 10000.0); X polarview(10.0, 0, 0, 0); X setdepth(0xc000,0x3fff); X } X X wheel=fmod(wheel-dwheel,360.0); X/* fprintf(stderr, "wheel:%f dwheel:%f\n", wheel, dwheel); */ X X if (smearbutton->val!=1.0) { X color(bkg); X clear(); X } else { X if (fadebutton->val==1.0) fadebackground(bkg, 1); X if (smoothbutton->val==1.0) { X drawit(); X swapbuffers(); X if (fadebutton->val==1.0) fadebackground(bkg, 0); X drawpanel(); X } X } X X drawit(); X swapbuffers(); X } X} X Xfloat Xtwixt(i,x,t) Xint i; Xfloat *x; Xfloat t; X{ Xint j=i-1; X X if (j<0) j+=NPNTS; X return x[i]*t+x[j]*(1.0-t); X} X Xfloat Xfoldtwixt(i,x,t) Xint i; Xfloat *x; Xfloat t; X{ X float r; X float d; X int j=i-1; X X if (j<0) j+=NPNTS; X d=x[i]-x[j]; X if (d> 180.0) r=x[i]*t+(x[j]+360.0)*(1.0-t); X else if (d<-180.0) r=(x[i]+360.0)*t+x[j]*(1.0-t); X else r=x[i]*t+x[j]*(1.0-t); X X return r; X} X Xdrawit() X{ Xint i,j; Xint outlinecolor; Xfloat tx,ty,tdzoom,tarm,twrist,tsize; Xfloat tspin,tflip,tdtwist; Xfloat col; X X if (zbufbutton->val==1.0) zclear(); X col=gcol; X X pushmatrix(); X#ifdef IRIS_4D X rot(wheel, 'x'); X#else X rotate((int)(10.0*wheel), 'x'); X#endif X X for (i=n;i>n-nlimit;i--) { X j=i%NPNTS; X if (j<0) j+=NPNTS; X if (j>NPNTS-1) j-=NPNTS; X X tx=twixt(j,x,t); X ty=twixt(j,y,t); X tdzoom=twixt(j,dzoom,t); X tarm=twixt(j,arm,t); X twrist=twixt(j,wrist,t); X tsize=twixt(j,size,t); X tspin=foldtwixt(j,spin,t); X tflip=foldtwixt(j,flip,t); X tdtwist=twixt(j,dtwist,t); X X color((int)col); X if (outline[j]) { X outlinecolor=((int)col+ncolors/2); X if (outlinecolor>=basecolor+ncolors) outlinecolor-=ncolors; X } X col-=maprange[j]; X while(col=basecolor+ncolors) col-=ncolors; X X if (fatline[j]) { X linewidth(FATLINEWIDTH); X } else { X linewidth(NORMALLINEWIDTH); X } X X pushmatrix(); X translate(tx, ty, 0.0); X#ifdef IRIS_4D X rot(tspin, 'z'); X#else IRIS_4D X rotate((int)(10.0*tspin), 'z'); X#endif IRIS_4D X translate(0.0,tarm,0.0); X#ifdef IRIS_4D X rot(tflip, 'y'); X#else IRIS_4D X rotate((int)(10.0*tflip), 'y'); X#endif IRIS_4D X translate(twrist,0.0,0.0); X scale(tsize,tsize,1.0); X if (fill[j]) polf2(3, triangle); X if (outline[j]) { X color(outlinecolor); X poly2(3, triangle); X color((int)col); X } X popmatrix(); X X scale(1.0, -1.0, 1.0); X X pushmatrix(); X translate(tx, ty, 0.0); X#ifdef IRIS_4D X rot(tspin, 'z'); X#else IRIS_4D X rotate((int)(10.0*tspin), 'z'); X#endif IRIS_4D X translate(0.0,tarm,0.0); X#ifdef IRIS_4D X rot(tflip, 'y'); X#else IRIS_4D X rotate((int)(10.0*tflip), 'y'); X#endif IRIS_4D X translate(twrist,0.0,0.0); X scale(tsize,tsize,1.0); X if (fill[j]) polf2(3, triangle); X if (outline[j]) { X color(outlinecolor); X poly2(3, triangle); X color((int)col); X } X popmatrix(); X X#ifdef IRIS_4D X rot(180.0, 'z'); X#else IRIS_4D X rotate((int)(10.0*180.0), 'z'); X#endif IRIS_4D X X pushmatrix(); X translate(tx, ty, 0.0); X#ifdef IRIS_4D X rot(tspin, 'z'); X#else IRIS_4D X rotate((int)(10.0*tspin), 'z'); X#endif IRIS_4D X translate(0.0,tarm,0.0); X#ifdef IRIS_4D X rot(tflip, 'y'); X#else IRIS_4D X rotate((int)(10.0*tflip), 'y'); X#endif IRIS_4D X translate(twrist,0.0,0.0); X scale(tsize,tsize,1.0); X if (fill[j]) polf2(3, triangle); X if (outline[j]) { X color(outlinecolor); X poly2(3, triangle); X color((int)col); X } X popmatrix(); X X scale(1.0, -1.0, 1.0); X X pushmatrix(); X translate(tx, ty, 0.0); X#ifdef IRIS_4D X rot(tspin, 'z'); X#else IRIS_4D X rotate((int)(10.0*tspin), 'z'); X#endif IRIS_4D X translate(0.0,tarm,0.0); X#ifdef IRIS_4D X rot(tflip, 'y'); X#else IRIS_4D X rotate((int)(10.0*tflip), 'y'); X#endif IRIS_4D X translate(twrist,0.0,0.0); X scale(tsize,tsize,1.0); X if (fill[j]) polf2(3, triangle); X if (outline[j]) { X color(outlinecolor); X poly2(3, triangle); X color((int)col); X } X popmatrix(); X X#ifdef IRIS_4D X rot(tdtwist, 'z'); X#else IRIS_4D X rotate((int)(10.0*tdtwist), 'z'); X#endif IRIS_4D X translate(0.0, 0.0, tdzoom); X X } X popmatrix(); X} X Xdefpanel() X{ XActuator *a; XSlideroid *ad; X X panel=mkpanel(); X panel->label="scripting"; X X a=mkact(pnl_button); X a->label="dump state"; X a->x=1.0; X a->y=4.5; X a->downfunc=dumpstate; X addact(a, panel); X X a=mkact(pnl_button); X a->label="begin script"; X a->x=1.0; X a->y=4.0; X a->downfunc=beginscript; X addact(a, panel); X X a=mkact(pnl_button); X a->label="end script"; X a->x=1.0; X a->y=3.5; X a->downfunc=endscript; X addact(a, panel); X X a=mkact(pnl_button); X a->label="append to script"; X a->x=1.0; X a->y=3.0; X a->downfunc=appendscript; X addact(a, panel); X X a=mkact(pnl_button); X a->label="read script"; X a->x=1.0; X a->y=2.5; X a->downfunc=readscript; X addact(a, panel); X X a=mkact(pnl_button); X a->label="stop reading script"; X a->x=1.0; X a->y=2.0; X a->downfunc=stopscript; X addact(a, panel); X X X panel=mkpanel(); X#ifdef IRIS_4D X panel->ppu=50.0; X#else X panel->ppu=45.0; X#endif X panel->label="electro-paint"; X X a=mkact(pnl_label); X a->x=0.2; X a->y=17.5; X a->label="...by Dave Tristram"; X addact(a,panel); X X a=mkact(pnl_wide_button); X a->x=0.0; X a->y=0.0; X a->label="exit"; X a->upfunc=cleanexit; X addact(a,panel); X X outlinebutton=mkact(pnl_toggle_button); X outlinebutton->label="outline"; X outlinebutton->labeltype=PNL_LABEL_LEFT; X outlinebutton->x=3.5; X outlinebutton->y=2.5; X addact(outlinebutton,panel); X X fatlinebutton=mkact(pnl_toggle_button); X fatlinebutton->label="fat lines"; X fatlinebutton->labeltype=PNL_LABEL_LEFT; X fatlinebutton->x=3.5; X fatlinebutton->y=2.0; X addact(fatlinebutton,panel); X X fillbutton=mkact(pnl_toggle_button); X fillbutton->label="fill"; X fillbutton->labeltype=PNL_LABEL_LEFT; X fillbutton->x=3.5; X fillbutton->y=1.5; X fillbutton->val=1.0; X addact(fillbutton,panel); X X smoothbutton=mkact(pnl_toggle_button); X smoothbutton->label="smooth"; X smoothbutton->labeltype=PNL_LABEL_LEFT; X smoothbutton->x=3.5; X smoothbutton->y=1.0; X smoothbutton->downfunc=setsmooth; X addact(smoothbutton,panel); X X smearbutton=mkact(pnl_toggle_button); X smearbutton->label="smear"; X smearbutton->labeltype=PNL_LABEL_LEFT; X smearbutton->x=3.5; X smearbutton->y=0.5; X smearbutton->downfunc=setsmear; X addact(smearbutton,panel); X X fadebutton=mkact(pnl_toggle_button); X fadebutton->label="fade"; X fadebutton->labeltype=PNL_LABEL_LEFT; X fadebutton->x=3.5; X fadebutton->y=0.0; X addact(fadebutton,panel); X X zbufbutton=mkact(pnl_toggle_button); X zbufbutton->label="z-buf"; X zbufbutton->labeltype=PNL_LABEL_LEFT; X zbufbutton->x=3.5; X zbufbutton->y=0.0; X zbufbutton->downfunc=setzbuf; X/* addact(zbufbutton,panel); */ X X stopbutton=mkact(pnl_toggle_button); X stopbutton->label="stop"; X stopbutton->labeltype=PNL_LABEL_LEFT; X stopbutton->x=3.5; X stopbutton->y= -0.5; X addact(stopbutton,panel); X X fullbutton=mkact(pnl_toggle_button); X fullbutton->label="full screen"; X fullbutton->labeltype=PNL_LABEL_LEFT; X fullbutton->x=3.5; X fullbutton->y= -1.0; X fullbutton->downfunc=fullscreen; X addact(fullbutton,panel); X X positionpuck=mkact(pnl_floating_puck); X positionpuck->x=0.0; X positionpuck->y=1.5; X addact(positionpuck,panel); X X#define MK_EP_SLIDEROID(Mname,Mlabel,Mx,My,Mmin,Mmax,Mval,Mvar) \ X Mname/**/slider=mkact(pnl_slideroid); \ X Mname/**/slider->label=Mlabel; \ X Mname/**/slider->labeltype=PNL_LABEL_BOTTOM; \ X Mname/**/slider->x=(Mx); \ X Mname/**/slider->y=(My); \ X Mname/**/slider->val=(Mval); \ X Mname/**/slider->minval=(Mmin); \ X Mname/**/slider->maxval=(Mmax); \ X ad=(Slideroid *)Mname/**/slider->data; \ X ad->resettarget=Mvar; \ X ad->resetval=Mval; \ X addact(Mname/**/slider,panel); X X X MK_EP_SLIDEROID(zoom,"zoom", 0.0, 3.5, -0.5, 0.5, 0.0, NULL); X MK_EP_SLIDEROID(twist,"twist",0.0, 5.5, -100.0, 100.0, 0.0, NULL); X MK_EP_SLIDEROID(speed,"speed",0.0, 7.5, 0.0, 1.0, 1.0, NULL); X MK_EP_SLIDEROID(n,"n", 0.0, 9.5, 1.0,NPNTS.0-1.0 ,32.0, NULL); X MK_EP_SLIDEROID(maprate,"rate",0.0,11.5, -20.0, 20.0, 1.0, NULL); X MK_EP_SLIDEROID(maprange,"range",0.0, 13.5, 0.0, 100.0, 1.0, NULL); X X MK_EP_SLIDEROID(wheel,"wheel",2.0, 3.5, -60.0, 60.0, 0.0, &wheel); X MK_EP_SLIDEROID(spin,"spin", 2.0, 5.5, -20.0, 20.0, 0.0, &gspin); X gspin=((Slideroid *)spinslider->data)->resetval=15.0; X MK_EP_SLIDEROID(flip,"flip", 2.0, 7.5, -20.0, 20.0, 0.0, &gflip); X MK_EP_SLIDEROID(arm,"arm", 2.0, 9.5, 0.0, 3.0, 0.0, NULL); X MK_EP_SLIDEROID(wrist,"wrist",2.0, 11.5, 0.0, 3.0, 0.0, NULL); X MK_EP_SLIDEROID(size,"size", 2.0, 13.5, 0.1, 10.0, 1.0, NULL); X X} X SHAR_EOF chmod 0644 epslideroid.c || echo "restore of epslideroid.c fails" sed 's/^X//' << 'SHAR_EOF' > eric.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include X XActuator *hs, *vs; X XPanel X*defpanel1(), *defpanel2(), *defpanel3(); X Xmain () X{ X short col; X X foreground (); X winopen ("demo"); X doublebuffer (); X gconfig (); X X ortho2 (-1.0,1.0,-1.0,1.0); X X defpanel1 (); X defpanel2 (); X defpanel3 (); X X color (RED); X X for (;;) { X (void) dopanel (); X pushmatrix (); X translate (hs->val,vs->val,0.0); X col = getcolor (); X color (BLACK); X clear (); X color (col); X rectf (-.10,-.10,.10,.10); X swapbuffers (); X popmatrix (); X } X} X X Xtypedef void (*PFV)(); X Xstruct button_hook X{ X Actuator act; X Actuator *button; X}; X Xset_my_button (b) X struct button_hook *b; X{ X b->button->val = b->act.val; X b->button->dirtycnt = 2; X} X XPanel X*defpanel1 () X{ X Panel *panel; X Actuator *slave; X struct button_hook *master; X X panel=mkpanel (); X panel->label="panel one"; X panel->ppu=50.0; X X hs = mkact (PNL_HSLIDER); X hs->label = "y position"; X hs->x = 1.0; X hs->y = 0.0; X hs->minval = -1.0; X hs->maxval = 1.0; X addact (hs, panel); X X slave = mkact (PNL_TOGGLE_BUTTON); X slave->label = "I push myself"; X slave->x = 1.0; X slave->y = 2.0; X addact (slave, panel); X X master = PNL_MKUSERACT (button_hook, PNL_TOGGLE_BUTTON); X master->button = slave; X master->act.label = "push me"; X master->act.x = 1.0; X master->act.y = 1.5; X master->act.downfunc = (PFV) set_my_button; X addact (master, panel); X X return panel; X} X Xclean_exit () X{ X exit (0); X} X XPanel X*defpanel2 () X{ X Panel *panel; X Actuator *tem; X X panel = mkpanel (); X panel->label = "panel two"; X panel->ppu = 50.0; X X vs = mkact (PNL_VSLIDER); X vs->label = "x position"; X vs->x = 0.0; X vs->y = 0.0; X vs->minval = -1.0; X vs->maxval = 1.0; X addact (vs, panel); X X tem = mkact (PNL_BUTTON); X tem->label = "dumppanel"; X tem->x = 1.0; X tem->y = 1.5; X tem->downfunc = (void (*)()) dumppanel; X addact (tem, panel); X X tem = mkact (PNL_BUTTON); X tem->label = "exit"; X tem->x = 1.0; X tem->y = 1.0; X tem->downfunc = (void (*)()) clean_exit; X addact (tem, panel); X X return panel; X} X Xstruct color_struct X{ X Actuator act; X Colorindex color; X} *cs; X Xset_color_func (cs) X struct color_struct *cs; X{ X color (cs->color); X} X XPanel X*defpanel3 () X{ X Panel *panel; X X panel = mkpanel (); X panel->label = "panel three"; X panel->ppu = 50.0; X X#define MAKE_COLOR_BUTTON(_color, _label, _x, _y, _val) \ X cs = PNL_MKUSERACT (color_struct, PNL_RADIO_BUTTON); \ X cs->color = _color; \ X cs->act.label = _label; \ X cs->act.x = _x; \ X cs->act.y = _y; \ X cs->act.val = _val; \ X cs->act.downfunc = (void (*)()) set_color_func; \ X addact (cs, panel) X X MAKE_COLOR_BUTTON (RED, "red", 1.0, 2.0, 1.0); X MAKE_COLOR_BUTTON (GREEN, "green", 1.0, 1.5, 0.0); X MAKE_COLOR_BUTTON (CYAN, " cyan", 1.0, 1.0, 0.0); X X return panel; X} SHAR_EOF chmod 0644 eric.c || echo "restore of eric.c fails" sed 's/^X//' << 'SHAR_EOF' > fade.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X/* X * fade - X * Make a background that fades windows out using a special X * pixel hack. X * X * Paul Haeberli - 1985 X * X */ X#include "gl.h" X#include "device.h" X Xshort tex[16]; Xint slow; X Xstatic int shifts[16] = { X 0, 2, 2, 0, X 1, 3, 3, 1, X 0, 2, 2, 0, X 1, 3, 3, 1, X}; X Xstatic int wheres[16] = { X 0, 2, 0, 2, X 1, 3, 1, 3, X 1, 3, 1, 3, X 0, 2, 0, 2, X}; X X/* bkg- the color you want to fade to X * adv- 1 to advance to the next texture (the normal case) X * 0 to remain at the same one (for the back buffer, say) X */ X Xfadebackground(bkg, adv) XColorindex bkg; Xint adv; X{ Xstatic int state; X X int i, k; X static int texno; X register int shift, where, pattern; X X texno+=adv; X/* texno=rand()%16; band mode */ X X while (texno>=16) texno -= 16; X for (i=0; i<16; i++) X tex[i] = 0; X shift = shifts[texno]; X where = wheres[texno]; X pattern = 0x1111< g_gets.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X/* X * g_gets.c : How to read a string from the keyboard without a textport. X * X * char *g_gets(stringcolor, backcolor, cursorcolor) X * returns stuff like gets() does X * Colorindex stringcolor, backcolor, cursorcolor; X * X */ X#include X#include X#include X X#define MAXSTRINGLEN 80 X#define MAXQUEUED 100 X#define MAXEVENTS 100 X#define MAXDEVICES 1024 X#define RESET -3 X#define ERASE -2 X#define QUIT -1 X Xstatic int numqueued = 0; Xstatic int numevents = 0; Xstatic int qstack[MAXQUEUED]; Xstatic struct { X Device dev; X short data; X} eventq[MAXEVENTS]; Xstatic long buf_state; X Xtypedef struct { X int device_num; X char lower; X char upper; X} KEY ; X Xstatic KEY keyboard[] = X{ X { AKEY, 'a', 'A' }, X { BKEY, 'b', 'B' }, X { CKEY, 'c', 'C' }, X { DKEY, 'd', 'D' }, X { EKEY, 'e', 'E' }, X { FKEY, 'f', 'F' }, X { GKEY, 'g', 'G' }, X { HKEY, 'h', 'H' }, X { IKEY, 'i', 'I' }, X { JKEY, 'j', 'J' }, X { KKEY, 'k', 'K' }, X { LKEY, 'l', 'L' }, X { MKEY, 'm', 'M' }, X { NKEY, 'n', 'N' }, X { OKEY, 'o', 'O' }, X { PKEY, 'p', 'P' }, X { QKEY, 'q', 'Q' }, X { RKEY, 'r', 'R' }, X { SKEY, 's', 'S' }, X { TKEY, 't', 'T' }, X { UKEY, 'u', 'U' }, X { VKEY, 'v', 'V' }, X { WKEY, 'w', 'W' }, X { XKEY, 'x', 'X' }, X { YKEY, 'y', 'Y' }, X { ZKEY, 'z', 'Z' }, X { ZEROKEY, '0', ')' }, X { ONEKEY, '1', '!' }, X { TWOKEY, '2', '@' }, X { THREEKEY, '3', '#' }, X { FOURKEY, '4', '$' }, X { FIVEKEY, '5', '%' }, X { SIXKEY, '6', '^' }, X { SEVENKEY, '7', '&' }, X { EIGHTKEY, '8', '*' }, X { NINEKEY, '9', '(' }, X { SEMICOLONKEY, ';', ':' }, X { PERIODKEY, '.', '>' }, X { COMMAKEY, ',', '<' }, X { ACCENTGRAVEKEY,'`', '~' }, X { MINUSKEY, '-', '_' }, X { QUOTEKEY, '\'', '"' }, X { BACKSLASHKEY, '\\', '|' }, X { EQUALKEY, '=', '+' }, X { LEFTBRACKETKEY,'[', '{' }, X { RIGHTBRACKETKEY,']', '}' }, X { VIRGULEKEY, '/', '?' }, X { SPACEKEY, ' ', '\0' }, X { TABKEY, '\t', '\0' }, X { RETKEY, '\r', '\0' }, X { LINEFEEDKEY, '\n', '\0' }, X { BREAKKEY, '\0', '\0' }, X { BACKSPACEKEY, '\b', '\0' }, X { DELKEY, '\0', '\0' }, X { SETUPKEY, '\0', '\0' }, X { CTRLKEY, '\0', '\0' }, X { CAPSLOCKKEY, '\0', '\0' }, X { RIGHTSHIFTKEY, '\0', '\0' }, X { LEFTSHIFTKEY, '\0', '\0' }, X { NOSCRLKEY, '\0', '\0' }, X { ESCKEY, '\0', '\0' }, X { LEFTARROWKEY, '\0', '\0' }, X { DOWNARROWKEY, '\0', '\0' }, X { RIGHTARROWKEY, '\0', '\0' }, X { UPARROWKEY, '\0', '\0' }, X { -1, '\0', '\0' } X}; X X XScreencoord ix, iy; Xint char_width; Xint char_height; Xint char_descender; Xint capitalize, controlize; Xstatic char string[MAXSTRINGLEN]; X X/*-----------------------------------------------------------------------*/ Xchar *g_gets(stringcolor, backcolor, cursorcolor) X /* do a gets without using textports ..echoing the */ X /* character on the screen, erasing when necessary */ X/*-----------------------------------------------------------------------*/ XColorindex stringcolor, backcolor, cursorcolor; X{ Xchar *g_getstring(); X X return g_getstring(stringcolor, backcolor, "", MAXSTRINGLEN); X} X X X/*-----------------------------------------------------------------------*/ SHAR_EOF echo "End of part 3, continue with part 4" echo "4" > s2_seq_.tmp exit 0 ------- Received: from VMB.BRL.MIL by VMB.BRL.MIL id af01476; 18 Aug 88 17:49 EDT Received: from VMB.BRL.MIL by VMB.brl.MIL id ag01422; 18 Aug 88 17:38 EDT Received: from smoke.brl.mil by VMB.BRL.MIL id ad01368; 18 Aug 88 17:28 EDT Received: from orville.nas.nasa.gov by SMOKE.BRL.MIL id aa10090; 18 Aug 88 17:22 EDT Received: Thu, 18 Aug 88 14:20:51 PDT by orville.nas.nasa.gov (5.59/1.2) Date: Thu, 18 Aug 88 14:20:51 PDT From: "David A. Tristram" Message-Id: <8808182120.AA25321@orville.nas.nasa.gov> To: info-iris@BRL.MIL Subject: panel04/06 #!/bin/sh # this is part 4 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file g_gets.c continued # CurArch=4 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 sed 's/^X//' << 'SHAR_EOF' >> g_gets.c Xchar *g_getstring(stringcolor, backcolor, cursorcolor, protostring, maxstringlen) X /* do a gets without using textports ..echoing the */ X /* character on the screen, erasing when necessary */ X/*-----------------------------------------------------------------------*/ XColorindex stringcolor, backcolor, cursorcolor; Xchar *protostring; /* initial string */ Xint maxstringlen; X{ X int g_getchar(); X register int i; X int c; X int protolen = strlen(protostring); X X char_width = strwidth("a"); X char_height = getheight(); X char_descender = getdescender(); X getcpos(&ix, &iy); X X numqueued = 0; X numevents = 0; X capitalize = 0; X controlize = 0; X X saveq(); X pushviewport(); X pushattributes(); X pushmatrix(); X screenspace(); X X frontbuffer(1); backbuffer(0); X X for (i = 1; i <= MAXKBDBUT; i++) qdevice(i); X if (protolen>maxstringlen) goto exit; X Xrestart: X bzero(string, maxstringlen); X color(cursorcolor); X drawcursor(protolen, maxstringlen); X if (protolen) { X strcpy(string, protostring); X cmov2i(ix,iy); X color(stringcolor); X charstr(protostring); X } X for (i = protolen;;) { X string[i]=(char)(c=g_getchar()); X switch(c) { X case '\n': X case '\r': X case '\0': X case QUIT: X string[i] = '\0'; X goto exit; X case RESET: X color(backcolor); X drawcursor(i, maxstringlen); X cmov2i(ix,iy); X charstr(string); X cmov2i(ix,iy); X protolen=0; X goto restart; X case ERASE: X if (i == 0) break; X string[i--] = '\0'; X color(backcolor); X drawcursor(i+1, maxstringlen); X color(cursorcolor); X drawcursor(i, maxstringlen); X cmov2i(ix+ i*char_width , iy); X break; X default: X if (!(i gets.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X/* X * g_gets.c : How to read a string from the keyboard without a textport. X * X */ X#include X#include X#include X X#define MAXSTRINGLEN 80 X#define MAXQUEUED 100 X#define MAXDEVICES 1024 X#define ERASE -2 X#define QUIT -1 X Xtypedef struct { X int device_num; X char lower; X char upper; X} KEY ; X Xstatic KEY keyboard[] = X{ X { AKEY, 'a', 'A' }, X { BKEY, 'b', 'B' }, X { CKEY, 'c', 'C' }, X { DKEY, 'd', 'D' }, X { EKEY, 'e', 'E' }, X { FKEY, 'f', 'F' }, X { GKEY, 'g', 'G' }, X { HKEY, 'h', 'H' }, X { IKEY, 'i', 'I' }, X { JKEY, 'j', 'J' }, X { KKEY, 'k', 'K' }, X { LKEY, 'l', 'L' }, X { MKEY, 'm', 'M' }, X { NKEY, 'n', 'N' }, X { OKEY, 'o', 'O' }, X { PKEY, 'p', 'P' }, X { QKEY, 'q', 'Q' }, X { RKEY, 'r', 'R' }, X { SKEY, 's', 'S' }, X { TKEY, 't', 'T' }, X { UKEY, 'u', 'U' }, X { VKEY, 'v', 'V' }, X { WKEY, 'w', 'W' }, X { XKEY, 'x', 'X' }, X { YKEY, 'y', 'Y' }, X { ZKEY, 'z', 'Z' }, X { ZEROKEY, '0', ')' }, X { ONEKEY, '1', '!' }, X { TWOKEY, '2', '@' }, X { THREEKEY, '3', '#' }, X { FOURKEY, '4', '$' }, X { FIVEKEY, '5', '%' }, X { SIXKEY, '6', '^' }, X { SEVENKEY, '7', '&' }, X { EIGHTKEY, '8', '*' }, X { NINEKEY, '9', '(' }, X { SEMICOLONKEY, ';', ':' }, X { PERIODKEY, '.', '>' }, X { COMMAKEY, ',', '<' }, X { ACCENTGRAVEKEY,'`', '~' }, X { MINUSKEY, '-', '_' }, X { QUOTEKEY, '\'', '"' }, X { BACKSLASHKEY, '\\', '|' }, X { EQUALKEY, '=', '+' }, X { LEFTBRACKETKEY,'[', '{' }, X { RIGHTBRACKETKEY,']', '}' }, X { VIRGULEKEY, '/', '?' }, X { SPACEKEY, ' ', '\0' }, X { TABKEY, '\t', '\0' }, X { RETKEY, '\r', '\0' }, X { LINEFEEDKEY, '\n', '\0' }, X { BREAKKEY, '\0', '\0' }, X { BACKSPACEKEY, '\b', '\0' }, X { DELKEY, '\0', '\0' }, X { SETUPKEY, '\0', '\0' }, X { CTRLKEY, '\0', '\0' }, X { CAPSLOCKKEY, '\0', '\0' }, X { RIGHTSHIFTKEY, '\0', '\0' }, X { LEFTSHIFTKEY, '\0', '\0' }, X { NOSCRLKEY, '\0', '\0' }, X { ESCKEY, '\0', '\0' }, X { LEFTARROWKEY, '\0', '\0' }, X { DOWNARROWKEY, '\0', '\0' }, X { RIGHTARROWKEY, '\0', '\0' }, X { UPARROWKEY, '\0', '\0' }, X { -1, '\0', '\0' } X}; X X Xstatic char string[MAXSTRINGLEN]; Xstatic int bufmode; X X/*-----------------------------------------------------------------------*/ Xchar *g_gets(ix, iy, stringcolor, backcolor) X /* do a gets without using textports ..echoing the */ X /* character on the screen, erasing when necesary */ X/*-----------------------------------------------------------------------*/ XColorindex stringcolor, backcolor; X{ X X static int inited = 0; X char g_getchar(); X int i; X int char_width = strwidth("a"); X X saveq(); X frontbuffer(TRUE); X backbuffer(FALSE); X X for (i = 1; i <= MAXKBDBUT; i++) qdevice(i); X cmov2i(ix, iy); X bzero(string, MAXSTRINGLEN); X X for (i = 0; i < MAXSTRINGLEN;) { X switch(string[i] = g_getchar()) X { X case '\n': X case '\r': X/* checkit(); */ X string[i] = '\0'; X goto exit; X X case '\0': X case QUIT: X for (i = 1; i <= MAXKBDBUT; i++) unqdevice(i); X restoreq(); X return(NULL); X X case ERASE: X if (i == 0) break; X string[i--] = '\0'; X cmov2i(ix+ i*char_width , iy); X color(backcolor); X charstr(&string[i]); X cmov2i(ix+ i*char_width , iy); X break; X X default: X/* checkit(); */ X color(stringcolor); X charstr(&string[i++]); X break; X } X } X Xexit: X for (i = 1; i <= MAXKBDBUT; i++) unqdevice(i); X restoreq(); X return(string); X} X X/*-----------------------------------------------------------------------*/ Xstatic char g_getchar() /* do a getchar without using textports */ X/*-----------------------------------------------------------------------*/ X{ X static capitalize = 0; X short val; X char upperkey(), lowerkey(); X long key; X X for(;;){ X key= qread(&val); X if (key == LEFTSHIFTKEY || key == RIGHTSHIFTKEY){ X capitalize = val; X continue; X }else if (val) /* do until user holds a key down */ X break; X } X X switch(key) X { X case DELKEY: X case BACKSPACEKEY: X return(ERASE); X X case ESCKEY: X return(QUIT); X default: X if (capitalize) return(upperkey(key)); X else return (lowerkey(key)); X } X} X X/*-------------------------------------------------------------------------*/ Xstatic char lowerkey(dev) /* maps sgi keyboard device numbers to printable */ X /* ascii characters. null for nonprintables */ X/*-------------------------------------------------------------------------*/ X{ X int i; X X for (i = 0; keyboard[i].device_num != -1; i++) X if(dev == keyboard[i].device_num) return(keyboard[i].lower); X return('\0'); X} X X/*-------------------------------------------------------------------------*/ Xstatic char upperkey(dev) /* maps sgi keyboard device numbers to printable */ X /* ascii characters. null for nonprintables */ X/*-------------------------------------------------------------------------*/ X{ X int i; X X for (i = 0; keyboard[i].device_num != -1; i++) X if(dev == keyboard[i].device_num) return(keyboard[i].upper); X return('\0'); X} X X Xstatic int numqueued = 0; Xstatic int qstack[MAXQUEUED]; X X/*------------------------------------------------------------------------*/ Xstatic saveq() /* save the device numbers of all keyboard queued devices */ X /* and unqueue them */ X/*------------------------------------------------------------------------*/ X{ X int i; X X bufmode = getbuffer(); /* also save enabled buffers */ X for (i = 1; i <= MAXKBDBUT; i++) X if (isqueued(i)) { X qstack[numqueued++] = i; X if (numqueued >= MAXQUEUED) { X fprintf(stderr, "Eeeek qstack overflow\n"); X return; X } X unqdevice(i); X } X} X X/*-----------------------------------------------------------------------*/ Xstatic restoreq() /* requeue all devices that were queued */ X/*-----------------------------------------------------------------------*/ X{ X backbuffer(bufmode&0x1); /* also restore enabled buffers */ X frontbuffer(bufmode&0x2); X while (numqueued) qdevice(--numqueued); X qreset(); X} SHAR_EOF chmod 0644 gets.c || echo "restore of gets.c fails" sed 's/^X//' << 'SHAR_EOF' > mouse.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include "panel.h" X Xvoid _newvalmouse(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ X Mouse *ad=(Mouse *)a->data; X X ad->x=p->x+sx; /* relative to screen origin */ X ad->y=p->y+sy; X X if (a->active) a->val=1.0; X else a->val=0.0; X} X Xvoid X_addmouse(a, p) XActuator *a; XPanel *p; X{ X if (pnl_mouse_act) { X fprintf(stderr, "libpanel: warning, duplicate pnl_mouse actuator\n"); X return; X } X a->data=alloc(sizeof(Mouse)); X pnl_mouse_act=a; X} X Xvoid Xpnl_mouse(a) XActuator *a; X{ X a->type=PNL_MOUSE; X X/* a->automatic=TRUE; */ X a->visible=FALSE; X a->newvalfunc=_newvalmouse; X a->addfunc=_addmouse; X a->drawfunc=NULL; X} X SHAR_EOF chmod 0644 mouse.c || echo "restore of mouse.c fails" sed 's/^X//' << 'SHAR_EOF' > palette.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include "panel.h" X X#define FINE_CONTROL_FACTOR 0.05 X Xvoid setpaletteval(a, x, dist) X Actuator *a; X Coord x; X float dist; X{ X Palette *ad=(Palette *)a->data; X X if (pnl_justdown) { X a->val=PNL_WORLD_TO_VAL(x, a->minval, a->maxval, dist); X ad->wsave=x; X } X X if (pnl_controlkey) a->val+= ad->finefactor X *(x-ad->wsave)/dist*(a->maxval-a->minval); X else { X a->val=PNL_WORLD_TO_VAL(x, a->minval, a->maxval, dist); X } X a->val=RANGE(a->val, a->maxval, a->minval); X X ad->wsave=x; X } X Xvoid _newvalvpalette(a,p,sx,sy) X Actuator *a; X Panel *p; X Screencoord sx,sy; X{ X Palette *ad=(Palette *)a->data; X Coord wx, wy; X float tmp; X X if (!a->active) return; X X mapw2(p->vobj,sx,sy,&wx,&wy); X X setpaletteval(a, wy-a->y, a->h); X} X Xvoid _newvalhpalette(a,p,sx,sy) X Actuator *a; X Panel *p; X Screencoord sx,sy; X{ X Palette *ad=(Palette *)a->data; X Coord wx, wy; X X if (!a->active) return; X X mapw2(p->vobj,sx,sy,&wx,&wy); X X setpaletteval(a, wx-a->x, a->w); X} X Xvoid X_drawvpalette(a, p) XActuator *a; XPanel *p; X{ XCoord y; X X pushmatrix(); X X translate(a->x,a->y,0.0); X X setshade((Colorindex)a->minval); X pmv2(0.0, 0.0); X pdr2(a->w, 0.0); X setshade((Colorindex)a->maxval); X pdr2(a->w, a->h); X pdr2(0.0, a->h); X spclos(); X X color(pnl_outline_color); X rect(0.0,0.0,a->w,a->h); X X popmatrix(); X if (a->label) drawlabel(a, p); X} X Xvoid X_drawhpalette(a, p) XActuator *a; XPanel *p; X{ XCoord y; X X pushmatrix(); X X translate(a->x,a->y,0.0); X X setshade((Colorindex)a->minval); X pmv2(0.0, 0.0); X pdr2(0.0, a->h); X setshade((Colorindex)a->maxval); X pdr2(a->w, a->h); X pdr2(a->w, 0.0); X spclos(); X color(pnl_outline_color); X rect(0.0,0.0,a->w,a->h); X X popmatrix(); X if (a->label) drawlabel(a, p); X} X Xvoid Xpnl_palette(a) XActuator *a; X{ X Palette *ad; X X a->type=PNL_PALETTE; X X a->data = alloc(sizeof(Palette)); X a->datasize = sizeof(Palette); X ad=(Palette *)a->data; X ad->wsave=0.0; X ad->finefactor=FINE_CONTROL_FACTOR; X X a->labeltype=PNL_LABEL_BOTTOM; X a->w=PNL_SLIDER_WIDTH; X a->h=PNL_SLIDER_HEIGHT; X a->newvalfunc=_newvalvpalette; X a->drawfunc=_drawvpalette; X} X Xvoid Xpnl_vpalette(a) XActuator *a; X{ X pnl_palette(a); X a->type=PNL_VSLIDER; X X a->w=PNL_SLIDER_WIDTH; X a->h=PNL_SLIDER_HEIGHT; X a->newvalfunc=_newvalvpalette; X a->drawfunc=_drawvpalette; X} X Xvoid Xpnl_hpalette(a) XActuator *a; X{ X pnl_palette(a); X a->type=PNL_HSLIDER; X X a->w=PNL_SLIDER_HEIGHT; X a->h=PNL_SLIDER_WIDTH; X a->newvalfunc=_newvalhpalette; X a->drawfunc=_drawhpalette; X} X SHAR_EOF chmod 0644 palette.c || echo "restore of palette.c fails" sed 's/^X//' << 'SHAR_EOF' > panel.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include X#include X#include X#include X#include X X#define PNL_EXTERN /* nothing */ X#define PNL_INIT(X) = (X) X#include "panel.h" X X#ifdef IRIS_4D XActuator *pickact(Panel *, Screencoord, Screencoord); XBoolean _hitact(/*Actuator *, Panel *, Coord, Coord*/); /* note: can't declare floats */ Xvoid _dumpact(Actuator *, int); Xvoid _loadact(Actuator *, int); Xvoid _fixpnl(Panel *); Xvoid _drawpnl(Panel *); X#else IRIS_4D XActuator *pickact(); XBoolean _hitact(); Xvoid _dumpact(); Xvoid _loadact(); Xvoid _fixpnl(); Xvoid _drawpnl(); X#endif IRIS_4D X Xjmp_buf dopanel_return; Xint pnl_winmouse; XBoolean pnl_shiftkey_save; XBoolean pnl_controlkey_save; X XPanel X*mkpanel() X{ X Panel *p; X int winsave=winget(); X X p=(Panel *)alloc(sizeof(Panel)); X X if (pnl_pl) p->next=pnl_pl; X else p->next=NULL; X pnl_pl=p; X X pnl_table[pnl_id]=(char *)p; X p->id=pnl_id++; X p->al=NULL; X p->lastgroup=NULL; X p->active=FALSE; X p->gid= -1; X p->usergid=winget(); X p->label=NULL; X p->enabled=TRUE; X p->fixfunc=_fixpnl; X p->drawfunc=_drawpnl; X p->downfunc=NULL; X p->activefunc=NULL; X p->upfunc=NULL; X p->dirtycnt=2; X X /* if user touches these, we won't make our X own guesses for them in dopanel() */ X p->x=p->y=p->w=p->h=0; X X p->ppu=PNL_PIXELS_PER_UNIT; X X p->vobj=genobj(); X makeobj(p->vobj); X maketag(1); X ortho2(0.0,10.0,0.0,10.0); /* placeholder viewing transform */ X closeobj(); X X winset(winsave); X return p; X} X X XActuator X*mkact(initfunc) Xvoid (* initfunc)(); X{ XActuator *a; X X a=(Actuator *)alloc(sizeof(Actuator)); X X pnl_table[pnl_id]=(char *)a; X a->id=pnl_id++; X a->active=FALSE; X a->key=NULLDEV; X a->label=NULL; X a->labeltype=PNL_LABEL_BOTTOM; X a->addfunc=NULL; X a->fixfunc=NULL; X a->pickfunc=_hitact; X a->dumpfunc=_dumpact; X a->loadfunc=_loadact; X a->newvalfunc=NULL; X a->downfunc=NULL; X a->activefunc=NULL; X a->upfunc=NULL; X a->group=a; X a->automatic=FALSE; X a->selectable=TRUE; X a->visible=TRUE; X a->next=NULL; X a->w=0.0; X a->h=0.0; X a->minval=0.0; X a->maxval=1.0; X a->val=0.0; X X if (initfunc) (* initfunc)(a); X X return a; X} X XActuator X*_mkuseract(size, initfunc) Xint size; X#ifdef IRIS_4D Xvoid (* initfunc)(Actuator *); X#else IRIS_4D Xvoid (* initfunc)(); X#endif IRIS_4D X{ X Actuator *temp = (Actuator *) alloc (size); X if (sizep=p; X X a->next=p->al; X p->al=a; X X a->initval=a->val; /* save for later resets */ X X if (a->label) { X a->lw=(float)strwidth(a->label)/p->ppu; X a->lh=(float)getheight()/p->ppu; X a->ld=(float)getdescender()/p->ppu; X } X X if (a->addfunc) (*a->addfunc)(a, p); X X if (a->automatic) { X Alist *al=(Alist *)alloc(sizeof(Alist)); X al->a=a; X al->next=p->autolist; X p->autolist=al; X } X X if (a->key!=NULLDEV) { X Alist *al=(Alist *)alloc(sizeof(Alist)); X al->a=a; X al->next=pnl_kl; X pnl_kl=al; X X qdevice(a->key); X } X X a->dirtycnt=2; X} X Xvoid Xaddtogroup(a, p) XActuator *a; XPanel *p; X{ X if (!p->lastgroup) p->lastgroup=a; X a->group=p->lastgroup->group; X p->lastgroup->group=a; X} X Xvoid Xendgroup(p) XPanel *p; X{ X p->lastgroup=NULL; X} X Xvoid Xfixpanel(p) XPanel *p; X{ X if (p&&p->fixfunc) { X (*p->fixfunc)(p); X } X p->dirtycnt = 2; X} X Xvoid Xfixact(a) XActuator *a; X{ X if (a&&a->fixfunc) { X (*a->fixfunc)(a); X } X a->dirtycnt = 2; X} X Xvoid Xlabeloffsets(a) XActuator *a; X{ X switch (a->labeltype) { X case PNL_LABEL_NORMAL: X a->lx=0.0; X a->ly=0.0; X break; X case PNL_LABEL_CENTER: X a->lx=0.5*(a->w-a->lw); X a->ly=0.5*(a->h-a->lh); X break; X case PNL_LABEL_BOTTOM: X a->lx=0.5*(a->w-a->lw); X a->ly= -(a->lh+PNL_DIM_2); X break; X case PNL_LABEL_RIGHT: X a->lx=a->w+PNL_DIM_2; X a->ly=0.5*(a->h-a->lh); X break; X case PNL_LABEL_LEFT: X a->lx= -(a->lw+PNL_DIM_2); X a->ly=0.5*(a->h-a->lh); X break; X case PNL_LABEL_TOP: X a->lx=0.5*(a->w-a->lw); X a->ly=a->h+PNL_DIM_2; X break; X default: X printf("unknown label type %d\n", a->labeltype); X exit(1); X } X} X Xvoid Xpanellimits(p) XPanel *p; X{ XActuator *a; Xfloat bx, by, bw, bh; X X p->minx=100000.0; X p->miny=100000.0; X p->maxx= -100000.0; X p->maxy= -100000.0; X X for (a=p->al;a;a=a->next) { X X if (!a->visible) continue; X X bx=a->x; X by=a->y; X bw=a->w; X bh=a->h; /* bounding box */ X X if (a->label) { X X labeloffsets(a); X X bx=MIN(a->x,a->x+a->lx); X by=MIN(a->y,a->y+a->ly); X bw=a->w+MAX(0.0,-a->lx)+MAX(0.0,a->lx+a->lw-a->w); X bh=a->h+MAX(0.0,-a->ly)+MAX(0.0,a->ly+a->lh-a->h); X } X X p->minx=MIN(p->minx, bx); X p->maxx=MAX(p->maxx, bx+bw); X p->miny=MIN(p->miny, by); X p->maxy=MAX(p->maxy, by+bh); X } X p->minx-=PNL_MARGIN; X p->maxx+=PNL_MARGIN; X p->miny-=PNL_MARGIN; X p->maxy+=PNL_MARGIN; X} X Xreshapepanel(p) XPanel *p; X{ Xfloat w,h; X X winset(p->gid); X getorigin(&p->x,&p->y); X getsize(&p->w, &p->h); X reshapeviewport(); X panellimits(p); X X if ((p->maxx-p->minx)/(p->maxy-p->miny) X >(float)p->w/(float)p->h) { X w=(p->maxx-p->minx); X h=(float)p->h/(float)p->w*w; X p->ppu=(float)p->w/w; X } else { X h=(p->maxy-p->miny); X w=(float)p->w/(float)p->h*h; X p->ppu=(float)p->h/h; X } X X editobj(p->vobj); X objreplace(1); X ortho2(p->minx,p->minx+w,p->miny,p->miny+h); X closeobj(); X callobj(p->vobj); X X p->dirtycnt=2; X} X Xpnl_initpanel(p) XPanel *p; X{ X static long ux, uy, uh, uw, dx=0; X long lx, ly; X Scoord tbh; X Boolean no_user_port=FALSE; X X panellimits(p); X X if (!(p->h&&p->w)) { X p->h=p->ppu*(p->maxy-p->miny); X p->w=p->ppu*(p->maxx-p->minx); X } X X /* panel position defaults */ X X if (p->label) tbh=PNL_TITLE_BAR_HEIGHT; X else tbh=0.0; X if (!(p->x&&p->y)) { X if (!(pnl_ox&&pnl_oy)) { X int tmp=winget(); X X winset(p->usergid); X getorigin(&ux,&uy); X getsize(&uw,&uh); X if (uw&&uh) { X p->x=ux+uw+PNL_SCREEN_BORDER; X p->y=uy+uh-p->h; X winset(tmp); X } else X /* if no user window, do a */ X /* prefsize instead of a prefposition */ X no_user_port=TRUE; X } else { X p->x=pnl_ox; X p->y=pnl_oy-p->h-PNL_SCREEN_BORDER-tbh; X if (p->y<0) { /* off bottom of screen */ X p->x+=dx; X p->y=uy+uh-p->h; X dx=0; X } X if (p->x+p->w>XMAXSCREEN) { /* off right edge of screen */ X ux+=PNL_TITLE_BAR_HEIGHT; X uy-=PNL_TITLE_BAR_HEIGHT; X p->x=ux+uw+PNL_SCREEN_BORDER; X p->y=uy+uh-p->h; X } X } X } X dx=MAX(dx, p->w+PNL_SCREEN_BORDER); X pnl_ox=p->x; X pnl_oy=p->y; X X if (no_user_port) prefsize(p->w, p->h); X else prefposition(p->x,p->x+p->w,p->y,p->y+p->h); X#ifdef IRIS_NEWS X if (!p->label) noborder(); X#endif IRIS_NEWS X X if (p->label) X p->gid=winopen(p->label); X else X p->gid=winopen("control panel"); X X if (no_user_port) { X getorigin(&lx, &ly); X p->x=lx; X p->y=ly; X } X X#ifdef IRIS_NEWS X qenter(REDRAW, p->gid); X qenter(INPUTCHANGE, p->gid); X#endif IRIS_NEWS X winconstraints(); X winconstraints(); X keepaspect(p->w,p->h); X winconstraints(); X X#ifdef IRIS_4D X doublebuffer(); X gconfig(); X#endif IRIS_4D X X reshapepanel(p); X if (p->label) wintitle(p->label); X} X Xvoid Xneedredraw() X{ X pnl_saveuserredraw=TRUE; X} X Xshort Xuserredraw() X{ XPanel *p; XDevice dev; Xshort data; X X if (qtest()==REDRAW) { X dev=qread(&data); X for (p=pnl_pl;p&&!(p->gid==data);p=p->next); X if (!p) { X#ifdef DEBUG Xprintf("userredraw consuming a REDRAW for mex window %d\n",data); X#endif DEBUG X return data; X } else { X#ifdef DEBUG Xprintf("userredraw requeueing a REDRAW for panel %s\n",p->label); X#endif DEBUG X qenter(dev,data); X return 0; X } X } else return 0; X} X Xvoid init() X{ X Panel *p; X X for (p=pnl_pl;p;p=p->next) pnl_initpanel(p); X X qdevice(LEFTMOUSE); X tie(LEFTMOUSE, MOUSEX, MOUSEY); X qdevice(LEFTSHIFTKEY); X qdevice(RIGHTSHIFTKEY); X#ifdef IRIS_4D X qdevice(LEFTCTRLKEY); X qdevice(RIGHTCTRLKEY); X#else IRIS_4D X qdevice(CTRLKEY); X#endif IRIS_4D X#ifdef IRIS_NEWS X qdevice(WINFREEZE); /* allows app to run when panels are collapsed */ X qdevice(WINTHAW); X#endif IRIS_NEWS X X pnl_virgin=FALSE; X} X Xputactiontoscript() /* format could be compressed */ X{ X static int lastframe=0; X static int msgtype_delay=PNL_MT_DELAY; X static int msgtype_mouse=PNL_MT_MOUSE; X static int buf[9]; X X if (pnl_frame>1) { X if (pnl_delayvirgin) { pnl_delayvirgin--; } /* skip first two delays */ X else if ((write(pnl_scriptoutfd, X &msgtype_delay, X sizeof(msgtype_delay))!=sizeof(msgtype_delay)) X || (write(pnl_scriptoutfd, X &pnl_frame, X sizeof(pnl_frame))!=sizeof(pnl_frame))) { X perror(pnl_scriptoutfile); X pnl_writescript=FALSE; X return FALSE; X } X } X pnl_frame=0; X X buf[0]=(int)pnl_cp->id; X buf[1]=(int)pnl_ca->id; X buf[2]=(int)pnl_mx-pnl_cp->x; /* the ultimate would be in world space */ X buf[3]=(int)pnl_my-pnl_cp->y; X buf[4]=(int)pnl_justup; X buf[5]=(int)pnl_justdown; X buf[6]=(int)pnl_mousedown; X buf[7]=(int)pnl_shiftkey; X buf[8]=(int)pnl_controlkey; X X if ((write(pnl_scriptoutfd, X &msgtype_mouse, X sizeof(msgtype_mouse))!=sizeof(msgtype_mouse)) X ||(write(pnl_scriptoutfd,buf,sizeof(buf))!=sizeof(buf))) { X perror(pnl_scriptoutfile); X pnl_writescript=FALSE; X return FALSE; X } X X#ifdef DEBUG X fprintf(stderr,"X"); X#endif DEBUG X return TRUE; X} X XBoolean Xpnl_beginreadscript(name) Xchar *name; X{ X if (pnl_writescript) return FALSE; X if (strcmp(name, pnl_scriptinfile)||!pnl_scriptinfd) { X if (pnl_scriptinfd) close(pnl_scriptinfd); X if (0>(pnl_scriptinfd=open(pnl_scriptinfile,O_RDONLY))) { X perror(pnl_scriptinfile); X return FALSE; X } X strcpy(pnl_scriptinfile, name); X } X lseek(pnl_scriptinfd, 0, 0); X pnl_readscript=TRUE; X} X XBoolean Xpnl_beginwritescript(name) Xchar *name; X{ X if (pnl_readscript) return FALSE; X if (strcmp(name, pnl_scriptoutfile)||!pnl_scriptoutfd) { X if (pnl_scriptoutfd) close(pnl_scriptoutfd); X/* if (0>(pnl_scriptoutfd=open(pnl_scriptoutfile, X O_WRONLY||O_APPEND||O_CREAT))) { */ X if (0>(pnl_scriptoutfd=creat(pnl_scriptoutfile,0777))) { X perror(pnl_scriptoutfile); X return FALSE; X } X strcpy(pnl_scriptoutfile, name); X } X pnl_writescript=TRUE; X pnl_delayvirgin=2; X} X XBoolean Xpnl_beginappendscript(name) Xchar *name; X{ X int c; X X if (pnl_readscript) return FALSE; X if (strcmp(name, pnl_scriptoutfile)||!pnl_scriptoutfd) { X if (pnl_scriptoutfd) close(pnl_scriptoutfd); X if (0>(pnl_scriptoutfd=open(pnl_scriptoutfile, X O_WRONLY||O_APPEND))) { X perror(pnl_scriptoutfile); X return FALSE; X } X strcpy(pnl_scriptoutfile, name); X } X if (!strcmp(pnl_scriptinfile,pnl_scriptoutfile)&&pnl_scriptinfd) { X c=lseek(pnl_scriptinfd, 0, 1); X lseek(pnl_scriptoutfd,c); X } else X lseek(pnl_scriptoutfd, 0, 2); X pnl_writescript=TRUE; X} X Xvoid Xpnl_endreadscript() X{ X/*if (pnl_scriptinfd) close(pnl_scriptinfd); */ X pnl_readscript=FALSE; X} X Xvoid Xpnl_endwritescript() X{ X if (pnl_scriptoutfd) { X close(pnl_scriptoutfd); X pnl_scriptoutfd=0; X } X pnl_writescript=FALSE; X} X XBoolean Xalt() X{ X static Boolean state; X X return state=!state; X} X Xvoid Xdumpstate() X{ XPanel *p; XActuator *a; X X if (pnl_readscript) return; X if (!pnl_scriptoutfd) pnl_beginwritescript("panel.script"); X if (!pnl_scriptoutfd) { X fprintf(stderr, "Can't write script file\n"); X return; X } X X for (p=pnl_pl;p;p=p->next) X for (a=p->al;a;a=a->next) X (a->dumpfunc)(a, pnl_scriptoutfd); X X} X Xvoid Xgetnewactive(ca,cp,mx,my) X Actuator **ca; X Panel **cp; X Screencoord mx, my; X{ X Panel *p=NULL; X Actuator *a=NULL; X X#ifndef IRIS_NEWS X#ifdef IRIS_4D X pnl_winmouse=gl_winat(mx,my); X#else IRIS_4D X pnl_winmouse=winat(mx,my); X#endif IRIS_4D X#endif IRIS_NEWS X for (p=pnl_pl;p;p=p->next) X if (pnl_winmouse==p->gid) break; X X#ifdef DEBUG X if (p) printf("a hit on panel %s\n", p->label); X else printf("a mousedown on mex window %d missed all panels\n", pnl_winmouse); X#endif DEBUG X X if (p) { X p->active=TRUE; X if ((a=pickact(p,mx,my))&&a->selectable) { X X#ifdef DEBUG X printf("picked %s\n", a->label); X#endif DEBUG X X a->active=TRUE; X a->dirtycnt=2; X } else { /* hit background */ X winset(p->gid); X winpop(); X } X } else { /* special case, mouse actuator active outside all panels */ X if (pnl_mouse_act&&pnl_mouse_act->selectable) { X#ifdef DEBUG X printf("picked the mouse actuator\n"); X#endif DEBUG X p=pnl_pl; /* set current panel to be non-null */ X p->active=TRUE; X a=pnl_mouse_act; X a->active=TRUE; X } X } X *cp=p; X *ca=a; X} X Xvoid Xdofuncs(a,p) XActuator *a; XPanel *p; X{ X if (pnl_justdown) { X if (p&&a&&a->downfunc) { X winset(p->usergid); X (*a->downfunc)(a); X winset(p->gid); X } X if (p&&p->downfunc) { X winset(p->usergid); X (*p->downfunc)(p); X winset(p->gid); X } X } X if (p&&a&&a->active&&a->activefunc) { X winset(p->usergid); X (*a->activefunc)(a); X winset(p->gid); X } X if (p&&p->active&&p->activefunc) { X winset(p->usergid); X (*p->activefunc)(p); X winset(p->gid); X } X if (pnl_justup) { X if (p&&a&&a->upfunc) { X winset(p->usergid); X (*a->upfunc)(a); X winset(p->gid); X } X if (p&&p->upfunc) { X winset(p->usergid); X (*p->upfunc)(p); X winset(p->gid); X } X } X} X Xsetinactive(a,p) XActuator *a; XPanel *p; X{ X if (p) p->active=FALSE; X if (a) { X X#ifdef DEBUG X printf("unpicked %s\n", a->label); X#endif DEBUG X X a->active=FALSE; X a->dirtycnt=2; X } X} X Xvoid Xdoautos(p,mx,my) XPanel *p; XScreencoord mx,my; X{ XAlist *e; XScreencoord sx=mx-p->x, sy=my-p->y; X X for (e=p->autolist;e;e=e->next){ X if (e->a->automatic) (*e->a->newvalfunc)(e->a,p,sx,sy); X } X} X XBoolean Xgetactionfromqueue() X{ X Panel *p=NULL; X Device dev; X short data; X Alist *e; X X pnl_ca=pnl_ca_save; X pnl_cp=pnl_cp_save; X if (pnl_ca) pnl_ca->active=pnl_ca_active_save; X if (pnl_cp) pnl_cp->active=pnl_cp_active_save; X pnl_shiftkey=pnl_shiftkey_save; X pnl_controlkey=pnl_controlkey_save; X X pnl_justup=pnl_justdown=FALSE; X redo: X if (qtest()) { X dev=qread(&data); X switch(dev) { X#ifdef IRIS_NEWS X case INPUTCHANGE: X pnl_winmouse=data; X goto redo; X#endif IRIS_NEWS X case PNL_TOKEN: X#ifdef DEBUG X printf("consumed a PNL_TOKEN, dopanel returning\n"); X#endif DEBUG X#ifdef IRIS_4D X longjmp(dopanel_return,TRUE); X#else IRIS_4D X break; /* mustn't get out of sync on 3030's */ X#endif IRIS_4D X case REDRAW: X for (p=pnl_pl;p;p=p->next) { X if (p->gid==data) { X reshapepanel(p); X break; X } X } X /* this redraw must not be for a panel, requeue it here */ X if (!p&&pnl_saveuserredraw) { X#ifdef DEBUG X printf("enqueing a PNL_TOKEN\n"); X#endif DEBUG X qenter(PNL_TOKEN); X qenter(dev,data); X } X break; X case LEFTMOUSE: X pnl_mousedown=data; X pnl_justdown=pnl_mousedown; X pnl_justup=!pnl_mousedown; X dev=qread(&data); pnl_mx=data; X dev=qread(&data); pnl_my=data; X break; X case LEFTSHIFTKEY: X case RIGHTSHIFTKEY: X pnl_shiftkey=data; X break; X#ifdef IRIS_4D X case LEFTCTRLKEY: X case RIGHTCTRLKEY: X#else IRIS_4D X case CTRLKEY: X#endif IRIS_4D X pnl_controlkey=data; X break; X default: X /* check for key equivalents */ X for (e=pnl_kl;e;e=e->next) X if (e->a->key==dev) break; X if (e) { X pnl_mousedown=data; X pnl_justdown=pnl_mousedown; X pnl_justup=!pnl_mousedown; X X if (!pnl_justdown&&!pnl_justup&&pnl_cp) { X pnl_mx=getvaluator(MOUSEX); X pnl_my=getvaluator(MOUSEY); X } X X pnl_ca=e->a; X pnl_cp=e->a->p; X goto end; X } X break; X } X } X X if (!pnl_justdown&&!pnl_justup&&pnl_cp) { X pnl_mx=getvaluator(MOUSEX); X pnl_my=getvaluator(MOUSEY); X } X X if (pnl_justdown) getnewactive(&pnl_ca,&pnl_cp,pnl_mx,pnl_my); X if (pnl_justup) setinactive(pnl_ca,pnl_cp); X X end: X pnl_ca_save=pnl_ca; X pnl_cp_save=pnl_cp; X if (pnl_ca) pnl_ca_active_save=pnl_ca->active; X if (pnl_cp) pnl_cp_active_save=pnl_cp->active; X pnl_shiftkey_save=pnl_shiftkey; X pnl_controlkey_save=pnl_controlkey; X X pnl_action_source=PNL_SRC_QUEUE; X} X Xgetactionfromscript() X { X int c, msgtype; X short actid; X static int buf[9]; X X pnl_justup=pnl_justdown=FALSE; X X if (pnl_delay>pnl_frame) return FALSE; X X more: X pnl_cp=NULL; X pnl_ca=NULL; X X if ((c=read(pnl_scriptinfd,&msgtype,sizeof(msgtype)))!=sizeof(msgtype)) { X#ifdef DEBUG X fprintf(stderr, "end of script on read\n"); X#endif DEBUG X pnl_readscript=FALSE; X return FALSE; X } X X switch (msgtype) { X case PNL_MT_MOUSE: X if ((c=read(pnl_scriptinfd,buf,sizeof(buf)))!=sizeof(buf)) { X#ifdef DEBUG X fprintf(stderr, "end of script on read\n"); X#endif DEBUG X pnl_readscript=FALSE; X return FALSE; X } X X if ( buf[0]<0 X ||buf[0]>=pnl_id X ||buf[1]<0 X ||buf[1]>=pnl_id) { X fprintf(stderr,"libpanel: bad actuator index in script file.\n"); X pnl_readscript=FALSE; X return FALSE; X } X X /* throw away script events for actuator the user is mousing */ X if ((Actuator *)pnl_table[buf[1]]==pnl_ca_save) return FALSE; X X pnl_cp=(Panel *)pnl_table[buf[0]]; X pnl_ca=(Actuator *)pnl_table[buf[1]]; X pnl_mx=(Screencoord)buf[2]+pnl_cp->x; X pnl_my=(Screencoord)buf[3]+pnl_cp->y; X pnl_justup=(Boolean)buf[4]; X pnl_justdown=(Boolean)buf[5]; X pnl_mousedown=(Boolean)buf[6]; X pnl_shiftkey=(Boolean)buf[7]; X pnl_controlkey=(Boolean)buf[8]; X X pnl_cp->active=pnl_ca->active=pnl_mousedown; X if (!pnl_mousedown) fixact(pnl_ca); X X pnl_action_source=PNL_SRC_SCRIPT; X return TRUE; X case PNL_MT_STATE: X if ((c=read(pnl_scriptinfd,&actid,sizeof(actid)))!=sizeof(actid)) { X#ifdef DEBUG X fprintf(stderr, "end of script on read\n"); X#endif DEBUG X pnl_readscript=FALSE; X return FALSE; X } X if ( actid<0 X ||actid>=pnl_id) { X fprintf(stderr, "libpanel: bad actuator identifier in script file.\n"); X pnl_readscript=FALSE; X return FALSE; X } X (*(((Actuator *)pnl_table[actid])->loadfunc)) X (pnl_table[actid], pnl_scriptinfd); X fixact((Actuator *)pnl_table[actid]); X goto more; X break; X case PNL_MT_DELAY: X if ((c=read(pnl_scriptinfd, X &pnl_delay, X sizeof(pnl_delay)))!=sizeof(pnl_delay)) { X#ifdef DEBUG X fprintf(stderr, "end of script on read\n"); X#endif DEBUG X pnl_readscript=FALSE; X return FALSE; X } X pnl_frame=0; X break; X default: X fprintf(stderr, "libpanel: unrecognized message type in script file\n"); X return FALSE; X } X} X Xgetaction() X{ X if (pnl_readscript) { X if (qtest()) X getactionfromqueue(); X else if (pnl_ca_save&&pnl_ca_save->active) { X if (alt()) X getactionfromqueue(); X else X if (!getactionfromscript()) getactionfromqueue(); X } else X getactionfromscript(); X } else getactionfromqueue(); X} X XActuator X*dopanel() X{ X Actuator *a=NULL; X Panel *p=NULL; X int winsave=winget(); X X if (setjmp(dopanel_return)) goto return_from_dopanel; X if (pnl_virgin) init(); X X redo: X X pnl_frame++; X getaction(); X X if (pnl_cp) pnl_cp->a=pnl_ca; X X if (pnl_cp&&pnl_ca&&pnl_ca->newvalfunc) { X winset(pnl_cp->gid); X (*pnl_ca->newvalfunc)(pnl_ca,pnl_cp,pnl_mx-pnl_cp->x,pnl_my-pnl_cp->y); X pnl_ca->dirtycnt=2; X } X X for (p=pnl_pl;p;p=p->next) doautos(p,pnl_mx,pnl_my); X for (p=pnl_pl;p;p=p->next) (*p->drawfunc)(p); X dofuncs(pnl_ca,pnl_cp); X X if (pnl_cp&&pnl_ca&&pnl_writescript) putactiontoscript(); X X if (pnl_cp&&!pnl_cp->active) { X pnl_cp=NULL; X if (pnl_action_source==PNL_SRC_QUEUE) { X pnl_cp_save=NULL; X } X } X if (pnl_ca&&!pnl_ca->active) { X pnl_ca=NULL; X if (pnl_action_source==PNL_SRC_QUEUE) pnl_ca_save=NULL; X } X X#ifdef IRIS_4D X /* no retries on 3030's so the user can swapbuffers */ X X if (qtest()==REDRAW) { /* someone left to redraw? */ X goto redo; X } X X if (pnl_justup) goto redo; /* any mousedowns left in that queue? */ X X#endif IRIS_4D X Xreturn_from_dopanel: X if (winsave!=winget()) winset(winsave); X return pnl_ca; X} X X/* X * drawpanel- X * X * this routine draws all actuators on every panel, which may be X * a bit of overkill. It also does not decrement the panel's X * dirtycnt so a later dopanel may draw them again. X * X */ X Xvoid Xdrawpanel() /* user routine to update all panels */ X{ XPanel *p; X X int winsave=winget(); X X if (pnl_virgin) { X dopanel(); X return; X } X X for (p=pnl_pl;p;p=p->next) { X p->dirtycnt++; X (*p->drawfunc)(p); X } X X winset(winsave); X return; X} X X#ifdef 0 XActuator X*pickact(p,mx,my) XPanel *p; XScreencoord mx, my; X{ Xshort buf[10]; Xint i, n; XActuator *a; XScreencoord savex, savey; X X picking=TRUE; X winset(p->gid); X X savex=getvaluator(MOUSEX); X savey=getvaluator(MOUSEY); X setvaluator(MOUSEX,mx,0,XMAXSCREEN); X setvaluator(MOUSEY,my,0,YMAXSCREEN); X X buf[1]=0; X picksize(1,1); X X pushmatrix(); X pick(buf, 9); X callobj(p->vobj); X X initnames(); X for (i=1,a=p->al;a;i++,a=a->next) { X loadname((short)i); X (*a->drawfunc)(a, p); X } X n=endpick(buf); X popmatrix(); X X setvaluator(MOUSEX,savex,0,XMAXSCREEN); X setvaluator(MOUSEY,savey,0,YMAXSCREEN); X X if (n<1) return NULL; X for (i=1,a=p->al;inext); X X picking=FALSE; X return a; X} X#endif X XActuator X*pickact(p,mx,my) XPanel *p; XScreencoord mx, my; X{ Xint i, n; XActuator *a; XScreencoord sx,sy; XCoord wx, wy; X X winset(p->gid); X sx=mx-p->x, sy=my-p->y; X mapw2(p->vobj,sx,sy,&wx,&wy); X X for (i=1,a=p->al;a;i++,a=a->next) { X if ((*a->pickfunc)(a,p,wx,wy)) break; X } X X return a; X} X XBoolean X_hitact(a,p,x,y) XActuator *a; XPanel *p; XCoord x,y; X{ X return PNL_HITACT(a,x,y); X} X Xvoid X_dumpact(a, fd) XActuator *a; Xint fd; X{ Xstatic int msgtype=PNL_MT_STATE; X X write(fd, &msgtype, sizeof(msgtype)); X write(fd, &a->id, sizeof(a->id)); X write(fd, a, sizeof(Actuator)); X write(fd, &a->datasize, sizeof(int)); X write(fd, a->data, a->datasize); X} X Xvoid X_loadact(a, fd) XActuator *a; Xint fd; X{ Xint c; X if (a->label) fprintf(stderr, "loading actuator %s, ", a->label); X c=read(fd, a, sizeof(Actuator)); X#ifdef DEBUG X fprintf(stderr, "read %d bytes, ", c); X#endif DEBUG X c=read(fd, &a->datasize, sizeof(int)); X#ifdef DEBUG fprintf(stderr, "read %d bytes, ", c); X if (a->datasize) { X#endif DEBUG X c=read(fd, a->data, a->datasize); X#ifdef DEBUG X fprintf(stderr, "read %d bytes\n", c); X#endif DEBUG X } X#ifdef DEBUG X else fprintf(stderr,"\n"); X} X#endif DEBUG X Xvoid X_fixpnl(p) XPanel *p; X{ X long x, y, w, h; X int winsave=winget(); X X winset(p->gid); X X getorigin(&x, &y); X getsize(&w, &h); X if ( p->x!=x X ||p->y!=y X ||p->w!=w X ||p->h!=h) { /* user reset size or location */ X winconstraints(); X winposition(p->x, p->x+p->w, p->y, p->y+p->h); X } else { /* maybe just made a new actuator */ X panellimits(p); X w=p->ppu*(p->maxx-p->minx); X h=p->ppu*(p->maxy-p->miny); X if ( ABS(p->w-w)>1 X ||ABS(p->h-h)>1) { X winconstraints(); X winposition(x, x+w, y, y+h); X p->x=x; p->y=y; p->w=w; p->h=h; X } X } X X keepaspect(p->w,p->h); X winconstraints(); X reshapepanel(p); X X winset(winsave); X} X X Xvoid X_drawpnl(p) XPanel *p; X{ Xint i; XActuator *a; XBoolean drewsomething=FALSE; X X if (p->dirtycnt) { X drewsomething=TRUE; X winset(p->gid); X#ifdef DEBUG Xprintf("drawing panel %s\n", p->label); X#endif DEBUG X p->dirtycnt--; X color(pnl_background_color); X clear(); X for (i=0,a=p->al;a;i++,a=a->next) { X if (a->visible&&a->drawfunc) (*a->drawfunc)(a, p); X } X } X X for (i=0,a=p->al;a;i++,a=a->next) { X if (a->dirtycnt) { X drewsomething=TRUE; X winset(p->gid); X#ifdef DEBUG Xprintf("drawing actuator %s with value of %g\n", a->label, a->val); X#endif DEBUG X if (a->visible&&a->drawfunc) (*a->drawfunc)(a, p); X a->dirtycnt--; X } X } X X#ifdef IRIS_4D X if (drewsomething) swapbuffers(); X#endif IRIS_4D X X} X Xdrawlabel(a, p) XActuator *a; XPanel *p; X{ X color(pnl_background_color); X rectf(a->x+a->lx,a->y+a->ly, X a->x+a->lx+a->lw,a->y+a->ly+a->lh); X if (p->ppu>pnl_char_threshold) { X color(pnl_outline_color); X cmov2(a->x+a->lx,a->y+a->ly+a->ld); X charstr(a->label); X } else { X color(pnl_normal_color); X rectf(a->x+a->lx,a->y+a->ly, X a->x+a->lx+a->lw, X a->y+a->ly+a->lh); X } X#ifdef 0 X color(pnl_highlight_color); X cmov2(a->x+a->lx,a->y+a->ly+a->ld); X charstr(a->label); X rect(a->x+a->lx,a->y+a->ly, X a->x+a->lx+a->lw, X a->y+a->ly+a->lh); X#endif X} X X#ifdef 0 XBoolean Xdumppanel() X{ XPanel *p; XActuator *a; XFILE *dumpfile; X X if (!(dumpfile=fopen("panel.txt","w"))) { X perror("panel.txt"); X return FALSE; X } X for (p=pnl_pl;p;p=p->next) { X if (p->label) fprintf(dumpfile, "panel: %-24s",p->label); X else fprintf(dumpfile, "panel: (NULL) "); X fprintf(dumpfile, "x: %-4d ", p->x); X fprintf(dumpfile, "y: %-4d ", p->y); X fprintf(dumpfile, "w: %-4d ", p->w); X fprintf(dumpfile, "h: %-4d\n", p->h); X for (a=p->al;a;a=a->next) { X if (a->label) fprintf(dumpfile, " actuator: %-19s", a->label); X else fprintf(dumpfile, " actuator: (NULL) "); X fprintf(dumpfile, "x: %-5g ", a->x); X fprintf(dumpfile, "y: %-5g ", a->y); X fprintf(dumpfile, "w: %-5g ", a->w); X fprintf(dumpfile, "h: %-5g\n", a->h); X } X } X fclose(dumpfile); X return TRUE; X} X#endif 0 X X#define FP fprintf X#define DF dumpfile X XBoolean Xdumppanel() X{ X Panel *p; X Actuator *a; X FILE *dumpfile; X Boolean ingroup; X X if (!(dumpfile=fopen("panel.txt","w"))) { X perror("panel.txt"); X return FALSE; X } X X for (p=pnl_pl;p;p=p->next) { X FP(DF, " p=mkpanel();\n"); X FP(DF, " /* p->id=%d; */\n", p->id); X FP(DF, " /* p->a=0x%x; */\n", p->a); X FP(DF, " /* p->al=0x%x; */\n", p->al); X FP(DF, " /* p->autolist=0x%x; */\n", p->autolist); X FP(DF, " /* p->lastgroup=0x%x; */\n", p->lastgroup); X FP(DF, " /* p->active=%s; */\n", (p->active?"TRUE":"FALSE")); X FP(DF, " p->enabled=%s;\n",(p->enabled?"TRUE":"FALSE")); X FP(DF, " p->x=%d;\n", p->x); X FP(DF, " p->y=%d;\n", p->y); X FP(DF, " p->w=%d;\n", p->w); X FP(DF, " p->h=%d;\n", p->h); X FP(DF, " /* p->minx=%f; */\n", p->minx); X FP(DF, " /* p->maxx=%f; */\n", p->maxx); X FP(DF, " /* p->miny=%f; */\n", p->miny); X FP(DF, " /* p->maxy=%f; */\n", p->maxy); X FP(DF, " /* p->cw=%f; */\n", p->cw); X FP(DF, " /* p->ch=%f; */\n", p->ch); X FP(DF, " /* p->gid=%d; */\n", p->gid); X FP(DF, " /* p->usergid=%d; */\n", p->usergid); X FP(DF, " /* p->vobj=%d; */\n", p->vobj); X FP(DF, " p->ppu=%f;\n", p->ppu); X FP(DF, " p->label=\"%s\";\n", (p->label?p->label:"NULL")); X FP(DF, " /* p->fixfunc=0x%x; */\n", p->fixfunc); X FP(DF, " /* p->drawfunc=0x%x; */\n", p->drawfunc); X FP(DF, " /* p->downfunc=0x%x; */\n", p->downfunc); X FP(DF, " /* p->activefunc=0x%x; */\n", p->activefunc); X FP(DF, " /* p->upfunc=0x%x; */\n", p->upfunc); X FP(DF, " /* p->dirtycnt=%d; */\n", p->dirtycnt); X FP(DF, " /* p->next=0x%x; */\n", p->next); X FP(DF, "\n"); X X for (a=p->al;a;a=a->next) { X FP(DF, " /* a->id=%d; */\n", a->id); X FP(DF, " /* a->type=%d; */\n", a->type); X FP(DF, " /* a->active=%s; */\n", (a->active?"TRUE":"FALSE")); X FP(DF, " a->x=%f;\n", a->x); X FP(DF, " a->y=%f;\n", a->y); X FP(DF, " a->w=%f;\n", a->w); X FP(DF, " a->h=%f;\n", a->h); X FP(DF, " a->lx=%f;\n", a->lx); X FP(DF, " a->ly=%f;\n", a->ly); X FP(DF, " a->lw=%f;\n", a->lw); X FP(DF, " a->lh=%f;\n", a->lh); X FP(DF, " a->ld=%f;\n", a->ld); X FP(DF, " a->val=%f;\n", a->val); X FP(DF, " a->initval=%f;\n", a->initval); X FP(DF, " a->maxval=%f;\n", a->maxval); X FP(DF, " a->minval=%f;\n", a->minval); X FP(DF, " a->label=\"%s\";\n", (a->label?a->label:"NULL")); X FP(DF, " a->key=%d;\n", a->key); X FP(DF, " a->labeltype=%d;\n", a->labeltype); X FP(DF, " /* a->addfunc=0x%x; */\n", a->addfunc); X FP(DF, " /* a->fixfunc=0x%x; */\n", a->fixfunc); X FP(DF, " /* a->pickfunc=0x%x; */\n", a->pickfunc); X FP(DF, " /* a->newvalfunc=0x%x; */\n", a->newvalfunc); X FP(DF, " /* a->dumpfunc=0x%x; */\n", a->dumpfunc); X FP(DF, " /* a->loadfunc=0x%x; */\n", a->loadfunc); X FP(DF, " /* a->drawfunc=0x%x; */\n", a->drawfunc); X FP(DF, " /* a->downfunc=0x%x; */\n", a->downfunc); X FP(DF, " /* a->activefunc=0x%x; */\n", a->activefunc); X FP(DF, " /* a->upfunc=0x%x; */\n", a->upfunc); X FP(DF, " /* a->dirtycnt=%d; */\n", a->dirtycnt); X FP(DF, " /* a->u=0x%x; */\n", a->u); X FP(DF, " /* a->data=0x%x; */\n", a->data); X FP(DF, " /* a->datasize=%d; */\n", a->datasize); X FP(DF, " a->automatic=%s;\n", (a->automatic?"TRUE":"FALSE")); X FP(DF, " a->selectable=%s;\n", (a->selectable?"TRUE":"FALSE")); X FP(DF, " a->visible=%s;\n", (a->visible?"TRUE":"FALSE")); X FP(DF, " /* a->group=0x%x; */\n", a->group); X FP(DF, " /* a->next=0x%x; */\n", a->next); SHAR_EOF echo "End of part 4, continue with part 5" echo "5" > s2_seq_.tmp exit 0 ------- Received: from VMB.BRL.MIL by VMB.BRL.MIL id ae01476; 18 Aug 88 17:49 EDT Received: from VMB.BRL.MIL by VMB.brl.MIL id af01422; 18 Aug 88 17:38 EDT Received: from smoke.brl.mil by VMB.BRL.MIL id ac01368; 18 Aug 88 17:28 EDT Received: from orville.nas.nasa.gov by SMOKE.BRL.MIL id aa10094; 18 Aug 88 17:22 EDT Received: Thu, 18 Aug 88 14:21:16 PDT by orville.nas.nasa.gov (5.59/1.2) Date: Thu, 18 Aug 88 14:21:16 PDT From: "David A. Tristram" Message-Id: <8808182121.AA25328@orville.nas.nasa.gov> To: info-iris@BRL.MIL Subject: panel05/06 #!/bin/sh # this is part 5 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file panel.c continued # CurArch=5 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 sed 's/^X//' << 'SHAR_EOF' >> panel.c X FP(DF, " /* a->p=0x%x; */\n", a->p); X FP(DF, " addact(a, p);\n"); X FP(DF, "\n"); X if (!ingroup&&a->group) ingroup=TRUE; X if (!a->group&&ingroup) { X FP(DF, " endgroup();\n"); X ingroup=FALSE; X } X FP(DF, "\n"); X } X } X fclose(dumpfile); X return TRUE; X} X Xchar X*alloc(size) Xint size; X{ Xchar *p; X X if (p=(char *)calloc(1,size)) return p; X else { X perror("calloc"); X exit(1); X } X} X XBoolean Xscreenpnt(wx, wy, wz, sx, sy) /* returns false if pnt is clipped */ XCoord wx, wy, wz; XScreencoord *sx, *sy; X{ Xshort buf[3]; X X feedback(buf, 3); X pnt(wx, wy, wz); X passthrough(0x99); X endfeedback(buf); X if (buf[0]==0x8) { /* passthrough command */ X *sx= *sy=0; X return FALSE; X } else { X *sx=buf[1]; X *sy=buf[2]; X return TRUE; X } X} X SHAR_EOF chmod 0644 panel.c || echo "restore of panel.c fails" sed 's/^X//' << 'SHAR_EOF' > panel.h && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#ifndef PNL_EDITOR_PARSING X#ifndef PNL_EXTERN X#define PNL_EXTERN extern X#endif X#ifndef PNL_INIT X#define PNL_INIT(x) /* nothing */ X#endif X#ifndef FILE X#include X#endif X#ifndef NULL X#define NULL 0 X#endif X#ifndef PI X#define PI 3.14159265358979323846 /* from math.h */ X#endif X#define PNL_RAD_TO_DEG (0.31830988618379067154*180.0) X#define PNL_TABLE_SIZE 4096 /* max number of panels + actuators */ X X#ifndef MAXSGIDEVICE X#define MAXSGIDEVICE 20000 X#endif MAXSGIDEVICE X#define PNL_DEVICE_OFFSET (MAXSGIDEVICE+1) X#define PNL_TOKEN (PNL_DEVICE_OFFSET+0) X X#define PNL_PIXELS_PER_UNIT 50.0 /* used to size the panel */ X#define PNL_CHAR_THRESHOLD 35.0 /* ppu below this, draw chars as rects */ X X#define PNL_CHAR_PIXEL_HEIGHT 10 X#define PNL_CHAR_PIXEL_WIDTH 10 X X#ifdef IRIS_NEWS X# define PNL_SCREEN_BORDER 12 X# define PNL_TITLE_BAR_HEIGHT 19 X#else X# define PNL_SCREEN_BORDER 6 X# define PNL_TITLE_BAR_HEIGHT 18 X#endif X X/* dimensions */ X#define PNL_MARGIN 0.2 /* absolute edge of panel left blank */ X#define PNL_DIM_1 0.2 /* absolute dist tween actuators */ X#define PNL_DIM_2 0.1 /* absolute dist to a label */ X#define PNL_DIM_3 0.05 /* a tiny little distance */ X#define PNL_DIM_4 0.025 /* half of THAT! */ X#define PNL_SLIDER_HEIGHT (6.0-PNL_DIM_1) /* w/o label */ X#define PNL_SLIDER_WIDTH (1.0-PNL_DIM_1) X#define PNL_SLIDER_BAR_HEIGHT (0.05*PNL_SLIDER_HEIGHT) X#define PNL_BUTTON_EDGE (0.5-0.5*PNL_DIM_1) X#define PNL_WIDE_BUTTON_WIDTH (2.0-PNL_DIM_1) X#define PNL_WIDE_BUTTON_HEIGHT PNL_BUTTON_EDGE X#define PNL_TYPEIN_LENGTH 40 /* default length in characters */ X#define PNL_TYPEIN_MAX_STRING 256 X#define PNL_TYPEOUT_BUFSIZ 4096 X#define PNL_TYPEOUT_COLUMNS PNL_TYPEIN_LENGTH X#define PNL_TYPEOUT_LINES 4 X#define PNL_TYPEOUT_MAX_COLUMNS 256 X#define PNL_SCROLL_WIDTH (2.0*PNL_DIM_1) X#define PNL_TYPEOUT_ARROW_HEIGHT (PNL_SCROLL_WIDTH/2.0) X#define PNL_PUCK_EDGE (4.0-PNL_DIM_1) X#define PNL_PUCK_SIZE (1.0-PNL_DIM_1) X#define PNL_FLOATING_PUCK_EDGE (1.0-PNL_DIM_1) X#define PNL_FLOATING_PUCK_SENS 10.0 /* units per full range output */ X#define PNL_METER_HEIGHT (1.8-PNL_DIM_1) X#define PNL_METER_WIDTH (3.0-PNL_DIM_1) X#define PNL_METER_LINEWIDTH 4 /* Pixels for meter pointer and bar line */ X#define PNL_STRIP_HEIGHT (1.8-PNL_DIM_1) X#define PNL_STRIP_WIDTH (6.0-PNL_DIM_1) X#define PNL_STRIP_LINEWIDTH 2 X#define PNL_STRIP_CHART_NPTS 200 X#define PNL_SLIDEROID_HEIGHT (1.5-PNL_DIM_1) X#define PNL_SLIDEROID_WIDTH (2.0-PNL_DIM_1) X#define PNL_DIAL_EDGE (1.0-PNL_DIM_1) X#define PNL_DIAL_WINDS 0.88 /* revs per full range output */ X X/* Actuator types */ X#define PNL_MAXACT 0x7ffff /* user types start here+1 */ X#define PNL_SLIDER 0 X#define PNL_VSLIDER PNL_SLIDER X#define PNL_HSLIDER 1 X#define PNL_FILLED_SLIDER 2 X#define PNL_FILLED_VSLIDER PNL_FILLED_SLIDER X#define PNL_FILLED_HSLIDER 3 X#define PNL_DVSLIDER 4 X#define PNL_DHSLIDER 5 X#define PNL_BUTTON 10 X#define PNL_TOGGLE_BUTTON 11 X#define PNL_RADIO_BUTTON 12 X#define PNL_WIDE_BUTTON 13 X#define PNL_TYPEIN 20 X#define PNL_LABEL 21 X#define PNL_TYPEOUT 30 X#define PNL_METER 40 X#define PNL_ANALOG_METER PNL_METER X#define PNL_ANALOG_BAR 41 X#define PNL_STRIP_CHART 42 X#define PNL_SCALE_CHART 43 X#define PNL_PUCK 50 X#define PNL_FLOATING_PUCK 51 X#define PNL_RUBBER_PUCK 52 X#define PNL_SLIDEROID 60 X#define PNL_PALETTE 70 X#define PNL_DIAL 80 X#define PNL_MOUSE 1000 X X/* drawing styles */ X#define PNL_OPEN 0 X#define PNL_FILLED 1 X X/* label styles */ X#define PNL_LABEL_LEFT 0 X#define PNL_LABEL_RIGHT 1 X#define PNL_LABEL_BOTTOM 2 X#define PNL_LABEL_TOP 3 X#define PNL_LABEL_NORMAL 4 X#define PNL_LABEL_CENTER 5 X X/* colors */ X#ifdef IRIS_4D X#define PNL_WHITE_COLOR WHITE X#define PNL_NORMAL_COLOR 490 X#define PNL_OTHER_COLOR 474 /* light enough? */ X#define PNL_BACKGROUND_COLOR 27 X#define PNL_HIGHLIGHT_COLOR 457 X#define PNL_OUTLINE_COLOR 321 X#else IRIS_4D X#define PNL_WHITE_COLOR WHITE X#define PNL_NORMAL_COLOR 30 X#define PNL_OTHER_COLOR 27 X#define PNL_BACKGROUND_COLOR 25 X#define PNL_HIGHLIGHT_COLOR 21 X#define PNL_OUTLINE_COLOR BLACK X#endif IRIS_4D X XPNL_EXTERN Colorindex pnl_background_color PNL_INIT(PNL_BACKGROUND_COLOR); XPNL_EXTERN Colorindex pnl_white_color PNL_INIT(PNL_WHITE_COLOR); XPNL_EXTERN Colorindex pnl_normal_color PNL_INIT(PNL_NORMAL_COLOR); XPNL_EXTERN Colorindex pnl_other_color PNL_INIT(PNL_OTHER_COLOR); XPNL_EXTERN Colorindex pnl_highlight_color PNL_INIT(PNL_HIGHLIGHT_COLOR); XPNL_EXTERN Colorindex pnl_outline_color PNL_INIT(PNL_OUTLINE_COLOR); X X/* mouse action sources */ X X#define PNL_SRC_QUEUE 0 X#define PNL_SRC_SCRIPT 1 X X/* script message types */ X X#define PNL_MT_STATE 0 X#define PNL_MT_MOUSE 1 X#define PNL_MT_DELAY 2 X#define PNL_MT_ENDBLOCK 3 X X#define PNL_HITACT(a,wx,wy) \ X ((wx)>(a)->x && (wx)<(a)->x+(a)->w && (wy)>(a)->y && (wy)<(a)->y+(a)->h) X#define PNL_ACCESS(type, ptr, member) (((type *)(ptr->data))->member) X#define PNL_MKUSERACT(struct_type, type) \ X ((struct struct_type *) \ X _mkuseract (sizeof (struct struct_type), type)) X X#define ABS(a) ((a)>0.0?(a):-(a)) X#define MIN(a, b) ((a)<(b)?(a):(b)) X#define MAX(a, b) ((a)>(b)?(a):(b)) X#define RANGE(a, b1, b2) \ X \ X ((b1)<(b2)? \ X ((a)<(b1)? \ X (b1): \ X ((a)>(b2)? \ X (b2):(a))): \ X ((a)<(b2)? \ X (b2): \ X ((a)>(b1)? \ X (b1):(a)))) X X#define PNL_VAL_TO_WORLD(val, min, max, dist) \ X (((val)-(min))/((max)-(min))*(dist)) X X#define PNL_WORLD_TO_VAL(x, min, max, dist) \ X ((x)/(dist)*((max)-(min))+(min)) X X#endif PNL_EDITOR_PARSING X Xtypedef struct panel { X short id; /* unique id */ X struct actuator *a; /* current actuator */ X struct actuator *al; /* actuator list */ X struct alist *autolist; /* list of auto actuators */ X struct actuator *lastgroup; /* last actuator added to a group */ X Boolean active, enabled; X long x, y, w, h; X Coord minx; X Coord maxx; X Coord miny; X Coord maxy; X Coord cw,ch; /* char width and height */ X short gid; /* mex window number of this panels window */ X short usergid; /* mex window number of one of the user's windows */ X Object vobj; /* viewing transformations */ X float ppu; /* pixels per unit */ X char *label; X#ifdef IRIS_4D X void (*fixfunc)(struct actuator *); X#else IRIS_4D X void (*fixfunc)(); X#endif IRIS_4D X void (*drawfunc)(); X void (*downfunc)(); X void (*activefunc)(); X void (*upfunc)(); X int dirtycnt; X struct panel *next; X} Panel; X Xtypedef struct actuator { X short id; /* unique id */ X struct panel *p; /* pointer to enclosing panel */ X int type; /* type id, init func should set this */ X Boolean active; X Coord x, y, w, h; X Coord lx, ly, lw, lh; /* offset and size of label */ X Coord ld; /* descender size */ X float val, initval, maxval, minval; X char *label; X Device key; /* keyboard equivalent */ X int labeltype; /* location of the label relative to the actuator */ X void (*addfunc)(); X#ifdef IRIS_4D X void (*fixfunc)(struct actuator *); X Boolean (*pickfunc)(/*struct actuator *,struct panel *,float,float*/); X void (*newvalfunc)(struct actuator *,struct panel *,short,short); X void (*dumpfunc)(struct actuator *, int); X void (*loadfunc)(struct actuator *, int); X#else IRIS_4D X void (*fixfunc)(); X Boolean (*pickfunc)(); X void (*newvalfunc)(); X void (*dumpfunc)(); X void (*loadfunc)(); X#endif IRIS_4D X void (*drawfunc)(); X void (*downfunc)(); X void (*activefunc)(); X void (*upfunc)(); X int dirtycnt; X char *u; /* pointer to arbitrary user data */ X char *data; /* pointer to data peculiar to a particular actuator */ X int datasize; /* size of data struct plus everyting it points to */ X Boolean automatic; /* true ==> newvalfunc called every dopanel */ X Boolean selectable; /* false ==> unpickable, newvalfunc never called */ X Boolean visible; /* does this actuator have a visible manifestation? */ X struct actuator *group; X struct actuator *next; X} Actuator; X X#ifndef PNL_EDITOR_PARSING X Xtypedef struct alist { X Actuator *a; X struct alist *next; X} Alist; X X/* actuator specific data */ X Xtypedef struct { X float x, y; X} Point; X Xtypedef struct { X int firstpt, lastpt; X Boolean Bind_Low, Bind_High; X float *y; X} Stripchart; X Xtypedef struct { X int mode; X float finefactor; X float valsave; X Coord wsave; X} Slider; X Xtypedef struct { X char * str; X int len; X} Typein; X Xtypedef struct { X char *buf; X int start; /* first char to display (appears in upper-left) */ X int dot; /* insertion point */ X int col,lin; /* width and height in character positions */ X int len; /* number of chars in buffer */ X int size; /* buffer size */ X Coord ch, cw, cd; /* character dimensions */ X} Typeout; X Xtypedef Point Puck; X Xtypedef struct { X Screencoord x; X Screencoord y; X} Mouse; X Xtypedef struct { X int mode; X Boolean finemode, resetmode; X float *resettarget, resetval; X float valsave; X Coord wsave; X} Slideroid; X Xtypedef Slider Palette; Xtypedef struct { X int mode; X float finefactor; X float valsave; X Coord wsave; X float winds; X} Dial; X X/* globals */ X XPNL_EXTERN int pnl_id PNL_INIT(0); X /* an incrementing index into the table */ X XPNL_EXTERN char *pnl_table[PNL_TABLE_SIZE]; X /* table of pointers to all panels and actuators */ X XPNL_EXTERN Panel *pnl_pl PNL_INIT(NULL); X /* list of all control panels */ X XPNL_EXTERN Alist *pnl_kl PNL_INIT(NULL); X /* a list of actuators with key equivalents */ X XPNL_EXTERN Panel *pnl_cp PNL_INIT(NULL); X /* panel being moused (current panel) */ X XPNL_EXTERN Actuator *pnl_ca PNL_INIT(NULL); X /* actuator being moused (current actuator) */ X XPNL_EXTERN Panel *pnl_cp_save PNL_INIT(NULL); X /* last cp from queue */ X XPNL_EXTERN Actuator *pnl_ca_save PNL_INIT(NULL); X /* last ca from queue */ X XPNL_EXTERN Boolean pnl_ca_active_save PNL_INIT(FALSE); X /* state of active field in pnl_ca_save */ X XPNL_EXTERN Boolean pnl_cp_active_save PNL_INIT(FALSE); X /* state of active field in pnl_cp_save */ X XPNL_EXTERN Actuator *pnl_mouse_act PNL_INIT(NULL); X /* the mouse actuator, if any */ X XPNL_EXTERN Screencoord pnl_mx, pnl_my; X /* where the mouse is */ X XPNL_EXTERN long int pnl_frame PNL_INIT(0); X /* frames since last delay message */ X XPNL_EXTERN int pnl_delay PNL_INIT(0); X /* frames 'til next message allowed from the queue */ X XPNL_EXTERN Boolean pnl_delayvirgin PNL_INIT(TRUE); X /* flag prevents writing initial delay token */ X XPNL_EXTERN Boolean pnl_readscript PNL_INIT(FALSE); X XPNL_EXTERN Boolean pnl_writescript PNL_INIT(FALSE); X XPNL_EXTERN int pnl_scriptinfd PNL_INIT(0); X XPNL_EXTERN int pnl_scriptoutfd PNL_INIT(0); X XPNL_EXTERN char *pnl_scriptinfile PNL_INIT("panel.script"); X XPNL_EXTERN char *pnl_scriptoutfile PNL_INIT("panel.script"); X XPNL_EXTERN Boolean pnl_virgin PNL_INIT(TRUE); X /* haven't done a dopanel yet */ X XPNL_EXTERN Boolean pnl_saveuserredraw PNL_INIT(FALSE); X /* if the user is using them, requeue them */ X XPNL_EXTERN Boolean pnl_scripting PNL_INIT(FALSE); X /* writing a script file */ X XPNL_EXTERN Screencoord pnl_ox, pnl_oy; X /* last window origin */ X XPNL_EXTERN Boolean pnl_justdown; X /* true when button first goes down */ X XPNL_EXTERN Boolean pnl_justup; X /* true when button first goes up */ X XPNL_EXTERN Boolean pnl_mousedown; X /* true when button is (was) down */ X /* (according to the queue) */ X XPNL_EXTERN Boolean pnl_shiftkey PNL_INIT(FALSE); X /* true when the shift key is down */ X XPNL_EXTERN Boolean pnl_controlkey PNL_INIT(FALSE); X /* true when the control key is down */ X XPNL_EXTERN int pnl_winsave; X /* gid of (user's) window when dopanel() is called */ X XPNL_EXTERN int pnl_action_source PNL_INIT(PNL_SRC_QUEUE); X /* where last mouse action came from */ X XPNL_EXTERN float pnl_char_threshold PNL_INIT(PNL_CHAR_THRESHOLD); X /* see PNL_CHAR_THRESHOLD above */ X X/* panel library utilities */ X X#ifdef IRIS_4D Xchar *alloc(int); X#else IRIS_4D Xchar *alloc(); X#endif IRIS_4D X X/* user functions */ X XPNL_EXTERN Panel *mkpanel(); XPNL_EXTERN Actuator *dopanel(); XPNL_EXTERN void dumpstate(); XPNL_EXTERN void drawpanel(); XPNL_EXTERN short userredraw(); XPNL_EXTERN void needredraw(); XPNL_EXTERN Boolean dumppanel(); X X#ifdef IRIS_4D X XPNL_EXTERN Actuator *mkact(/*void (*)()*/); /* parameter decl doesn't seem to work */ XPNL_EXTERN Actuator *_mkuseract(/*int, void (*)()*/); /* parameter decl doesn't seem to work */ XPNL_EXTERN void addact(Actuator *,Panel *); XPNL_EXTERN void endgroup(Panel *); XPNL_EXTERN char *g_gets(Colorindex,Colorindex,Colorindex); XPNL_EXTERN char *g_getstring(Colorindex,Colorindex,Colorindex,char *,int); XPNL_EXTERN Boolean pnl_beginreadscript(char *); XPNL_EXTERN Boolean pnl_beginwritescript(char *); XPNL_EXTERN void pnl_endreadscript(); XPNL_EXTERN void pnl_endwritescript(); X X#else IRIS_4D X XPNL_EXTERN Actuator *mkact(); XPNL_EXTERN Actuator *_mkuseract(); XPNL_EXTERN void addact(); XPNL_EXTERN void endgroup(); XPNL_EXTERN char *g_gets(); XPNL_EXTERN char *g_getstring(); XPNL_EXTERN Boolean pnl_beginreadscript(); XPNL_EXTERN Boolean pnl_beginwritescript(); XPNL_EXTERN void pnl_endreadscript(); XPNL_EXTERN void pnl_endwritescript(); X X#endif IRIS_4D X X#ifdef IRIS_4D Xextern void pnl_slider(Actuator *); Xextern void pnl_vslider(Actuator *); Xextern void pnl_hslider(Actuator *); Xextern void pnl_dvslider(Actuator *); Xextern void pnl_dhslider(Actuator *); Xextern void pnl_filled_slider(Actuator *); Xextern void pnl_filled_vslider(Actuator *); Xextern void pnl_filled_hslider(Actuator *); Xextern void pnl_button(Actuator *); Xextern void pnl_wide_button(Actuator *); Xextern void pnl_toggle_button(Actuator *); Xextern void pnl_radio_button(Actuator *); Xextern void pnl_meter(Actuator *); Xextern void pnl_analog_meter(Actuator *); Xextern void pnl_analog_bar(Actuator *); Xextern void pnl_strip_chart(Actuator *); Xextern void pnl_scale_chart(Actuator *); Xextern void pnl_puck(Actuator *); Xextern void pnl_floating_puck(Actuator *); Xextern void pnl_rubber_puck(Actuator *); Xextern void pnl_typein(Actuator *); Xextern void pnl_typeout(Actuator *); Xextern void pnl_label(Actuator *); Xextern void pnl_mouse(Actuator *); Xextern void pnl_slideroid(Actuator *); Xextern void pnl_palette(Actuator *); Xextern void pnl_dial(Actuator *); X#else IRIS_4D Xextern void pnl_slider(); Xextern void pnl_vslider(); Xextern void pnl_hslider(); Xextern void pnl_dvslider(); Xextern void pnl_dhslider(); Xextern void pnl_filled_slider(); Xextern void pnl_filled_vslider(); Xextern void pnl_filled_hslider(); Xextern void pnl_button(); Xextern void pnl_wide_button(); Xextern void pnl_toggle_button(); Xextern void pnl_radio_button(); Xextern void pnl_meter(); Xextern void pnl_analog_meter(); Xextern void pnl_analog_bar(); Xextern void pnl_strip_chart(); Xextern void pnl_scale_chart(); Xextern void pnl_puck(); Xextern void pnl_floating_puck(); Xextern void pnl_rubber_puck(); Xextern void pnl_typein(); Xextern void pnl_typeout(); Xextern void pnl_label(); Xextern void pnl_mouse(); Xextern void pnl_slideroid(); Xextern void pnl_palette(); Xextern void pnl_dial(); X#endif IRIS_4D X X#endif PNL_EDITOR_PARSING SHAR_EOF chmod 0644 panel.h || echo "restore of panel.h fails" sed 's/^X//' << 'SHAR_EOF' > puck.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X Xvoid _newvalpuck(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ XCoord wx,wy; Xstatic Coord d=PNL_PUCK_SIZE/2.0; X X if (!a->active) return; X X mapw2(p->vobj,sx,sy,&wx,&wy); X wx=RANGE(wx-a->x, d, a->w-d); X wy=RANGE(wy-a->y, d, a->h-d); X PNL_ACCESS(Puck, a, x)=(wx-d)/(a->w-2.0*d)*(a->maxval-a->minval)+a->minval; X PNL_ACCESS(Puck, a, y)=(wy-d)/(a->h-2.0*d)*(a->maxval-a->minval)+a->minval; X} X Xvoid X_drawpuckshape(a, p, x, y, style) XActuator *a; XPanel *p; XCoord x, y; Xint style; X{ Xstatic Coord d=PNL_PUCK_SIZE/2.0; X X if (style==PNL_FILLED) { X pmv2(-d,0.0); X pdr2(-PNL_DIM_2,-PNL_DIM_2); X pdr2(PNL_DIM_2,-PNL_DIM_2); X pdr2(d,0.0); X pdr2(PNL_DIM_2,PNL_DIM_2); X pdr2(-PNL_DIM_2,PNL_DIM_2); X pclos(); X pmv2(0.0,-d); X pdr2(PNL_DIM_2,-PNL_DIM_2); X pdr2(PNL_DIM_2,PNL_DIM_2); X pdr2(0.0,d); X pdr2(-PNL_DIM_2,PNL_DIM_2); X pdr2(-PNL_DIM_2,-PNL_DIM_2); X pclos(); X } else { X move2(-d,0.0); X draw2(-PNL_DIM_2, -PNL_DIM_2); X draw2(0.0,-d); X draw2(PNL_DIM_2,-PNL_DIM_2); X draw2(d,0.0); X draw2(PNL_DIM_2,PNL_DIM_2); X draw2(0.0,d); X draw2(-PNL_DIM_2,PNL_DIM_2); X draw2(-d,0.0); X } X} X Xvoid X_drawpuck(a, p) XActuator *a; XPanel *p; X{ XCoord x,y; Xstatic Coord d = PNL_PUCK_SIZE/2.0; X X color(PNL_NORMAL_COLOR); X rectf(a->x,a->y,a->x+a->w,a->y+a->h); X X pushmatrix(); X x=a->w*(PNL_ACCESS(Puck, a, x)-a->minval)/(a->maxval-a->minval); X y=a->h*(PNL_ACCESS(Puck, a, y)-a->minval)/(a->maxval-a->minval); X X translate(a->x+d, a->y+d, 0.0); X translate(x*(a->w-PNL_PUCK_SIZE)/a->w,y*(a->h-PNL_PUCK_SIZE)/a->h,0.0); X X color(PNL_HIGHLIGHT_COLOR); X _drawpuckshape(a,p,PNL_FILLED); X color(PNL_OUTLINE_COLOR); X _drawpuckshape(a,p,PNL_OPEN); X popmatrix(); X X color(PNL_OUTLINE_COLOR); X rect(a->x,a->y,a->x+a->w,a->y+a->h); X if (a->label) drawlabel(a, p); X} X Xvoid X_newvalfloatingpuck(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ XCoord wx,wy; Xstatic Coord d=PNL_PUCK_SIZE/2.0; X X if (!a->active) return; X X mapw2(p->vobj,sx,sy,&wx,&wy); X PNL_ACCESS(Puck, a, x)=(wx-a->x-d)/PNL_FLOATING_PUCK_SENS X *(a->maxval-a->minval); X PNL_ACCESS(Puck, a, y)=(wy-a->y-d)/PNL_FLOATING_PUCK_SENS X *(a->maxval-a->minval); X} X X#define PUCK_ERASE 0 X#define PUCK_DRAW 1 X X/* X * drawpup erase and draw in pup planes X * X * caveats: X * X * for erasing to work correctly, subsequent calls X * must be made with the same drawfunc. X * X * on the 3030, the cursor should be turned off. X * X */ X X_drawpup(a,p,x,y,mode,drawfunc) XActuator *a; /*p*/ XPanel *p; XCoord x,y; Xint mode; Xvoid (* drawfunc)(); X{ Xlong savemode; Xstatic Boolean drawn=FALSE; Xstatic Coord ox=0.0,oy=0.0,ox2=0.0,oy2=0.0; X X if (mode==PUCK_DRAW X && ox==x X && oy==y X && drawn) return; X#ifdef IRIS_4D X savemode=getdrawmode(); X drawmode(PUPDRAW); X#else IRIS_4D X pupmode(); X#endif IRIS_4D X X pushmatrix(); X pushviewport(); X fullscrn(); X ortho2(p->minx-(p->x/p->ppu), X p->minx+((XMAXSCREEN-p->x)/p->ppu), X p->miny-(p->y/p->ppu), X p->miny+((YMAXSCREEN-p->y)/p->ppu)); X X X#ifdef IRIS_4D X color(0); X#else IRIS_4D X pupcolor(PUP_CLEAR); X#endif IRIS_4D X/* pushmatrix(); X translate(ox2,oy2,0.0); X (* drawfunc)(a,p,PNL_FILLED); X popmatrix(); */ X X pushmatrix(); X translate(ox,oy,0.0); X (* drawfunc)(a,p,ox,oy,PNL_FILLED); X popmatrix(); X drawn=FALSE; X X if (mode==PUCK_DRAW) { X#ifdef IRIS_4D X color(1); X#else IRIS_4D X pupcolor(PUP_CURSOR); X#endif IRIS_4D X pushmatrix(); X translate(x,y,0.0); X (*drawfunc)(a,p, x, y, PNL_FILLED); X popmatrix(); X ox2=ox;oy2=oy; X ox=x;oy=y; X drawn=TRUE; X } X X#ifdef IRIS_4D X drawmode((Boolean)savemode); X#else IRIS_4D X endpupmode(); X#endif IRIS_4D X X endfullscrn(); X popviewport(); X popmatrix(); X} X Xvoid X_drawfloatingpuck(a,p) XActuator *a; XPanel *p; X{ Xstatic Coord d=PNL_PUCK_SIZE/2.0; XCoord x=0.0, y=0.0; X X pushmatrix(); X if (!a->active) { X _drawpup(a,p,x,y,PUCK_ERASE,_drawpuckshape); X X translate(a->x,a->y,0.0); X color(PNL_NORMAL_COLOR); X rectf(0.0,0.0,a->w,a->h); X color(PNL_OUTLINE_COLOR); X rect(0.0,0.0,a->w,a->h); X color(PNL_HIGHLIGHT_COLOR); X translate(a->w/2.0,a->h/2.0,0.0); X _drawpuckshape(a,p,x,y,PNL_FILLED); X color(PNL_OUTLINE_COLOR); X _drawpuckshape(a,p,x,y,PNL_OPEN); X curson(); X } else { X cursoff(); X x=PNL_FLOATING_PUCK_SENS X *PNL_ACCESS(Puck, a, x)/(a->maxval-a->minval) X +a->x+a->w/2.0; X y=PNL_FLOATING_PUCK_SENS X *PNL_ACCESS(Puck, a, y)/(a->maxval-a->minval) X +a->y+a->h/2.0; X X _drawpup(a,p,x,y,PUCK_DRAW,_drawpuckshape); X X translate(a->x,a->y,0.0); X color(PNL_HIGHLIGHT_COLOR); X rectf(0.0,0.0,a->w,a->h); X color(PNL_OUTLINE_COLOR); X rect(0.0,0.0,a->w,a->h); X X color(PNL_NORMAL_COLOR); X translate(a->w/2.0,a->h/2.0,0.0); X _drawpuckshape(a,p,x,y,PNL_FILLED); X color(PNL_OUTLINE_COLOR); X _drawpuckshape(a,p,x,y,PNL_OPEN); X } X popmatrix(); X X color(PNL_OUTLINE_COLOR); X if (a->label) drawlabel(a, p); X} X Xvoid X_drawrubberband(a, p, x, y, style) XActuator *a; XPanel *p; XCoord x, y; Xint style; X{ Xfloat r, alpha; XCoord dx, dy; X X dx=a->x+a->w/2.0-x; X dy=a->y+a->h/2.0-y; X X rectf(dx-PNL_DIM_3, X dy-PNL_DIM_3, X dx+PNL_DIM_3, X dy+PNL_DIM_3); X X pushmatrix(); X r=hypot((long float)dx,(long float)dy); X if (dx==0.0&&dy==0.0) alpha=0.0; X else alpha=atan2(dy,dx); X alpha=fmod(alpha, 360.0); X rot(alpha*PNL_RAD_TO_DEG,'z'); X rectf(0.0,-PNL_DIM_3/2.0,r,PNL_DIM_3/2.0); X popmatrix(); X} X Xvoid X_drawrubberpuckshape(a, p, x, y, style) XActuator *a; XPanel *p; XCoord x, y; Xint style; X{ Xstatic Coord d=PNL_PUCK_SIZE/2.0; X X if (style==PNL_FILLED) { X rectf(-d,-PNL_DIM_3,d,PNL_DIM_3); X rectf(-PNL_DIM_3,-d,PNL_DIM_3,d); X rectf(-PNL_DIM_2,-PNL_DIM_2,PNL_DIM_2,PNL_DIM_2); X } else { X move2(-PNL_DIM_3,-d); X draw2(PNL_DIM_3,-d); X draw2(PNL_DIM_3,-PNL_DIM_2); X draw2(PNL_DIM_2,-PNL_DIM_2); X draw2(PNL_DIM_2,-PNL_DIM_3); X draw2(d,-PNL_DIM_3); X draw2(d,PNL_DIM_3); X draw2(PNL_DIM_2,PNL_DIM_3); X draw2(PNL_DIM_2,PNL_DIM_2); X draw2(PNL_DIM_3,PNL_DIM_2); X draw2(PNL_DIM_3,d); X draw2(-PNL_DIM_3,d); X draw2(-PNL_DIM_3,PNL_DIM_2); X draw2(-PNL_DIM_2,PNL_DIM_2); X draw2(-PNL_DIM_2,PNL_DIM_3); X draw2(-d,PNL_DIM_3); X draw2(-d,-PNL_DIM_3); X draw2(-PNL_DIM_2,-PNL_DIM_3); X draw2(-PNL_DIM_2,-PNL_DIM_2); X draw2(-PNL_DIM_3,-PNL_DIM_2); X draw2(-PNL_DIM_3,-d); X } X} X Xvoid X_drawrubberpuckshapeandband(a, p, x, y, style) XActuator *a; XPanel *p; XCoord x, y; Xint style; X{ X _drawrubberpuckshape(a, p, x, y, style); X _drawrubberband(a, p, x, y, style); X} X Xvoid X_drawrubberpuck(a,p) XActuator *a; XPanel *p; X{ Xstatic Coord d=PNL_PUCK_SIZE/2.0; Xstatic Coord x, y; X X pushmatrix(); X if (!a->active) { X _drawpup(a,p,x,y,PUCK_ERASE,_drawrubberpuckshapeandband); X translate(a->x,a->y,0.0); X color(PNL_NORMAL_COLOR); X rectf(0.0,0.0,a->w,a->h); X color(PNL_OUTLINE_COLOR); X rect(0.0,0.0,a->w,a->h); X color(PNL_HIGHLIGHT_COLOR); X translate(a->w/2.0,a->h/2.0,0.0); X _drawrubberpuckshape(a,p,x,y,PNL_FILLED); X color(PNL_OUTLINE_COLOR); X _drawrubberpuckshape(a,p,x,y,PNL_OPEN); X curson(); X } else { X cursoff(); X x=PNL_FLOATING_PUCK_SENS X *PNL_ACCESS(Puck, a, x)/(a->maxval-a->minval) X +a->x+a->w/2.0; X y=PNL_FLOATING_PUCK_SENS X *PNL_ACCESS(Puck, a, y)/(a->maxval-a->minval) X +a->y+a->h/2.0; X X _drawpup(a,p,x,y,PUCK_DRAW,_drawrubberpuckshapeandband); X X translate(a->x,a->y,0.0); X color(PNL_HIGHLIGHT_COLOR); X rectf(0.0,0.0,a->w,a->h); X color(PNL_OUTLINE_COLOR); X rect(0.0,0.0,a->w,a->h); X X color(PNL_NORMAL_COLOR); X translate(a->w/2.0,a->h/2.0,0.0); X _drawrubberpuckshape(a,p,x,y,PNL_FILLED); X color(PNL_OUTLINE_COLOR); X _drawrubberpuckshape(a,p,x,y,PNL_OPEN); X } X popmatrix(); X if (pnl_justup) curson(); X X color(PNL_OUTLINE_COLOR); X if (a->label) drawlabel(a, p); X} X Xvoid Xpnl_puck(a) XActuator *a; X{ X a->type=PNL_PUCK; X X a->w=a->h=PNL_PUCK_EDGE; X a->data=(char *)alloc(sizeof(Puck)); /* this goes in an addfunc */ X a->datasize=sizeof(Puck); X PNL_ACCESS(Puck, a, x)=0.0; X PNL_ACCESS(Puck, a, y)=0.0; X a->labeltype=PNL_LABEL_BOTTOM; X a->newvalfunc=_newvalpuck; X a->drawfunc=_drawpuck; X} X Xvoid Xpnl_floating_puck(a) XActuator *a; X{ X a->type=PNL_FLOATING_PUCK; X X a->w=PNL_FLOATING_PUCK_EDGE; X a->h=PNL_FLOATING_PUCK_EDGE; X a->data=(char *)alloc(sizeof(Puck)); X a->datasize=sizeof(Puck); X PNL_ACCESS(Puck, a, x)=0.0; X PNL_ACCESS(Puck, a, y)=0.0; X a->newvalfunc=_newvalfloatingpuck; X a->drawfunc=_drawfloatingpuck; X} X Xvoid Xpnl_rubber_puck(a) XActuator *a; X{ X pnl_floating_puck(a); X X a->type=PNL_RUBBER_PUCK; X a->drawfunc=_drawrubberpuck; X} X SHAR_EOF chmod 0644 puck.c || echo "restore of puck.c fails" sed 's/^X//' << 'SHAR_EOF' > script.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include X Xvoid Xbeginscript() X{ X pnl_beginwritescript("panel.script"); X} X Xvoid Xappendscript() X{ X pnl_beginappendscript("panel.script"); X} X Xvoid Xendscript() X{ X pnl_endwritescript(); X} X Xvoid Xreadscript() X{ X pnl_beginreadscript("panel.script"); X} X Xvoid Xstopscript() X{ X pnl_endreadscript(); X} X Xinitscriptpanel() X{ XActuator *a; XPanel *p; X X p=mkpanel(); X p->label="scripting"; X X a=mkact(pnl_button); X a->label="dump state"; X a->x=1.0; X a->y=4.5; X a->downfunc=dumpstate; X addact(a, p); X X a=mkact(pnl_button); X a->label="begin script"; X a->x=1.0; X a->y=4.0; X a->downfunc=beginscript; X addact(a, p); X X a=mkact(pnl_button); X a->label="end script"; X a->x=1.0; X a->y=3.5; X a->downfunc=endscript; X addact(a, p); X X a=mkact(pnl_button); X a->label="append to script"; X a->x=1.0; X a->y=3.0; X a->downfunc=appendscript; X addact(a, p); X X a=mkact(pnl_button); X a->label="read script"; X a->x=1.0; X a->y=2.5; X a->downfunc=readscript; X addact(a, p); X X a=mkact(pnl_button); X a->label="stop reading script"; X a->x=1.0; X a->y=2.0; X a->downfunc=stopscript; X addact(a, p); X} SHAR_EOF chmod 0644 script.c || echo "restore of script.c fails" sed 's/^X//' << 'SHAR_EOF' > slider.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include "panel.h" X X#define NORMAL_MODE 0 X#define DIFFERENTIAL_MODE 1 X#define FINE_CONTROL_MODE 2 X X#define DIFFERENTIAL_FACTOR 0.1 X#define FINE_CONTROL_FACTOR 0.05 X Xvoid setsliderval(a, x, dist) X Actuator *a; X Coord x; X float dist; X{ X Slider *ad=(Slider *)a->data; X float tmp; X X tmp=PNL_VAL_TO_WORLD(a->val, a->minval, a->maxval, dist); X if (pnl_justdown) { X if (!pnl_controlkey) X a->val=PNL_WORLD_TO_VAL(x, a->minval, a->maxval, dist); X ad->wsave=x; X } X X a->val+= X (pnl_controlkey?ad->finefactor X *(x-ad->wsave)/dist*(a->maxval-a->minval) X :(x-ad->wsave)/dist*(a->maxval-a->minval)); X a->val=RANGE(a->val, a->maxval, a->minval); X X ad->wsave=x; X ad->valsave=a->val; X} X Xvoid _newvalvslider(a,p,sx,sy) X Actuator *a; X Panel *p; X Screencoord sx,sy; X{ X Slider *ad=(Slider *)a->data; X Coord wx, wy; X float tmp; X X if (!a->active) return; X X mapw2(p->vobj,sx,sy,&wx,&wy); X X setsliderval(a, wy-a->y, a->h); X} X Xvoid _newvalhslider(a,p,sx,sy) X Actuator *a; X Panel *p; X Screencoord sx,sy; X{ X Slider *ad=(Slider *)a->data; X Coord wx, wy; X X if (!a->active) return; X X mapw2(p->vobj,sx,sy,&wx,&wy); X X setsliderval(a, wx-a->x, a->w); X} X Xvoid _newvaldvslider(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ X Slider *ad=(Slider *)a->data; X Coord wx, wy; X X mapw2(p->vobj,sx,sy,&wx,&wy); X X if (pnl_justdown) { X if (wy-a->yh-PNL_BUTTON_EDGE) ad->mode = NORMAL_MODE; X else { X ad->wsave=wy; X ad->valsave=a->val; X if (wx-a->xmode = DIFFERENTIAL_MODE; X else ad->mode = FINE_CONTROL_MODE; X } X } X if (pnl_justup) ad->mode=NORMAL_MODE; X if (!a->active) return; X X switch (ad->mode) { X case NORMAL_MODE: X/* a->val=(wy-a->y)/(a->h-PNL_BUTTON_EDGE) X *(a->maxval-a->minval)+a->minval; */ X setsliderval(a, wy-a->y, a->h-PNL_BUTTON_EDGE); X break; X case DIFFERENTIAL_MODE: X a->val+=DIFFERENTIAL_FACTOR*(wy-ad->wsave)/a->h*(a->maxval-a->minval); X break; X case FINE_CONTROL_MODE: X a->val=ad->valsave X +FINE_CONTROL_FACTOR*(wy-ad->wsave)/a->h*(a->maxval-a->minval); X default: X break; X } X X a->val=RANGE(a->val, a->maxval, a->minval); X} X Xvoid X_drawvslider(a, p) XActuator *a; XPanel *p; X{ XCoord y; X X pushmatrix(); X X translate(a->x,a->y,0.0); X X color(pnl_normal_color); X rectf(0.0,0.0,a->w,a->h); X color(pnl_outline_color); X rect(0.0,0.0,a->w,a->h); X X y=(a->val-a->minval)/(a->maxval-a->minval)*a->h; X X color(pnl_highlight_color); X rectf(0.0,MAX(0.0,y-PNL_SLIDER_BAR_HEIGHT/2.0), X a->w,MIN(a->h,y+PNL_SLIDER_BAR_HEIGHT/2.0)); X color(pnl_outline_color); X rect(0.0,MAX(0.0,y-PNL_SLIDER_BAR_HEIGHT/2.0), X a->w,MIN(a->h,y+PNL_SLIDER_BAR_HEIGHT/2.0)); X X popmatrix(); X if (a->label) drawlabel(a, p); X} X Xvoid X_drawhslider(a, p) XActuator *a; XPanel *p; X{ XCoord x; X X pushmatrix(); X X translate(a->x,a->y,0.0); X X color(pnl_normal_color); X rectf(0.0,0.0,a->w,a->h); X color(pnl_outline_color); X rect(0.0,0.0,a->w,a->h); X X x=(a->val-a->minval)/(a->maxval-a->minval)*a->w; X X color(pnl_highlight_color); X rectf(MAX(0.0,x-PNL_SLIDER_BAR_HEIGHT/2.0),0.0, X MIN(a->w,x+PNL_SLIDER_BAR_HEIGHT/2.0),a->h); X color(pnl_outline_color); X rect(MAX(0.0,x-PNL_SLIDER_BAR_HEIGHT/2.0),0.0, X MIN(a->w,x+PNL_SLIDER_BAR_HEIGHT/2.0),a->h); X X popmatrix(); X if (a->label) drawlabel(a, p); X} X XCoord diamond[][2] = { X { 0.0, -1.0 }, X { 1.0, 0.0 }, X { 0.0, 1.0 }, X {-1.0, 0.0 } X }; X X_drawfineicon(selected) XBoolean selected; X{ X pushmatrix(); X if (selected) { X color(pnl_highlight_color); X rectf(-PNL_BUTTON_EDGE/2.0,-PNL_BUTTON_EDGE/2.0, X PNL_BUTTON_EDGE/2.0, PNL_BUTTON_EDGE/2.0); X color(pnl_normal_color); X scale(PNL_BUTTON_EDGE/2.0-PNL_DIM_3, PNL_BUTTON_EDGE/2.0-PNL_DIM_3, 0.0); X polf2(4, diamond); X color(pnl_outline_color); X poly2(4, diamond); X } else { X scale(PNL_BUTTON_EDGE/2.0-PNL_DIM_3, PNL_BUTTON_EDGE/2.0-PNL_DIM_3, 0.0); X color(pnl_other_color); X polf2(4, diamond); X color(pnl_outline_color); X poly2(4, diamond); X } X popmatrix(); X} X X_drawdifficon(selected) XBoolean selected; X{ X pushmatrix(); X if (selected) { X color(pnl_highlight_color); X rectf(-PNL_BUTTON_EDGE/2.0,-PNL_BUTTON_EDGE/2.0, X PNL_BUTTON_EDGE/2.0, PNL_BUTTON_EDGE/2.0); X color(pnl_normal_color); X scale(PNL_BUTTON_EDGE/2.0-PNL_DIM_3, PNL_BUTTON_EDGE/2.0-PNL_DIM_3, 0.0); X poly2(4, diamond); X } else { X color(pnl_outline_color); X scale(PNL_BUTTON_EDGE/2.0-PNL_DIM_3, PNL_BUTTON_EDGE/2.0-PNL_DIM_3, 0.0); X poly2(4, diamond); X } X popmatrix(); X} X Xvoid X_drawdvslider(a, p) XActuator *a; XPanel *p; X{ X Slider *ad=(Slider *)a->data; X Coord y; X X pushmatrix(); X X translate(a->x,a->y,0.0); X X color(pnl_normal_color); X rectf(0.0,0.0,a->w,a->h); X X pushmatrix(); X translate(PNL_BUTTON_EDGE/2.0,a->h-PNL_BUTTON_EDGE/2.0,0.0); X switch (ad->mode) { X case NORMAL_MODE: X _drawdifficon(FALSE); X translate(PNL_BUTTON_EDGE, 0.0, 0.0); X _drawfineicon(FALSE); X break; X case FINE_CONTROL_MODE: X _drawdifficon(FALSE); X translate(PNL_BUTTON_EDGE, 0.0, 0.0); X _drawfineicon(TRUE); X break; X case DIFFERENTIAL_MODE: X _drawdifficon(TRUE); X translate(PNL_BUTTON_EDGE, 0.0, 0.0); X _drawfineicon(FALSE); X break; X } X popmatrix(); X X color(pnl_outline_color); X rect(0.0,0.0,a->w,a->h); X move2(0.0,a->h-PNL_BUTTON_EDGE); X rdr2(PNL_SLIDER_WIDTH,0.0); X move2(PNL_BUTTON_EDGE,a->h-PNL_BUTTON_EDGE); X rdr2(0.0,PNL_BUTTON_EDGE); X X y=(a->val-a->minval)/(a->maxval-a->minval) X *(a->h-PNL_BUTTON_EDGE); X X color(pnl_highlight_color); X rectf(0.0,MAX(0.0,y-PNL_SLIDER_BAR_HEIGHT/2.0), X a->w,MIN(a->h-PNL_BUTTON_EDGE,y+PNL_SLIDER_BAR_HEIGHT/2.0)); X color(pnl_outline_color); X rect(0.0,MAX(0.0,y-PNL_SLIDER_BAR_HEIGHT/2.0), X a->w,MIN(a->h-PNL_BUTTON_EDGE,y+PNL_SLIDER_BAR_HEIGHT/2.0)); X X popmatrix(); X if (a->label) drawlabel(a, p); X} X Xvoid X_drawfilledhslider(a, p) XActuator *a; XPanel *p; X{ XCoord x; X X pushmatrix(); X X translate(a->x,a->y,0.0); X X color(pnl_normal_color); X rectf(0.0,0.0,a->w,a->h); X color(pnl_outline_color); X rect(0.0,0.0,a->w,a->h); X X x=(a->val-a->minval)/(a->maxval-a->minval)*a->w; X X color(pnl_highlight_color); X rectf(0.0,0.0,x,a->h); X color(pnl_outline_color); X rect(0.0,0.0,x,a->h); X X popmatrix(); X if (a->label) drawlabel(a, p); X} X Xvoid X_drawfilledvslider(a, p) XActuator *a; XPanel *p; X{ XCoord y; X X pushmatrix(); X X translate(a->x,a->y,0.0); X X color(pnl_normal_color); X rectf(0.0,0.0,a->w,a->h); X color(pnl_outline_color); X rect(0.0,0.0,a->w,a->h); X X y=(a->val-a->minval)/(a->maxval-a->minval)*a->h; X X color(pnl_highlight_color); X rectf(0.0,0.0,a->w,y); X color(pnl_outline_color); X rect(0.0,0.0,a->w,y); X X popmatrix(); X if (a->label) drawlabel(a, p); X} X Xvoid X_addslider(a) X Actuator *a; X{ X Slider *ad=(Slider *)a->data; X if (ad->finefactor==0.0) ad->finefactor=FINE_CONTROL_FACTOR; X} X Xvoid Xpnl_slider(a) XActuator *a; X{ X Slider *ad; X X a->type=PNL_SLIDER; X X a->data = alloc(sizeof(Slider)); X a->datasize = sizeof(Slider); X ad=(Slider *)a->data; X ad->wsave=0.0; X ad->mode=NORMAL_MODE; X X a->labeltype=PNL_LABEL_BOTTOM; X a->addfunc=_addslider; X X a->w=PNL_SLIDER_WIDTH; X a->h=PNL_SLIDER_HEIGHT; X a->newvalfunc=_newvalvslider; X a->drawfunc=_drawvslider; X} X Xvoid Xpnl_vslider(a) XActuator *a; X{ X pnl_slider(a); X a->type=PNL_VSLIDER; X X a->w=PNL_SLIDER_WIDTH; X a->h=PNL_SLIDER_HEIGHT; X a->newvalfunc=_newvalvslider; X a->drawfunc=_drawvslider; X} X Xvoid Xpnl_hslider(a) XActuator *a; X{ X pnl_slider(a); X a->type=PNL_HSLIDER; X X a->w=PNL_SLIDER_HEIGHT; X a->h=PNL_SLIDER_WIDTH; X a->newvalfunc=_newvalhslider; X a->drawfunc=_drawhslider; X} X Xvoid Xpnl_dvslider(a) XActuator *a; X{ X pnl_slider(a); X a->type=PNL_DVSLIDER; X X a->w=PNL_SLIDER_WIDTH; X a->h=PNL_SLIDER_HEIGHT; X a->newvalfunc=_newvaldvslider; X a->drawfunc=_drawdvslider; X} X Xvoid Xpnl_filled_vslider(a) XActuator *a; X{ X pnl_slider(a); X a->type=PNL_FILLED_VSLIDER; X X a->w=PNL_SLIDER_WIDTH; X a->h=PNL_SLIDER_HEIGHT; X a->newvalfunc=_newvalvslider; X a->drawfunc=_drawfilledvslider; X} X Xvoid Xpnl_filled_slider(a) XActuator *a; X{ X pnl_filled_vslider(a); X a->type=PNL_FILLED_SLIDER; X} X Xvoid Xpnl_filled_hslider(a) XActuator *a; X{ X pnl_slider(a); X a->type=PNL_FILLED_HSLIDER; X X a->w=PNL_SLIDER_HEIGHT; X a->h=PNL_SLIDER_WIDTH; X a->newvalfunc=_newvalhslider; X a->drawfunc=_drawfilledhslider; X} SHAR_EOF chmod 0644 slider.c || echo "restore of slider.c fails" sed 's/^X//' << 'SHAR_EOF' > slideroid.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include "panel.h" X X#define NORMAL_MODE 0 X#define DIFFERENTIAL_MODE 1 X#define ABSOLUTE_MODE 2 X X#define DIFFERENTIAL_FACTOR 0.01 X#define ABSOLUTE_FACTOR 0.05 X#define FINE_FACTOR 0.05 X Xvoid _newvalslideroid(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ X Slideroid *ad=(Slideroid *)a->data; X Coord wx, wy; X X mapw2(p->vobj,sx,sy,&wx,&wy); X X if (pnl_justdown) { X if ( wy-a->y>2.0*a->h/3.0 X && wx-a->xw/6.0) ad->finemode= ~ad->finemode; X else if ( wy-a->y>2.0*a->h/3.0 X && wx-a->x>5.0*a->w/6.0) { X ad->resetmode=TRUE; X if (a->val==a->initval X && ad->resettarget) *ad->resettarget=ad->resetval; X else a->val=a->initval; X } X else if (wy-a->yh/3.0) { X ad->wsave=wy; X ad->valsave=a->val; X if (wx-a->xw/2.0) ad->mode = DIFFERENTIAL_MODE; X else ad->mode = ABSOLUTE_MODE; X } else ad->mode = NORMAL_MODE; X } X if (pnl_justup) { X ad->mode=NORMAL_MODE; X ad->resetmode=FALSE; X } X if (!a->active) return; X X switch (ad->mode) { X case NORMAL_MODE: X break; X case DIFFERENTIAL_MODE: X a->val+=DIFFERENTIAL_FACTOR X *(ad->finemode?FINE_FACTOR:1.0) X *(wy-ad->wsave) X /a->h X *(a->maxval-a->minval); X break; X case ABSOLUTE_MODE: X a->val=ad->valsave X +ABSOLUTE_FACTOR X *(ad->finemode?FINE_FACTOR:1.0) X *(wy-ad->wsave)/a->h X *(a->maxval-a->minval); X default: X break; X } X X a->val=RANGE(a->val, a->maxval, a->minval); X} X Xstatic Coord diamond[][2] = { X { 0.0, -1.0 }, X { 1.0, 0.0 }, X { 0.0, 1.0 }, X {-1.0, 0.0 } X }; X Xstatic _drawabsicon(a, selected) XActuator *a; XBoolean selected; X{ X pushmatrix(); X if (selected) { X color(pnl_highlight_color); X rectf(-a->w/4.0,-a->h/6.0, X a->w/4.0, a->h/6.0); X color(pnl_normal_color); X scale(a->w/4.0-PNL_DIM_3, a->h/6.0-PNL_DIM_3, 0.0); X polf2(4, diamond); X color(pnl_outline_color); X poly2(4, diamond); X } else { X scale(a->w/4.0-PNL_DIM_3, a->h/6.0-PNL_DIM_3, 0.0); X color(pnl_other_color); X polf2(4, diamond); X color(pnl_outline_color); X poly2(4, diamond); X } X popmatrix(); X} X Xstatic _drawdifficon(a, selected) XActuator *a; XBoolean selected; X{ X pushmatrix(); X if (selected) { X color(pnl_highlight_color); X rectf(-a->w/4.0,-a->h/6.0, X a->w/4.0, a->h/6.0); X color(pnl_normal_color); X scale(a->w/4.0-PNL_DIM_3, a->h/6.0-PNL_DIM_3, 0.0); X poly2(4, diamond); X } else { X color(pnl_outline_color); X scale(a->w/4.0-PNL_DIM_3, a->h/6.0-PNL_DIM_3, 0.0); X poly2(4, diamond); X } X popmatrix(); X} X Xvoid X_drawslideroid(a, p) XActuator *a; XPanel *p; X{ X Slideroid *ad=(Slideroid *)a->data; X Coord cx, cy; X char s[7], stmp[16]; X X pushmatrix(); X X translate(a->x,a->y,0.0); X X color(pnl_normal_color); X rectf(0.0,0.0,a->w,a->h); X color(pnl_outline_color); X rect(0.0,0.0,a->w,a->h); X X move2(0.0,a->h/3.0); X rdr2(a->w,0.0); X move2(0.0,2.0*a->h/3.0); X rdr2(a->w,0.0); X move2(a->w/2.0,0.0); X rdr2(0.0,a->h/3.0); X move2(a->w/6.0,2.0*a->h/3.0); X rdr2(0.0,a->h/3.0); X move2(5.0*a->w/6.0,2.0*a->h/3.0); X rdr2(0.0,a->h/3.0); X X cx= -(float)strwidth("F")/p->ppu/2.0; X cy= -(float)(getheight("E")-getdescender())/p->ppu/2.0; X if (ad->finemode) { X color(pnl_highlight_color); X rectf(0.0,2.0*a->h/3.0,a->w/6.0,a->h); X color(pnl_white_color); X cmov2(a->w/12.0+cx, 5.0*a->h/6.0+cy); X charstr("F"); X color(pnl_outline_color); X } else { X cmov2(a->w/12.0+cx, 5.0*a->h/6.0+cy); X charstr("F"); X } X X if (ad->resetmode) { X color(pnl_highlight_color); X rectf(5.0*a->w/6.0,2.0*a->h/3.0,a->w,a->h); X color(pnl_white_color); X cmov2(11.0*a->w/12.0+cx, 5.0*a->h/6.0+cy); X charstr("R"); X color(pnl_outline_color); X } else { X cmov2(11.0*a->w/12.0+cx, 5.0*a->h/6.0+cy); X charstr("R"); X } X X sprintf(stmp, "%-+#10.3E", a->val); X strncpy(s, stmp, 6); X s[6]='\0'; X X cx= -(float)strwidth(s)/p->ppu/2.0; X cmov2(a->w/2.0+cx, 3.0*a->h/6.0+cy); X charstr(s); X X strncpy(s, stmp+6, 4); X s[4]='\0'; X X cx= -(float)strwidth(s)/p->ppu/2.0; X cmov2(a->w/2.0+cx, 5.0*a->h/6.0+cy); X charstr(s); X X pushmatrix(); X translate(a->w/4.0,a->h/6.0,0.0); X switch (ad->mode) { X case NORMAL_MODE: X _drawdifficon(a, FALSE); X translate(a->w/2.0, 0.0, 0.0); X _drawabsicon(a, FALSE); X break; X case ABSOLUTE_MODE: X _drawdifficon(a, FALSE); X translate(a->w/2.0, 0.0, 0.0); X _drawabsicon(a, TRUE); X break; X case DIFFERENTIAL_MODE: X _drawdifficon(a, TRUE); X translate(a->w/2.0, 0.0, 0.0); X _drawabsicon(a, FALSE); X break; X } X popmatrix(); X popmatrix(); X X if (a->label) drawlabel(a, p); X} X Xvoid Xpnl_slideroid(a) XActuator *a; X{ X Slideroid *ad; X X a->type=PNL_SLIDEROID; X X a->data = alloc(sizeof(Slideroid)); X a->datasize = sizeof(Slideroid); X ad=(Slideroid *)a->data; X ad->wsave=0.0; X ad->mode=NORMAL_MODE; X X a->w=PNL_SLIDEROID_WIDTH; X X a->h=PNL_SLIDEROID_HEIGHT; X a->labeltype=PNL_LABEL_BOTTOM; X a->newvalfunc=_newvalslideroid; X a->drawfunc=_drawslideroid; X} X SHAR_EOF chmod 0644 slideroid.c || echo "restore of slideroid.c fails" sed 's/^X//' << 'SHAR_EOF' > stoa.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X XBoolean Xtread(fd, buf, len) Xint fd; Xchar *buf; Xint len; X{ X int c; X X if ((c=read(0,buf,len))!=len) { X printf("\n"); X return FALSE; X } X return TRUE; X} X Xmain() X{ X int c; X Actuator a; X short actid; X int msgtype, datasize, delay; X int buf[9]; X char data[16386]; X X for (;;) { X if (!tread(0,&msgtype,sizeof(msgtype))) exit(1); X X switch (msgtype) { X case PNL_MT_MOUSE: X if (!tread(0,buf,sizeof(buf))) exit(1); X X pnl_cp=(Panel *)buf[0]; X pnl_ca=(Actuator *)buf[1]; X pnl_mx=(Screencoord)buf[2]; X pnl_my=(Screencoord)buf[3]; X pnl_justup=(Boolean)buf[4]; X pnl_justdown=(Boolean)buf[5]; X pnl_mousedown=(Boolean)buf[6]; X pnl_shiftkey=(Boolean)buf[7]; X pnl_controlkey=(Boolean)buf[8]; X X printf("MOUSE: %d %d %d %d %d %d %d\n", X pnl_cp, X pnl_ca, X pnl_mx, X pnl_my, X pnl_justup, X pnl_justdown, X pnl_mousedown, X pnl_shiftkey, X pnl_controlkey); X break; X case PNL_MT_STATE: X tread(0,&actid,sizeof(short)); X tread(0,&a,sizeof(a)); X tread(0,&datasize,sizeof(int)); X tread(0,data,datasize); X X printf("STATE: %d %d %f\n", actid, a.type, a.val); X break; X case PNL_MT_DELAY: X tread(0,&delay,sizeof(delay)); X X printf("DELAY: %d\n", delay); X break; X default: X printf("unrecognized message type\n"); X exit(1); X } X } X} X X SHAR_EOF chmod 0644 stoa.c || echo "restore of stoa.c fails" sed 's/^X//' << 'SHAR_EOF' > strip.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include "panel.h" X Xvoid NewY(a,x) XActuator *a; Xfloat x; X{ X int i; X Stripchart * dp = (Stripchart *)a->data; X X dp->y[dp->lastpt++] = x; X if (dp->lastpt >= PNL_STRIP_CHART_NPTS) dp->lastpt = 0; X if (dp->firstpt == dp->lastpt) { X dp->firstpt++; X if (dp->firstpt == PNL_STRIP_CHART_NPTS) dp->firstpt = 0; X } X} X Xvoid _setrange(a) XActuator *a; X{ X int i; X float mymin, mymax; X Stripchart * dp = (Stripchart *)a->data; X X i = dp->firstpt; X mymax = dp->y[i]; X mymin = mymax; X X while (i != dp->lastpt) { X if (dp->y[i] < mymin) mymin = dp->y[i]; X if (dp->y[i] > mymax) mymax = dp->y[i]; X i++; X if (i >= PNL_STRIP_CHART_NPTS) i = 0; X } X X if (mymin == mymax) { /* Center the only value, if all are same */ X mymin -= 0.1; X mymax += 0.1; X } X if (!dp->Bind_Low) X a->minval = mymin; X if (!dp->Bind_High) X a->maxval = mymax; X} X Xvoid X_addstripchart(a, p) XActuator *a; XPanel *p; X{ Xint i; X X PNL_ACCESS(Stripchart, a, firstpt) = 0; X PNL_ACCESS(Stripchart, a, lastpt) = 0; X PNL_ACCESS(Stripchart, a, y) = X (float *)alloc(PNL_STRIP_CHART_NPTS*sizeof(float)); X a->datasize=sizeof(Stripchart)+PNL_STRIP_CHART_NPTS*sizeof(float); X for (i = 0; i < PNL_STRIP_CHART_NPTS; i++) X PNL_ACCESS(Stripchart, a, y[i]) = 0.0; X} X Xvoid X_fixstripchart(a) XActuator *a; X{ X NewY(a, a->val); X} X Xvoid _newvalstripchart(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ X NewY(a,a->val); X} X Xvoid _dumpstripchart(a, fd) XActuator *a; Xint fd; X{ XStripchart *ad=(Stripchart *)a->data; Xstatic int msgtype=PNL_MT_STATE; X X write(fd, &msgtype, sizeof(msgtype)); X write(fd, &a->id, sizeof(a->id)); X write(fd, a, sizeof(Actuator)); X write(fd, &a->datasize, sizeof(int)); X write(fd, a->data, sizeof(Stripchart)); X write(fd, ad->y, PNL_STRIP_CHART_NPTS*sizeof(float)); X} X Xvoid _loadstripchart(a, fd) XActuator *a; Xint fd; X{ XStripchart *ad=(Stripchart *)a->data; X X read(fd, a, sizeof(Actuator)); X read(fd, &a->datasize, sizeof(int)); X read(fd, a->data, sizeof(Stripchart)); X read(fd, ad->y, PNL_STRIP_CHART_NPTS*sizeof(float)); X} X X Xvoid X_drawanalogmeter(a,p) XActuator *a; XPanel *p; X{ X float theta; X Coord x, y; X Coord radius = (a->w / 2.0) - (2.0*PNL_DIM_2); X Coord xorg = a->w / 2.0; X Coord yorg = PNL_DIM_2; X long oldwidth = getlwidth(); X X pushmatrix(); X translate(a->x,a->y,0.0); X X color(pnl_other_color); X rectf(0.0, 0.0, a->w, a->h); X X color(pnl_normal_color); X arcf(xorg, yorg, radius, 0, 1800); X X color(pnl_outline_color); X arc(xorg, yorg, radius, 0, 1800); X move2(xorg,yorg); X rmv2(-radius,0.0); X rdr2(2.0*radius,0.0); X X color(pnl_outline_color); X theta = M_PI * (float) (a->val - a->minval) X / (float) (a->maxval - a->minval); X theta = M_PI - theta; X x = xorg + radius * cos(theta); X y = yorg + radius * sin(theta); X linewidth(PNL_METER_LINEWIDTH); X move2(xorg,yorg); X draw2(x,y); X linewidth(oldwidth); X X color(pnl_outline_color); X rect(0.0, 0.0, a->w, a->h); X X popmatrix(); X if (a->label) drawlabel(a, p); X} X Xvoid X_drawanalogbar(a,p) XActuator *a; XPanel *p; X{ X float theta; X int dtheta; /* in tenths of degrees */ X Coord x, y; X Coord radius = (a->w / 2.0) - (2.0*PNL_DIM_2); X Coord xorg = a->w / 2.0; X Coord yorg = PNL_DIM_2; X long oldwidth = getlwidth(); X X pushmatrix(); X translate(a->x,a->y,0.0); X X color(pnl_other_color); X rectf(0.0, 0.0, a->w, a->h); X X color(pnl_normal_color); X arcf(xorg, yorg, radius, 0, 1800); X X color(pnl_highlight_color); X theta = M_PI * (float) (a->val - a->minval) X / (float) (a->maxval - a->minval); X theta = M_PI - theta; X dtheta = (int) (theta/M_PI*1800); X X arcf(xorg, yorg, radius, dtheta, 1800); SHAR_EOF echo "End of part 5, continue with part 6" echo "6" > s2_seq_.tmp exit 0 ------- Received: from smoke.brl.mil by VMB.BRL.MIL id ab28275; 3 Jan 89 19:17 EST Received: from orville.nas.nasa.gov by SMOKE.BRL.MIL id aa09399; 3 Jan 89 19:14 EST Received: Tue, 3 Jan 89 16:14:13 PST by orville.nas.nasa.gov (5.59/1.2) Date: Tue, 3 Jan 89 16:14:13 PST From: "David A. Tristram" Message-Id: <8901040014.AA02607@orville.nas.nasa.gov> To: info-iris@BRL.MIL Subject: panel06/06 #!/bin/sh # this is part 6 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file strip.c continued # CurArch=6 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 sed 's/^X//' << 'SHAR_EOF' >> strip.c X X color(pnl_outline_color); X x = xorg + radius * cos(theta); X y = yorg + radius * sin(theta); X linewidth(PNL_METER_LINEWIDTH); X move2(xorg,yorg); X draw2(x,y); X linewidth(oldwidth); X X color(pnl_outline_color); X arc(xorg, yorg, radius, 0, 1800); X move2(xorg,yorg); X rmv2(-radius,0.0); X rdr2(2.0*radius,0.0); X X color(pnl_outline_color); X rect(0.0, 0.0, a->w, a->h); X X popmatrix(); X if (a->label) drawlabel(a, p); X} X Xvoid X_drawstripchart(a,p) XActuator *a; XPanel *p; X{ X Coord x, y; X Actuator temp_act; X char temp_label[20]; X float xfactor, yfactor, yoffset, labelwidth; X Stripchart * dp = (Stripchart *)a->data; X int i; X long oldwidth = getlwidth(); X X X pushmatrix(); X labelwidth = strwidth(" ") * 8 / p->ppu; X translate(a->x,a->y,0.0); X X color(pnl_normal_color); X rectf(0.0, 0.0, a->w - labelwidth, a->h); X X color(pnl_outline_color); X X if (!dp->Bind_High || !dp->Bind_Low) X _setrange(a); X X if (dp->firstpt != dp->lastpt) { X xfactor = (a->w-labelwidth) / (PNL_STRIP_CHART_NPTS + 1); X yfactor = a->h / (a->maxval - a->minval); X yoffset = .03 * yfactor * ( a->maxval - a->minval); X yfactor = .94 * yfactor; X x = xfactor; X y = yoffset + X ((RANGE(dp->y[dp->firstpt],a->minval,a->maxval) - a->minval) * yfactor); X linewidth(PNL_STRIP_LINEWIDTH); X move2(x, y); X i = dp->firstpt + 1; X if (i >= PNL_STRIP_CHART_NPTS) i = 0; X while (i != dp->lastpt) { X x += xfactor; X y = yoffset X + ((RANGE(dp->y[i],a->minval,a->maxval) - a->minval) * yfactor); X draw2(x,y); X i++; X if (i >= PNL_STRIP_CHART_NPTS) i = 0; X } X linewidth(oldwidth); X } X X color(pnl_outline_color); X rect(0.0, 0.0, a->w-labelwidth, a->h); X X popmatrix(); X if (a->label) drawlabel(a, p); X X temp_act.labeltype = PNL_LABEL_RIGHT; X temp_act.label = temp_label; X X temp_act.x = a->x; X temp_act.y = a->y; X temp_act.lx = a->w -labelwidth + PNL_DIM_2; X temp_act.ly = 0.0; X sprintf(temp_label,"%.3g",a->minval); X temp_act.lw = labelwidth; X temp_act.lh = (float)getheight()/p->ppu; X temp_act.ld = (float)getdescender()/p->ppu; X drawlabel(&temp_act, p); X temp_act.ly = a->h - temp_act.lh; X sprintf(temp_label,"%.3g",a->maxval); X drawlabel(&temp_act, p); X} X Xvoid Xpnl_analog_meter(a) XActuator *a; X{ X a->type=PNL_ANALOG_METER; X X a->w=PNL_METER_WIDTH; X a->h=PNL_METER_HEIGHT; X a->labeltype=PNL_LABEL_BOTTOM; X a->selectable=FALSE; /* output actuator only */ X a->drawfunc=_drawanalogmeter; X} X Xvoid Xpnl_meter(a) XActuator *a; X{ X pnl_analog_meter(a); X a->type=PNL_METER; X} X Xvoid Xpnl_analog_bar(a) XActuator *a; X{ X pnl_analog_meter(a); X X a->type=PNL_ANALOG_BAR; X a->drawfunc=_drawanalogbar; X} X Xvoid Xpnl_strip_chart(a) XActuator *a; X{ X a->type=PNL_STRIP_CHART; X X a->w=PNL_STRIP_WIDTH; X a->h=PNL_STRIP_HEIGHT; X a->labeltype=PNL_LABEL_BOTTOM; X a->selectable=FALSE; /* output actuator only */ X a->data = alloc(sizeof(Stripchart)); X a->datasize=sizeof(Stripchart); X PNL_ACCESS(Stripchart, a, Bind_Low) = TRUE; X PNL_ACCESS(Stripchart, a, Bind_High) = TRUE; X a->addfunc=_addstripchart; X a->fixfunc=_fixstripchart; X a->newvalfunc=_newvalstripchart; X a->dumpfunc=_dumpstripchart; X a->drawfunc=_drawstripchart; X} X Xvoid Xpnl_scale_chart(a) XActuator *a; X{ X pnl_strip_chart(a); X X a->type=PNL_SCALE_CHART; X PNL_ACCESS(Stripchart, a, Bind_Low) = FALSE; X PNL_ACCESS(Stripchart, a, Bind_High) = FALSE; X} SHAR_EOF chmod 0644 strip.c || echo "restore of strip.c fails" sed 's/^X//' << 'SHAR_EOF' > typein.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include "panel.h" X Xvoid _newvaltypein(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ X if (!a->active) return; X X frontbuffer(TRUE); /* hack hack hack */ X (*a->drawfunc)(a,p); X frontbuffer(FALSE); X cmov2((Coord)(a->x+PNL_DIM_3), X (Coord)(a->y+PNL_DIM_3)+(Coord)getdescender()/p->ppu); X strcpy(PNL_ACCESS(Typein,a,str), X g_getstring(pnl_white_color, X pnl_highlight_color, X pnl_normal_color, X PNL_ACCESS(Typein,a,str), X PNL_ACCESS(Typein,a,len))); X#ifndef IRIS_4D X pnl_justup=TRUE; /* hack hack hack */ X setinactive(pnl_ca,pnl_cp); /* hackus maximus */ X X /* the 4d version of g_gets() seems to preserve mouse up events X better than the 3000 does */ X#endif IRIS_4D X} X Xvoid X_addtypein(a, p) XActuator *a; XPanel *p; X{ Xint len; Xchar *str = alloc(PNL_TYPEIN_MAX_STRING); X X if (PNL_ACCESS(Typein, a, str)) strcpy(str,PNL_ACCESS(Typein, a, str)); X PNL_ACCESS(Typein, a, str)=str; X X len = (PNL_ACCESS(Typein, a, len)? X PNL_ACCESS(Typein, a, len): X PNL_TYPEIN_LENGTH); X PNL_ACCESS(Typein, a, len)=len; X a->w=(float)len*(float)strwidth("a")/p->ppu+2.0*PNL_DIM_3; X a->h=2.0*PNL_DIM_3+(Coord)getheight()/p->ppu; X a->datasize=sizeof(Typein)+PNL_TYPEIN_MAX_STRING; X} X Xvoid _dumptypein(a, fd) XActuator *a; Xint fd; X{ XTypein *ad=(Typein *)a->data; Xstatic int msgtype=PNL_MT_STATE; X X write(fd, &msgtype, sizeof(msgtype)); X write(fd, &a->id, sizeof(a->id)); X write(fd, a, sizeof(Actuator)); X write(fd, &a->datasize, sizeof(int)); X write(fd, a->data, sizeof(Typein)); X write(fd, ad->str, PNL_TYPEIN_MAX_STRING); X} X Xvoid _loadtypein(a, fd) XActuator *a; Xint fd; X{ XTypein *ad=(Typein *)a->data; X X read(fd, a, sizeof(Actuator)); X read(fd, &a->datasize, sizeof(int)); X read(fd, a->data, sizeof(Typein)); X read(fd, ad->str, PNL_TYPEIN_MAX_STRING); X} X Xvoid X_drawtypein(a, p) XActuator *a; XPanel *p; X{ X if (a->active) color(pnl_highlight_color); X else color(pnl_normal_color); X rectf(a->x,a->y,a->x+a->w,a->y+a->h); X color(pnl_outline_color); X rect(a->x,a->y,a->x+a->w,a->y+a->h); X if (a->active) color(pnl_white_color); X else color(pnl_outline_color); X cmov2(a->x+PNL_DIM_3,a->y+PNL_DIM_3+(Coord)getdescender()/p->ppu); X charstr(PNL_ACCESS(Typein,a,str)); X if (a->label) drawlabel(a, p); X} X Xvoid Xpnl_typein(a) XActuator *a; X{ X a->type=PNL_TYPEIN; X X a->labeltype=PNL_LABEL_BOTTOM; X a->data = alloc(sizeof(Typein)); X a->datasize=sizeof(Typein); X PNL_ACCESS(Typein, a, len) = 0; X PNL_ACCESS(Typein, a, str) = ""; X a->addfunc=_addtypein; X a->newvalfunc=_newvaltypein; X a->dumpfunc=_dumptypein; X a->drawfunc=_drawtypein; X} X X/* X * this _drawlabel() draws the label actuator, not to be confused with X * drawlabel() that draws labels for every kind of actuator, (including, X * of course, label actuators). X * X */ X Xvoid X_drawlabel(a, p) XActuator *a; XPanel *p; X{ XScreencoord tx1,ty1,tx2,ty2; X X color(pnl_background_color); X rectf(a->x,a->y,a->x+a->w,a->y+a->h); X if (a->label) drawlabel(a, p); X} X Xvoid Xpnl_label(a) XActuator *a; X{ X a->type=PNL_LABEL; X X a->labeltype=PNL_LABEL_NORMAL; X a->drawfunc=_drawlabel; X} X SHAR_EOF chmod 0644 typein.c || echo "restore of typein.c fails" sed 's/^X//' << 'SHAR_EOF' > typeout.c && X/* X * this software is in the public domain, it may not be resold X * or relicensed. Do not remove this notice. Send modifications X * and requests for most recent version to: X * X * Author: David A. Tristram X * NASA Ames Research Center X * MS 258-5 X * Moffett Field, CA 94035 X * 415-694-4404 X * dat@orville.nas.nasa.gov X */ X#include X#include X#include X#include "panel.h" X Xchar X*_forwardline(a,p) XActuator *a; Xchar *p; X{ XTypeout *ad=(Typeout *)a->data; Xchar *q=p; X X p+=strcspn(p,"\n"); X if (p-q>ad->col) { X p-=(p-q)%ad->col; X } X if (*p=='\n') p++; X return p; X} X Xchar X*_backline(a,p) XActuator *a; Xchar *p; X{ XTypeout *ad=(Typeout *)a->data; Xchar *q=p; Xchar *r; Xint c; X X if (p==ad->buf) return p; X X if (*(p-1)=='\n'&&p!=ad->buf+1) p-=2; X for (;;p--) { X if (p<=ad->buf) break; X if (*p=='\n') { X p++; X break; X } X if (q-p>ad->col) { /* wrapped line */ X/* X count chars to previous newline or bob, X take that count mod line length to find chars from left margin X back up that amount, unless its 0, otherwise back up line length. X*/ X for (r=p;r>ad->buf&&*r!='\n';r--); X c=(p-r)%ad->col; X if (c) p=q-c; X else p=q-ad->col; X break; X } X } X return p; X} X Xscrollup(a) XActuator *a; X{ XTypeout *ad=(Typeout *)a->data; Xchar *s=ad->buf+ad->start; Xint n; X X/* if (*(ad->buf+ad->start)>ad->len) return; */ X s=_forwardline(a, ad->buf+ad->start); X ad->start=s-ad->buf; X return; X} X Xscrolldown(a) XActuator *a; X{ Xint n; XTypeout *ad=(Typeout *)a->data; Xchar *s=ad->buf+ad->start; X X if (s-ad->buf<2) return; X n=2; X while (s-n>ad->buf&&*(s-n)!='\n') n++; X if (n==ad->start) n++; /* pointing to first char */ X if (ncol+2) { /* regular line */ X ad->start-=n-1; X } else { /* wrapped line */ X ad->start-=n-ad->col-1; X } X} X Xint X_linelen(a,p) XActuator *a; Xchar *p; X{ XTypeout *ad=(Typeout *)a->data; Xint i; Xchar *q=p; X X while (pbuf+ad->len&&*p!='\n') p++; X return p-q; X} X Xint X_postopnt(a,x,y) XActuator *a; Xint x,y; X{ XTypeout *ad=(Typeout *)a->data; Xint i; Xchar *p,*q; X X p=q=ad->buf+ad->start; X X for (i=0;idata; Xint i; Xchar *p,*q,*r; X X *x= *y=0; X p=q=r=ad->buf+ad->start; X X while (p-q<=pnt) { X if (r==(p=_forwardline(a,p))) break; X /* in case p doesn't move */ X (*y)++; X r=p; X } X p=_backline(a,p); X *y=MAX(0,*y-1); X *x=pnt-(p-q); X} X Xvoid Xtprint(a,s) XActuator *a; Xchar *s; X{ XTypeout *ad=(Typeout *)a->data; Xchar *p; Xint c=0; X X if (a->type!=PNL_TYPEOUT) { X fprintf(stderr, "tprint: actuator"); X if (a->label) fprintf(stderr, " %s", a->label); X fprintf(stderr," not a typeout\n"); X return; X } X X ad->dot=ad->len; X for (p=ad->buf+ad->dot;p>ad->buf&&clin;p--) { X if (*p=='\n') c++; X } X ad->start=MAX(0,p-ad->buf); X if (ad->start!=0) ad->start+=2; X X if (strlen(s)+1>ad->size) { X tprint(a,"tprint: That message was too long!"); X return; X } X X if (ad->dot+strlen(s)+1>ad->size) { X ad->dot=0; X } X X sprintf(ad->buf+ad->dot,"%s\n",s); X ad->dot+=strlen(s)+1; X *(ad->buf+ad->dot)='\0'; X X fixact(a); X} X Xvoid _newvaltypeout(a,p,sx,sy) XActuator *a; XPanel *p; XScreencoord sx,sy; X{ Xint n; Xfloat f; XTypeout *ad=(Typeout *)a->data; XCoord xorg,yorg; /* origin of top left text position */ XCoord wx, wy; Xint tx, ty; /* text position, increasing downwards */ X X if (!a->active) return; X X xorg=a->x+PNL_DIM_3; X yorg=a->y+PNL_DIM_3+ad->cd X +(ad->lin-1)*ad->ch; X X mapw2(p->vobj,sx,sy,&wx,&wy); X X if (wx>a->x+a->w-PNL_SCROLL_WIDTH) { /* in scrollbar */ X if (wyy+PNL_TYPEOUT_ARROW_HEIGHT) { /* lower arrow */ X/* if (!pnl_justdown) return; */ X scrollup(a); X } else if (wy>a->y+a->h-PNL_TYPEOUT_ARROW_HEIGHT) { /* upper arrow */ X/* if (!pnl_justdown) return; */ X scrolldown(a); X } else { /* elevator region */ X f=1.0-(wy-a->y-PNL_TYPEOUT_ARROW_HEIGHT) X /(a->h-2.0*PNL_TYPEOUT_ARROW_HEIGHT); X n=f*ad->len; X while (n>0&&*(ad->buf+n-1)!='\n') n--; X ad->start=n; X } X } else { /* in typeout region */ X tx=(wx-xorg)/ad->cw; X ty=(yorg-wy)/ad->ch+1.0; X tx=RANGE(tx,0,ad->col-1); X ty=RANGE(ty,0,ad->lin-1); X ad->dot=ad->start+_postopnt(a,tx,ty); X/* printf("tx=%d, ty=%d, dot=%d\n",tx,ty,ad->dot); */ X } X} X Xvoid X_fixtypeout(a) XActuator *a; X{ XTypeout *ad=(Typeout *)a->data; X X ad->len=strlen(ad->buf); X a->datasize=sizeof(Typeout)+ad->len; X a->dirtycnt=2; X} X Xvoid X_addtypeout(a, p) XActuator *a; XPanel *p; X{ XTypeout *ad=(Typeout *)a->data; Xint col,lin; X X ad->size = (ad->size?ad->size:PNL_TYPEOUT_BUFSIZ); X ad->buf=alloc(ad->size); X X col = (ad->col?ad->col:PNL_TYPEOUT_COLUMNS); X ad->col=col; X lin = (ad->lin?ad->lin:PNL_TYPEOUT_LINES); X ad->lin=lin; X X ad->cw=(Coord)strwidth("M")/p->ppu; X ad->ch=(Coord)getheight()/p->ppu; X ad->cd=(Coord)getdescender()/p->ppu; X a->w=(Coord)col*ad->cw+2.0*PNL_DIM_3+PNL_SCROLL_WIDTH; X a->h=(Coord)lin*ad->ch+2.0*PNL_DIM_3; X X _fixtypeout(a); X} X Xvoid _dumptypeout(a, fd) XActuator *a; Xint fd; X{ XTypeout *ad=(Typeout *)a->data; Xstatic int msgtype=PNL_MT_STATE; X X write(fd, &msgtype, sizeof(msgtype)); X write(fd, &a->id, sizeof(a->id)); X write(fd, a, sizeof(Actuator)); X write(fd, &a->datasize, sizeof(int)); X write(fd, a->data, sizeof(Typeout)); X write(fd, ad->buf, ad->len); X} X Xvoid _loadtypeout(a, fd) XActuator *a; Xint fd; X{ XTypeout *ad=(Typeout *)a->data; X X read(fd, a, sizeof(Actuator)); X read(fd, &a->datasize, sizeof(int)); X read(fd, a->data, sizeof(Typeout)); X read(fd, ad->buf, ad->len); X} X Xvoid X_drawscrollarrow() X{ X pmv2(PNL_TYPEOUT_ARROW_HEIGHT, PNL_DIM_3); X pdr2(PNL_DIM_3, PNL_TYPEOUT_ARROW_HEIGHT-PNL_DIM_3); X pdr2(PNL_SCROLL_WIDTH-PNL_DIM_3, PNL_TYPEOUT_ARROW_HEIGHT-PNL_DIM_3); X pclos(); X} X X_drawelevator(a, p, style) XActuator *a; XPanel *p; Xint style; X{ XTypeout *ad=(Typeout *)a->data; XCoord y; X X pushmatrix(); X translate(a->x+a->w-PNL_SCROLL_WIDTH, X a->y+PNL_TYPEOUT_ARROW_HEIGHT, X 0.0); X y=1.0-(float)ad->start/(float)ad->len; X y*=a->h-2.0*PNL_TYPEOUT_ARROW_HEIGHT-PNL_DIM_2; X if (style==PNL_FILLED) X rectf(0.0,y,PNL_SCROLL_WIDTH,y+PNL_DIM_2); X else X rect(0.0,y,PNL_SCROLL_WIDTH,y+PNL_DIM_2); X popmatrix(); X} X Xvoid X_drawcursor(a, tx, ty) XActuator *a; Xint tx, ty; X{ Xstatic char *s="M"; XTypeout *ad=(Typeout *)a->data; X X pushmatrix(); X translate(tx*ad->cw,-ty*ad->ch-ad->cd,0.0); X color(pnl_highlight_color); X rectf(0.0,0.0,ad->cw,ad->ch); X color(pnl_white_color); X cmov2(0.0,ad->cd); X sprintf(s, "%c", *(ad->buf+ad->dot)); X charstr(s); X popmatrix(); X} X Xvoid X_drawtypeout(a, p) XActuator *a; XPanel *p; X{ Xint n, l=0; /* upper left corner is col 0, lin 0. */ XCoord xorg, yorg; /* origin of first char position */ Xint tx,ty; Xchar *s, t[PNL_TYPEOUT_MAX_COLUMNS], *end; XTypeout *ad=(Typeout *)a->data; X X xorg=a->x+PNL_DIM_3; X yorg=a->y+PNL_DIM_3+ad->cd X +(ad->lin-1)*ad->ch; X X color(pnl_normal_color); X rectf(a->x,a->y,a->x+a->w,a->y+a->h); X color(pnl_outline_color); X rect(a->x,a->y,a->x+a->w,a->y+a->h); X rect(a->x+a->w-PNL_SCROLL_WIDTH, a->y, a->x+a->w, a->y+a->h); X rect(a->x+a->w-PNL_SCROLL_WIDTH, a->y+PNL_TYPEOUT_ARROW_HEIGHT, X a->x+a->w, a->y+a->h-PNL_TYPEOUT_ARROW_HEIGHT); X X color(pnl_highlight_color); X _drawelevator(a, p, PNL_FILLED); X color(pnl_outline_color); X _drawelevator(a, p, PNL_OPEN); X X color(pnl_outline_color); X pushmatrix(); X translate(a->x+a->w-PNL_SCROLL_WIDTH, a->y, 0.0); X _drawscrollarrow(); X translate(0.0, a->h, 0.0); X scale(1.0, -1.0, 1.0); X _drawscrollarrow(); X popmatrix(); X X s=ad->buf+ad->start; X/* end=s+strlen(s); /* waste of time? */ X end=ad->buf+ad->len; X X do { X if ((n=strcspn(s, "\n"))col) { X strncpy(t, s, n); X t[n]='\0'; X s+=strlen(t)+1; X } else { X strncpy(t, s, ad->col); X t[ad->col]='\0'; X s+=ad->col; X } X cmov2(xorg,yorg-(Coord)l*ad->ch); X charstr(t); X l++; X } while (slin); X X if (ad->dot>=ad->start) { X _pnttopos(a,ad->dot-ad->start,&tx,&ty); X if (tylin) { X pushmatrix(); X translate(xorg,yorg,0.0); X _drawcursor(a,tx,ty); X popmatrix(); X } X } X/* printf("dot=%d, tx=%d, ty=%d\n",ad->dot,tx,ty); */ X X if (a->label) drawlabel(a, p); X} X Xvoid Xpnl_typeout(a) XActuator *a; X{ XTypeout *ad; X X a->type=PNL_TYPEOUT; X X a->labeltype=PNL_LABEL_BOTTOM; X a->data = alloc(sizeof(Typeout)); X a->datasize=sizeof(Typeout); X ad=(Typeout *)a->data; X ad->buf = NULL; X ad->lin = 0; X ad->col = 0; X ad->start = 0; X ad->dot = 0; X ad->len = 0; X a->addfunc=_addtypeout; X a->newvalfunc=_newvaltypeout; X a->fixfunc=_fixtypeout; X a->dumpfunc=_dumptypeout; X a->drawfunc=_drawtypeout; X} X SHAR_EOF chmod 0644 typeout.c || echo "restore of typeout.c fails" rm -f s2_seq_.tmp echo "You have unpacked the last part" exit 0