void drawSavePanel(void) { const char* s; int i,strlength; GSetForeground(saveGC,(float)saveButtonColor,Xoption); for (i=saveButtonsStart; i<(saveButtonsEnd); i++) { GDraw3DButtonOut(saveGC,saveWindow, (control->buttonQueue[i]).buttonX, (control->buttonQueue[i]).buttonY, (control->buttonQueue[i]).buttonWidth, (control->buttonQueue[i]).buttonHeight,Xoption); s = (control->buttonQueue[i]).text; strlength = strlen(s); GSetForeground(trashGC, (float)monoColor((control->buttonQueue[i]).textColor),Xoption); GDrawString(trashGC,saveWindow, (control->buttonQueue[i]).buttonX + centerX(processGC,s,strlength, (control->buttonQueue[i]).buttonWidth), (control->buttonQueue[i]).buttonY + centerY(processGC,(control->buttonQueue[i]).buttonHeight), s,strlen(s),Xoption); } /* for i in control->buttonQueue */ } /* drawSavePanel */
void showAxesLabels(int dFlag) { int xcoord2,ycoord2; if (dFlag == Xoption) if (mono || (viewport->monoOn)) GSetForeground(globGC,(float)foregroundColor,dFlag); else GSetForeground(globGC,(float)monoColor(labelColor),dFlag); else GSetForeground(GC9991,psBlack,dFlag); /* axes label for X */ if ((int)axesZ[0][0] >= (int)axesZ[0][1]) { if (axesXY[0][2] < axesXY[0][0]) xcoord2 = axesXY[0][2]-5; else xcoord2 = axesXY[0][2] + 5; if (axesXY[0][3] < axesXY[0][1]) ycoord2 = axesXY[0][3]-5; else ycoord2 = axesXY[0][3] + 5; if (!viewport->yzOn) { if (dFlag == Xoption) GDrawString(globGC,viewmap,xcoord2,ycoord2,"X",1,dFlag); else GDrawString(GC9991,viewport->viewWindow,xcoord2,ycoord2,"X",1,dFlag); } } /* axes label for Y */ if ((int)axesZ[1][0] >= (int)axesZ[1][1]) { if (axesXY[1][2] < axesXY[1][0]) xcoord2 = axesXY[1][2]-5; else xcoord2 = axesXY[1][2] + 5; if (axesXY[1][3] < axesXY[1][1]) ycoord2 = axesXY[1][3]-5; else ycoord2 = axesXY[1][3] + 5; if (!viewport->xzOn) { if (dFlag == Xoption) GDrawString(globGC,viewmap,xcoord2,ycoord2,"Y",1,dFlag); else GDrawString(GC9991,viewport->viewWindow,xcoord2,ycoord2,"Y",1,dFlag); } } /* axes label for Z */ if ((int)axesZ[2][0] >= (int)axesZ[2][1]) { if (axesXY[2][2] < axesXY[2][0]) xcoord2 = axesXY[2][2]-5; else xcoord2 = axesXY[2][2] + 5; if (axesXY[2][3] < axesXY[2][1]) ycoord2 = axesXY[2][3]-5; else ycoord2 = axesXY[2][3] + 5; if (!viewport->xyOn) { if (dFlag == Xoption) GDrawString(globGC,viewmap,xcoord2,ycoord2,"Z",1,dFlag); else GDrawString(GC9991,viewport->viewWindow,xcoord2,ycoord2,"Z",1,dFlag); } } }
void drawClipZBut (void) { XClearArea(dsply,volumeWindow,clipZButX,clipZButY, midAxis+blank,midAxis+blank,False); GSetForeground(trashGC,(float)monoColor(toggleColor),Xoption); GDrawLine(trashGC,volumeWindow,clipZButTopEndX,clipZButTopEndY, clipZButBotEndX,clipZButBotEndY,Xoption); GDrawLine(trashGC,volumeWindow,clipZButTopEndX-4,clipZButTopEndY, clipZButTopEndX,clipZButTopEndY,Xoption); GDrawLine(trashGC,volumeWindow,clipZButTopEndX,clipZButTopEndY-4, clipZButTopEndX,clipZButTopEndY,Xoption); GDrawLine(trashGC,volumeWindow,clipZButBotEndX+4,clipZButBotEndY, clipZButBotEndX,clipZButBotEndY,Xoption); GDrawLine(trashGC,volumeWindow,clipZButBotEndX,clipZButBotEndY+4, clipZButBotEndX,clipZButBotEndY,Xoption); GSetForeground(trashGC,(float)monoColor(arcColor),Xoption); GFillArc(trashGC,volumeWindow, (int)(zClipMinN * midAxis * zFactor + clipZButTopEndX - 3), (int)(zClipMinN * midAxis * zFactor + clipZButTopEndY + 3), arcSize,arcSize,45*64,360*64,Xoption); /* 64 units per degree */ GFillArc(trashGC,volumeWindow, (int)(zClipMaxN * midAxis * zFactor + clipZButTopEndX + 3), (int)(zClipMaxN * midAxis * zFactor + clipZButTopEndY - 5), arcSize,arcSize,45*64,360*64,Xoption); /* 64 units per degree */ GSetForeground(volumeGC,(float)monoColor(toggleColor),Xoption); GDrawString(volumeGC,volumeWindow,clipZMessX,clipZMessY,"Z",1,Xoption); }
void drawEyeControl (void) { float here; int there; GSetForeground(trashGC,(float)eyeColor,Xoption); /* draw the eyeDistance box & slide bar */ GDraw3DButtonOut(trashGC,volumeWindow, frusX(eyeWinX),frusY(eyeWinY+5),eyeWidth,eyeHeight,Xoption); GDrawLine(trashGC,volumeWindow, frusX(eyeMinX),frusY(eyeBarY+5),frusX(eyeMaxX),frusY(eyeBarY+5),Xoption); here = (viewData.eyeDistance - minEyeDistance) / (maxEyeDistance - minEyeDistance); here = pow((double)here,0.333333); there = here * (eyeMaxX - eyeMinX) + eyeMinX; /* screen x */ GDrawLine(trashGC,volumeWindow, frusX(there),frusY(eyeBarY+2),frusX(there),frusY(eyeBarY+8),Xoption); /* draw the eye */ GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption); GSetForeground(trashGC,(float)monoColor(52),Xoption); GDrawLine(trashGC,volumeWindow, frusX(there),frusY(frustrumMidY-5), frusX(there+8),frusY(frustrumMidY),Xoption); GDrawLine(trashGC,volumeWindow, frusX(there+2),frusY(frustrumMidY+4), frusX(there+8),frusY(frustrumMidY-1),Xoption); GSetForeground(trashGC,(float)frustrumColor,Xoption); GDrawLine(trashGC,volumeWindow, frusX(there+4),frusY(frustrumMidY-3), frusX(there+2),frusY(frustrumMidY),Xoption); GDrawLine(trashGC,volumeWindow, frusX(there+4),frusY(frustrumMidY+2), frusX(there+3),frusY(frustrumMidY),Xoption); GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,Xoption); /* draw string label */ GSetForeground(volumeGC,(float)eyeColor,Xoption); GDrawString(volumeGC,volumeWindow,eyeDistMessX,eyeDistMessY, "Eye Distance",strlen("eye distance"),Xoption); }
void drawLightingPanel(void) { char *s; int i,strlength; /* Draw border lines to separate the lighting window, potentiometers, and button regions of the lightng subpanel. */ GSetForeground(trashGC,(float)foregroundColor,Xoption); GSetLineAttributes(trashGC,3,LineSolid,CapButt,JoinMiter,Xoption); GDrawLine(trashGC, lightingWindow, 0, potA, controlWidth, potA, Xoption); GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption); GDrawLine(trashGC, lightingWindow, 0, lightB, controlWidth, lightB, Xoption); GDrawLine(trashGC, lightingWindow, 0, lightPotA, controlWidth, lightPotA, Xoption); GDrawLine(trashGC, lightingWindow, 0, lightPotB, controlWidth, lightPotB, Xoption); GDrawLine(trashGC, lightingWindow, lightTransL, lightPotA, lightTransL, lightPotB, Xoption); writeControlTitle(lightingWindow); s = "Lighting Control Panel"; strlength = strlen(s); GSetForeground(anotherGC,(float)lightingTitleColor,Xoption); GDrawString(anotherGC, lightingWindow, centerX(anotherGC, s, strlength, controlWidth), lightB+18, s, strlength, Xoption); for (i=lightingButtonsStart; i<(lightingButtonsEnd); i++) { switch (i) { case lightMove: GSetForeground(lightingGC,(float)lightingButtonColor,Xoption); GDraw3DButtonOut(lightingGC,lightingWindow, (control->buttonQueue[i]).buttonX, (control->buttonQueue[i]).buttonY, (control->buttonQueue[i]).buttonWidth, (control->buttonQueue[i]).buttonHeight,Xoption); GSetForeground(lightingGC,(float)monoColor(buttonColor),Xoption); GDrawLine(lightingGC,lightingWindow, (control->buttonQueue[i]).buttonX + (control->buttonQueue[i]).xHalf, (control->buttonQueue[i]).buttonY, (control->buttonQueue[i]).buttonX + (control->buttonQueue[i]).xHalf, (control->buttonQueue[i]).buttonY + 2*(control->buttonQueue[i]).yHalf,Xoption); GDrawLine(lightingGC,lightingWindow, (control->buttonQueue[i]).buttonX, (control->buttonQueue[i]).buttonY + (control->buttonQueue[i]).yHalf, (control->buttonQueue[i]).buttonX + 2*(control->buttonQueue[i]).xHalf, (control->buttonQueue[i]).buttonY + (control->buttonQueue[i]).yHalf,Xoption); break; case lightMoveXY: GSetForeground(lightingGC,(float)lightingButtonColor,Xoption); GDraw3DButtonOut(lightingGC,lightingWindow, (control->buttonQueue[i]).buttonX, (control->buttonQueue[i]).buttonY, (control->buttonQueue[i]).buttonWidth, (control->buttonQueue[i]).buttonHeight,Xoption); GSetForeground(lightingGC,(float)monoColor(buttonColor),Xoption); GDrawLine(lightingGC,lightingWindow, (control->buttonQueue[i]).buttonX + (control->buttonQueue[i]).xHalf, (control->buttonQueue[i]).buttonY, (control->buttonQueue[i]).buttonX + (control->buttonQueue[i]).xHalf, (control->buttonQueue[i]).buttonY + 2*(control->buttonQueue[i]).yHalf,Xoption); GDrawLine(lightingGC,lightingWindow, (control->buttonQueue[i]).buttonX, (control->buttonQueue[i]).buttonY + (control->buttonQueue[i]).yHalf, (control->buttonQueue[i]).buttonX + 2*(control->buttonQueue[i]).xHalf, (control->buttonQueue[i]).buttonY + (control->buttonQueue[i]).yHalf,Xoption); break; case lightMoveZ: GSetForeground(lightingGC,(float)lightingButtonColor,Xoption); GDraw3DButtonOut(lightingGC,lightingWindow, (control->buttonQueue[i]).buttonX, (control->buttonQueue[i]).buttonY, (control->buttonQueue[i]).buttonWidth, (control->buttonQueue[i]).buttonHeight,Xoption); GSetForeground(lightingGC,(float)monoColor(buttonColor),Xoption); GDrawLine(lightingGC,lightingWindow, (control->buttonQueue[i]).buttonX + (control->buttonQueue[i]).xHalf, (control->buttonQueue[i]).buttonY, (control->buttonQueue[i]).buttonX + (control->buttonQueue[i]).xHalf, (control->buttonQueue[i]).buttonY + 2*(control->buttonQueue[i]).yHalf,Xoption); GDrawLine(lightingGC,lightingWindow, (control->buttonQueue[i]).buttonX + (control->buttonQueue[i]).xHalf - (control->buttonQueue[i]).xHalf/2, (control->buttonQueue[i]).buttonY + (control->buttonQueue[i]).yHalf, (control->buttonQueue[i]).buttonX + (control->buttonQueue[i]).xHalf + (control->buttonQueue[i]).xHalf/2, (control->buttonQueue[i]).buttonY + (control->buttonQueue[i]).yHalf,Xoption); break; case lightTranslucent: drawLightTransArrow(); break; default: GDraw3DButtonOut(lightingGC,lightingWindow, (control->buttonQueue[i]).buttonX, (control->buttonQueue[i]).buttonY, (control->buttonQueue[i]).buttonWidth, (control->buttonQueue[i]).buttonHeight,Xoption); s = (control->buttonQueue[i]).text; strlength = strlen(s); GSetForeground(trashGC, (float)monoColor((control->buttonQueue[i]).textColor),Xoption); GDrawString(trashGC, lightingWindow, (control->buttonQueue[i]).buttonX + centerX(processGC,s,strlength, (control->buttonQueue[i]).buttonWidth), (control->buttonQueue[i]).buttonY + centerY(processGC,(control->buttonQueue[i]).buttonHeight), s,strlen(s),Xoption); } /* switch */ } /* for i in control->buttonQueue */ GSetForeground(lightingGC,(float)monoColor(labelColor),Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightMoveXY].buttonX + control->buttonQueue[lightMoveXY].buttonWidth + 3, control->buttonQueue[lightMoveXY].buttonY + control->buttonQueue[lightMoveXY].yHalf, "x",1,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightMoveXY].buttonX + control->buttonQueue[lightMoveXY].xHalf - 2, control->buttonQueue[lightMoveXY].buttonY - 4, "y",1,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightMoveZ].buttonX + control->buttonQueue[lightMoveZ].xHalf - 2, control->buttonQueue[lightMoveZ].buttonY - 4, "z",1,Xoption); /** Draw the title for the intensity potentiometer. */ GSetForeground(lightingGC,(float)lightingTransColor,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightTranslucent].buttonX + control->buttonQueue[lightTranslucent].buttonWidth + 3, control->buttonQueue[lightTranslucent].buttonY, "I",1,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightTranslucent].buttonX + control->buttonQueue[lightTranslucent].buttonWidth + 3, control->buttonQueue[lightTranslucent].buttonY + lightFontHeight, "n",1,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightTranslucent].buttonX + control->buttonQueue[lightTranslucent].buttonWidth + 3, control->buttonQueue[lightTranslucent].buttonY + lightFontHeight*2, "t",1,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightTranslucent].buttonX + control->buttonQueue[lightTranslucent].buttonWidth + 3, control->buttonQueue[lightTranslucent].buttonY + lightFontHeight*3, "e",1,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightTranslucent].buttonX + control->buttonQueue[lightTranslucent].buttonWidth + 3, control->buttonQueue[lightTranslucent].buttonY + lightFontHeight*4, "n",1,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightTranslucent].buttonX + control->buttonQueue[lightTranslucent].buttonWidth + 3, control->buttonQueue[lightTranslucent].buttonY + lightFontHeight*5, "s",1,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightTranslucent].buttonX + control->buttonQueue[lightTranslucent].buttonWidth + 3, control->buttonQueue[lightTranslucent].buttonY + lightFontHeight*6, "i",1,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightTranslucent].buttonX + control->buttonQueue[lightTranslucent].buttonWidth + 3, control->buttonQueue[lightTranslucent].buttonY + lightFontHeight*7, "t",1,Xoption); GDrawString(lightingGC,lightingWindow, control->buttonQueue[lightTranslucent].buttonX + control->buttonQueue[lightTranslucent].buttonWidth + 3, control->buttonQueue[lightTranslucent].buttonY + lightFontHeight*8, "y",1,Xoption); drawLightingAxes(); drawLightTransArrow(); } /* drawLightingPanel */
void drawLightingAxes(void) { XWindowAttributes laInfo; int i,xCenter,yCenter; float Px0,Py0; int vPx0,vPy0,vPx1,vPy1; viewTriple pointX,pointY,pointXY,pointXYZ; XGetWindowAttributes(dsply,lightingAxes,&laInfo); XClearWindow(dsply,lightingAxes); xCenter = laInfo.width / 2; yCenter = laInfo.height / 2; sinTheta = sin(-viewport->theta); cosTheta = cos(-viewport->theta); sinPhi = sin(viewport->phi); cosPhi = cos(viewport->phi); GSetForeground(lightingGC,(float)monoColor(buttonColor),Xoption); for (i=0; i < 3; i++) { Px0 = proj2PX(axes[i][0],axes[i][1]); Py0 = proj2PY(axes[i][0],axes[i][1],axes[i][2]); vPx0 = Px0 * lightScale + xCenter; vPy0 = laInfo.height - (Py0 * lightScale + yCenter); Px0 = proj2PX(axes[i][3],axes[i][4]); Py0 = proj2PY(axes[i][3],axes[i][4],axes[i][5]); vPx1 = Px0 * lightScale + xCenter; vPy1 = laInfo.height - (Py0 * lightScale + yCenter); GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption); } GSetForeground(lightingGC,(float)lightingLabelColor,Xoption); for (i=0; i < basicScreen; i++) { Px0 = proj2PX(labels[i][0],labels[i][1]); Py0 = proj2PY(labels[i][0],labels[i][1],labels[i][2]); vPx0 = Px0 * lightScale + xCenter; vPy0 = laInfo.height - (Py0 * lightScale + yCenter); Px0 = proj2PX(labels[i][3],labels[i][4]); Py0 = proj2PY(labels[i][3],labels[i][4],labels[i][5]); vPx1 = Px0 * lightScale + xCenter; vPy1 = laInfo.height - (Py0 * lightScale + yCenter); GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption); } GSetForeground(lightingGC,(float)lightingBoxColor,Xoption); pointX.x = tempLightPointer[0] * lightAxesScale; pointX.y = 0; pointX.z = 0; pointY.x = 0; pointY.y = tempLightPointer[1] * lightAxesScale; pointY.z = 0; pointXY.x = tempLightPointer[0] * lightAxesScale; pointXY.y = tempLightPointer[1] * lightAxesScale; pointXY.z = 0; pointXYZ.x = tempLightPointer[0] * lightAxesScale; pointXYZ.y = tempLightPointer[1] * lightAxesScale; pointXYZ.z = tempLightPointer[2] * lightAxesScale; Px0 = proj2PX(pointXY.x,pointXY.y); Py0 = proj2PY(pointXY.x,pointXY.y,pointXY.z); vPx0 = Px0 * lightScale + xCenter; vPy0 = laInfo.height - (Py0 * lightScale + yCenter); Px0 = proj2PX(pointX.x,pointX.y); Py0 = proj2PY(pointX.x,pointX.y,pointX.z); vPx1 = Px0 * lightScale + xCenter; vPy1 = laInfo.height - (Py0 * lightScale + yCenter); GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption); Px0 = proj2PX(pointY.x,pointY.y); Py0 = proj2PY(pointY.x,pointY.y,pointY.z); vPx1 = Px0 * lightScale + xCenter; vPy1 = laInfo.height - (Py0 * lightScale + yCenter); GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption); Px0 = proj2PX(pointXYZ.x,pointXYZ.y); Py0 = proj2PY(pointXYZ.x,pointXYZ.y,pointXYZ.z); vPx1 = Px0 * lightScale + xCenter; vPy1 = laInfo.height - (Py0 * lightScale + yCenter); GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption); GSetForeground(lightingGC,(float)lightingLightColor,Xoption); Px0 = proj2PX(point0.x,point0.y); Py0 = proj2PY(point0.x,point0.y,point0.z); vPx0 = Px0 * lightScale + xCenter; vPy0 = laInfo.height - (Py0 * lightScale + yCenter); GDrawLine(lightingGC,lightingAxes,vPx0,vPy0,vPx1,vPy1,Xoption); } /* drawLightingAxes */
void drawVolumePanel (void) { int i,strlength; /* Draw some lines for volume panel. */ GSetForeground(trashGC,(float)foregroundColor,Xoption); GSetLineAttributes(trashGC,3,LineSolid,CapButt,JoinMiter,Xoption); GDrawLine(trashGC, volumeWindow, 0, potA, controlWidth, potA, Xoption); GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption); GDrawLine(trashGC, volumeWindow, 0, volumeTitleA, controlWidth, volumeTitleA, Xoption); GDrawLine(trashGC, volumeWindow, 0, volumeTitleB, controlWidth, volumeTitleB, Xoption); writeControlTitle(volumeWindow); s = "Viewing Volume Panel"; strlength = strlen(s); GSetForeground(anotherGC,(float)volumeTitleColor,Xoption); GDrawString(anotherGC,volumeWindow, centerX(anotherGC,s,strlength,controlWidth), volumeTitleA+18,s,strlength,Xoption); GSetForeground(anotherGC,(float)monoColor(toggleColor),Xoption); GDrawString(anotherGC,volumeWindow, control->buttonQueue[perspectiveBut].buttonX + 4, control->buttonQueue[perspectiveBut].buttonY - 17, "Settings", 8, Xoption); GSetForeground(trashGC,(float)monoColor(toggleColor),Xoption); GDraw3DButtonOut(trashGC,volumeWindow, control->buttonQueue[perspectiveBut].buttonX - 7, control->buttonQueue[perspectiveBut].buttonY - 36, 100,100,Xoption); for (i=0; i<strlen(clipMess); i++) GDrawString(trashGC,volumeWindow,clipMessX,clipMessY + i*clipMessDy, &(clipMess[i]),1,Xoption); for (i=0; i<strlen(eyeMess1); i++) GDrawString(trashGC,volumeWindow,eyeMess1X,eyeMess1Y + i*eyeMess1Dy, &(eyeMess1[i]),1,Xoption); for (i=0; i<strlen(eyeMess2); i++) GDrawString(trashGC,volumeWindow,eyeMess2X,eyeMess2Y + i*eyeMess2Dy, &(eyeMess2[i]),1,Xoption); GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,Xoption); GSetForeground(trashGC,(float)volumeButtonColor,Xoption); for (i=volumeButtonsStart; i<(volumeButtonsEnd); i++) { GSetForeground(trashGC, (float)monoColor((control->buttonQueue[i]).textColor),Xoption); switch (i) { case perspectiveBut: case clipRegionBut: case clipSurfaceBut: GSetForeground(volumeGC,(float)monoColor(toggleColor),Xoption); GDraw3DButtonOut(volumeGC,volumeWindow, (control->buttonQueue[i]).buttonX, (control->buttonQueue[i]).buttonY, (control->buttonQueue[i]).buttonWidth, (control->buttonQueue[i]).buttonHeight,Xoption); GSetForeground(volumeGC, (float)monoColor((control->buttonQueue[i]).textColor),Xoption); GDrawString(volumeGC,volumeWindow, (control->buttonQueue[i]).buttonX + (control->buttonQueue[i]).buttonWidth + 4, (control->buttonQueue[i]).buttonY + centerY(volumeGC,(control->buttonQueue[i]).buttonHeight), (control->buttonQueue[i]).text, strlen(control->buttonQueue[i].text),Xoption); if (i==perspectiveBut && viewData.perspective) GDrawString(volumeGC,volumeWindow, (control->buttonQueue[i]).buttonX + centerX(volumeGC,"x",1, (control->buttonQueue[i]).buttonWidth), (control->buttonQueue[i]).buttonY + centerY(volumeGC,(control->buttonQueue[i]).buttonHeight), "x",1,Xoption); else if (i==clipRegionBut && viewData.clipbox) GDrawString(volumeGC,volumeWindow, (control->buttonQueue[i]).buttonX + centerX(volumeGC,"x",1, (control->buttonQueue[i]).buttonWidth), (control->buttonQueue[i]).buttonY + centerY(volumeGC,(control->buttonQueue[i]).buttonHeight), "x",1,Xoption); else if (i==clipSurfaceBut && viewData.clipStuff) GDrawString(volumeGC,volumeWindow, (control->buttonQueue[i]).buttonX + centerX(volumeGC,"x",1, (control->buttonQueue[i]).buttonWidth), (control->buttonQueue[i]).buttonY + centerY(volumeGC,(control->buttonQueue[i]).buttonHeight), "x",1,Xoption); break; case clipXBut: drawClipXBut(); break; case clipYBut: drawClipYBut(); break; case clipZBut: drawClipZBut(); break; case frustrumBut: break; default: GDraw3DButtonOut(trashGC,volumeWindow, (control->buttonQueue[i]).buttonX, (control->buttonQueue[i]).buttonY, (control->buttonQueue[i]).buttonWidth, (control->buttonQueue[i]).buttonHeight,Xoption); s = (control->buttonQueue[i]).text; strlength = strlen(s); GSetForeground(trashGC, (float)monoColor((control->buttonQueue[i]).textColor),Xoption); GDrawString(trashGC,volumeWindow, (control->buttonQueue[i]).buttonX + centerX(processGC,s,strlength, (control->buttonQueue[i]).buttonWidth), (control->buttonQueue[i]).buttonY + centerY(processGC,(control->buttonQueue[i]).buttonHeight), s,strlen(s),Xoption); } /* switch */ } /* for i in volumeButtons */ drawFrustrum(); drawClipVolume(); /*** put in header ***/ drawClipXBut(); drawClipYBut(); drawClipZBut(); } /* drawVolumePanel() */
void drawClipYBut (void) { XClearArea(dsply,volumeWindow,clipYButX,clipYButY, minorAxis+blank,majorAxis+blank,False); GSetForeground(trashGC,(float)monoColor(toggleColor),Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY + (control->buttonQueue[clipYBut]).buttonHeight,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf-3, (control->buttonQueue[clipYBut]).buttonY-3, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf+3, (control->buttonQueue[clipYBut]).buttonY-3, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf-3, (control->buttonQueue[clipYBut]).buttonY + (control->buttonQueue[clipYBut]).buttonHeight+3, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY + (control->buttonQueue[clipYBut]).buttonHeight,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf+3, (control->buttonQueue[clipYBut]).buttonY + (control->buttonQueue[clipYBut]).buttonHeight+3, (control->buttonQueue[clipYBut]).buttonX + (control->buttonQueue[clipYBut]).xHalf, (control->buttonQueue[clipYBut]).buttonY + (control->buttonQueue[clipYBut]).buttonHeight,Xoption); GSetForeground(trashGC,(float)monoColor(arcColor),Xoption); /* note: minimum buttons closer to the box */ GFillArc(trashGC,volumeWindow, (int)(clipYButX + minorAxis/2 - 8), (int)(yClipMinN * (majorAxis-tinyArc) + clipYButY), arcSize,arcSize,90*64,360*64,Xoption); /* 64 units per degree */ GFillArc(trashGC,volumeWindow, (int)(clipYButX + minorAxis/2 + 3), (int)(yClipMaxN * (majorAxis-tinyArc) + clipYButY), arcSize,arcSize,90*64,360*64,Xoption); /* 64 units per degree */ GSetForeground(volumeGC,(float)monoColor(toggleColor),Xoption); GDrawString(volumeGC,volumeWindow,clipYMessX,clipYMessY,"Y",1,Xoption); }
void drawClipXBut (void) { XClearArea(dsply,volumeWindow,clipXButX,clipXButY, majorAxis+blank,minorAxis+blank,False); GSetForeground(trashGC,(float)monoColor(toggleColor),Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipXBut]).buttonX, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf, (control->buttonQueue[clipXBut]).buttonX + (control->buttonQueue[clipXBut]).buttonWidth, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipXBut]).buttonX-3, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf-3, (control->buttonQueue[clipXBut]).buttonX, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipXBut]).buttonX-3, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf+3, (control->buttonQueue[clipXBut]).buttonX, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipXBut]).buttonX + (control->buttonQueue[clipXBut]).buttonWidth+3, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf-3, (control->buttonQueue[clipXBut]).buttonX + (control->buttonQueue[clipXBut]).buttonWidth, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf,Xoption); GDrawLine(trashGC,volumeWindow, (control->buttonQueue[clipXBut]).buttonX + (control->buttonQueue[clipXBut]).buttonWidth+3, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf+3, (control->buttonQueue[clipXBut]).buttonX + (control->buttonQueue[clipXBut]).buttonWidth, (control->buttonQueue[clipXBut]).buttonY + (control->buttonQueue[clipXBut]).yHalf,Xoption); GSetForeground(trashGC,(float)monoColor(arcColor),Xoption); GFillArc(trashGC,volumeWindow, (int)(xClipMinN * (majorAxis-tinyArc) + clipXButX), /* x value */ (int)(clipXButY + minorAxis/2 + 1), /* y value */ arcSize,arcSize,0,360*64,Xoption); /* 64 units per degree */ GFillArc(trashGC,volumeWindow, (int)(xClipMaxN * (majorAxis-tinyArc) + clipXButX), /* x value */ (int)(clipXButY + minorAxis/2 - 7), /* y value */ arcSize,arcSize,0,360*64,Xoption); /* 64 units per degree */ GSetForeground(volumeGC,(float)monoColor(toggleColor),Xoption); GDrawString(volumeGC,volumeWindow,clipXMessX,clipXMessY,"X",1,Xoption); }
void scanLines(int dFlag) { unsigned long pixColor; int i; char tempA; if (dFlag == Xoption) { if (viewmap_valid) { XFreePixmap(dsply,viewmap); viewmap_valid=0; } viewmap = XCreatePixmap(/* display */ dsply, /* drawable */ viewport->viewWindow, /* width */ vwInfo.width, /* height */ vwInfo.height, /* depth */ DefaultDepth(dsply,scrn)); viewmap_valid =1; GSetForeground(trashGC,(float)backgroundColor,dFlag); XFillRectangle(dsply,viewmap,trashGC,0,0,vwInfo.width,vwInfo.height); XFillRectangle(dsply,viewport->viewWindow,trashGC,0,0, vwInfo.width,vwInfo.height); } else { GSetForeground(GC9991, 1.0-(float)((int)(psShadeMax-0.3*psShadeMax)-1)*psShadeMul,dFlag); quadMesh[0].x = 0; quadMesh[0].y = 0; quadMesh[1].x = graphWindowAttrib.width+2; quadMesh[1].y = 0; quadMesh[2].x = graphWindowAttrib.width+2; quadMesh[2].y = graphWindowAttrib.height; quadMesh[3].x = 0; quadMesh[3].y = graphWindowAttrib.height; quadMesh[4].x = 0; quadMesh[4].y = 0; PSFillPolygon(GC9991, quadMesh, 5); } if (graphWindowAttrib.height >= physicalHeight) graphWindowAttrib.height = physicalHeight - 1; if (graphWindowAttrib.width >= physicalWidth) graphWindowAttrib.width = physicalWidth - 1; if (dFlag == Xoption) strcpy(control->message," Display Scanlines "); else strcpy(control->message," Writing Output "); writeControlMessage(); scanline = graphWindowAttrib.height-1; imageX = XCreateImage(/* display */ dsply, /* visual */ DefaultVisual(dsply,scrn), /* depth */ DefaultDepth(dsply,scrn), /* format */ ZPixmap, /* offset */ 0, /* data */ 0, /* width */ vwInfo.width, /* height */ 1, /* bitmap_pad */ 32, /* bytes_per_line */ 0); imageX->data = (char *)malloc(imageX->bytes_per_line); while (scanline >= 0 && keepDrawingViewport()) { /* initialize buffer values for scanline */ pixColor = backgroundColor; for (i=0; i < (int)graphWindowAttrib.width; i++) { put_zBuffer(i,10000.0); put_cBuffer_indx(i,-1); put_cBuffer_axes(i,'0'); if (mono || viewport->monoOn) if ((scanline % 2) == 0) if ((i % 2) == 0) { if (i>=0 && i<vwInfo.width) XPutPixel(imageX,i,0,backgroundColor); } else { if (i>=0 && i<vwInfo.width) XPutPixel(imageX,i,0,foregroundColor); } else if ((i % 2) == 0) { if (i>=0 && i<vwInfo.width) XPutPixel(imageX,i,0,foregroundColor); } else { if (i>=0 && i<vwInfo.width) XPutPixel(imageX,i,0,backgroundColor); } else { if (i>=0 && i<vwInfo.width) XPutPixel(imageX,i,0,backgroundColor); } } /* writes the axes info to the buffers */ if (viewData.box) boxTObuffer(); if (viewData.clipbox) clipboxTObuffer(); if (viewport->axesOn) axesTObuffer(); /* fill buffers for current scanline */ scanPhong(dFlag); for (i=0; i < (int)graphWindowAttrib.width; i++) { /* include bounding region info */ if (viewData.box) { if (get_cBuffer_axes(i) == 'b') { if (dFlag==Xoption) { if (mono || (viewport->monoOn)) pixColor = foregroundColor; else pixColor = boxInline; if (i >=0 && i<vwInfo.width) XPutPixel(imageX,i,0,pixColor); } else { GSetForeground(GC9991, psBlack, dFlag ); GDrawPoint(viewport->viewWindow, GC9991, i,scanline,dFlag); } } } /* include clipping box info */ if (viewData.clipbox) { if (get_cBuffer_axes(i)== 'c') { if (dFlag==Xoption) { if (mono || (viewport->monoOn)) pixColor = foregroundColor; else pixColor = clipBoxInline; if (i >=0 && i<vwInfo.width) XPutPixel(imageX,i,0,pixColor); } else { GSetForeground(GC9991, psBlack, dFlag ); GDrawPoint(viewport->viewWindow, GC9991, i,scanline,dFlag); } } } /* include axes info */ if (viewport->axesOn) { if (get_cBuffer_axes(i) == 'a') { if (dFlag == Xoption) { if (mono || (viewport->monoOn)) pixColor = foregroundColor; else pixColor = monoColor(axesColor); if (i >=0 && i<vwInfo.width) XPutPixel(imageX,i,0,pixColor); } else { GSetForeground(GC9991,psBlack,dFlag); GDrawPoint(viewport->viewWindow, GC9991, i,scanline,dFlag); } } /* if buffer slot is an axes point */ tempA = get_cBuffer_axes(i); } else tempA = '0'; /* else axes not on */ if (get_cBuffer_indx(i) >= 0 && (tempA == '0')) { if (dFlag == Xoption) { GSetForeground(trashGC,(float)get_cBuffer_indx(i),dFlag); pixColor = get_cBuffer_indx(i); if (i >=0 && i<vwInfo.width) XPutPixel(imageX,i,0,pixColor); } else { GSetForeground(GC9991,(float)get_cBuffer_indx(i),dFlag); GDrawPoint(viewport->viewWindow, GC9991, i,scanline,dFlag); } } } /* for each pixel in scanline */ if (dFlag == Xoption) { XPutImage(dsply,viewport->viewWindow,trashGC,imageX,0,0,0, scanline,vwInfo.width,1); XPutImage(dsply,viewmap,trashGC,imageX,0,0,0, scanline,vwInfo.width,1); } scanline--; } /* while each scanline */ XDestroyImage(imageX); }
void drawControlPanel(void) { controlPanelStruct *cp; int i,strlength; char *s; cp = viewport->controlPanel; /* Draw border lines to separate the potentiometer, message, graph select and button regions of the control panel. */ GSetForeground(trashGC,(float)foregroundColor,Xoption); GSetLineAttributes(trashGC,3,LineSolid,CapButt,JoinMiter,Xoption); GDrawLine(trashGC, cp->controlWindow, 0, potA, controlWidth, potA, Xoption); GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption); GDrawLine(trashGC, cp->controlWindow, 0, potB, controlWidth, potB, Xoption); GDrawLine(trashGC, cp->controlWindow, 0, messageBot, controlWidth, messageBot, Xoption); GDrawLine(trashGC, cp->controlWindow, 0, 286, controlWidth, 286, Xoption); /** put the line width as 1 last because used below as well **/ GSetLineAttributes(trashGC,1,LineSolid,CapButt,JoinMiter,Xoption); GDrawRectangle(trashGC,cp->controlWindow,closeLeft,closeTop, (controlWidth-closeLeft+8),(controlHeight-closeTop+8),Xoption); /* Write potentiometer titles on the control panel. */ writeControlTitle(); GSetForeground(globGC,(float)controlPotHeaderColor,Xoption); s = "Scale"; strlength = strlen(s); GDrawString(globGC,cp->controlWindow, centerX(globGC,s,strlength, cp->buttonQueue[scale2D].buttonWidth) + cp->buttonQueue[scale2D].buttonX, 31+headerHeight,s,strlength,Xoption); s = "Translate"; strlength = strlen(s); GDrawString(globGC,cp->controlWindow, centerX(globGC,s,strlength, cp->buttonQueue[translate2D].buttonWidth) + cp->buttonQueue[translate2D].buttonX, 31+headerHeight,s,strlen(s),Xoption); GSetForeground(globGC,(float)controlColorColor,Xoption); /* Write title of the graph selection window. */ s = "Graphs"; strlength = strlen(s); GDrawString(globGC,cp->controlWindow, centerX(globGC,s,strlength,controlWidth),graphHeaderHeight, s,strlength,Xoption); /* Write titles on regular buttons and draw pixmaps on potentiometers. */ for (i=0; i<(maxButtons2D); i++) { if ((cp->buttonQueue[i]).pot) { GSetForeground(globalGC1,(float)buttonColor,Xoption); GDrawRectangle(globalGC1,cp->controlWindow, (cp->buttonQueue[i]).buttonX, (cp->buttonQueue[i]).buttonY, (cp->buttonQueue[i]).buttonWidth, (cp->buttonQueue[i]).buttonHeight,Xoption); GSetForeground(trashGC, (float)monoColor((cp->buttonQueue[i]).textColor),Xoption); GDrawLine(globalGC1,cp->controlWindow, /* trashGC, */ (cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf, (cp->buttonQueue[i]).buttonY, (cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf, (cp->buttonQueue[i]).buttonY + 2*(cp->buttonQueue[i]).yHalf,Xoption); GDrawLine(globalGC1,cp->controlWindow, /* trashGC, */ (cp->buttonQueue[i]).buttonX, (cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf, (cp->buttonQueue[i]).buttonX + 2*(cp->buttonQueue[i]).xHalf, (cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,Xoption); switch (i) { case scale2D: GDrawLines(trashGC,cp->controlWindow,scaleArrow, scaleArrowN,CoordModeOrigin,Xoption); break; case translate2D: GDrawLines(trashGC,cp->controlWindow,translateArrow, translateArrowN,CoordModeOrigin,Xoption); break; } /* switch i */ } else if (cp->buttonQueue[i].graphNum) { if (mono) { if (graphStateArray[i-graphStart].showing) { GSetForeground(graphGC,(float)backgroundColor,Xoption); GSetBackground(graphGC,(float)foregroundColor,Xoption); } else { GSetForeground(graphGC,(float)foregroundColor,Xoption); GSetBackground(graphGC,(float)backgroundColor,Xoption); } strlength = strlen((cp->buttonQueue[i]).text); GDrawImageString(graphGC,cp->controlWindow, (cp->buttonQueue[i]).buttonX + centerX(graphGC,cp->buttonQueue[i].text, strlength,(cp->buttonQueue[i]).buttonWidth), (cp->buttonQueue[i]).buttonY + centerY(graphGC,(cp->buttonQueue[i]).buttonHeight), cp->buttonQueue[i].text,strlength,Xoption); } else { if (graphStateArray[i-graphStart].showing) GSetForeground(graphGC,(float)graphBarShowingColor,Xoption); else GSetForeground(graphGC,(float)graphBarHiddenColor,Xoption); strlength = strlen((cp->buttonQueue[i]).text); GDrawString(graphGC,cp->controlWindow, (cp->buttonQueue[i]).buttonX + centerX(graphGC,cp->buttonQueue[i].text, strlength,(cp->buttonQueue[i]).buttonWidth), (cp->buttonQueue[i]).buttonY + centerY(graphGC,(cp->buttonQueue[i]).buttonHeight), cp->buttonQueue[i].text,strlength,Xoption); } } else if (cp->buttonQueue[i].graphSelect) { /* The select characters are defined as: "^" for on and "-" for off. */ if (graphStateArray[i-graphSelectStart].selected) { GSetForeground(graphGC,(float)graphBarSelectColor,Xoption); strcpy((cp->buttonQueue[i]).text,"^"); } else { GSetForeground(graphGC,(float)graphBarNotSelectColor,Xoption); *(cp->buttonQueue[i]).text = '-'; strcpy((cp->buttonQueue[i]).text,"-"); } GDrawString(graphGC,cp->controlWindow, (cp->buttonQueue[i]).buttonX + centerX(graphGC,cp->buttonQueue[i].text, strlength,(cp->buttonQueue[i]).buttonWidth), (cp->buttonQueue[i]).buttonY + centerY(graphGC,(cp->buttonQueue[i]).buttonHeight), cp->buttonQueue[i].text,strlength,Xoption); } else { /* a regular button */ int isOn = 1; switch(i) { case pointsOnOff: isOn = pointsON = graphStateArray[0].pointsOn; if (graphStateArray[0].pointsOn) strcpy((cp->buttonQueue[i]).text,"Pts On "); else strcpy((cp->buttonQueue[i]).text,"Pts Off"); break; case spline2D: isOn = splineON = graphStateArray[0].splineOn; if (graphStateArray[0].splineOn) strcpy((cp->buttonQueue[i]).text, "Box On "); else strcpy((cp->buttonQueue[i]).text, "Box Off"); break; case connectOnOff: isOn = connectON = graphStateArray[0].connectOn; if (graphStateArray[0].connectOn) strcpy((cp->buttonQueue[i]).text, "Lines On "); else strcpy((cp->buttonQueue[i]).text, "Lines Off"); break; case axesOnOff2D: isOn = axesON = graphStateArray[0].axesOn; if (graphStateArray[0].axesOn) strcpy((cp->buttonQueue[i]).text , "Axes On "); else strcpy((cp->buttonQueue[i]).text , "Axes Off"); break; case unitsOnOff2D: isOn = unitsON = graphStateArray[0].unitsOn; if (graphStateArray[0].unitsOn) strcpy( (cp->buttonQueue[i]).text , "Units On "); else strcpy( (cp->buttonQueue[i]).text , "Units Off"); break; case closeAll2D: isOn = 0; default: break; } /* switch i */ s = (cp->buttonQueue[i]).text; strlength = strlen(s); GDrawPushButton(dsply, globalGC1, trashGC, processGC, cp->controlWindow, (cp->buttonQueue[i]).buttonX, (cp->buttonQueue[i]).buttonY, (cp->buttonQueue[i]).buttonWidth, (cp->buttonQueue[i]).buttonHeight, isOn, s,buttonColor, monoColor((cp->buttonQueue[i]).textColor), Xoption); } /* else a regular button */ } /* for each button */ /* Refresh the latest message */ makeMessageFromData(0); writeControlMessage(); XFlush(dsply); } /*** drawControlPanel ***/
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() */