int spadAction (void) { int code, viewCommand; float f1, f2, f3; int i1, i2, i3; if (viewAloned==yes) { close(0); return(-1); } readViewman(&viewCommand, intSize); switch (viewCommand) { case rotate: readViewman(&f1, floatSize); readViewman(&f2, floatSize); viewport->theta = f1; viewport->phi = f2; while (viewport->theta >= two_pi) viewport->theta -= two_pi; while (viewport->theta < 0.0) viewport->theta += two_pi; while (viewport->phi > pi) viewport->phi -= two_pi; while (viewport->phi <= -pi) viewport->phi += two_pi; viewport->axestheta = viewport->theta; viewport->axesphi = viewport->phi; spadDraw=yes; rotated=yes; viewport->yzOn = viewport->xzOn = viewport->xyOn = no; break; case zoom: readViewman(&f1, floatSize); viewport->scale = f1; if (viewport->scale > maxScale) viewport->scale = maxScale; else if (viewport->scale < minScale) viewport->scale = minScale; spadDraw=yes; zoomed = yes; break; case zoomx: readViewman(&f1, floatSize); readViewman(&f2, floatSize); readViewman(&f3, floatSize); viewport->scaleX = f1; viewport->scaleY = f2; viewport->scaleZ = f3; if ((viewport->scaleX == 1.0) && (viewport->scaleY == 1.0) && (viewport->scaleZ == 1.0)) { viewport->zoomXOn = viewport->zoomYOn = viewport->zoomZOn = yes; } else { if (viewport->scaleX == 1.0) viewport->zoomXOn = no; else { if (viewport->scaleX > maxScale) viewport->scaleX = maxScale; else if (viewport->scaleX < minScale) viewport->scaleX = minScale; } if (viewport->scaleY == 1.0) viewport->zoomYOn = no; else { if (viewport->scaleY > maxScale) viewport->scaleY = maxScale; else if (viewport->scaleY < minScale) viewport->scaleY = minScale; } if (viewport->scaleZ == 1.0) viewport->zoomZOn = no; else { if (viewport->scaleZ > maxScale) viewport->scaleZ = maxScale; else if (viewport->scaleZ < minScale) viewport->scaleZ = minScale; } } spadDraw=yes; zoomed = yes; break; case translate: readViewman(&(viewport->deltaX),floatSize); readViewman(&(viewport->deltaY),floatSize); if (viewport->deltaX > maxDeltaX) viewport->deltaX = maxDeltaX; else if (viewport->deltaX < -maxDeltaX) viewport->deltaX = -maxDeltaX; if (viewport->deltaY > maxDeltaY) viewport->deltaY = maxDeltaY; else if (viewport->deltaY < -maxDeltaY) viewport->deltaY = -maxDeltaY; spadDraw=yes; translated = yes; break; case modifyPOINT: readViewman(&i1,intSize); i1--; readViewman(&(refPt3D(viewData,i1)->x),floatSize); readViewman(&(refPt3D(viewData,i1)->y),floatSize); readViewman(&(refPt3D(viewData,i1)->z),floatSize); readViewman(&(refPt3D(viewData,i1)->c),floatSize); scalePoint(refPt3D(viewData,i1)); spadDraw=yes; break; case hideControl: readViewman(&i1,intSize); if (i1) { /* show control panel */ if (viewport->haveControl) XUnmapWindow(dsply,control->controlWindow); putControlPanelSomewhere(someInt); } else { /* turn off control panel */ if (viewport->haveControl) { viewport->haveControl = no; XUnmapWindow(dsply,control->controlWindow); } } break; case axesOnOff: readViewman(&i1,intSize); viewport->axesOn = i1; spadDraw=yes; if (viewData.style == smooth) { if (multiColorFlag) redoDither = yes; else redoColor = yes; } if (viewport->haveControl) drawControlPanel(); break; /* Non-uniform scaling is not in AXIOM yet. */ /* Neither is object or origin rotation. */ case perspectiveOnOff: readViewman(&i1,intSize); viewData.perspective = i1; switchedPerspective = yes; spadDraw=yes; break; case region3D: readViewman(&i1,intSize); viewport->regionOn = i1; viewData.box = i1; spadDraw=yes; if (viewport->haveControl) drawControlPanel(); redoSmooth = yes; break; case clipRegionOnOff: readViewman(&i1,intSize); viewData.clipbox = i1; spadDraw=yes; break; case clipSurfaceOnOff: readViewman(&i1,intSize); viewData.clipStuff = i1; spadDraw=yes; break; case eyeDistanceData: readViewman(&f1,floatSize); viewData.eyeDistance = f1; if (viewData.eyeDistance > maxEyeDistance) viewData.eyeDistance = maxEyeDistance; else if (viewData.eyeDistance < minEyeDistance) viewData.eyeDistance = minEyeDistance; spadDraw=yes; changedEyeDistance = yes; break; case hitherPlaneData: readViewman(&f1,floatSize); viewData.clipPlane = f1; spadDraw=yes; changedEyeDistance = yes; break; case queryVIEWPOINT: f1 = viewport->deltaX; code = check(write(Socket, &f1, floatSize)); f1 = viewport->deltaY; code = check(write(Socket, &f1, floatSize)); f1 = viewport->scale; code = check(write(Socket, &f1, floatSize)); f1 = viewport->scaleX; code = check(write(Socket, &f1, floatSize)); f1 = viewport->scaleY; code = check(write(Socket, &f1, floatSize)); f1 = viewport->scaleZ; code = check(write(Socket, &f1, floatSize)); f1 = viewport->theta; code = check(write(Socket, &f1, floatSize)); f1 = viewport->phi; code = check(write(Socket, &f1, floatSize)); break; case changeVIEWPOINT: readViewman(&f1, floatSize); readViewman(&f2, floatSize); viewport->deltaX = f1; viewport->deltaY = f2; if (viewport->deltaX > maxDeltaX) viewport->deltaX = maxDeltaX; else if (viewport->deltaX < -maxDeltaX) viewport->deltaX = -maxDeltaX; if (viewport->deltaY > maxDeltaY) viewport->deltaY = maxDeltaY; else if (viewport->deltaY < -maxDeltaY) viewport->deltaY = -maxDeltaY; translated = yes; readViewman(&f1, floatSize); viewport->scale = f1; if (viewport->scale > maxScale) viewport->scale = maxScale; else if (viewport->scale < minScale) viewport->scale = minScale; zoomed = yes; readViewman(&f1, floatSize); readViewman(&f2, floatSize); readViewman(&f3, floatSize); viewport->scaleX = f1; viewport->scaleY = f2; viewport->scaleZ = f3; if ((viewport->scaleX == 1.0) && (viewport->scaleY == 1.0) && (viewport->scaleZ == 1.0)) { viewport->zoomXOn = viewport->zoomYOn = viewport->zoomZOn = yes; } else { if (viewport->scaleX == 1.0) viewport->zoomXOn = no; else { if (viewport->scaleX > maxScale) viewport->scaleX = maxScale; else if (viewport->scaleX < minScale) viewport->scaleX = minScale; } if (viewport->scaleY == 1.0) viewport->zoomYOn = no; else { if (viewport->scaleY > maxScale) viewport->scaleY = maxScale; else if (viewport->scaleY < minScale) viewport->scaleY = minScale; } if (viewport->scaleZ == 1.0) viewport->zoomZOn = no; else { if (viewport->scaleZ > maxScale) viewport->scaleZ = maxScale; else if (viewport->scaleZ < minScale) viewport->scaleZ = minScale; } } readViewman(&f1, floatSize); readViewman(&f2, floatSize); viewData.theta = f1; viewData.phi = f2; while (viewport->theta >= two_pi) viewport->theta -= two_pi; while (viewport->theta < 0.0) viewport->theta += two_pi; while (viewport->phi > pi) viewport->phi -= two_pi; while (viewport->phi <= -pi) viewport->phi += two_pi; viewport->axestheta = viewport->theta; viewport->axesphi = viewport->phi; spadDraw=yes; rotated=yes; break; case colorDef: readViewman(&(viewport->hueOffset),intSize); readViewman(&(viewport->numberOfHues),intSize); /* spadcolors is indexed by 0 */ viewport->hueOffset --; viewport->numberOfHues --; viewport->hueTop = viewport->numberOfHues; if (viewport->hueOffset < 0) viewport->hueOffset = 0; if (viewport->hueTop < 0) viewport->hueTop = 0; if (viewport->hueOffset >= totalHues) viewport->hueOffset = totalHues-1; if (viewport->hueTop >= totalHues) viewport->hueTop = totalHues-1; viewport->numberOfHues = viewport->hueTop - viewport->hueOffset; if ((viewport->hueTop == viewport->hueOffset) && (!viewport->monoOn)) redoColor = yes; else { redoColor = no; redoDither = yes; } if (viewport->haveControl) drawColorMap(); break; case closeAll: code = check(write(Socket,&ack,intSize)); goodbye(-1); case moveViewport: readViewman(&i1,intSize); readViewman(&i2,intSize); XMoveWindow(dsply,viewport->titleWindow,i1,i2); XSync(dsply,0); break; case resizeViewport: readViewman(&i1,intSize); readViewman(&i2,intSize); XResizeWindow(dsply,viewport->titleWindow,i1,i2+titleHeight); XResizeWindow(dsply,viewport->viewWindow,i1,i2); spadDraw=yes; redoSmooth =yes; break; case transparent: case opaqueMesh: case render: case smooth: viewData.style = viewCommand; spadDraw=yes; redoSmooth =yes; break; case lightDef: readViewman(&(viewport->lightVector[0]),floatSize); readViewman(&(viewport->lightVector[1]),floatSize); readViewman(&(viewport->lightVector[2]),floatSize); normalizeVector(viewport->lightVector); movingLight = yes; drawLightingAxes(); XSync(dsply,0); break; case translucenceDef: readViewman(&backLightIntensity,floatSize); tempLightIntensity = backLightIntensity; lightIntensity = tempLightIntensity; changedIntensity = yes; drawLightTransArrow(); XSync(dsply,0); break; case changeTitle: readViewman(&i1,intSize); readViewman(viewport->title,i1); viewport->title[i1] = '\0'; writeTitle(); switch (doingPanel) { case CONTROLpanel: case CONTOURpanel: writeControlTitle(control->controlWindow); break; case VOLUMEpanel: writeControlTitle(volumeWindow); break; case LIGHTpanel: writeControlTitle(lightingWindow); break; } /* switch */ XFlush(dsply); break; case writeView: readViewman(&i1,intSize); readViewman(filename,i1); filename[i1] = '\0'; sprintf(errorStr,"writing of viewport data"); i3 = 0; readViewman(&i2,intSize); while (i2) { i3 = i3 | (1<<i2); readViewman(&i2,intSize); } if (writeViewport(i3) < 0) fprintf(stderr," Nothing was written\n"); break; case diagOnOff: readViewman(&i1,intSize); if (viewData.outlineRenderOn) { viewport->diagonals = i1; spadDraw=yes; } else { strcpy(control->message," Use this option with Outline "); writeControlMessage(); } break; case outlineOnOff: readViewman(&i1,intSize); if (viewData.style == render) { viewData.outlineRenderOn = i1; spadDraw=yes; if (viewport->haveControl) drawControlPanel(); } else { strcpy(control->message," Use this option in Shaded mode "); writeControlMessage(); } break; case spadPressedAButton: readViewman(&i1,intSize); buttonAction(i1); break; default: return(-1); } /* switch */ ack++; code = check(write(Socket,&ack,intSize)); return(0); }
int spadAction(void) { int code,viewCommand; float f1,f2; int i1,i2,i3,viewGoAhead; static int ack = 1; if (viewAloned==yes) { close(0); return(-1); } readViewman(&viewCommand,intSize); switch (viewCommand) { case hideControl2D: readViewman(&i1,intSize); if (i1) { /* show control panel */ if (viewport->haveControl) XUnmapWindow(dsply,control->controlWindow); putControlPanelSomewhere(someInt); } else { /* turn off control panel */ if (viewport->haveControl) { viewport->haveControl = no; XUnmapWindow(dsply,control->controlWindow); } } break; case changeTitle: readViewman(&i1,intSize); readViewman(viewport->title,i1); viewport->title[i1] = '\0'; writeTitle(); writeControlTitle(); XFlush(dsply); spadDraw=no; break; case writeView: readViewman(&i1,intSize); readViewman(filename,i1); filename[i1] = '\0'; sprintf(errorStr,"writing of viewport data"); i3 = 0; readViewman(&i2,intSize); while (i2) { i3 = i3 | (1<<i2); readViewman(&i2,intSize); } if (writeViewport(i3) < 0) fprintf(stderr," Nothing was written\n"); break; case closeAll2D: code = check(write(Socket,&ack,intSize)); goodbye(-1); case ps2D: readViewman(&i1,intSize); buttonAction(viewCommand); break; case axesOnOff2D: readViewman(&i1,intSize); i1--; readViewman(&i2,intSize); graphStateArray[i1].axesOn = i2; if (graphStateArray[i1].showing) spadDraw=yes; break; case axesColor2D: readViewman(&i1,intSize); i1--; readViewman(&i2,intSize); graphStateArray[i1].axesColor = i2; if (graphStateArray[i1].showing) spadDraw=yes; break; case unitsOnOff2D: readViewman(&i1,intSize); i1--; readViewman(&i2,intSize); graphStateArray[i1].unitsOn = i2; if (graphStateArray[i1].showing) spadDraw=yes; break; case unitsColor2D: readViewman(&i1,intSize); i1--; readViewman(&i2,intSize); graphStateArray[i1].unitsColor = i2; if (graphStateArray[i1].showing) spadDraw=yes; break; case connectOnOff: readViewman(&i1,intSize); i1--; readViewman(&i2,intSize); graphStateArray[i1].connectOn = i2; if (graphStateArray[i1].showing) spadDraw=yes; break; case pointsOnOff: readViewman(&i1,intSize); i1--; readViewman(&i2,intSize); graphStateArray[i1].pointsOn = i2; if (graphStateArray[i1].showing) spadDraw=yes; break; case spline2D: readViewman(&i1,intSize); i1--; readViewman(&i2,intSize); graphStateArray[i1].splineOn = i2; if (graphStateArray[i1].showing) spadDraw=yes; break; case showing2D: readViewman(&i1,intSize); i1--; readViewman(&i2,intSize); /* simulate a button press to turn display number on/off */ graphStateArray[i1].showing = !i2; clickedOnGraph(i1,i1+graphStart); break; case scale2D: readViewman(&i1,intSize); i1--; /* passed index is [1..9] but internal representation is [0..8] */ readViewman(&f1,floatSize); readViewman(&f2,floatSize); graphStateArray[i1].scaleX = f1; graphStateArray[i1].scaleY = f2; if (graphStateArray[i1].scaleX > maxScale) graphStateArray[i1].scaleX = maxScale; else if (graphStateArray[i1].scaleX < minScale) graphStateArray[i1].scaleX = minScale; if (graphStateArray[i1].scaleY > maxScale) graphStateArray[i1].scaleY = maxScale; else if (graphStateArray[i1].scaleY < minScale) graphStateArray[i1].scaleY = minScale; if (graphStateArray[i1].showing) spadDraw=yes; break; /* scale2D */ case translate2D: readViewman(&i1,intSize); i1--; /* passed index is [1..9] but internal representation is [0..8] */ readViewman(&f1,floatSize); readViewman(&f2,floatSize); graphStateArray[i1].centerX = f1; graphStateArray[i1].centerY = f2; if (graphStateArray[i1].centerX > maxDelta) graphStateArray[i1].centerX = maxDelta; else if (graphStateArray[i1].centerX < -maxDelta) graphStateArray[i1].centerX = maxDelta; if (graphStateArray[i1].centerY > maxDelta) graphStateArray[i1].centerY = maxDelta; else if (graphStateArray[i1].centerY < -maxDelta) graphStateArray[i1].centerY = maxDelta; if (graphStateArray[i1].showing) spadDraw=yes; break; /* translate2D */ case moveViewport: readViewman(&i1,intSize); readViewman(&i2,intSize); XMoveWindow(dsply,viewport->titleWindow,i1,i2); XSync(dsply,False); break; case resizeViewport: readViewman(&i1,intSize); readViewman(&i2,intSize); XResizeWindow(dsply,viewport->titleWindow,i1,i2+titleHeight); XResizeWindow(dsply,viewport->viewWindow,i1,i2); spadDraw=yes; break; case putGraph: readViewman(&i1,intSize); /* key of graph to get */ readViewman(&i2,intSize); /* slot to drop graph onto 0..8*/ readViewman(&viewGoAhead,intSize); if (viewGoAhead < 0) { sprintf(control->message,"%s%d","Couldn't put into graph ",i2+1); writeControlMessage(); } else { sprintf(control->message,"%s%d","Dropped onto graph ",i2+1); writeControlMessage(); freeGraph(i2); graphArray[i2].key = i1; getGraphFromViewman(i2); /* simulate a button press to turn display number on and select on */ /* need !yes since it will be inverted */ graphStateArray[i2].selected = no; graphStateArray[i2].connectOn = yes; graphStateArray[i2].showing = !(graphStateArray[i2].showing); clickedOnGraph(i2,i2+graphStart); clickedOnGraphSelect(i2,i2+graphSelectStart); } break; case spadPressedAButton: readViewman(&i1,intSize); buttonAction(i1); break; default: return(-1); } /* switch */ ack++; code = check(write(Socket,&ack,intSize)); return(0); }
void getGraphFromViewman(int i) { /** This routine should be called right after a read of the graph key was made from the viewport manager (or defined in some other way). **/ int j,k,xPointsNeeded; pointListStruct *llPtr; pointStruct *p; readViewman(&(graphArray[i].xmin),floatSize); readViewman(&(graphArray[i].xmax),floatSize); readViewman(&(graphArray[i].ymin),floatSize); readViewman(&(graphArray[i].ymax),floatSize); readViewman(&(graphArray[i].xNorm),floatSize); readViewman(&(graphArray[i].yNorm),floatSize); readViewman(&(graphArray[i].spadUnitX),floatSize); readViewman(&(graphArray[i].spadUnitY),floatSize); readViewman(&(graphArray[i].unitX),floatSize); readViewman(&(graphArray[i].unitY),floatSize); readViewman(&(graphArray[i].originX),floatSize); readViewman(&(graphArray[i].originY),floatSize); readViewman(&(graphArray[i].numberOfLists),intSize); if (!(llPtr = (pointListStruct *)malloc(graphArray[i].numberOfLists * sizeof(pointListStruct)))) { fprintf(stderr,"VIEW2D: Fatal Error>> Ran out of memory trying to receive a graph.\n"); exitWithAck(RootWindow(dsply,scrn),Window,-1); } graphArray[i].listOfListsOfPoints = llPtr; xPointsNeeded = 0; for (j=0; j<graphArray[i].numberOfLists; j++) { readViewman(&(llPtr->numberOfPoints),intSize); if (!(p = (pointStruct *)malloc(llPtr->numberOfPoints * sizeof(pointStruct)))) { fprintf(stderr,"VIEW2D: (pointStruct) ran out of memory trying to create a new graph.\n"); exitWithAck(RootWindow(dsply,scrn),Window,-1); } llPtr->listOfPoints = p; /** point to current point list **/ for (k=0; k<llPtr->numberOfPoints; k++) { readViewman(&(p->x),floatSize); readViewman(&(p->y),floatSize); readViewman(&(p->hue),floatSize); readViewman(&(p->shade),floatSize); p++; } /* for k in list of points */ readViewman(&(llPtr->pointColor),intSize); readViewman(&(llPtr->lineColor),intSize); readViewman(&(llPtr->pointSize),intSize); xPointsNeeded += llPtr->numberOfPoints; llPtr++; } /* for j in list of lists of points */ /* read in graph state for the existing graph (override default values) */ readViewman(&(graphStateArray[i].scaleX),floatSize); readViewman(&(graphStateArray[i].scaleY),floatSize); readViewman(&(graphStateArray[i].deltaX),floatSize); readViewman(&(graphStateArray[i].deltaY),floatSize); readViewman(&(graphStateArray[i].pointsOn),intSize); readViewman(&(graphStateArray[i].connectOn),intSize); readViewman(&(graphStateArray[i].splineOn),intSize); readViewman(&(graphStateArray[i].axesOn),intSize); readViewman(&(graphStateArray[i].axesColor),intSize); readViewman(&(graphStateArray[i].unitsOn),intSize); readViewman(&(graphStateArray[i].unitsColor),intSize); readViewman(&(graphStateArray[i].showing),intSize); graphStateArray[i].selected = yes; graphStateBackupArray[i] = graphStateArray[i]; graphStateArray[i].deltaX = graphStateArray[0].deltaX; graphStateArray[i].deltaY = graphStateArray[0].deltaY; graphStateArray[i].scaleX = graphStateArray[0].scaleX; graphStateArray[i].scaleY = graphStateArray[0].scaleY; /* allocate memory for xPoints (used in drawViewport) */ if (!(xPointsArray[i].xPoint = (XPoint *)malloc(xPointsNeeded * sizeof(XPoint)))) { fprintf(stderr,"VIEW2D: (XPoint) Ran out of memory (malloc) trying to create a new graph.\n"); exitWithAck(RootWindow(dsply,scrn),Window,-1); } if (!(xPointsArray[i].x10Point = (Vertex *)malloc(xPointsNeeded * sizeof(Vertex)))) { fprintf(stderr, "VIEW2D: (X10Point) Ran out of memory (malloc) trying to create a new graph.\n"); exitWithAck(RootWindow(dsply,scrn),Window,-1); } if (!(xPointsArray[i].arc = (XArc *)malloc(xPointsNeeded * sizeof(XArc)))) { fprintf(stderr,"VIEW2D: (XArc) Ran out of memory (malloc) trying to create a new graph.\n"); exitWithAck(RootWindow(dsply,scrn),Window,-1); } } /* getGraphFromViewman */
int main(void) { XGCValues controlGCVals; int i,code; view2DStruct viewData; char property[256]; char *prop = &property[0]; char *str_type[20]; XrmValue value; /**** Set up display ****/ if ((dsply = XOpenDisplay(getenv("DISPLAY"))) == NULL) fprintf(stderr,"Could not open the display.\n"); scrn = DefaultScreen(dsply); rtWindow = RootWindow(dsply,scrn); /**** link Xwindows to viewports - X10 feature ****/ table = XCreateAssocTable(nbuckets); /**** Create FriCAS color map ****/ totalColors = XInitSpadFill(dsply,scrn,&colorMap, &totalHues,&totalSolidShades, &totalDitheredAndSolids,&totalShades); if (totalColors < 0) { fprintf(stderr,">>Error: Could not allocate all the necessary colors.\n"); exitWithAck(RootWindow(dsply,scrn),Window,-1); } mergeDatabases(); /*** Determine whether monochrome or color is used ***/ if (XrmGetResource(rDB,"Axiom.2D.monochrome","",str_type,&value) == True) (void) strncpy(prop,value.addr,(int)value.size); else (void) strcpy(prop, "off"); mono = ((totalSolid == 2) || (strcmp(prop,"on") == 0)); if (XrmGetResource(rDB,"Axiom.2D.inverse","",str_type,&value) == True) (void) strncpy(prop,value.addr,(int)value.size); else (void) strcpy(prop, "off"); if (mono) if (strcmp(prop,"on") == 0) { /* 0 if equal (inverse video) */ foregroundColor = WhitePixel(dsply,scrn); backgroundColor = BlackPixel(dsply,scrn); } else { /* off (no inverse video) */ foregroundColor = BlackPixel(dsply,scrn); backgroundColor = WhitePixel(dsply,scrn); } else /* inverse of inverse in color (for some strange reason) */ if (strcmp(prop,"on") == 0) { /* 0 if equal (inverse video) */ foregroundColor = WhitePixel(dsply,scrn); backgroundColor = BlackPixel(dsply,scrn); } else { /* off (no inverse video) */ foregroundColor = BlackPixel(dsply,scrn); backgroundColor = WhitePixel(dsply,scrn); } /* read default file name for postScript output */ if (XrmGetResource(rDB, "Axiom.2D.postscriptFile", "", str_type, &value) == True) (void) strncpy(prop,value.addr,(int)value.size); else (void) strcpy(prop, "axiom2D.ps"); PSfilename = (char *)malloc(strlen(prop)+1); strcpy(PSfilename,prop); /**** Open global fonts ****/ serverFont = XQueryFont(dsply,XGContextFromGC(DefaultGC(dsply,scrn))); if (XrmGetResource(rDB, "Axiom.2D.messageFont", "Axiom.2D.Font", str_type, &value) == True) (void) strncpy(prop,value.addr,(int)value.size); else (void) strcpy(prop,messageFontDefault); if ((globalFont = XLoadQueryFont(dsply, prop)) == NULL) { fprintf(stderr, "Warning: could not get the %s font for messageFont\n",prop); globalFont = serverFont; } if (XrmGetResource(rDB, "Axiom.2D.buttonFont", "Axiom.2D.Font", str_type, &value) == True) (void) strncpy(prop,value.addr,(int)value.size); else (void) strcpy(prop,buttonFontDefault); if ((buttonFont = XLoadQueryFont(dsply, prop)) == NULL) { fprintf(stderr, "Warning: could not get the %s font for buttonFont\n",prop); buttonFont = serverFont; } if (XrmGetResource(rDB, "Axiom.2D.headerFont", "Axiom.2D.Font", str_type, &value) == True) (void) strncpy(prop,value.addr,(int)value.size); else (void) strcpy(prop,headerFontDefault); if ((headerFont = XLoadQueryFont(dsply, prop)) == NULL) { fprintf(stderr, "Warning: could not get the %s font for headerFont\n",prop); headerFont = serverFont; } if (XrmGetResource(rDB, "Axiom.2D.titleFont", "Axiom.2D.Font", str_type,&value) == True) (void) strncpy(prop,value.addr,(int)value.size); else (void) strcpy(prop,titleFontDefault); if ((titleFont = XLoadQueryFont(dsply, prop)) == NULL) { fprintf(stderr, "Warning: could not get the %s font for titleFont\n",prop); titleFont = serverFont; } if (XrmGetResource(rDB, "Axiom.2D.graphFont", "Axiom.2D.Font", str_type,&value) == True) (void) strncpy(prop,value.addr,(int)value.size); else (void) strcpy(prop,graphFontDefault); if ((graphFont = XLoadQueryFont(dsply, prop)) == NULL) { fprintf(stderr, "Warning: could not get the %s font for graphFont\n",prop); graphFont = serverFont; } if (XrmGetResource(rDB, "Axiom.2D.unitFont", "Axiom.2D.Font", str_type,&value) == True) (void) strncpy(prop,value.addr,(int)value.size); else (void) strcpy(prop,unitFontDefault); if ((unitFont = XLoadQueryFont(dsply, prop)) == NULL) { fprintf(stderr, "Warning: could not get the %s font for unitFont\n",prop); unitFont = serverFont; } /**** Create widely used Graphic Contexts ****/ PSGlobalInit(); /* must initiate before using any G/PS functions need character name: used as postscript GC variable need to create ps GCs for all GCs used by drawings in viewWindow */ /* globalGC1 */ controlGCVals.foreground = monoColor(axesColorDefault); controlGCVals.background = backgroundColor; globalGC1 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground , &controlGCVals); carefullySetFont(globalGC1,globalFont); /* create the equivalent GCs for ps */ PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap, psMiterJoin, psWhite, psBlack); /* controlMessageGC */ controlGCVals.foreground = controlMessageColor; controlMessageGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground ,&controlGCVals); carefullySetFont(controlMessageGC,globalFont); /* globalGC2 */ controlGCVals.foreground = monoColor(labelColor); controlGCVals.background = backgroundColor; globalGC2 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground, &controlGCVals); carefullySetFont(globalGC2,buttonFont); PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap, psMiterJoin, psWhite, psBlack); /* trashGC */ trashGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); carefullySetFont(trashGC,buttonFont); PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap, psMiterJoin, psWhite, psBlack); /* globGC */ globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); carefullySetFont(globGC,headerFont); PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap, psMiterJoin, psWhite, psBlack); /* anotherGC */ controlGCVals.line_width = colorWidth; anotherGC = XCreateGC(dsply,rtWindow,GCBackground,&controlGCVals); carefullySetFont(anotherGC,titleFont); PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap, psMiterJoin, psWhite, psBlack); /* processGC */ gcVals.background = backgroundColor; processGC = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals); carefullySetFont(processGC,buttonFont); /* graphGC */ graphGC = XCreateGC(dsply,rtWindow,GCBackground,&gcVals); carefullySetFont(graphGC,graphFont); PSCreateContext(graphGC, "graphGC", psNormalWidth, psButtCap, psMiterJoin, psWhite, psBlack); /* unitGC */ unitGC = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals); carefullySetFont(unitGC,unitFont); PSCreateContext(unitGC, "unitGC", psNormalWidth, psButtCap, psMiterJoin, psWhite, psBlack); /**** Initialize Graph States ****/ for (i=0; i<maxGraphs; i++) { graphStateArray[i].scaleX = 0.9; graphStateArray[i].scaleY = 0.9; graphStateArray[i].deltaX = 0.0; graphStateArray[i].deltaY = 0.0; graphStateArray[i].centerX = 0.0; graphStateArray[i].centerY = 0.0; graphStateArray[i].pointsOn = yes; graphStateArray[i].connectOn = yes; graphStateArray[i].splineOn = no; graphStateArray[i].axesOn = yes; graphStateArray[i].unitsOn = no; graphStateArray[i].showing = no; graphStateArray[i].selected = no; graphStateBackupArray[i] = graphStateArray[i]; } /**** Get Data from the Viewport Manager ****/ i = 123; code=check(write(Socket,&i,intSize)); /* Check if I am getting stuff from FriCAS or, if I am viewAlone. */ readViewman(&viewAloned,intSize); readViewman(&viewData,sizeof(view2DStruct)); readViewman(&i,intSize); if (!(viewData.title = (char *)malloc(i))) { fprintf(stderr, "ERROR: Ran out of memory trying to receive the title.\n"); exitWithAck(RootWindow(dsply,scrn),Window,-1); } readViewman(viewData.title,i); for (i=0; i<maxGraphs; i++) { readViewman(&(graphArray[i].key),intSize); if (graphArray[i].key) { /** this graph slot has data **/ getGraphFromViewman(i); } /* if graph exists (graphArray[i].key is not zero) */ } /* for i in graphs */ viewport = makeView2D(&viewData); control = viewport->controlPanel; bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls); /* send acknowledgement to viewport manager */ i = 345; check(write(Socket,&(viewport->viewWindow),sizeof(Window))); processEvents(); goodbye(-1); return(0); /* control never reaches here but compiler complains */ } /* main() */