spe@spice.cs.cmu.edu (Sean Engelson) (05/24/88)
I'm having some trouble getting input to work in a simple NeWS program I'm writing. I have a program that draws a colour 3d representation of a cube, and I want to be able to click on and drag the sides of the cube to change its size. The program I wrote (using C and CPS) is below. For some reason, when I run it, after (or while) the event manager is forked, my canvas disappears and things are frozen. Can anyone please tell me what I'm doing wrong? I used go.cps as my model. Thanks, Sean Engelson Computer Science Dept. Carnegie-Mellon University Sean.Engelson@Cs.Cmu.Edu Please excuse the debugging code... -- vox.cps --- cdef init_server() /brk { pop } def % /brk { dbgbreak } def /width -20 def /height -20 def /thick 30 def /x { 190 thick sub } def /y { x } def /blue 0.4 0 1 rgbcolor def /yellow 1 1 0 rgbcolor def /red 1 0 0.4 rgbcolor def /dragging false def /repaintFront { gsave blue setcolor x y moveto width height rect fill grestore } def /repaintTop { gsave yellow setcolor x y moveto thick thick rlineto width 0 rlineto thick neg dup rlineto width neg 0 rlineto fill grestore } def /repaintSide { gsave red setcolor x y moveto thick thick rlineto 0 height rlineto thick neg dup rlineto 0 height neg rlineto fill grestore } def /repaintAll { 1 fillcanvas 1 200 div dup scale repaintFront repaintTop repaintSide } def /StartMove { /dragging true store /face XLocation x width add lt YLocation y height add lt and % if (MouseX < x + width) & (MouseY < y + height) { /thick } % We want to look at thick { /normX XLocation x width add sub def /normY YLocation y height add sub def normX normY lt { /matrix } { /fov } ifelse } ifelse store } def /EndMove { /dragging false store } def /MaybeDragMouse { begin dragging { face /fov eq { /width x XLocation sub store } if face /matrix eq { /height y YLocation sub store } if face /thick eq { /thick XLocation dup times YLocation dup times add sqrt store } if } if end } def /downeventinterest {/DownTransition ClientCanvas eventmgrinterest} def /upeventinterest {/UpTransition ClientCanvas eventmgrinterest} def /nulleventinterest {null ClientCanvas eventmgrinterest} def /startinput { /ButtonMgr [ /LeftMouseButton { StartMove } downeventinterest /LeftMouseButton { EndMove } upeventinterest /MouseDragged { MaybeDragMouse } nulleventinterest ] forkeventmgr store } def /makewin { /VoxWin DefaultWindow % New subclass dictbegin /FrameLabel (Voxel Volume) def /ButtonMgr null def dictend classbegin /PaintClient { clippath pathbbox scale repaintAll } def % /DestroyClient { % ButtonMgr killprocess % } def /ForkFrameEventMgr { /ForkFrameEventMgr super send (Forking eventmgr\n) [] dbgprintf /mine brk startinput } def classend def (Done defing\n) [] dbgprintf /mine brk /win framebuffer /new VoxWin send def (created window\n) [] dbgprintf /mine brk /reshapefromuser win send (reshaped window\n) [] dbgprintf /mine brk /map win send (Done initing\n) [] dbgprintf /mine brk } def cdef redraw_vox() /paintclient win send cdef set_vox(w, h, th) /width w neg store /height h neg store /thick th store /paintclient win send cdef make_vox() makewin (Done making\n) [] dbgprintf /mine brk -- vox.c --- #include "psio.h" #include "vox.h" main() { int i; init_voxel(); printf("inited\n"); i = 40; while ( !psio_error(PostScriptInput)) { set_vox(i, i, i); i += 2; if (i = 200) i = 60; } } init_voxel() { ps_open_PostScript(); printf("opened\n"); init_server(); printf("servered\n"); make_vox(); } set_voxel(w, h, th) int w, h, th; { set_vox(w, h, th); } -- Sean Philip Engelson I have no opinions. Carnegie-Mellon University Therefore my employer is mine. Computer Science Department ---------------------------------------------------------------------- My opinions are my own, and do not reflect official policy, either explicit or implied, of the Carnegie-Mellon University Computer Science Department. ---------------------------------------------------------------------- ARPA: spe@spice.cs.cmu.edu UUCP: {harvard | seismo | ucbvax}!spice.cs.cmu.edu!spe