diff --git a/books/bookvol8.pamphlet b/books/bookvol8.pamphlet index 8830367..3cf1cd5 100644 --- a/books/bookvol8.pamphlet +++ b/books/bookvol8.pamphlet @@ -1031,17 +1031,29 @@ However, the moColor macro IS used but not included. */ #define refPt3D(v,x) ( (x)>(v).numOfPoints?traverse(resMax - ((x)-((v).numOfPoints-1))):(v).points + (x) ) +@ +\index{componentProp struct} +\index{struct!componentProp} +<>= typedef struct _componentProp { int closed, solid; } componentProp; +@ +\index{struct!LPoint} +\index{LPoint struct} +<>= typedef struct _LPoint { /* meaning list of points */ componentProp prop; int numOfPoints; int *indices; } LPoint; +@ +\index{struct!LLPoint} +\index{LLPoint struct} +<>= typedef struct _LLPoint { /* meaning list of list of points */ /* for the current 3D stuff: functions of 2 variables - closed is false (xmax does not close @@ -1055,6 +1067,10 @@ typedef struct _LLPoint { /* meaning list of list of points */ } LLPoint; +@ +\index{struct!LLLPoint} +\index{LLLPoint struct} +<>= typedef struct _LLLPoint { /* meaning list of list of list of points */ /* for the current 3D stuff -- that is functions of 2 variables and parametric surfaces of one variable (tubes) -- there would be @@ -1113,6 +1129,12 @@ typedef struct _LLLPoint { /* meaning list of list of list of points */ * This is used to keep track of GC name in character and in unsigned long */ +@ +\index{struct!GCstruct} +\index{GCstruct struct} +\index{struct!GCptr} +\index{GCptr struct} +<>= typedef struct _GCstruct { GC GCint; char GCchar[10]; @@ -1140,6 +1162,10 @@ extern GCptr GChead; /* Points to the head of GCstruct linked list. */ /* Used in XDraw and XDrawFilled */ +@ +\index{struct!Vertex} +\index{Vertex struct} +<>= typedef struct _Vertex { short x, y; unsigned short flags; @@ -1158,11 +1184,13 @@ typedef struct _Vertex { XDrawFilled so it shouldn't be defined. */ -/* - XAssoc - Associations used in the XAssocTable data structure. The - associations are used as circular queue entries in the association table - which is contains an array of circular queues (buckets). - */ +@ +{\tt XAssoc} - Associations used in the XAssocTable data structure. The +associations are used as circular queue entries in the association table +which is contains an array of circular queues (buckets). +\index{struct!XAssoc} +\index{XAssoc struct} +<>= typedef struct _XAssoc { struct _XAssoc *next; /* Next object in this bucket. */ struct _XAssoc *prev; /* Previous obejct in this bucket. */ @@ -1171,15 +1199,17 @@ typedef struct _XAssoc { char *data; /* Pointer to untyped memory. */ } XAssoc; -/* - XAssocTable - X Window System id to data structure pointer association - table. An XAssocTable is a hash table whose buckets are circular - queues of XAssoc's. The XAssocTable is constructed from an array of - XAssoc's which are the circular queue headers (bucket headers). - An XAssocTable consists an XAssoc pointer that points to the first - bucket in the bucket array and an integer that indicates the number - of buckets in the array. - */ +@ +{\tt XAssocTable} - X Window System id to data structure pointer association +table. An XAssocTable is a hash table whose buckets are circular +queues of XAssoc's. The XAssocTable is constructed from an array of +XAssoc's which are the circular queue headers (bucket headers). +An XAssocTable consists an XAssoc pointer that points to the first +bucket in the bucket array and an integer that indicates the number +of buckets in the array. +\index{struct!XAssocTable} +\index{XAssocTable struct} +<>= typedef struct _XAssocTable { XAssoc **buckets; /* Pointer to first bucket in bucket array.*/ int size; /* Table size (number of buckets). */ @@ -1204,15 +1234,25 @@ typedef struct _XAssocTable { @ \section{rgb.h} +\index{struct!RGB} +\index{RGB struct} <>= typedef struct _RGB { float r,g,b; } RGB ; +@ +\index{struct!HSV} +\index{HSV struct} +<>= typedef struct _HSV { float h,s,v; } HSV ; +@ +\index{struct!HLS} +\index{HLS struct} +<>= typedef struct _HLS { float h,l,s; } HLS ; @@ -1258,12 +1298,22 @@ extern int scrn; #define openTube 1 #define closedTube 0 +@ +\index{struct!triple} +\index{triple struct} +<>= typedef struct _triple { /* used for normals */ float x,y,z; } triple; <> +@ +\index{struct!viewTriple} +\index{viewTriple struct} +\index{struct!viewTriplePtr} +\index{viewTriplePtr struct} +<>= typedef struct _viewTriple { /* used for points in 3 space */ float x,y,z,c,sc; /* c is color component */ float wx,wy,wz; /* world space coords */ @@ -1283,7 +1333,10 @@ typedef struct _viewTriple { /* used for points in 3 space */ #define polygonComponent 3 #define surfaceComponent 4 - +@ +\index{struct!poly} +\index{poly struct} +<>= typedef struct _poly { int num, sortNum, split; /* how many times the polygon's been split */ @@ -1305,21 +1358,30 @@ typedef struct _poly { partialClipPz, totalClipPz; } poly; - +@ +\index{struct!polyList} +\index{polyList struct} +<>= typedef struct _polyList { int numPolys; poly *polyIndx; struct _polyList *next; } polyList; - +@ +\index{struct!slice} +\index{slice struct} +<>= typedef struct _slice { int keyoffset; viewTriple *points; struct _slice *next; } slice; - +@ +\index{struct!tubeModel} +\index{tubeModel struct} +<>= typedef struct _tubeModel { /* numslices are the number of pts on the curve */ int numslices, slicepts, numPolygons; @@ -1328,7 +1390,10 @@ typedef struct _tubeModel { poly *polygons; } tubeModel; - +@ +\index{struct!pointInfo} +\index{pointInfo struct} +<>= typedef struct _pointInfo { viewTriple *theVT; int onVertex,segmentNum; @@ -1341,7 +1406,10 @@ typedef struct _pointInfo { #include #define maxGraphs 9 - +@ +\index{struct!viewManager} +\index{viewManager struct} +<>= typedef struct _viewManager { int viewType, /* specifies view3d, view2d, etc... */ PID, /* unique integer greater than zero */ @@ -1352,17 +1420,27 @@ typedef struct _viewManager { struct _viewManager *nextViewport; } viewManager; +@ +\index{struct!viewWithThisGraph} +\index{viewWithThisGraph struct} +<>= typedef struct _viewsWithThisGraph { viewManager *viewGr; struct _viewsWithThisGraph *nextViewthing; } viewsWithThisGraph; - +@ +\index{struct!pointStruct} +\index{pointStruct struct} +<>= typedef struct _pointStruct { float x,y,hue,shade; } pointStruct; - +@ +\index{struct!pointListStruct} +\index{pointListStruct struct} +<>= typedef struct _pointListStruct { pointStruct *listOfPoints; float hue, shade; @@ -1370,7 +1448,10 @@ typedef struct _pointListStruct { numberOfPoints; } pointListStruct; - +@ +\index{struct!graphStruct} +\index{graphStruct struct} +<>= typedef struct _graphStruct { int key; float xmin,xmax,ymin,ymax; @@ -1384,7 +1465,10 @@ typedef struct _graphStruct { struct _graphStruct *nextGraph; } graphStruct; - +@ +\index{struct!view2DStruct} +\index{view2DStruct struct} +<>= typedef struct _view2DStruct { char *title; int vX,vY,vW,vH, @@ -1394,7 +1478,10 @@ typedef struct _view2DStruct { int graphKeyArray[maxGraphs]; } view2DStruct; - +@ +\index{struct!graphStateStruct} +\index{graphStateStruct struct} +<>= typedef struct _graphStateStruct { float scaleX, scaleY, deltaX, deltaY, centerX, centerY; int pointsOn, connectOn, splineOn, axesOn, unitsOn, @@ -1403,7 +1490,6 @@ typedef struct _graphStateStruct { View2D initializes them */ } graphStateStruct; - /* need spline color, axes color, units color... */ @ \section{view3d.h} @@ -1415,17 +1501,28 @@ typedef struct _graphStateStruct { */ #define maxGraphs 9 +@ +\index{struct!fun2VarModel} +\index{fun2VarModel struct} +<>= typedef struct _fun2VarModel { float *zArray,*cArray; viewTriple *pointList; } fun2VarModel; +@ +\index{union!kindOf} +<>= union kindOf { /* float *zArray; */ fun2VarModel fun2Var; tubeModel tube; }; +@ +\index{struct!view3DStruct} +\index{view3DStruct struct} +<>= typedef struct _view3DStruct { int typeOf3D; float xmin,xmax,ymin,ymax,zmin,zmax; @@ -1466,8 +1563,11 @@ typedef struct _view3DStruct { */ } view3DStruct; - -/* for drawing the region box */ +@ +\index{struct!boxSideStruct} +\index{boxSideStruct struct} +for drawing the region box +<>= typedef struct _boxSideStruct { viewTriplePtr pointsPtr[4]; /* see notes for definition of box */ int inside; @@ -1680,68 +1780,120 @@ static char volumeMask_bits[] = { \chapter{viewman} \label{viewman} -\subsection{cleanup.c} -<>= -#define _CLEANUP_C +<>= + /* Viewport Commands */ +#define makeViewport -1 +#define makeGraph -1 +#define check(code) checker(code,__LINE__,"") +#define maxConnect 40 +#define intSize sizeof(int) +#define floatSize sizeof(float) +#define yes 1 +#define no 0 +#define writeEach +#define components +#define spadActionMode -#include -#include -#include +#include +#ifdef SGIplatform +#include +#endif +#include #if !defined(BSDplatform) #include #endif -#include #include +#include +#include +#include +#include #include +#include -<> <> +<> +<> +<> +#include "bsdsignal.h" +#include "bsdsignal.h1" +#include "com.h" +#include "sockio-c.h1" #include "util.h1" -extern void brokenPipe(int sig); -extern void endChild(int sig); -extern void rmViewMgr(viewManager * slotPtr); -extern void closeChildViewport(viewManager * slotPtr); -extern void goodbye(int sig); -extern graphStruct * makeGraphFromSpadData(void); -extern void discardGraph(graphStruct * theGraph); -extern int readViewport(viewManager * viewPort , void * info , int size); +extern int acknow; +extern int checkClosedChild; +extern int currentGraph; +extern graphStateStruct currentGraphState; +extern int defDsply; +extern Display *dsply; +extern fd_set filedes; +extern int foundBrokenPipe; +extern int graphKey; +extern graphStruct *graphList; +extern int picked; +extern char propertyBuffer[]; +extern Window root; +extern char *s1; +extern viewManager *slot; +extern Sock *spadSock; +extern viewManager *stepSlot; +extern int viewCommand; +extern XEvent viewmanEvent; +extern int viewError; +extern int viewOkay; +extern viewManager *viewports; +extern int viewType; + -void -brokenPipe(int sig) -{ - fprintf(stderr, - "The viewport manager tried to write to a non-existing pipe.\n"); -} +/************* global variables **************/ +Display *dsply; +Window root; +XEvent viewmanEvent; +viewManager *viewports, + *slot, + *stepSlot; +Sock *spadSock; +int viewType, + viewCommand, + acknow, + graphKey = 1, + defDsply, + currentGraph, + picked = no, + viewOkay = 0, + viewError = -1, + checkClosedChild = no, + foundBrokenPipe = no; +fd_set filedes; +graphStruct *graphList; +graphStateStruct currentGraphState; +char *s1, + propertyBuffer[256];/* XProperty buffer */ -void -endChild(int sig) -{ +@ +\subsection{endChild} +\index{viewman!endChild} +\index{endChild viewman} +<>= +void endChild(int sig) { checkClosedChild = yes; } - -/**************************** - * void rmViewMgr(slotPtr) * - * * - * given a pointer to a * - * viewManager, this * - * procedure removes it * - * from the viewport list * -*****************************/ - -void -rmViewMgr(viewManager *slotPtr) -{ - +@ +\subsection{rmViewMgr} +Given a pointer to a viewManager, this procedure removes it +from the viewport list. +\index{viewman!rmViewMgr} +\index{rmViewMgr viewman} +<>= +void rmViewMgr(viewManager *slotPtr) { int i,throwAway,code; viewManager *somePort, *someOtherPort; graphStruct *someGraph,*someOtherGraph; /* used in discarding graphs */ viewsWithThisGraph *someView,*someOtherView; - for (somePort=someOtherPort=viewports; (somePort != 0) && (somePort != slotPtr); somePort=(someOtherPort=somePort)->nextViewport) @@ -1749,7 +1901,6 @@ rmViewMgr(viewManager *slotPtr) assert ((somePort == 0) || (somePort == viewports) || (somePort == someOtherPort->nextViewport)); - if (somePort) { if (somePort == viewports) viewports=viewports->nextViewport; else someOtherPort->nextViewport = somePort->nextViewport; @@ -1757,7 +1908,8 @@ rmViewMgr(viewManager *slotPtr) /*** if view2d, then clean up after the graphs as well ***/ if (slotPtr->viewType == view2DType) { for (i=0; inextGraph)); - if (someGraph) { /* if found (should always be true) */ - for(someView=someOtherView=someGraph->views; (someView !=0 ) && (someView->viewGr != slotPtr); someView=(someOtherView=someView)->nextViewthing) @@ -1794,7 +1944,8 @@ rmViewMgr(viewManager *slotPtr) free(someView); /* remove this viewport from list */ } - /* if now nothing is pointing to this graph , remove the graph from the list*/ + /* if now nothing is pointing to this graph */ + /* remove the graph from the list*/ if (someGraph->views == 0) { if (someGraph == graphList) graphList = graphList->nextGraph; @@ -1811,43 +1962,28 @@ rmViewMgr(viewManager *slotPtr) free(slotPtr); } /* rmViewMgr() */ - -/*********************************** - * int closeChildViewport(slotPtr) * - * * - * given a pointer to a viewport * - * structure (viewManager) this * - * procedure first waits for the * - * actual process to die and then * - * removes it from the list of * - * viewports via rmViewMgr(). * - ***********************************/ - -void -closeChildViewport(viewManager *slotPtr) -{ - +@ +\subsection{closeChildViewport} +Given a pointer to a viewport structure (viewManager) this +procedure first waits for the actual process to die and then +removes it from the list of viewports via rmViewMgr(). +\index{viewman!closeChildViewport} +\index{closeChildViewport viewman} +<>= +void closeChildViewport(viewManager *slotPtr) { int status; rmViewMgr(slotPtr); wait(&status); - } /* closeChildViewport */ - -/********************* - * int goodbye() * - * * - * kill all children * - * (how mean) and * - * then kill self. * - *********************/ - -void -goodbye(int sig) -{ - +@ +\subsection{goodbye} +Kill all children (how mean) and then kill self. +\index{viewman!goodbye} +\index{goodbye viewman} +<>= +void goodbye(int sig) { viewManager *v; - v = viewports; while (v) { kill(v->PID,SIGTERM); @@ -1855,64 +1991,28 @@ goodbye(int sig) v = v->nextViewport; } exit(0); - } - - - @ -\subsection{fun2d.c} -<>= -#define _FUN2D_C - -#include -#include -#include -#include - - - -<> -<> - -#include "util.h1" -#include "sockio-c.h1" -extern void funView2D(int viewCommand); -extern void sendGraphToView2D(int i ,int there,viewManager * viewType, - graphStateStruct * doGraphStateArray); -extern void forkView2D(void); -extern int readViewport(viewManager * viewPort , void * info , int size); -extern void makeView2DFromSpadData(view2DStruct * viewdata , - graphStateStruct graphState[]); - -#define writeEach - -void -funView2D(int viewCommand) -{ - +\subsection{funView2D} +\index{viewman!funView2D} +\index{funView2D viewman} +<>= +void funView2D(int viewCommand) { int code; int viewPID; float f1,f2; int i1,i2,i3; viewManager *viewport; - viewPID = get_int(spadSock); - - viewport = viewports; while ((viewport) && (viewport->PID != viewPID)) { viewport = viewport->nextViewport; } - if (viewport) { send_int(spadSock,1); /* acknowledge to spad */ code = write(viewport->viewOut,&viewCommand,intSize); - - switch (viewCommand) { - case putGraph: i1 = get_int(spadSock); /* graph key */ i2 = get_int(spadSock); /* viewport slot 1..9 */ @@ -1924,7 +2024,6 @@ funView2D(int viewCommand) sendGraphToView2D(0,i1,viewport,¤tGraphState); break; - case translate2D: i1 = get_int(spadSock); /* graph index */ f1 = get_float(spadSock); /* translate in the x direction */ @@ -1933,7 +2032,6 @@ funView2D(int viewCommand) code = write(viewport->viewOut,&f1,floatSize); code = write(viewport->viewOut,&f2,floatSize); break; - case scale2D: i1 = get_int(spadSock); /* graph index */ f1 = get_float(spadSock); /* scale in the x direction */ @@ -1942,12 +2040,10 @@ funView2D(int viewCommand) code = write(viewport->viewOut,&f1,floatSize); code = write(viewport->viewOut,&f2,floatSize); break; - case hideControl2D: i1 = get_int(spadSock); code = write(viewport->viewOut,&i1,intSize); break; - case axesOnOff2D: case unitsOnOff2D: case connectOnOff: @@ -1959,7 +2055,6 @@ funView2D(int viewCommand) code = write(viewport->viewOut,&i1,intSize); code = write(viewport->viewOut,&i2,intSize); break; - case moveViewport: case resizeViewport: i1 = get_int(spadSock); @@ -1967,14 +2062,12 @@ funView2D(int viewCommand) code = write(viewport->viewOut,&i1,intSize); code = write(viewport->viewOut,&i2,intSize); break; - case changeTitle: s1 = get_string(spadSock); i1 = strlen(s1); code = write(viewport->viewOut,&i1,intSize); code = write(viewport->viewOut,s1,i1); break; - case writeView: s1 = get_string(spadSock); i1 = strlen(s1); @@ -1988,12 +2081,10 @@ funView2D(int viewCommand) code = write(viewport->viewOut,&i2,intSize); } break; - case spadPressedAButton: i1 = get_int(spadSock); code = write(viewport->viewOut,&i1,intSize); break; - } /* switch */ /*** get acknowledge from viewport */ code = readViewport(viewport,&acknow,intSize); @@ -2001,13 +2092,14 @@ funView2D(int viewCommand) } else { send_int(spadSock,-1); /* send error value in acknowledge to spad */ } - } -void -forkView2D(void) -{ - +@ +\subsection{forkView2D} +\index{viewman!forkView2D} +\index{forkView2D viewman} +<>= +void forkView2D(void) { viewManager *viewport; int childPID, code; int i; @@ -2015,27 +2107,21 @@ forkView2D(void) graphStateStruct doGraphStateArray[maxGraphs]; int there; int pipe0[2], pipe1[2]; - char envAXIOM[100],runView[100]; - #ifdef DEBUG fprintf(stderr,"fun2d:Pipe calls for 2D\n"); #endif check(pipe(pipe0)); check(pipe(pipe1)); - #ifdef DEBUG fprintf(stderr,"Fork routine for 2D\n"); #endif childPID = check(fork()); - switch(childPID) { - case -1: fprintf(stderr, "The viewport manager cannot open a viewport window.\nTry closing some viewports.\n"); return; - case 0: /***************************** * child process * @@ -2050,7 +2136,6 @@ forkView2D(void) close(pipe0[1]); close(pipe1[0]); close(pipe1[1]); - #ifdef DEBUG fprintf(stderr,"Executing TwoDimensionalViewport process\n"); #endif @@ -2059,7 +2144,6 @@ forkView2D(void) check(execl(runView,runView,NULL)); fprintf(stderr,"The viewport manager could not execute view2d.\nCheck that view2d is on your PATH.\n"); exit(-1); - default: /****************************** * parent process * @@ -2070,25 +2154,20 @@ forkView2D(void) } viewport->viewType = view2DType; viewport->PID = childPID; - /* set up pipes to child process */ close(pipe0[0]); close(pipe1[1]); viewport->viewIn = pipe1[0]; viewport->viewOut = pipe0[1]; - /* add new viewport to global list */ viewport->nextViewport = viewports; viewports = viewport; - if (viewport->viewIn <0) { fprintf(stderr, "viewman could not create connection to a 2D viewport window. Try again.\n"); return; } else { - code = readViewport(viewport,&acknow,intSize); - if (code < 0) { fprintf(stderr, "viewman could not read from a 2D viewport window\ncode=%d\nack=%d\n", @@ -2096,13 +2175,10 @@ forkView2D(void) return; } } - makeView2DFromSpadData(&doView2D,doGraphStateArray); - /* tell the child that mother is a viewport manager */ i = no; write(viewport->viewOut,&i,sizeof(int)); - write(viewport->viewOut,&doView2D,sizeof(view2DStruct)); i = strlen(doView2D.title)+1; write(viewport->viewOut,&i,intSize); /* send length of the title child */ @@ -2112,44 +2188,39 @@ forkView2D(void) write(viewport->viewOut,&there,intSize); sendGraphToView2D(i,there,viewport,doGraphStateArray); }; /* for i in graphs */ - /*** get acknowledge from viewport */ - code = readViewport(viewport,&(viewport->viewWindow),sizeof(Window)); sleep(1); /* wait a second...*/ send_int(spadSock,viewport->PID); /* acknowledge to spad */ - } /* switch */ - } /* forkView2D() */ - - -void -sendGraphToView2D(int i,int there,viewManager *viewport, - graphStateStruct *doGraphStateArray) -{ - +@ +\subsection{sendGraphToView2D} +\index{viewman!sendGraphToView2D} +\index{sendGraphToView2D viewman} +<>= +void sendGraphToView2D(int i,int there,viewManager *viewport, + graphStateStruct *doGraphStateArray) { graphStruct *gPtr; pointListStruct *llPtr; pointStruct *p; viewsWithThisGraph *oneView; int j,k; - if (there) { gPtr = graphList; - while ( gPtr != NULL && gPtr->key != there) /** find the right graph (same key) in graph list **/ + /** find the right graph (same key) in graph list **/ + while ( gPtr != NULL && gPtr->key != there) gPtr = gPtr->nextGraph; if ((gPtr==NULL) ||(gPtr->key != there) ){ - fprintf(stderr, - "The viewport manager cannot find the requested graph and will quit and restart.\n"); + fprintf(stderr,"The viewport manager cannot find the requested graph\n"); + fprintf(stderr,"and will quit and restart.\n"); exit(-1); } - - -/*** Before sending off the data, insert a pointer to viewport from graph ***/ + /* Before sending off the data, insert a pointer to viewport from graph */ if (!(oneView = (viewsWithThisGraph *)malloc(sizeof(viewsWithThisGraph)))) { - fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (viewsWithThisGraph).\n"); + fprintf(stderr,"The viewport manager ran out of memory trying to \n"); + fprintf(stderr,"create a new graph (viewsWithThisGraph).\n"); return; } oneView->viewGr = viewport; @@ -2173,7 +2244,6 @@ sendGraphToView2D(int i,int there,viewManager *viewport, #else write(viewport->viewOut,gPtr,sizeof(graphStruct)); #endif - llPtr = gPtr->listOfListsOfPoints; for (j=0; j<(gPtr->numberOfLists); j++) { write(viewport->viewOut,&(llPtr->numberOfPoints),intSize); @@ -2190,7 +2260,6 @@ sendGraphToView2D(int i,int there,viewManager *viewport, write(viewport->viewOut,&(llPtr->pointSize),intSize); llPtr++; } /* for j in list of lists of points */ - /* a graph state is defined for a graph if graph is there */ write(viewport->viewOut,&(doGraphStateArray[i].scaleX),floatSize); write(viewport->viewOut,&(doGraphStateArray[i].scaleY),floatSize); @@ -2204,56 +2273,27 @@ sendGraphToView2D(int i,int there,viewManager *viewport, write(viewport->viewOut,&(doGraphStateArray[i].unitsOn),intSize); write(viewport->viewOut,&(doGraphStateArray[i].unitsColor),intSize); write(viewport->viewOut,&(doGraphStateArray[i].showing),intSize); - } /* if graph is there */ - } @ -\subsection{fun3d.c} -<>= -#define _FUN3D_C - -#include -#include -#include -#include - -<> -#define spadActionMode -/* define spadEventMode */ -#define components -<> - -#include "util.h1" -#include "sockio-c.h1" -extern void funView3D(int viewCommand); -extern void forkView3D(int typeOfViewport); -extern void makeView3DFromSpadData(view3DStruct * viewdata, - int typeOfViewport); -extern int readViewport(viewManager * viewPort , void * info , int size); - -void -funView3D(int viewCommand) -{ - +\subsection{funView3D} +\index{viewman!funView3D} +\index{funView3D viewman} +<>= +void funView3D(int viewCommand) { int code; int viewPID; float f1,f2,f3,f4; int i1,i2; viewManager *viewport; - viewPID = get_int(spadSock); - viewport = viewports; while ((viewport) && (viewport->PID != viewPID)) viewport = viewport->nextViewport; - if (viewport) { send_int(spadSock,1); /* acknowledge to spad */ - viewmanEvent.xclient.window = viewport->viewWindow; - code = write(viewport->viewOut,&viewCommand,intSize); switch (viewCommand) { case rotate: @@ -2262,12 +2302,10 @@ funView3D(int viewCommand) code = write(viewport->viewOut,&f1,floatSize); code = write(viewport->viewOut,&f2,floatSize); break; - case zoom: f1 = get_float(spadSock); code = write(viewport->viewOut,&f1,floatSize); break; - case zoomx: f1 = get_float(spadSock); f2 = get_float(spadSock); @@ -2276,14 +2314,12 @@ funView3D(int viewCommand) code = write(viewport->viewOut,&f2,floatSize); code = write(viewport->viewOut,&f3,floatSize); break; - case translate: f1 = get_float(spadSock); f2 = get_float(spadSock); code = write(viewport->viewOut,&f1,floatSize); code = write(viewport->viewOut,&f2,floatSize); break; - case modifyPOINT: i1 = get_int(spadSock); f1 = get_float(spadSock); @@ -2296,12 +2332,10 @@ funView3D(int viewCommand) code = write(viewport->viewOut,&f3,floatSize); code = write(viewport->viewOut,&f4,floatSize); break; - case hideControl: i1 = get_int(spadSock); code = write(viewport->viewOut,&i1,intSize); break; - case axesOnOff: case perspectiveOnOff: case region3D: @@ -2310,39 +2344,33 @@ funView3D(int viewCommand) i1 = get_int(spadSock); code = write(viewport->viewOut,&i1,intSize); break; - case eyeDistanceData: case hitherPlaneData: f1 = get_float(spadSock); code = write(viewport->viewOut,&f1,floatSize); break; - case colorDef: i1 = get_int(spadSock); i2 = get_int(spadSock); code = write(viewport->viewOut,&i1,intSize); code = write(viewport->viewOut,&i2,intSize); break; - case moveViewport: i1 = get_int(spadSock); i2 = get_int(spadSock); code = write(viewport->viewOut,&i1,intSize); code = write(viewport->viewOut,&i2,intSize); break; - case resizeViewport: i1 = get_int(spadSock); i2 = get_int(spadSock); code = write(viewport->viewOut,&i1,intSize); code = write(viewport->viewOut,&i2,intSize); break; - case transparent: case opaqueMesh: case render: break; - case lightDef: f1 = get_float(spadSock); f2 = get_float(spadSock); @@ -2351,20 +2379,16 @@ funView3D(int viewCommand) code = write(viewport->viewOut,&f2,floatSize); code = write(viewport->viewOut,&f3,floatSize); break; - case translucenceDef: f1 = get_float(spadSock); code = write(viewport->viewOut,&f1,floatSize); break; - - case changeTitle: s1 = get_string(spadSock); i1 = strlen(s1); code = write(viewport->viewOut,&i1,intSize); code = write(viewport->viewOut,s1,i1); break; - case writeView: s1 = get_string(spadSock); i1 = strlen(s1); @@ -2378,63 +2402,56 @@ funView3D(int viewCommand) code = write(viewport->viewOut,&i2,intSize); } break; - case diagOnOff: i1 = get_int(spadSock); code = write(viewport->viewOut,&i1,intSize); break; - case outlineOnOff: i1 = get_int(spadSock); code = write(viewport->viewOut,&i1,intSize); break; - case spadPressedAButton: i1 = get_int(spadSock); code = write(viewport->viewOut,&i1,intSize); break; } /* switch */ /*** get acknowledge from viewport */ - code = readViewport(viewport,&acknow,intSize); send_int(spadSock,1); /* acknowledge to spad */ } else { /* if (viewport) */ send_int(spadSock,-1); /* send error value in acknowledge to spad */ } - } -void -forkView3D(int typeOfViewport) -{ +@ +\subsection{forkView3D} +\index{viewman!forkView3D} +\index{forkView3D viewman} +<>= +void forkView3D(int typeOfViewport) { viewManager *viewport; int childPID, code; int i; - view3DStruct doView3D; int pipe0[2],pipe1[2]; int *anIndex; - char envAXIOM[100],runView[100]; int j,k; LLPoint *anLLPoint; LPoint *anLPoint; - #ifdef DEBUG fprintf(stderr,"Pipe calls for 3D\n"); #endif check(pipe(pipe0)); check(pipe(pipe1)); - #ifdef DEBUG fprintf(stderr,"Fork routine for 3D\n"); #endif switch(childPID = check(fork())) { - case -1: - printf("Cannot create a new process - you probably have too many things running already.\n"); + printf("Cannot create a new process - \n"); + printf("you probably have too many things running already.\n"); return; - case 0: /***************************** * child process * @@ -2449,7 +2466,6 @@ forkView3D(int typeOfViewport) close(pipe0[1]); close(pipe1[0]); close(pipe1[1]); - #ifdef DEBUG fprintf(stderr,"Executing ThreeDimensionalViewport process\n"); #endif @@ -2458,7 +2474,6 @@ forkView3D(int typeOfViewport) check(execl(runView,runView,NULL)); fprintf(stderr,"The viewport manager could not execute view3d.\nCheck that view3d is on your PATH.\n"); exit(-1); - default: /****************************** * parent process * @@ -2469,47 +2484,37 @@ forkView3D(int typeOfViewport) } viewport->viewType = typeOfViewport; viewport->PID = childPID; - /* set up pipes to child process */ close(pipe0[0]); close(pipe1[1]); viewport->viewIn = pipe1[0]; viewport->viewOut = pipe0[1]; - /* add new viewport to global list */ viewport->nextViewport = viewports; viewports = viewport; - if (viewport->viewIn <0) { - fprintf(stderr, - "The viewport manager could not create connection to a 3D viewport window. Try again.\n"); + fprintf(stderr,"The viewport manager could not create connection to\n"); + fprintf(stderr," a 3D viewport window. Try again.\n"); return; } else { - code = readViewport(viewport,&acknow,intSize); - if (code < 0) { - fprintf(stderr, - "The viewport manager could not read from a 3D viewport window\ncode=%d\nack=%d\n",code,acknow); + fprintf(stderr,"The viewport manager could not read from a 3D \n"); + fprintf(stderr,"viewport window\ncode=%d\nack=%d\n",code,acknow); return; } } - makeView3DFromSpadData(&doView3D,typeOfViewport); - /* tell the child that parent is a viewport manager */ i = no; write(viewport->viewOut,&i,sizeof(int)); - write(viewport->viewOut,&doView3D,sizeof(view3DStruct)); - i = strlen(doView3D.title)+1; - write(viewport->viewOut,&i,intSize); /* tell the length of the title to child */ - write(viewport->viewOut,doView3D.title,i); /* tell the title to the child */ + write(viewport->viewOut,&i,intSize); /*tell the length of title to child */ + write(viewport->viewOut,doView3D.title,i); /* tell the title to child */ write(viewport->viewOut,&(doView3D.lightVec[0]),floatSize); write(viewport->viewOut,&(doView3D.lightVec[1]),floatSize); write(viewport->viewOut,&(doView3D.lightVec[2]),floatSize); - /* send generalized 3D components */ write(viewport->viewOut,&(doView3D.numOfPoints),intSize); for (i=0; iviewOut,anIndex,intSize); } /* for LPoints in LLPoints (j) */ } /* for LLPoints in LLLPoints (i) */ - /*** get acknowledge from viewport */ code = readViewport(viewport,&(viewport->viewWindow),sizeof(Window)); sleep(1); /* wait a second...*/ @@ -2544,60 +2548,23 @@ forkView3D(int typeOfViewport) } /* forkView3D() */ - -@ -\subsection{globalsm.h} -<>= -extern viewManager *viewports,*slot,*stepSlot; -extern Sock *spadSock; -extern int viewType, viewCommand; -extern fd_set filedes; -extern int acknow; -extern int graphKey; -extern graphStruct *graphList; -extern char *s1; -extern Display *dsply; -extern int defDsply; -extern Window root; -extern XEvent viewmanEvent; -extern int currentGraph; -extern graphStateStruct currentGraphState; -extern int picked; -extern int viewOkay; -extern int viewError; -extern int checkClosedChild, - foundBrokenPipe; -extern char propertyBuffer[]; @ -\subsection{make2d.c} -<>= -#define _MAKE2D_C - -<> - -#include "sockio-c.h1" -extern void makeView2DFromSpadData(view2DStruct * viewdata , - graphStateStruct graphState[]); - -void -makeView2DFromSpadData(view2DStruct *viewdata,graphStateStruct graphState[]) -{ - - int i; - +\subsection{makeView2DFromSpadData} +\index{viewman!makeView2DFromSpadData} +\index{makeView2DFromSpadData viewman} +<>= +void makeView2DFromSpadData(view2DStruct *viewdata, + graphStateStruct graphState[]) +{ int i; viewdata->title = get_string(spadSock); - viewdata->vX = get_int(spadSock); viewdata->vY = get_int(spadSock); viewdata->vW = get_int(spadSock); viewdata->vH = get_int(spadSock); - viewdata->showCP = get_int(spadSock); - for (i=0; igraphKeyArray[i] = get_int(spadSock); if (viewdata->graphKeyArray[i]) { - graphState[i].scaleX = get_float(spadSock); graphState[i].scaleY = get_float(spadSock); graphState[i].deltaX = get_float(spadSock); @@ -2610,31 +2577,17 @@ makeView2DFromSpadData(view2DStruct *viewdata,graphStateStruct graphState[]) graphState[i].unitsOn = get_int(spadSock); graphState[i].unitsColor = get_int(spadSock); graphState[i].showing = get_int(spadSock); - graphState[i].selected = 1; /* always default to selected? */ - + graphState[i].selected = 1; /* always default to selected? */ } } } -@ -\subsection{make3d.c} -<>= -#define _MAKE3D_C - -#include - -<> -#define spadActionMode -/* define spadEventMode */ -#define components - -#include "sockio-c.h1" -extern void makeView3DFromSpadData(view3DStruct * viewdata, - int typeOfViewport); - -void -makeView3DFromSpadData(view3DStruct *viewdata,int typeOfViewport) -{ +@ +\subsection{makeView3DFromSpadData} +\index{viewman!makeView3DFromSpadData} +\index{makeView3DFromSpadData viewman} +<>= +void makeView3DFromSpadData(view3DStruct *viewdata,int typeOfViewport) { int i,j,k; LLPoint *anLLPoint; LPoint *anLPoint; @@ -2644,11 +2597,8 @@ makeView3DFromSpadData(view3DStruct *viewdata,int typeOfViewport) double cMin = 0; double cMax = 0; double cNorm = 0; - viewdata->typeOf3D = typeOfViewport; - viewdata->title = get_string(spadSock); - viewdata->deltaX = get_float(spadSock); viewdata->deltaY = get_float(spadSock); viewdata->scale = get_float(spadSock); @@ -2657,12 +2607,10 @@ makeView3DFromSpadData(view3DStruct *viewdata,int typeOfViewport) viewdata->scaleZ = get_float(spadSock); viewdata->theta = get_float(spadSock); viewdata->phi = get_float(spadSock); - viewdata->vX = get_int(spadSock); viewdata->vY = get_int(spadSock); viewdata->vW = get_int(spadSock); viewdata->vH = get_int(spadSock); - viewdata->showCP = get_int(spadSock); viewdata->style = get_int(spadSock); viewdata->AxesOn = get_int(spadSock); @@ -2671,20 +2619,17 @@ makeView3DFromSpadData(view3DStruct *viewdata,int typeOfViewport) viewdata->box = get_int(spadSock); viewdata->clipbox = get_int(spadSock); viewdata->clipStuff = get_int(spadSock); - viewdata->hueOff = get_int(spadSock); viewdata->numOfHues = get_int(spadSock); - viewdata->lightVec[0] = get_float(spadSock); viewdata->lightVec[1] = get_float(spadSock); viewdata->lightVec[2] = get_float(spadSock); viewdata->translucency = get_float(spadSock); - viewdata->perspective = get_int(spadSock); viewdata->eyeDistance = get_float(spadSock); - viewdata->numOfPoints = get_int(spadSock); - viewdata->points = (viewTriple *)malloc(viewdata->numOfPoints * sizeof(viewTriple)); + viewdata->points = + (viewTriple *)malloc(viewdata->numOfPoints * sizeof(viewTriple)); for (i=0; inumOfPoints; i++) { refPt(*viewdata,i)->x = get_float(spadSock); refPt(*viewdata,i)->y = get_float(spadSock); @@ -2698,17 +2643,22 @@ makeView3DFromSpadData(view3DStruct *viewdata,int typeOfViewport) viewdata->zmin = viewdata->zmax = refPt(*viewdata,i)->z; cMin = cMax = refPt(*viewdata,i)->c; } else { - if (refPt(*viewdata,i)->x < viewdata->xmin) viewdata->xmin = refPt(*viewdata,i)->x; - else if (refPt(*viewdata,i)->x > viewdata->xmax) viewdata->xmax = refPt(*viewdata,i)->x; - if (refPt(*viewdata,i)->y < viewdata->ymin) viewdata->ymin = refPt(*viewdata,i)->y; - else if (refPt(*viewdata,i)->y > viewdata->ymax) viewdata->ymax = refPt(*viewdata,i)->y; - if (refPt(*viewdata,i)->z < viewdata->zmin) viewdata->zmin = refPt(*viewdata,i)->z; - else if (refPt(*viewdata,i)->z > viewdata->zmax) viewdata->zmax = refPt(*viewdata,i)->z; + if (refPt(*viewdata,i)->x < viewdata->xmin) + viewdata->xmin = refPt(*viewdata,i)->x; + else if (refPt(*viewdata,i)->x > viewdata->xmax) + viewdata->xmax = refPt(*viewdata,i)->x; + if (refPt(*viewdata,i)->y < viewdata->ymin) + viewdata->ymin = refPt(*viewdata,i)->y; + else if (refPt(*viewdata,i)->y > viewdata->ymax) + viewdata->ymax = refPt(*viewdata,i)->y; + if (refPt(*viewdata,i)->z < viewdata->zmin) + viewdata->zmin = refPt(*viewdata,i)->z; + else if (refPt(*viewdata,i)->z > viewdata->zmax) + viewdata->zmax = refPt(*viewdata,i)->z; if (refPt(*viewdata,i)->c < cMin) cMin = refPt(*viewdata,i)->c; else if (refPt(*viewdata,i)->c > cMax) cMax = refPt(*viewdata,i)->c; } /* if (firstPieceOfData) else */ } /* for i (point data) */ - viewdata->lllp.numOfComponents = get_int(spadSock); anLLPoint = viewdata->lllp.llp = (LLPoint *)malloc(viewdata->lllp.numOfComponents*sizeof(LLPoint)); @@ -2728,191 +2678,61 @@ makeView3DFromSpadData(view3DStruct *viewdata,int typeOfViewport) *anIndex = get_int(spadSock); } /* for LPoints in LLPoints (j) */ } /* for LLPoints in LLLPoints (i) */ - /* now normalize the colors */ cNorm = cMax - cMin; /*** new fields - cmin, cmax ***/ viewdata->cmin = cMin; viewdata->cmax = cMax; - constantColor = (cNorm < 0.0001); for (i=0; inumOfPoints; i++) if (constantColor) refPt(*viewdata,i)->c = 0.5; else refPt(*viewdata,i)->c = (refPt(*viewdata,i)->c - cMin)/cNorm; - viewdata->scaleDown = yes; - } @ -\subsection{viewman Makefile} -<>= -BOOK=${SPD}/books/bookvol8.pamphlet -MIDINT= ${INT}/graph/viewman -MIDOBJ= ${OBJ}/${SYS}/graph/viewman -OUT= ${MNT}/${SYS}/lib -LIB= ${OBJ}/${SYS}/lib -DOC= ${MNT}/${SYS}/doc/src/graph - -CFLAGS = ${CCF} -I${SRC}/include -LDFLAGS = ${LDF} -lX11 - -OBJS= ${MIDOBJ}/viewman.o ${MIDOBJ}/readview.o ${MIDOBJ}/make3d.o \ - ${MIDOBJ}/fun3d.o ${MIDOBJ}/makegraph.o ${MIDOBJ}/make2d.o \ - ${MIDOBJ}/fun2d.o ${MIDOBJ}/cleanup.o ${MIDOBJ}/sselect.o \ - ${OBJ}/${SYS}/lib/sockio-c.o - -all: ${OBJS} ${OUT}/viewman - @ echo 30 finished viewman from bookvol8 - -${OUT}/viewman: ${OBJS} ${LIB}/util.o ${LIB}/bsdsignal.o - @ echo 1 linking ${OUT}/viewman - @ ${CC} ${OBJS} -o ${OUT}/viewman ${LIB}/util.o \ - ${LIB}/bsdsignal.o ${LDFLAGS} - -${MIDINT}/viewman.c: ${BOOK} - @ echo 2 ${MIDINT}/viewman.c from ${BOOK} - @( cd ${MIDINT} ; \ - ${TANGLE} -R"viewman/viewman.c" ${BOOK} >viewman.c ) - -${MIDOBJ}/viewman.o: ${SRC}/include/com.h ${MIDINT}/viewman.c - @ echo 3 making ${MIDOBJ}/viewman.o from ${MIDINT}/viewman.c - @ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/viewman.c ) - -${MIDINT}/sselect.c: ${BOOK} - @ echo 5 ${MIDINT}/sselect.c from ${BOOK} - @( cd ${MIDINT} ; \ - ${TANGLE} -R"viewman/sselect.c" ${BOOK} >sselect.c ) - -${MIDOBJ}/sselect.o: ${SRC}/include/com.h ${MIDINT}/sselect.c - @ echo 6 making ${MIDOBJ}/sselect.o from ${MIDINT}/sselect.c - @ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/sselect.c ) - -${MIDINT}/cleanup.c: ${BOOK} - @ echo 8 ${MIDINT}/cleanup.c from ${BOOK} - @( cd ${MIDINT} ; \ - ${TANGLE} -R"viewman/cleanup.c" ${BOOK} >cleanup.c ) - -${MIDOBJ}/cleanup.o: ${SRC}/include/com.h ${MIDINT}/cleanup.c - @ echo 9 making ${MIDOBJ}/cleanup.o from ${MIDINT}/cleanup.c - @ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/cleanup.c ) - -${MIDINT}/fun2d.c: ${BOOK} - @ echo 11 ${MIDINT}/fun2d.c from ${BOOK} - @( cd ${MIDINT} ; \ - ${TANGLE} -R"viewman/fun2d.c" ${BOOK} >fun2d.c ) - -${MIDOBJ}/fun2d.o: ${SRC}/include/com.h ${MIDINT}/fun2d.c - @ echo 12 making ${MIDOBJ}/fun2d.o from ${MIDINT}/fun2d.c - @ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/fun2d.c ) - -${MIDINT}/make2d.c: ${BOOK} - @ echo 14 ${MIDINT}/make2d.c from ${BOOK} - @( cd ${MIDINT} ; \ - ${TANGLE} -R"viewman/make2d.c" ${BOOK} >make2d.c ) - -${MIDOBJ}/make2d.o: ${SRC}/include/com.h ${MIDINT}/make2d.c - @ echo 15 making ${MIDOBJ}/make2d.o from ${MIDINT}/make2d.c - @ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/make2d.c ) - -${MIDINT}/makegraph.c: ${BOOK} - @ echo 17 ${MIDINT}/makegraph.c from ${BOOK} - @( cd ${MIDINT} ; \ - ${TANGLE} -R"viewman/makegraph.c" ${BOOK} >makegraph.c ) - -${MIDOBJ}/makegraph.o: ${SRC}/include/com.h ${MIDINT}/makegraph.c - @ echo 18 making ${MIDOBJ}/makegraph.o from ${MIDINT}/makegraph.c - @ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/makegraph.c ) - -${MIDINT}/fun3d.c: ${BOOK} - @ echo 20 ${MIDINT}/fun3d.c from ${BOOK} - @( cd ${MIDINT} ; \ - ${TANGLE} -R"viewman/fun3d.c" ${BOOK} >fun3d.c ) - -${MIDOBJ}/fun3d.o: ${SRC}/include/com.h ${MIDINT}/fun3d.c - @ echo 21 making ${MIDOBJ}/fun3d.o from ${MIDINT}/fun3d.c - @ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/fun3d.c ) - -${MIDINT}/make3d.c: ${BOOK} - @ echo 23 ${MIDINT}/make3d.c from ${BOOK} - @( cd ${MIDINT} ; \ - ${TANGLE} -R"viewman/make3d.c" ${BOOK} >make3d.c ) - -${MIDOBJ}/make3d.o: ${SRC}/include/com.h ${MIDINT}/make3d.c - @ echo 24 making ${MIDOBJ}/make3d.o from ${MIDINT}/make3d.c - @ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/make3d.c ) - -${MIDINT}/readview.c: ${BOOK} - @ echo 26 ${MIDINT}/readview.c from ${BOOK} - @( cd ${MIDINT} ; \ - ${TANGLE} -R"viewman/readview.c" ${BOOK} >readview.c ) - -${MIDOBJ}/readview.o: ${SRC}/include/com.h ${MIDINT}/readview.c - @ echo 27 making ${MIDOBJ}/readview.o from ${MIDINT}/readview.c - @ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/readview.c ) - -@ -\subsection{makegraph.c} -<>= -#define _MAKEGRAPH_C - -#include -#include - -<> - -#include "sockio-c.h1" -extern graphStruct * makeGraphFromSpadData(void); -extern void discardGraph(graphStruct * theGraph); - -graphStruct * -makeGraphFromSpadData(void) -{ - +\subsection{makeGraphFromSpadData} +\index{viewman!makeGraphFromSpadData} +\index{makeGraphFromSpadData viewman} +<>= +graphStruct *makeGraphFromSpadData(void) { graphStruct *graphData; pointListStruct *pL; pointStruct *p; int i,j; - if (!(graphData = (graphStruct *)malloc(sizeof(graphStruct)))) { - fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (graphStruct).\n"); + fprintf(stderr,"The viewport manager ran out of memory trying to \n"); + fprintf(stderr, "create a new graph (graphStruct).\n"); exit(-1); } - graphData->xmin = get_float(spadSock); /* after everything is normalized */ graphData->xmax = get_float(spadSock); graphData->ymin = get_float(spadSock); /* view2d */ graphData->ymax = get_float(spadSock); - graphData->xNorm = 1/(graphData->xmax - graphData->xmin); graphData->yNorm = 1/(graphData->ymax - graphData->ymin); - graphData->spadUnitX = get_float(spadSock); graphData->spadUnitY = get_float(spadSock); - graphData->unitX = graphData->spadUnitX * graphData->xNorm; graphData->unitY = graphData->spadUnitY * graphData->yNorm; - graphData->originX = -graphData->xmin * graphData->xNorm - 0.5; graphData->originY = -graphData->ymin * graphData->yNorm - 0.5; - - graphData->numberOfLists = get_int(spadSock); - if (!(pL = (pointListStruct *)malloc(graphData->numberOfLists * sizeof(pointListStruct)))) { - fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (pointListStruct).\n"); + if (!(pL = (pointListStruct *) + malloc(graphData->numberOfLists * sizeof(pointListStruct)))) { + fprintf(stderr,"The viewport manager ran out of memory trying to \n"); + fprintf(stderr,"create a new graph (pointListStruct).\n"); exit(-1); } graphData->listOfListsOfPoints = pL; - for (i=0; inumberOfLists; i++) { - pL->numberOfPoints = get_int(spadSock); - if (!(p = (pointStruct *)malloc(pL->numberOfPoints * sizeof(pointStruct)))) { - fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (pointStruct).\n"); + if (!(p=(pointStruct *)malloc(pL->numberOfPoints*sizeof(pointStruct)))) { + fprintf(stderr,"The viewport manager ran out of memory trying to \n"); + fprintf(stderr,"create a new graph (pointStruct).\n"); exit(-1); } pL->listOfPoints = p; /** point to current point list **/ - for (j=0; jnumberOfPoints; j++) { p->x = get_float(spadSock); /* get numbers from Axiom */ p->y = get_float(spadSock); @@ -2929,56 +2749,33 @@ makeGraphFromSpadData(void) pL->pointSize = get_int(spadSock); pL++; /** advance to next point list **/ } - - graphData->key = graphKey++; - send_int(spadSock,(graphKey-1)); /* acknowledge to spad */ - - return(graphData); - } - -void -discardGraph (graphStruct *theGraph) -{ - +@ +\subsection{discardGraph} +\index{viewman!discardGraph} +\index{discardGraph viewman} +<>= +void discardGraph(graphStruct *theGraph) { pointListStruct *pL; int j; - for (j=0, pL=theGraph->listOfListsOfPoints; jnumberOfLists; j++,pL++) free(pL->listOfPoints); free(theGraph->listOfListsOfPoints); free(theGraph); - } -@ -\subsection{readview.c} -<>= -#define _READVIEW_C - -#include -#include -#include - -<> - -extern void brokenPipe(int sig); -extern void endChild(int sig); -extern void rmViewMgr(viewManager * slotPtr); -extern void closeChildViewport(viewManager * slotPtr); -extern void goodbye(int sig); - - -int -readViewport (viewManager *viewPort,void *info,int size) -{ +@ +\subsection{readViewport} +\index{viewman!readViewport} +\index{readViewport viewman} +<>= +int readViewport(viewManager *viewPort,void *info,int size) { int canRead; - again: if ((canRead=read(viewPort->viewIn,info,size)) > 0) return(canRead); if (errno==EINTR || errno==EAGAIN) goto again; @@ -2986,49 +2783,18 @@ again: } @ -\subsection{sselect.c} -<>= -#define _SSELECT_C - -#include -#include -#include -#include -#include - -<> -#include "bsdsignal.h" - -#include "sockio-c.h1" -#include "bsdsignal.h1" -extern void brokenPipe(int sig); -extern void endChild(int sig); -extern void rmViewMgr(viewManager * slotPtr); -extern void closeChildViewport(viewManager * slotPtr); -extern void goodbye(int sig); - -extern int -superSelect(int n , int * rd , int * wr , int * ex , char * timeout); - -/******************************************* - * int superSelect(n, rd, wr, ex, timeout) * - * * - * superselect! if select returns a -1 * - * due to an interrupt (EINTR), this * - * routine checks to see if it's a * - * child viewport that has closed. * - * Expected global variables: * - * int checkClosedChild * - *******************************************/ - -int -superSelect(int n, int *rd, int *wr, int *ex, char *timeout) -{ - +\subsection{superSelect} +The function superselect!, if select returns a -1 +due to an interrupt (EINTR), this routine checks to see if it's a +child viewport that has closed. Expected global variables: +{\tt checkClosedChild} +\index{viewman!superSelect} +\index{superSelect viewman} +<>= +int superSelect(int n,int *rd,int *wr,int *ex,char *timeout) { int waiting; viewManager *viewport; int ret_val; - ret_val = select(n, (void *)rd, (void *)wr, (void *)ex, (void *)timeout); while (ret_val == -1 && errno == EINTR) { /* checkClosedChild gets set by the SIGCHLD handler */ @@ -3043,11 +2809,11 @@ superSelect(int n, int *rd, int *wr, int *ex, char *timeout) /* flush(spadSock); */ /* send_int(spadSock,1); acknowledge to spad */ checkClosedChild = no; -#if defined(BSDplatform) || defined(MACOSXplatform) + #if defined(BSDplatform) || defined(MACOSXplatform) bsdSignal(SIGCHLD,endChild,DontRestartSystemCalls); -#else + #else bsdSignal(SIGCLD,endChild,DontRestartSystemCalls); -#endif + #endif } } ret_val = select(n, (void *)rd, (void *)wr, (void *)ex, (void *)timeout); @@ -3056,84 +2822,27 @@ superSelect(int n, int *rd, int *wr, int *ex, char *timeout) } @ -\subsection{viewman.c} -<>= -#define _VIEWMAN_C - -#include -#include -#include -#include -#include -#include -#ifdef SGIplatform -#include -#endif - -<> -#define spadActionMode -/* define spadEventMode */ -#define components -<> -<> -#include "bsdsignal.h" - - -#include "bsdsignal.h1" -#include "util.h1" -#include "sockio-c.h1" -extern void funView2D(int viewCommand); -extern void sendGraphToView2D(int i ,int there,viewManager * viewType, - graphStateStruct * doGraphStateArray); -extern void forkView2D(void); -extern void funView3D(int viewCommand); -extern void forkView3D(int typeOfViewport); -extern graphStruct * makeGraphFromSpadData(void); -extern void discardGraph(graphStruct * theGraph); -extern int readViewport(viewManager * viewPort , void * info , int size); -extern void brokenPipe(int sig); -extern void endChild(int sig); -extern void rmViewMgr(viewManager * slotPtr); -extern void closeChildViewport(viewManager * slotPtr); -extern void goodbye(int sig); - -extern int -superSelect(int n , int * rd , int * wr , int * ex , char * timeout); - -/************* global variables **************/ - -Display *dsply; -Window root; -XEvent viewmanEvent; -viewManager *viewports, - *slot, - *stepSlot; -Sock *spadSock; -int viewType, - viewCommand, - acknow, - graphKey = 1, - defDsply, - currentGraph, - picked = no, - viewOkay = 0, - viewError = -1, - checkClosedChild = no, - foundBrokenPipe = no; -fd_set filedes; -graphStruct *graphList; -graphStateStruct currentGraphState; -char *s1, - propertyBuffer[256];/* XProperty buffer */ - - -int -main (void) -{ +\subsection{brokenPipe} +\index{viewman!brokenPipe} +\index{brokenPipe viewman} +<>= +void brokenPipe(int sig) { + fprintf(stderr, + "The viewport manager tried to write to a non-existing pipe.\n"); +} +@ +\subsection{main} +The function superselect!, if select returns a -1 +due to an interrupt (EINTR), this routine checks to see if it's a +child viewport that has closed. Expected global variables: +{\tt checkClosedChild} +\index{viewman!main} +\index{main viewman} +<>= +int main(void) { graphStruct *aGraph; int keepLooking,code; - bsdSignal(SIGPIPE,brokenPipe,DontRestartSystemCalls); #if defined(BSDplatform) || defined(MACOSXplatform) bsdSignal(SIGCHLD,endChild,RestartSystemCalls); @@ -3141,7 +2850,6 @@ main (void) bsdSignal(SIGCLD,endChild,RestartSystemCalls); #endif bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls); - /* Connect up to Axiom server */ spadSock = connect_to_local_server(SpadServer,ViewportServer,Forever); if (spadSock == NULL) { @@ -3152,11 +2860,9 @@ main (void) else fprintf(stderr,"viewman: Connected to Axiom\n"); #endif - /******** initialize ********/ viewports = 0; graphList = 0; - /******** getting stuff from spad and viewports ******** ********* the viewports have priority over **** *** Axiom. ***/ @@ -3168,14 +2874,12 @@ main (void) FD_SET(slot->viewIn,&filedes); slot = slot->nextViewport; } - #ifdef DEBUG fprintf(stderr,"Selection for filedes of %x \n",filedes); #endif code = check(superSelect(FD_SETSIZE,(void *) &filedes,0,0,0)); for (;code<=0;) code = check(superSelect(FD_SETSIZE,(void *)&filedes,0,0,0)); - slot = viewports; keepLooking = 1; while (keepLooking && slot) { @@ -3185,19 +2889,15 @@ main (void) fprintf(stderr,"Reading child viewport...\n"); #endif readViewport(slot,&viewCommand,intSize); - switch (viewCommand) { - case pick2D: #ifdef DEBUG fprintf(stderr,"viewman: Doing 2D pick\n"); #endif picked = yes; - readViewport(slot,¤tGraph,intSize); /* get the graph to pick */ readViewport(slot,¤tGraphState,sizeof(graphStateStruct)); break; - case drop2D: #ifdef DEBUG fprintf(stderr,"viewman: Doing 2D drop\n"); @@ -3208,24 +2908,21 @@ main (void) sendGraphToView2D(0,currentGraph,slot,¤tGraphState); } else { write(slot->viewOut,&viewError,intSize); - fprintf(stderr,"The viewport manager cannot drop a graph because nothing has been picked yet.\n"); + fprintf(stderr,"The viewport manager cannot drop a graph \n"); + fprintf(stderr,"because nothing has been picked yet.\n"); } break; - case viewportClosing: #ifdef DEBUG fprintf(stderr,"viewman: closing viewport\n"); #endif closeChildViewport(slot); break; - }; /* switch */ - }; /* if reading slot->viewIn */ stepSlot = slot; slot = slot->nextViewport; }; /* while */ - if (keepLooking) { /* if 1 => slots not read, read from spad */ #ifdef DEBUG fprintf(stderr,"viewman: still looking\n"); @@ -3233,9 +2930,7 @@ main (void) viewType = get_int(spadSock); if (viewType == -1) goodbye(-1); viewCommand = get_int(spadSock); - switch (viewType) { - case view3DType: #ifdef DEBUG fprintf(stderr,"viewman: making 3D viewport\n"); @@ -3244,9 +2939,7 @@ main (void) forkView3D(view3DType); else funView3D(viewCommand); - break; - case viewTubeType: #ifdef DEBUG fprintf(stderr,"viewman: viewing a tube\n"); @@ -3255,9 +2948,7 @@ main (void) forkView3D(viewTubeType); else funView3D(viewCommand); - break; - case viewGraphType: #ifdef DEBUG fprintf(stderr,"viewman: making a graph\n"); @@ -3268,7 +2959,6 @@ main (void) graphList = aGraph; } break; - case view2DType: #ifdef DEBUG fprintf(stderr,"viewman: forking 2D\n"); @@ -3279,32 +2969,38 @@ main (void) funView2D(viewCommand); } break; - } /* switch on viewType */ } /* if (keepLooking) */ } /* while (1) */ } @ -\subsection{viewman.h} -<>= -<> -<> +\subsection{viewman Makefile} +<>= +BOOK=${SPD}/books/bookvol8.pamphlet +MIDINT= ${INT}/graph/viewman +MIDOBJ= ${OBJ}/${SYS}/graph/viewman +OUT= ${MNT}/${SYS}/lib +LIB= ${OBJ}/${SYS}/lib - /* Viewport Commands */ -#define makeViewport -1 -#define makeGraph -1 +CFLAGS = ${CCF} -I${SRC}/include +LDFLAGS = ${LDF} -lX11 -#define check(code) checker(code,__LINE__,"") -#define maxConnect 40 -#define intSize sizeof(int) -#define floatSize sizeof(float) -#define yes 1 -#define no 0 +OBJS= ${MIDOBJ}/viewman.o ${OBJ}/${SYS}/lib/sockio-c.o +all: ${OBJS} ${OUT}/viewman + @ echo 30 finished viewman from bookvol8 + +${OUT}/viewman: ${OBJS} ${LIB}/util.o ${LIB}/bsdsignal.o + @ echo 1 linking ${OUT}/viewman + @ ${CC} ${OBJS} -o ${OUT}/viewman ${LIB}/util.o \ + ${LIB}/bsdsignal.o ${LDFLAGS} + +${MIDOBJ}/viewman.o: ${SRC}/include/com.h ${BOOK} + @ echo 3 making ${MIDOBJ}/viewman.o from ${BOOK} + @( cd ${MIDINT} ; ${TANGLE} -R"viewman" ${BOOK} >viewman.c ) + @ ( cd ${MIDOBJ} ; ${CC} ${CFLAGS} -c ${MIDINT}/viewman.c ) -#include "com.h" -<> @ \chapter{viewalone} \label{viewalone} @@ -6128,7 +5824,10 @@ freeGraph(int i) #define drawViewport(type) drawTheViewport(type); #define spadDrawViewport() spadMode++; drawTheViewport(X); spadMode--; - +@ +\index{struct!buttonStruct} +\index{buttonStruct struct} +<>= typedef struct _buttonStruct { int buttonKey, pot, mask, graphNum, graphSelect; short buttonX,buttonY,buttonWidth,buttonHeight,xHalf,yHalf; @@ -6137,6 +5836,10 @@ typedef struct _buttonStruct { int textColor, textHue, textShade; } buttonStruct; +@ +\index{struct!controlPanelStruct} +\index{controlPanelStruct struct} +<>= typedef struct _controlPanelStruct { int numOfButtons; Window controlWindow,messageWindow,colormapWindow; @@ -6144,10 +5847,18 @@ typedef struct _controlPanelStruct { struct _buttonStruct buttonQueue[maxButtons2D]; } controlPanelStruct; +@ +\index{struct!mouseCoord} +\index{mouseCoord struct} +<>= typedef struct _mouseCoord { float x,y; } mouseCoord; +@ +\index{struct!viewPoints} +\index{viewPoints struct} +<>= typedef struct _viewPoints { int viewportKey; char title[80]; @@ -6159,20 +5870,24 @@ typedef struct _viewPoints { struct _viewPoints *prevViewport,*nextViewport; } viewPoints; - +@ +\index{struct!controlXY} +\index{controlXY struct} +<>= typedef struct _controlXY { int putX,putY; } controlXY; - +@ +\index{struct!xPointStruct} +\index{xPointStruct struct} +<>= typedef struct _xPointStruct { XPoint *xPoint; Vertex *x10Point; XArc *arc; } xPointStruct; - - #define calcUnitX(ii) (vwInfo.width * \ ((graphArray[0].unitX * ii + \ graphArray[0].originX - graphStateArray[0].centerX) *\ @@ -11306,6 +11021,10 @@ contour_minMaxPolygons(poly * aPoly) ((z_min < z_val) && (z_max >= z_val)) #ifdef oldie +@ +\index{struct!active\_poly\_struct} +\index{active\_poly\_struct struct} +<>= typedef struct _active_poly_struct { struct _active_poly_struct *next; int num; @@ -11313,11 +11032,19 @@ typedef struct _active_poly_struct { } active_poly_struct; #endif +@ +\index{struct!segment\_struct} +\index{segment\_struct struct} +<>= typedef struct _segment_struct { struct _segment_struct *next; struct _viewTriple *point1, *point2; } segment_struct; +@ +\index{struct!segment\_list\_struct} +\index{segment\_list\_struct struct} +<>= typedef struct _segment_list_struct { int num_segs; segment_struct *segments; @@ -13976,6 +13703,10 @@ extern Atom wm_delete_window; /*** control stuff ***/ /**********************************/ +@ +\index{struct!buttonStruct} +\index{buttonStruct struct} +<>= typedef struct _buttonStruct { int buttonKey, pot, mask; short buttonX, buttonY, buttonWidth, buttonHeight, xHalf, yHalf; @@ -13984,12 +13715,20 @@ typedef struct _buttonStruct { int textColor,textHue,textShade; } buttonStruct; +@ +\index{struct!controlPanelStruct} +\index{controlPanelStruct struct} +<>= typedef struct _controlPanelStruct { Window controlWindow, messageWindow, colormapWindow; char message[40]; buttonStruct buttonQueue[maxButtons3D]; } controlPanelStruct; +@ +\index{struct!mouseCoord} +\index{mouseCoord struct} +<>= typedef struct _mouseCoord { float x, y; } mouseCoord; @@ -13999,10 +13738,18 @@ typedef struct _mouseCoord { /*** mesh stuff ***/ /**********************************/ +@ +\index{struct!meshStruct} +\index{meshStruct struct} +<>= typedef struct _meshStruct { float N0[4], N1[4]; /* the fourth element is Zmin */ } meshStruct; +@ +\index{struct!points3D} +\index{points3D struct} +<>= typedef struct _points3D { float xmin, xmax, ymin, ymax, @@ -14016,8 +13763,10 @@ typedef struct _points3D { meshStruct *normData; /* list of normals */ } points3D; - - +@ +\index{struct!colorBuffer} +\index{colorBuffer struct} +<>= typedef struct _colorBuffer { int indx; char axes; @@ -14028,18 +13777,24 @@ typedef struct _colorBuffer { /*** axes stuff ***/ /**********************************/ +@ +\index{struct!point} +\index{point struct} +<>= typedef struct _point { float x, y, z; int flag; } point; - - /**** one of the (many) sloppy things that need to be - cleaned up is the viewPoints structure. a lot of - stuff in it is used solely for the function of - two variables stuff. they should be moved to - the fun2Var substructure. ****/ - +@ +\index{struct!viewPoints} +\index{viewPoints struct} +One of the (many) sloppy things that need to be +cleaned up is the viewPoints structure. a lot of +stuff in it is used solely for the function of +two variables stuff. they should be moved to +the fun2Var substructure. +<>= typedef struct _viewPoints { int viewportKey; char title[80]; @@ -14065,7 +13820,10 @@ typedef struct _viewPoints { struct _viewPoints *prevViewport, *nextViewport; } viewPoints; - +@ +\index{struct!controlXY} +\index{controlXY struct} +<>= typedef struct _controlXY { int putX, putY; } controlXY; @@ -26309,6 +26067,8 @@ the file is copied to the output file. @ PostScript structures +\label{psStruct} +\index{psStruct} <>= typedef struct _psStruct { /* data structure for ps routines info */ int flag; diff --git a/changelog b/changelog index e4f1428..b783c96 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,4 @@ +20080613 tpd books/bookvol8 compress viewman.c to a single file 20080612 tpd books/bookvol12 point to The Axiom Literate Documentation 20080612 tpd books/bookvol11 point to The Axiom Literate Documentation 20080612 tpd books/bookvol10 point to The Axiom Literate Documentation