diff options
Diffstat (limited to 'src/graph')
200 files changed, 12331 insertions, 13423 deletions
diff --git a/src/graph/Gdraws/Gdraws0.h b/src/graph/Gdraws/Gdraws0.h index 62066b69..8d703347 100755..100644 --- a/src/graph/Gdraws/Gdraws0.h +++ b/src/graph/Gdraws/Gdraws0.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _GDRAWS0_H_ diff --git a/src/graph/Gdraws/Gfun.c.pamphlet b/src/graph/Gdraws/Gfun.c index c7ef9d6e..ffb8275a 100644 --- a/src/graph/Gdraws/Gfun.c.pamphlet +++ b/src/graph/Gdraws/Gfun.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph Gfun.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _GFUN_C @@ -117,21 +103,21 @@ PSCreateFile( i = 1; while (i < psDrawNo) { /* loops through each file/procedure */ if (psData[i].flag) { /* if set, procedure/file is used */ - if ((ifp = fopen(psData[i].filename, "r")) == NULL) { - if (i == GCdictps) { /* GC dictionaries */ - fprintf(stderr, "Warning: missing GCdictionary.\n"); + if ((ifp = fopen(psData[i].filename, "r")) == NULL) { + if (i == GCdictps) { /* GC dictionaries */ + fprintf(stderr, "Warning: missing GCdictionary.\n"); } - else { - fprintf(stderr, "Cannot open %s to read.\n", - psData[i].filename); - fclose(ofp); - return (psError); - } - } - else { - filecopy(ifp, ofp); - fclose(ifp); - } + else { + fprintf(stderr, "Cannot open %s to read.\n", + psData[i].filename); + fclose(ofp); + return (psError); + } + } + else { + filecopy(ifp, ofp); + fclose(ifp); + } } i++; } @@ -169,7 +155,7 @@ Gdraws_drawFrame( /* choose 2 and "frameDict" for frame dictionary: can be anything else */ PSCreateContext((GC)2, "frameDict", borderW, psButtCap, psMiterJoin, - psWhite, psBlack); + psWhite, psBlack); fp = fopen(psData[scriptps].filename, "a"); @@ -179,7 +165,7 @@ Gdraws_drawFrame( XGetWindowAttributes(dsply, titleWindow, &twInfo); fprintf(fp, "\t%s\t%d\t%d\t%d\t%d\ttitle\n", "frameDict", - twInfo.height - vwInfo.height, twInfo.width, 0, vwInfo.height); + twInfo.height - vwInfo.height, twInfo.width, 0, vwInfo.height); /* draw viewport window */ @@ -189,7 +175,7 @@ Gdraws_drawFrame( psData[drawIstrps].flag = yes; fprintf(fp, "\t%s\tloadFont\n\t%d\t(%s) stringwidth pop sub 2 div\n", - "frameDict", twInfo.width, title); + "frameDict", twInfo.width, title); fprintf(fp, "\t%d\t(%s)\t(%s)\tpsDrawIStr\n", 15, title, "title"); return (fclose(fp)); @@ -200,8 +186,8 @@ Gdraws_drawFrame( int Gdraws_setDimension( - Window viewWindow, - Window titleWindow) + Window viewWindow, + Window titleWindow) { FILE *fp; XWindowAttributes vwInfo, twInfo; @@ -231,7 +217,7 @@ Gdraws_setDimension( } else { if (vwInfo.height > pageHeight) - fprintf(fp, "\t%f\t%f", width, pageHeight / width); + fprintf(fp, "\t%f\t%f", width, pageHeight / width); } } else { @@ -240,7 +226,7 @@ Gdraws_setDimension( fprintf(fp, "\tscale\n\n"); fprintf(fp, "\t%d\t%d\t%d\tsetDim\n", twInfo.height - vwInfo.height, - vwInfo.height, vwInfo.width); + vwInfo.height, vwInfo.width); /* Write a Bounding Box for psfig etc. */ @@ -272,14 +258,14 @@ GDrawImageString( FILE *fp; if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GDrawImageString cannot open %s\n", - psData[scriptps].filename); - return (psError); + fprintf(stderr, "GDrawImageString cannot open %s\n", + psData[scriptps].filename); + return (psError); } psData[drawIstrps].flag = yes; /* set procedure flag */ fprintf(fp, "\t%s\t%d\t%d\t(%s)\t(%s)\tpsDrawIStr\n", - PSfindGC(gc), x, y, string, "window"); + PSfindGC(gc), x, y, string, "window"); s = fclose(fp); } break; @@ -311,20 +297,20 @@ GDrawArc( FILE *fp; if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GDrawArc cannot open %s\n", - psData[scriptps].filename); - return (psError); + fprintf(stderr, "GDrawArc cannot open %s\n", + psData[scriptps].filename); + return (psError); } psData[drawarcps].flag = yes; fprintf(fp, "\t%s\t%d\t%d\t%d\t%d\t%d\t%d\tpsDrawArc\n", - PSfindGC(gc), x, y, hght, wdth, ang1 / 64, ang2 / 64); + PSfindGC(gc), x, y, hght, wdth, ang1 / 64, ang2 / 64); s = fclose(fp); } break; default: fprintf(stderr, "Gdrawarc request (%d) not implemented yet.\n", - dFlag); + dFlag); return (psError); } return (s); @@ -350,20 +336,20 @@ GDrawLine( FILE *fp; if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GDrawLine cannot open %s\n", - psData[scriptps].filename); - return (psError); + fprintf(stderr, "GDrawLine cannot open %s\n", + psData[scriptps].filename); + return (psError); } psData[drawlineps].flag = yes; /* sets procedure flag */ fprintf(fp, "\t%s\t%d\t%d\t%d\t%d\tpsDrawLine\n", - PSfindGC(gc), x1, y1, x0, y0); + PSfindGC(gc), x1, y1, x0, y0); s = fclose(fp); } break; default: fprintf(stderr, "Gdrawline request (%d) not implemented yet.\n", - dFlag); + dFlag); return (psError); } return (s); @@ -397,9 +383,9 @@ GDrawLines( int i = 0; if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GDrawLines cannot open %s\n", - psData[scriptps].filename); - return (psError); + fprintf(stderr, "GDrawLines cannot open %s\n", + psData[scriptps].filename); + return (psError); } psData[drawlinesps].flag = yes; /* set procedure flag */ @@ -411,13 +397,13 @@ GDrawLines( } fprintf(fp, "\t%d\t%d\t%d\tpsDrawLines\n", - numberOfPoints, points[i].x, points[i].y); + numberOfPoints, points[i].x, points[i].y); s = fclose(fp); } break; default: fprintf(stderr, "Gdrawlines request (%d) not implemented yet\n", - dFlag); + dFlag); return (psError); } return (s); @@ -444,20 +430,20 @@ GDrawPoint( FILE *fp; if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GDrawPoint cannot open %s\n", - psData[scriptps].filename); - return (psError); + fprintf(stderr, "GDrawPoint cannot open %s\n", + psData[scriptps].filename); + return (psError); } psData[drawpointps].flag = yes; /* sets procedure flag */ fprintf(fp, "\t%s\t%d\t%d\t%d\t%d\tpsDrawPoint\n", - PSfindGC(gc), x0, y0, x0 + 1, y0 + 1); + PSfindGC(gc), x0, y0, x0 + 1, y0 + 1); s = fclose(fp); } break; default: fprintf(stderr, "Gdrawpoint request (%d) not implemented yet\n", - dFlag); + dFlag); return (psError); } return (s); @@ -485,20 +471,20 @@ GDrawRectangle( FILE *fp; if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GDrawRect cannot open %s\n", - psData[scriptps].filename); - return (psError); + fprintf(stderr, "GDrawRect cannot open %s\n", + psData[scriptps].filename); + return (psError); } psData[drawrectps].flag = yes; fprintf(fp, "\t%s\t%d\t%d\t%d\t%d\tpsDrawRect\n", - PSfindGC(gc), width, height, x, y); + PSfindGC(gc), width, height, x, y); s = fclose(fp); } break; default: fprintf(stderr, "Gdrawrect request (%d) not implemented yet\n", - dFlag); + dFlag); return (psError); } return (s); @@ -522,14 +508,14 @@ GDraw3DButtonOut( /* add extra line down rhs */ GDrawLine(gc, windowId, - x + width, y + 1, x + width, y + height, - dFlag); + x + width, y + 1, x + width, y + height, + dFlag); /* add extra line across bottom */ GDrawLine(gc, windowId, - x + 1, y + height, x + width, y + height, - dFlag); + x + 1, y + height, x + width, y + height, + dFlag); return (s); } @@ -552,14 +538,14 @@ GDraw3DButtonIn( /* add extra line down lhs */ GDrawLine(gc, windowId, - x, y, x, y + height - 1, - dFlag); + x, y, x, y + height - 1, + dFlag); /* add extra line across top */ GDrawLine(gc, windowId, - x, y, x + width - 1, y, - dFlag); + x, y, x + width - 1, y, + dFlag); return (s); } @@ -593,9 +579,9 @@ GDrawPushButton( GSetForeground(gc2, (float) color, dFlag); return GDrawString(gc2, windowId, - x + (isOn ? 2 : 0) + centerX(gc3, text, len, width), - y + (isOn ? 2 : 0) + centerY(gc3, height), - text, len, dFlag); + x + (isOn ? 2 : 0) + centerX(gc3, text, len, width), + y + (isOn ? 2 : 0) + centerY(gc3, height), + text, len, dFlag); } @@ -623,21 +609,21 @@ GDrawString( FILE *fp; if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GDrawString cannot open %s\n", - psData[scriptps].filename); - return (psError); + fprintf(stderr, "GDrawString cannot open %s\n", + psData[scriptps].filename); + return (psError); } psData[drawstrps].flag = yes; /* sets procedure flag */ fprintf(fp, "\t%s\t(%s)\t%d\t%d\tpsDrawStr\n", - PSfindGC(gc), string, x, y); + PSfindGC(gc), string, x, y); s = fclose(fp); } break; default: fprintf(stderr, "Gdrawstring request (%d) not implemented yet\n", - dFlag); + dFlag); return (psError); } return (s); @@ -666,21 +652,21 @@ GFillArc( FILE *fp; if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GFillArc cannot open %s\n", - psData[scriptps].filename); - return (psError); + fprintf(stderr, "GFillArc cannot open %s\n", + psData[scriptps].filename); + return (psError); } psData[fillarcps].flag = yes; /* sets procedure flag */ fprintf(fp, "\t%s\t%d %d\t%d %d\t%d %d\t%d %d\tpsFillArc\n", - PSfindGC(gc), x, y, hght, wdth, ang1 / 64, ang2 / 64, - x + wdth / 2, y + hght / 2); + PSfindGC(gc), x, y, hght, wdth, ang1 / 64, ang2 / 64, + x + wdth / 2, y + hght / 2); s = fclose(fp); } break; default: fprintf(stderr, "GFillArc request (%d) not implemented yet\n", - dFlag); + dFlag); return (psError); } return (s); @@ -713,74 +699,74 @@ PSGlobalInit(void) sprintf(psData[headerps].filename, "%s%s", envAXIOM, "/Gdraws/PS/header.ps"); sprintf(psData[drawps].filename, "%s%s", envAXIOM, "/Gdraws/PS/draw.ps"); sprintf(psData[drawarcps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/drawarc.ps"); + "/Gdraws/PS/drawarc.ps"); sprintf(psData[drawfilledps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/drwfilled.ps"); + "/Gdraws/PS/drwfilled.ps"); sprintf(psData[drawcolorps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/drawcolor.ps"); + "/Gdraws/PS/drawcolor.ps"); sprintf(psData[fillpolyps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/fillpoly.ps"); + "/Gdraws/PS/fillpoly.ps"); sprintf(psData[colorpolyps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/colorpoly.ps"); + "/Gdraws/PS/colorpoly.ps"); sprintf(psData[fillwolps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/fillwol.ps"); + "/Gdraws/PS/fillwol.ps"); sprintf(psData[colorwolps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/colorwol.ps"); + "/Gdraws/PS/colorwol.ps"); sprintf(psData[drawpointps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/drawpoint.ps"); + "/Gdraws/PS/drawpoint.ps"); sprintf(psData[drawlineps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/drawline.ps"); + "/Gdraws/PS/drawline.ps"); sprintf(psData[drawlinesps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/drawlines.ps"); + "/Gdraws/PS/drawlines.ps"); sprintf(psData[drawrectps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/drawrect.ps"); + "/Gdraws/PS/drawrect.ps"); sprintf(psData[drawstrps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/drawstr.ps"); + "/Gdraws/PS/drawstr.ps"); sprintf(psData[drawIstrps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/drawIstr.ps"); + "/Gdraws/PS/drawIstr.ps"); sprintf(psData[fillarcps].filename, "%s%s", envAXIOM, - "/Gdraws/PS/fillarc.ps"); + "/Gdraws/PS/fillarc.ps"); sprintf(psData[setupps].filename, "%s%s", envAXIOM, "/Gdraws/PS/setup.ps"); sprintf(psData[endps].filename, "%s%s", envAXIOM, "/Gdraws/PS/end.ps"); } else if ((envAXIOM = getenv("AXIOM")) != NULL) { psData[headerps].flag = yes; sprintf(psData[headerps].filename, "%s%s", envAXIOM, - "/lib/graph/header.ps"); + "/lib/graph/header.ps"); sprintf(psData[drawps].filename, "%s%s", envAXIOM, - "/lib/graph/draw.ps"); + "/lib/graph/draw.ps"); sprintf(psData[drawarcps].filename, "%s%s", envAXIOM, - "/lib/graph/drawarc.ps"); + "/lib/graph/drawarc.ps"); sprintf(psData[drawfilledps].filename, "%s%s", envAXIOM, - "/lib/graph/drwfilled.ps"); + "/lib/graph/drwfilled.ps"); sprintf(psData[drawcolorps].filename, "%s%s", envAXIOM, - "/lib/graph/drawcolor.ps"); + "/lib/graph/drawcolor.ps"); sprintf(psData[fillpolyps].filename, "%s%s", envAXIOM, - "/lib/graph/fillpoly.ps"); + "/lib/graph/fillpoly.ps"); sprintf(psData[colorpolyps].filename, "%s%s", envAXIOM, - "/lib/graph/colorpoly.ps"); + "/lib/graph/colorpoly.ps"); sprintf(psData[fillwolps].filename, "%s%s", envAXIOM, - "/lib/graph/fillwol.ps"); + "/lib/graph/fillwol.ps"); sprintf(psData[colorwolps].filename, "%s%s", envAXIOM, - "/lib/graph/colorwol.ps"); + "/lib/graph/colorwol.ps"); sprintf(psData[drawpointps].filename, "%s%s", envAXIOM, - "/lib/graph/drawpoint.ps"); + "/lib/graph/drawpoint.ps"); sprintf(psData[drawlineps].filename, "%s%s", envAXIOM, - "/lib/graph/drawline.ps"); + "/lib/graph/drawline.ps"); sprintf(psData[drawlinesps].filename, "%s%s", envAXIOM, - "/lib/graph/drawlines.ps"); + "/lib/graph/drawlines.ps"); sprintf(psData[drawrectps].filename, "%s%s", envAXIOM, - "/lib/graph/drawrect.ps"); + "/lib/graph/drawrect.ps"); sprintf(psData[drawstrps].filename, "%s%s", envAXIOM, - "/lib/graph/drawstr.ps"); + "/lib/graph/drawstr.ps"); sprintf(psData[drawIstrps].filename, "%s%s", envAXIOM, - "/lib/graph/drawIstr.ps"); + "/lib/graph/drawIstr.ps"); sprintf(psData[fillarcps].filename, "%s%s", envAXIOM, - "/lib/graph/fillarc.ps"); + "/lib/graph/fillarc.ps"); sprintf(psData[setupps].filename, "%s%s", envAXIOM, - "/lib/graph/setup.ps"); + "/lib/graph/setup.ps"); sprintf(psData[endps].filename, "%s%s", envAXIOM, - "/lib/graph/end.ps"); + "/lib/graph/end.ps"); } else { fprintf(stderr, " need environment variable AXIOM or DEVE; process aborted\n"); @@ -872,12 +858,12 @@ PSCreateContext( if ((fp = fopen(psData[GCdictps].filename, "a")) == NULL) { fprintf(stderr, "PSCreateContext cannot open %s\n", - psData[GCdictps].filename); + psData[GCdictps].filename); return (psError); } fprintf(fp, "\t%d\t%d\t%d\n\t%f\t%f\t/%s\tmakeDict\n", joinStyle, - capStyle, lineWidth, bg, fg, C_gc); + capStyle, lineWidth, bg, fg, C_gc); return (fclose(fp)); } @@ -925,9 +911,9 @@ GSetForeground( FILE *fp; if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GSetForeground cannot open %s\n", - psData[scriptps].filename); - return (0); + fprintf(stderr, "GSetForeground cannot open %s\n", + psData[scriptps].filename); + return (0); } fprintf(fp, "\t%s\t%f\tsetForeground\n", PSfindGC(gc), color); s = fclose(fp); @@ -961,9 +947,9 @@ GSetBackground( FILE *fp; if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GSetBackground cannot open %s\n", - psData[scriptps].filename); - return (0); + fprintf(stderr, "GSetBackground cannot open %s\n", + psData[scriptps].filename); + return (0); } fprintf(fp, "\t%s\t%f\tsetBackground\n", PSfindGC(gc), color); s = fclose(fp); @@ -993,7 +979,7 @@ GSetLineAttributes( switch (dFlag) { case Xoption: XSetLineAttributes(dsply, gc, lineWidth, lineStyle, - capStyle, joinStyle); + capStyle, joinStyle); break; case PSoption: { @@ -1003,32 +989,32 @@ GSetLineAttributes( switch (capStyle) { case 0: /* CapNotLast is not implemented in ps */ case 1: - psCap = psButtCap; - break; + psCap = psButtCap; + break; case 2: - psCap = psRoundCap; - break; + psCap = psRoundCap; + break; case 3: - psCap = psPSqCap; - break; + psCap = psPSqCap; + break; default: - fprintf(stderr, "cap style: %d unknown, using default.\n", capStyle); - psCap = psButtCap; + fprintf(stderr, "cap style: %d unknown, using default.\n", capStyle); + psCap = psButtCap; } switch (joinStyle) { case 0: - psJoin = psMiterJoin; - break; + psJoin = psMiterJoin; + break; case 1: - psJoin = psRoundJoin; - break; + psJoin = psRoundJoin; + break; case 2: - psJoin = psBevelJoin; - break; + psJoin = psBevelJoin; + break; default: - fprintf(stderr, "join style: %d unknown, using default.\n", joinStyle); - psJoin = psMiterJoin; + fprintf(stderr, "join style: %d unknown, using default.\n", joinStyle); + psJoin = psMiterJoin; } /* @@ -1038,13 +1024,13 @@ GSetLineAttributes( */ if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { - fprintf(stderr, "GSetLineAttributes cannot open %s\n", - psData[scriptps].filename); - return (0); + fprintf(stderr, "GSetLineAttributes cannot open %s\n", + psData[scriptps].filename); + return (0); } fprintf(fp, "\t%d\t%d\t%d\t%s\tsetLineAttributes\n", - lineWidth, psCap, psJoin, PSfindGC(gc)); + lineWidth, psCap, psJoin, PSfindGC(gc)); s = fclose(fp); } break; @@ -1115,7 +1101,7 @@ centerY (GC viewGCy,int windowHeight) fontStruct = XQueryFont(dsply,con); if (fontStruct == NULL) return(0); result = (windowHeight - - (fontStruct->max_bounds.ascent + fontStruct->max_bounds.descent))/2 + + (fontStruct->max_bounds.ascent + fontStruct->max_bounds.descent))/2 + fontStruct->max_bounds.ascent; XFreeFontInfo(NULL,fontStruct,1); return(result); @@ -1140,7 +1126,7 @@ PSColorPolygon( if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { fprintf(stderr, "PSColorPolygon cannot open %s\n", - psData[scriptps].filename); + psData[scriptps].filename); return (psError); } @@ -1190,7 +1176,7 @@ PSColorwOutline( } fprintf(fp, "\t%d\t%d\t%d\tpsFillwOutline\n", - numberOfPoints, points[i].x, points[i].y); + numberOfPoints, points[i].x, points[i].y); return (fclose(fp)); } @@ -1211,7 +1197,7 @@ PSDrawColor( if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { fprintf(stderr, "GDraw cannot open %s\n", - psData[scriptps].filename); + psData[scriptps].filename); return (psError); } @@ -1245,7 +1231,7 @@ PSFillPolygon( if ((fp = fopen(psData[scriptps].filename, "a")) == NULL) { fprintf(stderr, "PSFillPolygon cannot open %s\n", - psData[scriptps].filename); + psData[scriptps].filename); return (psError); } @@ -1292,7 +1278,7 @@ PSFillwOutline( } fprintf(fp, "\t%d\t%d\t%d\tpsFillwOutline\n", - numberOfPoints, points[i].x, points[i].y); + numberOfPoints, points[i].x, points[i].y); return (fclose(fp)); } @@ -1341,9 +1327,3 @@ XDeleteAssoc(Display * dsp,HashTable * table, Window w) -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/Gdraws/Makefile.in b/src/graph/Gdraws/Makefile.in index 597116d0..434b29bb 100644 --- a/src/graph/Gdraws/Makefile.in +++ b/src/graph/Gdraws/Makefile.in @@ -1,4 +1,4 @@ -# Copyright (C) 2007, Gabriel Dos Reis. +# Copyright (C) 2007-2008, Gabriel Dos Reis. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -55,15 +55,13 @@ DOTH= $(axiom_src_srcdir)/graph/viewman # a .c file in the library subdirectory DOTC= $(axiom_src_srcdir)/lib -pamphlets = Gfun.c.pamphlet psFiles.pamphlet Makefile.pamphlet - AXIOM_CFLAGS = ${CCF} -I${LINC} -I${GINC} -I$(srcdir) -I${HINC} \ $(axiom_includes) ${AXIOM_X11_CFLAGS} subdir = src/graph/Gdraws/ -pamphlets = Makefile.pamphlet Gfun.c.pamphlet psFiles.pamphlet +pamphlets = psFiles.pamphlet HEADERS = ${IN}/Gdraws0.h ${LINC}/G.h ${LINC}/Gfun.H1 \ ${GINC}/hash.h ${GINC}/hash.H1 $(axiom_c_macros_h) @@ -91,9 +89,6 @@ stamp: Gfun.$(OBJEXT) $(PSfiles) $(PS)/%.ps: $(srcdir)/psFiles.pamphlet $(axiom_build_document) --tangle=$* --output=$@ $< -Gfun.c: $(srcdir)/Gfun.c.pamphlet - $(axiom_build_document) --tangle --output=$@ $< - Gfun.$(OBJEXT): ${HEADERS} Gfun.$(OBJEXT): $(builddir)/Gfun.c diff --git a/src/graph/Gdraws/data.c.pamphlet b/src/graph/Gdraws/data.c index 70c113b6..d3f58173 100644 --- a/src/graph/Gdraws/data.c.pamphlet +++ b/src/graph/Gdraws/data.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph data.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C), 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> /* Data file to test out Gdraw functions */ @@ -248,9 +234,3 @@ Gdraws_data(int dFlag) return (1); } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/Gdraws/loadFont.c b/src/graph/Gdraws/loadFont.c new file mode 100644 index 00000000..dc557525 --- /dev/null +++ b/src/graph/Gdraws/loadFont.c @@ -0,0 +1,51 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/* load_font for display to test out Gdraw functions in this directory */ + +#include "Gdraws0.h" +#include "../include/G.h" + +#include <stdio.h> + +void +Gdraws_load_font(XFontStruct **font_info, char *fontname) +{ + if ((*font_info = XLoadQueryFont(dsply, fontname)) == NULL) { + fprintf(stderr, "cannot open font %s\n", fontname); + exit(-1); + } +} diff --git a/src/graph/Gdraws/loadFont.c.pamphlet b/src/graph/Gdraws/loadFont.c.pamphlet deleted file mode 100644 index 72484e13..00000000 --- a/src/graph/Gdraws/loadFont.c.pamphlet +++ /dev/null @@ -1,71 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph loadFont.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - - -/* load_font for display to test out Gdraw functions in this directory */ - -#include "Gdraws0.h" -#include "../include/G.h" - -#include <stdio.h> - -void -Gdraws_load_font(XFontStruct **font_info, char *fontname) -{ - if ((*font_info = XLoadQueryFont(dsply, fontname)) == NULL) { - fprintf(stderr, "cannot open font %s\n", fontname); - exit(-1); - } -} -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/Gdraws/main.c b/src/graph/Gdraws/main.c new file mode 100644 index 00000000..7d8e99fe --- /dev/null +++ b/src/graph/Gdraws/main.c @@ -0,0 +1,195 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/* main procedure to test out Gdraw functions in this directory */ +#include <stdio.h> +#include "Gdraws0.h" +#include "../view3D/header.h" + +GC gc, gc1; +Display *dsply; +int scrn; +viewPoints *viewport; + +int psInit=no; +GCptr GChead=NULL; +char *PSfilename="OUTPUT.ps"; +char *envAXIOM; + +int +main(int argc, char **argv) +{ + + XGCValues values; + + XEvent report; + int x0=0, y0=0, width=300, height=200, border=3; + + char *fontname = "6x13"; + XFontStruct *dsp_font; + + Window menu; + char *str1 = " Print out the PostScript file? ", + *str0 = "Generate a PostScript file (OUTPUT.ps)?"; + int m_width, m_height, flag=yes; + + /* open display */ + if ((dsply = XOpenDisplay(NULL)) == NULL) { + printf("Can't open display NULL\n"); + exit(-1); + } + + scrn = DefaultScreen(dsply); + + /* access font */ + Gdraws_load_font(&dsp_font, fontname); + + values.background = WhitePixel(dsply, scrn); + values.foreground = BlackPixel(dsply, scrn); + + gc = XCreateGC(dsply, RootWindow(dsply, scrn), + (GCForeground | GCBackground), &values); + PSGlobalInit(); /* must initiate before using G/PS functions */ + PSCreateContext(gc, "gc", psNormalWidth, psButtCap, + psMiterJoin, psWhite, psBlack); + XSetFont(dsply, gc, dsp_font->fid); + gc1 = XCreateGC(dsply, RootWindow(dsply, scrn), + (GCForeground | GCBackground), &values); + PSCreateContext(gc1, "gc1", psNormalWidth, psButtCap, psMiterJoin, + psWhite, psBlack); + XSetFont(dsply, gc1, dsp_font->fid); + + if (!(viewport = (viewPoints *)malloc(sizeof(viewPoints)))) { + fprintf(stderr,"Ran out of memory (malloc) trying to create a viewport.\n"); + exit(-1); + } + + viewport->titleWindow = XCreateSimpleWindow(dsply, RootWindow(dsply,scrn), + x0, y0, width+6, + height+32+height/4, border, + BlackPixel(dsply, scrn), + WhitePixel(dsply, scrn)); + + viewport->viewWindow = XCreateSimpleWindow(dsply, viewport->titleWindow, + x0, y0+20, width, height, border, + BlackPixel(dsply, scrn), + WhitePixel(dsply, scrn)); + + strcpy(viewport->title, "what is a test title?"); + + m_width = width; m_height = height/4; + menu = XCreateSimpleWindow(dsply, viewport->titleWindow, x0, y0+20+height+6, + m_width, m_height, border, + BlackPixel(dsply,scrn), WhitePixel(dsply,scrn)); + + XSelectInput(dsply, viewport->viewWindow, + KeyPressMask|ButtonPressMask|ExposureMask); + XSelectInput(dsply, viewport->titleWindow, KeyPressMask|ExposureMask); + XSelectInput(dsply, menu, KeyPressMask|ButtonPressMask|ExposureMask); + + XMapWindow(dsply, viewport->viewWindow); + XMapWindow(dsply, viewport->titleWindow); + XFlush(dsply); + + while (yes) { + XNextEvent(dsply, &report); + switch (report.type) { + + case Expose: + if (report.xexpose.window==viewport->titleWindow) { + if (GDrawImageString(gc, viewport->titleWindow, + 20, 15, viewport->title, + strlen(viewport->title),X) == psError) + printf("screen draw image string failed.\n"); + if (Gdraws_data(X) == psError) + printf("screen Gdraws_data failed.\n"); + } + if (report.xexpose.window==viewport->viewWindow) { + if (Gdraws_data(X) == psError) + printf("screen Gdraws_data failed.\n"); + } + else if (report.xexpose.window==menu) { + if (flag) + Gdraws_draw_menu(menu, str0, m_width, m_height); + else + Gdraws_draw_menu(menu, str1, m_width, m_height); + } + break; + + case ButtonPress: + if (report.xbutton.window==viewport->viewWindow) { + XMapWindow(dsply, menu); + XFlush(dsply); + } + else if (report.xbutton.window==menu && flag) { + XUnmapWindow(dsply, menu); + if (Gdraws_pressed_yes(m_width, m_height, report.xbutton.x, + report.xbutton.y)) { + flag=no; + XMapWindow(dsply, menu); + PSInit(viewport->viewWindow, viewport->titleWindow); + if (Gdraws_data(PS) != psError) + PSCreateFile(3,viewport->viewWindow, + viewport->titleWindow,viewport->title); + else printf("PS Gdraws_data failed.\n"); + } + } + else if (report.xbutton.window==menu && !flag) { + XUnmapWindow(dsply, menu); + if (Gdraws_pressed_yes(m_width, m_height, report.xbutton.x, + report.xbutton.y)) + system("print OUTPUT.ps"); + flag = yes; + } + break; + + case KeyPress: + if (report.xkey.window==viewport->viewWindow || + report.xkey.window==viewport->titleWindow) { + XFreeGC(dsply, gc); + XFreeGC(dsply, gc1); + XCloseDisplay(dsply); + PSClose(); + exit(1); + } + else if (report.xkey.window==menu) XUnmapWindow(dsply, menu); + + default: + break; + } + } + return 0; +} diff --git a/src/graph/Gdraws/main.c.pamphlet b/src/graph/Gdraws/main.c.pamphlet deleted file mode 100644 index 838b4bbb..00000000 --- a/src/graph/Gdraws/main.c.pamphlet +++ /dev/null @@ -1,215 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph main.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - - -/* main procedure to test out Gdraw functions in this directory */ -#include <stdio.h> -#include "Gdraws0.h" -#include "../view3D/header.h" - -GC gc, gc1; -Display *dsply; -int scrn; -viewPoints *viewport; - -int psInit=no; -GCptr GChead=NULL; -char *PSfilename="OUTPUT.ps"; -char *envAXIOM; - -int -main(int argc, char **argv) -{ - - XGCValues values; - - XEvent report; - int x0=0, y0=0, width=300, height=200, border=3; - - char *fontname = "6x13"; - XFontStruct *dsp_font; - - Window menu; - char *str1 = " Print out the PostScript file? ", - *str0 = "Generate a PostScript file (OUTPUT.ps)?"; - int m_width, m_height, flag=yes; - - /* open display */ - if ((dsply = XOpenDisplay(NULL)) == NULL) { - printf("Can't open display NULL\n"); - exit(-1); - } - - scrn = DefaultScreen(dsply); - - /* access font */ - Gdraws_load_font(&dsp_font, fontname); - - values.background = WhitePixel(dsply, scrn); - values.foreground = BlackPixel(dsply, scrn); - - gc = XCreateGC(dsply, RootWindow(dsply, scrn), - (GCForeground | GCBackground), &values); - PSGlobalInit(); /* must initiate before using G/PS functions */ - PSCreateContext(gc, "gc", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); - XSetFont(dsply, gc, dsp_font->fid); - gc1 = XCreateGC(dsply, RootWindow(dsply, scrn), - (GCForeground | GCBackground), &values); - PSCreateContext(gc1, "gc1", psNormalWidth, psButtCap, psMiterJoin, - psWhite, psBlack); - XSetFont(dsply, gc1, dsp_font->fid); - - if (!(viewport = (viewPoints *)malloc(sizeof(viewPoints)))) { - fprintf(stderr,"Ran out of memory (malloc) trying to create a viewport.\n"); - exit(-1); - } - - viewport->titleWindow = XCreateSimpleWindow(dsply, RootWindow(dsply,scrn), - x0, y0, width+6, - height+32+height/4, border, - BlackPixel(dsply, scrn), - WhitePixel(dsply, scrn)); - - viewport->viewWindow = XCreateSimpleWindow(dsply, viewport->titleWindow, - x0, y0+20, width, height, border, - BlackPixel(dsply, scrn), - WhitePixel(dsply, scrn)); - - strcpy(viewport->title, "what is a test title?"); - - m_width = width; m_height = height/4; - menu = XCreateSimpleWindow(dsply, viewport->titleWindow, x0, y0+20+height+6, - m_width, m_height, border, - BlackPixel(dsply,scrn), WhitePixel(dsply,scrn)); - - XSelectInput(dsply, viewport->viewWindow, - KeyPressMask|ButtonPressMask|ExposureMask); - XSelectInput(dsply, viewport->titleWindow, KeyPressMask|ExposureMask); - XSelectInput(dsply, menu, KeyPressMask|ButtonPressMask|ExposureMask); - - XMapWindow(dsply, viewport->viewWindow); - XMapWindow(dsply, viewport->titleWindow); - XFlush(dsply); - - while (yes) { - XNextEvent(dsply, &report); - switch (report.type) { - - case Expose: - if (report.xexpose.window==viewport->titleWindow) { - if (GDrawImageString(gc, viewport->titleWindow, - 20, 15, viewport->title, - strlen(viewport->title),X) == psError) - printf("screen draw image string failed.\n"); - if (Gdraws_data(X) == psError) - printf("screen Gdraws_data failed.\n"); - } - if (report.xexpose.window==viewport->viewWindow) { - if (Gdraws_data(X) == psError) - printf("screen Gdraws_data failed.\n"); - } - else if (report.xexpose.window==menu) { - if (flag) - Gdraws_draw_menu(menu, str0, m_width, m_height); - else - Gdraws_draw_menu(menu, str1, m_width, m_height); - } - break; - - case ButtonPress: - if (report.xbutton.window==viewport->viewWindow) { - XMapWindow(dsply, menu); - XFlush(dsply); - } - else if (report.xbutton.window==menu && flag) { - XUnmapWindow(dsply, menu); - if (Gdraws_pressed_yes(m_width, m_height, report.xbutton.x, - report.xbutton.y)) { - flag=no; - XMapWindow(dsply, menu); - PSInit(viewport->viewWindow, viewport->titleWindow); - if (Gdraws_data(PS) != psError) - PSCreateFile(3,viewport->viewWindow, - viewport->titleWindow,viewport->title); - else printf("PS Gdraws_data failed.\n"); - } - } - else if (report.xbutton.window==menu && !flag) { - XUnmapWindow(dsply, menu); - if (Gdraws_pressed_yes(m_width, m_height, report.xbutton.x, - report.xbutton.y)) - system("print OUTPUT.ps"); - flag = yes; - } - break; - - case KeyPress: - if (report.xkey.window==viewport->viewWindow || - report.xkey.window==viewport->titleWindow) { - XFreeGC(dsply, gc); - XFreeGC(dsply, gc1); - XCloseDisplay(dsply); - PSClose(); - exit(1); - } - else if (report.xkey.window==menu) XUnmapWindow(dsply, menu); - - default: - break; - } - } - return 0; -} -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/Gdraws/menu.c b/src/graph/Gdraws/menu.c new file mode 100644 index 00000000..7380065a --- /dev/null +++ b/src/graph/Gdraws/menu.c @@ -0,0 +1,62 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* menu of display used for testing out Gdraw functions in this directory */ +#include "Gdraws0.h" +#include "../include/G.h" + +extern GC gc; + +void +Gdraws_draw_menu(Window menu, char *str, int width, int height) +{ + char *str1 = "y e s", *str2 = "n o"; + int x0=0, y0=0; + + XDrawString(dsply, menu, gc, 30, height/4+3, str, strlen(str)); + + XFillArc(dsply, menu, gc, 35, height/3+5, width/2-50, height/3*2-10, + 0*64, 360*64); + + XFillArc(dsply, menu, gc, width/2+5, height/3+5, width/2-50, height/3*2-10, + 0*64, 360*64); + + XSetForeground(dsply, gc, WhitePixel(dsply, scrn)); + XDrawString(dsply, menu, gc, width/4-5, height/3*2+3, str1, strlen(str1)); + XDrawString(dsply, menu, gc, width/4*3-28,height/3*2+3, str2, strlen(str2)); + XSetForeground(dsply, gc, BlackPixel(dsply, scrn)); + + XFlush(dsply); +} diff --git a/src/graph/Gdraws/menu.c.pamphlet b/src/graph/Gdraws/menu.c.pamphlet deleted file mode 100644 index 7219f8d6..00000000 --- a/src/graph/Gdraws/menu.c.pamphlet +++ /dev/null @@ -1,82 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph menu.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -/* menu of display used for testing out Gdraw functions in this directory */ -#include "Gdraws0.h" -#include "../include/G.h" - -extern GC gc; - -void -Gdraws_draw_menu(Window menu, char *str, int width, int height) -{ - char *str1 = "y e s", *str2 = "n o"; - int x0=0, y0=0; - - XDrawString(dsply, menu, gc, 30, height/4+3, str, strlen(str)); - - XFillArc(dsply, menu, gc, 35, height/3+5, width/2-50, height/3*2-10, - 0*64, 360*64); - - XFillArc(dsply, menu, gc, width/2+5, height/3+5, width/2-50, height/3*2-10, - 0*64, 360*64); - - XSetForeground(dsply, gc, WhitePixel(dsply, scrn)); - XDrawString(dsply, menu, gc, width/4-5, height/3*2+3, str1, strlen(str1)); - XDrawString(dsply, menu, gc, width/4*3-28,height/3*2+3, str2, strlen(str2)); - XSetForeground(dsply, gc, BlackPixel(dsply, scrn)); - - XFlush(dsply); -} -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/Gdraws/yesORno.c b/src/graph/Gdraws/yesORno.c new file mode 100644 index 00000000..f1ef7acc --- /dev/null +++ b/src/graph/Gdraws/yesORno.c @@ -0,0 +1,46 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Decides if mouse click was in yes or no region; used by program to test + * out Gdraw functions in this directory. + */ + +#include "Gdraws0.h" + +int +Gdraws_pressed_yes(int win_width, int win_height, int x, int y) +{ + return (x < win_width / 2) ? yes : no; +} diff --git a/src/graph/Gdraws/yesORno.c.pamphlet b/src/graph/Gdraws/yesORno.c.pamphlet deleted file mode 100644 index daed4bca..00000000 --- a/src/graph/Gdraws/yesORno.c.pamphlet +++ /dev/null @@ -1,67 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph yesORno.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -/* - * Decides if mouse click was in yes or no region; used by program to test - * out Gdraw functions in this directory. - */ - -#include "Gdraws0.h" - -int -Gdraws_pressed_yes(int win_width, int win_height, int x, int y) -{ - return (x < win_width / 2) ? yes : no; -} -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/Makefile.in b/src/graph/Makefile.in index 47297295..ed1a4655 100644 --- a/src/graph/Makefile.in +++ b/src/graph/Makefile.in @@ -1,4 +1,4 @@ -# Copyright (C) 2007, Gabriel Dos Reis. +# Copyright (C) 2007-2008, Gabriel Dos Reis. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -37,8 +37,6 @@ pamphlets = fileformats.pamphlet Makefile.pamphlet subdir = src/graph/ -pamphlets = Makefile.pamphlet - .PHONY: all all-ax all-graph all: all-ax diff --git a/src/graph/include/G.h b/src/graph/include/G.h index 726ac68a..726ac68a 100755..100644 --- a/src/graph/include/G.h +++ b/src/graph/include/G.h diff --git a/src/graph/include/Gfun.H1 b/src/graph/include/Gfun.H1 index 9c612fc4..9c612fc4 100755..100644 --- a/src/graph/include/Gfun.H1 +++ b/src/graph/include/Gfun.H1 diff --git a/src/graph/include/XDefs.h b/src/graph/include/XDefs.h index 03e46da2..03e46da2 100755..100644 --- a/src/graph/include/XDefs.h +++ b/src/graph/include/XDefs.h diff --git a/src/graph/include/actions.h b/src/graph/include/actions.h index 118bda71..118bda71 100755..100644 --- a/src/graph/include/actions.h +++ b/src/graph/include/actions.h diff --git a/src/graph/include/all_2d.H1 b/src/graph/include/all_2d.H1 index f2404a89..f2404a89 100755..100644 --- a/src/graph/include/all_2d.H1 +++ b/src/graph/include/all_2d.H1 diff --git a/src/graph/include/all_3d.H1 b/src/graph/include/all_3d.H1 index d41ba4d7..d41ba4d7 100755..100644 --- a/src/graph/include/all_3d.H1 +++ b/src/graph/include/all_3d.H1 diff --git a/src/graph/include/all_alone.H1 b/src/graph/include/all_alone.H1 index c5415126..c5415126 100755..100644 --- a/src/graph/include/all_alone.H1 +++ b/src/graph/include/all_alone.H1 diff --git a/src/graph/include/bitmaps/hand.bitmap b/src/graph/include/bitmaps/hand.bitmap index aa504daa..aa504daa 100755..100644 --- a/src/graph/include/bitmaps/hand.bitmap +++ b/src/graph/include/bitmaps/hand.bitmap diff --git a/src/graph/include/bitmaps/light11.bitmap b/src/graph/include/bitmaps/light11.bitmap index d79dd52c..d79dd52c 100755..100644 --- a/src/graph/include/bitmaps/light11.bitmap +++ b/src/graph/include/bitmaps/light11.bitmap diff --git a/src/graph/include/bitmaps/light11.mask b/src/graph/include/bitmaps/light11.mask index 4fffa962..4fffa962 100755..100644 --- a/src/graph/include/bitmaps/light11.mask +++ b/src/graph/include/bitmaps/light11.mask diff --git a/src/graph/include/bitmaps/mouse11.bitmap b/src/graph/include/bitmaps/mouse11.bitmap index 231c6630..231c6630 100755..100644 --- a/src/graph/include/bitmaps/mouse11.bitmap +++ b/src/graph/include/bitmaps/mouse11.bitmap diff --git a/src/graph/include/bitmaps/mouse11.mask b/src/graph/include/bitmaps/mouse11.mask index 6e5621f4..6e5621f4 100755..100644 --- a/src/graph/include/bitmaps/mouse11.mask +++ b/src/graph/include/bitmaps/mouse11.mask diff --git a/src/graph/include/bitmaps/spad11.bitmap b/src/graph/include/bitmaps/spad11.bitmap index 0be6b15d..0be6b15d 100755..100644 --- a/src/graph/include/bitmaps/spad11.bitmap +++ b/src/graph/include/bitmaps/spad11.bitmap diff --git a/src/graph/include/bitmaps/spad11.mask b/src/graph/include/bitmaps/spad11.mask index 05329be6..05329be6 100755..100644 --- a/src/graph/include/bitmaps/spad11.mask +++ b/src/graph/include/bitmaps/spad11.mask diff --git a/src/graph/include/bitmaps/volume.bitmap b/src/graph/include/bitmaps/volume.bitmap index c5b65e29..c5b65e29 100755..100644 --- a/src/graph/include/bitmaps/volume.bitmap +++ b/src/graph/include/bitmaps/volume.bitmap diff --git a/src/graph/include/bitmaps/volume.mask b/src/graph/include/bitmaps/volume.mask index 98e377dc..98e377dc 100755..100644 --- a/src/graph/include/bitmaps/volume.mask +++ b/src/graph/include/bitmaps/volume.mask diff --git a/src/graph/include/bitmaps/volume2.bitmap b/src/graph/include/bitmaps/volume2.bitmap index 36705a4d..36705a4d 100755..100644 --- a/src/graph/include/bitmaps/volume2.bitmap +++ b/src/graph/include/bitmaps/volume2.bitmap diff --git a/src/graph/include/bitmaps/volume2.mask b/src/graph/include/bitmaps/volume2.mask index f8cddbe0..f8cddbe0 100755..100644 --- a/src/graph/include/bitmaps/volume2.mask +++ b/src/graph/include/bitmaps/volume2.mask diff --git a/src/graph/include/buttons2d.H1 b/src/graph/include/buttons2d.H1 index 12e64992..12e64992 100755..100644 --- a/src/graph/include/buttons2d.H1 +++ b/src/graph/include/buttons2d.H1 diff --git a/src/graph/include/buttons3d.H1 b/src/graph/include/buttons3d.H1 index 12e64992..12e64992 100755..100644 --- a/src/graph/include/buttons3d.H1 +++ b/src/graph/include/buttons3d.H1 diff --git a/src/graph/include/cleanup.H1 b/src/graph/include/cleanup.H1 index bd78e7a4..bd78e7a4 100755..100644 --- a/src/graph/include/cleanup.H1 +++ b/src/graph/include/cleanup.H1 diff --git a/src/graph/include/closeView3d.H1 b/src/graph/include/closeView3d.H1 index 7f90c596..7f90c596 100755..100644 --- a/src/graph/include/closeView3d.H1 +++ b/src/graph/include/closeView3d.H1 diff --git a/src/graph/include/colors.h b/src/graph/include/colors.h index d2d659cc..d2d659cc 100755..100644 --- a/src/graph/include/colors.h +++ b/src/graph/include/colors.h diff --git a/src/graph/include/component.h b/src/graph/include/component.h index 6d4f1324..6d4f1324 100755..100644 --- a/src/graph/include/component.h +++ b/src/graph/include/component.h diff --git a/src/graph/include/component3d.H1 b/src/graph/include/component3d.H1 index eccc3a0c..eccc3a0c 100755..100644 --- a/src/graph/include/component3d.H1 +++ b/src/graph/include/component3d.H1 diff --git a/src/graph/include/control2d.H1 b/src/graph/include/control2d.H1 index 69aad119..69aad119 100755..100644 --- a/src/graph/include/control2d.H1 +++ b/src/graph/include/control2d.H1 diff --git a/src/graph/include/control3d.H1 b/src/graph/include/control3d.H1 index ae8584e8..ae8584e8 100755..100644 --- a/src/graph/include/control3d.H1 +++ b/src/graph/include/control3d.H1 diff --git a/src/graph/include/fun2D.H1 b/src/graph/include/fun2D.H1 index dae11b59..dae11b59 100755..100644 --- a/src/graph/include/fun2D.H1 +++ b/src/graph/include/fun2D.H1 diff --git a/src/graph/include/fun3D.H1 b/src/graph/include/fun3D.H1 index ada7b475..ada7b475 100755..100644 --- a/src/graph/include/fun3D.H1 +++ b/src/graph/include/fun3D.H1 diff --git a/src/graph/include/graph2d.H1 b/src/graph/include/graph2d.H1 index 2d5888d8..2d5888d8 100755..100644 --- a/src/graph/include/graph2d.H1 +++ b/src/graph/include/graph2d.H1 diff --git a/src/graph/include/illuminate3d.H1 b/src/graph/include/illuminate3d.H1 index 80b7c05f..80b7c05f 100755..100644 --- a/src/graph/include/illuminate3d.H1 +++ b/src/graph/include/illuminate3d.H1 diff --git a/src/graph/include/light11.bitmap b/src/graph/include/light11.bitmap index d79dd52c..d79dd52c 100755..100644 --- a/src/graph/include/light11.bitmap +++ b/src/graph/include/light11.bitmap diff --git a/src/graph/include/light11.mask b/src/graph/include/light11.mask index 4fffa962..4fffa962 100755..100644 --- a/src/graph/include/light11.mask +++ b/src/graph/include/light11.mask diff --git a/src/graph/include/lightbut3d.H1 b/src/graph/include/lightbut3d.H1 index 84625013..84625013 100755..100644 --- a/src/graph/include/lightbut3d.H1 +++ b/src/graph/include/lightbut3d.H1 diff --git a/src/graph/include/lighting3d.H1 b/src/graph/include/lighting3d.H1 index 38ebf301..38ebf301 100755..100644 --- a/src/graph/include/lighting3d.H1 +++ b/src/graph/include/lighting3d.H1 diff --git a/src/graph/include/main2d.H1 b/src/graph/include/main2d.H1 index 7283dad6..7283dad6 100755..100644 --- a/src/graph/include/main2d.H1 +++ b/src/graph/include/main2d.H1 diff --git a/src/graph/include/main3d.H1 b/src/graph/include/main3d.H1 index 7283dad6..7283dad6 100755..100644 --- a/src/graph/include/main3d.H1 +++ b/src/graph/include/main3d.H1 diff --git a/src/graph/include/make2D.H1 b/src/graph/include/make2D.H1 index 26dcac5d..26dcac5d 100755..100644 --- a/src/graph/include/make2D.H1 +++ b/src/graph/include/make2D.H1 diff --git a/src/graph/include/make3D.H1 b/src/graph/include/make3D.H1 index 22ee1d4f..22ee1d4f 100755..100644 --- a/src/graph/include/make3D.H1 +++ b/src/graph/include/make3D.H1 diff --git a/src/graph/include/makeGraph.H1 b/src/graph/include/makeGraph.H1 index 419d2408..419d2408 100755..100644 --- a/src/graph/include/makeGraph.H1 +++ b/src/graph/include/makeGraph.H1 diff --git a/src/graph/include/mesh3d.H1 b/src/graph/include/mesh3d.H1 index 6f70458c..6f70458c 100755..100644 --- a/src/graph/include/mesh3d.H1 +++ b/src/graph/include/mesh3d.H1 diff --git a/src/graph/include/mode.h b/src/graph/include/mode.h index 4d0c923b..4d0c923b 100755..100644 --- a/src/graph/include/mode.h +++ b/src/graph/include/mode.h diff --git a/src/graph/include/mouse11.bitmap b/src/graph/include/mouse11.bitmap index 231c6630..231c6630 100755..100644 --- a/src/graph/include/mouse11.bitmap +++ b/src/graph/include/mouse11.bitmap diff --git a/src/graph/include/mouse11.mask b/src/graph/include/mouse11.mask index 6e5621f4..6e5621f4 100755..100644 --- a/src/graph/include/mouse11.mask +++ b/src/graph/include/mouse11.mask diff --git a/src/graph/include/msort3d.H1 b/src/graph/include/msort3d.H1 index a0acb789..a0acb789 100755..100644 --- a/src/graph/include/msort3d.H1 +++ b/src/graph/include/msort3d.H1 diff --git a/src/graph/include/noX10.h b/src/graph/include/noX10.h index 5c4e077c..5c4e077c 100755..100644 --- a/src/graph/include/noX10.h +++ b/src/graph/include/noX10.h diff --git a/src/graph/include/override.h b/src/graph/include/override.h index 70b59368..70b59368 100755..100644 --- a/src/graph/include/override.h +++ b/src/graph/include/override.h diff --git a/src/graph/include/pot2d.H1 b/src/graph/include/pot2d.H1 index 597c6ae7..597c6ae7 100755..100644 --- a/src/graph/include/pot2d.H1 +++ b/src/graph/include/pot2d.H1 diff --git a/src/graph/include/pot3d.H1 b/src/graph/include/pot3d.H1 index cfcd8c03..cfcd8c03 100755..100644 --- a/src/graph/include/pot3d.H1 +++ b/src/graph/include/pot3d.H1 diff --git a/src/graph/include/process2d.H1 b/src/graph/include/process2d.H1 index dae65e2b..dae65e2b 100755..100644 --- a/src/graph/include/process2d.H1 +++ b/src/graph/include/process2d.H1 diff --git a/src/graph/include/process3d.H1 b/src/graph/include/process3d.H1 index 8bfefafe..8bfefafe 100755..100644 --- a/src/graph/include/process3d.H1 +++ b/src/graph/include/process3d.H1 diff --git a/src/graph/include/project3d.H1 b/src/graph/include/project3d.H1 index 99287bef..99287bef 100755..100644 --- a/src/graph/include/project3d.H1 +++ b/src/graph/include/project3d.H1 diff --git a/src/graph/include/purty/hand.bitmap b/src/graph/include/purty/hand.bitmap index aa504daa..aa504daa 100755..100644 --- a/src/graph/include/purty/hand.bitmap +++ b/src/graph/include/purty/hand.bitmap diff --git a/src/graph/include/purty/light11.bitmap b/src/graph/include/purty/light11.bitmap index d79dd52c..d79dd52c 100755..100644 --- a/src/graph/include/purty/light11.bitmap +++ b/src/graph/include/purty/light11.bitmap diff --git a/src/graph/include/purty/light11.mask b/src/graph/include/purty/light11.mask index 4fffa962..4fffa962 100755..100644 --- a/src/graph/include/purty/light11.mask +++ b/src/graph/include/purty/light11.mask diff --git a/src/graph/include/purty/mouse11.bitmap b/src/graph/include/purty/mouse11.bitmap index 231c6630..231c6630 100755..100644 --- a/src/graph/include/purty/mouse11.bitmap +++ b/src/graph/include/purty/mouse11.bitmap diff --git a/src/graph/include/purty/mouse11.mask b/src/graph/include/purty/mouse11.mask index 6e5621f4..6e5621f4 100755..100644 --- a/src/graph/include/purty/mouse11.mask +++ b/src/graph/include/purty/mouse11.mask diff --git a/src/graph/include/purty/slicer.bitmap b/src/graph/include/purty/slicer.bitmap index 6f871847..6f871847 100755..100644 --- a/src/graph/include/purty/slicer.bitmap +++ b/src/graph/include/purty/slicer.bitmap diff --git a/src/graph/include/purty/spadBitmap.bitmap b/src/graph/include/purty/spadBitmap.bitmap index f8b9d7d8..f8b9d7d8 100755..100644 --- a/src/graph/include/purty/spadBitmap.bitmap +++ b/src/graph/include/purty/spadBitmap.bitmap diff --git a/src/graph/include/purty/spadMask.mask b/src/graph/include/purty/spadMask.mask index 40954629..40954629 100755..100644 --- a/src/graph/include/purty/spadMask.mask +++ b/src/graph/include/purty/spadMask.mask diff --git a/src/graph/include/purty/volume.bitmap b/src/graph/include/purty/volume.bitmap index c5b65e29..c5b65e29 100755..100644 --- a/src/graph/include/purty/volume.bitmap +++ b/src/graph/include/purty/volume.bitmap diff --git a/src/graph/include/purty/volume.mask b/src/graph/include/purty/volume.mask index 98e377dc..98e377dc 100755..100644 --- a/src/graph/include/purty/volume.mask +++ b/src/graph/include/purty/volume.mask diff --git a/src/graph/include/purty/volume.mask.B b/src/graph/include/purty/volume.mask.B index ed3e7929..ed3e7929 100755..100644 --- a/src/graph/include/purty/volume.mask.B +++ b/src/graph/include/purty/volume.mask.B diff --git a/src/graph/include/purty/volume2.bitmap b/src/graph/include/purty/volume2.bitmap index 36705a4d..36705a4d 100755..100644 --- a/src/graph/include/purty/volume2.bitmap +++ b/src/graph/include/purty/volume2.bitmap diff --git a/src/graph/include/purty/volume2.mask b/src/graph/include/purty/volume2.mask index f8cddbe0..f8cddbe0 100755..100644 --- a/src/graph/include/purty/volume2.mask +++ b/src/graph/include/purty/volume2.mask diff --git a/src/graph/include/quit3d.H1 b/src/graph/include/quit3d.H1 index cb5b1fda..cb5b1fda 100755..100644 --- a/src/graph/include/quit3d.H1 +++ b/src/graph/include/quit3d.H1 diff --git a/src/graph/include/quitbut3d.H1 b/src/graph/include/quitbut3d.H1 index d33590f5..d33590f5 100755..100644 --- a/src/graph/include/quitbut3d.H1 +++ b/src/graph/include/quitbut3d.H1 diff --git a/src/graph/include/readView.H1 b/src/graph/include/readView.H1 index 72c10092..72c10092 100755..100644 --- a/src/graph/include/readView.H1 +++ b/src/graph/include/readView.H1 diff --git a/src/graph/include/save3d.H1 b/src/graph/include/save3d.H1 index 7f4e2241..7f4e2241 100755..100644 --- a/src/graph/include/save3d.H1 +++ b/src/graph/include/save3d.H1 diff --git a/src/graph/include/savebut3d.H1 b/src/graph/include/savebut3d.H1 index 74f253f9..74f253f9 100755..100644 --- a/src/graph/include/savebut3d.H1 +++ b/src/graph/include/savebut3d.H1 diff --git a/src/graph/include/smoothShade3d.H1 b/src/graph/include/smoothShade3d.H1 index 258638cd..258638cd 100755..100644 --- a/src/graph/include/smoothShade3d.H1 +++ b/src/graph/include/smoothShade3d.H1 diff --git a/src/graph/include/spadAction2d.H1 b/src/graph/include/spadAction2d.H1 index edf84047..edf84047 100755..100644 --- a/src/graph/include/spadAction2d.H1 +++ b/src/graph/include/spadAction2d.H1 diff --git a/src/graph/include/spadAction3d.H1 b/src/graph/include/spadAction3d.H1 index bff7f438..bff7f438 100755..100644 --- a/src/graph/include/spadAction3d.H1 +++ b/src/graph/include/spadAction3d.H1 diff --git a/src/graph/include/spadBitmap.bitmap b/src/graph/include/spadBitmap.bitmap index f8b9d7d8..f8b9d7d8 100755..100644 --- a/src/graph/include/spadBitmap.bitmap +++ b/src/graph/include/spadBitmap.bitmap diff --git a/src/graph/include/spadMask.mask b/src/graph/include/spadMask.mask index 40954629..40954629 100755..100644 --- a/src/graph/include/spadMask.mask +++ b/src/graph/include/spadMask.mask diff --git a/src/graph/include/spoon2D.H1 b/src/graph/include/spoon2D.H1 index c6899a63..c6899a63 100755..100644 --- a/src/graph/include/spoon2D.H1 +++ b/src/graph/include/spoon2D.H1 diff --git a/src/graph/include/spoonComp.H1 b/src/graph/include/spoonComp.H1 index 23f10f1b..23f10f1b 100755..100644 --- a/src/graph/include/spoonComp.H1 +++ b/src/graph/include/spoonComp.H1 diff --git a/src/graph/include/sselect.H1 b/src/graph/include/sselect.H1 index 1982c98f..1982c98f 100755..100644 --- a/src/graph/include/sselect.H1 +++ b/src/graph/include/sselect.H1 diff --git a/src/graph/include/stuff2d.H1 b/src/graph/include/stuff2d.H1 index e8488e88..e8488e88 100755..100644 --- a/src/graph/include/stuff2d.H1 +++ b/src/graph/include/stuff2d.H1 diff --git a/src/graph/include/stuff3d.H1 b/src/graph/include/stuff3d.H1 index ffd16370..ffd16370 100755..100644 --- a/src/graph/include/stuff3d.H1 +++ b/src/graph/include/stuff3d.H1 diff --git a/src/graph/include/surface3d.H1 b/src/graph/include/surface3d.H1 index 20823a8e..20823a8e 100755..100644 --- a/src/graph/include/surface3d.H1 +++ b/src/graph/include/surface3d.H1 diff --git a/src/graph/include/transform3d.H1 b/src/graph/include/transform3d.H1 index dc8c5895..dc8c5895 100755..100644 --- a/src/graph/include/transform3d.H1 +++ b/src/graph/include/transform3d.H1 diff --git a/src/graph/include/tube.h b/src/graph/include/tube.h index 8d664332..8d664332 100755..100644 --- a/src/graph/include/tube.h +++ b/src/graph/include/tube.h diff --git a/src/graph/include/view.h b/src/graph/include/view.h index 52ecf42b..52ecf42b 100755..100644 --- a/src/graph/include/view.h +++ b/src/graph/include/view.h diff --git a/src/graph/include/view2D.h b/src/graph/include/view2D.h index 3a1b06c2..3a1b06c2 100755..100644 --- a/src/graph/include/view2D.h +++ b/src/graph/include/view2D.h diff --git a/src/graph/include/view3D.h b/src/graph/include/view3D.h index aea7cd9f..aea7cd9f 100755..100644 --- a/src/graph/include/view3D.h +++ b/src/graph/include/view3D.h diff --git a/src/graph/include/viewAlone.H1 b/src/graph/include/viewAlone.H1 index def07621..def07621 100755..100644 --- a/src/graph/include/viewAlone.H1 +++ b/src/graph/include/viewAlone.H1 diff --git a/src/graph/include/viewCommand.h b/src/graph/include/viewCommand.h index 249feedd..249feedd 100755..100644 --- a/src/graph/include/viewCommand.h +++ b/src/graph/include/viewCommand.h diff --git a/src/graph/include/viewport2D.H1 b/src/graph/include/viewport2D.H1 index 634abb96..634abb96 100755..100644 --- a/src/graph/include/viewport2D.H1 +++ b/src/graph/include/viewport2D.H1 diff --git a/src/graph/include/viewport3d.H1 b/src/graph/include/viewport3d.H1 index 7cf42c2f..7cf42c2f 100755..100644 --- a/src/graph/include/viewport3d.H1 +++ b/src/graph/include/viewport3d.H1 diff --git a/src/graph/include/volume3d.H1 b/src/graph/include/volume3d.H1 index e9245f31..e9245f31 100755..100644 --- a/src/graph/include/volume3d.H1 +++ b/src/graph/include/volume3d.H1 diff --git a/src/graph/include/write.h b/src/graph/include/write.h index 1deec4e1..1deec4e1 100755..100644 --- a/src/graph/include/write.h +++ b/src/graph/include/write.h diff --git a/src/graph/include/write2d.H1 b/src/graph/include/write2d.H1 index 2925821e..2925821e 100755..100644 --- a/src/graph/include/write2d.H1 +++ b/src/graph/include/write2d.H1 diff --git a/src/graph/include/write3d.H1 b/src/graph/include/write3d.H1 index 2925821e..2925821e 100755..100644 --- a/src/graph/include/write3d.H1 +++ b/src/graph/include/write3d.H1 diff --git a/src/graph/view2D/Makefile.in b/src/graph/view2D/Makefile.in index dcff96f4..905d8179 100644 --- a/src/graph/view2D/Makefile.in +++ b/src/graph/view2D/Makefile.in @@ -1,4 +1,4 @@ -# Copyright (C) 2007, Gabriel Dos Reis. +# Copyright (C) 2007-2008, Gabriel Dos Reis. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -41,12 +41,10 @@ build_libdir = $(abs_top_builddir)/src/lib bin_PROGRAMS = view2D$(EXEEXT) -view2D_sources = buttons2d.c control2d.c graph2d.c main2d.c pot2d.c \ +view2D_SOURCES = buttons2d.c control2d.c graph2d.c main2d.c pot2d.c \ process2d.c spadAction2d.c stuff2d.c viewport2D.c write2d.c -view2D_SOURCES = $(addsuffix .pamphlet, $(view2D_sources)) - -view2D_objects = $(view2D_sources:.c=.lo) +view2D_objects = $(view2D_SOURCES:.c=.lo) Gfun_objects = ../Gdraws/Gfun.lo @@ -56,8 +54,6 @@ view2D_DEPENDENCIES = $(Gfun_objects) subdir = src/graph/view2D/ -pamphlets = Makefile.pamphlet $(view2D_SOURCES) - AXIOM_CFLAGS = ${CCF} ${AXIOM_X11_CFLAGS} -I${LINC} -I${GINC} -I$(srcdir) \ $(axiom_includes) @@ -81,7 +77,6 @@ $(axiom_target_libdir)/view2D$(EXEEXT): $(view2D_objects) $(view2D_DEPENDENCIES) $(LINK) -o $@ $(view2D_objects) $(Gfun_objects) \ $(view2D_LDADD) $(AXIOM_X11_LDFLAGS) -lm -.PRECIOUS: %.c .PRECIOUS: %.lo %.$(OBJEXT): $(HEADERS) @@ -89,13 +84,10 @@ $(axiom_target_libdir)/view2D$(EXEEXT): $(view2D_objects) $(view2D_DEPENDENCIES) %.lo: $(builddir)/%.c $(axiom_c_macros.h) $(COMPILE) -o $@ $(CFLAGS) $(AXIOM_CFLAGS) $< -%.c: $(srcdir)/%.c.pamphlet - $(axiom_build_document) --tangle --output=$@ $< - mostlyclean-local: clean-local: mostlyclean-local - @rm -f $(view2D_sources) $(view2D_objects) + @rm -f $(view2D_objects) @rm -f $(axiom_target_libdir)/view2D$(EXEEXT) distclean-local: clean-local diff --git a/src/graph/view2D/buttons2d.c b/src/graph/view2D/buttons2d.c new file mode 100644 index 00000000..3d7a4be6 --- /dev/null +++ b/src/graph/view2D/buttons2d.c @@ -0,0 +1,718 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _BUTTONS2D_C +#include "axiom-c-macros.h" + +#include <string.h> + +#include "header2.h" +#include "buttons2d.H1" +#include "all_2d.H1" + + + + +#define bColor 98 +#define graphColor 138 + +/***************************************************** + * int initButtons(buttons) * + * * + * Creates the fields for each button window in the * + * two dimensional control panel, and returns the * + * number of buttons created. * + * * + *****************************************************/ + +int +#ifdef _NO_PROTO +initButtons (buttons) +buttonStruct *buttons; +#else +initButtons (buttonStruct *buttons) +#endif +{ + int ii, num = 0; + +/********** Scale(Zoom) and Translate Potentiometer Buttons **********/ + + /* Title: "Scale" */ + ii = scale2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 85; + buttons[ii].buttonWidth = 110; + buttons[ii].buttonHeight = 80; + buttons[ii].buttonKey = ii; + buttons[ii].pot = yes; /* scale is a potentiometer */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = potMASK; + buttons[ii].textColor = 164; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Title: "Translate" */ + ii = translate2D; + buttons[ii].buttonX = 121; + buttons[ii].buttonY = 85; + buttons[ii].buttonWidth = 110; + buttons[ii].buttonHeight = 80; + buttons[ii].buttonKey = ii; + buttons[ii].pot = yes; /* translate is a potentiometer */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = potMASK; + buttons[ii].textColor = 21; /* line color of translate arrow */ + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Scale potentiometer buttons */ + + /* Scale along X axis */ + ii = zoom2Dx; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 55; + buttons[ii].buttonWidth = 53; + buttons[ii].buttonHeight = 25; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"X On "); + buttons[ii].textColor = bColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + + /* Scale along Y axis */ + ii = zoom2Dy; + buttons[ii].buttonX = 62; + buttons[ii].buttonY = 55; + buttons[ii].buttonWidth = 53; + buttons[ii].buttonHeight = 25; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Y On "); + buttons[ii].textColor = bColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Translate along X axis */ + ii = translate2Dx; + buttons[ii].buttonX = 121; + buttons[ii].buttonY = 55; + buttons[ii].buttonWidth = 53; + buttons[ii].buttonHeight = 25; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"X On "); + buttons[ii].textColor = bColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + + /* Translate along Y axis */ + ii = translate2Dy; + buttons[ii].buttonX = 179; + buttons[ii].buttonY = 55; + buttons[ii].buttonWidth = 53; + buttons[ii].buttonHeight = 25; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Y On "); + buttons[ii].textColor = bColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + + /* Axes Turned On/Off */ + ii = axesOnOff2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 292; + buttons[ii].buttonWidth = 90; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Axes On "); + buttons[ii].textColor = 75; + buttons[ii].textHue = 10; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Units Turned On/Off */ + ii = unitsOnOff2D; + buttons[ii].buttonX = 100; + buttons[ii].buttonY = 292; + buttons[ii].buttonWidth = 90; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Units Off"); + buttons[ii].textColor = 75; + buttons[ii].textHue = 10; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Generate a Postscript file */ + ii = ps2D; + buttons[ii].buttonX = 195; + buttons[ii].buttonY = 292; + buttons[ii].buttonWidth = 36; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"PS"); + buttons[ii].textColor = 35; + buttons[ii].textHue = 5; + buttons[ii].textShade = 2; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Bounding Rectangle On/Off */ + ii = spline2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 329; + buttons[ii].buttonWidth = 66; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Box Off"); + buttons[ii].textColor = 7; + buttons[ii].textHue = 26; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Graph points On/Off */ + ii = pointsOnOff; + buttons[ii].buttonX = 75; + buttons[ii].buttonY = 329; + buttons[ii].buttonWidth = 67; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Pts On "); + buttons[ii].textColor = 7; + buttons[ii].textHue = 26; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Graph lines On/Off */ + ii = connectOnOff; + buttons[ii].buttonX = 147; + buttons[ii].buttonY = 329; + buttons[ii].buttonWidth = 84; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Lines On "); + buttons[ii].textColor = 7; + buttons[ii].textHue = 26; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Reset View Position Button */ + ii = reset2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 364; + buttons[ii].buttonWidth = 60; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Reset"); + buttons[ii].textColor = bColor; + buttons[ii].textHue = 5; + buttons[ii].textShade = 2; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Hide Control Panel */ + ii = hideControl2D; + buttons[ii].buttonX = 70; + buttons[ii].buttonY = 364; + buttons[ii].buttonWidth = 88; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Hide Panel"); + buttons[ii].textColor = bColor; + buttons[ii].textHue = 5; + buttons[ii].textShade = 2; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Exits from the viewport running */ + ii = closeAll2D; + buttons[ii].buttonX = 169; + buttons[ii].buttonY = 370; + buttons[ii].buttonWidth = 61; + buttons[ii].buttonHeight = 24; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Quit"); + buttons[ii].textColor = 13; + buttons[ii].textHue = 29; + buttons[ii].textShade = 2; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Indicates that the graph from a viewport is to be picked up. */ + ii = pick2D; + buttons[ii].buttonX = 190; + buttons[ii].buttonY = 217; + buttons[ii].buttonWidth = 40; + buttons[ii].buttonHeight = 24; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Pick"); + buttons[ii].textColor = 123; + buttons[ii].textHue = 19; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Indicates that the graph from a viewport is to be dropped into a slot. */ + ii = drop2D; + buttons[ii].buttonX = 190; + buttons[ii].buttonY = 245; + buttons[ii].buttonWidth = 40; + buttons[ii].buttonHeight = 24; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Drop"); + buttons[ii].textColor = 123; + buttons[ii].textHue = 19; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Indicates that the status of the graphs being displayed in the viewport + is to be cleared. */ + ii = clear2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 217; + buttons[ii].buttonWidth = 49; + buttons[ii].buttonHeight = 24; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Clear"); + buttons[ii].textColor = 123; + buttons[ii].textHue = 19; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Asks for the scale and translation information for the specified graph. */ + ii = query2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 245; + buttons[ii].buttonWidth = 49; + buttons[ii].buttonHeight = 24; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Query"); + buttons[ii].textColor = 123; + buttons[ii].textHue = 19; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* These buttons indicate the 9 available slot numbers into which + a 2D graph can be placed, and the status of the graph, i.e. whether + it is displayed or not. */ + + ii = graph1; + buttons[ii].buttonX = graphBarLeft; + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"1"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect1; + buttons[ii].buttonX = graphBarLeft; + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"^"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph2; + buttons[ii].buttonX = graphBarLeft + (graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"2"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect2; + buttons[ii].buttonX = graphBarLeft + (graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph3; + buttons[ii].buttonX = graphBarLeft + 2*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"3"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect3; + buttons[ii].buttonX = graphBarLeft + 2*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /**** blend these three together ***/ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph4; + buttons[ii].buttonX = graphBarLeft + 3*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"4"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect4; + buttons[ii].buttonX = graphBarLeft + 3*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph5; + buttons[ii].buttonX = graphBarLeft + 4*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"5"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect5; + buttons[ii].buttonX = graphBarLeft + 4*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph6; + buttons[ii].buttonX = graphBarLeft + 5*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"6"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect6; + buttons[ii].buttonX = graphBarLeft + 5*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph7; + buttons[ii].buttonX = graphBarLeft + 6*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"7"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect7; + buttons[ii].buttonX = graphBarLeft + 6*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph8; + buttons[ii].buttonX = graphBarLeft + 7*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"8"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect8; + buttons[ii].buttonX = graphBarLeft + 7*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph9; + buttons[ii].buttonX = graphBarLeft + 8*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"9"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect9; + buttons[ii].buttonX = graphBarLeft + 8*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"*"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + return(num); +} diff --git a/src/graph/view2D/buttons2d.c.pamphlet b/src/graph/view2D/buttons2d.c.pamphlet deleted file mode 100644 index c0c19185..00000000 --- a/src/graph/view2D/buttons2d.c.pamphlet +++ /dev/null @@ -1,738 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D buttons2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _BUTTONS2D_C -#include "axiom-c-macros.h" - -#include <string.h> - -#include "header2.h" -#include "buttons2d.H1" -#include "all_2d.H1" - - - - -#define bColor 98 -#define graphColor 138 - -/***************************************************** - * int initButtons(buttons) * - * * - * Creates the fields for each button window in the * - * two dimensional control panel, and returns the * - * number of buttons created. * - * * - *****************************************************/ - -int -#ifdef _NO_PROTO -initButtons (buttons) -buttonStruct *buttons; -#else -initButtons (buttonStruct *buttons) -#endif -{ - int ii, num = 0; - -/********** Scale(Zoom) and Translate Potentiometer Buttons **********/ - - /* Title: "Scale" */ - ii = scale2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 85; - buttons[ii].buttonWidth = 110; - buttons[ii].buttonHeight = 80; - buttons[ii].buttonKey = ii; - buttons[ii].pot = yes; /* scale is a potentiometer */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = potMASK; - buttons[ii].textColor = 164; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Title: "Translate" */ - ii = translate2D; - buttons[ii].buttonX = 121; - buttons[ii].buttonY = 85; - buttons[ii].buttonWidth = 110; - buttons[ii].buttonHeight = 80; - buttons[ii].buttonKey = ii; - buttons[ii].pot = yes; /* translate is a potentiometer */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = potMASK; - buttons[ii].textColor = 21; /* line color of translate arrow */ - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Scale potentiometer buttons */ - - /* Scale along X axis */ - ii = zoom2Dx; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 55; - buttons[ii].buttonWidth = 53; - buttons[ii].buttonHeight = 25; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"X On "); - buttons[ii].textColor = bColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - - /* Scale along Y axis */ - ii = zoom2Dy; - buttons[ii].buttonX = 62; - buttons[ii].buttonY = 55; - buttons[ii].buttonWidth = 53; - buttons[ii].buttonHeight = 25; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Y On "); - buttons[ii].textColor = bColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Translate along X axis */ - ii = translate2Dx; - buttons[ii].buttonX = 121; - buttons[ii].buttonY = 55; - buttons[ii].buttonWidth = 53; - buttons[ii].buttonHeight = 25; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"X On "); - buttons[ii].textColor = bColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - - /* Translate along Y axis */ - ii = translate2Dy; - buttons[ii].buttonX = 179; - buttons[ii].buttonY = 55; - buttons[ii].buttonWidth = 53; - buttons[ii].buttonHeight = 25; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Y On "); - buttons[ii].textColor = bColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - - /* Axes Turned On/Off */ - ii = axesOnOff2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 292; - buttons[ii].buttonWidth = 90; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Axes On "); - buttons[ii].textColor = 75; - buttons[ii].textHue = 10; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Units Turned On/Off */ - ii = unitsOnOff2D; - buttons[ii].buttonX = 100; - buttons[ii].buttonY = 292; - buttons[ii].buttonWidth = 90; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Units Off"); - buttons[ii].textColor = 75; - buttons[ii].textHue = 10; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Generate a Postscript file */ - ii = ps2D; - buttons[ii].buttonX = 195; - buttons[ii].buttonY = 292; - buttons[ii].buttonWidth = 36; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"PS"); - buttons[ii].textColor = 35; - buttons[ii].textHue = 5; - buttons[ii].textShade = 2; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Bounding Rectangle On/Off */ - ii = spline2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 329; - buttons[ii].buttonWidth = 66; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Box Off"); - buttons[ii].textColor = 7; - buttons[ii].textHue = 26; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Graph points On/Off */ - ii = pointsOnOff; - buttons[ii].buttonX = 75; - buttons[ii].buttonY = 329; - buttons[ii].buttonWidth = 67; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Pts On "); - buttons[ii].textColor = 7; - buttons[ii].textHue = 26; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Graph lines On/Off */ - ii = connectOnOff; - buttons[ii].buttonX = 147; - buttons[ii].buttonY = 329; - buttons[ii].buttonWidth = 84; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Lines On "); - buttons[ii].textColor = 7; - buttons[ii].textHue = 26; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Reset View Position Button */ - ii = reset2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 364; - buttons[ii].buttonWidth = 60; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Reset"); - buttons[ii].textColor = bColor; - buttons[ii].textHue = 5; - buttons[ii].textShade = 2; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Hide Control Panel */ - ii = hideControl2D; - buttons[ii].buttonX = 70; - buttons[ii].buttonY = 364; - buttons[ii].buttonWidth = 88; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Hide Panel"); - buttons[ii].textColor = bColor; - buttons[ii].textHue = 5; - buttons[ii].textShade = 2; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Exits from the viewport running */ - ii = closeAll2D; - buttons[ii].buttonX = 169; - buttons[ii].buttonY = 370; - buttons[ii].buttonWidth = 61; - buttons[ii].buttonHeight = 24; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Quit"); - buttons[ii].textColor = 13; - buttons[ii].textHue = 29; - buttons[ii].textShade = 2; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Indicates that the graph from a viewport is to be picked up. */ - ii = pick2D; - buttons[ii].buttonX = 190; - buttons[ii].buttonY = 217; - buttons[ii].buttonWidth = 40; - buttons[ii].buttonHeight = 24; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Pick"); - buttons[ii].textColor = 123; - buttons[ii].textHue = 19; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Indicates that the graph from a viewport is to be dropped into a slot. */ - ii = drop2D; - buttons[ii].buttonX = 190; - buttons[ii].buttonY = 245; - buttons[ii].buttonWidth = 40; - buttons[ii].buttonHeight = 24; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Drop"); - buttons[ii].textColor = 123; - buttons[ii].textHue = 19; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Indicates that the status of the graphs being displayed in the viewport - is to be cleared. */ - ii = clear2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 217; - buttons[ii].buttonWidth = 49; - buttons[ii].buttonHeight = 24; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Clear"); - buttons[ii].textColor = 123; - buttons[ii].textHue = 19; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Asks for the scale and translation information for the specified graph. */ - ii = query2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 245; - buttons[ii].buttonWidth = 49; - buttons[ii].buttonHeight = 24; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Query"); - buttons[ii].textColor = 123; - buttons[ii].textHue = 19; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* These buttons indicate the 9 available slot numbers into which - a 2D graph can be placed, and the status of the graph, i.e. whether - it is displayed or not. */ - - ii = graph1; - buttons[ii].buttonX = graphBarLeft; - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"1"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect1; - buttons[ii].buttonX = graphBarLeft; - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"^"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph2; - buttons[ii].buttonX = graphBarLeft + (graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"2"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect2; - buttons[ii].buttonX = graphBarLeft + (graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph3; - buttons[ii].buttonX = graphBarLeft + 2*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"3"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect3; - buttons[ii].buttonX = graphBarLeft + 2*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /**** blend these three together ***/ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph4; - buttons[ii].buttonX = graphBarLeft + 3*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"4"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect4; - buttons[ii].buttonX = graphBarLeft + 3*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph5; - buttons[ii].buttonX = graphBarLeft + 4*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"5"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect5; - buttons[ii].buttonX = graphBarLeft + 4*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph6; - buttons[ii].buttonX = graphBarLeft + 5*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"6"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect6; - buttons[ii].buttonX = graphBarLeft + 5*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph7; - buttons[ii].buttonX = graphBarLeft + 6*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"7"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect7; - buttons[ii].buttonX = graphBarLeft + 6*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph8; - buttons[ii].buttonX = graphBarLeft + 7*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"8"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect8; - buttons[ii].buttonX = graphBarLeft + 7*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph9; - buttons[ii].buttonX = graphBarLeft + 8*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"9"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect9; - buttons[ii].buttonX = graphBarLeft + 8*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"*"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - return(num); -} -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/control2d.c.pamphlet b/src/graph/view2D/control2d.c index c45ba400..5645e2ec 100644 --- a/src/graph/view2D/control2d.c.pamphlet +++ b/src/graph/view2D/control2d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D control2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _CONTROL2D_C #include "axiom-c-macros.h" @@ -108,8 +94,8 @@ writeControlTitle(void) XClearArea(dsply,control->controlWindow,0,0,controlWidth,potA,False); GSetForeground(anotherGC,(float)controlTitleColor,Xoption); GDrawImageString(anotherGC,control->controlWindow, - centerX(anotherGC,s,strlength,controlWidth), - 15,s,strlength,Xoption); + centerX(anotherGC,s,strlength,controlWidth), + 15,s,strlength,Xoption); } /* writeControlTitle() */ @@ -138,8 +124,8 @@ makeMessageFromData(int whichGraph) strcpy(deltaXReport,"-big"); } else { sprintf(deltaXReport,"%4.0f", - -graphStateArray[whichGraph].centerX / - graphArray[whichGraph].unitX); + -graphStateArray[whichGraph].centerX / + graphArray[whichGraph].unitX); } if ((graphStateArray[whichGraph].centerY) > 999.0) { strcpy(deltaYReport,"+big"); @@ -147,11 +133,11 @@ makeMessageFromData(int whichGraph) strcpy(deltaYReport,"-big"); } else { sprintf(deltaYReport,"%4.0f", - -graphStateArray[whichGraph].centerY / - graphArray[whichGraph].unitY); + -graphStateArray[whichGraph].centerY / + graphArray[whichGraph].unitY); } sprintf(viewport->controlPanel->message,"[%s,%s] >%d< [%s,%s]", - scaleXReport,scaleYReport,whichGraph+1,deltaXReport,deltaYReport); + scaleXReport,scaleYReport,whichGraph+1,deltaXReport,deltaYReport); } /* if haveControl */ } /* makeMessageFromData() */ @@ -164,7 +150,7 @@ writeControlMessage() writeControlMessage(void) #endif { - int strlength; + int strlength; controlPanelStruct *cp; XWindowAttributes cwInfo; @@ -175,9 +161,9 @@ writeControlMessage(void) GDrawImageString(controlMessageGC,cp->controlWindow, - centerX(globalGC1,cp->message,strlength,controlWidth), - controlMessageY + globalFont->max_bounds.ascent - 2, - cp->message,strlength,Xoption); + centerX(globalGC1,cp->message,strlength,controlWidth), + controlMessageY + globalFont->max_bounds.ascent - 2, + cp->message,strlength,Xoption); } /*********************************/ @@ -205,13 +191,13 @@ drawControlPanel(void) 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); + 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); + (controlWidth-closeLeft+8),(controlHeight-closeTop+8),Xoption); /* Write potentiometer titles on the control panel. */ writeControlTitle(); @@ -219,17 +205,17 @@ drawControlPanel(void) 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); + 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); + centerX(globGC,s,strlength, + cp->buttonQueue[translate2D].buttonWidth) + + cp->buttonQueue[translate2D].buttonX, + 31+headerHeight,s,strlen(s),Xoption); GSetForeground(globGC,(float)controlColorColor,Xoption); @@ -237,8 +223,8 @@ drawControlPanel(void) s = "Graphs"; strlength = strlen(s); GDrawString(globGC,cp->controlWindow, - centerX(globGC,s,strlength,controlWidth),graphHeaderHeight, - s,strlength,Xoption); + centerX(globGC,s,strlength,controlWidth),graphHeaderHeight, + s,strlength,Xoption); /* Write titles on regular buttons and draw pixmaps on potentiometers. */ @@ -247,142 +233,142 @@ drawControlPanel(void) 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); + (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); + (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); + (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); + (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; + GDrawLines(trashGC,cp->controlWindow,scaleArrow, + scaleArrowN,CoordModeOrigin,Xoption); + break; case translate2D: - GDrawLines(trashGC,cp->controlWindow,translateArrow, - translateArrowN,CoordModeOrigin,Xoption); - break; + 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); + 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); - } + 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,"^"); + 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,"-"); + 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); + (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; + 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); + (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 */ @@ -403,10 +389,10 @@ getControlXY(int whereDoYouWantPanel) #endif { XWindowAttributes wAttr, wAttrib; - controlXY cXY; - int tmp=1; - Window rootW, parentW, *childrenWs, tmpW; - unsigned int nChildren; + controlXY cXY; + int tmp=1; + Window rootW, parentW, *childrenWs, tmpW; + unsigned int nChildren; tmpW = viewport->titleWindow; while(tmp) { @@ -441,7 +427,7 @@ getControlXY(int whereDoYouWantPanel) cXY.putX = wAttrib.x + wAttrib.width; cXY.putY = wAttrib.y; } else if ((physicalHeight - (wAttrib.y + wAttr.height)) >= - controlHeight) { + controlHeight) { cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; cXY.putY = wAttrib.y + wAttrib.height; } else if (wAttrib.x >= controlWidth) { @@ -450,7 +436,7 @@ getControlXY(int whereDoYouWantPanel) } else if (wAttrib.y >= controlHeight) { cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; cXY.putY = wAttrib.y - controlHeight - borderHeight; - } else { /* put inside of viewport */ + } else { /* put inside of viewport */ cXY.putX = wAttrib.x + wAttr.width - controlWidth; cXY.putY = wAttrib.y + wAttr.height - controlHeight; } @@ -472,14 +458,14 @@ makeControlPanel(void) { Window cw; - int i,num; + int i,num; controlPanelStruct *control; - buttonStruct *buttons; - controlXY cXY; + buttonStruct *buttons; + controlXY cXY; XSetWindowAttributes cwAttrib, controlAttrib; - XSizeHints sizehints; - Pixmap mousebits,mousemask; - XColor foreColor, backColor; + XSizeHints sizehints; + Pixmap mousebits,mousemask; + XColor foreColor, backColor; if (!(control = (controlPanelStruct *)malloc(sizeof(controlPanelStruct)))) { fprintf(stderr,"Ran out of memory trying to create a control panel.\n"); @@ -490,9 +476,9 @@ makeControlPanel(void) /* Define and assign a mouse cursor. */ mousebits = XCreateBitmapFromData(dsply,rtWindow,mouseBitmap_bits, - mouseBitmap_width,mouseBitmap_height); + mouseBitmap_width,mouseBitmap_height); mousemask = XCreateBitmapFromData(dsply,rtWindow,mouseMask_bits, - mouseMask_width,mouseMask_height); + mouseMask_width,mouseMask_height); cwAttrib.background_pixel = backgroundColor; /* controlBackground; */ cwAttrib.border_pixel = foregroundColor; cwAttrib.backing_store = WhenMapped; @@ -504,17 +490,17 @@ makeControlPanel(void) backColor.pixel = controlCursorBackground; XQueryColor(dsply,colorMap,&backColor); cwAttrib.cursor = XCreatePixmapCursor(dsply,mousebits,mousemask, - &foreColor,&backColor, - mouseBitmap_x_hot,mouseBitmap_y_hot); + &foreColor,&backColor, + mouseBitmap_x_hot,mouseBitmap_y_hot); cw = XCreateWindow(dsply,rtWindow, - cXY.putX,cXY.putY,controlWidth,controlHeight,3, - CopyFromParent,InputOutput,CopyFromParent, - controlCreateMASK,&cwAttrib); + cXY.putX,cXY.putY,controlWidth,controlHeight,3, + CopyFromParent,InputOutput,CopyFromParent, + controlCreateMASK,&cwAttrib); sizehints.flags = PPosition | PSize; - sizehints.x = cXY.putX; - sizehints.y = cXY.putY; + sizehints.x = cXY.putX; + sizehints.y = cXY.putY; sizehints.width = controlWidth; sizehints.height = controlHeight; @@ -522,7 +508,7 @@ makeControlPanel(void) XSetNormalHints(dsply,cw,&sizehints); XSetStandardProperties(dsply,cw,"2D Control Panel","2D Control Panel", - None,NULL,0,&sizehints); + None,NULL,0,&sizehints); control->controlWindow = cw; num = initButtons(control->buttonQueue); @@ -532,24 +518,24 @@ makeControlPanel(void) for (i=0; i<num; i++) { controlAttrib.event_mask = (control->buttonQueue[i]).mask; (control->buttonQueue[i]).self = XCreateWindow(dsply,cw, - (control->buttonQueue[i]).buttonX, - (control->buttonQueue[i]).buttonY, - (control->buttonQueue[i]).buttonWidth, - (control->buttonQueue[i]).buttonHeight, - 0,0,InputOnly,CopyFromParent, - buttonCreateMASK,&controlAttrib); + (control->buttonQueue[i]).buttonX, + (control->buttonQueue[i]).buttonY, + (control->buttonQueue[i]).buttonWidth, + (control->buttonQueue[i]).buttonHeight, + 0,0,InputOnly,CopyFromParent, + buttonCreateMASK,&controlAttrib); XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, - &((control->buttonQueue[i]).buttonKey)); + &((control->buttonQueue[i]).buttonKey)); /* Use buttonKey instead of i because buttonKey has a permanent address */ XMapWindow(dsply,(control->buttonQueue[i]).self); } - /* Create message window */ + /* Create message window */ control->messageWindow = XCreateWindow(dsply,cw,0,controlMessageY, - controlWidth,controlMessageHeight, - 0,0,InputOnly,CopyFromParent, - messageCreateMASK,&cwAttrib); + controlWidth,controlMessageHeight, + 0,0,InputOnly,CopyFromParent, + messageCreateMASK,&cwAttrib); XMapWindow(dsply,control->messageWindow); for (i=0; i<scaleArrowN; i++) { @@ -591,7 +577,7 @@ putControlPanelSomewhere(int whereDoesPanelGo) #endif { controlPanelStruct *control; - controlXY whereControl; + controlXY whereControl; control = viewport->controlPanel; whereControl = getControlXY(whereDoesPanelGo); @@ -600,7 +586,7 @@ putControlPanelSomewhere(int whereDoesPanelGo) XRaiseWindow(dsply,control->controlWindow); XMoveWindow(dsply,control->controlWindow,whereControl.putX, - whereControl.putY); + whereControl.putY); drawControlPanel(); if (viewport->justMadeControl) { @@ -629,13 +615,7 @@ clearControlMessage(void) strcpy(viewport->controlPanel->message,""); XClearArea(dsply,viewport->controlPanel->controlWindow, - 0,controlMessageY-2,controlWidth,controlMessageHeight,False); + 0,controlMessageY-2,controlWidth,controlMessageHeight,False); } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/globals2.h b/src/graph/view2D/globals2.h index de0d132a..1544471d 100755..100644 --- a/src/graph/view2D/globals2.h +++ b/src/graph/view2D/globals2.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ extern int scrn; diff --git a/src/graph/view2D/graph2d.c.pamphlet b/src/graph/view2D/graph2d.c index add87b5b..47960cd7 100644 --- a/src/graph/view2D/graph2d.c.pamphlet +++ b/src/graph/view2D/graph2d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D graph2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All right reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _GRAPH2D_C #include "axiom-c-macros.h" @@ -172,7 +158,7 @@ freeGraph(int i) if (graphArray[i].key) { graphArray[i].key = 0; /* 0 means no graph */ for (j=0,llPtr=graphArray[i].listOfListsOfPoints; - j<graphArray[i].numberOfLists; j++,llPtr++) + j<graphArray[i].numberOfLists; j++,llPtr++) free(llPtr->listOfPoints); free(llPtr); free(xPointsArray[i].xPoint); @@ -180,9 +166,3 @@ freeGraph(int i) } } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/header2.h b/src/graph/view2D/header2.h index b6b37848..c7d63985 100755..100644 --- a/src/graph/view2D/header2.h +++ b/src/graph/view2D/header2.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights resrved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <X11/Xlib.h> diff --git a/src/graph/view2D/main2d.c.pamphlet b/src/graph/view2D/main2d.c index 72135f9a..8ff6b8e7 100644 --- a/src/graph/view2D/main2d.c.pamphlet +++ b/src/graph/view2D/main2d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D main2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _MAIN2D_C #include "axiom-c-macros.h" @@ -217,10 +203,10 @@ main(void) (void) strcpy(prop, "off"); if (mono) - if (strcmp(prop,"on") == 0) { /* 0 if equal (inverse video) */ + if (strcmp(prop,"on") == 0) { /* 0 if equal (inverse video) */ foregroundColor = WhitePixel(dsply,scrn); backgroundColor = BlackPixel(dsply,scrn); - } else { /* off (no inverse video) */ + } else { /* off (no inverse video) */ foregroundColor = BlackPixel(dsply,scrn); backgroundColor = WhitePixel(dsply,scrn); } @@ -236,9 +222,9 @@ main(void) /* read default file name for postScript output */ if (XrmGetResource(rDB, - "Axiom.2D.postscriptFile", - "", - str_type, &value) == True) + "Axiom.2D.postscriptFile", + "", + str_type, &value) == True) (void) strncpy(prop,value.addr,(int)value.size); else (void) strcpy(prop, "axiom2D.ps"); @@ -252,84 +238,84 @@ main(void) serverFont = XQueryFont(dsply,XGContextFromGC(DefaultGC(dsply,scrn))); if (XrmGetResource(rDB, - "Axiom.2D.messageFont", - "Axiom.2D.Font", - str_type, &value) == True) + "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); + "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) + "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); + "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) + "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); + "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) + "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); + "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) + "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); + "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) + "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); + "Warning: could not get the %s font for unitFont\n",prop); unitFont = serverFont; } @@ -345,19 +331,19 @@ main(void) controlGCVals.foreground = monoColor(axesColorDefault); controlGCVals.background = backgroundColor; globalGC1 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground , - &controlGCVals); + &controlGCVals); carefullySetFont(globalGC1,globalFont); /* create the equivalent GCs for ps */ PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* controlMessageGC */ controlGCVals.foreground = controlMessageColor; controlMessageGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(controlMessageGC,globalFont); /* globalGC2 */ @@ -365,24 +351,24 @@ main(void) controlGCVals.foreground = monoColor(labelColor); controlGCVals.background = backgroundColor; globalGC2 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground, - &controlGCVals); + &controlGCVals); carefullySetFont(globalGC2,buttonFont); PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* trashGC */ trashGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); carefullySetFont(trashGC,buttonFont); PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* globGC */ globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); carefullySetFont(globGC,headerFont); PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* anotherGC */ @@ -390,7 +376,7 @@ main(void) anotherGC = XCreateGC(dsply,rtWindow,GCBackground,&controlGCVals); carefullySetFont(anotherGC,titleFont); PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* processGC */ @@ -403,14 +389,14 @@ main(void) graphGC = XCreateGC(dsply,rtWindow,GCBackground,&gcVals); carefullySetFont(graphGC,graphFont); PSCreateContext(graphGC, "graphGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* unitGC */ unitGC = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals); carefullySetFont(unitGC,unitFont); PSCreateContext(unitGC, "unitGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /**** Initialize Graph States ****/ @@ -443,14 +429,14 @@ main(void) if (!(viewData.title = (char *)malloc(i))) { fprintf(stderr, - "ERROR: Ran out of memory trying to receive the title.\n"); + "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 **/ + if (graphArray[i].key) { /** this graph slot has data **/ getGraphFromViewman(i); } /* if graph exists (graphArray[i].key is not zero) */ } /* for i in graphs */ @@ -515,9 +501,3 @@ mergeDatabases(void) XrmMergeDatabases(homeDB,&rDB); } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/pot2d.c b/src/graph/view2D/pot2d.c new file mode 100644 index 00000000..95443a4d --- /dev/null +++ b/src/graph/view2D/pot2d.c @@ -0,0 +1,63 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _POT2D_C +#include "axiom-c-macros.h" + +#include "header2.h" + +#include "all_2d.H1" + +mouseCoord +#ifdef _NO_PROTO +getPotValue(eX,eY,xH,yH) + short eX,eY,xH,yH; +#else +getPotValue(short eX,short eY,short xH,short yH) +#endif +{ + + mouseCoord whereMouse; + float x,y; + + x = (float)eX/xH - 1; + y = -((float)eY/yH -1); + /* make non-linear potentiometer */ + whereMouse.x = x*x*x; + whereMouse.y = y*y*y; + + return(whereMouse); + +} /* getPotValue() */ diff --git a/src/graph/view2D/pot2d.c.pamphlet b/src/graph/view2D/pot2d.c.pamphlet deleted file mode 100644 index af4addb7..00000000 --- a/src/graph/view2D/pot2d.c.pamphlet +++ /dev/null @@ -1,83 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D pot2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _POT2D_C -#include "axiom-c-macros.h" - -#include "header2.h" - -#include "all_2d.H1" - -mouseCoord -#ifdef _NO_PROTO -getPotValue(eX,eY,xH,yH) - short eX,eY,xH,yH; -#else -getPotValue(short eX,short eY,short xH,short yH) -#endif -{ - - mouseCoord whereMouse; - float x,y; - - x = (float)eX/xH - 1; - y = -((float)eY/yH -1); - /* make non-linear potentiometer */ - whereMouse.x = x*x*x; - whereMouse.y = y*y*y; - - return(whereMouse); - -} /* getPotValue() */ -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/process2d.c b/src/graph/view2D/process2d.c new file mode 100644 index 00000000..7df82480 --- /dev/null +++ b/src/graph/view2D/process2d.c @@ -0,0 +1,938 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _PROCESS2D_C +#include "axiom-c-macros.h" + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/time.h> +#ifdef RIOSplatform +#include <sys/select.h> +#endif + +#include "header2.h" + +#include "all_2d.H1" +#include "util.H1" +#include "Gfun.H1" +#include "XSpadFill.H1" + + +static int doit=0; /* globish variable for picking/dropping/clearing - all sorts of + 2 button sequence events (command & graph #). */ + + +void +#ifdef _NO_PROTO +doPick (i,bKey) + int i,bKey; +#else +doPick (int i,int bKey) +#endif +{ + int vCommand=pick2D; + + picking = no; + /* reset indicator so that we're not in pick/drop/query mode anymore */ + doit = 0; + if (graphArray[currentGraph].key) { + check(write(Socket,&vCommand,intSize)); + check(write(Socket,&(graphArray[currentGraph].key),intSize)); + check(write(Socket,&(graphStateArray[currentGraph]), + sizeof(graphStateStruct))); + sprintf(control->message,"%s%d","Picked up graph ",currentGraph+1); + } else + sprintf(control->message,"%s","This graph is empty!"); + writeControlMessage(); + + +} + + +void +#ifdef _NO_PROTO +doDrop (i,bKey) + int i,bKey; +#else +doDrop (int i,int bKey) +#endif +{ + int vCommand=drop2D; + int viewGoAhead; + + dropping = no; + /* reset indicator so that we're not in pick/drop/query mode anymore */ + doit = 0; + check(write(Socket,&(vCommand),intSize)); + readViewman(&viewGoAhead,intSize); + if (viewGoAhead < 0) { + sprintf(control->message,"%s%d","Couldn't drop to graph ",currentGraph+1); + writeControlMessage(); + } else { + sprintf(control->message,"%s%d","Dropped onto graph ",currentGraph+1); + writeControlMessage(); + freeGraph(currentGraph); + readViewman(&(graphArray[currentGraph].key),intSize); + getGraphFromViewman(currentGraph); + /* simulate a button press to turn display number on and select on */ + /* need !yes since it will be inverted */ + graphStateArray[currentGraph].selected = no; + graphStateArray[currentGraph].showing = + !(graphStateArray[currentGraph].showing); + clickedOnGraph(currentGraph,currentGraph+graphStart); + clickedOnGraphSelect(currentGraph,currentGraph+graphSelectStart); + } +} + +void +#ifdef _NO_PROTO +clickedOnGraphSelect (i,bKey) + int i,bKey; +#else +clickedOnGraphSelect (int i,int bKey) +#endif +{ + int strlength; + + switch (doit) { + case pick2D: + currentGraph = i; + doPick(i,bKey); + break; + case drop2D: + currentGraph = i; + doDrop(i,bKey); + break; + case query2D: + queriedGraph = i; + makeMessageFromData(queriedGraph); + writeControlMessage(); + /* reset indicator so that we're not in pick/drop/query mode anymore */ + doit = 0; + break; + default: + graphStateArray[i].selected = !(graphStateArray[i].selected); + if (graphStateArray[i].selected) { + GSetForeground(graphGC,(float)graphBarSelectColor,Xoption); + strcpy(control->buttonQueue[bKey].text,"^"); + strlength = strlen(control->buttonQueue[bKey].text); + } else { + GSetForeground(graphGC,(float)graphBarNotSelectColor,Xoption); + strcpy(control->buttonQueue[bKey].text,"-"); + strlength = strlen(control->buttonQueue[bKey].text); + } + /* just to make sure the background is reset from clickedOnGraph */ + if (mono) { + GSetForeground(graphGC,(float)foregroundColor,Xoption); + GSetBackground(graphGC,(float)backgroundColor,Xoption); + } + + GDrawImageString(graphGC,control->controlWindow, + control->buttonQueue[bKey].buttonX + + centerX(graphGC, + control->buttonQueue[bKey].text,strlength, + control->buttonQueue[bKey].buttonWidth), + control->buttonQueue[bKey].buttonY + + centerY(graphGC, + control->buttonQueue[bKey].buttonHeight), + control->buttonQueue[bKey].text,strlength,Xoption); + GSetForeground(trashGC,(float)foregroundColor,Xoption); + GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption); + GDrawLine(trashGC,control->controlWindow,0,286,controlWidth,286,Xoption); + break; + } /* switch doit */ + +} + + +static void +#ifndef _NO_PROTO +drawControlPushButton(int isOn, int index) +#else + drawControlPushButton(isOn,index) + int isOn; + int index; +#endif +{ + GDrawPushButton(dsply, processGC, processGC, processGC, + control->controlWindow, + (control->buttonQueue[index]).buttonX, + (control->buttonQueue[index]).buttonY, + (control->buttonQueue[index]).buttonWidth, + (control->buttonQueue[index]).buttonHeight, + isOn, + (control->buttonQueue[index]).text, + buttonColor, + monoColor((control->buttonQueue[index]).textColor), Xoption); + XSync(dsply,False); +} + + + +void +#ifdef _NO_PROTO +buttonAction (bKey) + int bKey; +#else +buttonAction (int bKey) +#endif +{ + int i; + + switch (bKey) { + + case pick2D: + if (viewAloned) { + sprintf(control->message,"%s","Cannot pick without AXIOM!"); + writeControlMessage(); + XSync(dsply,False); + } + else { + doit = pick2D; + sprintf(control->message,"%s","Click on the graph to pick"); + writeControlMessage(); + XSync(dsply,False); + } + break; + + case drop2D: + if (viewAloned) { + sprintf(control->message,"%s","Cannot drop without AXIOM!"); + writeControlMessage(); + XSync(dsply,False); + } else { + doit = drop2D; + sprintf(control->message,"%s","Click on the graph to drop"); + writeControlMessage(); + XSync(dsply,False); + } + break; + + case query2D: + doit = query2D; + sprintf(control->message,"%s","Click on the graph to query"); + writeControlMessage(); + XSync(dsply,False); + break; + + + case zoom2Dx: + if (zoomXON) + strcpy((control->buttonQueue[zoom2Dx]).text , + "X Off"); + else + strcpy((control->buttonQueue[zoom2Dx]).text , + "X On "); + zoomXON = !zoomXON; + + drawControlPushButton(zoomXON, zoom2Dx); + XSync(dsply,False); + break; + + case zoom2Dy: + if (zoomYON) strcpy((control->buttonQueue[zoom2Dy]).text, + "Y Off"); + else strcpy((control->buttonQueue[zoom2Dy]).text , + "Y On "); + zoomYON = !zoomYON; + drawControlPushButton(zoomYON, zoom2Dy); + XSync(dsply,False); + break; + + + case translate2Dx: + if (transXON) strcpy((control->buttonQueue[translate2Dx]).text, + "X Off"); + else strcpy( (control->buttonQueue[translate2Dx]).text, + "X On "); + transXON = !transXON; + drawControlPushButton(transXON, translate2Dx); + XSync(dsply,False); + break; + + case translate2Dy: + if (transYON) strcpy((control->buttonQueue[translate2Dy]).text, + "Y Off"); + else strcpy( (control->buttonQueue[translate2Dy]).text, + "Y On"); + transYON = !transYON; + drawControlPushButton(transYON, translate2Dy); + XSync(dsply,False); + break; + + case pointsOnOff: + if (pointsON) strcpy((control->buttonQueue[pointsOnOff]).text, + "Pts Off"); + else strcpy( (control->buttonQueue[pointsOnOff]).text, + "Pts On "); + pointsON = !pointsON; + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i].pointsOn = pointsON; + + drawControlPushButton(pointsON, pointsOnOff); + drawViewport(Xoption); + break; + + case connectOnOff: + if (connectON) strcpy((control->buttonQueue[connectOnOff]).text, + "Lines Off"); + else strcpy( (control->buttonQueue[connectOnOff]).text, + "Lines On "); + connectON = !connectON; + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i].connectOn = connectON; + + drawControlPushButton(connectON, connectOnOff); + drawViewport(Xoption); + break; + + case spline2D: + if (splineON) strcpy((control->buttonQueue[spline2D]).text, + "Box Off"); + else strcpy ((control->buttonQueue[spline2D]).text , + "Box On "); + splineON = !splineON; + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i].splineOn = splineON; + + drawControlPushButton(splineON, spline2D); + drawViewport(Xoption); + break; + + case axesOnOff2D: + if (axesON) + strcpy ((control->buttonQueue[axesOnOff2D]).text, + "Axes Off"); + else + strcpy ((control->buttonQueue[axesOnOff2D]).text , + "Axes On "); + axesON = !axesON; + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i].axesOn = axesON; + + drawControlPushButton(axesON, axesOnOff2D); + drawViewport(Xoption); + break; + + case unitsOnOff2D: + if (unitsON) + strcpy( (control->buttonQueue[unitsOnOff2D]).text, + "Units Off"); + else + strcpy ((control->buttonQueue[unitsOnOff2D]).text, + "Units On "); + unitsON = !unitsON; + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i].unitsOn = unitsON; + + drawControlPushButton(unitsON, unitsOnOff2D); + drawViewport(Xoption); + break; + + case ps2D: + strcpy(control->message,"Creating postscript now ..."); + writeControlMessage(); + drawControlPushButton(1, ps2D); + + if (PSInit(viewport->viewWindow, viewport->titleWindow) == psError) { + strcpy(control->message,"Aborted: PSInit error."); + writeControlMessage(); + drawControlPushButton(0, ps2D); + XSync(dsply,False); + return; /* make new temp name for new file */ + } + + drawViewport(PSoption); /* draw picture in PS; create ps script file */ + + if (PSCreateFile(viewBorderWidth, + viewport->viewWindow, + viewport->titleWindow, + viewport->title) == psError) { + strcpy(control->message,"Aborted: PSCreateFile error."); + writeControlMessage(); + drawControlPushButton(0, ps2D); + XSync(dsply,False); + return; + } + + clearControlMessage(); + strcpy(control->message,PSfilename); + strcat(control->message," in working dir "); + writeControlMessage(); + drawControlPushButton(0, ps2D); + XSync(dsply,False); + break; + + case hideControl2D: + if (viewport->haveControl) { + viewport->haveControl = no; + XUnmapWindow(dsply,control->controlWindow); + XSync(dsply,False); + } + break; + + case reset2D: + /* reset view */ + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i] = graphStateBackupArray[i]; + + unitsON = no; + strcpy( (control->buttonQueue[unitsOnOff2D]).text,s = "Units Off"); + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i].unitsOn = no; + drawControlPushButton(unitsON, unitsOnOff2D); + + pointsON = yes; + strcpy ((control->buttonQueue[pointsOnOff]).text ,"Pts On "); + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i].pointsOn = yes; + drawControlPushButton(pointsON, pointsOnOff); + + axesON = yes; + strcpy ((control->buttonQueue[axesOnOff2D]).text,"Axes On "); + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i].axesOn = yes; + drawControlPushButton(axesON, axesOnOff2D); + + connectON = yes; + strcpy((control->buttonQueue[connectOnOff]).text,"Lines On "); + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i].connectOn = yes; + drawControlPushButton(connectON, connectOnOff); + + splineON = no; + strcpy( (control->buttonQueue[connectOnOff]).text ,"Box Off"); + for (i=0; i<maxGraphs; i++) + if (graphStateArray[i].showing && graphStateArray[i].selected) + graphStateArray[i].splineOn = splineON; + drawControlPushButton(splineON, spline2D); + drawViewport(Xoption); + + break; + + case closeAll2D: + strcpy(control->message," Click again to confirm "); + writeControlMessage(); + drawControlPushButton(1, closeAll2D); + XSync(dsply,False); + viewport->closing = yes; + break; + + case clear2D: + for (i=0; i<maxGraphs; i++) graphStateArray[i].selected = 1; + clickedOnGraphSelect(0,graphSelect1); + clickedOnGraphSelect(1,graphSelect2); + clickedOnGraphSelect(2,graphSelect3); + clickedOnGraphSelect(3,graphSelect4); + clickedOnGraphSelect(4,graphSelect5); + clickedOnGraphSelect(5,graphSelect6); + clickedOnGraphSelect(6,graphSelect7); + clickedOnGraphSelect(7,graphSelect8); + clickedOnGraphSelect(8,graphSelect9); + XSync(dsply,False); + break; + + case graph1: + case graph2: + case graph3: + case graph4: + case graph5: + case graph6: + case graph7: + case graph8: + case graph9: + clickedOnGraph(bKey-graphStart,bKey); + XSync(dsply,False); + break; + + case graphSelect1: + case graphSelect2: + case graphSelect3: + case graphSelect4: + case graphSelect5: + case graphSelect6: + case graphSelect7: + case graphSelect8: + case graphSelect9: + clickedOnGraphSelect(bKey-graphSelectStart,bKey); + XSync(dsply,False); + break; + + } /* switch (action) */ +} + +/*********************** X Event Processing ***************************/ +void +#ifdef _NO_PROTO +processEvents() +#else +processEvents(void) +#endif +{ + + XEvent *event, + tempEvent; + Window whichWindow; + XWindowAttributes graphWindowAttrib; + buttonStruct *controlButton; + mouseCoord mouseXY; + int i, + someInt, + mouseW4, + mouseH4, + toggleReady, + gotToggle = no, + checkButton = no, + firstTime = yes, + gotEvent = 0, + buttonTablePtr, + Xcon, + len, + externalControl; + fd_set rd; + + + externalControl=0; + Xcon = ConnectionNumber(dsply); + + + if (!(event = (XEvent *)malloc(sizeof(XEvent)))) { + fprintf(stderr,"Ran out of memory initializing event processing.\n"); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + + controlButton = control->buttonQueue; + + while(1) { + + len=0; + while(len<=0) { + FD_ZERO(&rd); + if (externalControl==0) FD_SET(0, &rd); + FD_SET(Xcon,&rd); + + if (XEventsQueued(dsply, QueuedAlready)) { + len=1; + break; + } + if (!followMouse) + len=select(FD_SETSIZE,(void *) &rd,0,0,0); + else + len=1; + } + if (FD_ISSET(Xcon,&rd)|| + XEventsQueued(dsply, QueuedAfterFlush) || + followMouse) { + + if (followMouse) { + if (XPending(dsply)) + XNextEvent(dsply,event); + gotEvent++; + } else { + XNextEvent(dsply,event); + gotEvent++; + } + + if (gotToggle || !followMouse) + checkButton = no; + + if (gotEvent) { + whichWindow = ((XButtonEvent *)event)->window; + firstTime = no; + + switch(((XEvent *)event)->type) { + + case ClientMessage: + if (event->xclient.data.l[0] == wm_delete_window) { + goodbye(-1); + } + else { + fprintf(stderr,"Unknown Client Message ...\n"); + } + break; + case Expose: + if (whichWindow == viewport->titleWindow) { + /* get rid of redundant events */ + XCheckWindowEvent(dsply, + viewport->titleWindow, + ExposureMask, + &tempEvent); + writeTitle(); + XGetWindowAttributes(dsply, + whichWindow, + &graphWindowAttrib); + XResizeWindow(dsply, + viewport->viewWindow, + graphWindowAttrib.width, + graphWindowAttrib.height-titleHeight); + XSync(dsply,False); + break; + } else if (whichWindow == viewport->viewWindow) { + XCheckWindowEvent(dsply, + viewport->viewWindow, + ExposureMask, + &tempEvent); + XGetWindowAttributes(dsply, + viewport->titleWindow, + &graphWindowAttrib); + XResizeWindow(dsply, + viewport->viewWindow, + graphWindowAttrib.width, + graphWindowAttrib.height-titleHeight); + drawViewport(Xoption); + XMapWindow(dsply,whichWindow); + XSync(dsply,False); + break; + } else { /* it's gotta be the control panel */ + XGetWindowAttributes(dsply, + control->controlWindow, + &graphWindowAttrib); + /* do not allow resizing of control panel */ + if ((graphWindowAttrib.width != controlWidth) || + (graphWindowAttrib.height != controlHeight)) { + XResizeWindow(dsply, + control->controlWindow, + controlWidth, + controlHeight); + } + drawControlPanel(); + XSync(dsply,False); + break; + } + break; + + case MotionNotify: + if (followMouse) { + while (XCheckMaskEvent(dsply, + ButtonMotionMask, + event)); + mouseXY = getPotValue(((XButtonEvent *)event)->x, + ((XButtonEvent *)event)->y, + controlButton->xHalf, + controlButton->yHalf); + } + if (controlButton->pot) { + gotToggle = no; + checkButton = yes; + } + break; + + case ButtonRelease: + if (followMouse==yes) { + followMouse = no; + toggleReady = yes; + checkButton = no; + drawViewport(Xoption); + } else { + followMouse = no; + toggleReady = yes; + checkButton = no; + } + break; + + case LeaveNotify: + /* + We still follow the mouse when we leave the pots. + */ + /* + followMouse = no; + toggleReady = yes; + checkButton = no; + */ + + break; + + case ButtonPress: + if (whichWindow == viewport->viewWindow) { + + /* mouse clicked on viewport */ + + switch (((XButtonEvent *)event)->button) { + case Button3: + + /* print out (x,y) object-space coordinates in message area */ + + XGetWindowAttributes(dsply,whichWindow,&graphWindowAttrib); + sprintf(viewport->controlPanel->message, + " >%d<: [%6.2f,%6.2f] ", + queriedGraph+1, + projX((((XButtonEvent *)event)->x), + graphWindowAttrib.width,queriedGraph), + projY((((XButtonEvent *)event)->y), + graphWindowAttrib.height,queriedGraph)); + writeControlMessage(); + XFlush(dsply); + break; + default: + + /* Find where mouse is on the viewport => where to put the CP */ + + XGetWindowAttributes(dsply, + whichWindow, + &graphWindowAttrib); + mouseW4 = graphWindowAttrib.width/4; + if (((XButtonEvent *)event)->x > + (graphWindowAttrib.width - mouseW4)) + someInt = 1; + else { + mouseH4 = graphWindowAttrib.height/4; + if (((XButtonEvent *)event)->y > + (graphWindowAttrib.height - mouseH4)) + someInt = 2; + else if (((XButtonEvent *)event)->x < mouseW4) + someInt = 3; + else if (((XButtonEvent *)event)->y < mouseH4) + someInt = 4; + else someInt = 0; + } + if (viewport->haveControl) { + XUnmapWindow(dsply,control->controlWindow); + } + putControlPanelSomewhere(someInt); + XMapWindow(dsply,control->controlWindow); + XSync(dsply,False); + break; + } /* switch on mouse button */ + } else if (whichWindow == control->colormapWindow) { + + /* mouse clicked on colormap */ + + followMouse = yes; + gotToggle = no; + checkButton = yes; + firstTime = yes; + } else if (whichWindow != control->controlWindow) { + + /* mouse clicked on control window (not colormap) */ + + if (controlButton->self != whichWindow) { + buttonTablePtr = *((int *)XLookUpAssoc(dsply,table,whichWindow)); + controlButton = &(control->buttonQueue[buttonTablePtr]); + } + + if (controlButton->pot) { + /* figure out [x,y] for this button in the range [-1..1,-1..1] */ + mouseXY = getPotValue(((XButtonEvent *)event)->x, + ((XButtonEvent *)event)->y, + controlButton->xHalf, + controlButton->yHalf); + followMouse = yes; + gotToggle = no; + } else { + followMouse = no; + gotToggle = yes; /* auto-repeat on toggle buttons not allowed */ + if (toggleReady) { + toggleReady = no; + } + } + checkButton = yes; + firstTime = yes; + } + break; + + } /* switch */ + gotEvent--; + } /* if gotEvent */ + + + /* Allow repeat polling when mouse button clicked on a potentiometer. */ + + if (followMouse && !firstTime && (followMouse++ > mouseWait)) { + followMouse = yes; /* reset for next timing loop */ + checkButton = yes; + } + if (checkButton) { + if (viewport->closing && (controlButton->buttonKey == closeAll2D)) { + goodbye(-1); + } else { + clearControlMessage(); + viewport->closing = no; + drawControlPushButton(0, closeAll2D); + if ((doit) && + ((controlButton->buttonKey < graphStart) && + (controlButton->buttonKey > (graphSelectStart + maxGraphs)))) + doit = 0; + + switch(controlButton->buttonKey) { + + case translate2D: + for (i=0; i<maxGraphs; i++) { + if (graphStateArray[i].showing && graphStateArray[i].selected) { + if (transXON) { + graphStateArray[i].centerX -= mouseXY.x * 0.1; + if (graphStateArray[i].centerX > maxDelta) + graphStateArray[i].centerX = maxDelta; + else if (graphStateArray[i].centerX < -maxDelta) + graphStateArray[i].centerX = maxDelta; + } + if (transYON) { + graphStateArray[i].centerY -= mouseXY.y * 0.1; + if (graphStateArray[i].centerY > maxDelta) + graphStateArray[i].centerY = maxDelta; + else if (graphStateArray[i].centerY < -maxDelta) + graphStateArray[i].centerY = maxDelta; + } + } /* graph showing or selected */ + } /* for graphs */ + drawViewport(Xoption); + break; + + case scale2D: + for (i=0; i<maxGraphs; i++) { + if (graphStateArray[i].showing && graphStateArray[i].selected) { + if (zoomXON) { + graphStateArray[i].scaleX *= (1 - mouseXY.y * 0.3); + if (graphStateArray[i].scaleX > maxScale) + graphStateArray[i].scaleX = maxScale; + else if (graphStateArray[i].scaleX < minScale) + graphStateArray[i].scaleX = minScale; + } + if (zoomYON) { + graphStateArray[i].scaleY *= (1 - mouseXY.y * 0.3); + if (graphStateArray[i].scaleY > maxScale) + graphStateArray[i].scaleY = maxScale; + else if (graphStateArray[i].scaleY < minScale) + graphStateArray[i].scaleY = minScale; + } + } /* graph showing or selected */ + } /* for graphs */ + drawViewport(Xoption); + break; + + default: + buttonAction(controlButton->buttonKey); + } /* switch on buttonKey */ + } /* else - not closing */ + } /* if checkButton */ + } /* if FD_ISSET(Xcon.... */ + else if FD_ISSET(0,&rd) { + externalControl=spadAction(); /* returns (-1) if broken ,0 if success */ + if (spadDraw && (externalControl==0)) drawViewport(Xoption); + } + } /* while */ +} /* processEvents() */ + + + + + + +void +#ifdef _NO_PROTO +clickedOnGraph (i,bKey) + int i,bKey; +#else +clickedOnGraph (int i,int bKey) +#endif +{ + + switch (doit) { + case pick2D: + currentGraph = queriedGraph = i; + doPick(i,bKey); + break; + case drop2D: + currentGraph = queriedGraph = i; + doDrop(i,bKey); + break; + case query2D: + queriedGraph = i; + makeMessageFromData(queriedGraph); + writeControlMessage(); + /* reset indicator so that we're not in pick/drop/query mode anymore */ + doit = 0; + break; + default: + graphStateArray[i].showing = !(graphStateArray[i].showing); + if (mono) { + if (graphStateArray[i].showing) { + GSetForeground(graphGC,(float)backgroundColor,Xoption); + GSetBackground(graphGC,(float)foregroundColor,Xoption); + } else { + GSetForeground(graphGC,(float)foregroundColor,Xoption); + GSetBackground(graphGC,(float)backgroundColor,Xoption); + } + GDrawImageString(graphGC, + control->controlWindow, + (control->buttonQueue[bKey]).buttonX + + centerX(graphGC,(control->buttonQueue[bKey]).text,1, + (control->buttonQueue[bKey]).buttonWidth), + (control->buttonQueue[bKey]).buttonY + + centerY(graphGC,(control->buttonQueue[bKey]).buttonHeight), + (control->buttonQueue[bKey]).text, + 1, + Xoption); + } else { + if (graphStateArray[i].showing) + GSetForeground(graphGC,(float)graphBarShowingColor,Xoption); + else + GSetForeground(graphGC,(float)graphBarHiddenColor,Xoption); + GDrawString(graphGC, + control->controlWindow, + (control->buttonQueue[bKey]).buttonX + + centerX(graphGC,(control->buttonQueue[bKey]).text,1, + (control->buttonQueue[bKey]).buttonWidth), + (control->buttonQueue[bKey]).buttonY + + centerY(graphGC,(control->buttonQueue[bKey]).buttonHeight), + (control->buttonQueue[bKey]).text,1,Xoption); + } + drawViewport(Xoption); + break; + } /* switch doit */ + +} + + + + + + + + + diff --git a/src/graph/view2D/process2d.c.pamphlet b/src/graph/view2D/process2d.c.pamphlet deleted file mode 100644 index 11c1c34b..00000000 --- a/src/graph/view2D/process2d.c.pamphlet +++ /dev/null @@ -1,958 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D process2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _PROCESS2D_C -#include "axiom-c-macros.h" - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/time.h> -#ifdef RIOSplatform -#include <sys/select.h> -#endif - -#include "header2.h" - -#include "all_2d.H1" -#include "util.H1" -#include "Gfun.H1" -#include "XSpadFill.H1" - - -static int doit=0; /* globish variable for picking/dropping/clearing - all sorts of - 2 button sequence events (command & graph #). */ - - -void -#ifdef _NO_PROTO -doPick (i,bKey) - int i,bKey; -#else -doPick (int i,int bKey) -#endif -{ - int vCommand=pick2D; - - picking = no; - /* reset indicator so that we're not in pick/drop/query mode anymore */ - doit = 0; - if (graphArray[currentGraph].key) { - check(write(Socket,&vCommand,intSize)); - check(write(Socket,&(graphArray[currentGraph].key),intSize)); - check(write(Socket,&(graphStateArray[currentGraph]), - sizeof(graphStateStruct))); - sprintf(control->message,"%s%d","Picked up graph ",currentGraph+1); - } else - sprintf(control->message,"%s","This graph is empty!"); - writeControlMessage(); - - -} - - -void -#ifdef _NO_PROTO -doDrop (i,bKey) - int i,bKey; -#else -doDrop (int i,int bKey) -#endif -{ - int vCommand=drop2D; - int viewGoAhead; - - dropping = no; - /* reset indicator so that we're not in pick/drop/query mode anymore */ - doit = 0; - check(write(Socket,&(vCommand),intSize)); - readViewman(&viewGoAhead,intSize); - if (viewGoAhead < 0) { - sprintf(control->message,"%s%d","Couldn't drop to graph ",currentGraph+1); - writeControlMessage(); - } else { - sprintf(control->message,"%s%d","Dropped onto graph ",currentGraph+1); - writeControlMessage(); - freeGraph(currentGraph); - readViewman(&(graphArray[currentGraph].key),intSize); - getGraphFromViewman(currentGraph); - /* simulate a button press to turn display number on and select on */ - /* need !yes since it will be inverted */ - graphStateArray[currentGraph].selected = no; - graphStateArray[currentGraph].showing = - !(graphStateArray[currentGraph].showing); - clickedOnGraph(currentGraph,currentGraph+graphStart); - clickedOnGraphSelect(currentGraph,currentGraph+graphSelectStart); - } -} - -void -#ifdef _NO_PROTO -clickedOnGraphSelect (i,bKey) - int i,bKey; -#else -clickedOnGraphSelect (int i,int bKey) -#endif -{ - int strlength; - - switch (doit) { - case pick2D: - currentGraph = i; - doPick(i,bKey); - break; - case drop2D: - currentGraph = i; - doDrop(i,bKey); - break; - case query2D: - queriedGraph = i; - makeMessageFromData(queriedGraph); - writeControlMessage(); - /* reset indicator so that we're not in pick/drop/query mode anymore */ - doit = 0; - break; - default: - graphStateArray[i].selected = !(graphStateArray[i].selected); - if (graphStateArray[i].selected) { - GSetForeground(graphGC,(float)graphBarSelectColor,Xoption); - strcpy(control->buttonQueue[bKey].text,"^"); - strlength = strlen(control->buttonQueue[bKey].text); - } else { - GSetForeground(graphGC,(float)graphBarNotSelectColor,Xoption); - strcpy(control->buttonQueue[bKey].text,"-"); - strlength = strlen(control->buttonQueue[bKey].text); - } - /* just to make sure the background is reset from clickedOnGraph */ - if (mono) { - GSetForeground(graphGC,(float)foregroundColor,Xoption); - GSetBackground(graphGC,(float)backgroundColor,Xoption); - } - - GDrawImageString(graphGC,control->controlWindow, - control->buttonQueue[bKey].buttonX + - centerX(graphGC, - control->buttonQueue[bKey].text,strlength, - control->buttonQueue[bKey].buttonWidth), - control->buttonQueue[bKey].buttonY + - centerY(graphGC, - control->buttonQueue[bKey].buttonHeight), - control->buttonQueue[bKey].text,strlength,Xoption); - GSetForeground(trashGC,(float)foregroundColor,Xoption); - GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption); - GDrawLine(trashGC,control->controlWindow,0,286,controlWidth,286,Xoption); - break; - } /* switch doit */ - -} - - -static void -#ifndef _NO_PROTO -drawControlPushButton(int isOn, int index) -#else - drawControlPushButton(isOn,index) - int isOn; - int index; -#endif -{ - GDrawPushButton(dsply, processGC, processGC, processGC, - control->controlWindow, - (control->buttonQueue[index]).buttonX, - (control->buttonQueue[index]).buttonY, - (control->buttonQueue[index]).buttonWidth, - (control->buttonQueue[index]).buttonHeight, - isOn, - (control->buttonQueue[index]).text, - buttonColor, - monoColor((control->buttonQueue[index]).textColor), Xoption); - XSync(dsply,False); -} - - - -void -#ifdef _NO_PROTO -buttonAction (bKey) - int bKey; -#else -buttonAction (int bKey) -#endif -{ - int i; - - switch (bKey) { - - case pick2D: - if (viewAloned) { - sprintf(control->message,"%s","Cannot pick without AXIOM!"); - writeControlMessage(); - XSync(dsply,False); - } - else { - doit = pick2D; - sprintf(control->message,"%s","Click on the graph to pick"); - writeControlMessage(); - XSync(dsply,False); - } - break; - - case drop2D: - if (viewAloned) { - sprintf(control->message,"%s","Cannot drop without AXIOM!"); - writeControlMessage(); - XSync(dsply,False); - } else { - doit = drop2D; - sprintf(control->message,"%s","Click on the graph to drop"); - writeControlMessage(); - XSync(dsply,False); - } - break; - - case query2D: - doit = query2D; - sprintf(control->message,"%s","Click on the graph to query"); - writeControlMessage(); - XSync(dsply,False); - break; - - - case zoom2Dx: - if (zoomXON) - strcpy((control->buttonQueue[zoom2Dx]).text , - "X Off"); - else - strcpy((control->buttonQueue[zoom2Dx]).text , - "X On "); - zoomXON = !zoomXON; - - drawControlPushButton(zoomXON, zoom2Dx); - XSync(dsply,False); - break; - - case zoom2Dy: - if (zoomYON) strcpy((control->buttonQueue[zoom2Dy]).text, - "Y Off"); - else strcpy((control->buttonQueue[zoom2Dy]).text , - "Y On "); - zoomYON = !zoomYON; - drawControlPushButton(zoomYON, zoom2Dy); - XSync(dsply,False); - break; - - - case translate2Dx: - if (transXON) strcpy((control->buttonQueue[translate2Dx]).text, - "X Off"); - else strcpy( (control->buttonQueue[translate2Dx]).text, - "X On "); - transXON = !transXON; - drawControlPushButton(transXON, translate2Dx); - XSync(dsply,False); - break; - - case translate2Dy: - if (transYON) strcpy((control->buttonQueue[translate2Dy]).text, - "Y Off"); - else strcpy( (control->buttonQueue[translate2Dy]).text, - "Y On"); - transYON = !transYON; - drawControlPushButton(transYON, translate2Dy); - XSync(dsply,False); - break; - - case pointsOnOff: - if (pointsON) strcpy((control->buttonQueue[pointsOnOff]).text, - "Pts Off"); - else strcpy( (control->buttonQueue[pointsOnOff]).text, - "Pts On "); - pointsON = !pointsON; - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i].pointsOn = pointsON; - - drawControlPushButton(pointsON, pointsOnOff); - drawViewport(Xoption); - break; - - case connectOnOff: - if (connectON) strcpy((control->buttonQueue[connectOnOff]).text, - "Lines Off"); - else strcpy( (control->buttonQueue[connectOnOff]).text, - "Lines On "); - connectON = !connectON; - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i].connectOn = connectON; - - drawControlPushButton(connectON, connectOnOff); - drawViewport(Xoption); - break; - - case spline2D: - if (splineON) strcpy((control->buttonQueue[spline2D]).text, - "Box Off"); - else strcpy ((control->buttonQueue[spline2D]).text , - "Box On "); - splineON = !splineON; - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i].splineOn = splineON; - - drawControlPushButton(splineON, spline2D); - drawViewport(Xoption); - break; - - case axesOnOff2D: - if (axesON) - strcpy ((control->buttonQueue[axesOnOff2D]).text, - "Axes Off"); - else - strcpy ((control->buttonQueue[axesOnOff2D]).text , - "Axes On "); - axesON = !axesON; - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i].axesOn = axesON; - - drawControlPushButton(axesON, axesOnOff2D); - drawViewport(Xoption); - break; - - case unitsOnOff2D: - if (unitsON) - strcpy( (control->buttonQueue[unitsOnOff2D]).text, - "Units Off"); - else - strcpy ((control->buttonQueue[unitsOnOff2D]).text, - "Units On "); - unitsON = !unitsON; - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i].unitsOn = unitsON; - - drawControlPushButton(unitsON, unitsOnOff2D); - drawViewport(Xoption); - break; - - case ps2D: - strcpy(control->message,"Creating postscript now ..."); - writeControlMessage(); - drawControlPushButton(1, ps2D); - - if (PSInit(viewport->viewWindow, viewport->titleWindow) == psError) { - strcpy(control->message,"Aborted: PSInit error."); - writeControlMessage(); - drawControlPushButton(0, ps2D); - XSync(dsply,False); - return; /* make new temp name for new file */ - } - - drawViewport(PSoption); /* draw picture in PS; create ps script file */ - - if (PSCreateFile(viewBorderWidth, - viewport->viewWindow, - viewport->titleWindow, - viewport->title) == psError) { - strcpy(control->message,"Aborted: PSCreateFile error."); - writeControlMessage(); - drawControlPushButton(0, ps2D); - XSync(dsply,False); - return; - } - - clearControlMessage(); - strcpy(control->message,PSfilename); - strcat(control->message," in working dir "); - writeControlMessage(); - drawControlPushButton(0, ps2D); - XSync(dsply,False); - break; - - case hideControl2D: - if (viewport->haveControl) { - viewport->haveControl = no; - XUnmapWindow(dsply,control->controlWindow); - XSync(dsply,False); - } - break; - - case reset2D: - /* reset view */ - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i] = graphStateBackupArray[i]; - - unitsON = no; - strcpy( (control->buttonQueue[unitsOnOff2D]).text,s = "Units Off"); - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i].unitsOn = no; - drawControlPushButton(unitsON, unitsOnOff2D); - - pointsON = yes; - strcpy ((control->buttonQueue[pointsOnOff]).text ,"Pts On "); - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i].pointsOn = yes; - drawControlPushButton(pointsON, pointsOnOff); - - axesON = yes; - strcpy ((control->buttonQueue[axesOnOff2D]).text,"Axes On "); - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i].axesOn = yes; - drawControlPushButton(axesON, axesOnOff2D); - - connectON = yes; - strcpy((control->buttonQueue[connectOnOff]).text,"Lines On "); - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i].connectOn = yes; - drawControlPushButton(connectON, connectOnOff); - - splineON = no; - strcpy( (control->buttonQueue[connectOnOff]).text ,"Box Off"); - for (i=0; i<maxGraphs; i++) - if (graphStateArray[i].showing && graphStateArray[i].selected) - graphStateArray[i].splineOn = splineON; - drawControlPushButton(splineON, spline2D); - drawViewport(Xoption); - - break; - - case closeAll2D: - strcpy(control->message," Click again to confirm "); - writeControlMessage(); - drawControlPushButton(1, closeAll2D); - XSync(dsply,False); - viewport->closing = yes; - break; - - case clear2D: - for (i=0; i<maxGraphs; i++) graphStateArray[i].selected = 1; - clickedOnGraphSelect(0,graphSelect1); - clickedOnGraphSelect(1,graphSelect2); - clickedOnGraphSelect(2,graphSelect3); - clickedOnGraphSelect(3,graphSelect4); - clickedOnGraphSelect(4,graphSelect5); - clickedOnGraphSelect(5,graphSelect6); - clickedOnGraphSelect(6,graphSelect7); - clickedOnGraphSelect(7,graphSelect8); - clickedOnGraphSelect(8,graphSelect9); - XSync(dsply,False); - break; - - case graph1: - case graph2: - case graph3: - case graph4: - case graph5: - case graph6: - case graph7: - case graph8: - case graph9: - clickedOnGraph(bKey-graphStart,bKey); - XSync(dsply,False); - break; - - case graphSelect1: - case graphSelect2: - case graphSelect3: - case graphSelect4: - case graphSelect5: - case graphSelect6: - case graphSelect7: - case graphSelect8: - case graphSelect9: - clickedOnGraphSelect(bKey-graphSelectStart,bKey); - XSync(dsply,False); - break; - - } /* switch (action) */ -} - -/*********************** X Event Processing ***************************/ -void -#ifdef _NO_PROTO -processEvents() -#else -processEvents(void) -#endif -{ - - XEvent *event, - tempEvent; - Window whichWindow; - XWindowAttributes graphWindowAttrib; - buttonStruct *controlButton; - mouseCoord mouseXY; - int i, - someInt, - mouseW4, - mouseH4, - toggleReady, - gotToggle = no, - checkButton = no, - firstTime = yes, - gotEvent = 0, - buttonTablePtr, - Xcon, - len, - externalControl; - fd_set rd; - - - externalControl=0; - Xcon = ConnectionNumber(dsply); - - - if (!(event = (XEvent *)malloc(sizeof(XEvent)))) { - fprintf(stderr,"Ran out of memory initializing event processing.\n"); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - - controlButton = control->buttonQueue; - - while(1) { - - len=0; - while(len<=0) { - FD_ZERO(&rd); - if (externalControl==0) FD_SET(0, &rd); - FD_SET(Xcon,&rd); - - if (XEventsQueued(dsply, QueuedAlready)) { - len=1; - break; - } - if (!followMouse) - len=select(FD_SETSIZE,(void *) &rd,0,0,0); - else - len=1; - } - if (FD_ISSET(Xcon,&rd)|| - XEventsQueued(dsply, QueuedAfterFlush) || - followMouse) { - - if (followMouse) { - if (XPending(dsply)) - XNextEvent(dsply,event); - gotEvent++; - } else { - XNextEvent(dsply,event); - gotEvent++; - } - - if (gotToggle || !followMouse) - checkButton = no; - - if (gotEvent) { - whichWindow = ((XButtonEvent *)event)->window; - firstTime = no; - - switch(((XEvent *)event)->type) { - - case ClientMessage: - if (event->xclient.data.l[0] == wm_delete_window) { - goodbye(-1); - } - else { - fprintf(stderr,"Unknown Client Message ...\n"); - } - break; - case Expose: - if (whichWindow == viewport->titleWindow) { - /* get rid of redundant events */ - XCheckWindowEvent(dsply, - viewport->titleWindow, - ExposureMask, - &tempEvent); - writeTitle(); - XGetWindowAttributes(dsply, - whichWindow, - &graphWindowAttrib); - XResizeWindow(dsply, - viewport->viewWindow, - graphWindowAttrib.width, - graphWindowAttrib.height-titleHeight); - XSync(dsply,False); - break; - } else if (whichWindow == viewport->viewWindow) { - XCheckWindowEvent(dsply, - viewport->viewWindow, - ExposureMask, - &tempEvent); - XGetWindowAttributes(dsply, - viewport->titleWindow, - &graphWindowAttrib); - XResizeWindow(dsply, - viewport->viewWindow, - graphWindowAttrib.width, - graphWindowAttrib.height-titleHeight); - drawViewport(Xoption); - XMapWindow(dsply,whichWindow); - XSync(dsply,False); - break; - } else { /* it's gotta be the control panel */ - XGetWindowAttributes(dsply, - control->controlWindow, - &graphWindowAttrib); - /* do not allow resizing of control panel */ - if ((graphWindowAttrib.width != controlWidth) || - (graphWindowAttrib.height != controlHeight)) { - XResizeWindow(dsply, - control->controlWindow, - controlWidth, - controlHeight); - } - drawControlPanel(); - XSync(dsply,False); - break; - } - break; - - case MotionNotify: - if (followMouse) { - while (XCheckMaskEvent(dsply, - ButtonMotionMask, - event)); - mouseXY = getPotValue(((XButtonEvent *)event)->x, - ((XButtonEvent *)event)->y, - controlButton->xHalf, - controlButton->yHalf); - } - if (controlButton->pot) { - gotToggle = no; - checkButton = yes; - } - break; - - case ButtonRelease: - if (followMouse==yes) { - followMouse = no; - toggleReady = yes; - checkButton = no; - drawViewport(Xoption); - } else { - followMouse = no; - toggleReady = yes; - checkButton = no; - } - break; - - case LeaveNotify: - /* - We still follow the mouse when we leave the pots. - */ - /* - followMouse = no; - toggleReady = yes; - checkButton = no; - */ - - break; - - case ButtonPress: - if (whichWindow == viewport->viewWindow) { - - /* mouse clicked on viewport */ - - switch (((XButtonEvent *)event)->button) { - case Button3: - - /* print out (x,y) object-space coordinates in message area */ - - XGetWindowAttributes(dsply,whichWindow,&graphWindowAttrib); - sprintf(viewport->controlPanel->message, - " >%d<: [%6.2f,%6.2f] ", - queriedGraph+1, - projX((((XButtonEvent *)event)->x), - graphWindowAttrib.width,queriedGraph), - projY((((XButtonEvent *)event)->y), - graphWindowAttrib.height,queriedGraph)); - writeControlMessage(); - XFlush(dsply); - break; - default: - - /* Find where mouse is on the viewport => where to put the CP */ - - XGetWindowAttributes(dsply, - whichWindow, - &graphWindowAttrib); - mouseW4 = graphWindowAttrib.width/4; - if (((XButtonEvent *)event)->x > - (graphWindowAttrib.width - mouseW4)) - someInt = 1; - else { - mouseH4 = graphWindowAttrib.height/4; - if (((XButtonEvent *)event)->y > - (graphWindowAttrib.height - mouseH4)) - someInt = 2; - else if (((XButtonEvent *)event)->x < mouseW4) - someInt = 3; - else if (((XButtonEvent *)event)->y < mouseH4) - someInt = 4; - else someInt = 0; - } - if (viewport->haveControl) { - XUnmapWindow(dsply,control->controlWindow); - } - putControlPanelSomewhere(someInt); - XMapWindow(dsply,control->controlWindow); - XSync(dsply,False); - break; - } /* switch on mouse button */ - } else if (whichWindow == control->colormapWindow) { - - /* mouse clicked on colormap */ - - followMouse = yes; - gotToggle = no; - checkButton = yes; - firstTime = yes; - } else if (whichWindow != control->controlWindow) { - - /* mouse clicked on control window (not colormap) */ - - if (controlButton->self != whichWindow) { - buttonTablePtr = *((int *)XLookUpAssoc(dsply,table,whichWindow)); - controlButton = &(control->buttonQueue[buttonTablePtr]); - } - - if (controlButton->pot) { - /* figure out [x,y] for this button in the range [-1..1,-1..1] */ - mouseXY = getPotValue(((XButtonEvent *)event)->x, - ((XButtonEvent *)event)->y, - controlButton->xHalf, - controlButton->yHalf); - followMouse = yes; - gotToggle = no; - } else { - followMouse = no; - gotToggle = yes; /* auto-repeat on toggle buttons not allowed */ - if (toggleReady) { - toggleReady = no; - } - } - checkButton = yes; - firstTime = yes; - } - break; - - } /* switch */ - gotEvent--; - } /* if gotEvent */ - - - /* Allow repeat polling when mouse button clicked on a potentiometer. */ - - if (followMouse && !firstTime && (followMouse++ > mouseWait)) { - followMouse = yes; /* reset for next timing loop */ - checkButton = yes; - } - if (checkButton) { - if (viewport->closing && (controlButton->buttonKey == closeAll2D)) { - goodbye(-1); - } else { - clearControlMessage(); - viewport->closing = no; - drawControlPushButton(0, closeAll2D); - if ((doit) && - ((controlButton->buttonKey < graphStart) && - (controlButton->buttonKey > (graphSelectStart + maxGraphs)))) - doit = 0; - - switch(controlButton->buttonKey) { - - case translate2D: - for (i=0; i<maxGraphs; i++) { - if (graphStateArray[i].showing && graphStateArray[i].selected) { - if (transXON) { - graphStateArray[i].centerX -= mouseXY.x * 0.1; - if (graphStateArray[i].centerX > maxDelta) - graphStateArray[i].centerX = maxDelta; - else if (graphStateArray[i].centerX < -maxDelta) - graphStateArray[i].centerX = maxDelta; - } - if (transYON) { - graphStateArray[i].centerY -= mouseXY.y * 0.1; - if (graphStateArray[i].centerY > maxDelta) - graphStateArray[i].centerY = maxDelta; - else if (graphStateArray[i].centerY < -maxDelta) - graphStateArray[i].centerY = maxDelta; - } - } /* graph showing or selected */ - } /* for graphs */ - drawViewport(Xoption); - break; - - case scale2D: - for (i=0; i<maxGraphs; i++) { - if (graphStateArray[i].showing && graphStateArray[i].selected) { - if (zoomXON) { - graphStateArray[i].scaleX *= (1 - mouseXY.y * 0.3); - if (graphStateArray[i].scaleX > maxScale) - graphStateArray[i].scaleX = maxScale; - else if (graphStateArray[i].scaleX < minScale) - graphStateArray[i].scaleX = minScale; - } - if (zoomYON) { - graphStateArray[i].scaleY *= (1 - mouseXY.y * 0.3); - if (graphStateArray[i].scaleY > maxScale) - graphStateArray[i].scaleY = maxScale; - else if (graphStateArray[i].scaleY < minScale) - graphStateArray[i].scaleY = minScale; - } - } /* graph showing or selected */ - } /* for graphs */ - drawViewport(Xoption); - break; - - default: - buttonAction(controlButton->buttonKey); - } /* switch on buttonKey */ - } /* else - not closing */ - } /* if checkButton */ - } /* if FD_ISSET(Xcon.... */ - else if FD_ISSET(0,&rd) { - externalControl=spadAction(); /* returns (-1) if broken ,0 if success */ - if (spadDraw && (externalControl==0)) drawViewport(Xoption); - } - } /* while */ -} /* processEvents() */ - - - - - - -void -#ifdef _NO_PROTO -clickedOnGraph (i,bKey) - int i,bKey; -#else -clickedOnGraph (int i,int bKey) -#endif -{ - - switch (doit) { - case pick2D: - currentGraph = queriedGraph = i; - doPick(i,bKey); - break; - case drop2D: - currentGraph = queriedGraph = i; - doDrop(i,bKey); - break; - case query2D: - queriedGraph = i; - makeMessageFromData(queriedGraph); - writeControlMessage(); - /* reset indicator so that we're not in pick/drop/query mode anymore */ - doit = 0; - break; - default: - graphStateArray[i].showing = !(graphStateArray[i].showing); - if (mono) { - if (graphStateArray[i].showing) { - GSetForeground(graphGC,(float)backgroundColor,Xoption); - GSetBackground(graphGC,(float)foregroundColor,Xoption); - } else { - GSetForeground(graphGC,(float)foregroundColor,Xoption); - GSetBackground(graphGC,(float)backgroundColor,Xoption); - } - GDrawImageString(graphGC, - control->controlWindow, - (control->buttonQueue[bKey]).buttonX + - centerX(graphGC,(control->buttonQueue[bKey]).text,1, - (control->buttonQueue[bKey]).buttonWidth), - (control->buttonQueue[bKey]).buttonY + - centerY(graphGC,(control->buttonQueue[bKey]).buttonHeight), - (control->buttonQueue[bKey]).text, - 1, - Xoption); - } else { - if (graphStateArray[i].showing) - GSetForeground(graphGC,(float)graphBarShowingColor,Xoption); - else - GSetForeground(graphGC,(float)graphBarHiddenColor,Xoption); - GDrawString(graphGC, - control->controlWindow, - (control->buttonQueue[bKey]).buttonX + - centerX(graphGC,(control->buttonQueue[bKey]).text,1, - (control->buttonQueue[bKey]).buttonWidth), - (control->buttonQueue[bKey]).buttonY + - centerY(graphGC,(control->buttonQueue[bKey]).buttonHeight), - (control->buttonQueue[bKey]).text,1,Xoption); - } - drawViewport(Xoption); - break; - } /* switch doit */ - -} - - - - - - - - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/spadAction2d.c.pamphlet b/src/graph/view2D/spadAction2d.c index 69ed10bb..900d4358 100644 --- a/src/graph/view2D/spadAction2d.c.pamphlet +++ b/src/graph/view2D/spadAction2d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D spadAction2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _SPADACTION2D_C #include "axiom-c-macros.h" @@ -76,7 +62,7 @@ readViewman(void * info,int size) int mold = 0; sprintf(errorStr,"%s %d %s","read of ",size, - " bytes from viewport manager\n"); + " bytes from viewport manager\n"); mold = check(read(0,info,size)); return(mold); @@ -273,8 +259,8 @@ spadAction(void) break; case putGraph: - readViewman(&i1,intSize); /* key of graph to get */ - readViewman(&i2,intSize); /* slot to drop graph onto 0..8*/ + 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); @@ -311,9 +297,3 @@ spadAction(void) } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/stuff2d.c b/src/graph/view2D/stuff2d.c new file mode 100644 index 00000000..1d5d75a5 --- /dev/null +++ b/src/graph/view2D/stuff2d.c @@ -0,0 +1,125 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _STUFF2D_C +#include "axiom-c-macros.h" + +#include <unistd.h> +#include <stdlib.h> + +#include "header2.h" + +#include "all_2d.H1" +#include "Gfun.H1" +#include "util.H1" + + +/**************************/ +/*** float absolute(x) ***/ +/**************************/ + +float +#ifdef _NO_PROTO +absolute(x) + float x; +#else +absolute(float x) +#endif +{ + if (x<0.0) { + return(-x); + } else { + return(x); + } +} + + + +/************************/ +/*** void goodbye() ***/ +/************************/ + +void +#ifdef _NO_PROTO +goodbye(sig) +int sig; +#else +goodbye(int sig) +#endif +{ + int Command,i; + +#ifdef DEBUG + fprintf(stderr,"view2D: Tidying up and exiting\n"); +#endif + PSClose(); /* free PS file and data structure space */ + + XFreeGC(dsply,globalGC1); + XFreeGC(dsply,globalGC2); + XFreeGC(dsply,globGC); + XFreeGC(dsply,trashGC); + XFreeGC(dsply,anotherGC); + XFreeGC(dsply,controlMessageGC); + XFreeGC(dsply,graphGC); + XFreeGC(dsply,unitGC); + + XFreeFont(dsply,globalFont); + XFreeFont(dsply,buttonFont); + XFreeFont(dsply,headerFont); + XFreeFont(dsply,titleFont); + XFreeFont(dsply,graphFont); + XFreeFont(dsply,unitFont); + + XFreeColormap(dsply,colorMap); + + /** send off the current graphs to viewport manager **/ + + Command = viewportClosing; + check(write(Socket,&Command,intSize)); + + for (i=0; i<maxGraphs;i++) { + check(write(Socket,&graphArray[i].key,intSize)); + } + close(Socket); + XCloseDisplay(dsply); + exit(0); + +} + + + + + + diff --git a/src/graph/view2D/stuff2d.c.pamphlet b/src/graph/view2D/stuff2d.c.pamphlet deleted file mode 100644 index d4e3d4ed..00000000 --- a/src/graph/view2D/stuff2d.c.pamphlet +++ /dev/null @@ -1,145 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D stuff2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _STUFF2D_C -#include "axiom-c-macros.h" - -#include <unistd.h> -#include <stdlib.h> - -#include "header2.h" - -#include "all_2d.H1" -#include "Gfun.H1" -#include "util.H1" - - -/**************************/ -/*** float absolute(x) ***/ -/**************************/ - -float -#ifdef _NO_PROTO -absolute(x) - float x; -#else -absolute(float x) -#endif -{ - if (x<0.0) { - return(-x); - } else { - return(x); - } -} - - - -/************************/ -/*** void goodbye() ***/ -/************************/ - -void -#ifdef _NO_PROTO -goodbye(sig) -int sig; -#else -goodbye(int sig) -#endif -{ - int Command,i; - -#ifdef DEBUG - fprintf(stderr,"view2D: Tidying up and exiting\n"); -#endif - PSClose(); /* free PS file and data structure space */ - - XFreeGC(dsply,globalGC1); - XFreeGC(dsply,globalGC2); - XFreeGC(dsply,globGC); - XFreeGC(dsply,trashGC); - XFreeGC(dsply,anotherGC); - XFreeGC(dsply,controlMessageGC); - XFreeGC(dsply,graphGC); - XFreeGC(dsply,unitGC); - - XFreeFont(dsply,globalFont); - XFreeFont(dsply,buttonFont); - XFreeFont(dsply,headerFont); - XFreeFont(dsply,titleFont); - XFreeFont(dsply,graphFont); - XFreeFont(dsply,unitFont); - - XFreeColormap(dsply,colorMap); - - /** send off the current graphs to viewport manager **/ - - Command = viewportClosing; - check(write(Socket,&Command,intSize)); - - for (i=0; i<maxGraphs;i++) { - check(write(Socket,&graphArray[i].key,intSize)); - } - close(Socket); - XCloseDisplay(dsply); - exit(0); - -} - - - - - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/viewport2D.c.pamphlet b/src/graph/view2D/viewport2D.c index c1632984..a0a06aa9 100644 --- a/src/graph/view2D/viewport2D.c.pamphlet +++ b/src/graph/view2D/viewport2D.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D viewport2D} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _VIEWPORT2D_C #include "axiom-c-macros.h" @@ -60,8 +46,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <X11/Xutil.h> #include <limits.h> -#define NotPoint (SHRT_MAX) -#define eqNANQ(x) (x == NotPoint) +#define NotPoint (SHRT_MAX) +#define eqNANQ(x) (x == NotPoint) #include "header2.h" @@ -159,33 +145,33 @@ drawTheViewport(int dFlag) graphArray[i].yNorm = 1.0/((graphArray[i].ymax-graphArray[i].ymin) * aspectR); graphArray[i].originY = -graphArray[i].ymin*graphArray[i].yNorm - - 0.5/aspectR; + - 0.5/aspectR; graphArray[i].unitY = graphArray[i].spadUnitY*graphArray[i].yNorm; xAxis = rint(vwInfo.width * - ((graphArray[0].originX - graphStateArray[0].centerX) * - graphStateArray[0].scaleX + 0.5)); + ((graphArray[0].originX - graphStateArray[0].centerX) * + graphStateArray[0].scaleX + 0.5)); yAxis= rint(vwInfo.height * aspectR * - (1 - ((graphArray[0].originY*aspectR - - graphStateArray[0].centerY) * - graphStateArray[0].scaleY + 0.5*aspectR ))); + (1 - ((graphArray[0].originY*aspectR - + graphStateArray[0].centerY) * + graphStateArray[0].scaleY + 0.5*aspectR ))); if (graphStateArray[i].axesOn) { if (dFlag==Xoption) /* do only for X, ps uses default of black */ GSetForeground(globalGC1, - (float)monoColor(graphStateArray[i].axesColor), - dFlag); - - if ((yAxis >=0) && (yAxis <= vwInfo.height)) + (float)monoColor(graphStateArray[i].axesColor), + dFlag); + + if ((yAxis >=0) && (yAxis <= vwInfo.height)) GDrawLine(globalGC1,vw, - 0,yAxis, - vwInfo.width,yAxis, - dFlag); - if ((xAxis >=0) && (xAxis <= vwInfo.width)) - GDrawLine(globalGC1,vw, - xAxis,0, - xAxis,vwInfo.height, - dFlag); + 0,yAxis, + vwInfo.width,yAxis, + dFlag); + if ((xAxis >=0) && (xAxis <= vwInfo.width)) + GDrawLine(globalGC1,vw, + xAxis,0, + xAxis,vwInfo.height, + dFlag); } @@ -209,48 +195,48 @@ drawTheViewport(int dFlag) if (isNaN(aPoint->x)) { anXPoint->x = anX10Point->x = NotPoint; } - else { + else { diffX = graphArray[i].xmax-graphArray[i].xmin; anXPoint->x = anX10Point->x = vwInfo.width * ((aPoint->x * diffX/(graphArray[0].xmax-graphArray[0].xmin) - + (graphArray[0].originX - graphArray[i].originX*diffX / - (graphArray[0].xmax-graphArray[0].xmin)) - - graphStateArray[0].centerX)*graphStateArray[i].scaleX+0.5); + + (graphArray[0].originX - graphArray[i].originX*diffX / + (graphArray[0].xmax-graphArray[0].xmin)) + - graphStateArray[0].centerX)*graphStateArray[i].scaleX+0.5); } if (isNaN(aPoint->y)) { anXPoint->y = anX10Point->y = NotPoint; - } + } else { diffY = graphArray[i].ymax-graphArray[i].ymin; anXPoint->y = anX10Point->y = vwInfo.height * aspectR * - (1 - ((aPoint->y * diffY/(graphArray[0].ymax-graphArray[0].ymin) - + (graphArray[0].originY - graphArray[i].originY* diffY/ - (graphArray[0].ymax-graphArray[0].ymin))*aspectR - - graphStateArray[0].centerY) * - graphStateArray[i].scaleY + 0.5*aspectR)); + (1 - ((aPoint->y * diffY/(graphArray[0].ymax-graphArray[0].ymin) + + (graphArray[0].originY - graphArray[i].originY* diffY/ + (graphArray[0].ymax-graphArray[0].ymin))*aspectR + - graphStateArray[0].centerY) * + graphStateArray[i].scaleY + 0.5*aspectR)); } } else { if (isNaN(aPoint->x)) { anXPoint->x = anX10Point->x = NotPoint; } - else { + else { anXPoint->x = anX10Point->x = vwInfo.width * ((aPoint->x - graphStateArray[i].centerX) * - graphStateArray[i].scaleX + 0.5); + graphStateArray[i].scaleX + 0.5); } if (isNaN(aPoint->y)) { anXPoint->y = anX10Point->y = NotPoint; - } - else { + } + else { anXPoint->y = anX10Point->y = vwInfo.height * aspectR * (1 - ((aPoint->y - graphStateArray[i].centerY) * - graphStateArray[i].scaleY + 0.5*aspectR)); + graphStateArray[i].scaleY + 0.5*aspectR)); } } /* first or last point */ if (k == 0 || k == (aList->numberOfPoints - 1)) { - anX10Point->flags = 0; + anX10Point->flags = 0; } else { anX10Point->flags = VertexCurved; } @@ -260,108 +246,108 @@ drawTheViewport(int dFlag) anXarc++; } /* for aPoint in pointList */ - aPoint--; /* make it legal, the last one*/ + aPoint--; /* make it legal, the last one*/ if (graphStateArray[i].connectOn || graphStateArray[i].pointsOn) { halfSize = aList->pointSize/2; ptX = tempXpt->x; ptY = tempXpt->y; clipped = ptX > vwInfo.x && ptX < vwInfo.width && - ptY > 0 && ptY < vwInfo.height; + ptY > 0 && ptY < vwInfo.height; if (graphStateArray[i].pointsOn) { if (dFlag==Xoption) { if (mono) { GSetForeground(globalGC1, - (float)monoColor((int)(aPoint->hue)), - dFlag); + (float)monoColor((int)(aPoint->hue)), + dFlag); } else { GSetForeground(globalGC1, - (float)XSolidColor((int)(aPoint->hue), - (int)(aPoint->shade)), - dFlag); + (float)XSolidColor((int)(aPoint->hue), + (int)(aPoint->shade)), + dFlag); } } if (clipped && !eqNANQ(ptX) && !eqNANQ(ptY)) GFillArc(globalGC1,vw,ptX-halfSize, - ptY-halfSize,aList->pointSize,aList->pointSize, - 0,360*64, dFlag); + ptY-halfSize,aList->pointSize,aList->pointSize, + 0,360*64, dFlag); } /* if points on */ for (ii=0, aPoint=aList->listOfPoints; - ii<aList->numberOfPoints; - ++ii, ++tempXpt, ++aPoint) { + ii<aList->numberOfPoints; + ++ii, ++tempXpt, ++aPoint) { ptX1 = tempXpt->x; ptY1 = tempXpt->y; clipped1 = ptX1 > vwInfo.x && ptX1 < vwInfo.width && - ptY1 > 0 && ptY1 < vwInfo.height; + ptY1 > 0 && ptY1 < vwInfo.height; if (graphStateArray[i].connectOn) { if (dFlag==Xoption) { if (mono) { GSetForeground(globalGC1, - (float)monoColor((int)(aList->lineColor-1)/5), - dFlag); + (float)monoColor((int)(aList->lineColor-1)/5), + dFlag); } else { GSetForeground(globalGC1, - (float)XSolidColor((int)(aList->lineColor-1)/5, - (int)((aList->lineColor-1)%5)/2), - dFlag); + (float)XSolidColor((int)(aList->lineColor-1)/5, + (int)((aList->lineColor-1)%5)/2), + dFlag); } - } /* if X */ + } /* if X */ if ((clipped || clipped1) && !eqNANQ(ptX) && !eqNANQ(ptY) && - !eqNANQ(ptX1) && !eqNANQ(ptY1)) + !eqNANQ(ptX1) && !eqNANQ(ptY1)) GDrawLine(globalGC1,vw, - ptX,ptY,ptX1,ptY1, - dFlag); + ptX,ptY,ptX1,ptY1, + dFlag); } /* if lines on */ if (graphStateArray[i].pointsOn) { if (dFlag==Xoption) { if (mono) { GSetForeground(globalGC1, - (float)monoColor((int)(aPoint->hue)), - dFlag); + (float)monoColor((int)(aPoint->hue)), + dFlag); } else { GSetForeground(globalGC1, - (float)XSolidColor((int)(aPoint->hue), - (int)(aPoint->shade)), - dFlag); + (float)XSolidColor((int)(aPoint->hue), + (int)(aPoint->shade)), + dFlag); } } if (clipped1 && !eqNANQ(ptX1) && !eqNANQ(ptY1)) GFillArc(globalGC1,vw,ptX1-halfSize, - ptY1-halfSize,aList->pointSize,aList->pointSize, - 0,360*64, dFlag); + ptY1-halfSize,aList->pointSize,aList->pointSize, + 0,360*64, dFlag); } /* if points on */ ptX = ptX1; ptY = ptY1; clipped = clipped1; } /* for all points */ - } /* if points or lines on */ + } /* if points or lines on */ if (graphStateArray[i].splineOn) { /* need spline color as well */ if (dFlag==Xoption) /* do only for X, ps uses default of black */ - GSetForeground(globalGC1, - (float)monoColor(148), - dFlag); + GSetForeground(globalGC1, + (float)monoColor(148), + dFlag); boxX = vwInfo.width * - ((-0.5 - graphStateArray[i].centerX)* - graphStateArray[i].scaleX + 0.5); + ((-0.5 - graphStateArray[i].centerX)* + graphStateArray[i].scaleX + 0.5); boxY = vwInfo.height * aspectR * - (1 - ((0.5 - graphStateArray[i].centerY)* - graphStateArray[i].scaleY + 0.5*aspectR)); + (1 - ((0.5 - graphStateArray[i].centerY)* + graphStateArray[i].scaleY + 0.5*aspectR)); boxW = graphStateArray[i].scaleX * vwInfo.width + 1; boxH = graphStateArray[i].scaleY * vwInfo.height * aspectR + 1; GDrawRectangle(globalGC1,vw, - boxX,boxY,boxW,boxH, - dFlag); + boxX,boxY,boxW,boxH, + dFlag); } tempXpt = anXPoint; } /* for a aList in listofListsOfPoints */ if (graphStateArray[i].unitsOn) { - /* do only for X, ps uses default of black */ + /* do only for X, ps uses default of black */ if (dFlag==Xoption) GSetForeground(unitGC, - (float)monoColor(graphStateArray[i].unitsColor), - dFlag); + (float)monoColor(graphStateArray[i].unitsColor), + dFlag); tickStart = calcUnitX(0); @@ -372,70 +358,70 @@ drawTheViewport(int dFlag) unitWidth = 5*overall.width; /* limit on acceptable separation : 5 chars */ k = floor(unitWidth/oneTickUnit) +1; /* get skipping integer */ for (ii=0, jj = tickStart; - jj < vwInfo.width; - ii=ii+k,jj =jj+k* oneTickUnit) { - if (jj >= 0) { - - /* ticks stuck to viewport*/ - GDrawLine(unitGC,vw, - (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4, - dFlag); - - sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX); - strlength=strlen(aunit); - halflength=XTextWidth(unitFont,aunit,strlength)/2; - - if (dFlag == Xoption) GDrawImageString(unitGC, - vw, - (int)rint(jj) - halflength, - vwInfo.height -8 -descent, - aunit, - strlength, - dFlag); - if (dFlag == PSoption) GDrawImageString(unitGC, - vw, - (int)rint(jj) -(strlength*3) , - vwInfo.height -14, - aunit, - strlength, - dFlag); - /* these are "eyeball" parameters for the given PS font */ + jj < vwInfo.width; + ii=ii+k,jj =jj+k* oneTickUnit) { + if (jj >= 0) { + + /* ticks stuck to viewport*/ + GDrawLine(unitGC,vw, + (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4, + dFlag); + + sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX); + strlength=strlen(aunit); + halflength=XTextWidth(unitFont,aunit,strlength)/2; + + if (dFlag == Xoption) GDrawImageString(unitGC, + vw, + (int)rint(jj) - halflength, + vwInfo.height -8 -descent, + aunit, + strlength, + dFlag); + if (dFlag == PSoption) GDrawImageString(unitGC, + vw, + (int)rint(jj) -(strlength*3) , + vwInfo.height -14, + aunit, + strlength, + dFlag); + /* these are "eyeball" parameters for the given PS font */ - } + } - } + } /* ticks along the negative X axis */ for (ii=-k,jj=tickStart - k*oneTickUnit; - jj > 0; - ii=ii-k,jj = jj-k*oneTickUnit) { - if (jj <= vwInfo.width) { - - /* ticks stuck to viewport*/ - GDrawLine(unitGC,vw, - (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4, - dFlag); - - sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX); - strlength=strlen(aunit); - halflength=XTextWidth(unitFont,aunit,strlength)/2; - - if (dFlag == Xoption) GDrawImageString(unitGC, - vw, - (int)rint(jj) - halflength, - vwInfo.height -8 -descent, - aunit, - strlength, - dFlag); - if (dFlag == PSoption) GDrawImageString(unitGC, - vw, - (int)rint(jj) -(strlength*3) , - vwInfo.height -14, - aunit, - strlength, - dFlag); - /* these are "eyeball" parameters for the given PS font */ - } - } + jj > 0; + ii=ii-k,jj = jj-k*oneTickUnit) { + if (jj <= vwInfo.width) { + + /* ticks stuck to viewport*/ + GDrawLine(unitGC,vw, + (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4, + dFlag); + + sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX); + strlength=strlen(aunit); + halflength=XTextWidth(unitFont,aunit,strlength)/2; + + if (dFlag == Xoption) GDrawImageString(unitGC, + vw, + (int)rint(jj) - halflength, + vwInfo.height -8 -descent, + aunit, + strlength, + dFlag); + if (dFlag == PSoption) GDrawImageString(unitGC, + vw, + (int)rint(jj) -(strlength*3) , + vwInfo.height -14, + aunit, + strlength, + dFlag); + /* these are "eyeball" parameters for the given PS font */ + } + } tickStart = calcUnitY(0); oneTickUnit = calcUnitY(1) - tickStart; @@ -444,117 +430,117 @@ drawTheViewport(int dFlag) unitWidth = 2*(ascent+descent); /* limit of acceptable separation */ k = floor(unitWidth/fabs(oneTickUnit)) +1; /* get skipping integer */ for (ii=0,jj = tickStart; - jj > 0; - ii=ii+k,jj =jj+k*oneTickUnit ) { - if (jj < vwInfo.height) { + jj > 0; + ii=ii+k,jj =jj+k*oneTickUnit ) { + if (jj < vwInfo.height) { - /* ticks stuck to viewport*/ - /* on the right */ - /* + /* ticks stuck to viewport*/ + /* on the right */ + /* GDrawLine(unitGC,vw, - vwInfo.width-6,(int)rint(jj), - vwInfo.width-2,(int)rint(jj),dFlag); - */ - /* on the left */ - GDrawLine(unitGC,vw, - 2,(int)rint(jj), - 6,(int)rint(jj), - dFlag); - sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY); - strlength=strlen(aunit); - XTextExtents(unitFont,aunit,strlength,&dummyInt, - &ascent,&descent,&overall); - halflength=overall.width; /* let's reuse that variable */ - - if(dFlag == Xoption){ + vwInfo.width-6,(int)rint(jj), + vwInfo.width-2,(int)rint(jj),dFlag); + */ + /* on the left */ + GDrawLine(unitGC,vw, + 2,(int)rint(jj), + 6,(int)rint(jj), + dFlag); + sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY); + strlength=strlen(aunit); + XTextExtents(unitFont,aunit,strlength,&dummyInt, + &ascent,&descent,&overall); + halflength=overall.width; /* let's reuse that variable */ + + if(dFlag == Xoption){ /* on the right */ - /* - GDrawImageString(unitGC, vw, - vwInfo.width-halflength -6-descent, - (int)rint(jj)+ascent/2 , - aunit, strlength, dFlag); - */ + /* + GDrawImageString(unitGC, vw, + vwInfo.width-halflength -6-descent, + (int)rint(jj)+ascent/2 , + aunit, strlength, dFlag); + */ /* on the left */ - GDrawImageString(unitGC, vw, - 8 + charlength/2, - (int)rint(jj)+ascent/2 , - aunit, strlength, dFlag); - } - if(dFlag == PSoption){ + GDrawImageString(unitGC, vw, + 8 + charlength/2, + (int)rint(jj)+ascent/2 , + aunit, strlength, dFlag); + } + if(dFlag == PSoption){ /* on the right */ - /* - GDrawImageString(unitGC, vw, - vwInfo.width - 6 - (strlength*6), - (int)rint(jj)+4, - aunit, strlength, dFlag); - */ + /* + GDrawImageString(unitGC, vw, + vwInfo.width - 6 - (strlength*6), + (int)rint(jj)+4, + aunit, strlength, dFlag); + */ /* on the left */ - GDrawImageString(unitGC, vw, - 8,(int)rint(jj)+4, - aunit, strlength, dFlag); - /* these are "eyeball" parameters for the given PS font */ - } - } - } + GDrawImageString(unitGC, vw, + 8,(int)rint(jj)+4, + aunit, strlength, dFlag); + /* these are "eyeball" parameters for the given PS font */ + } + } + } /* ticks along the negative Y axis */ for (ii=(-k),jj = tickStart - k*oneTickUnit; - jj < vwInfo.height; - ii=ii-k,jj =jj-k*oneTickUnit) { - if (jj > 0) { + jj < vwInfo.height; + ii=ii-k,jj =jj-k*oneTickUnit) { + if (jj > 0) { - /* ticks stuck to viewport*/ - /* on the right */ - /* + /* ticks stuck to viewport*/ + /* on the right */ + /* GDrawLine(unitGC,vw, - vwInfo.width-6,(int)rint(jj), - vwInfo.width-2,(int)rint(jj), - dFlag); - */ - /* on the left */ - GDrawLine(unitGC,vw, - 2,(int)rint(jj), - 6,(int)rint(jj), - dFlag); - - sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY); - strlength=strlen(aunit); - XTextExtents(unitFont,aunit,strlength,&dummyInt, - &ascent,&descent,&overall); - halflength=overall.width; /* let's reuse that variable */ - - if(dFlag == Xoption){ + vwInfo.width-6,(int)rint(jj), + vwInfo.width-2,(int)rint(jj), + dFlag); + */ + /* on the left */ + GDrawLine(unitGC,vw, + 2,(int)rint(jj), + 6,(int)rint(jj), + dFlag); + + sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY); + strlength=strlen(aunit); + XTextExtents(unitFont,aunit,strlength,&dummyInt, + &ascent,&descent,&overall); + halflength=overall.width; /* let's reuse that variable */ + + if(dFlag == Xoption){ /* on the right */ - /* - GDrawImageString(unitGC, vw, - vwInfo.width-halflength -6-descent, - (int)rint(jj)+ascent/2 , - aunit, strlength, dFlag); - */ + /* + GDrawImageString(unitGC, vw, + vwInfo.width-halflength -6-descent, + (int)rint(jj)+ascent/2 , + aunit, strlength, dFlag); + */ /* on the left */ - GDrawImageString(unitGC, vw, - 8 + charlength/2, - (int)rint(jj)+ascent/2 , - aunit, strlength, dFlag); - } - if(dFlag == PSoption){ + GDrawImageString(unitGC, vw, + 8 + charlength/2, + (int)rint(jj)+ascent/2 , + aunit, strlength, dFlag); + } + if(dFlag == PSoption){ /* on the right */ - /* - GDrawImageString(unitGC, vw, - vwInfo.width -6 -(strlength*6), - (int)rint(jj)+4 , - aunit, strlength, dFlag); - */ + /* + GDrawImageString(unitGC, vw, + vwInfo.width -6 -(strlength*6), + (int)rint(jj)+4 , + aunit, strlength, dFlag); + */ /* on the left */ - GDrawImageString(unitGC, vw, - 8, - (int)rint(jj)+4 , - aunit, strlength, dFlag); - /* these are "eyeball" parameters for the given PS font */ - } - } - } + GDrawImageString(unitGC, vw, + 8, + (int)rint(jj)+4 , + aunit, strlength, dFlag); + /* these are "eyeball" parameters for the given PS font */ + } + } + } } /* if unitsOn */ } /* if graph i exists and is showing */ @@ -635,7 +621,7 @@ makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP) XQueryColor(dsply,colorMap,&foreColor); XQueryColor(dsply,colorMap,&backColor); viewAttrib.cursor = XCreatePixmapCursor(dsply,spadbits,spadmask, - &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot); + &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot); viewAttrib.event_mask = titleMASK; if (vW) { @@ -651,16 +637,16 @@ makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP) } viewTitleWindow = XCreateWindow(dsply,rtWindow,vX,vY,vW,vH, - viewBorderWidth, - CopyFromParent,InputOutput,CopyFromParent, - viewportTitleCreateMASK,&viewAttrib); + viewBorderWidth, + CopyFromParent,InputOutput,CopyFromParent, + viewportTitleCreateMASK,&viewAttrib); wm_delete_window = XInternAtom(dsply, "WM_DELETE_WINDOW", False); (void) XSetWMProtocols(dsply, viewTitleWindow, &wm_delete_window, 1); XSetNormalHints(dsply,viewTitleWindow,&titleSizeHints); XSetStandardProperties(dsply,viewTitleWindow,"AXIOM 2D",viewport->title, - None,NULL,0,&titleSizeHints); + None,NULL,0,&titleSizeHints); viewport->titleWindow = viewTitleWindow; viewAttrib.event_mask = viewportMASK; @@ -671,14 +657,14 @@ makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP) viewSizeHints.height = titleSizeHints.height - (titleHeight + appendixHeight); viewGraphWindow = XCreateWindow(dsply,viewTitleWindow, - viewSizeHints.x,viewSizeHints.y, - viewSizeHints.width,viewSizeHints.height, - viewBorderWidth, - CopyFromParent,InputOutput,CopyFromParent, - viewportCreateMASK,&viewAttrib); + viewSizeHints.x,viewSizeHints.y, + viewSizeHints.width,viewSizeHints.height, + viewBorderWidth, + CopyFromParent,InputOutput,CopyFromParent, + viewportCreateMASK,&viewAttrib); XSetNormalHints(dsply,viewGraphWindow,&viewSizeHints); XSetStandardProperties(dsply,viewGraphWindow,"2D Viewport","2D Viewport", - None,NULL,0,&viewSizeHints); + None,NULL,0,&viewSizeHints); viewport->viewWindow = viewGraphWindow; @@ -725,9 +711,3 @@ makeView2D(view2DStruct *viewdata) } /* makeView2D */ -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/write2d.c.pamphlet b/src/graph/view2D/write2d.c index 66eafe26..7a00fc68 100644 --- a/src/graph/view2D/write2d.c.pamphlet +++ b/src/graph/view2D/write2d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D write2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _WRITE2D_C #include "axiom-c-macros.h" @@ -100,7 +86,7 @@ writeViewport(int thingsToWrite) fprintf(viewDataFile,"%d\n",view2DType); fprintf(viewDataFile,"%s\n",viewport->title); fprintf(viewDataFile,"%d %d %d %d\n",vwInfo.x,vwInfo.y, - vwInfo.width,vwInfo.height); + vwInfo.width,vwInfo.height); for (i=0; i<maxGraphs; i++) { fprintf(viewDataFile,"%d\n",graphArray[i].key); fprintf(viewDataFile,"%g %g\n", @@ -128,7 +114,7 @@ writeViewport(int thingsToWrite) } else { fprintf(viewDataFile,"%g %g %g %g\n", graphArray[i].xmin,graphArray[i].ymin, - graphArray[i].xmax,graphArray[i].ymax); + graphArray[i].xmax,graphArray[i].ymax); fprintf(viewDataFile,"%g %g\n", graphArray[i].xNorm,graphArray[i].yNorm); fprintf(viewDataFile,"%g %g\n", @@ -165,16 +151,16 @@ writeViewport(int thingsToWrite) sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.xpm"); XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); write_pixmap_file(dsply,scrn,viewBitmapFilename, - viewport->titleWindow,0,0,vwInfo.width, - vwInfo.height+titleHeight); + viewport->titleWindow,0,0,vwInfo.width, + vwInfo.height+titleHeight); break; case Bitmap: /*** Create the bitmap (bitmaps need leaf name) ***/ sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.bm"); XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); code = XWriteBitmapFile(dsply,viewBitmapFilename, - viewport->titleWindow,vwInfo.width, - vwInfo.height+vwInfo.border_width+20,-1,-1); + viewport->titleWindow,vwInfo.width, + vwInfo.height+vwInfo.border_width+20,-1,-1); break; case Image: /*** Create the pixmap (bitmaps need leaf name) ***/ @@ -185,16 +171,16 @@ writeViewport(int thingsToWrite) drawViewport(Xoption); writeTitle(); write_pixmap_file(dsply,scrn,viewBitmapFilename, - viewport->titleWindow,0,0,vwInfo.width, - vwInfo.height+titleHeight); + viewport->titleWindow,0,0,vwInfo.width, + vwInfo.height+titleHeight); /*** Create the bitmap (bitmaps need leaf name) ***/ mono = 1; drawViewport(Xoption); writeTitle(); sprintf(viewBitmapFilename,"%s%s%s",viewDirName,"/","image.bm"); code = XWriteBitmapFile(dsply,viewBitmapFilename, - viewport->titleWindow,vwInfo.width, - vwInfo.height+vwInfo.border_width+20,-1,-1); + viewport->titleWindow,vwInfo.width, + vwInfo.height+vwInfo.border_width+20,-1,-1); mono = 0; break; @@ -202,11 +188,11 @@ writeViewport(int thingsToWrite) /*** Create postscript output for viewport (in axiom2D.ps) ***/ sprintf(PSfilename,"%s%s",viewDirName,"/axiom2D.ps"); if (PSInit(viewport->viewWindow,viewport->titleWindow) == psError) - return (-1); + return (-1); drawViewport(PSoption); /* write new script file in /tmp */ if (PSCreateFile(viewBorderWidth,viewport->viewWindow, - viewport->titleWindow, viewport->title) == psError) - return(-1); /* concat script & proc into axiom2D.ps */ + viewport->titleWindow, viewport->title) == psError) + return(-1); /* concat script & proc into axiom2D.ps */ break; } /* switch on ii */ @@ -217,9 +203,3 @@ writeViewport(int thingsToWrite) } /* else create directory okay */ } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/Makefile.in b/src/graph/view3D/Makefile.in index 914d79a6..e8fc9f44 100644 --- a/src/graph/view3D/Makefile.in +++ b/src/graph/view3D/Makefile.in @@ -1,4 +1,4 @@ -# Copyright (C) 2007, Gabriel Dos Reis. +# Copyright (C) 2007-2008, Gabriel Dos Reis. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -45,16 +45,14 @@ build_libdir = $(abs_top_builddir)/src/lib bin_PROGRAMS = view3D$(EXEEXT) -view3D_sources = buttons3d.c closeView3d.c component3d.c control3d.c \ +view3D_SOURCES = buttons3d.c closeView3d.c component3d.c control3d.c \ illuminate3d.c lightbut3d.c lighting3d.c main3d.c \ mesh3d.c msort3d.c pot3d.c process3d.c project3d.c \ quitbut3d.c quit3d.c save3d.c savebut3d.c smoothShade3d.c \ spadAction3d.c stuff3d.c surface3d.c transform3d.c \ viewport3d.c volume3d.c write3d.c -view3D_SOURCES = $(addsuffix .pamphlet, $(view3D_sources)) - -view3D_objects = $(addprefix $(builddir)/, $(view3D_sources:.c=.lo)) +view3D_objects = $(addprefix $(builddir)/, $(view3D_SOURCES:.c=.lo)) Gfun_objects = ../Gdraws/Gfun.lo @@ -62,8 +60,6 @@ Gfun_objects = ../Gdraws/Gfun.lo view3D_LDADD = $(axiom_target_libdir)/libspad.la view3D_DEPENDENCIES = $(Gfun_objects) -pamphlets = Makefile.pamphlet $(view3D_SOURCES) - subdir = src/graph/view3D/ AXIOM_CFLAGS = ${CCF} ${AXIOM_X11_CFLAGS} -I${LINC} -I${GINC} -I${IN} \ @@ -88,16 +84,12 @@ $(axiom_target_libdir)/view3D$(EXEEXT): $(view3D_objects) $(view3D_DEPENDENCIES) $(view3D_LDADD) $(AXIOM_X11_LDFLAGS) -lm .PRECIOUS: %.lo -.PRECIOUS: %.c %.lo: $(HEADERS) %.lo: %.c $(COMPILE) -o $@ $(CFLAGS) $(AXIOM_CFLAGS) $< -%.c: $(srcdir)/%.c.pamphlet - $(axiom_build_document) --tangle --output=$@ $< - mostly-clean: clean-clean: mostlyclean-clean diff --git a/src/graph/view3D/buttons3d.c.pamphlet b/src/graph/view3D/buttons3d.c index 544892b8..898a6799 100644 --- a/src/graph/view3D/buttons3d.c.pamphlet +++ b/src/graph/view3D/buttons3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D buttons3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _BUTTONS3D_C #include "axiom-c-macros.h" @@ -54,9 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "cpanel.h" #include "all_3d.H1" -#define BH 31 /* button window height */ -#define PH 80 /* potentiometer window height */ -#define XEDGE 5 /* leftmost button starts here */ +#define BH 31 /* button window height */ +#define PH 80 /* potentiometer window height */ +#define XEDGE 5 /* leftmost button starts here */ /***************************************************** * int initButtons(buttons) * @@ -84,7 +70,7 @@ initButtons (buttonStruct *buttons) /* Title: "Rotate" */ ii = rotate; buttons[ii].buttonX = XEDGE; buttons[ii].buttonY = 85; - buttons[ii].buttonWidth = 110; buttons[ii].buttonHeight = PH; + buttons[ii].buttonWidth = 110; buttons[ii].buttonHeight = PH; buttons[ii].buttonKey = ii; buttons[ii].pot = yes; /* rotate is a potentiometer */ buttons[ii].mask = potMASK; @@ -128,7 +114,7 @@ initButtons (buttonStruct *buttons) /* Wirefram mesh */ ii = transparent; buttons[ii].buttonX = XEDGE; buttons[ii].buttonY = PBY; - buttons[ii].buttonWidth = 45; buttons[ii].buttonHeight = BH; + buttons[ii].buttonWidth = 45; buttons[ii].buttonHeight = BH; buttons[ii].buttonKey = ii; buttons[ii].pot = no; buttons[ii].mask = buttonMASK; @@ -270,7 +256,7 @@ initButtons (buttonStruct *buttons) /* Shows Lighting Control Panel */ ii = lighting; buttons[ii].buttonX = XEDGE; buttons[ii].buttonY = PBY; - buttons[ii].buttonWidth = 65; buttons[ii].buttonHeight = BH; + buttons[ii].buttonWidth = 65; buttons[ii].buttonHeight = BH; buttons[ii].buttonKey = ii; buttons[ii].pot = no; buttons[ii].mask = buttonMASK; @@ -328,7 +314,7 @@ initButtons (buttonStruct *buttons) /* Red is off, Green is on */ ii = originr; buttons[ii].buttonX = XEDGE; buttons[ii].buttonY = 55; - buttons[ii].buttonWidth = 53; buttons[ii].buttonHeight = 25; + buttons[ii].buttonWidth = 53; buttons[ii].buttonHeight = 25; buttons[ii].buttonKey = ii; buttons[ii].pot = no; buttons[ii].mask = buttonMASK; @@ -441,9 +427,3 @@ initButtons (buttonStruct *buttons) } /* initButtons() */ -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/closeView3d.c b/src/graph/view3D/closeView3d.c new file mode 100644 index 00000000..bb3e8257 --- /dev/null +++ b/src/graph/view3D/closeView3d.c @@ -0,0 +1,95 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _CLOSEVIEW3D_C +#include "axiom-c-macros.h" + +#include <stdlib.h> +#include "header.h" + +#include "util.H1" +#include "Gfun.H1" +#include "all_3d.H1" + + + +/***************************************************** + * int closeViewport() * + * * + * This closes all of the windows created for the * + * control panel window and the viewport window of * + * the current graph being displayed. * + * It does not currently return a specified value. * + * * + *****************************************************/ + +void +#ifdef _NO_PROTO +closeViewport () +#else +closeViewport (void) +#endif +{ + int i; + + /* First, unlink viewport from global list of viewports */ + if (viewport->prevViewport) { /* if there is a viewport before it */ + (viewport->prevViewport)->nextViewport = viewport->nextViewport; + } else { /* this is the first viewport */ + viewport = viewport->nextViewport; + } + if (viewport->nextViewport) { /* if there is a viewport following it */ + (viewport->nextViewport)->prevViewport = viewport->prevViewport; + } + + /* Free up the control panel button windows */ + for (i=0; i<maxButtons3D; i++) { + XDeleteAssoc(dsply,table,(control->buttonQueue[i]).self); + } + + /* Free up the control panel window */ + XDestroyWindow(dsply,control->controlWindow); + free(control); + + /* Free up the viewport window */ + + XDestroyWindow(dsply,viewport->viewWindow); + XDestroyWindow(dsply,viewport->titleWindow); + free(viewport); + + XFlush(dsply); + +} /* closeViewport() */ + diff --git a/src/graph/view3D/closeView3d.c.pamphlet b/src/graph/view3D/closeView3d.c.pamphlet deleted file mode 100644 index 3d66aa26..00000000 --- a/src/graph/view3D/closeView3d.c.pamphlet +++ /dev/null @@ -1,115 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D closeView3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _CLOSEVIEW3D_C -#include "axiom-c-macros.h" - -#include <stdlib.h> -#include "header.h" - -#include "util.H1" -#include "Gfun.H1" -#include "all_3d.H1" - - - -/***************************************************** - * int closeViewport() * - * * - * This closes all of the windows created for the * - * control panel window and the viewport window of * - * the current graph being displayed. * - * It does not currently return a specified value. * - * * - *****************************************************/ - -void -#ifdef _NO_PROTO -closeViewport () -#else -closeViewport (void) -#endif -{ - int i; - - /* First, unlink viewport from global list of viewports */ - if (viewport->prevViewport) { /* if there is a viewport before it */ - (viewport->prevViewport)->nextViewport = viewport->nextViewport; - } else { /* this is the first viewport */ - viewport = viewport->nextViewport; - } - if (viewport->nextViewport) { /* if there is a viewport following it */ - (viewport->nextViewport)->prevViewport = viewport->prevViewport; - } - - /* Free up the control panel button windows */ - for (i=0; i<maxButtons3D; i++) { - XDeleteAssoc(dsply,table,(control->buttonQueue[i]).self); - } - - /* Free up the control panel window */ - XDestroyWindow(dsply,control->controlWindow); - free(control); - - /* Free up the viewport window */ - - XDestroyWindow(dsply,viewport->viewWindow); - XDestroyWindow(dsply,viewport->titleWindow); - free(viewport); - - XFlush(dsply); - -} /* closeViewport() */ - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/component3d.c b/src/graph/view3D/component3d.c new file mode 100644 index 00000000..fab1b5c3 --- /dev/null +++ b/src/graph/view3D/component3d.c @@ -0,0 +1,887 @@ +/* + Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _COMPONENT3D_C +#include "axiom-c-macros.h" + +#include "header.h" +#include "draw.h" + +#include "Gfun.H1" +#include "util.H1" +#include "XSpadFill.H1" + +#include "all_3d.H1" + +#define axisLength 1.0 /* use 100.0, if data is not to be normalized */ + +#define samePoint(a,b) ((refPt3D(viewData,a)->x == refPt3D(viewData,b)->x) &&\ + (refPt3D(viewData,a)->y == refPt3D(viewData,b)->y) &&\ + (refPt3D(viewData,a)->z == refPt3D(viewData,b)->z)) +#define MAX_POINT 1000.0 +#define MIN_POINT -1000.0 + + +void +#ifdef _NO_PROTO +scaleComponents () +#else +scaleComponents (void) +#endif +{ + + double xRange,yRange,zRange; + int i; + viewTriple *aPoint; + + /* Temporary range limits until the three dimensional clipping + package is fully functional */ + + if (viewData.xmin < MIN_POINT) viewData.xmin = MIN_POINT; + if (viewData.xmax > MAX_POINT) viewData.xmax = MAX_POINT; + if (viewData.ymin < MIN_POINT) viewData.ymin = MIN_POINT; + if (viewData.ymax > MAX_POINT) viewData.ymax = MAX_POINT; + if (viewData.zmin < MIN_POINT) viewData.zmin = MIN_POINT; + if (viewData.zmax > MAX_POINT) viewData.zmax = MAX_POINT; + + xRange = viewData.xmax - viewData.xmin; + yRange = viewData.ymax - viewData.ymin; + zRange = viewData.zmax - viewData.zmin; + + /* We scale down, normalize the data, if it is coming from AXIOM + (handled by viewman). If the data is coming from a file (handled by + viewAlone) then it should already been scaled down. + */ + + /* Find the coordinate axis with the larges range of data and scale + the others relative to it. + */ + /* compare x and y ranges */ + if (xRange > yRange) { + if (xRange > zRange) { + if (absolute(viewData.xmax) >= absolute(viewData.xmin)) + viewData.scaleToView = axisLength/(absolute(viewData.xmax)); + else + viewData.scaleToView = axisLength/(absolute(viewData.xmin)); + } else { + if (absolute(viewData.zmax) >= absolute(viewData.zmin)) + viewData.scaleToView = axisLength/(absolute(viewData.zmax)); + else + viewData.scaleToView = axisLength/(absolute(viewData.zmin)); + } + } else { + if (yRange > zRange) { + if (absolute(viewData.ymax) >= absolute(viewData.ymin)) + viewData.scaleToView = axisLength/(absolute(viewData.ymax)); + else + viewData.scaleToView = axisLength/(absolute(viewData.ymin)); + } else { + if (absolute(viewData.zmax) >= absolute(viewData.zmin)) + viewData.scaleToView = axisLength/(absolute(viewData.zmax)); + else + viewData.scaleToView = axisLength/(absolute(viewData.zmin)); + } + } + + /* We now normalize all the points in this program. The information + needed to link the normalized set of points back to the real object + space scale created in AXIOM is held in viewData.scaleToView. */ + viewData.xmin *= viewData.scaleToView; + viewData.xmax *= viewData.scaleToView; + viewData.ymin *= viewData.scaleToView; + viewData.ymax *= viewData.scaleToView; + viewData.zmin *= viewData.scaleToView; + viewData.zmax *= viewData.scaleToView; + viewData.clipXmin = viewData.xmin; + viewData.clipXmax = viewData.xmax; + viewData.clipYmin = viewData.ymin; + viewData.clipYmax = viewData.ymax; + viewData.clipZmin = viewData.zmin; + viewData.clipZmax = viewData.zmax; + + for (i=0, aPoint=viewData.points; i<viewData.numOfPoints; i++,aPoint++) { + aPoint->x *= viewData.scaleToView; + aPoint->y *= viewData.scaleToView; + aPoint->z *= viewData.scaleToView; + } + +} /* scaleComponents() */ + + +/* + void makeTriangle(a,b,c) + Given three indices to three points, a triangular polygon is created + and inserted into the polygon list of viewData. If two or more of the + points are coincidental, no polygon is created since that would be a + degenerate (collapsed) polygon. + */ + +void +#ifdef _NO_PROTO +makeTriangle (a, b, c) + int a,b,c; +#else +makeTriangle (int a, int b, int c) +#endif +{ + poly *aPoly; + + if (!(samePoint(a,b) || samePoint(b,c) || samePoint(c,a))) { + /* create triangle only if the three vertex points are distinct */ + aPoly = (poly *)saymem("component.c",1,sizeof(poly)); + aPoly->num = aPoly->sortNum = viewData.numPolygons++; + aPoly->split = aPoly->moved = no; + aPoly->numpts = 3; + aPoly->primitiveType = polygonComponent; + aPoly->indexPtr = (int *)saymem("component.c",3,sizeof(int)); + *(aPoly->indexPtr) = a; + *(aPoly->indexPtr + 1) = b; + *(aPoly->indexPtr + 2) = c; + aPoly->doNotStopDraw = yes; + aPoly->next = viewData.polygons; + viewData.polygons = aPoly; + } /* if all points are unique */ + +} /* makeTriangle() */ + + + + +/* + void triangulate() + + Only if there is more than one list do we triangulate; a single list + is used for either a space curve or simply a point. Actually, in that + case, we now make "flat" *polygons, flagged by the primitiveType field + (pointComponent, etc. in tube.h). We need to examine two lists at a time + (and if the structure is closed, the last and first as well). For every + three points in the two lists, alternating between one in one and two in + the other, we construct triangles. If one list is shorter, then its last + point becomes the vertex for the remaining pairs of points from the other + list. It turns out that any distribution of points in the two lists + (preserving cyclic order) will produce the same desired polygon. + */ + +void +#ifdef _NO_PROTO +triangulate () +#else +triangulate (void) +#endif +{ + + int u,l; + int uBound,lBound; + int i,j,k; + LLPoint *anLLPoint; + LPoint *list1,*list2; + poly *aPoly; + + anLLPoint = viewData.lllp.llp; + for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) { + if (anLLPoint->numOfLists > 1) { + list2 = anLLPoint->lp; + for (j=1; j<anLLPoint->numOfLists; j++) { + list1 = list2; + list2 = list1 + 1; + u = l = 0; + uBound = u+1 < list1->numOfPoints; + lBound = l+1 < list2->numOfPoints; + while (uBound || lBound) { + if (uBound) { + makeTriangle(*(list1->indices + u + 1), + *(list1->indices + u), *(list2->indices + l)); + u++; + uBound = u+1 < list1->numOfPoints; + } + if (lBound) { + makeTriangle(*(list2->indices + l), + *(list2->indices + l + 1), *(list1->indices + u)); + l++; + lBound = l+1 < list2->numOfPoints; + } + } /* while (uBound || lBound) */ + } /* for j<anLLPoint->numOfLists */ + } /* if anLLPoint->numOfLists > 1 */ + else { + /* if anLLPoint->numOfLists <= 1...assume this means =1 */ + /* Flat polygons are to be drawn when hidden + surface algorithm is used.*/ + if (anLLPoint->numOfLists == 1) { + if (anLLPoint->lp->numOfPoints == 1) { + /* this graph is a single point */ + aPoly = (poly *)saymem("component.c",1,sizeof(poly)); + aPoly->num = aPoly->sortNum = viewData.numPolygons++; + aPoly->split = aPoly->moved = no; + aPoly->primitiveType = pointComponent; + aPoly->numpts = 1; + aPoly->indexPtr = (int *)saymem("component.c",1,intSize); + *(aPoly->indexPtr) = *(anLLPoint->lp->indices); + aPoly->doNotStopDraw = yes; + aPoly->next = viewData.polygons; + viewData.polygons = aPoly; + } else { + /* this graph is a curve */ + for (k=0; k<anLLPoint->lp->numOfPoints-1; k++) { + aPoly = (poly *)saymem("component.c",1,sizeof(poly)); + aPoly->num = aPoly->sortNum = viewData.numPolygons++; + aPoly->split = aPoly->moved = no; + aPoly->primitiveType = lineComponent; /* curveComponent */ + aPoly->numpts = 2; + aPoly->indexPtr = + (int *)saymem("component.c",2,sizeof(int)); + *(aPoly->indexPtr) = *(anLLPoint->lp->indices + k); + *(aPoly->indexPtr+1) = *(anLLPoint->lp->indices + k + 1); + aPoly->doNotStopDraw = yes; + aPoly->next = viewData.polygons; + viewData.polygons = aPoly; + } /* for k */ + if (anLLPoint->lp->prop.closed) { + aPoly = (poly *)saymem("component.c",1,sizeof(poly)); + aPoly->num = aPoly->sortNum = viewData.numPolygons++; + aPoly->split = aPoly->moved = no; + aPoly->primitiveType = lineComponent; /* curveComponent */ + aPoly->numpts = 2; + aPoly->indexPtr = + (int *)saymem("component.c",2,sizeof(int)); + *(aPoly->indexPtr) = *(anLLPoint->lp->indices + k); + *(aPoly->indexPtr+1) = *(anLLPoint->lp->indices); + aPoly->doNotStopDraw = yes; + aPoly->next = viewData.polygons; + viewData.polygons = aPoly; + } /* if list of points is closed */ + } /* else */ + } /* point, line, polygon, surface components are taken care of above */ + } /* else anLLPoint->numOfLists <= 1 */ + } /* for LLPoints in LLLPoints (i) */ + +} /* triangulate */ + + + +void +#ifdef _NO_PROTO +readComponentsFromViewman () +#else +readComponentsFromViewman (void) +#endif +{ + int i,j,k; + LLPoint *anLLPoint; + LPoint *anLPoint; + viewTriple *aPoint; + /* maxLength holds the max(llp,lp) figure regarding how large to + make the array of XPoints, i.e. quadMesh, for use in calling XDraw(). */ + int maxLength=0; + + int *anIndex; + + readViewman(&(viewData.numOfPoints),intSize); + aPoint = viewData.points = + (viewTriple *)saymem("component.c",viewData.numOfPoints, + sizeof(viewTriple)); + for (i=0; i<viewData.numOfPoints; i++, aPoint++) { + readViewman(&(aPoint->x),floatSize); + readViewman(&(aPoint->y),floatSize); + readViewman(&(aPoint->z),floatSize); + readViewman(&(aPoint->c),floatSize); +#ifdef NANQ_DEBUG + if (!(aPoint->z < 0) && !(aPoint->z > 0) && !(aPoint->z == 0)) + fprintf(stderr,"%g\n", aPoint->z); +#endif + } + + readViewman(&(viewData.lllp.numOfComponents),intSize); + anLLPoint = viewData.lllp.llp = + (LLPoint *)saymem("component.c, i",viewData.lllp.numOfComponents, + sizeof(LLPoint)); + for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) { + readViewman(&(anLLPoint->prop.closed),intSize); + readViewman(&(anLLPoint->prop.solid),intSize); + readViewman(&(anLLPoint->numOfLists),intSize); + anLPoint = anLLPoint->lp = + (LPoint *)saymem("component.c, ii",anLLPoint->numOfLists, + sizeof(LPoint)); + for (j=0; j<anLLPoint->numOfLists; j++,anLPoint++) { + if (anLLPoint->numOfLists > maxLength) + maxLength = anLLPoint->numOfLists; + readViewman(&(anLPoint->prop.closed),intSize); + readViewman(&(anLPoint->prop.solid),intSize); + readViewman(&(anLPoint->numOfPoints),intSize); + anIndex = anLPoint->indices = + (int *)saymem("component.c, index",anLPoint->numOfPoints,intSize); + if (anLPoint->numOfPoints > maxLength) + maxLength = anLPoint->numOfPoints; + for (k=0; k<anLPoint->numOfPoints; k++,anIndex++) { + readViewman(anIndex,intSize); + /* AXIOM arrays are one based, C arrays are zero based */ + if (!viewAloned) (*anIndex)--; + } + } /* for LPoints in LLPoints (j) */ + } /* for LLPoints in LLLPoints (i) */ + + quadMesh = (XPoint *)saymem("component.c",maxLength+2,sizeof(XPoint)); + +} /* readComponentsFromViewman() */ + + + +/* + void calcNormData() * + Calculates the surface normals for the polygons that make up the tube. + Also finds the fourth coefficient to the plane equation: + Ax + By + Cz + D = 0 + A,B, and C are in the normal N[3] and D is the planeConst. + Figures out the color as well (from the average of the points) and + resets the moved flag + */ + +void +#ifdef _NO_PROTO +calcNormData () +#else +calcNormData (void) +#endif +{ + + poly *aPoly; + int *index; + + for (aPoly = viewData.polygons; aPoly != NIL(poly); aPoly = aPoly->next) { + index = aPoly->indexPtr; + switch (aPoly->primitiveType) { + case pointComponent: + case lineComponent: + aPoly->moved = 0; + aPoly->color = refPt3D(viewData,*index)->c; + break; + default: + /* + The following line takes 3 consecutive points and asks + for the normal vector defined by them. This assumes that + these do not contain co-linear points. For some reason, + co-linear points are allowed, this needs to be changed. + */ + getMeshNormal(refPt3D(viewData,*index)->x, + refPt3D(viewData,*index)->y, + refPt3D(viewData,*index)->z, + refPt3D(viewData,*(index+1))->x, + refPt3D(viewData,*(index+1))->y, + refPt3D(viewData,*(index+1))->z, + refPt3D(viewData,*(index+2))->x, + refPt3D(viewData,*(index+2))->y, + refPt3D(viewData,*(index+2))->z, 0.0, 1.0, aPoly->N); + + /* calculate the constant term, D, for the plane equation */ + aPoly->planeConst = + -(aPoly->N[0] * refPt3D(viewData,*index)->x + + aPoly->N[1] * refPt3D(viewData,*index)->y + + aPoly->N[2] * refPt3D(viewData,*index)->z); + aPoly->moved = 0; + aPoly->color = (refPt3D(viewData,*index)->c + + (refPt3D(viewData,*(index+1)))->c + + (refPt3D(viewData,*(index+2)))->c) / 3.0; + break; + } /* switch */ + } + +} /* calcNormData() */ + + + +/* + viewPoints *make3DComponents() + + Read in all the 3D data from the viewport manager and construct the + model of it. The model is based upon a list of lists of lists of points. + Each top level list makes a component in 3-space. The interpretation + really begins at the level below that, where the list of lists of + points is. For 3D explicit equations of two variables, the closed + boolean for this level is False and the closed boolean for each sublist + is False as well. For 3D parameterized curves of one variable, the + closed boolean for this level is defined by the user from AXIOM , + (which defaults to False) and the closed boolean for each sublist is True. + */ + +viewPoints * +#ifdef _NO_PROTO +make3DComponents () +#else +make3DComponents (void) +#endif +{ + viewPoints *graphData; + + readComponentsFromViewman(); + + /* The initial boundaries for the clipping region are set to those + of the boundaries of the data region. */ + viewData.clipXmin = viewData.xmin; viewData.clipXmax = viewData.xmax; + viewData.clipYmin = viewData.ymin; viewData.clipYmax = viewData.ymax; + viewData.clipZmin = viewData.zmin; viewData.clipZmax = viewData.zmax; + + /* normalize the data coordinates */ + if (viewData.scaleDown) scaleComponents(); + viewData.numPolygons = 0; + /* initially the list of polygons is empty */ + viewData.polygons = NIL(poly); + /* create the polygons; (sets viewData.polygons and viewData.numPolygons) */ + triangulate(); + /* calculate the plane equations for all the polygons */ + calcNormData(); + + graphData = makeViewport(); + + imageX = XCreateImage(/* display */ dsply, + /* visual */ DefaultVisual(dsply,scrn), + /* depth */ DefaultDepth(dsply,scrn), + /* format */ ZPixmap, + /* offset */ 0, + /* data */ NULL, + /* width */ vwInfo.width, + /* height */ 1, + /* bitmap_pad */ 32, + /* bytes_per_line */ 0); + imageX->data = NIL(char); + + /* windowing displaying */ + writeTitle(); + postMakeViewport(); + drawViewport(Xoption); + firstTime = yes; + XMapWindow(dsply, graphData->viewWindow); + XMapWindow(dsply, graphData->titleWindow); + XFlush(dsply); + + return(graphData); + +} /* make3DComponents */ + + + + + +void +#ifdef _NO_PROTO +draw3DComponents (dFlag) + int dFlag; +#else +draw3DComponents (int dFlag) +#endif +{ + + int i, j, k, hue, x1, y1, x2, y2; + LLPoint *anLLPoint; + LPoint *anLPoint; + int *anIndex; + int componentType; /* what the component is to be interpreted as */ + int clip_a,clip_i; /* for use in wire mesh mode clipping */ + XEvent peekEvent; + viewTriple *aLPt; + XPoint line[2]; + RGB col_rgb; + + calcEyePoint(); + while ((XPending(dsply) > 0) && (scanline > 0)) + XNextEvent(dsply,&peekEvent); + switch (viewData.style) { + + case transparent: + GSetLineAttributes(componentGC,0,LineSolid,CapButt,JoinMiter,dFlag); + if (dFlag==Xoption) { + if (mono || viewport->monoOn) + GSetForeground(componentGC, (float)foregroundColor, dFlag); + else + GSetForeground(componentGC, (float) meshOutline, dFlag); + } else { + GSetForeground(componentGC, psBlack, dFlag); + } + /* no need to check "keep drawing" for ps */ + if (dFlag == Xoption) drawMore = keepDrawingViewport(); + + /* + This is where we interpret the list of lists of lists of points struct. + We want to extract the following forms of data: + - individual points (drawn as filled points) + - lines (space curves) + - defined polygon primitives + - surfaces + the last one is the one that will replace the function of 2 variables, + tubes as well as 3D parameterized functions of 2 variables. + Since there could be many other ways of constructing L L L Pts - much + more than could be usefully interpreted - any other formats are + currently not allowed. When they are, this comment should be updated + appropriately. + + ************************************************************************ + + Traverse each component. + We decide here, before we begin traversing the + component what we want to interpret it as. + Here's the convention used to figure that out: + - points: #anLLPoint->numOfLists was 1 + #anLPoint->numOfPoints is 1 + - lines: #anLLPoint->numOfLists was 1 + #anLPoint->numOfPoints > 1 + - polygons: #anLLPoint->numOfLists was 2 + #anLPoint->numOfPoints is 1 + - surface: #anLLPoint->numOfLists was some m>1 + #anLPoint->numOfPoints all point lists are the same. + + */ + + anLLPoint = viewData.lllp.llp; + for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) { + /* initially, component type is unknown */ + componentType = stillDontKnow; + if (anLLPoint->numOfLists == 1) { + if (anLLPoint->lp->numOfPoints == 1) componentType = pointComponent; + else componentType = lineComponent; + } else if (anLLPoint->numOfLists == 2) { + if ((anLLPoint->lp->numOfPoints == 1) && + ((anLLPoint->lp+1)->numOfPoints > 2)) + componentType = polygonComponent; + } + /* Check for corrupt data and NaN data is made in AXIOM . */ + if (componentType == stillDontKnow) + componentType = surfaceComponent; + + anLPoint = anLLPoint->lp; + + switch (componentType) { + + case pointComponent: + /* anLLPoint->numOfLists == anLLPoint->lp->numOfPoints == 1 here */ + aLPt = refPt3D(viewData,*(anLPoint->indices)); + project(aLPt,quadMesh,0); + if (dFlag==Xoption) { + if (mono || viewport->monoOn) + GSetForeground(componentGC, (float)foregroundColor, dFlag); + else { + hue = hueValue(aLPt->c); + GSetForeground(componentGC, (float)XSolidColor(hue,2), dFlag); + } + } else GSetForeground(componentGC, psBlack, dFlag); + GFillArc(componentGC,viewport->viewWindow,quadMesh->x,quadMesh->y, + viewData.pointSize,viewData.pointSize,0,360*64,dFlag); + break; + + case lineComponent: + /* anLLPoint->numOfLists == 1 here */ + anIndex = anLPoint->indices; + aLPt = refPt3D(viewData,*anIndex); + project(aLPt,quadMesh,0); + x1 = quadMesh[0].x; y1 = quadMesh[0].y; anIndex++; + for (k=1; k<anLPoint->numOfPoints; k++,anIndex++) { + aLPt = refPt3D(viewData,*anIndex); + project(aLPt,quadMesh,k); + x2 = quadMesh[k].x; y2 = quadMesh[k].y; + if (dFlag==Xoption) { + if (mono || viewport->monoOn) + GSetForeground(componentGC, (float)foregroundColor, dFlag); + else { + hue = hueValue(aLPt->c); + GSetForeground(componentGC, (float)XSolidColor(hue,2), dFlag); + } + if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) + GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); + } else { + if (dFlag==PSoption && !mono && !viewport->monoOn) { + hue = getHue(aLPt->c); + col_rgb = hlsTOrgb((float)hue,0.5,0.8); + line[0].x = x1; line[0].y = y1; + line[1].x = x2; line[1].y = y2; + PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,line,2); + } else { + if (foregroundColor == white) + GSetForeground(componentGC, 0.0, dFlag); + else + GSetForeground(componentGC, psBlack, dFlag); + if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) + GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); + } + } + x1 = x2; y1 = y2; + } /* for points in LPoints (k) */ + if (anLPoint->prop.closed) { + project(refPt3D(viewData,*(anLPoint->indices)),quadMesh, + anLPoint->numOfPoints); + x2 = quadMesh[anLPoint->numOfPoints].x; + y2 = quadMesh[anLPoint->numOfPoints].y; + if (dFlag==Xoption) { + if (mono || viewport->monoOn) + GSetForeground(componentGC, (float)foregroundColor, dFlag); + else { + hue = hueValue(aLPt->c); + GSetForeground(componentGC, (float)XSolidColor(hue,2), dFlag); + } + if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) + GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); + } + else { + if (dFlag==PSoption && !mono && !viewport->monoOn) { + hue = getHue(aLPt->c); + col_rgb = hlsTOrgb((float)hue,0.5,0.8); + line[0].x = x1; line[0].y = y1; + line[1].x = x2; line[1].y = y2; + PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,line,2); + } + else { + if (foregroundColor == white) + GSetForeground(componentGC, 0.0, dFlag); + else + GSetForeground(componentGC, psBlack, dFlag); + if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) + GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); + } + } + } + break; + + case polygonComponent: + /* first pt of polygon is a single list */ + project(refPt3D(viewData,*(anLPoint->indices)),quadMesh,0); + /* remaining points in the 2nd list (always of size 2 or greater) */ + x1 = quadMesh[0].x; y1 = quadMesh[0].y; + anLPoint = anLLPoint->lp + 1; + anIndex = anLPoint->indices; + for (k=1; k<=anLPoint->numOfPoints; k++,anIndex++) { + aLPt = refPt3D(viewData,*anIndex); + project(aLPt,quadMesh,k); + x2 = quadMesh[k].x; y2 = quadMesh[k].y; + if (dFlag==Xoption) { + if (mono || viewport->monoOn) + GSetForeground(componentGC, (float)foregroundColor, dFlag); + else { + hue = hueValue(aLPt->c); + GSetForeground(componentGC, (float)XSolidColor(hue,2), dFlag); + } + if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) + GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); + } + else { + if (dFlag==PSoption && !mono && !viewport->monoOn) { + hue = getHue(aLPt->c); + col_rgb = hlsTOrgb((float)hue,0.5,0.8); + line[0].x = x1; line[0].y = y1; + line[1].x = x2; line[1].y = y2; + PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,line,2); + } + else { + if (foregroundColor == white) + GSetForeground(componentGC, 0.0, dFlag); + else + GSetForeground(componentGC, psBlack, dFlag); + if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) + GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); + } + } + x1 = x2; y1 = y2; + } /* for points in LPoints (k) */ + project(refPt3D(viewData,*(anLLPoint->lp->indices)),quadMesh,k); + x2 = quadMesh[k].x; y2 = quadMesh[k].y; + if (dFlag==Xoption) { + if (mono || viewport->monoOn) + GSetForeground(componentGC, (float)foregroundColor, dFlag); + else { + hue = hueValue(refPt3D(viewData,*anIndex)->c); + GSetForeground(componentGC, (float)XSolidColor(hue,2), dFlag); + } + if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) + GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); + } else { + if (dFlag==PSoption && !mono && !viewport->monoOn) { + hue = getHue(refPt3D(viewData,*anIndex)->c); + col_rgb = hlsTOrgb((float)hue,0.5,0.8); + line[0].x = x1; line[0].y = y1; + line[1].x = x2; line[1].y = y2; + PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,line,2); + } + else { + if (foregroundColor == white) + GSetForeground(componentGC, 0.0, dFlag); + else + GSetForeground(componentGC, psBlack, dFlag); + if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) + GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); + } + } + /* close a polygon */ + break; + + case surfaceComponent: + if (dFlag==Xoption) { + if (mono || viewport->monoOn) + GSetForeground(componentGC, (float)foregroundColor, dFlag); + else + GSetForeground(componentGC, (float) meshOutline, dFlag); + } + else { + GSetForeground(componentGC, psBlack, dFlag); + } + + /* traverse down one direction first (all points + in a list at a time) */ + for (j=0; drawMore && j<anLLPoint->numOfLists; j++,anLPoint++) { + anIndex = anLPoint->indices; + clip_a = 0; + for (k=0, clip_i=0; + drawMore && k<anLPoint->numOfPoints; + k++, anIndex++, clip_i++) { + aLPt = refPt3D(viewData,*anIndex); + project(aLPt,quadMesh,k); + + if (behindClipPlane(aLPt->pz) || + (viewData.clipStuff && + outsideClippedBoundary(aLPt->x, aLPt->y, aLPt->z))) { + if (clip_i - clip_a > 1) { + GDrawLines(componentGC,viewport->viewWindow,(quadMesh+clip_a), + clip_i-clip_a, CoordModeOrigin, dFlag ); + } + clip_a = clip_i + 1; + } + + drawMore = keepDrawingViewport(); + } /* for points in LPoints (k) */ + if (drawMore) { + /* if drawMore is true, then the above loop terminated with + clip_i incremented properly */ + if (anLPoint->prop.closed) { + /* If closed, then do the first point again - no need to project + just copy over from the first one */ + aLPt = refPt3D(viewData,*(anLPoint->indices)); + project(aLPt,quadMesh, anLPoint->numOfPoints); + if (behindClipPlane(aLPt->pz) || + (viewData.clipStuff && + outsideClippedBoundary(aLPt->x, aLPt->y, aLPt->z))) { + if (clip_i - clip_a > 1) { + GDrawLines(componentGC, viewport->viewWindow, + (quadMesh+clip_a), clip_i-clip_a, + CoordModeOrigin, dFlag); + } + clip_a = clip_i + 1; + } + clip_i++; + } /* closed */ + if (clip_i - clip_a > 1) { + GDrawLines(componentGC, viewport->viewWindow, (quadMesh+clip_a), + clip_i-clip_a, CoordModeOrigin, dFlag); + } + } /* drawMore */ + } /* for LPoints in LLPoints (j) */ + + /* now traverse down the list in the other direction + (one point from each list at a time) */ + for (j=0; drawMore && j<anLLPoint->lp->numOfPoints; j++) { + clip_a = 0; + for (k=0, clip_i=0; + drawMore && k<anLLPoint->numOfLists; + k++, clip_i++) { + aLPt = refPt3D(viewData,*((anLLPoint->lp + k)->indices + j)); + project(aLPt, quadMesh,k); + + if (behindClipPlane(aLPt->pz) || + (viewData.clipStuff && + outsideClippedBoundary(aLPt->x, aLPt->y, aLPt->z))) { + if (clip_i - clip_a > 1) { + GDrawLines(componentGC,viewport->viewWindow,quadMesh+clip_a, + clip_i-clip_a, CoordModeOrigin, dFlag ); + } + clip_a = clip_i + 1; + } + drawMore = keepDrawingViewport(); + } /* for points in LPoints (k) */ + + if (drawMore) { + /* if drawMore is true, then the above loop terminated with + clip_i incremented properly */ + if (anLLPoint->prop.closed) { + /* if closed, do the first point again - no need to project + just copy over from the first one */ + aLPt = refPt3D(viewData,*((anLLPoint->lp + 0)->indices + j)); + project(aLPt, quadMesh, anLLPoint->numOfLists); + if (behindClipPlane(aLPt->pz) || + (viewData.clipStuff && + outsideClippedBoundary(aLPt->x, aLPt->y, aLPt->z))) { + if (clip_i - clip_a > 1) { + GDrawLines(componentGC, viewport->viewWindow, + quadMesh + clip_a, clip_i - clip_a, + CoordModeOrigin, dFlag); + } + clip_a = clip_i + 1; + } + clip_i++; + } /* closed */ + if (clip_i - clip_a > 1) { + GDrawLines(componentGC, viewport->viewWindow, quadMesh+clip_a, + clip_i-clip_a, CoordModeOrigin, dFlag); + } + } /* drawMore */ + } /* for a point in each LPoint (j) */ + break; + } /* switch componentType */ + } /* for LLPoints in LLLPoints (i) */ + break; + + case opaqueMesh: + if (dFlag==Xoption) { + GSetForeground(globGC, (float)opaqueForeground, dFlag); + GSetForeground(opaqueGC, (float)opaqueOutline, dFlag); + } + else { + GSetForeground(globGC, psBlack, dFlag); + GSetForeground(opaqueGC, psBlack, dFlag); + } + GSetLineAttributes(opaqueGC,0,LineSolid,CapButt,JoinRound,dFlag); + drawPolygons(dFlag); + break; + + case render: + if (viewData.outlineRenderOn) { + GSetLineAttributes(renderGC,0,LineSolid,CapButt,JoinRound,dFlag); + if (dFlag==Xoption) GSetForeground(renderGC,(float)black, dFlag); + else GSetForeground(renderGC,psBlack, dFlag ); + } + drawPolygons(dFlag); + break; + + case smooth: + drawPhong(dFlag); + break; + + } /* switch on style */ + +} /* draw3DComponents() */ + diff --git a/src/graph/view3D/component3d.c.pamphlet b/src/graph/view3D/component3d.c.pamphlet deleted file mode 100644 index 258c5589..00000000 --- a/src/graph/view3D/component3d.c.pamphlet +++ /dev/null @@ -1,907 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D component3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _COMPONENT3D_C -#include "axiom-c-macros.h" - -#include "header.h" -#include "draw.h" - -#include "Gfun.H1" -#include "util.H1" -#include "XSpadFill.H1" - -#include "all_3d.H1" - -#define axisLength 1.0 /* use 100.0, if data is not to be normalized */ - -#define samePoint(a,b) ((refPt3D(viewData,a)->x == refPt3D(viewData,b)->x) &&\ - (refPt3D(viewData,a)->y == refPt3D(viewData,b)->y) &&\ - (refPt3D(viewData,a)->z == refPt3D(viewData,b)->z)) -#define MAX_POINT 1000.0 -#define MIN_POINT -1000.0 - - -void -#ifdef _NO_PROTO -scaleComponents () -#else -scaleComponents (void) -#endif -{ - - double xRange,yRange,zRange; - int i; - viewTriple *aPoint; - - /* Temporary range limits until the three dimensional clipping - package is fully functional */ - - if (viewData.xmin < MIN_POINT) viewData.xmin = MIN_POINT; - if (viewData.xmax > MAX_POINT) viewData.xmax = MAX_POINT; - if (viewData.ymin < MIN_POINT) viewData.ymin = MIN_POINT; - if (viewData.ymax > MAX_POINT) viewData.ymax = MAX_POINT; - if (viewData.zmin < MIN_POINT) viewData.zmin = MIN_POINT; - if (viewData.zmax > MAX_POINT) viewData.zmax = MAX_POINT; - - xRange = viewData.xmax - viewData.xmin; - yRange = viewData.ymax - viewData.ymin; - zRange = viewData.zmax - viewData.zmin; - - /* We scale down, normalize the data, if it is coming from AXIOM - (handled by viewman). If the data is coming from a file (handled by - viewAlone) then it should already been scaled down. - */ - - /* Find the coordinate axis with the larges range of data and scale - the others relative to it. - */ - /* compare x and y ranges */ - if (xRange > yRange) { - if (xRange > zRange) { - if (absolute(viewData.xmax) >= absolute(viewData.xmin)) - viewData.scaleToView = axisLength/(absolute(viewData.xmax)); - else - viewData.scaleToView = axisLength/(absolute(viewData.xmin)); - } else { - if (absolute(viewData.zmax) >= absolute(viewData.zmin)) - viewData.scaleToView = axisLength/(absolute(viewData.zmax)); - else - viewData.scaleToView = axisLength/(absolute(viewData.zmin)); - } - } else { - if (yRange > zRange) { - if (absolute(viewData.ymax) >= absolute(viewData.ymin)) - viewData.scaleToView = axisLength/(absolute(viewData.ymax)); - else - viewData.scaleToView = axisLength/(absolute(viewData.ymin)); - } else { - if (absolute(viewData.zmax) >= absolute(viewData.zmin)) - viewData.scaleToView = axisLength/(absolute(viewData.zmax)); - else - viewData.scaleToView = axisLength/(absolute(viewData.zmin)); - } - } - - /* We now normalize all the points in this program. The information - needed to link the normalized set of points back to the real object - space scale created in AXIOM is held in viewData.scaleToView. */ - viewData.xmin *= viewData.scaleToView; - viewData.xmax *= viewData.scaleToView; - viewData.ymin *= viewData.scaleToView; - viewData.ymax *= viewData.scaleToView; - viewData.zmin *= viewData.scaleToView; - viewData.zmax *= viewData.scaleToView; - viewData.clipXmin = viewData.xmin; - viewData.clipXmax = viewData.xmax; - viewData.clipYmin = viewData.ymin; - viewData.clipYmax = viewData.ymax; - viewData.clipZmin = viewData.zmin; - viewData.clipZmax = viewData.zmax; - - for (i=0, aPoint=viewData.points; i<viewData.numOfPoints; i++,aPoint++) { - aPoint->x *= viewData.scaleToView; - aPoint->y *= viewData.scaleToView; - aPoint->z *= viewData.scaleToView; - } - -} /* scaleComponents() */ - - -/* - void makeTriangle(a,b,c) - Given three indices to three points, a triangular polygon is created - and inserted into the polygon list of viewData. If two or more of the - points are coincidental, no polygon is created since that would be a - degenerate (collapsed) polygon. - */ - -void -#ifdef _NO_PROTO -makeTriangle (a, b, c) - int a,b,c; -#else -makeTriangle (int a, int b, int c) -#endif -{ - poly *aPoly; - - if (!(samePoint(a,b) || samePoint(b,c) || samePoint(c,a))) { - /* create triangle only if the three vertex points are distinct */ - aPoly = (poly *)saymem("component.c",1,sizeof(poly)); - aPoly->num = aPoly->sortNum = viewData.numPolygons++; - aPoly->split = aPoly->moved = no; - aPoly->numpts = 3; - aPoly->primitiveType = polygonComponent; - aPoly->indexPtr = (int *)saymem("component.c",3,sizeof(int)); - *(aPoly->indexPtr) = a; - *(aPoly->indexPtr + 1) = b; - *(aPoly->indexPtr + 2) = c; - aPoly->doNotStopDraw = yes; - aPoly->next = viewData.polygons; - viewData.polygons = aPoly; - } /* if all points are unique */ - -} /* makeTriangle() */ - - - - -/* - void triangulate() - - Only if there is more than one list do we triangulate; a single list - is used for either a space curve or simply a point. Actually, in that - case, we now make "flat" *polygons, flagged by the primitiveType field - (pointComponent, etc. in tube.h). We need to examine two lists at a time - (and if the structure is closed, the last and first as well). For every - three points in the two lists, alternating between one in one and two in - the other, we construct triangles. If one list is shorter, then its last - point becomes the vertex for the remaining pairs of points from the other - list. It turns out that any distribution of points in the two lists - (preserving cyclic order) will produce the same desired polygon. - */ - -void -#ifdef _NO_PROTO -triangulate () -#else -triangulate (void) -#endif -{ - - int u,l; - int uBound,lBound; - int i,j,k; - LLPoint *anLLPoint; - LPoint *list1,*list2; - poly *aPoly; - - anLLPoint = viewData.lllp.llp; - for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) { - if (anLLPoint->numOfLists > 1) { - list2 = anLLPoint->lp; - for (j=1; j<anLLPoint->numOfLists; j++) { - list1 = list2; - list2 = list1 + 1; - u = l = 0; - uBound = u+1 < list1->numOfPoints; - lBound = l+1 < list2->numOfPoints; - while (uBound || lBound) { - if (uBound) { - makeTriangle(*(list1->indices + u + 1), - *(list1->indices + u), *(list2->indices + l)); - u++; - uBound = u+1 < list1->numOfPoints; - } - if (lBound) { - makeTriangle(*(list2->indices + l), - *(list2->indices + l + 1), *(list1->indices + u)); - l++; - lBound = l+1 < list2->numOfPoints; - } - } /* while (uBound || lBound) */ - } /* for j<anLLPoint->numOfLists */ - } /* if anLLPoint->numOfLists > 1 */ - else { - /* if anLLPoint->numOfLists <= 1...assume this means =1 */ - /* Flat polygons are to be drawn when hidden - surface algorithm is used.*/ - if (anLLPoint->numOfLists == 1) { - if (anLLPoint->lp->numOfPoints == 1) { - /* this graph is a single point */ - aPoly = (poly *)saymem("component.c",1,sizeof(poly)); - aPoly->num = aPoly->sortNum = viewData.numPolygons++; - aPoly->split = aPoly->moved = no; - aPoly->primitiveType = pointComponent; - aPoly->numpts = 1; - aPoly->indexPtr = (int *)saymem("component.c",1,intSize); - *(aPoly->indexPtr) = *(anLLPoint->lp->indices); - aPoly->doNotStopDraw = yes; - aPoly->next = viewData.polygons; - viewData.polygons = aPoly; - } else { - /* this graph is a curve */ - for (k=0; k<anLLPoint->lp->numOfPoints-1; k++) { - aPoly = (poly *)saymem("component.c",1,sizeof(poly)); - aPoly->num = aPoly->sortNum = viewData.numPolygons++; - aPoly->split = aPoly->moved = no; - aPoly->primitiveType = lineComponent; /* curveComponent */ - aPoly->numpts = 2; - aPoly->indexPtr = - (int *)saymem("component.c",2,sizeof(int)); - *(aPoly->indexPtr) = *(anLLPoint->lp->indices + k); - *(aPoly->indexPtr+1) = *(anLLPoint->lp->indices + k + 1); - aPoly->doNotStopDraw = yes; - aPoly->next = viewData.polygons; - viewData.polygons = aPoly; - } /* for k */ - if (anLLPoint->lp->prop.closed) { - aPoly = (poly *)saymem("component.c",1,sizeof(poly)); - aPoly->num = aPoly->sortNum = viewData.numPolygons++; - aPoly->split = aPoly->moved = no; - aPoly->primitiveType = lineComponent; /* curveComponent */ - aPoly->numpts = 2; - aPoly->indexPtr = - (int *)saymem("component.c",2,sizeof(int)); - *(aPoly->indexPtr) = *(anLLPoint->lp->indices + k); - *(aPoly->indexPtr+1) = *(anLLPoint->lp->indices); - aPoly->doNotStopDraw = yes; - aPoly->next = viewData.polygons; - viewData.polygons = aPoly; - } /* if list of points is closed */ - } /* else */ - } /* point, line, polygon, surface components are taken care of above */ - } /* else anLLPoint->numOfLists <= 1 */ - } /* for LLPoints in LLLPoints (i) */ - -} /* triangulate */ - - - -void -#ifdef _NO_PROTO -readComponentsFromViewman () -#else -readComponentsFromViewman (void) -#endif -{ - int i,j,k; - LLPoint *anLLPoint; - LPoint *anLPoint; - viewTriple *aPoint; - /* maxLength holds the max(llp,lp) figure regarding how large to - make the array of XPoints, i.e. quadMesh, for use in calling XDraw(). */ - int maxLength=0; - - int *anIndex; - - readViewman(&(viewData.numOfPoints),intSize); - aPoint = viewData.points = - (viewTriple *)saymem("component.c",viewData.numOfPoints, - sizeof(viewTriple)); - for (i=0; i<viewData.numOfPoints; i++, aPoint++) { - readViewman(&(aPoint->x),floatSize); - readViewman(&(aPoint->y),floatSize); - readViewman(&(aPoint->z),floatSize); - readViewman(&(aPoint->c),floatSize); -#ifdef NANQ_DEBUG - if (!(aPoint->z < 0) && !(aPoint->z > 0) && !(aPoint->z == 0)) - fprintf(stderr,"%g\n", aPoint->z); -#endif - } - - readViewman(&(viewData.lllp.numOfComponents),intSize); - anLLPoint = viewData.lllp.llp = - (LLPoint *)saymem("component.c, i",viewData.lllp.numOfComponents, - sizeof(LLPoint)); - for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) { - readViewman(&(anLLPoint->prop.closed),intSize); - readViewman(&(anLLPoint->prop.solid),intSize); - readViewman(&(anLLPoint->numOfLists),intSize); - anLPoint = anLLPoint->lp = - (LPoint *)saymem("component.c, ii",anLLPoint->numOfLists, - sizeof(LPoint)); - for (j=0; j<anLLPoint->numOfLists; j++,anLPoint++) { - if (anLLPoint->numOfLists > maxLength) - maxLength = anLLPoint->numOfLists; - readViewman(&(anLPoint->prop.closed),intSize); - readViewman(&(anLPoint->prop.solid),intSize); - readViewman(&(anLPoint->numOfPoints),intSize); - anIndex = anLPoint->indices = - (int *)saymem("component.c, index",anLPoint->numOfPoints,intSize); - if (anLPoint->numOfPoints > maxLength) - maxLength = anLPoint->numOfPoints; - for (k=0; k<anLPoint->numOfPoints; k++,anIndex++) { - readViewman(anIndex,intSize); - /* AXIOM arrays are one based, C arrays are zero based */ - if (!viewAloned) (*anIndex)--; - } - } /* for LPoints in LLPoints (j) */ - } /* for LLPoints in LLLPoints (i) */ - - quadMesh = (XPoint *)saymem("component.c",maxLength+2,sizeof(XPoint)); - -} /* readComponentsFromViewman() */ - - - -/* - void calcNormData() * - Calculates the surface normals for the polygons that make up the tube. - Also finds the fourth coefficient to the plane equation: - Ax + By + Cz + D = 0 - A,B, and C are in the normal N[3] and D is the planeConst. - Figures out the color as well (from the average of the points) and - resets the moved flag - */ - -void -#ifdef _NO_PROTO -calcNormData () -#else -calcNormData (void) -#endif -{ - - poly *aPoly; - int *index; - - for (aPoly = viewData.polygons; aPoly != NIL(poly); aPoly = aPoly->next) { - index = aPoly->indexPtr; - switch (aPoly->primitiveType) { - case pointComponent: - case lineComponent: - aPoly->moved = 0; - aPoly->color = refPt3D(viewData,*index)->c; - break; - default: - /* - The following line takes 3 consecutive points and asks - for the normal vector defined by them. This assumes that - these do not contain co-linear points. For some reason, - co-linear points are allowed, this needs to be changed. - */ - getMeshNormal(refPt3D(viewData,*index)->x, - refPt3D(viewData,*index)->y, - refPt3D(viewData,*index)->z, - refPt3D(viewData,*(index+1))->x, - refPt3D(viewData,*(index+1))->y, - refPt3D(viewData,*(index+1))->z, - refPt3D(viewData,*(index+2))->x, - refPt3D(viewData,*(index+2))->y, - refPt3D(viewData,*(index+2))->z, 0.0, 1.0, aPoly->N); - - /* calculate the constant term, D, for the plane equation */ - aPoly->planeConst = - -(aPoly->N[0] * refPt3D(viewData,*index)->x + - aPoly->N[1] * refPt3D(viewData,*index)->y + - aPoly->N[2] * refPt3D(viewData,*index)->z); - aPoly->moved = 0; - aPoly->color = (refPt3D(viewData,*index)->c + - (refPt3D(viewData,*(index+1)))->c + - (refPt3D(viewData,*(index+2)))->c) / 3.0; - break; - } /* switch */ - } - -} /* calcNormData() */ - - - -/* - viewPoints *make3DComponents() - - Read in all the 3D data from the viewport manager and construct the - model of it. The model is based upon a list of lists of lists of points. - Each top level list makes a component in 3-space. The interpretation - really begins at the level below that, where the list of lists of - points is. For 3D explicit equations of two variables, the closed - boolean for this level is False and the closed boolean for each sublist - is False as well. For 3D parameterized curves of one variable, the - closed boolean for this level is defined by the user from AXIOM , - (which defaults to False) and the closed boolean for each sublist is True. - */ - -viewPoints * -#ifdef _NO_PROTO -make3DComponents () -#else -make3DComponents (void) -#endif -{ - viewPoints *graphData; - - readComponentsFromViewman(); - - /* The initial boundaries for the clipping region are set to those - of the boundaries of the data region. */ - viewData.clipXmin = viewData.xmin; viewData.clipXmax = viewData.xmax; - viewData.clipYmin = viewData.ymin; viewData.clipYmax = viewData.ymax; - viewData.clipZmin = viewData.zmin; viewData.clipZmax = viewData.zmax; - - /* normalize the data coordinates */ - if (viewData.scaleDown) scaleComponents(); - viewData.numPolygons = 0; - /* initially the list of polygons is empty */ - viewData.polygons = NIL(poly); - /* create the polygons; (sets viewData.polygons and viewData.numPolygons) */ - triangulate(); - /* calculate the plane equations for all the polygons */ - calcNormData(); - - graphData = makeViewport(); - - imageX = XCreateImage(/* display */ dsply, - /* visual */ DefaultVisual(dsply,scrn), - /* depth */ DefaultDepth(dsply,scrn), - /* format */ ZPixmap, - /* offset */ 0, - /* data */ NULL, - /* width */ vwInfo.width, - /* height */ 1, - /* bitmap_pad */ 32, - /* bytes_per_line */ 0); - imageX->data = NIL(char); - - /* windowing displaying */ - writeTitle(); - postMakeViewport(); - drawViewport(Xoption); - firstTime = yes; - XMapWindow(dsply, graphData->viewWindow); - XMapWindow(dsply, graphData->titleWindow); - XFlush(dsply); - - return(graphData); - -} /* make3DComponents */ - - - - - -void -#ifdef _NO_PROTO -draw3DComponents (dFlag) - int dFlag; -#else -draw3DComponents (int dFlag) -#endif -{ - - int i, j, k, hue, x1, y1, x2, y2; - LLPoint *anLLPoint; - LPoint *anLPoint; - int *anIndex; - int componentType; /* what the component is to be interpreted as */ - int clip_a,clip_i; /* for use in wire mesh mode clipping */ - XEvent peekEvent; - viewTriple *aLPt; - XPoint line[2]; - RGB col_rgb; - - calcEyePoint(); - while ((XPending(dsply) > 0) && (scanline > 0)) - XNextEvent(dsply,&peekEvent); - switch (viewData.style) { - - case transparent: - GSetLineAttributes(componentGC,0,LineSolid,CapButt,JoinMiter,dFlag); - if (dFlag==Xoption) { - if (mono || viewport->monoOn) - GSetForeground(componentGC, (float)foregroundColor, dFlag); - else - GSetForeground(componentGC, (float) meshOutline, dFlag); - } else { - GSetForeground(componentGC, psBlack, dFlag); - } - /* no need to check "keep drawing" for ps */ - if (dFlag == Xoption) drawMore = keepDrawingViewport(); - - /* - This is where we interpret the list of lists of lists of points struct. - We want to extract the following forms of data: - - individual points (drawn as filled points) - - lines (space curves) - - defined polygon primitives - - surfaces - the last one is the one that will replace the function of 2 variables, - tubes as well as 3D parameterized functions of 2 variables. - Since there could be many other ways of constructing L L L Pts - much - more than could be usefully interpreted - any other formats are - currently not allowed. When they are, this comment should be updated - appropriately. - - ************************************************************************ - - Traverse each component. - We decide here, before we begin traversing the - component what we want to interpret it as. - Here's the convention used to figure that out: - - points: #anLLPoint->numOfLists was 1 - #anLPoint->numOfPoints is 1 - - lines: #anLLPoint->numOfLists was 1 - #anLPoint->numOfPoints > 1 - - polygons: #anLLPoint->numOfLists was 2 - #anLPoint->numOfPoints is 1 - - surface: #anLLPoint->numOfLists was some m>1 - #anLPoint->numOfPoints all point lists are the same. - - */ - - anLLPoint = viewData.lllp.llp; - for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) { - /* initially, component type is unknown */ - componentType = stillDontKnow; - if (anLLPoint->numOfLists == 1) { - if (anLLPoint->lp->numOfPoints == 1) componentType = pointComponent; - else componentType = lineComponent; - } else if (anLLPoint->numOfLists == 2) { - if ((anLLPoint->lp->numOfPoints == 1) && - ((anLLPoint->lp+1)->numOfPoints > 2)) - componentType = polygonComponent; - } - /* Check for corrupt data and NaN data is made in AXIOM . */ - if (componentType == stillDontKnow) - componentType = surfaceComponent; - - anLPoint = anLLPoint->lp; - - switch (componentType) { - - case pointComponent: - /* anLLPoint->numOfLists == anLLPoint->lp->numOfPoints == 1 here */ - aLPt = refPt3D(viewData,*(anLPoint->indices)); - project(aLPt,quadMesh,0); - if (dFlag==Xoption) { - if (mono || viewport->monoOn) - GSetForeground(componentGC, (float)foregroundColor, dFlag); - else { - hue = hueValue(aLPt->c); - GSetForeground(componentGC, (float)XSolidColor(hue,2), dFlag); - } - } else GSetForeground(componentGC, psBlack, dFlag); - GFillArc(componentGC,viewport->viewWindow,quadMesh->x,quadMesh->y, - viewData.pointSize,viewData.pointSize,0,360*64,dFlag); - break; - - case lineComponent: - /* anLLPoint->numOfLists == 1 here */ - anIndex = anLPoint->indices; - aLPt = refPt3D(viewData,*anIndex); - project(aLPt,quadMesh,0); - x1 = quadMesh[0].x; y1 = quadMesh[0].y; anIndex++; - for (k=1; k<anLPoint->numOfPoints; k++,anIndex++) { - aLPt = refPt3D(viewData,*anIndex); - project(aLPt,quadMesh,k); - x2 = quadMesh[k].x; y2 = quadMesh[k].y; - if (dFlag==Xoption) { - if (mono || viewport->monoOn) - GSetForeground(componentGC, (float)foregroundColor, dFlag); - else { - hue = hueValue(aLPt->c); - GSetForeground(componentGC, (float)XSolidColor(hue,2), dFlag); - } - if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) - GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); - } else { - if (dFlag==PSoption && !mono && !viewport->monoOn) { - hue = getHue(aLPt->c); - col_rgb = hlsTOrgb((float)hue,0.5,0.8); - line[0].x = x1; line[0].y = y1; - line[1].x = x2; line[1].y = y2; - PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,line,2); - } else { - if (foregroundColor == white) - GSetForeground(componentGC, 0.0, dFlag); - else - GSetForeground(componentGC, psBlack, dFlag); - if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) - GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); - } - } - x1 = x2; y1 = y2; - } /* for points in LPoints (k) */ - if (anLPoint->prop.closed) { - project(refPt3D(viewData,*(anLPoint->indices)),quadMesh, - anLPoint->numOfPoints); - x2 = quadMesh[anLPoint->numOfPoints].x; - y2 = quadMesh[anLPoint->numOfPoints].y; - if (dFlag==Xoption) { - if (mono || viewport->monoOn) - GSetForeground(componentGC, (float)foregroundColor, dFlag); - else { - hue = hueValue(aLPt->c); - GSetForeground(componentGC, (float)XSolidColor(hue,2), dFlag); - } - if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) - GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); - } - else { - if (dFlag==PSoption && !mono && !viewport->monoOn) { - hue = getHue(aLPt->c); - col_rgb = hlsTOrgb((float)hue,0.5,0.8); - line[0].x = x1; line[0].y = y1; - line[1].x = x2; line[1].y = y2; - PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,line,2); - } - else { - if (foregroundColor == white) - GSetForeground(componentGC, 0.0, dFlag); - else - GSetForeground(componentGC, psBlack, dFlag); - if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) - GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); - } - } - } - break; - - case polygonComponent: - /* first pt of polygon is a single list */ - project(refPt3D(viewData,*(anLPoint->indices)),quadMesh,0); - /* remaining points in the 2nd list (always of size 2 or greater) */ - x1 = quadMesh[0].x; y1 = quadMesh[0].y; - anLPoint = anLLPoint->lp + 1; - anIndex = anLPoint->indices; - for (k=1; k<=anLPoint->numOfPoints; k++,anIndex++) { - aLPt = refPt3D(viewData,*anIndex); - project(aLPt,quadMesh,k); - x2 = quadMesh[k].x; y2 = quadMesh[k].y; - if (dFlag==Xoption) { - if (mono || viewport->monoOn) - GSetForeground(componentGC, (float)foregroundColor, dFlag); - else { - hue = hueValue(aLPt->c); - GSetForeground(componentGC, (float)XSolidColor(hue,2), dFlag); - } - if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) - GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); - } - else { - if (dFlag==PSoption && !mono && !viewport->monoOn) { - hue = getHue(aLPt->c); - col_rgb = hlsTOrgb((float)hue,0.5,0.8); - line[0].x = x1; line[0].y = y1; - line[1].x = x2; line[1].y = y2; - PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,line,2); - } - else { - if (foregroundColor == white) - GSetForeground(componentGC, 0.0, dFlag); - else - GSetForeground(componentGC, psBlack, dFlag); - if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) - GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); - } - } - x1 = x2; y1 = y2; - } /* for points in LPoints (k) */ - project(refPt3D(viewData,*(anLLPoint->lp->indices)),quadMesh,k); - x2 = quadMesh[k].x; y2 = quadMesh[k].y; - if (dFlag==Xoption) { - if (mono || viewport->monoOn) - GSetForeground(componentGC, (float)foregroundColor, dFlag); - else { - hue = hueValue(refPt3D(viewData,*anIndex)->c); - GSetForeground(componentGC, (float)XSolidColor(hue,2), dFlag); - } - if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) - GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); - } else { - if (dFlag==PSoption && !mono && !viewport->monoOn) { - hue = getHue(refPt3D(viewData,*anIndex)->c); - col_rgb = hlsTOrgb((float)hue,0.5,0.8); - line[0].x = x1; line[0].y = y1; - line[1].x = x2; line[1].y = y2; - PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,line,2); - } - else { - if (foregroundColor == white) - GSetForeground(componentGC, 0.0, dFlag); - else - GSetForeground(componentGC, psBlack, dFlag); - if (!eqNANQ(x1) && !eqNANQ(y1) && !eqNANQ(x2) && !eqNANQ(y2)) - GDrawLine(componentGC,viewport->viewWindow,x1,y1,x2,y2,dFlag); - } - } - /* close a polygon */ - break; - - case surfaceComponent: - if (dFlag==Xoption) { - if (mono || viewport->monoOn) - GSetForeground(componentGC, (float)foregroundColor, dFlag); - else - GSetForeground(componentGC, (float) meshOutline, dFlag); - } - else { - GSetForeground(componentGC, psBlack, dFlag); - } - - /* traverse down one direction first (all points - in a list at a time) */ - for (j=0; drawMore && j<anLLPoint->numOfLists; j++,anLPoint++) { - anIndex = anLPoint->indices; - clip_a = 0; - for (k=0, clip_i=0; - drawMore && k<anLPoint->numOfPoints; - k++, anIndex++, clip_i++) { - aLPt = refPt3D(viewData,*anIndex); - project(aLPt,quadMesh,k); - - if (behindClipPlane(aLPt->pz) || - (viewData.clipStuff && - outsideClippedBoundary(aLPt->x, aLPt->y, aLPt->z))) { - if (clip_i - clip_a > 1) { - GDrawLines(componentGC,viewport->viewWindow,(quadMesh+clip_a), - clip_i-clip_a, CoordModeOrigin, dFlag ); - } - clip_a = clip_i + 1; - } - - drawMore = keepDrawingViewport(); - } /* for points in LPoints (k) */ - if (drawMore) { - /* if drawMore is true, then the above loop terminated with - clip_i incremented properly */ - if (anLPoint->prop.closed) { - /* If closed, then do the first point again - no need to project - just copy over from the first one */ - aLPt = refPt3D(viewData,*(anLPoint->indices)); - project(aLPt,quadMesh, anLPoint->numOfPoints); - if (behindClipPlane(aLPt->pz) || - (viewData.clipStuff && - outsideClippedBoundary(aLPt->x, aLPt->y, aLPt->z))) { - if (clip_i - clip_a > 1) { - GDrawLines(componentGC, viewport->viewWindow, - (quadMesh+clip_a), clip_i-clip_a, - CoordModeOrigin, dFlag); - } - clip_a = clip_i + 1; - } - clip_i++; - } /* closed */ - if (clip_i - clip_a > 1) { - GDrawLines(componentGC, viewport->viewWindow, (quadMesh+clip_a), - clip_i-clip_a, CoordModeOrigin, dFlag); - } - } /* drawMore */ - } /* for LPoints in LLPoints (j) */ - - /* now traverse down the list in the other direction - (one point from each list at a time) */ - for (j=0; drawMore && j<anLLPoint->lp->numOfPoints; j++) { - clip_a = 0; - for (k=0, clip_i=0; - drawMore && k<anLLPoint->numOfLists; - k++, clip_i++) { - aLPt = refPt3D(viewData,*((anLLPoint->lp + k)->indices + j)); - project(aLPt, quadMesh,k); - - if (behindClipPlane(aLPt->pz) || - (viewData.clipStuff && - outsideClippedBoundary(aLPt->x, aLPt->y, aLPt->z))) { - if (clip_i - clip_a > 1) { - GDrawLines(componentGC,viewport->viewWindow,quadMesh+clip_a, - clip_i-clip_a, CoordModeOrigin, dFlag ); - } - clip_a = clip_i + 1; - } - drawMore = keepDrawingViewport(); - } /* for points in LPoints (k) */ - - if (drawMore) { - /* if drawMore is true, then the above loop terminated with - clip_i incremented properly */ - if (anLLPoint->prop.closed) { - /* if closed, do the first point again - no need to project - just copy over from the first one */ - aLPt = refPt3D(viewData,*((anLLPoint->lp + 0)->indices + j)); - project(aLPt, quadMesh, anLLPoint->numOfLists); - if (behindClipPlane(aLPt->pz) || - (viewData.clipStuff && - outsideClippedBoundary(aLPt->x, aLPt->y, aLPt->z))) { - if (clip_i - clip_a > 1) { - GDrawLines(componentGC, viewport->viewWindow, - quadMesh + clip_a, clip_i - clip_a, - CoordModeOrigin, dFlag); - } - clip_a = clip_i + 1; - } - clip_i++; - } /* closed */ - if (clip_i - clip_a > 1) { - GDrawLines(componentGC, viewport->viewWindow, quadMesh+clip_a, - clip_i-clip_a, CoordModeOrigin, dFlag); - } - } /* drawMore */ - } /* for a point in each LPoint (j) */ - break; - } /* switch componentType */ - } /* for LLPoints in LLLPoints (i) */ - break; - - case opaqueMesh: - if (dFlag==Xoption) { - GSetForeground(globGC, (float)opaqueForeground, dFlag); - GSetForeground(opaqueGC, (float)opaqueOutline, dFlag); - } - else { - GSetForeground(globGC, psBlack, dFlag); - GSetForeground(opaqueGC, psBlack, dFlag); - } - GSetLineAttributes(opaqueGC,0,LineSolid,CapButt,JoinRound,dFlag); - drawPolygons(dFlag); - break; - - case render: - if (viewData.outlineRenderOn) { - GSetLineAttributes(renderGC,0,LineSolid,CapButt,JoinRound,dFlag); - if (dFlag==Xoption) GSetForeground(renderGC,(float)black, dFlag); - else GSetForeground(renderGC,psBlack, dFlag ); - } - drawPolygons(dFlag); - break; - - case smooth: - drawPhong(dFlag); - break; - - } /* switch on style */ - -} /* draw3DComponents() */ - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/contour.h b/src/graph/view3D/contour.h index d037c442..0a713c68 100755..100644 --- a/src/graph/view3D/contour.h +++ b/src/graph/view3D/contour.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + all rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ diff --git a/src/graph/view3D/contour3d.c.out b/src/graph/view3D/contour3d.c.out index 14e791e2..14e791e2 100755..100644 --- a/src/graph/view3D/contour3d.c.out +++ b/src/graph/view3D/contour3d.c.out diff --git a/src/graph/view3D/contour_panel3d.c.out b/src/graph/view3D/contour_panel3d.c.out index 45709849..45709849 100755..100644 --- a/src/graph/view3D/contour_panel3d.c.out +++ b/src/graph/view3D/contour_panel3d.c.out diff --git a/src/graph/view3D/control3d.c b/src/graph/view3D/control3d.c new file mode 100644 index 00000000..3544484c --- /dev/null +++ b/src/graph/view3D/control3d.c @@ -0,0 +1,1056 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _CONTROL3D_C +#include "axiom-c-macros.h" + +#include <string.h> +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> + +#include "mouse11.bitmap" +#include "mouse11.mask" + +#include "header.h" +#include "cpanel.h" + +#include "util.H1" +#include "XShade.H1" +#include "XSpadFill.H1" +#include "Gfun.H1" +#include "all_3d.H1" + +/* Defines the pixmap for the arrow displayed in the scale window */ +#define zoomArrowN 11 +static XPoint zoomArrow[zoomArrowN] = { + {29,14},{38,23},{33,23}, + {40,45},{53,45}, + {29,69}, + {5,45},{18,45}, + {25,23},{20,23},{29,14} }; + +/* Defines the pixmap for the arrows displayed in the translate window */ +#define translateArrowN 25 +static XPoint translateArrow[translateArrowN] = { + {55,2},{60,10},{58,10},{58,37}, + {85,37},{85,35},{93,40},{85,45},{85,43},{58,43}, + {58,70},{60,70},{55,78},{50,70},{52,70},{52,43}, + {25,43},{25,45},{17,40},{25,35},{25,37},{52,37}, + {52,10},{50,10},{55,2} }; + +static int rotateX, rotateY, rotateR; + +/* + void drawColorMap () + */ + +void +#ifdef _NO_PROTO +drawColorMap () +#else +drawColorMap (void) +#endif +{ + + controlPanelStruct *cp; + int i,shadeWidth; + + /* Draw the color map window */ + + cp = viewport->controlPanel; + + XClearArea(dsply,cp->controlWindow,5,colormapY,colormapW,colormapH,False); + + /* if window is grayscale, show the grayscale colormap */ + if (mono || (viewport->monoOn)) { + shadeWidth = 230/maxGreyShade; + for (i=0; i<maxGreyShade; i++) { + XChangeShade(dsply, i); + XShadeRectangle(dsply,cp->controlWindow, + colormapX + colorOffsetX + i*shadeWidth, + colormapY + colorOffsetY - 10, shadeWidth, 40); + } + } else { + GDrawString(globalGC2,cp->controlWindow,colorWidth, + colormapY + 13,"-",1,Xoption); + GDrawString(globalGC2,cp->controlWindow,30*colorWidth + 40, + colormapY + 13,"+",1,Xoption); + GDrawString(globalGC2,cp->controlWindow,colorWidth, + colormapY + 46,"-",1,Xoption); + GDrawString(globalGC2,cp->controlWindow,30*colorWidth + 40, + colormapY + 46,"+",1,Xoption); + for (i=0; i<totalHues; i++) { + GSetForeground(anotherGC, (float)XSolidColor(i,2), Xoption); + GDrawLine(anotherGC,cp->controlWindow, + colormapX + i*colorWidth + colorOffsetX, + colormapY + colorOffsetY, + colormapX + i*colorWidth + colorOffsetX, + colormapY + colorOffsetY + colorHeight,Xoption); + } + + if (viewport->hueTop > totalHues-1) viewport->hueTop = totalHues-1; + if (viewport->hueOffset > totalHues-1) viewport->hueOffset = totalHues-1; + + GSetForeground(globGC, (float)monoColor(7), Xoption); + /* Bottom (zmin) color indicator */ + GDrawLine(globGC,cp->controlWindow, + colormapX + viewport->hueOffset * colorWidth + colorOffsetX, + colormapY + colorOffsetY+colorHeight, + colormapX + viewport->hueOffset * colorWidth + colorOffsetX, + colormapY + colorOffsetY+colorHeight+colorPointer,Xoption); + + /* Top (zmax) color indicator */ + GDrawLine(globGC,cp->controlWindow, + colormapX + viewport->hueTop * colorWidth+colorOffsetX, + colormapY + colorOffsetY, + colormapX + viewport->hueTop * colorWidth+colorOffsetX, + colormapY + colorOffsetY-colorPointer,Xoption); + + /* Connect the bottom and top color indicator bars */ + GSetForeground(globGC, (float)monoColor(0), Xoption); + GDrawLine(globGC,cp->controlWindow, + colormapX + viewport->hueOffset * colorWidth + colorOffsetX, + colormapY + colorOffsetY+colorHeight, + colormapX + viewport->hueTop * colorWidth+colorOffsetX, + colormapY + colorOffsetY,Xoption); + } + XSync(dsply,0); + +} /* drawColorMap() */ + + +/******************************* + * void writeControlTitle(w) * + * * + * We need the window argument * + * here because there are * + * multiple control panels in * + * 3D. * + *******************************/ + +void +#ifdef _NO_PROTO +writeControlTitle (w) + Window w; +#else +writeControlTitle (Window w) +#endif +{ + int strlength; + + s = viewport->title; + strlength = strlen(s); + XClearArea(dsply,w,0,0,controlWidth,potA,False); + + GSetForeground(anotherGC,(float)controlTitleColor,Xoption); + GDrawString(anotherGC,w,centerX(anotherGC,s,strlength,controlWidth), + 15,s,strlength,Xoption); + +} /* writeControlTitle() */ + + +/************************************/ +/*** void clearControlMessage() ***/ +/************************************/ + +void +#ifdef _NO_PROTO +clearControlMessage () +#else +clearControlMessage (void) +#endif +{ + int strlength; + + strcpy(viewport->controlPanel->message," "); + strlength = strlen(viewport->controlPanel->message); + GDrawImageString(globalGC1,viewport->controlPanel->controlWindow, + centerX(globalGC1,viewport->controlPanel->message, + strlength,controlWidth), + controlMessageY + globalFont->max_bounds.ascent + 8, + viewport->controlPanel->message,strlength,Xoption); + +} + +/************************************/ +/*** void writeControlMessage() ***/ +/************************************/ + +void +#ifdef _NO_PROTO +writeControlMessage () +#else +writeControlMessage (void) +#endif +{ + + int strlength; + controlPanelStruct *cp; + + cp = viewport->controlPanel; + strlength = strlen(cp->message); + XClearArea(dsply,cp->controlWindow, + 0,controlMessageY+ globalFont->max_bounds.ascent + 8, + 0,controlMessageHeight,False); + GSetForeground(globalGC1, (float)controlMessageColor, Xoption); + GDrawImageString(globalGC1,cp->controlWindow, + centerX(globalGC1,cp->message,strlength,controlWidth), + controlMessageY + globalFont->max_bounds.ascent + 8, + cp->message,strlength,Xoption); + + XFlush(dsply); + +} + +/*********************************/ +/*** void drawControlPanel() ***/ +/*********************************/ + +void +#ifdef _NO_PROTO +drawControlPanel() +#else +drawControlPanel(void ) +#endif +{ + + int offShade=14; + controlPanelStruct *cp; + int i, strlength; + char *s; + + cp = viewport->controlPanel; + + GSetForeground(trashGC, (float)foregroundColor, Xoption); + + /* Draw border lines to separate the potentiometer, message, colormap and + button regions of the control panel. */ + GSetLineAttributes(trashGC, 2, LineSolid, CapButt, JoinMiter, Xoption); + + /* Draw a horizontal white line below the potentiometer area. */ + GDrawLine(trashGC, cp->controlWindow, 0, potB-1, controlWidth, potB-1, Xoption); + + /* Draw a horizontal white line above the rendering mode buttons. */ + GDrawLine(trashGC, cp->controlWindow, 0, butA, controlWidth, butA, Xoption); + + /* Draw a horizontal white line above the color mapping area. */ + GDrawLine(trashGC, cp->controlWindow, 0, cmapA, controlWidth, cmapA, Xoption); + + GSetLineAttributes(trashGC, 3, LineSolid, CapButt, JoinMiter, Xoption); + /* Draw a horizontal white line above the potentiometer area. */ + GDrawLine(trashGC, cp->controlWindow, 0, potA, controlWidth, potA, Xoption); + + /* Set the line width as 1 here because it is used below as well. */ + GSetLineAttributes(trashGC, 1, LineSolid, CapButt, JoinMiter, Xoption); + + /* Draw inner white lines around quit, hide panel, and reset buttons. */ + GDrawLine(trashGC, cp->controlWindow, closeL, butA, closeL, butA+110, Xoption); + + /* Write potentiometer titles on the control panel. */ + + writeControlTitle(cp->controlWindow); + GSetForeground(globGC, (float)controlPotHeaderColor, Xoption); + + s = "Rotate"; + GDrawString(globGC,cp->controlWindow,35,31+headerHeight,s,strlen(s),Xoption); + s = "Translate"; + GDrawString(globGC,cp->controlWindow,202,31+headerHeight,s,strlen(s),Xoption); + s = "Scale"; + GDrawString(globGC,cp->controlWindow,126,31+headerHeight,s,strlen(s),Xoption); + + GSetForeground(globGC, (float)controlColorColor, Xoption); + + /* Write labels on regular buttons, draw pixmaps on the potentiometers. */ + + GSetForeground(globalGC1, (float)monoColor(buttonColor), Xoption); + + for (i=controlButtonsStart3D; i<(controlButtonsEnd3D); i++) { + /* special cases depending on initial conditions */ + + /* check if axes are set on or off */ + + if (((cp->buttonQueue[i]).buttonKey == axesOnOff) && + (viewport->axesOn)) { + (cp->buttonQueue[i]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1, (float)backgroundColor, Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[axesOnOff]).buttonX, + (control->buttonQueue[axesOnOff]).buttonY, + (control->buttonQueue[axesOnOff]).buttonWidth, + (control->buttonQueue[axesOnOff]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[axesOnOff]).buttonX, + (control->buttonQueue[axesOnOff]).buttonY, + (control->buttonQueue[axesOnOff]).buttonWidth, + (control->buttonQueue[axesOnOff]).buttonHeight,Xoption); + } + } else { + if (((cp->buttonQueue[i]).buttonKey == axesOnOff) && + (!viewport->axesOn)) { + (cp->buttonQueue[i]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,cp->controlWindow, + (cp->buttonQueue[i]).buttonX, + (cp->buttonQueue[i]).buttonY, + (cp->buttonQueue[i]).buttonWidth, + (cp->buttonQueue[i]).buttonHeight); + s = (control->buttonQueue[axesOnOff]).text; + strlength = strlen(s); + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[axesOnOff]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[axesOnOff]).buttonX + + centerX(processGC,s,strlength, + (control->buttonQueue[axesOnOff]).buttonWidth), + (control->buttonQueue[axesOnOff]).buttonY + + centerY(processGC, + (control->buttonQueue[axesOnOff]).buttonHeight), + s,strlength,Xoption); + } /* if mono */ + } + } /* if axes */ + + /* check if bounding region is set on or off */ + + if (((cp->buttonQueue[i]).buttonKey == region3D) && + (viewport->regionOn)) { + (cp->buttonQueue[i]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1, (float)backgroundColor, Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[region3D]).buttonX, + (control->buttonQueue[region3D]).buttonY, + (control->buttonQueue[region3D]).buttonWidth, + (control->buttonQueue[region3D]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[region3D]).buttonX, + (control->buttonQueue[region3D]).buttonY, + (control->buttonQueue[region3D]).buttonWidth, + (control->buttonQueue[region3D]).buttonHeight,Xoption); + } + } else { + if (((cp->buttonQueue[i]).buttonKey == region3D) && + (!viewport->regionOn)) { + (cp->buttonQueue[i]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,cp->controlWindow, + (cp->buttonQueue[i]).buttonX, + (cp->buttonQueue[i]).buttonY, + (cp->buttonQueue[i]).buttonWidth, + (cp->buttonQueue[i]).buttonHeight); + s = (control->buttonQueue[region3D]).text; + strlength = strlen(s); + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[region3D]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[region3D]).buttonX + + centerX(processGC,s,strlength, + (control->buttonQueue[region3D]).buttonWidth), + (control->buttonQueue[region3D]).buttonY + + centerY(processGC, + (control->buttonQueue[region3D]).buttonHeight), + s,strlength,Xoption); + } /* if mono */ + } + } /* if bounding region */ + + /* check if black and white is set on or off */ + + if (((cp->buttonQueue[i]).buttonKey == bwColor) && (mono)) { + (cp->buttonQueue[i]).text = " "; + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,cp->controlWindow, + (cp->buttonQueue[i]).buttonX, + (cp->buttonQueue[i]).buttonY, + (cp->buttonQueue[i]).buttonWidth, + (cp->buttonQueue[i]).buttonHeight); + } else { + if (((cp->buttonQueue[i]).buttonKey == bwColor) && viewport->monoOn) { + (cp->buttonQueue[i]).textColor = onColor; + s = (control->buttonQueue[bwColor]).text; + strlength = strlen(s); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[bwColor]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[bwColor]).buttonX + + centerX(processGC,s,strlength, + (control->buttonQueue[bwColor]).buttonWidth), + (control->buttonQueue[bwColor]).buttonY + + centerY(processGC, + (control->buttonQueue[bwColor]).buttonHeight), + s,strlength,Xoption); + } else { + if (((cp->buttonQueue[i]).buttonKey == bwColor) && (!viewport->monoOn)) { + (cp->buttonQueue[i]).textColor = offColor; + s = (control->buttonQueue[bwColor]).text; + strlength = strlen(s); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[bwColor]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[bwColor]).buttonX + + centerX(processGC,s,strlength, + (control->buttonQueue[bwColor]).buttonWidth), + (control->buttonQueue[bwColor]).buttonY + + centerY(processGC, + (control->buttonQueue[bwColor]).buttonHeight), + s,strlength,Xoption); + } + } + } /* if black and white */ + + /* check if object rotation is set on or off */ + + if (((cp->buttonQueue[i]).buttonKey == objectr) && + (viewport->objectrOn)) { + (control->buttonQueue[objectr]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1, (float)backgroundColor, Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[objectr]).buttonX, + (control->buttonQueue[objectr]).buttonY, + (control->buttonQueue[objectr]).buttonWidth, + (control->buttonQueue[objectr]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[objectr]).buttonX, + (control->buttonQueue[objectr]).buttonY, + (control->buttonQueue[objectr]).buttonWidth, + (control->buttonQueue[objectr]).buttonHeight,Xoption); + } + } else { + if (((cp->buttonQueue[i]).buttonKey == objectr) && + (!viewport->objectrOn)) { + (control->buttonQueue[objectr]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[objectr]).buttonX, + (control->buttonQueue[objectr]).buttonY, + (control->buttonQueue[objectr]).buttonWidth, + (control->buttonQueue[objectr]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[objectr]).buttonX, + (control->buttonQueue[objectr]).buttonY, + (control->buttonQueue[objectr]).buttonWidth, + (control->buttonQueue[objectr]).buttonHeight,Xoption); + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[objectr]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[objectr]).buttonX + + centerX(processGC,(control->buttonQueue[objectr]).text, + strlen((control->buttonQueue[objectr]).text), + (control->buttonQueue[objectr]).buttonWidth), + (control->buttonQueue[objectr]).buttonY + + centerY(processGC, + (control->buttonQueue[objectr]).buttonHeight), + (control->buttonQueue[objectr]).text, + strlen((control->buttonQueue[objectr]).text),Xoption); + } + } /* else not object rotation */ + } /* if object rotation */ + + /* check if origin rotation is set on or off */ + + if (((cp->buttonQueue[i]).buttonKey == originr) && + (viewport->originrOn)) { + (control->buttonQueue[originr]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1, (float)backgroundColor, Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[originr]).buttonX, + (control->buttonQueue[originr]).buttonY, + (control->buttonQueue[originr]).buttonWidth, + (control->buttonQueue[originr]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[originr]).buttonX, + (control->buttonQueue[originr]).buttonY, + (control->buttonQueue[originr]).buttonWidth, + (control->buttonQueue[originr]).buttonHeight,Xoption); + } + } else { + if (((cp->buttonQueue[i]).buttonKey == originr) && + (!viewport->originrOn)) { + (control->buttonQueue[originr]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[originr]).buttonX, + (control->buttonQueue[originr]).buttonY, + (control->buttonQueue[originr]).buttonWidth, + (control->buttonQueue[originr]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[originr]).buttonX, + (control->buttonQueue[originr]).buttonY, + (control->buttonQueue[originr]).buttonWidth, + (control->buttonQueue[originr]).buttonHeight,Xoption); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[originr]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[originr]).buttonX + + centerX(processGC,(control->buttonQueue[originr]).text, + strlen((control->buttonQueue[originr]).text), + (control->buttonQueue[originr]).buttonWidth), + (control->buttonQueue[originr]).buttonY + + centerY(processGC, + (control->buttonQueue[originr]).buttonHeight), + (control->buttonQueue[originr]).text, + strlen((control->buttonQueue[originr]).text),Xoption); + } + } /* else not origin rotation */ + } /* if origin rotation */ + + /* check if zoom X is set on or off */ + + if (((cp->buttonQueue[i]).buttonKey == zoomx) && + (viewport->zoomXOn)) { + (control->buttonQueue[zoomx]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1, (float)backgroundColor, Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[zoomx]).buttonX, + (control->buttonQueue[zoomx]).buttonY, + (control->buttonQueue[zoomx]).buttonWidth, + (control->buttonQueue[zoomx]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[zoomx]).buttonX, + (control->buttonQueue[zoomx]).buttonY, + (control->buttonQueue[zoomx]).buttonWidth, + (control->buttonQueue[zoomx]).buttonHeight,Xoption); + } + } else { + if (((cp->buttonQueue[i]).buttonKey == zoomx) && + (!viewport->zoomXOn)) { + (control->buttonQueue[zoomx]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[zoomx]).buttonX, + (control->buttonQueue[zoomx]).buttonY, + (control->buttonQueue[zoomx]).buttonWidth, + (control->buttonQueue[zoomx]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[zoomx]).buttonX, + (control->buttonQueue[zoomx]).buttonY, + (control->buttonQueue[zoomx]).buttonWidth, + (control->buttonQueue[zoomx]).buttonHeight,Xoption); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[zoomx]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[zoomx]).buttonX + + centerX(processGC,(control->buttonQueue[zoomx]).text, + strlen((control->buttonQueue[zoomx]).text), + (control->buttonQueue[zoomx]).buttonWidth), + (control->buttonQueue[zoomx]).buttonY + + centerY(processGC, + (control->buttonQueue[zoomx]).buttonHeight), + (control->buttonQueue[zoomx]).text, + strlen((control->buttonQueue[zoomx]).text),Xoption); + } + } /* else not zoom X */ + } /* if zoom X */ + + /* check if zoom Y is set on or off */ + + if (((cp->buttonQueue[i]).buttonKey == zoomy) && + (viewport->zoomYOn)) { + (control->buttonQueue[zoomy]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1, (float)backgroundColor, Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[zoomy]).buttonX, + (control->buttonQueue[zoomy]).buttonY, + (control->buttonQueue[zoomy]).buttonWidth, + (control->buttonQueue[zoomy]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[zoomy]).buttonX, + (control->buttonQueue[zoomy]).buttonY, + (control->buttonQueue[zoomy]).buttonWidth, + (control->buttonQueue[zoomy]).buttonHeight,Xoption); + } + } else { + if (((cp->buttonQueue[i]).buttonKey == zoomy) && + (!viewport->zoomYOn)) { + (control->buttonQueue[zoomy]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[zoomy]).buttonX, + (control->buttonQueue[zoomy]).buttonY, + (control->buttonQueue[zoomy]).buttonWidth, + (control->buttonQueue[zoomy]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[zoomy]).buttonX, + (control->buttonQueue[zoomy]).buttonY, + (control->buttonQueue[zoomy]).buttonWidth, + (control->buttonQueue[zoomy]).buttonHeight,Xoption); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[zoomy]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[zoomy]).buttonX + + centerX(processGC,(control->buttonQueue[zoomy]).text, + strlen((control->buttonQueue[zoomy]).text), + (control->buttonQueue[zoomy]).buttonWidth), + (control->buttonQueue[zoomy]).buttonY + + centerY(processGC, + (control->buttonQueue[zoomy]).buttonHeight), + (control->buttonQueue[zoomy]).text, + strlen((control->buttonQueue[zoomy]).text),Xoption); + } + } /* else not zoom Y */ + } /* if zoom Y */ + + /* check if zoom Z is set on or off */ + + if (((cp->buttonQueue[i]).buttonKey == zoomz) && + (viewport->zoomZOn)) { + (control->buttonQueue[zoomz]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1, (float)backgroundColor, Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[zoomz]).buttonX, + (control->buttonQueue[zoomz]).buttonY, + (control->buttonQueue[zoomz]).buttonWidth, + (control->buttonQueue[zoomz]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[zoomz]).buttonX, + (control->buttonQueue[zoomz]).buttonY, + (control->buttonQueue[zoomz]).buttonWidth, + (control->buttonQueue[zoomz]).buttonHeight,Xoption); + } + } else { + if (((cp->buttonQueue[i]).buttonKey == zoomz) && + (!viewport->zoomZOn)) { + (control->buttonQueue[zoomz]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[zoomz]).buttonX, + (control->buttonQueue[zoomz]).buttonY, + (control->buttonQueue[zoomz]).buttonWidth, + (control->buttonQueue[zoomz]).buttonHeight); + GSetForeground(globalGC1, (float)foregroundColor, Xoption); + GDrawRectangle(globalGC1,control->controlWindow, + (control->buttonQueue[zoomz]).buttonX, + (control->buttonQueue[zoomz]).buttonY, + (control->buttonQueue[zoomz]).buttonWidth, + (control->buttonQueue[zoomz]).buttonHeight,Xoption); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[zoomz]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[zoomz]).buttonX + + centerX(processGC,(control->buttonQueue[zoomz]).text, + strlen((control->buttonQueue[zoomz]).text), + (control->buttonQueue[zoomz]).buttonWidth), + (control->buttonQueue[zoomz]).buttonY + + centerY(processGC, + (control->buttonQueue[zoomz]).buttonHeight), + (control->buttonQueue[zoomz]).text, + strlen((control->buttonQueue[zoomz]).text),Xoption); + } + } /* else not zoom Y */ + } /* if zoom Y */ + + /* check if outline is set on or off */ + + if (((cp->buttonQueue[i]).buttonKey == outlineOnOff) && + (viewData.outlineRenderOn)) { + (cp->buttonQueue[i]).textColor = onColor; + } else { + if (((cp->buttonQueue[i]).buttonKey == outlineOnOff) && + !(viewData.outlineRenderOn)) { + (cp->buttonQueue[i]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,cp->controlWindow, + (cp->buttonQueue[i]).buttonX, + (cp->buttonQueue[i]).buttonY, + (cp->buttonQueue[i]).buttonWidth, + (cp->buttonQueue[i]).buttonHeight); + s = (control->buttonQueue[outlineOnOff]).text; + strlength = strlen(s); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[outlineOnOff]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[outlineOnOff]).buttonX + + centerX(processGC,s,strlength, + (control->buttonQueue[outlineOnOff]).buttonWidth), + (control->buttonQueue[outlineOnOff]).buttonY + + centerY(processGC, + (control->buttonQueue[outlineOnOff]).buttonHeight), + s,strlength,Xoption); + } /* if mono */ + } /* outline off */ + } /* outline on */ + + /* Draw the button window border */ + + GDraw3DButtonOut(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); + switch (i) { + case rotate: + GDrawArc(trashGC, cp->controlWindow, + rotateX, rotateY, rotateR, rotateR, 0, 360*64, Xoption); + break; + + case zoom: + GDrawLines(trashGC, cp->controlWindow, zoomArrow, zoomArrowN, + CoordModeOrigin, Xoption); + break; + + case translate: + GDrawLines(trashGC, cp->controlWindow, translateArrow, + translateArrowN, CoordModeOrigin, Xoption); + break; + + default: + s = (cp->buttonQueue[i]).text; + strlength = strlen(s); + GDrawString(trashGC, cp->controlWindow, + (cp->buttonQueue[i]).buttonX + + centerX(processGC,s,strlength, + (cp->buttonQueue[i]).buttonWidth), + (cp->buttonQueue[i]).buttonY + + centerY(processGC, + (cp->buttonQueue[i]).buttonHeight),s,strlen(s),Xoption); + break; + }; + + if ((cp->buttonQueue[i]).pot) { + /* draw horizontal and vertical centerlines */ + + GDrawLine(globalGC1,cp->controlWindow, + (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, + (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); + } + } + + /* refresh the latest message */ + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + + /* Draw the color map window */ + cp = viewport->controlPanel; + drawColorMap(); + XFlush(dsply); + +} /* drawControlPanel() */ + + +/***************************** + * void getControlXY() * + * * + * Determines the x and y * + * coordinate where the * + * control panel is to be * + * placed, based upon where * + * the mouse button was * + * pressed within the graph * + * viewport window. * + *****************************/ + +controlXY +#ifdef _NO_PROTO +getControlXY (whereDoYouWantPanel) + int whereDoYouWantPanel; +#else +getControlXY (int whereDoYouWantPanel) +#endif +{ + + XWindowAttributes wAttrib; + controlXY cXY; + int viewX, viewY, viewW, viewH, tmp=1; + Window rootW, parentW, *childrenWs, tmpW; + unsigned int nChildren; + + tmpW = viewport->titleWindow; + while(tmp) { + XQueryTree(dsply,tmpW,&rootW,&parentW,&childrenWs,&nChildren); + XFree(childrenWs); + if (parentW == rtWindow) { + tmp = 0; + } else { + tmpW = parentW; + } + } + XGetWindowAttributes(dsply,tmpW,&wAttrib); + + viewX = wAttrib.x; + viewY = wAttrib.y; + viewW = wAttrib.width; + viewH = wAttrib.height; + + if (whereDoYouWantPanel) { + switch (whereDoYouWantPanel) { + case 1: /* right */ + cXY.putX = viewX + viewW; + cXY.putY = viewY; + break; + case 2: /* bottom */ + cXY.putX = viewX + (viewW - controlWidth)/2; /* center it */ + cXY.putY = viewY + viewH; + break; + case 3: /* left */ + cXY.putX = viewX - controlWidth - borderWidth; + cXY.putY = viewY; + break; + case 4: /* top */ + cXY.putX = viewX + (viewW - controlWidth)/2; /* center it */ + cXY.putY = viewY - controlHeight - borderHeight; + } + } else { + if ((physicalWidth - (viewX + viewW)) >= controlWidth) { + cXY.putX = viewX + viewW; + cXY.putY = viewY; + } else if ((physicalHeight - (viewY + viewH)) >= controlHeight) { + cXY.putX = viewX + (viewW - controlWidth)/2; /* center it */ + cXY.putY = viewY + viewH; + } else if (viewX >= controlWidth) { + cXY.putX = viewX - controlWidth - borderWidth; + cXY.putY = viewY; + } else if (viewY >= controlHeight) { + cXY.putX = viewX + (viewW - controlWidth)/2; /* center it */ + cXY.putY = viewY - controlHeight - borderHeight; + } else { /* put inside of viewport */ + cXY.putX = viewX + viewW - controlWidth; + cXY.putY = viewY + viewH - controlHeight; + } + } + if (cXY.putX < 0) cXY.putX = 0; + if (cXY.putY < 0) cXY.putY = 0; + return(cXY); + +} + + + +/************************************************/ +/*** controlPanelStruct *makeControlPanel() ***/ +/************************************************/ + +controlPanelStruct * +#ifdef _NO_PROTO +makeControlPanel () +#else +makeControlPanel (void) +#endif +{ + + Window cw; + int i, num; + controlPanelStruct *control; + buttonStruct *buttons; + controlXY cXY; + XSetWindowAttributes cwAttrib, controlAttrib; + XSizeHints sizehint; + Pixmap mousebits, mousemask; + XColor foreColor, backColor; + + if (!(control = (controlPanelStruct *)saymem("control.c",1, + sizeof(controlPanelStruct)))) { + fprintf(stderr,"Ran out of memory trying to create control panel.\n"); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + + cXY = getControlXY(0); + + mousebits = XCreateBitmapFromData(dsply,rtWindow, mouseBitmap_bits, + mouseBitmap_width, mouseBitmap_height); + mousemask = XCreateBitmapFromData(dsply,rtWindow, mouseMask_bits, + mouseMask_width, mouseMask_height); + cwAttrib.background_pixel = backgroundColor; + cwAttrib.border_pixel = foregroundColor; + cwAttrib.event_mask = controlMASK; + cwAttrib.colormap = colorMap; + cwAttrib.override_redirect = overrideManager; + foreColor.pixel = controlCursorForeground; + XQueryColor(dsply,colorMap,&foreColor); + backColor.pixel = controlCursorBackground; + XQueryColor(dsply,colorMap,&backColor); + cwAttrib.cursor = XCreatePixmapCursor(dsply,mousebits, + mousemask, &foreColor,&backColor, + mouseBitmap_x_hot,mouseBitmap_y_hot); + cw = XCreateWindow(dsply,rtWindow, + cXY.putX,cXY.putY,controlWidth,controlHeight,3, + CopyFromParent,InputOutput,CopyFromParent, + controlCreateMASK,&cwAttrib); + + sizehint.flags = PPosition | PSize; + sizehint.x = cXY.putX; + sizehint.y = cXY.putY; + sizehint.width = controlWidth; + sizehint.height = controlHeight; + /*** the None stands for icon pixmap ***/ + XSetNormalHints(dsply,cw,&sizehint); + XSetStandardProperties(dsply,cw,"3D Control Panel","3D Control Panel", + None,NULL,0,&sizehint); + + /* Define and assign a mouse cursor */ + control->controlWindow = cw; + + num = initButtons(control->buttonQueue); + buttons = control->buttonQueue; + for (i=controlButtonsStart3D; i<(controlButtonsEnd3D); i++) { + controlAttrib.event_mask = (control->buttonQueue[i]).mask; + (control->buttonQueue[i]).self = XCreateWindow(dsply,cw, + (control->buttonQueue[i]).buttonX, + (control->buttonQueue[i]).buttonY, + (control->buttonQueue[i]).buttonWidth, + (control->buttonQueue[i]).buttonHeight, + 0,0,InputOnly,CopyFromParent, + buttonCreateMASK,&controlAttrib); + XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, + &((control->buttonQueue[i]).buttonKey)); + /* use buttonKey and not i because buttonKey has a permanent address */ + + XMapWindow(dsply,(control->buttonQueue[i]).self); + + } /* for each button */ + + + /* Set up the potentiometer pixmaps. */ + for (i=0; i<zoomArrowN; i++) { + zoomArrow[i].x += buttons[zoom].buttonX; + zoomArrow[i].y += buttons[zoom].buttonY; + } + for (i=0; i<translateArrowN; i++) { + translateArrow[i].x += buttons[translate].buttonX; + translateArrow[i].y += buttons[translate].buttonY; + } + + rotateX = control->buttonQueue[rotate].buttonX+17; + rotateY = control->buttonQueue[rotate].buttonY+2; + rotateR = control->buttonQueue[rotate].buttonHeight-4; + + strcpy(control->message," "); + + /* Create the color mapping window */ + controlAttrib.event_mask = colorMASK; + control->colormapWindow = XCreateWindow(dsply,cw, colorWidth,colormapY, + colormapW,colormapH,0, 0,InputOnly, + CopyFromParent, colormapCreateMASK, + &controlAttrib); + XMapWindow(dsply,control->colormapWindow); + viewport->justMadeControl = yes; + + return(control); + +} /* makeControlPanel() */ + + + + +/****************************************** + * void putControlPanelSomewhere() * + * This routine puts up the control panel * + * associated with the viewport passed * + * in. It first tries to put it to the * + * right of the viewport. If there isn't * + * enough room, it tries the bottom and * + * so on going clockwise. If the viewport * + * is too big and there is no room to put * + * the control panel outside of it, the * + * control panel is placed on the bottom * + * right hand corner of the viewport. * + *****************************************/ + +void +#ifdef _NO_PROTO +putControlPanelSomewhere (whereDoesPanelGo) + int whereDoesPanelGo; +#else +putControlPanelSomewhere (int whereDoesPanelGo) +#endif +{ + controlPanelStruct *control; + controlXY whereControl; + + control = viewport->controlPanel; + whereControl = getControlXY(whereDoesPanelGo); + + viewport->haveControl = yes; + + XRaiseWindow(dsply,control->controlWindow); + XMoveWindow(dsply, control->controlWindow, + whereControl.putX, whereControl.putY); + + drawControlPanel(); + XSync(dsply,0); + if (viewport->justMadeControl) { + XMapWindow(dsply,control->controlWindow); + viewport->justMadeControl = no; + } + XMapWindow(dsply,control->controlWindow); + XFlush(dsply); + +} + + + diff --git a/src/graph/view3D/control3d.c.pamphlet b/src/graph/view3D/control3d.c.pamphlet deleted file mode 100644 index 72e04c44..00000000 --- a/src/graph/view3D/control3d.c.pamphlet +++ /dev/null @@ -1,1076 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D control3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _CONTROL3D_C -#include "axiom-c-macros.h" - -#include <string.h> -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> - -#include "mouse11.bitmap" -#include "mouse11.mask" - -#include "header.h" -#include "cpanel.h" - -#include "util.H1" -#include "XShade.H1" -#include "XSpadFill.H1" -#include "Gfun.H1" -#include "all_3d.H1" - -/* Defines the pixmap for the arrow displayed in the scale window */ -#define zoomArrowN 11 -static XPoint zoomArrow[zoomArrowN] = { - {29,14},{38,23},{33,23}, - {40,45},{53,45}, - {29,69}, - {5,45},{18,45}, - {25,23},{20,23},{29,14} }; - -/* Defines the pixmap for the arrows displayed in the translate window */ -#define translateArrowN 25 -static XPoint translateArrow[translateArrowN] = { - {55,2},{60,10},{58,10},{58,37}, - {85,37},{85,35},{93,40},{85,45},{85,43},{58,43}, - {58,70},{60,70},{55,78},{50,70},{52,70},{52,43}, - {25,43},{25,45},{17,40},{25,35},{25,37},{52,37}, - {52,10},{50,10},{55,2} }; - -static int rotateX, rotateY, rotateR; - -/* - void drawColorMap () - */ - -void -#ifdef _NO_PROTO -drawColorMap () -#else -drawColorMap (void) -#endif -{ - - controlPanelStruct *cp; - int i,shadeWidth; - - /* Draw the color map window */ - - cp = viewport->controlPanel; - - XClearArea(dsply,cp->controlWindow,5,colormapY,colormapW,colormapH,False); - - /* if window is grayscale, show the grayscale colormap */ - if (mono || (viewport->monoOn)) { - shadeWidth = 230/maxGreyShade; - for (i=0; i<maxGreyShade; i++) { - XChangeShade(dsply, i); - XShadeRectangle(dsply,cp->controlWindow, - colormapX + colorOffsetX + i*shadeWidth, - colormapY + colorOffsetY - 10, shadeWidth, 40); - } - } else { - GDrawString(globalGC2,cp->controlWindow,colorWidth, - colormapY + 13,"-",1,Xoption); - GDrawString(globalGC2,cp->controlWindow,30*colorWidth + 40, - colormapY + 13,"+",1,Xoption); - GDrawString(globalGC2,cp->controlWindow,colorWidth, - colormapY + 46,"-",1,Xoption); - GDrawString(globalGC2,cp->controlWindow,30*colorWidth + 40, - colormapY + 46,"+",1,Xoption); - for (i=0; i<totalHues; i++) { - GSetForeground(anotherGC, (float)XSolidColor(i,2), Xoption); - GDrawLine(anotherGC,cp->controlWindow, - colormapX + i*colorWidth + colorOffsetX, - colormapY + colorOffsetY, - colormapX + i*colorWidth + colorOffsetX, - colormapY + colorOffsetY + colorHeight,Xoption); - } - - if (viewport->hueTop > totalHues-1) viewport->hueTop = totalHues-1; - if (viewport->hueOffset > totalHues-1) viewport->hueOffset = totalHues-1; - - GSetForeground(globGC, (float)monoColor(7), Xoption); - /* Bottom (zmin) color indicator */ - GDrawLine(globGC,cp->controlWindow, - colormapX + viewport->hueOffset * colorWidth + colorOffsetX, - colormapY + colorOffsetY+colorHeight, - colormapX + viewport->hueOffset * colorWidth + colorOffsetX, - colormapY + colorOffsetY+colorHeight+colorPointer,Xoption); - - /* Top (zmax) color indicator */ - GDrawLine(globGC,cp->controlWindow, - colormapX + viewport->hueTop * colorWidth+colorOffsetX, - colormapY + colorOffsetY, - colormapX + viewport->hueTop * colorWidth+colorOffsetX, - colormapY + colorOffsetY-colorPointer,Xoption); - - /* Connect the bottom and top color indicator bars */ - GSetForeground(globGC, (float)monoColor(0), Xoption); - GDrawLine(globGC,cp->controlWindow, - colormapX + viewport->hueOffset * colorWidth + colorOffsetX, - colormapY + colorOffsetY+colorHeight, - colormapX + viewport->hueTop * colorWidth+colorOffsetX, - colormapY + colorOffsetY,Xoption); - } - XSync(dsply,0); - -} /* drawColorMap() */ - - -/******************************* - * void writeControlTitle(w) * - * * - * We need the window argument * - * here because there are * - * multiple control panels in * - * 3D. * - *******************************/ - -void -#ifdef _NO_PROTO -writeControlTitle (w) - Window w; -#else -writeControlTitle (Window w) -#endif -{ - int strlength; - - s = viewport->title; - strlength = strlen(s); - XClearArea(dsply,w,0,0,controlWidth,potA,False); - - GSetForeground(anotherGC,(float)controlTitleColor,Xoption); - GDrawString(anotherGC,w,centerX(anotherGC,s,strlength,controlWidth), - 15,s,strlength,Xoption); - -} /* writeControlTitle() */ - - -/************************************/ -/*** void clearControlMessage() ***/ -/************************************/ - -void -#ifdef _NO_PROTO -clearControlMessage () -#else -clearControlMessage (void) -#endif -{ - int strlength; - - strcpy(viewport->controlPanel->message," "); - strlength = strlen(viewport->controlPanel->message); - GDrawImageString(globalGC1,viewport->controlPanel->controlWindow, - centerX(globalGC1,viewport->controlPanel->message, - strlength,controlWidth), - controlMessageY + globalFont->max_bounds.ascent + 8, - viewport->controlPanel->message,strlength,Xoption); - -} - -/************************************/ -/*** void writeControlMessage() ***/ -/************************************/ - -void -#ifdef _NO_PROTO -writeControlMessage () -#else -writeControlMessage (void) -#endif -{ - - int strlength; - controlPanelStruct *cp; - - cp = viewport->controlPanel; - strlength = strlen(cp->message); - XClearArea(dsply,cp->controlWindow, - 0,controlMessageY+ globalFont->max_bounds.ascent + 8, - 0,controlMessageHeight,False); - GSetForeground(globalGC1, (float)controlMessageColor, Xoption); - GDrawImageString(globalGC1,cp->controlWindow, - centerX(globalGC1,cp->message,strlength,controlWidth), - controlMessageY + globalFont->max_bounds.ascent + 8, - cp->message,strlength,Xoption); - - XFlush(dsply); - -} - -/*********************************/ -/*** void drawControlPanel() ***/ -/*********************************/ - -void -#ifdef _NO_PROTO -drawControlPanel() -#else -drawControlPanel(void ) -#endif -{ - - int offShade=14; - controlPanelStruct *cp; - int i, strlength; - char *s; - - cp = viewport->controlPanel; - - GSetForeground(trashGC, (float)foregroundColor, Xoption); - - /* Draw border lines to separate the potentiometer, message, colormap and - button regions of the control panel. */ - GSetLineAttributes(trashGC, 2, LineSolid, CapButt, JoinMiter, Xoption); - - /* Draw a horizontal white line below the potentiometer area. */ - GDrawLine(trashGC, cp->controlWindow, 0, potB-1, controlWidth, potB-1, Xoption); - - /* Draw a horizontal white line above the rendering mode buttons. */ - GDrawLine(trashGC, cp->controlWindow, 0, butA, controlWidth, butA, Xoption); - - /* Draw a horizontal white line above the color mapping area. */ - GDrawLine(trashGC, cp->controlWindow, 0, cmapA, controlWidth, cmapA, Xoption); - - GSetLineAttributes(trashGC, 3, LineSolid, CapButt, JoinMiter, Xoption); - /* Draw a horizontal white line above the potentiometer area. */ - GDrawLine(trashGC, cp->controlWindow, 0, potA, controlWidth, potA, Xoption); - - /* Set the line width as 1 here because it is used below as well. */ - GSetLineAttributes(trashGC, 1, LineSolid, CapButt, JoinMiter, Xoption); - - /* Draw inner white lines around quit, hide panel, and reset buttons. */ - GDrawLine(trashGC, cp->controlWindow, closeL, butA, closeL, butA+110, Xoption); - - /* Write potentiometer titles on the control panel. */ - - writeControlTitle(cp->controlWindow); - GSetForeground(globGC, (float)controlPotHeaderColor, Xoption); - - s = "Rotate"; - GDrawString(globGC,cp->controlWindow,35,31+headerHeight,s,strlen(s),Xoption); - s = "Translate"; - GDrawString(globGC,cp->controlWindow,202,31+headerHeight,s,strlen(s),Xoption); - s = "Scale"; - GDrawString(globGC,cp->controlWindow,126,31+headerHeight,s,strlen(s),Xoption); - - GSetForeground(globGC, (float)controlColorColor, Xoption); - - /* Write labels on regular buttons, draw pixmaps on the potentiometers. */ - - GSetForeground(globalGC1, (float)monoColor(buttonColor), Xoption); - - for (i=controlButtonsStart3D; i<(controlButtonsEnd3D); i++) { - /* special cases depending on initial conditions */ - - /* check if axes are set on or off */ - - if (((cp->buttonQueue[i]).buttonKey == axesOnOff) && - (viewport->axesOn)) { - (cp->buttonQueue[i]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1, (float)backgroundColor, Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[axesOnOff]).buttonX, - (control->buttonQueue[axesOnOff]).buttonY, - (control->buttonQueue[axesOnOff]).buttonWidth, - (control->buttonQueue[axesOnOff]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[axesOnOff]).buttonX, - (control->buttonQueue[axesOnOff]).buttonY, - (control->buttonQueue[axesOnOff]).buttonWidth, - (control->buttonQueue[axesOnOff]).buttonHeight,Xoption); - } - } else { - if (((cp->buttonQueue[i]).buttonKey == axesOnOff) && - (!viewport->axesOn)) { - (cp->buttonQueue[i]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,cp->controlWindow, - (cp->buttonQueue[i]).buttonX, - (cp->buttonQueue[i]).buttonY, - (cp->buttonQueue[i]).buttonWidth, - (cp->buttonQueue[i]).buttonHeight); - s = (control->buttonQueue[axesOnOff]).text; - strlength = strlen(s); - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[axesOnOff]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[axesOnOff]).buttonX + - centerX(processGC,s,strlength, - (control->buttonQueue[axesOnOff]).buttonWidth), - (control->buttonQueue[axesOnOff]).buttonY + - centerY(processGC, - (control->buttonQueue[axesOnOff]).buttonHeight), - s,strlength,Xoption); - } /* if mono */ - } - } /* if axes */ - - /* check if bounding region is set on or off */ - - if (((cp->buttonQueue[i]).buttonKey == region3D) && - (viewport->regionOn)) { - (cp->buttonQueue[i]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1, (float)backgroundColor, Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[region3D]).buttonX, - (control->buttonQueue[region3D]).buttonY, - (control->buttonQueue[region3D]).buttonWidth, - (control->buttonQueue[region3D]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[region3D]).buttonX, - (control->buttonQueue[region3D]).buttonY, - (control->buttonQueue[region3D]).buttonWidth, - (control->buttonQueue[region3D]).buttonHeight,Xoption); - } - } else { - if (((cp->buttonQueue[i]).buttonKey == region3D) && - (!viewport->regionOn)) { - (cp->buttonQueue[i]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,cp->controlWindow, - (cp->buttonQueue[i]).buttonX, - (cp->buttonQueue[i]).buttonY, - (cp->buttonQueue[i]).buttonWidth, - (cp->buttonQueue[i]).buttonHeight); - s = (control->buttonQueue[region3D]).text; - strlength = strlen(s); - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[region3D]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[region3D]).buttonX + - centerX(processGC,s,strlength, - (control->buttonQueue[region3D]).buttonWidth), - (control->buttonQueue[region3D]).buttonY + - centerY(processGC, - (control->buttonQueue[region3D]).buttonHeight), - s,strlength,Xoption); - } /* if mono */ - } - } /* if bounding region */ - - /* check if black and white is set on or off */ - - if (((cp->buttonQueue[i]).buttonKey == bwColor) && (mono)) { - (cp->buttonQueue[i]).text = " "; - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,cp->controlWindow, - (cp->buttonQueue[i]).buttonX, - (cp->buttonQueue[i]).buttonY, - (cp->buttonQueue[i]).buttonWidth, - (cp->buttonQueue[i]).buttonHeight); - } else { - if (((cp->buttonQueue[i]).buttonKey == bwColor) && viewport->monoOn) { - (cp->buttonQueue[i]).textColor = onColor; - s = (control->buttonQueue[bwColor]).text; - strlength = strlen(s); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[bwColor]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[bwColor]).buttonX + - centerX(processGC,s,strlength, - (control->buttonQueue[bwColor]).buttonWidth), - (control->buttonQueue[bwColor]).buttonY + - centerY(processGC, - (control->buttonQueue[bwColor]).buttonHeight), - s,strlength,Xoption); - } else { - if (((cp->buttonQueue[i]).buttonKey == bwColor) && (!viewport->monoOn)) { - (cp->buttonQueue[i]).textColor = offColor; - s = (control->buttonQueue[bwColor]).text; - strlength = strlen(s); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[bwColor]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[bwColor]).buttonX + - centerX(processGC,s,strlength, - (control->buttonQueue[bwColor]).buttonWidth), - (control->buttonQueue[bwColor]).buttonY + - centerY(processGC, - (control->buttonQueue[bwColor]).buttonHeight), - s,strlength,Xoption); - } - } - } /* if black and white */ - - /* check if object rotation is set on or off */ - - if (((cp->buttonQueue[i]).buttonKey == objectr) && - (viewport->objectrOn)) { - (control->buttonQueue[objectr]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1, (float)backgroundColor, Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[objectr]).buttonX, - (control->buttonQueue[objectr]).buttonY, - (control->buttonQueue[objectr]).buttonWidth, - (control->buttonQueue[objectr]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[objectr]).buttonX, - (control->buttonQueue[objectr]).buttonY, - (control->buttonQueue[objectr]).buttonWidth, - (control->buttonQueue[objectr]).buttonHeight,Xoption); - } - } else { - if (((cp->buttonQueue[i]).buttonKey == objectr) && - (!viewport->objectrOn)) { - (control->buttonQueue[objectr]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[objectr]).buttonX, - (control->buttonQueue[objectr]).buttonY, - (control->buttonQueue[objectr]).buttonWidth, - (control->buttonQueue[objectr]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[objectr]).buttonX, - (control->buttonQueue[objectr]).buttonY, - (control->buttonQueue[objectr]).buttonWidth, - (control->buttonQueue[objectr]).buttonHeight,Xoption); - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[objectr]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[objectr]).buttonX + - centerX(processGC,(control->buttonQueue[objectr]).text, - strlen((control->buttonQueue[objectr]).text), - (control->buttonQueue[objectr]).buttonWidth), - (control->buttonQueue[objectr]).buttonY + - centerY(processGC, - (control->buttonQueue[objectr]).buttonHeight), - (control->buttonQueue[objectr]).text, - strlen((control->buttonQueue[objectr]).text),Xoption); - } - } /* else not object rotation */ - } /* if object rotation */ - - /* check if origin rotation is set on or off */ - - if (((cp->buttonQueue[i]).buttonKey == originr) && - (viewport->originrOn)) { - (control->buttonQueue[originr]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1, (float)backgroundColor, Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[originr]).buttonX, - (control->buttonQueue[originr]).buttonY, - (control->buttonQueue[originr]).buttonWidth, - (control->buttonQueue[originr]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[originr]).buttonX, - (control->buttonQueue[originr]).buttonY, - (control->buttonQueue[originr]).buttonWidth, - (control->buttonQueue[originr]).buttonHeight,Xoption); - } - } else { - if (((cp->buttonQueue[i]).buttonKey == originr) && - (!viewport->originrOn)) { - (control->buttonQueue[originr]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[originr]).buttonX, - (control->buttonQueue[originr]).buttonY, - (control->buttonQueue[originr]).buttonWidth, - (control->buttonQueue[originr]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[originr]).buttonX, - (control->buttonQueue[originr]).buttonY, - (control->buttonQueue[originr]).buttonWidth, - (control->buttonQueue[originr]).buttonHeight,Xoption); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[originr]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[originr]).buttonX + - centerX(processGC,(control->buttonQueue[originr]).text, - strlen((control->buttonQueue[originr]).text), - (control->buttonQueue[originr]).buttonWidth), - (control->buttonQueue[originr]).buttonY + - centerY(processGC, - (control->buttonQueue[originr]).buttonHeight), - (control->buttonQueue[originr]).text, - strlen((control->buttonQueue[originr]).text),Xoption); - } - } /* else not origin rotation */ - } /* if origin rotation */ - - /* check if zoom X is set on or off */ - - if (((cp->buttonQueue[i]).buttonKey == zoomx) && - (viewport->zoomXOn)) { - (control->buttonQueue[zoomx]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1, (float)backgroundColor, Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[zoomx]).buttonX, - (control->buttonQueue[zoomx]).buttonY, - (control->buttonQueue[zoomx]).buttonWidth, - (control->buttonQueue[zoomx]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[zoomx]).buttonX, - (control->buttonQueue[zoomx]).buttonY, - (control->buttonQueue[zoomx]).buttonWidth, - (control->buttonQueue[zoomx]).buttonHeight,Xoption); - } - } else { - if (((cp->buttonQueue[i]).buttonKey == zoomx) && - (!viewport->zoomXOn)) { - (control->buttonQueue[zoomx]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[zoomx]).buttonX, - (control->buttonQueue[zoomx]).buttonY, - (control->buttonQueue[zoomx]).buttonWidth, - (control->buttonQueue[zoomx]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[zoomx]).buttonX, - (control->buttonQueue[zoomx]).buttonY, - (control->buttonQueue[zoomx]).buttonWidth, - (control->buttonQueue[zoomx]).buttonHeight,Xoption); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[zoomx]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[zoomx]).buttonX + - centerX(processGC,(control->buttonQueue[zoomx]).text, - strlen((control->buttonQueue[zoomx]).text), - (control->buttonQueue[zoomx]).buttonWidth), - (control->buttonQueue[zoomx]).buttonY + - centerY(processGC, - (control->buttonQueue[zoomx]).buttonHeight), - (control->buttonQueue[zoomx]).text, - strlen((control->buttonQueue[zoomx]).text),Xoption); - } - } /* else not zoom X */ - } /* if zoom X */ - - /* check if zoom Y is set on or off */ - - if (((cp->buttonQueue[i]).buttonKey == zoomy) && - (viewport->zoomYOn)) { - (control->buttonQueue[zoomy]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1, (float)backgroundColor, Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[zoomy]).buttonX, - (control->buttonQueue[zoomy]).buttonY, - (control->buttonQueue[zoomy]).buttonWidth, - (control->buttonQueue[zoomy]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[zoomy]).buttonX, - (control->buttonQueue[zoomy]).buttonY, - (control->buttonQueue[zoomy]).buttonWidth, - (control->buttonQueue[zoomy]).buttonHeight,Xoption); - } - } else { - if (((cp->buttonQueue[i]).buttonKey == zoomy) && - (!viewport->zoomYOn)) { - (control->buttonQueue[zoomy]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[zoomy]).buttonX, - (control->buttonQueue[zoomy]).buttonY, - (control->buttonQueue[zoomy]).buttonWidth, - (control->buttonQueue[zoomy]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[zoomy]).buttonX, - (control->buttonQueue[zoomy]).buttonY, - (control->buttonQueue[zoomy]).buttonWidth, - (control->buttonQueue[zoomy]).buttonHeight,Xoption); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[zoomy]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[zoomy]).buttonX + - centerX(processGC,(control->buttonQueue[zoomy]).text, - strlen((control->buttonQueue[zoomy]).text), - (control->buttonQueue[zoomy]).buttonWidth), - (control->buttonQueue[zoomy]).buttonY + - centerY(processGC, - (control->buttonQueue[zoomy]).buttonHeight), - (control->buttonQueue[zoomy]).text, - strlen((control->buttonQueue[zoomy]).text),Xoption); - } - } /* else not zoom Y */ - } /* if zoom Y */ - - /* check if zoom Z is set on or off */ - - if (((cp->buttonQueue[i]).buttonKey == zoomz) && - (viewport->zoomZOn)) { - (control->buttonQueue[zoomz]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1, (float)backgroundColor, Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[zoomz]).buttonX, - (control->buttonQueue[zoomz]).buttonY, - (control->buttonQueue[zoomz]).buttonWidth, - (control->buttonQueue[zoomz]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[zoomz]).buttonX, - (control->buttonQueue[zoomz]).buttonY, - (control->buttonQueue[zoomz]).buttonWidth, - (control->buttonQueue[zoomz]).buttonHeight,Xoption); - } - } else { - if (((cp->buttonQueue[i]).buttonKey == zoomz) && - (!viewport->zoomZOn)) { - (control->buttonQueue[zoomz]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[zoomz]).buttonX, - (control->buttonQueue[zoomz]).buttonY, - (control->buttonQueue[zoomz]).buttonWidth, - (control->buttonQueue[zoomz]).buttonHeight); - GSetForeground(globalGC1, (float)foregroundColor, Xoption); - GDrawRectangle(globalGC1,control->controlWindow, - (control->buttonQueue[zoomz]).buttonX, - (control->buttonQueue[zoomz]).buttonY, - (control->buttonQueue[zoomz]).buttonWidth, - (control->buttonQueue[zoomz]).buttonHeight,Xoption); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[zoomz]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[zoomz]).buttonX + - centerX(processGC,(control->buttonQueue[zoomz]).text, - strlen((control->buttonQueue[zoomz]).text), - (control->buttonQueue[zoomz]).buttonWidth), - (control->buttonQueue[zoomz]).buttonY + - centerY(processGC, - (control->buttonQueue[zoomz]).buttonHeight), - (control->buttonQueue[zoomz]).text, - strlen((control->buttonQueue[zoomz]).text),Xoption); - } - } /* else not zoom Y */ - } /* if zoom Y */ - - /* check if outline is set on or off */ - - if (((cp->buttonQueue[i]).buttonKey == outlineOnOff) && - (viewData.outlineRenderOn)) { - (cp->buttonQueue[i]).textColor = onColor; - } else { - if (((cp->buttonQueue[i]).buttonKey == outlineOnOff) && - !(viewData.outlineRenderOn)) { - (cp->buttonQueue[i]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,cp->controlWindow, - (cp->buttonQueue[i]).buttonX, - (cp->buttonQueue[i]).buttonY, - (cp->buttonQueue[i]).buttonWidth, - (cp->buttonQueue[i]).buttonHeight); - s = (control->buttonQueue[outlineOnOff]).text; - strlength = strlen(s); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[outlineOnOff]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[outlineOnOff]).buttonX + - centerX(processGC,s,strlength, - (control->buttonQueue[outlineOnOff]).buttonWidth), - (control->buttonQueue[outlineOnOff]).buttonY + - centerY(processGC, - (control->buttonQueue[outlineOnOff]).buttonHeight), - s,strlength,Xoption); - } /* if mono */ - } /* outline off */ - } /* outline on */ - - /* Draw the button window border */ - - GDraw3DButtonOut(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); - switch (i) { - case rotate: - GDrawArc(trashGC, cp->controlWindow, - rotateX, rotateY, rotateR, rotateR, 0, 360*64, Xoption); - break; - - case zoom: - GDrawLines(trashGC, cp->controlWindow, zoomArrow, zoomArrowN, - CoordModeOrigin, Xoption); - break; - - case translate: - GDrawLines(trashGC, cp->controlWindow, translateArrow, - translateArrowN, CoordModeOrigin, Xoption); - break; - - default: - s = (cp->buttonQueue[i]).text; - strlength = strlen(s); - GDrawString(trashGC, cp->controlWindow, - (cp->buttonQueue[i]).buttonX + - centerX(processGC,s,strlength, - (cp->buttonQueue[i]).buttonWidth), - (cp->buttonQueue[i]).buttonY + - centerY(processGC, - (cp->buttonQueue[i]).buttonHeight),s,strlen(s),Xoption); - break; - }; - - if ((cp->buttonQueue[i]).pot) { - /* draw horizontal and vertical centerlines */ - - GDrawLine(globalGC1,cp->controlWindow, - (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, - (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); - } - } - - /* refresh the latest message */ - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - - /* Draw the color map window */ - cp = viewport->controlPanel; - drawColorMap(); - XFlush(dsply); - -} /* drawControlPanel() */ - - -/***************************** - * void getControlXY() * - * * - * Determines the x and y * - * coordinate where the * - * control panel is to be * - * placed, based upon where * - * the mouse button was * - * pressed within the graph * - * viewport window. * - *****************************/ - -controlXY -#ifdef _NO_PROTO -getControlXY (whereDoYouWantPanel) - int whereDoYouWantPanel; -#else -getControlXY (int whereDoYouWantPanel) -#endif -{ - - XWindowAttributes wAttrib; - controlXY cXY; - int viewX, viewY, viewW, viewH, tmp=1; - Window rootW, parentW, *childrenWs, tmpW; - unsigned int nChildren; - - tmpW = viewport->titleWindow; - while(tmp) { - XQueryTree(dsply,tmpW,&rootW,&parentW,&childrenWs,&nChildren); - XFree(childrenWs); - if (parentW == rtWindow) { - tmp = 0; - } else { - tmpW = parentW; - } - } - XGetWindowAttributes(dsply,tmpW,&wAttrib); - - viewX = wAttrib.x; - viewY = wAttrib.y; - viewW = wAttrib.width; - viewH = wAttrib.height; - - if (whereDoYouWantPanel) { - switch (whereDoYouWantPanel) { - case 1: /* right */ - cXY.putX = viewX + viewW; - cXY.putY = viewY; - break; - case 2: /* bottom */ - cXY.putX = viewX + (viewW - controlWidth)/2; /* center it */ - cXY.putY = viewY + viewH; - break; - case 3: /* left */ - cXY.putX = viewX - controlWidth - borderWidth; - cXY.putY = viewY; - break; - case 4: /* top */ - cXY.putX = viewX + (viewW - controlWidth)/2; /* center it */ - cXY.putY = viewY - controlHeight - borderHeight; - } - } else { - if ((physicalWidth - (viewX + viewW)) >= controlWidth) { - cXY.putX = viewX + viewW; - cXY.putY = viewY; - } else if ((physicalHeight - (viewY + viewH)) >= controlHeight) { - cXY.putX = viewX + (viewW - controlWidth)/2; /* center it */ - cXY.putY = viewY + viewH; - } else if (viewX >= controlWidth) { - cXY.putX = viewX - controlWidth - borderWidth; - cXY.putY = viewY; - } else if (viewY >= controlHeight) { - cXY.putX = viewX + (viewW - controlWidth)/2; /* center it */ - cXY.putY = viewY - controlHeight - borderHeight; - } else { /* put inside of viewport */ - cXY.putX = viewX + viewW - controlWidth; - cXY.putY = viewY + viewH - controlHeight; - } - } - if (cXY.putX < 0) cXY.putX = 0; - if (cXY.putY < 0) cXY.putY = 0; - return(cXY); - -} - - - -/************************************************/ -/*** controlPanelStruct *makeControlPanel() ***/ -/************************************************/ - -controlPanelStruct * -#ifdef _NO_PROTO -makeControlPanel () -#else -makeControlPanel (void) -#endif -{ - - Window cw; - int i, num; - controlPanelStruct *control; - buttonStruct *buttons; - controlXY cXY; - XSetWindowAttributes cwAttrib, controlAttrib; - XSizeHints sizehint; - Pixmap mousebits, mousemask; - XColor foreColor, backColor; - - if (!(control = (controlPanelStruct *)saymem("control.c",1, - sizeof(controlPanelStruct)))) { - fprintf(stderr,"Ran out of memory trying to create control panel.\n"); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - - cXY = getControlXY(0); - - mousebits = XCreateBitmapFromData(dsply,rtWindow, mouseBitmap_bits, - mouseBitmap_width, mouseBitmap_height); - mousemask = XCreateBitmapFromData(dsply,rtWindow, mouseMask_bits, - mouseMask_width, mouseMask_height); - cwAttrib.background_pixel = backgroundColor; - cwAttrib.border_pixel = foregroundColor; - cwAttrib.event_mask = controlMASK; - cwAttrib.colormap = colorMap; - cwAttrib.override_redirect = overrideManager; - foreColor.pixel = controlCursorForeground; - XQueryColor(dsply,colorMap,&foreColor); - backColor.pixel = controlCursorBackground; - XQueryColor(dsply,colorMap,&backColor); - cwAttrib.cursor = XCreatePixmapCursor(dsply,mousebits, - mousemask, &foreColor,&backColor, - mouseBitmap_x_hot,mouseBitmap_y_hot); - cw = XCreateWindow(dsply,rtWindow, - cXY.putX,cXY.putY,controlWidth,controlHeight,3, - CopyFromParent,InputOutput,CopyFromParent, - controlCreateMASK,&cwAttrib); - - sizehint.flags = PPosition | PSize; - sizehint.x = cXY.putX; - sizehint.y = cXY.putY; - sizehint.width = controlWidth; - sizehint.height = controlHeight; - /*** the None stands for icon pixmap ***/ - XSetNormalHints(dsply,cw,&sizehint); - XSetStandardProperties(dsply,cw,"3D Control Panel","3D Control Panel", - None,NULL,0,&sizehint); - - /* Define and assign a mouse cursor */ - control->controlWindow = cw; - - num = initButtons(control->buttonQueue); - buttons = control->buttonQueue; - for (i=controlButtonsStart3D; i<(controlButtonsEnd3D); i++) { - controlAttrib.event_mask = (control->buttonQueue[i]).mask; - (control->buttonQueue[i]).self = XCreateWindow(dsply,cw, - (control->buttonQueue[i]).buttonX, - (control->buttonQueue[i]).buttonY, - (control->buttonQueue[i]).buttonWidth, - (control->buttonQueue[i]).buttonHeight, - 0,0,InputOnly,CopyFromParent, - buttonCreateMASK,&controlAttrib); - XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, - &((control->buttonQueue[i]).buttonKey)); - /* use buttonKey and not i because buttonKey has a permanent address */ - - XMapWindow(dsply,(control->buttonQueue[i]).self); - - } /* for each button */ - - - /* Set up the potentiometer pixmaps. */ - for (i=0; i<zoomArrowN; i++) { - zoomArrow[i].x += buttons[zoom].buttonX; - zoomArrow[i].y += buttons[zoom].buttonY; - } - for (i=0; i<translateArrowN; i++) { - translateArrow[i].x += buttons[translate].buttonX; - translateArrow[i].y += buttons[translate].buttonY; - } - - rotateX = control->buttonQueue[rotate].buttonX+17; - rotateY = control->buttonQueue[rotate].buttonY+2; - rotateR = control->buttonQueue[rotate].buttonHeight-4; - - strcpy(control->message," "); - - /* Create the color mapping window */ - controlAttrib.event_mask = colorMASK; - control->colormapWindow = XCreateWindow(dsply,cw, colorWidth,colormapY, - colormapW,colormapH,0, 0,InputOnly, - CopyFromParent, colormapCreateMASK, - &controlAttrib); - XMapWindow(dsply,control->colormapWindow); - viewport->justMadeControl = yes; - - return(control); - -} /* makeControlPanel() */ - - - - -/****************************************** - * void putControlPanelSomewhere() * - * This routine puts up the control panel * - * associated with the viewport passed * - * in. It first tries to put it to the * - * right of the viewport. If there isn't * - * enough room, it tries the bottom and * - * so on going clockwise. If the viewport * - * is too big and there is no room to put * - * the control panel outside of it, the * - * control panel is placed on the bottom * - * right hand corner of the viewport. * - *****************************************/ - -void -#ifdef _NO_PROTO -putControlPanelSomewhere (whereDoesPanelGo) - int whereDoesPanelGo; -#else -putControlPanelSomewhere (int whereDoesPanelGo) -#endif -{ - controlPanelStruct *control; - controlXY whereControl; - - control = viewport->controlPanel; - whereControl = getControlXY(whereDoesPanelGo); - - viewport->haveControl = yes; - - XRaiseWindow(dsply,control->controlWindow); - XMoveWindow(dsply, control->controlWindow, - whereControl.putX, whereControl.putY); - - drawControlPanel(); - XSync(dsply,0); - if (viewport->justMadeControl) { - XMapWindow(dsply,control->controlWindow); - viewport->justMadeControl = no; - } - XMapWindow(dsply,control->controlWindow); - XFlush(dsply); - -} - - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/cpanel.h b/src/graph/view3D/cpanel.h index 37da0202..b01e5ad0 100755..100644 --- a/src/graph/view3D/cpanel.h +++ b/src/graph/view3D/cpanel.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ diff --git a/src/graph/view3D/draw.h b/src/graph/view3D/draw.h index 1239f2a9..a9ad0339 100755..100644 --- a/src/graph/view3D/draw.h +++ b/src/graph/view3D/draw.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define meshOutline monoColor(140) diff --git a/src/graph/view3D/eventnames.h b/src/graph/view3D/eventnames.h index ecfcab31..9c3527c2 100755..100644 --- a/src/graph/view3D/eventnames.h +++ b/src/graph/view3D/eventnames.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ static char *event_name[] = { diff --git a/src/graph/view3D/globals.h b/src/graph/view3D/globals.h index a779690f..5734564c 100755..100644 --- a/src/graph/view3D/globals.h +++ b/src/graph/view3D/globals.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copryight (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ extern int scrn; diff --git a/src/graph/view3D/header.h b/src/graph/view3D/header.h index ca76c7d7..1cb58a0d 100755..100644 --- a/src/graph/view3D/header.h +++ b/src/graph/view3D/header.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define view3D diff --git a/src/graph/view3D/illuminate3d.c.pamphlet b/src/graph/view3D/illuminate3d.c index 6cc8f908..fbfa5559 100644 --- a/src/graph/view3D/illuminate3d.c.pamphlet +++ b/src/graph/view3D/illuminate3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D illuminate3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _ILLUMINATE3D_C #include "axiom-c-macros.h" @@ -138,7 +124,7 @@ hueValue(float val) #endif { int hue; - + hue = floor(absolute(val) * viewport->numberOfHues) + viewport->hueOffset; if (hue > 26) hue = 26; @@ -154,7 +140,7 @@ getHue(float val) #endif { int hue; - + hue = hueValue(val); if (hue < 11) hue *= 6; @@ -228,9 +214,3 @@ hlsTOrgb(float h,float l,float s) -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/lightbut3d.c.pamphlet b/src/graph/view3D/lightbut3d.c index f9f7c433..6ed0ff3b 100644 --- a/src/graph/view3D/lightbut3d.c.pamphlet +++ b/src/graph/view3D/lightbut3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D lightbut3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _LIGHTBUT3D_C #include "axiom-c-macros.h" @@ -66,7 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. int #ifdef _NO_PROTO initLightButtons (lightButtons) - buttonStruct *lightButtons; + buttonStruct *lightButtons; #else initLightButtons (buttonStruct *lightButtons) #endif @@ -164,9 +150,3 @@ initLightButtons (buttonStruct *lightButtons) } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/lighting3d.c b/src/graph/view3D/lighting3d.c new file mode 100644 index 00000000..8d8bb50d --- /dev/null +++ b/src/graph/view3D/lighting3d.c @@ -0,0 +1,607 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _LIGHTING3D_C +#include "axiom-c-macros.h" + +#include <math.h> +#include <string.h> + +#include "light11.bitmap" +#include "light11.mask" + + +#include "header.h" +#include "static.h" +#include "draw.h" +#include "cpanel.h" +#include "volume.h" + +#include "Gfun.H1" +#include "XSpadFill.H1" +#include "all_3d.H1" + +#define lightMASK ExposureMask +#define lightCursorForeground lightingTitleColor +#define lightCursorBackground foregroundColor + +#define lightFontHeight (lightingFont->max_bounds.ascent+lightingFont->max_bounds.descent) + +#define lightingAxesColor monoColor(52) +#define lightingLabelColor monoColor(12) +#define lightingBoxColor monoColor(138) +#define lightingLightColor monoColor(7) +#define lightingTitleColor monoColor(69) +#define lightingButtonColor monoColor(140) +#define lightingTransColor monoColor(140) +#define lightingTransArrowColor monoColor(100) +#define lightingTransLabelColor monoColor(207) + +#define lightingAxesSize 175 +#define lightingAxesX 61 +#define lightingAxesY 28 + +#define lightAxesScale 110 /* the extent of the axes in object space */ +#define lightScale 0.63 /* projected scale factor */ + +#define arrowHead (control->buttonQueue[lightTranslucent].buttonX + 5) +static viewTriple point0 = {0,0,0}; + + +/*************************** + * int makeLightingPanel() * + ***************************/ + +int +#ifdef _NO_PROTO +makeLightingPanel() +#else +makeLightingPanel(void) +#endif +{ + + int i; + XSetWindowAttributes cwAttrib, controlAttrib; + XSizeHints sizehint; + Pixmap lightbits,lightmask; + XColor foreColor, backColor; + + lightbits = XCreateBitmapFromData(dsply,rtWindow, lightBitmap_bits, + lightBitmap_width,lightBitmap_height); + lightmask = XCreateBitmapFromData(dsply,rtWindow, lightMask_bits, + lightMask_width,lightMask_height); + cwAttrib.background_pixel = backgroundColor; + cwAttrib.border_pixel = foregroundColor; + cwAttrib.event_mask = lightMASK; + cwAttrib.colormap = colorMap; + cwAttrib.override_redirect = overrideManager; + foreColor.pixel = lightCursorForeground; + XQueryColor(dsply,colorMap,&foreColor); + backColor.pixel = lightCursorBackground; + XQueryColor(dsply,colorMap,&backColor); + cwAttrib.cursor = XCreatePixmapCursor(dsply,lightbits,lightmask, + &foreColor,&backColor, + lightBitmap_x_hot,lightBitmap_y_hot); + lightingWindow = XCreateWindow(dsply,control->controlWindow, + -3,-3,controlWidth,controlHeight,3, + CopyFromParent,InputOutput,CopyFromParent, + controlCreateMASK,&cwAttrib); + + sizehint.flags = USPosition | USSize; + sizehint.x = 0; + sizehint.y = 0; + sizehint.width = controlWidth; + sizehint.height = controlHeight; + /*** the None stands for icon pixmap. ***/ + XSetNormalHints(dsply,lightingWindow,&sizehint); + XSetStandardProperties(dsply,lightingWindow,"Lighting Panel 3D", + "Lighting Panel",None,NULL,0,&sizehint); + + /*** lighting axes window ***/ + cwAttrib.event_mask = 0; + lightingAxes = XCreateWindow(dsply,lightingWindow, + lightingAxesX,lightingAxesY, + lightingAxesSize,lightingAxesSize, + 0,CopyFromParent,InputOutput,CopyFromParent, + controlCreateMASK,&cwAttrib); + + sizehint.flags = USPosition | USSize; + sizehint.x = lightingAxesX; + sizehint.y = lightingAxesY; + sizehint.width = lightingAxesSize; + sizehint.height = lightingAxesSize; + /*** the None stands for icon pixmap ***/ + XSetNormalHints(dsply,lightingAxes,&sizehint); + XSetStandardProperties(dsply,lightingAxes,"Lighting Axes","Lighting Axes", + None,NULL,0,&sizehint); + XMapWindow(dsply,lightingAxes); + + /*** draw lighting buttons ***/ + initLightButtons(control->buttonQueue); +/* + controlAttrib.event_mask = (control->buttonQueue[lightingButtonsStart]).mask; + (control->buttonQueue[lightingButtonsStart]).self = + XCreateWindow(dsply, lightingWindow, + (control->buttonQueue[lightingButtonsStart]).buttonX, + (control->buttonQueue[lightingButtonsStart]).buttonY, + (control->buttonQueue[lightingButtonsStart]).buttonWidth, + (control->buttonQueue[lightingButtonsStart]).buttonHeight, + 0,0,InputOnly,CopyFromParent, + buttonCreateMASK,&controlAttrib); + XMakeAssoc(dsply,table,(control->buttonQueue[lightingButtonsStart]).self, + &((control->buttonQueue[lightingButtonsStart]).buttonKey)); + XMapWindow(dsply,(control->buttonQueue[lightingButtonsStart]).self); +*/ + for (i=(lightingButtonsStart + 1); i<(lightingButtonsEnd); i++) { + controlAttrib.event_mask = (control->buttonQueue[i]).mask; + (control->buttonQueue[i]).self = + XCreateWindow(dsply,lightingWindow, + (control->buttonQueue[i]).buttonX, + (control->buttonQueue[i]).buttonY, + (control->buttonQueue[i]).buttonWidth, + (control->buttonQueue[i]).buttonHeight, + 0,0,InputOnly,CopyFromParent, + buttonCreateMASK,&controlAttrib); + XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, + &((control->buttonQueue[i]).buttonKey)); + XMapWindow(dsply,(control->buttonQueue[i]).self); + } + + /* assign global direction variables for light projections */ + sinTheta = sin(-viewport->theta); + cosTheta = cos(-viewport->theta); + sinPhi = sin(viewport->phi); + cosPhi = cos(viewport->phi); + + return(0); + +} /* makeLightingPanel() */ + +/*************************** + * void drawLightingAxes() * + ***************************/ + +void +#ifdef _NO_PROTO +drawLightingAxes() +#else +drawLightingAxes(void) +#endif +{ + + 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 drawLightTransArrow() * + ******************************/ + +void +#ifdef _NO_PROTO +drawLightTransArrow() +#else +drawLightTransArrow(void) +#endif +{ + + int i; + float f; + + /*** Draw the intensity potentiometer window. ***/ + XClearArea(dsply,lightingWindow, + (control->buttonQueue[lightTranslucent]).buttonX, + (control->buttonQueue[lightTranslucent]).buttonY-5, + (control->buttonQueue[lightTranslucent]).buttonWidth, + (control->buttonQueue[lightTranslucent]).buttonHeight+10, + False); + GDrawLine(controlMessageGC,lightingWindow, + (control->buttonQueue[lightTranslucent]).buttonX, + (control->buttonQueue[lightTranslucent]).buttonY, + (control->buttonQueue[lightTranslucent]).buttonX, + (control->buttonQueue[lightTranslucent]).buttonY + + (control->buttonQueue[lightTranslucent]).buttonHeight,Xoption); + GDrawLine(controlMessageGC,lightingWindow, + (control->buttonQueue[lightTranslucent]).buttonX + 1, + (control->buttonQueue[lightTranslucent]).buttonY, + (control->buttonQueue[lightTranslucent]).buttonX + + (control->buttonQueue[lightTranslucent]).buttonWidth * 3/10, + (control->buttonQueue[lightTranslucent]).buttonY,Xoption); + GDrawLine(controlMessageGC,lightingWindow, + (control->buttonQueue[lightTranslucent]).buttonX + 1, + (control->buttonQueue[lightTranslucent]).buttonY + + (control->buttonQueue[lightTranslucent]).yHalf/2, + (control->buttonQueue[lightTranslucent]).buttonX + + (control->buttonQueue[lightTranslucent]).buttonWidth * 2/10, + (control->buttonQueue[lightTranslucent]).buttonY + + (control->buttonQueue[lightTranslucent]).yHalf/2,Xoption); + GDrawLine(controlMessageGC,lightingWindow, + (control->buttonQueue[lightTranslucent]).buttonX + 1, + (control->buttonQueue[lightTranslucent]).buttonY + + (control->buttonQueue[lightTranslucent]).yHalf, + (control->buttonQueue[lightTranslucent]).buttonX + + (control->buttonQueue[lightTranslucent]).buttonWidth * 3/10, + (control->buttonQueue[lightTranslucent]).buttonY + + (control->buttonQueue[lightTranslucent]).yHalf,Xoption); + GDrawLine(controlMessageGC,lightingWindow, + (control->buttonQueue[lightTranslucent]).buttonX + 1, + (control->buttonQueue[lightTranslucent]).buttonY + + (control->buttonQueue[lightTranslucent]).buttonHeight*3/4, + (control->buttonQueue[lightTranslucent]).buttonX + + (control->buttonQueue[lightTranslucent]).buttonWidth * 2/10, + (control->buttonQueue[lightTranslucent]).buttonY + + (control->buttonQueue[lightTranslucent]).buttonHeight*3/4,Xoption); + GDrawLine(controlMessageGC,lightingWindow, + (control->buttonQueue[lightTranslucent]).buttonX + 1, + (control->buttonQueue[lightTranslucent]).buttonY + + (control->buttonQueue[lightTranslucent]).buttonHeight, + (control->buttonQueue[lightTranslucent]).buttonX + + (control->buttonQueue[lightTranslucent]).buttonWidth * 3/10, + (control->buttonQueue[lightTranslucent]).buttonY + + (control->buttonQueue[lightTranslucent]).buttonHeight,Xoption); + + /*** Draw the intensity selection arrow ***/ + GSetForeground(lightingGC,(float)lightingTransArrowColor,Xoption); + + f = (control->buttonQueue[lightTranslucent].buttonY + + control->buttonQueue[lightTranslucent].buttonHeight) - + (tempLightIntensity * + control->buttonQueue[lightTranslucent].buttonHeight); + i = f; + GDrawLine(lightingGC, lightingWindow, arrowHead + 10, i, + arrowHead + 22, i + 2, Xoption); + GDrawLine(lightingGC, lightingWindow, arrowHead + 22, i + 2, + arrowHead + 22, i - 2, Xoption); + GDrawLine(lightingGC, lightingWindow, arrowHead + 22, i - 2, + arrowHead + 10, i, Xoption); + +} /* drawLightTransArrow() */ + + + + + +/**************************** + * void drawLightingPanel() * + ****************************/ + +void +#ifdef _NO_PROTO +drawLightingPanel() +#else +drawLightingPanel(void) +#endif +{ + + 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 */ + + + + + diff --git a/src/graph/view3D/lighting3d.c.pamphlet b/src/graph/view3D/lighting3d.c.pamphlet deleted file mode 100644 index adcd6850..00000000 --- a/src/graph/view3D/lighting3d.c.pamphlet +++ /dev/null @@ -1,627 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D lighting3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _LIGHTING3D_C -#include "axiom-c-macros.h" - -#include <math.h> -#include <string.h> - -#include "light11.bitmap" -#include "light11.mask" - - -#include "header.h" -#include "static.h" -#include "draw.h" -#include "cpanel.h" -#include "volume.h" - -#include "Gfun.H1" -#include "XSpadFill.H1" -#include "all_3d.H1" - -#define lightMASK ExposureMask -#define lightCursorForeground lightingTitleColor -#define lightCursorBackground foregroundColor - -#define lightFontHeight (lightingFont->max_bounds.ascent+lightingFont->max_bounds.descent) - -#define lightingAxesColor monoColor(52) -#define lightingLabelColor monoColor(12) -#define lightingBoxColor monoColor(138) -#define lightingLightColor monoColor(7) -#define lightingTitleColor monoColor(69) -#define lightingButtonColor monoColor(140) -#define lightingTransColor monoColor(140) -#define lightingTransArrowColor monoColor(100) -#define lightingTransLabelColor monoColor(207) - -#define lightingAxesSize 175 -#define lightingAxesX 61 -#define lightingAxesY 28 - -#define lightAxesScale 110 /* the extent of the axes in object space */ -#define lightScale 0.63 /* projected scale factor */ - -#define arrowHead (control->buttonQueue[lightTranslucent].buttonX + 5) -static viewTriple point0 = {0,0,0}; - - -/*************************** - * int makeLightingPanel() * - ***************************/ - -int -#ifdef _NO_PROTO -makeLightingPanel() -#else -makeLightingPanel(void) -#endif -{ - - int i; - XSetWindowAttributes cwAttrib, controlAttrib; - XSizeHints sizehint; - Pixmap lightbits,lightmask; - XColor foreColor, backColor; - - lightbits = XCreateBitmapFromData(dsply,rtWindow, lightBitmap_bits, - lightBitmap_width,lightBitmap_height); - lightmask = XCreateBitmapFromData(dsply,rtWindow, lightMask_bits, - lightMask_width,lightMask_height); - cwAttrib.background_pixel = backgroundColor; - cwAttrib.border_pixel = foregroundColor; - cwAttrib.event_mask = lightMASK; - cwAttrib.colormap = colorMap; - cwAttrib.override_redirect = overrideManager; - foreColor.pixel = lightCursorForeground; - XQueryColor(dsply,colorMap,&foreColor); - backColor.pixel = lightCursorBackground; - XQueryColor(dsply,colorMap,&backColor); - cwAttrib.cursor = XCreatePixmapCursor(dsply,lightbits,lightmask, - &foreColor,&backColor, - lightBitmap_x_hot,lightBitmap_y_hot); - lightingWindow = XCreateWindow(dsply,control->controlWindow, - -3,-3,controlWidth,controlHeight,3, - CopyFromParent,InputOutput,CopyFromParent, - controlCreateMASK,&cwAttrib); - - sizehint.flags = USPosition | USSize; - sizehint.x = 0; - sizehint.y = 0; - sizehint.width = controlWidth; - sizehint.height = controlHeight; - /*** the None stands for icon pixmap. ***/ - XSetNormalHints(dsply,lightingWindow,&sizehint); - XSetStandardProperties(dsply,lightingWindow,"Lighting Panel 3D", - "Lighting Panel",None,NULL,0,&sizehint); - - /*** lighting axes window ***/ - cwAttrib.event_mask = 0; - lightingAxes = XCreateWindow(dsply,lightingWindow, - lightingAxesX,lightingAxesY, - lightingAxesSize,lightingAxesSize, - 0,CopyFromParent,InputOutput,CopyFromParent, - controlCreateMASK,&cwAttrib); - - sizehint.flags = USPosition | USSize; - sizehint.x = lightingAxesX; - sizehint.y = lightingAxesY; - sizehint.width = lightingAxesSize; - sizehint.height = lightingAxesSize; - /*** the None stands for icon pixmap ***/ - XSetNormalHints(dsply,lightingAxes,&sizehint); - XSetStandardProperties(dsply,lightingAxes,"Lighting Axes","Lighting Axes", - None,NULL,0,&sizehint); - XMapWindow(dsply,lightingAxes); - - /*** draw lighting buttons ***/ - initLightButtons(control->buttonQueue); -/* - controlAttrib.event_mask = (control->buttonQueue[lightingButtonsStart]).mask; - (control->buttonQueue[lightingButtonsStart]).self = - XCreateWindow(dsply, lightingWindow, - (control->buttonQueue[lightingButtonsStart]).buttonX, - (control->buttonQueue[lightingButtonsStart]).buttonY, - (control->buttonQueue[lightingButtonsStart]).buttonWidth, - (control->buttonQueue[lightingButtonsStart]).buttonHeight, - 0,0,InputOnly,CopyFromParent, - buttonCreateMASK,&controlAttrib); - XMakeAssoc(dsply,table,(control->buttonQueue[lightingButtonsStart]).self, - &((control->buttonQueue[lightingButtonsStart]).buttonKey)); - XMapWindow(dsply,(control->buttonQueue[lightingButtonsStart]).self); -*/ - for (i=(lightingButtonsStart + 1); i<(lightingButtonsEnd); i++) { - controlAttrib.event_mask = (control->buttonQueue[i]).mask; - (control->buttonQueue[i]).self = - XCreateWindow(dsply,lightingWindow, - (control->buttonQueue[i]).buttonX, - (control->buttonQueue[i]).buttonY, - (control->buttonQueue[i]).buttonWidth, - (control->buttonQueue[i]).buttonHeight, - 0,0,InputOnly,CopyFromParent, - buttonCreateMASK,&controlAttrib); - XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, - &((control->buttonQueue[i]).buttonKey)); - XMapWindow(dsply,(control->buttonQueue[i]).self); - } - - /* assign global direction variables for light projections */ - sinTheta = sin(-viewport->theta); - cosTheta = cos(-viewport->theta); - sinPhi = sin(viewport->phi); - cosPhi = cos(viewport->phi); - - return(0); - -} /* makeLightingPanel() */ - -/*************************** - * void drawLightingAxes() * - ***************************/ - -void -#ifdef _NO_PROTO -drawLightingAxes() -#else -drawLightingAxes(void) -#endif -{ - - 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 drawLightTransArrow() * - ******************************/ - -void -#ifdef _NO_PROTO -drawLightTransArrow() -#else -drawLightTransArrow(void) -#endif -{ - - int i; - float f; - - /*** Draw the intensity potentiometer window. ***/ - XClearArea(dsply,lightingWindow, - (control->buttonQueue[lightTranslucent]).buttonX, - (control->buttonQueue[lightTranslucent]).buttonY-5, - (control->buttonQueue[lightTranslucent]).buttonWidth, - (control->buttonQueue[lightTranslucent]).buttonHeight+10, - False); - GDrawLine(controlMessageGC,lightingWindow, - (control->buttonQueue[lightTranslucent]).buttonX, - (control->buttonQueue[lightTranslucent]).buttonY, - (control->buttonQueue[lightTranslucent]).buttonX, - (control->buttonQueue[lightTranslucent]).buttonY + - (control->buttonQueue[lightTranslucent]).buttonHeight,Xoption); - GDrawLine(controlMessageGC,lightingWindow, - (control->buttonQueue[lightTranslucent]).buttonX + 1, - (control->buttonQueue[lightTranslucent]).buttonY, - (control->buttonQueue[lightTranslucent]).buttonX + - (control->buttonQueue[lightTranslucent]).buttonWidth * 3/10, - (control->buttonQueue[lightTranslucent]).buttonY,Xoption); - GDrawLine(controlMessageGC,lightingWindow, - (control->buttonQueue[lightTranslucent]).buttonX + 1, - (control->buttonQueue[lightTranslucent]).buttonY + - (control->buttonQueue[lightTranslucent]).yHalf/2, - (control->buttonQueue[lightTranslucent]).buttonX + - (control->buttonQueue[lightTranslucent]).buttonWidth * 2/10, - (control->buttonQueue[lightTranslucent]).buttonY + - (control->buttonQueue[lightTranslucent]).yHalf/2,Xoption); - GDrawLine(controlMessageGC,lightingWindow, - (control->buttonQueue[lightTranslucent]).buttonX + 1, - (control->buttonQueue[lightTranslucent]).buttonY + - (control->buttonQueue[lightTranslucent]).yHalf, - (control->buttonQueue[lightTranslucent]).buttonX + - (control->buttonQueue[lightTranslucent]).buttonWidth * 3/10, - (control->buttonQueue[lightTranslucent]).buttonY + - (control->buttonQueue[lightTranslucent]).yHalf,Xoption); - GDrawLine(controlMessageGC,lightingWindow, - (control->buttonQueue[lightTranslucent]).buttonX + 1, - (control->buttonQueue[lightTranslucent]).buttonY + - (control->buttonQueue[lightTranslucent]).buttonHeight*3/4, - (control->buttonQueue[lightTranslucent]).buttonX + - (control->buttonQueue[lightTranslucent]).buttonWidth * 2/10, - (control->buttonQueue[lightTranslucent]).buttonY + - (control->buttonQueue[lightTranslucent]).buttonHeight*3/4,Xoption); - GDrawLine(controlMessageGC,lightingWindow, - (control->buttonQueue[lightTranslucent]).buttonX + 1, - (control->buttonQueue[lightTranslucent]).buttonY + - (control->buttonQueue[lightTranslucent]).buttonHeight, - (control->buttonQueue[lightTranslucent]).buttonX + - (control->buttonQueue[lightTranslucent]).buttonWidth * 3/10, - (control->buttonQueue[lightTranslucent]).buttonY + - (control->buttonQueue[lightTranslucent]).buttonHeight,Xoption); - - /*** Draw the intensity selection arrow ***/ - GSetForeground(lightingGC,(float)lightingTransArrowColor,Xoption); - - f = (control->buttonQueue[lightTranslucent].buttonY + - control->buttonQueue[lightTranslucent].buttonHeight) - - (tempLightIntensity * - control->buttonQueue[lightTranslucent].buttonHeight); - i = f; - GDrawLine(lightingGC, lightingWindow, arrowHead + 10, i, - arrowHead + 22, i + 2, Xoption); - GDrawLine(lightingGC, lightingWindow, arrowHead + 22, i + 2, - arrowHead + 22, i - 2, Xoption); - GDrawLine(lightingGC, lightingWindow, arrowHead + 22, i - 2, - arrowHead + 10, i, Xoption); - -} /* drawLightTransArrow() */ - - - - - -/**************************** - * void drawLightingPanel() * - ****************************/ - -void -#ifdef _NO_PROTO -drawLightingPanel() -#else -drawLightingPanel(void) -#endif -{ - - 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 */ - - - - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/main3d.c.pamphlet b/src/graph/view3D/main3d.c index 01674d58..2197538e 100644 --- a/src/graph/view3D/main3d.c.pamphlet +++ b/src/graph/view3D/main3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D main3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _MAIN3D_C #include "axiom-c-macros.h" @@ -124,7 +110,7 @@ int spadMode=no, /* yes if receiving AXIOM command and int spadSignalReceived=0; /* yes if current state is a result of a signal from AXIOM */ int inNextEvent=no; /* true just before a call to - XNextEvent */ + XNextEvent */ jmp_buf jumpFlag; char errorStr[80]; @@ -154,7 +140,7 @@ float sinTheta, sinPhi, cosTheta, cosPhi, viewScale, int xCenter, yCenter; XWindowAttributes vwInfo; -XWindowAttributes graphWindowAttrib; +XWindowAttributes graphWindowAttrib; XPoint *quadMesh; XImage *imageX; @@ -185,7 +171,7 @@ XPoint polygonMesh[20]; int saveFlag=no; int firstTime=yes, noTrans = yes, startup = yes; int redrawView = no; /* set to yes when returning from - subpanels */ + subpanels */ int redoColor = no, pixelSetFlag = no, redoDither = no; int redoSmooth = no, multiColorFlag = no; @@ -214,9 +200,9 @@ int doingPanel=CONTROLpanel; /* rewrite titles in proper panel */ int doingVolume; int screenX; /* global floating point indicating mouse position - on frustrum screen */ + on frustrum screen */ float xClipMinN, xClipMaxN, /* normalized values for - clip volume */ + clip volume */ yClipMinN, yClipMaxN, zClipMinN, zClipMaxN, clipValue; /* mouse input */ @@ -444,13 +430,13 @@ main(void) GCBackground ,&controlGCVals); carefullySetFont(globalGC1,globalFont); PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* controlMessageGC */ controlGCVals.foreground = controlMessageColor; controlGCVals.background = backgroundColor; controlMessageGC = XCreateGC(dsply,rtWindow,GCForeground | - GCBackground ,&controlGCVals); + GCBackground ,&controlGCVals); carefullySetFont(controlMessageGC,globalFont); /* globalGC2 */ @@ -458,38 +444,38 @@ main(void) globalGC2 = XCreateGC(dsply,rtWindow,GCForeground,&controlGCVals); carefullySetFont(globalGC2,buttonFont); PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* trashGC */ controlGCVals.function = GXcopy; trashGC = XCreateGC(dsply,rtWindow,0 ,&controlGCVals); carefullySetFont(trashGC,buttonFont); PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* componentGC */ componentGC = XCreateGC(dsply,rtWindow,0 ,&controlGCVals); carefullySetFont(componentGC,buttonFont); PSCreateContext(componentGC, "componentGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* opaqueGC */ opaqueGC = XCreateGC(dsply,rtWindow,0 ,&controlGCVals); carefullySetFont(opaqueGC,buttonFont); PSCreateContext(opaqueGC, "opaqueGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* renderGC */ renderGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); carefullySetFont(renderGC,buttonFont); PSCreateContext(renderGC, "renderGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* globGC */ globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); carefullySetFont(globGC,headerFont); PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* anotherGC */ controlGCVals.line_width = colorWidth; @@ -497,47 +483,47 @@ main(void) GCFunction ,&controlGCVals); carefullySetFont(anotherGC,titleFont); PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* also create one for rendering (grayscale only for now) */ /* assign arbitrary number to renderGC as 9991 - see header.h */ PSCreateContext(GC9991, "renderGC", psNormalWidth, psButtCap, - psRoundJoin, psWhite, psBlack ); + psRoundJoin, psWhite, psBlack ); /* processGC */ gcVals.background = backgroundColor; processGC = XCreateGC(dsply,rtWindow,GCBackground | - GCFillStyle,&gcVals); + GCFillStyle,&gcVals); carefullySetFont(processGC,buttonFont); /* lightingGC */ controlGCVals.foreground = monoColor(axesColor); controlGCVals.background = backgroundColor; lightingGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(lightingGC,lightingFont); /* volumeGC */ volumeGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(volumeGC,volumeFont); /* quitGC */ quitGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(quitGC,buttonFont); /* saveGC */ saveGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(saveGC,buttonFont); /* graphGC */ graphGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(graphGC,buttonFont); /**** Get Data from the Viewport Manager ****/ @@ -606,8 +592,8 @@ main(void) check(write(Socket,&(viewport->viewWindow),sizeof(Window))); viewmap = XCreatePixmap(dsply,viewport->viewWindow, - vwInfo.width,vwInfo.height, - DisplayPlanes(dsply,scrn)); + vwInfo.width,vwInfo.height, + DisplayPlanes(dsply,scrn)); viewmap_valid = 1; processEvents(); @@ -662,9 +648,3 @@ mergeDatabases(void) XrmMergeDatabases(homeDB,&rDB); } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/mesh3d.c b/src/graph/view3D/mesh3d.c new file mode 100644 index 00000000..ee71074b --- /dev/null +++ b/src/graph/view3D/mesh3d.c @@ -0,0 +1,136 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _MESH3D_C +#include "axiom-c-macros.h" + +#include <math.h> + +#include "header.h" +#include "all_3d.H1" + +/*************************************************************************** + *** void getMeshNormal(x0,y0,z0,x1,y1,z1,x2,y2,z2,zMin,zRange,Normal); *** + ***************************************************************************/ + +void +#ifdef _NO_PROTO +getMeshNormal(x0,y0,z0,x1,y1,z1,x2,y2,z2,zMin,zRange,Normal) + float x0,y0,z0,x1,y1,z1,x2,y2,z2,zMin,zRange,Normal[3]; +#else +getMeshNormal(float x0,float y0,float z0,float x1,float y1,float z1, + float x2,float y2,float z2,float zMin,float zRange,float Normal[3]) +#endif +{ + float Ax,Ay,Az,Bx,By,Bz, + UnitFactor; + + Ax = x0-x1; Ay = y0-y1; Az = z0-z1; + Bx = x2-x1; By = y2-y1; Bz = z2-z1; + + /* compute cross product */ + + Normal[0] = (Ay*Bz - Az*By); + Normal[1] = (Az*Bx - Ax*Bz); + Normal[2] = (Ax*By - Ay*Bx); + + /* normalize normal vector */ + + UnitFactor = sqrt(Normal[0]*Normal[0] + + Normal[1]*Normal[1] + + Normal[2]*Normal[2]); + if (UnitFactor > 0.0) { + Normal[0] /= UnitFactor; + Normal[1] /= UnitFactor; + Normal[2] /= UnitFactor; + } else { + Normal[0] = 0.0; + Normal[1] = 0.0; + Normal[2] = 0.0; + } + +} /* getMeshNormal() */ + + +/*********************************** + **** void normalizeVector(v) **** + ***********************************/ + +void +#ifdef _NO_PROTO +normalizeVector(v) + float *v; +#else +normalizeVector(float *v) +#endif +{ + /* v should be a triple (ignoring the rest of the array if necessary) */ + + float UnitFactor; + + UnitFactor = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + if (UnitFactor != 0.0) { + v[0] /= UnitFactor; + v[1] /= UnitFactor; + v[2] /= UnitFactor; + } else { + v[0] = v[1] = v[2] = 0.0; + } + +} /* normalizeVector() */ + + +/************************************ + **** void dotProduct(a,b,size) **** + ************************************/ + +float +#ifdef _NO_PROTO +dotProduct(a,b,size) + float *a,*b; + int size; +#else +dotProduct(float * a,float *b,int size) +#endif +{ + int i; + float f=0; + + for (i=0; i<size; i++) + f += (a[i]*b[i]); + return(f); + +} /* dotProduct() */ + diff --git a/src/graph/view3D/mesh3d.c.pamphlet b/src/graph/view3D/mesh3d.c.pamphlet deleted file mode 100644 index 9abe377f..00000000 --- a/src/graph/view3D/mesh3d.c.pamphlet +++ /dev/null @@ -1,156 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D mesh3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _MESH3D_C -#include "axiom-c-macros.h" - -#include <math.h> - -#include "header.h" -#include "all_3d.H1" - -/*************************************************************************** - *** void getMeshNormal(x0,y0,z0,x1,y1,z1,x2,y2,z2,zMin,zRange,Normal); *** - ***************************************************************************/ - -void -#ifdef _NO_PROTO -getMeshNormal(x0,y0,z0,x1,y1,z1,x2,y2,z2,zMin,zRange,Normal) - float x0,y0,z0,x1,y1,z1,x2,y2,z2,zMin,zRange,Normal[3]; -#else -getMeshNormal(float x0,float y0,float z0,float x1,float y1,float z1, - float x2,float y2,float z2,float zMin,float zRange,float Normal[3]) -#endif -{ - float Ax,Ay,Az,Bx,By,Bz, - UnitFactor; - - Ax = x0-x1; Ay = y0-y1; Az = z0-z1; - Bx = x2-x1; By = y2-y1; Bz = z2-z1; - - /* compute cross product */ - - Normal[0] = (Ay*Bz - Az*By); - Normal[1] = (Az*Bx - Ax*Bz); - Normal[2] = (Ax*By - Ay*Bx); - - /* normalize normal vector */ - - UnitFactor = sqrt(Normal[0]*Normal[0] + - Normal[1]*Normal[1] + - Normal[2]*Normal[2]); - if (UnitFactor > 0.0) { - Normal[0] /= UnitFactor; - Normal[1] /= UnitFactor; - Normal[2] /= UnitFactor; - } else { - Normal[0] = 0.0; - Normal[1] = 0.0; - Normal[2] = 0.0; - } - -} /* getMeshNormal() */ - - -/*********************************** - **** void normalizeVector(v) **** - ***********************************/ - -void -#ifdef _NO_PROTO -normalizeVector(v) - float *v; -#else -normalizeVector(float *v) -#endif -{ - /* v should be a triple (ignoring the rest of the array if necessary) */ - - float UnitFactor; - - UnitFactor = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); - if (UnitFactor != 0.0) { - v[0] /= UnitFactor; - v[1] /= UnitFactor; - v[2] /= UnitFactor; - } else { - v[0] = v[1] = v[2] = 0.0; - } - -} /* normalizeVector() */ - - -/************************************ - **** void dotProduct(a,b,size) **** - ************************************/ - -float -#ifdef _NO_PROTO -dotProduct(a,b,size) - float *a,*b; - int size; -#else -dotProduct(float * a,float *b,int size) -#endif -{ - int i; - float f=0; - - for (i=0; i<size; i++) - f += (a[i]*b[i]); - return(f); - -} /* dotProduct() */ - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/msort3d.c.pamphlet b/src/graph/view3D/msort3d.c index 73202452..36e07743 100644 --- a/src/graph/view3D/msort3d.c.pamphlet +++ b/src/graph/view3D/msort3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D msort3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _MSORT3D_C #include "axiom-c-macros.h" @@ -182,7 +168,7 @@ msort(linkThing *p,int min,int max,int (*compare)(linkThing *, linkThing *)) temp = q->next; q->next = 0; xxx = merge(msort(p,min,mid,compare), - msort(temp,mid+1,max,compare), compare); + msort(temp,mid+1,max,compare), compare); return(xxx); } @@ -191,9 +177,3 @@ msort(linkThing *p,int min,int max,int (*compare)(linkThing *, linkThing *)) -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/pot3d.c b/src/graph/view3D/pot3d.c new file mode 100644 index 00000000..6b4a9fd5 --- /dev/null +++ b/src/graph/view3D/pot3d.c @@ -0,0 +1,97 @@ +/* + Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _POT3D_C +#include "axiom-c-macros.h" + +#include "header.h" +#include "all_3d.H1" + +/****************************/ +/*** void getPotValue() ***/ +/****************************/ + +mouseCoord +#ifdef _NO_PROTO +getPotValue(eX,eY,xH,yH) + short eX,eY,xH,yH; +#else +getPotValue(short eX,short eY,short xH,short yH) +#endif +{ + + mouseCoord whereMouse; + float x,y; + + x = (float)eX/xH - 1; + y = -((float)eY/yH -1); + + /* make non-linear potentiometer */ + whereMouse.x = x*x*x; + whereMouse.y = y*y*y; + if (whereMouse.x > 1.0) whereMouse.x = 1.0; + if (whereMouse.y > 1.0) whereMouse.y = 1.0; + if (whereMouse.x < -1.0) whereMouse.x = -1.0; + if (whereMouse.y < -1.0) whereMouse.y = -1.0; + + return(whereMouse); + +} /* getPotValue() */ + + + +/**********************************/ +/*** void getLinearPotValue() ***/ +/**********************************/ + +mouseCoord +#ifdef _NO_PROTO +getLinearPotValue(eX,eY,xH,yH) + short eX,eY,xH,yH; +#else +getLinearPotValue(short eX,short eY,short xH,short yH) +#endif +{ + + mouseCoord whereMouse; + + whereMouse.x = (float)eX/xH - 1; + whereMouse.y = -((float)eY/yH -1); + + return(whereMouse); + +} /* getLinearPotValue() */ + + diff --git a/src/graph/view3D/pot3d.c.pamphlet b/src/graph/view3D/pot3d.c.pamphlet deleted file mode 100644 index ee8ea1fc..00000000 --- a/src/graph/view3D/pot3d.c.pamphlet +++ /dev/null @@ -1,117 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D pot3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _POT3D_C -#include "axiom-c-macros.h" - -#include "header.h" -#include "all_3d.H1" - -/****************************/ -/*** void getPotValue() ***/ -/****************************/ - -mouseCoord -#ifdef _NO_PROTO -getPotValue(eX,eY,xH,yH) - short eX,eY,xH,yH; -#else -getPotValue(short eX,short eY,short xH,short yH) -#endif -{ - - mouseCoord whereMouse; - float x,y; - - x = (float)eX/xH - 1; - y = -((float)eY/yH -1); - - /* make non-linear potentiometer */ - whereMouse.x = x*x*x; - whereMouse.y = y*y*y; - if (whereMouse.x > 1.0) whereMouse.x = 1.0; - if (whereMouse.y > 1.0) whereMouse.y = 1.0; - if (whereMouse.x < -1.0) whereMouse.x = -1.0; - if (whereMouse.y < -1.0) whereMouse.y = -1.0; - - return(whereMouse); - -} /* getPotValue() */ - - - -/**********************************/ -/*** void getLinearPotValue() ***/ -/**********************************/ - -mouseCoord -#ifdef _NO_PROTO -getLinearPotValue(eX,eY,xH,yH) - short eX,eY,xH,yH; -#else -getLinearPotValue(short eX,short eY,short xH,short yH) -#endif -{ - - mouseCoord whereMouse; - - whereMouse.x = (float)eX/xH - 1; - whereMouse.y = -((float)eY/yH -1); - - return(whereMouse); - -} /* getLinearPotValue() */ - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/process.h b/src/graph/view3D/process.h index 82f80c79..47400a5d 100755..100644 --- a/src/graph/view3D/process.h +++ b/src/graph/view3D/process.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define maxEyeDistance 2000.0 diff --git a/src/graph/view3D/process3d.c b/src/graph/view3D/process3d.c new file mode 100644 index 00000000..79c11b42 --- /dev/null +++ b/src/graph/view3D/process3d.c @@ -0,0 +1,1605 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _PROCESS3D_C +#include "axiom-c-macros.h" + +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/time.h> + + +#include "header.h" +#include "cpanel.h" +#include "volume.h" +#include "mode.h" +#include "process.h" +#include "draw.h" +#include "sockio.h" +#include "com.h" + + +#include "util.H1" +#include "Gfun.H1" +#include "pixmap.H1" +#include "XShade.H1" +#include "XSpadFill.H1" +#include "all_3d.H1" + +#define inside(A,B) (((XButtonEvent *)event)->x >= A && \ + ((XButtonEvent *)event)->x <= B) + + +void +#ifdef _NO_PROTO +buttonAction (bKey) +int bKey; +#else +buttonAction (int bKey) +#endif +{ + + char *s1, *s2; + int strL, strL1, strL2, offShade=14; + + /* Button colors which are offColor, RED, are turned off, and those which + are onColor, GREEN, indicate the mode is in effect. */ + + switch (bKey) { + + case hideControl: + if (viewport->haveControl) { + viewport->haveControl = no; + XUnmapWindow(dsply,control->controlWindow); + } + break; + + case region3D: + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + if (viewport->regionOn) { + viewport->regionOn = no; + (control->buttonQueue[region3D]).textColor = offColor; + viewData.box = 0; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[region3D]).buttonX, + (control->buttonQueue[region3D]).buttonY, + (control->buttonQueue[region3D]).buttonWidth, + (control->buttonQueue[region3D]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[region3D]).buttonX, + (control->buttonQueue[region3D]).buttonY, + (control->buttonQueue[region3D]).buttonWidth, + (control->buttonQueue[region3D]).buttonHeight,Xoption); + } + } else { /* inverted color for region off */ + viewport->regionOn = yes; + viewData.box = 1; + (control->buttonQueue[region3D]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1,(float)backgroundColor,Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[region3D]).buttonX, + (control->buttonQueue[region3D]).buttonY, + (control->buttonQueue[region3D]).buttonWidth, + (control->buttonQueue[region3D]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[region3D]).buttonX, + (control->buttonQueue[region3D]).buttonY, + (control->buttonQueue[region3D]).buttonWidth, + (control->buttonQueue[region3D]).buttonHeight,Xoption); + } + } + + s = (control->buttonQueue[region3D]).text; + strL = strlen(s); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[region3D]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[region3D]).buttonX + + centerX(processGC,s,strL, + (control->buttonQueue[region3D]).buttonWidth), + (control->buttonQueue[region3D]).buttonY + + centerY(processGC, + (control->buttonQueue[region3D]).buttonHeight), + s,strL,Xoption); + redoSmooth = yes; + drawViewport(Xoption); + break; + + + + case bwColor: + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + if (!mono) { + if (viewport->monoOn) { + viewport->monoOn = no; + if (viewport->hueTop == viewport->hueOffset) redoColor = yes; + else redoDither = yes; + (control->buttonQueue[bwColor]).textColor = offColor; + (control->buttonQueue[bwColor]).text = "BW"; + } else { + viewport->monoOn = yes; + maxGreyShade = XInitShades(dsply,scrn); + if (viewport->hueTop == viewport->hueOffset) redoColor = yes; + else redoDither = yes; + (control->buttonQueue[bwColor]).textColor = onColor; + (control->buttonQueue[bwColor]).text = "BW"; + GSetForeground(globalGC1,(float)backgroundColor,Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[bwColor]).buttonX, + (control->buttonQueue[bwColor]).buttonY, + (control->buttonQueue[bwColor]).buttonWidth, + (control->buttonQueue[bwColor]).buttonHeight); + GSetForeground(globalGC1,(float)monoColor(buttonColor),Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[bwColor]).buttonX, + (control->buttonQueue[bwColor]).buttonY, + (control->buttonQueue[bwColor]).buttonWidth, + (control->buttonQueue[bwColor]).buttonHeight,Xoption); + } + + s = (control->buttonQueue[bwColor]).text; + strL = strlen(s); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[bwColor]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[bwColor]).buttonX + + centerX(processGC,s,strL, + (control->buttonQueue[bwColor]).buttonWidth), + (control->buttonQueue[bwColor]).buttonY + + centerY(processGC, + (control->buttonQueue[bwColor]).buttonHeight), + s,strL,Xoption); + drawColorMap(); + redoSmooth = yes; + writeTitle(); + drawViewport(Xoption); + } + break; + + + + case outlineOnOff: + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + if (viewData.outlineRenderOn) { + viewData.outlineRenderOn = 0; + (control->buttonQueue[outlineOnOff]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[outlineOnOff]).buttonX, + (control->buttonQueue[outlineOnOff]).buttonY, + (control->buttonQueue[outlineOnOff]).buttonWidth, + (control->buttonQueue[outlineOnOff]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[outlineOnOff]).buttonX, + (control->buttonQueue[outlineOnOff]).buttonY, + (control->buttonQueue[outlineOnOff]).buttonWidth, + (control->buttonQueue[outlineOnOff]).buttonHeight,Xoption); + } + } else { + viewData.outlineRenderOn = 1; + (control->buttonQueue[outlineOnOff]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1,(float)backgroundColor,Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[outlineOnOff]).buttonX, + (control->buttonQueue[outlineOnOff]).buttonY, + (control->buttonQueue[outlineOnOff]).buttonWidth, + (control->buttonQueue[outlineOnOff]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[outlineOnOff]).buttonX, + (control->buttonQueue[outlineOnOff]).buttonY, + (control->buttonQueue[outlineOnOff]).buttonWidth, + (control->buttonQueue[outlineOnOff]).buttonHeight,Xoption); + } + } + s = (control->buttonQueue[outlineOnOff]).text; + strL = strlen(s); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[outlineOnOff]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[outlineOnOff]).buttonX + + centerX(processGC,s,strL, + (control->buttonQueue[outlineOnOff]).buttonWidth), + (control->buttonQueue[outlineOnOff]).buttonY + + centerY(processGC, + (control->buttonQueue[outlineOnOff]).buttonHeight), + s,strL,Xoption); + if (viewData.style == render) { + drawViewport(Xoption); + } + break; + + + case lighting: + if (saveFlag) { + doingPanel = CONTROLpanel; + XUnmapWindow(dsply,saveWindow); + } + doingPanel = LIGHTpanel; + tempLightPointer[0] = viewport->lightVector[0]; + tempLightPointer[1] = viewport->lightVector[1]; + tempLightPointer[2] = viewport->lightVector[2]; + tempLightIntensity = lightIntensity; + XMapWindow(dsply,lightingWindow); + break; + + + case viewVolume: + if (saveFlag) { + doingPanel = CONTROLpanel; + XUnmapWindow(dsply,saveWindow); + } + doingPanel = VOLUMEpanel; + XMapWindow(dsply,volumeWindow); + redrawView = yes; + drawViewport(Xoption); /* draw it with doingVolume set to yes */ + break; + + + case volumeReturn: + doingPanel = CONTROLpanel; + redoSmooth = yes; + redrawView = yes; + XUnmapWindow(dsply,volumeWindow); + break; + + + case volumeAbort: + doingPanel = CONTROLpanel; + redrawView = yes; + XUnmapWindow(dsply,volumeWindow); + break; + + + case lightReturn: + doingPanel = CONTROLpanel; + viewport->lightVector[0] = lightPointer[0] = tempLightPointer[0]; + viewport->lightVector[1] = lightPointer[1] = tempLightPointer[1]; + viewport->lightVector[2] = lightPointer[2] = tempLightPointer[2]; + lightIntensity = tempLightIntensity; + normalizeVector(viewport->lightVector); + redrawView = ((viewData.style == render) || (viewData.style == smooth)); + if (movingLight || changedIntensity) redoSmooth = yes; + XUnmapWindow(dsply,lightingWindow); + break; + + + case lightAbort: + movingLight = no; changedIntensity = no; + doingPanel = CONTROLpanel; + XUnmapWindow(dsply,lightingWindow); + break; + + + case resetView: + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + viewport->axesOn = yes; + viewport->regionOn = no; viewData.box = 0; + viewData.outlineRenderOn = 0; + viewport->monoOn = no; + viewport->zoomXOn = viewport->zoomYOn = viewport->zoomZOn = yes; + viewport->originrOn = yes; viewport->objectrOn = no; + viewport->originFlag = no; + viewport->xyOn = viewport->xzOn = viewport->yzOn = no; + viewport->lightVector[0] = -0.5; + viewport->lightVector[1] = 0.5; + viewport->lightVector[2] = 0.5; + viewport->translucency = viewData.translucency; + viewport->deltaX = viewport->deltaX0; + viewport->deltaY = viewport->deltaY0; + viewport->deltaY = viewport->deltaZ0; + viewport->scale = viewport->scale0; + viewport->scaleX = viewport->scaleY = viewport->scaleZ = 1.0; + if (!equal(viewport->theta,viewport->theta0) || !equal(viewport->phi,viewport->phi0)) + rotated = yes; + viewport->theta = viewport->axestheta = viewport->theta0 = viewData.theta; + viewport->phi = viewport->axesphi = viewport->phi0 = viewData.phi; + viewport->thetaObj = 0.0; + viewport->phiObj = 0.0; + redoSmooth = yes; + drawViewport(Xoption); + if (viewport->haveControl) drawControlPanel(); + writeTitle(); + break; + + + case axesOnOff: + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + if (viewport->axesOn) { + viewport->axesOn = no; + (control->buttonQueue[axesOnOff]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[axesOnOff]).buttonX, + (control->buttonQueue[axesOnOff]).buttonY, + (control->buttonQueue[axesOnOff]).buttonWidth, + (control->buttonQueue[axesOnOff]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[axesOnOff]).buttonX, + (control->buttonQueue[axesOnOff]).buttonY, + (control->buttonQueue[axesOnOff]).buttonWidth, + (control->buttonQueue[axesOnOff]).buttonHeight,Xoption); + } + } else { /* draw invert-color button */ + viewport->axesOn = yes; + (control->buttonQueue[axesOnOff]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1,(float)backgroundColor,Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[axesOnOff]).buttonX, + (control->buttonQueue[axesOnOff]).buttonY, + (control->buttonQueue[axesOnOff]).buttonWidth, + (control->buttonQueue[axesOnOff]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[axesOnOff]).buttonX, + (control->buttonQueue[axesOnOff]).buttonY, + (control->buttonQueue[axesOnOff]).buttonWidth, + (control->buttonQueue[axesOnOff]).buttonHeight,Xoption); + } + } + + s = (control->buttonQueue[axesOnOff]).text; + strL = strlen(s); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[axesOnOff]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[axesOnOff]).buttonX + + centerX(processGC,s,strL, + (control->buttonQueue[axesOnOff]).buttonWidth), + (control->buttonQueue[axesOnOff]).buttonY + + centerY(processGC, + (control->buttonQueue[axesOnOff]).buttonHeight), + s,strL,Xoption); + if (viewData.style == smooth) { + if (multiColorFlag) redoDither = yes; + else redoColor = yes; + } + drawViewport(Xoption); + break; + + + case zoomx: + if (viewport->zoomXOn) { + viewport->zoomXOn = no; + (control->buttonQueue[zoomx]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[zoomx]).buttonX, + (control->buttonQueue[zoomx]).buttonY, + (control->buttonQueue[zoomx]).buttonWidth, + (control->buttonQueue[zoomx]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[zoomx]).buttonX, + (control->buttonQueue[zoomx]).buttonY, + (control->buttonQueue[zoomx]).buttonWidth, + (control->buttonQueue[zoomx]).buttonHeight,Xoption); + } + } else { + viewport->zoomXOn = yes; + (control->buttonQueue[zoomx]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1,(float)backgroundColor,Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[zoomx]).buttonX, + (control->buttonQueue[zoomx]).buttonY, + (control->buttonQueue[zoomx]).buttonWidth, + (control->buttonQueue[zoomx]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[zoomx]).buttonX, + (control->buttonQueue[zoomx]).buttonY, + (control->buttonQueue[zoomx]).buttonWidth, + (control->buttonQueue[zoomx]).buttonHeight,Xoption); + } + } + + s = (control->buttonQueue[zoomx]).text; + strL = strlen(s); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[zoomx]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[zoomx]).buttonX + + centerX(processGC,s,strL, + (control->buttonQueue[zoomx]).buttonWidth), + (control->buttonQueue[zoomx]).buttonY + + centerY(processGC, + (control->buttonQueue[zoomx]).buttonHeight), + s,strL,Xoption); + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + break; + + + case zoomy: + if (viewport->zoomYOn) { + viewport->zoomYOn = no; + (control->buttonQueue[zoomy]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[zoomy]).buttonX, + (control->buttonQueue[zoomy]).buttonY, + (control->buttonQueue[zoomy]).buttonWidth, + (control->buttonQueue[zoomy]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[zoomy]).buttonX, + (control->buttonQueue[zoomy]).buttonY, + (control->buttonQueue[zoomy]).buttonWidth, + (control->buttonQueue[zoomy]).buttonHeight,Xoption); + } + } else { + viewport->zoomYOn = yes; + (control->buttonQueue[zoomy]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1,(float)backgroundColor,Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[zoomy]).buttonX, + (control->buttonQueue[zoomy]).buttonY, + (control->buttonQueue[zoomy]).buttonWidth, + (control->buttonQueue[zoomy]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[zoomy]).buttonX, + (control->buttonQueue[zoomy]).buttonY, + (control->buttonQueue[zoomy]).buttonWidth, + (control->buttonQueue[zoomy]).buttonHeight,Xoption); + } + } + + s = (control->buttonQueue[zoomy]).text; + strL = strlen(s); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[zoomy]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[zoomy]).buttonX + + centerX(processGC,s,strL, + (control->buttonQueue[zoomy]).buttonWidth), + (control->buttonQueue[zoomy]).buttonY + + centerY(processGC, + (control->buttonQueue[zoomy]).buttonHeight), + s,strL,Xoption); + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + break; + + + case zoomz: + if (viewport->zoomZOn) { + viewport->zoomZOn = no; + (control->buttonQueue[zoomz]).textColor = offColor; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[zoomz]).buttonX, + (control->buttonQueue[zoomz]).buttonY, + (control->buttonQueue[zoomz]).buttonWidth, + (control->buttonQueue[zoomz]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[zoomz]).buttonX, + (control->buttonQueue[zoomz]).buttonY, + (control->buttonQueue[zoomz]).buttonWidth, + (control->buttonQueue[zoomz]).buttonHeight,Xoption); + } + } else { + viewport->zoomZOn = yes; + (control->buttonQueue[zoomz]).textColor = onColor; + if (mono) { + GSetForeground(globalGC1,(float)backgroundColor,Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[zoomz]).buttonX, + (control->buttonQueue[zoomz]).buttonY, + (control->buttonQueue[zoomz]).buttonWidth, + (control->buttonQueue[zoomz]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[zoomz]).buttonX, + (control->buttonQueue[zoomz]).buttonY, + (control->buttonQueue[zoomz]).buttonWidth, + (control->buttonQueue[zoomz]).buttonHeight,Xoption); + } + } + + s = (control->buttonQueue[zoomz]).text; + strL = strlen(s); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[zoomz]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[zoomz]).buttonX + + centerX(processGC,s,strL, + (control->buttonQueue[zoomz]).buttonWidth), + (control->buttonQueue[zoomz]).buttonY + + centerY(processGC, + (control->buttonQueue[zoomz]).buttonHeight), + s,strL,Xoption); + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + break; + + + case originr: + viewport->originrOn = yes; + (control->buttonQueue[originr]).textColor = onColor; + viewport->objectrOn = no; + (control->buttonQueue[objectr]).textColor = offColor; + viewport->originFlag = yes; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[objectr]).buttonX, + (control->buttonQueue[objectr]).buttonY, + (control->buttonQueue[objectr]).buttonWidth, + (control->buttonQueue[objectr]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[objectr]).buttonX, + (control->buttonQueue[objectr]).buttonY, + (control->buttonQueue[objectr]).buttonWidth, + (control->buttonQueue[objectr]).buttonHeight,Xoption); + GSetForeground(globalGC1,(float)backgroundColor,Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[originr]).buttonX, + (control->buttonQueue[originr]).buttonY, + (control->buttonQueue[originr]).buttonWidth, + (control->buttonQueue[originr]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[originr]).buttonX, + (control->buttonQueue[originr]).buttonY, + (control->buttonQueue[originr]).buttonWidth, + (control->buttonQueue[originr]).buttonHeight,Xoption); + } + s1 = (control->buttonQueue[objectr]).text; + strL1 = strlen(s1); + s2 = (control->buttonQueue[originr]).text; + strL2 = strlen(s2); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[objectr]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[objectr]).buttonX + + centerX(processGC,s1,strL1, + (control->buttonQueue[objectr]).buttonWidth), + (control->buttonQueue[objectr]).buttonY + + centerY(processGC, + (control->buttonQueue[objectr]).buttonHeight), + s1,strL1,Xoption); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[originr]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[originr]).buttonX + + centerX(processGC,s2,strL2, + (control->buttonQueue[originr]).buttonWidth), + (control->buttonQueue[originr]).buttonY + + centerY(processGC, + (control->buttonQueue[originr]).buttonHeight), + s2,strL2,Xoption); + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + break; + + + + case objectr: + viewport->objectrOn = yes; + (control->buttonQueue[objectr]).textColor = onColor; + viewport->originrOn = no; + (control->buttonQueue[originr]).textColor = offColor; + + viewport->originFlag = no; + if (mono) { + XChangeShade(dsply,offShade); + XShadeRectangle(dsply,control->controlWindow, + (control->buttonQueue[originr]).buttonX, + (control->buttonQueue[originr]).buttonY, + (control->buttonQueue[originr]).buttonWidth, + (control->buttonQueue[originr]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[originr]).buttonX, + (control->buttonQueue[originr]).buttonY, + (control->buttonQueue[originr]).buttonWidth, + (control->buttonQueue[originr]).buttonHeight,Xoption); + GSetForeground(globalGC1,(float)backgroundColor,Xoption); + XFillRectangle(dsply, control->controlWindow, globalGC1, + (control->buttonQueue[objectr]).buttonX, + (control->buttonQueue[objectr]).buttonY, + (control->buttonQueue[objectr]).buttonWidth, + (control->buttonQueue[objectr]).buttonHeight); + GSetForeground(globalGC1,(float)foregroundColor,Xoption); + GDrawRectangle(globalGC1, control->controlWindow, + (control->buttonQueue[objectr]).buttonX, + (control->buttonQueue[objectr]).buttonY, + (control->buttonQueue[objectr]).buttonWidth, + (control->buttonQueue[objectr]).buttonHeight,Xoption); + } + s1 = (control->buttonQueue[objectr]).text; + strL1 = strlen(s1); + s2 = (control->buttonQueue[originr]).text; + strL2 = strlen(s2); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[objectr]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[objectr]).buttonX + + centerX(processGC,s1,strL1, + (control->buttonQueue[objectr]).buttonWidth), + (control->buttonQueue[objectr]).buttonY + + centerY(processGC, + (control->buttonQueue[objectr]).buttonHeight), + s1,strL1,Xoption); + + GSetForeground(processGC, + (float)monoColor((control->buttonQueue[originr]).textColor),Xoption); + GDrawImageString(processGC,control->controlWindow, + (control->buttonQueue[originr]).buttonX + + centerX(processGC,s2,strL2, + (control->buttonQueue[originr]).buttonWidth), + (control->buttonQueue[originr]).buttonY + + centerY(processGC, + (control->buttonQueue[originr]).buttonHeight), + s2,strL2,Xoption); + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + break; + + + + case ps: + strcpy(control->message," Creating postscript file ... "); + writeControlMessage(); + if (PSInit(viewport->viewWindow, viewport->titleWindow) == psError) { + strcpy(control->message," Aborted: PSInit error. "); + writeControlMessage(); + return; /* make new tmpnam for new file */ + } + + redoSmooth = yes; + drawViewport(PSoption); /* draw picture in PS; create ps script file */ + + if (PSCreateFile(viewBorderWidth, viewport->viewWindow, + viewport->titleWindow, viewport->title) == psError) { + strcpy(control->message," Aborted: PSCreateFile error. "); + writeControlMessage(); + return; + } + + clearControlMessage(); + strcpy(control->message,PSfilename); + strcat(control->message," in working dir "); + writeControlMessage(); + break; + + + + case pixmap: + strcpy(control->message," Creating axiom3D.xpm now ... "); + writeControlMessage(); + XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); + write_pixmap_file(dsply,scrn,"axiom3D.xpm", + viewport->titleWindow,0,0,vwInfo.width, + vwInfo.height+titleHeight); + clearControlMessage(); + strcpy(control->message," axiom3D.xpm in working dir "); + writeControlMessage(); + break; + + + + case transparent: + case opaqueMesh: + case render: + case smooth: + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + viewData.style = bKey; + drawViewport(Xoption); /* draw picture in viewWindow with X routines */ + break; + + + case closeAll: + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + doingPanel = QUITpanel; + viewport->closing = yes; + XMapWindow(dsply,quitWindow); + break; + + + case quitReturn: + XUnmapWindow(dsply,quitWindow); + break; + + + case quitAbort: + doingPanel = CONTROLpanel; + XUnmapWindow(dsply,quitWindow); + break; + + + case saveit: + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + saveFlag = yes; + doingPanel = SAVEpanel; + XMapWindow(dsply,saveWindow); + break; + + + case saveExit: + saveFlag = no; + doingPanel = CONTROLpanel; + XUnmapWindow(dsply,saveWindow); + break; + + + case xy: + viewport->theta = pi; + viewport->phi = 0.0; + viewport->axestheta = pi; + viewport->axesphi = 0.0; + rotated = yes; + viewport->yzOn = viewport->xzOn = no; + viewport->xyOn = yes; + drawViewport(Xoption); + break; + + + case xz: + viewport->theta = pi; + viewport->phi = -pi_half; + viewport->axestheta = pi; + viewport->axesphi = -pi_half; + rotated = yes; + viewport->yzOn = viewport->xyOn = no; + viewport->xzOn = yes; + drawViewport(Xoption); + break; + + + case yz: + viewport->theta = pi_half; + viewport->phi = -pi_half; + viewport->axestheta = pi_half; + viewport->axesphi = -pi_half; + rotated = yes; + viewport->xzOn = viewport->xyOn = no; + viewport->yzOn = yes; + drawViewport(Xoption); + break; + + + default: + fprintf(stderr,"Received a non-functioning button request: %d \n",bKey); + break; + } /* switch (action) */ + +} /* processEvents() */ + + + +/************************** X Event Processing *****************************/ +void +#ifdef _NO_PROTO +processEvents() +#else +processEvents(void) +#endif +{ + + XEvent *event, tempEvent; + Window whichWindow; + buttonStruct *controlButton; + mouseCoord mouseXY, linearMouseXY; + int someInt, mouseW4, mouseH4; + int toggleReady =yes; + int checkButton = no; + int first_time = yes; + int changingColor = yes; + int gotEvent = 0, exposeView = no; + int tempTW, tempTH, tempVW, tempVH; + int buttonTablePtr; + float f1, f2; + int px, py, lx, ly; + unsigned int lbuttons; + Window dummy; + int Xcon,externalControl,len; + fd_set rd; + + externalControl = 0; + Xcon = ConnectionNumber(dsply); + + /** assign lightPointer for light panel **/ + lightPointer[0] = tempLightPointer[0] = viewport->lightVector[0]; + lightPointer[1] = tempLightPointer[1] = viewport->lightVector[1]; + lightPointer[2] = tempLightPointer[2] = viewport->lightVector[2]; + + if (!(event = (XEvent *)saymem("process.c",1,sizeof(XEvent)))) { + fprintf(stderr,"Ran out of memory initializing event processing.\n"); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + + controlButton = 0; + + while(1) { + + /* Store old viewport window size attributes for resizing comparison. */ + XGetWindowAttributes(dsply,viewport->titleWindow,&graphWindowAttrib); + tempTW = graphWindowAttrib.width; + tempTH = graphWindowAttrib.height; + XGetWindowAttributes(dsply,viewport->viewWindow,&graphWindowAttrib); + tempVW = graphWindowAttrib.width; + tempVH = graphWindowAttrib.height; + + /* Get the next X event. The check for pending events is so that + a held down mouse button is interpreted as an event + even if nothing is pending. */ + + len=0; + while(len<=0) { + FD_ZERO(&rd); + if (externalControl==0) FD_SET(0, &rd); + FD_SET(Xcon,&rd); + + if (XEventsQueued(dsply, QueuedAlready)) { + len=1; + break; + } + if (!followMouse) + len=select(FD_SETSIZE,(void *)&rd,0,0,0); + else + len=1; + } + + if (FD_ISSET(Xcon,&rd)|| + XEventsQueued(dsply, QueuedAfterFlush) || + followMouse) { + + if (followMouse) { + if (XPending(dsply)) + XNextEvent(dsply,event); + gotEvent++; + } else { + XNextEvent(dsply,event); + gotEvent++; + } + + if (gotToggle || !followMouse) + checkButton = no; + + if (gotEvent) { + whichWindow = ((XButtonEvent *)event)->window; + first_time = no; + + switch(((XEvent *)event)->type) { + case ClientMessage: + if (event->xclient.data.l[0] == wm_delete_window) { + goodbye(-1); + } + else { + fprintf(stderr,"Unknown Client Message ...\n"); + } + break; + case Expose: + if (whichWindow == viewport->titleWindow) { + exposeView = yes; + followMouse = no; + XSync(dsply,0); + /* get rid of redundant exposure events */ + XCheckWindowEvent(dsply,viewport->titleWindow, + ExposureMask,&tempEvent); + writeTitle(); + XGetWindowAttributes(dsply,viewport->titleWindow, + &graphWindowAttrib); + if ((graphWindowAttrib.width!=tempTW) || + ((graphWindowAttrib.height)!=tempTH)) { + XResizeWindow(dsply,viewport->viewWindow, + graphWindowAttrib.width, graphWindowAttrib.height); + redoSmooth = yes; /* recompute smooth image pixmap if resized */ + } + } else if (whichWindow == viewport->viewWindow) { + exposeView = yes; + followMouse = no; + XSync(dsply,0); + XCheckWindowEvent(dsply,viewport->viewWindow,ExposureMask, + &tempEvent); + XGetWindowAttributes(dsply,viewport->viewWindow,&graphWindowAttrib); + if ((graphWindowAttrib.width!=tempVW) || + ((graphWindowAttrib.height)!=tempVH)) { + XResizeWindow(dsply,viewport->viewWindow,graphWindowAttrib.width, + graphWindowAttrib.height); + redoSmooth = yes; /* recompute smooth image pixmap if resized */ + } + drawViewport(Xoption); + XMapWindow(dsply,whichWindow); + } else if (whichWindow == lightingWindow) { + XGetWindowAttributes(dsply,control->controlWindow, + &graphWindowAttrib); + /* do not allow resizing of control panel */ + if ((graphWindowAttrib.width!=controlWidth) || + (graphWindowAttrib.height!=controlHeight)) { + XResizeWindow(dsply,control->controlWindow,controlWidth, + controlHeight); + } + drawLightingPanel(); + } else if (whichWindow == volumeWindow) { + XGetWindowAttributes(dsply,control->controlWindow, + &graphWindowAttrib); + /* do not allow resizing of control panel */ + if ((graphWindowAttrib.width!=controlWidth) || + (graphWindowAttrib.height!=controlHeight)) { + XResizeWindow(dsply,control->controlWindow,controlWidth, + controlHeight); + } + drawVolumePanel(); + if (redrawView) { + redrawView = no; + drawViewport(Xoption); + } + } else if (whichWindow == quitWindow) { + XGetWindowAttributes(dsply,control->controlWindow, + &graphWindowAttrib); + /* do not allow resizing of control panel */ + if ((graphWindowAttrib.width!=controlWidth) || + (graphWindowAttrib.height!=controlHeight)) { + XResizeWindow(dsply,control->controlWindow,controlWidth, + controlHeight); + } + drawQuitPanel(); + } else if (whichWindow == saveWindow) { + XGetWindowAttributes(dsply,control->controlWindow, + &graphWindowAttrib); + /* do not allow resizing of control panel */ + if ((graphWindowAttrib.width!=controlWidth) || + (graphWindowAttrib.height!=controlHeight)) { + XResizeWindow(dsply,control->controlWindow,controlWidth, + controlHeight); + } + drawSavePanel(); + } else if (whichWindow == control->controlWindow) { + XGetWindowAttributes(dsply,control->controlWindow, + &graphWindowAttrib); + /* do not allow resizing of control panel */ + if ((graphWindowAttrib.width != controlWidth) || + (graphWindowAttrib.height != controlHeight)) { + XResizeWindow(dsply,control->controlWindow, + controlWidth,controlHeight); + } + if (viewport->haveControl) drawControlPanel(); + followMouse = no; + if (redrawView || exposeView) { + redrawView = no; + drawViewport(Xoption); + } + exposeView = no; + } else { + fprintf(stderr,"Not a valid window.\n"); + } + + XFlush(dsply); + while(XCheckTypedWindowEvent(dsply, whichWindow, Expose, &tempEvent)); + break; + + + case MotionNotify: + exposeView = no; + if (followMouse) { + if (whichWindow == control->colormapWindow) { + while (XCheckMaskEvent(dsply,ButtonMotionMask,event)); + first_time = checkButton = followMouse = changingColor = yes; + gotToggle = no; + } else if (whichWindow != control->controlWindow) { + if (controlButton->pot) { + while (XCheckMaskEvent(dsply,ButtonMotionMask,event)); + mouseXY = getPotValue(((XButtonEvent *)event)->x, + ((XButtonEvent *)event)->y, + controlButton->xHalf, + controlButton->yHalf); + linearMouseXY = getLinearPotValue(((XButtonEvent *)event)->x, + ((XButtonEvent *)event)->y, + controlButton->xHalf, + controlButton->yHalf); + first_time = checkButton = followMouse = yes; + gotToggle = no; + } + } + } + break; + + case ButtonRelease: + exposeView = followMouse = no; + toggleReady = yes; gotToggle = yes; + break; + + case LeaveNotify: + XQueryPointer(dsply,rtWindow,&dummy,&dummy,&px,&py,&lx,&ly,&lbuttons); + if ( (controlButton) && + ((whichWindow == control->colormapWindow) || + (controlButton->pot)) && + (lbuttons & Button1Mask || + lbuttons & Button2Mask || + lbuttons & Button3Mask)) { + followMouse = yes; + if (whichWindow == control->colormapWindow) + changingColor = yes; + } + else { + followMouse = no; + changingColor = no; + } + toggleReady = yes; + checkButton = exposeView = no; + break; + + case ButtonPress: + exposeView = no; changingColor = no; + if (whichWindow == viewport->viewWindow) { + /* find out where the mouse button is pressed on the viewport, + this determines where to put the control panel */ + XGetWindowAttributes(dsply,whichWindow,&graphWindowAttrib); + mouseW4 = graphWindowAttrib.width/4; + if (((XButtonEvent *)event)->x > (graphWindowAttrib.width-mouseW4)) + someInt = 1; + else { + mouseH4 = graphWindowAttrib.height/4; + if (((XButtonEvent *)event)->y > + (graphWindowAttrib.height - mouseH4)) someInt = 2; + else if (((XButtonEvent *)event)->x < mouseW4) someInt = 3; + else if (((XButtonEvent *)event)->y < mouseH4) someInt = 4; + else someInt = 0; + } + if (viewport->haveControl) { + XUnmapWindow(dsply,control->controlWindow); + } + putControlPanelSomewhere(someInt); + writeControlMessage(); + XSync(dsply,0); + } else if (whichWindow == control->colormapWindow) { + gotToggle = no; + first_time = checkButton = followMouse = changingColor = yes; + } else if (whichWindow != control->controlWindow) { + /* mouse clicked on one of the buttons */ + if (!controlButton || (controlButton->self != whichWindow)) { + buttonTablePtr = *((int *)XLookUpAssoc(dsply,table,whichWindow)); + /** lighting buttons have indices greater than 100 **/ + /** all buttons share the same array now **/ + controlButton = &(control->buttonQueue[buttonTablePtr]); + } + if (controlButton->pot) { + /* figure out [x,y] for this button in the range [-1..1,-1..1] */ + mouseXY = getPotValue(((XButtonEvent *)event)->x, + ((XButtonEvent *)event)->y, + controlButton->xHalf,controlButton->yHalf); + linearMouseXY = getLinearPotValue(((XButtonEvent *)event)->x, + ((XButtonEvent *)event)->y, + controlButton->xHalf, + controlButton->yHalf); + followMouse = yes; + gotToggle = no; + } else { + followMouse = no; + gotToggle = yes; /* auto-repeat of toggle buttons not allowed */ + if (toggleReady) toggleReady = no; + } + checkButton = yes; + first_time = yes; + } + break; + + default: + toggleReady = gotToggle = yes; + exposeView = changingColor = checkButton = followMouse = no; + break; + + } /* switch */ + gotEvent--; + } /* if gotEvent */ + + /* Allow a pressed mouse button on a potentiometer to poll repeatedly. */ + if (followMouse && !first_time && (followMouse++ > mouseWait)) { + /* reset for next timing loop */ + followMouse = yes; + checkButton = yes; + } + if (checkButton) { + if (viewport->closing && (controlButton->buttonKey == quitReturn)) { + goodbye(-1); + } else if (changingColor) { + viewport->closing = no; + /* moving top color map pointer */ + if (((XButtonEvent *)event)->y < colorOffsetY) { + if (((XButtonEvent *)event)->x < (colorOffset+colorWidth)) { + /* decreasing top hue number */ + if (viewport->hueTop > 0) viewport->hueTop--; + } else if (((XButtonEvent *)event)->x >= + (colorOffsetX + totalHues*colorWidth + colorWidth)) { + if (viewport->hueTop < totalHues) viewport->hueTop++; + } else { + viewport->hueTop = + (((XButtonEvent *)event)->x - + colorOffsetX + colorWidth/2 - 13) / colorWidth; + } + } else if (((XButtonEvent *)event)->y > + (colorOffsetY + colorHeight)) { + /* moving bottom color map pointer */ + if (((XButtonEvent *)event)->x < (colorOffset+colorWidth)) { + /* decreasing offset number */ + if (viewport->hueOffset > 0) viewport->hueOffset--; + } else if (((XButtonEvent *)event)->x >= + (colorOffsetX + totalHues*colorWidth + colorWidth)) { + if (viewport->hueOffset < totalHues) viewport->hueOffset++; + } else { + viewport->hueOffset = + (((XButtonEvent *)event)->x - + colorOffsetX + colorWidth/2 - 13) / colorWidth; + } + } + /* color map pointer does not wrap around */ + 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; + redoDither = no; + } else { + redoColor = no; + redoDither = yes; + } + /* update color map changes on control panel */ + drawColorMap(); + } else { + viewport->closing = no; + clearControlMessage(); + /* reset all the things that might affect a recalculation for + redrawing removing hidden surfaces */ + + /* determine what type of button has been pressed */ + switch(controlButton->buttonKey) { + + /*** Potentiometers ***/ + case rotate: + if (!((viewport->originrOn) && (viewport->objectrOn))) { + /* update the amount of rotation around the object center + of volume */ + if (viewport->objectrOn) { + viewport->thetaObj += mouseXY.x * rotateFactor; + viewport->phiObj -= mouseXY.y * rotateFactor; + while (viewport->thetaObj >= two_pi) { + viewport->thetaObj -= two_pi; + } + while (viewport->thetaObj < 0.0) { + viewport->thetaObj += two_pi; + } + while (viewport->phiObj > pi) { + viewport->phiObj -= two_pi; + } + while (viewport->phiObj <= -pi) { + viewport->phiObj += two_pi; + } + } + /* update amount of rotation around the world space origin */ + if (viewport->originrOn) { + viewport->theta += mouseXY.x * rotateFactor; + viewport->phi -= mouseXY.y * rotateFactor; + 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 += mouseXY.x * rotateFactor; + viewport->axesphi -= mouseXY.y * rotateFactor; + while (viewport->axestheta >= two_pi) { + viewport->axestheta -= two_pi; + } + while (viewport->axestheta < 0.0) { + viewport->axestheta += two_pi; + } + while (viewport->axesphi > pi) { + viewport->axesphi -= two_pi; + } + while (viewport->axesphi <= -pi) { + viewport->axesphi += two_pi; + } + } + rotated = yes; + viewport->yzOn = viewport->xzOn = viewport->xyOn = no; + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + drawViewport(Xoption); + } + break; + + case zoom: + /* if uniform scaling */ + if ((viewport->zoomXOn) && + (viewport->zoomYOn) && + (viewport->zoomZOn)) { + viewport->scale *= 1 - mouseXY.y * scaleFactor; + } else { /* else scale axes independently */ + if (viewport->zoomXOn) viewport->scaleX *= (1 - mouseXY.y); + if (viewport->zoomYOn) viewport->scaleY *= (1 - mouseXY.y); + if (viewport->zoomZOn) viewport->scaleZ *= (1 - mouseXY.y); + } + if (viewport->scale > maxScale) viewport->scale = maxScale; + else if (viewport->scale < minScale) viewport->scale = minScale; + if (viewport->scaleX > maxScale) viewport->scaleX = maxScale; + else if (viewport->scaleX < minScale) viewport->scaleX = minScale; + if (viewport->scaleY > maxScale) viewport->scaleY = maxScale; + else if (viewport->scaleY < minScale) viewport->scaleY = minScale; + if (viewport->scaleZ > maxScale) viewport->scaleZ = maxScale; + else if (viewport->scaleZ < minScale) viewport->scaleZ = minScale; + zoomed = yes; + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + if ((viewport->zoomXOn) || + (viewport->zoomYOn) || + (viewport->zoomZOn)) + drawViewport(Xoption); + break; + + case translate: + viewport->deltaX += mouseXY.x * translateFactor; + viewport->deltaY += mouseXY.y * translateFactor; + 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; + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + drawViewport(Xoption); + break; + + /*** Lighting panel ***/ + case lightMoveXY: + tempLightPointer[0] = linearMouseXY.x; + tempLightPointer[1] = linearMouseXY.y; + if (tempLightPointer[0] > 1) tempLightPointer[0] = 1; + else if (tempLightPointer[0] < -1) tempLightPointer[0] = -1; + if (tempLightPointer[1] > 1) tempLightPointer[1] = 1; + else if (tempLightPointer[1] < -1) tempLightPointer[1] = -1; + movingLight = yes; + drawLightingAxes(); + break; + + case lightMoveZ: + tempLightPointer[2] = linearMouseXY.y; + /* linearMouse => no checking necessary */ + if (tempLightPointer[2] > 1) tempLightPointer[2] = 1; + else if (tempLightPointer[2] < -1) tempLightPointer[2] = -1; + movingLight = yes; + drawLightingAxes(); + break; + + /* changes the light intensity */ + case lightTranslucent: + tempLightIntensity = (linearMouseXY.y+1)/2; + if (tempLightIntensity > 1) tempLightIntensity = 1; + else if (tempLightIntensity < 0) tempLightIntensity = 0; + changedIntensity = yes; + drawLightTransArrow(); + break; + + /*** volume panel ***/ + case frustrumBut: + screenX = ((XButtonEvent *)event)->x; + if inside(eyeMinX,eyeMaxX) { + /* object coordinate */ + f2 = mouseXY.x * (maxEyeDistance - minEyeDistance) + + minEyeDistance; + if (f2 != viewData.eyeDistance) { + doingVolume = 2; /* flag for using screenX */ + changedEyeDistance = yes; + viewData.eyeDistance = f2; + drawFrustrum(); + drawViewport(Xoption); + } + } + else if inside(hitherMinX,hitherMaxX) { + f1 = ((float)hitherMaxX - ((XButtonEvent *)event)->x) / + (hitherMaxX - hitherMinX); + /* object coordinate */ + f2 = f1 * (clipPlaneMax - clipPlaneMin) + clipPlaneMin; + if (f2 != viewData.clipPlane) { + doingVolume = 3; /* flag for using screenX */ + viewData.clipPlane = f2; + drawFrustrum(); + drawViewport(Xoption); + } + } + else { + doingVolume = 1; /* check out doingVolume */ + doingPanel = VOLUMEpanel; + } + break; + + case clipXBut: /* this is a horizontal button */ + clipValue = linearMouseXY.x * 0.5 + 0.5; /* normalize to 0..1 */ + if (lessThan(clipValue,0.0)) clipValue = 0.0; + if (greaterThan(clipValue,1.0)) clipValue = 1.0; + if (lessThan(linearMouseXY.y,0.0)) { + if (!equal(xClipMinN,clipValue)) { + if (greaterThan(xClipMaxN-clipValue,minDistXY)) + xClipMinN = clipValue; + else + xClipMinN = xClipMaxN - minDistXY; + viewData.clipXmin = xClipMinN * + (viewData.xmax - viewData.xmin) + + viewData.xmin; + drawClipXBut(); + drawClipVolume(); + if (viewData.clipbox) + drawViewport(Xoption); + } + } else { + if (!equal(xClipMaxN,clipValue)) { + if (greaterThan(clipValue-xClipMinN,minDistXY)) + xClipMaxN = clipValue; + else + xClipMaxN = xClipMinN + minDistXY; + viewData.clipXmax = xClipMaxN * + (viewData.xmax - viewData.xmin) + + viewData.xmin; + drawClipXBut(); + drawClipVolume(); + if (viewData.clipbox) + drawViewport(Xoption); + } + } + break; + + case clipYBut: /* this is a vertical button */ + /* normalize to 0..1, bottom up */ + clipValue = 1 - (linearMouseXY.y * 0.5 + 0.5); + if (lessThan(clipValue,0.0)) clipValue = 0.0; + if (greaterThan(clipValue,1.0)) clipValue = 1.0; + if (lessThan(linearMouseXY.x,0.0)) { + if (!equal(yClipMinN,clipValue)) { + if (greaterThan(yClipMaxN-clipValue,minDistXY)) + yClipMinN = clipValue; + else + yClipMinN = yClipMaxN - minDistXY; + viewData.clipYmin = yClipMinN * + (viewData.ymax - viewData.ymin) + + viewData.ymin; + drawClipYBut(); + drawClipVolume(); + if (viewData.clipbox) + drawViewport(Xoption); + } + } else { + if (!equal(yClipMaxN,clipValue)) { + if (greaterThan(clipValue-yClipMinN,minDistXY)) + yClipMaxN = clipValue; + else + yClipMaxN = yClipMinN + minDistXY; + viewData.clipYmax = yClipMaxN * + (viewData.ymax - viewData.ymin) + + viewData.ymin; + drawClipYBut(); + drawClipVolume(); + if (viewData.clipbox) + drawViewport(Xoption); + } + } + break; + + case clipZBut: /* this is a diagonally aligned button! */ + /* f1 is the distance from the center of the button along + the diagonal line with a slope of -1. If f1 is negative, + the direction is downward from the center, if f1 is + positive, the direction is upward from the center. + Note that there ought to be a constant factor, namely + cos(45), multiplied by f1 for the correct normalized value; + however, we exploit this by foreshortening the length of the + diagonal by that same factor (so instead of normalizing the + numbers to, the line we normalize the line to the numbers) + since we need to shorten the line at some point anyway + (both to match the length of the diagonal side of the box + and to allow more area for mouse input. */ + + /* cos(45), etc => 0.4 */ + f1 = (linearMouseXY.x - linearMouseXY.y) * 0.4 + 0.5; + if (lessThan(f1,0.0)) f1 = 0.0; + if (greaterThan(f1,1.0)) f1 = 1.0; + /* note that x<y => moving upward */ + if (lessThan(-linearMouseXY.x,linearMouseXY.y)) { + if (!equal(zClipMaxN,f1)) { + if (greaterThan(f1-zClipMinN,minDistZ)) + zClipMaxN = f1; + else + zClipMaxN = zClipMinN + minDistZ; + viewData.clipZmax = zClipMaxN * + (viewData.zmax - viewData.zmin) + + viewData.zmin; + drawClipZBut(); + drawClipVolume(); + if (viewData.clipbox) + drawViewport(Xoption); + } + } else { + if (!equal(zClipMinN,f1)) { + if (greaterThan(zClipMaxN-f1,minDistZ)) + zClipMinN = f1; + else + zClipMinN = zClipMaxN - minDistZ; + viewData.clipZmin = zClipMinN * + (viewData.zmax - viewData.zmin) + + viewData.zmin; + drawClipZBut(); + drawClipVolume(); + if (viewData.clipbox) + drawViewport(Xoption); + } + } /* if lessThan(x,y) */ + break; + + case perspectiveBut: + if ((viewData.perspective = !viewData.perspective)) { + switchedPerspective = yes; + GSetForeground(volumeGC, + (float)monoColor((control->buttonQueue[perspectiveBut]).textColor),Xoption); + GDrawString(volumeGC,volumeWindow, + controlButton->buttonX + + centerX(volumeGC,"x",1,controlButton->buttonWidth), + controlButton->buttonY + + centerY(volumeGC,controlButton->buttonHeight), + "x",1,Xoption); + } + else + XClearArea(dsply,volumeWindow, + controlButton->buttonX+1, + controlButton->buttonY+1, + controlButton->buttonHeight-2, + controlButton->buttonWidth-2, + False); + drawViewport(Xoption); + break; + + case clipRegionBut: + if ((viewData.clipbox = !viewData.clipbox)) { + GSetForeground(volumeGC, + (float)monoColor((control->buttonQueue[clipRegionBut]).textColor),Xoption); + GDrawString(volumeGC,volumeWindow, + controlButton->buttonX + + centerX(volumeGC,"x",1,controlButton->buttonWidth), + controlButton->buttonY + + centerY(volumeGC,controlButton->buttonHeight), + "x",1,Xoption); + } + else + XClearArea(dsply,volumeWindow, + controlButton->buttonX+1, + controlButton->buttonY+1, + controlButton->buttonWidth-2, + controlButton->buttonHeight-2, + False); + + drawViewport(Xoption); + break; + + case clipSurfaceBut: + if ((viewData.clipStuff = !viewData.clipStuff)) { + GSetForeground(volumeGC, + (float)monoColor((control->buttonQueue[clipSurfaceBut]).textColor),Xoption); + GDrawString(volumeGC,volumeWindow, + controlButton->buttonX + + centerX(volumeGC,"x",1,controlButton->buttonWidth), + controlButton->buttonY + + centerY(volumeGC,controlButton->buttonHeight), + "x",1,Xoption); + } + else + XClearArea(dsply,volumeWindow, + controlButton->buttonX+1, + controlButton->buttonY+1, + controlButton->buttonWidth-2, + controlButton->buttonHeight-2, + False); + break; + + default: + buttonAction(controlButton->buttonKey); + } /* switch on buttonKey */ + + } /* else - not closing */ + } /* if checkButton */ + } /* if FD_ISSET(Xcon,.. */ + else if FD_ISSET(0,&rd) { + externalControl = spadAction(); + if (spadDraw && (externalControl==0)) drawViewport(Xoption); + } + } /* for (until closed) */ +} /* processEvents() */ + + + diff --git a/src/graph/view3D/process3d.c.pamphlet b/src/graph/view3D/process3d.c.pamphlet deleted file mode 100644 index d6174388..00000000 --- a/src/graph/view3D/process3d.c.pamphlet +++ /dev/null @@ -1,1625 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D process3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _PROCESS3D_C -#include "axiom-c-macros.h" - -#include <string.h> -#include <stdlib.h> -#include <unistd.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/time.h> - - -#include "header.h" -#include "cpanel.h" -#include "volume.h" -#include "mode.h" -#include "process.h" -#include "draw.h" -#include "sockio.h" -#include "com.h" - - -#include "util.H1" -#include "Gfun.H1" -#include "pixmap.H1" -#include "XShade.H1" -#include "XSpadFill.H1" -#include "all_3d.H1" - -#define inside(A,B) (((XButtonEvent *)event)->x >= A && \ - ((XButtonEvent *)event)->x <= B) - - -void -#ifdef _NO_PROTO -buttonAction (bKey) -int bKey; -#else -buttonAction (int bKey) -#endif -{ - - char *s1, *s2; - int strL, strL1, strL2, offShade=14; - - /* Button colors which are offColor, RED, are turned off, and those which - are onColor, GREEN, indicate the mode is in effect. */ - - switch (bKey) { - - case hideControl: - if (viewport->haveControl) { - viewport->haveControl = no; - XUnmapWindow(dsply,control->controlWindow); - } - break; - - case region3D: - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - if (viewport->regionOn) { - viewport->regionOn = no; - (control->buttonQueue[region3D]).textColor = offColor; - viewData.box = 0; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[region3D]).buttonX, - (control->buttonQueue[region3D]).buttonY, - (control->buttonQueue[region3D]).buttonWidth, - (control->buttonQueue[region3D]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[region3D]).buttonX, - (control->buttonQueue[region3D]).buttonY, - (control->buttonQueue[region3D]).buttonWidth, - (control->buttonQueue[region3D]).buttonHeight,Xoption); - } - } else { /* inverted color for region off */ - viewport->regionOn = yes; - viewData.box = 1; - (control->buttonQueue[region3D]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1,(float)backgroundColor,Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[region3D]).buttonX, - (control->buttonQueue[region3D]).buttonY, - (control->buttonQueue[region3D]).buttonWidth, - (control->buttonQueue[region3D]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[region3D]).buttonX, - (control->buttonQueue[region3D]).buttonY, - (control->buttonQueue[region3D]).buttonWidth, - (control->buttonQueue[region3D]).buttonHeight,Xoption); - } - } - - s = (control->buttonQueue[region3D]).text; - strL = strlen(s); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[region3D]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[region3D]).buttonX + - centerX(processGC,s,strL, - (control->buttonQueue[region3D]).buttonWidth), - (control->buttonQueue[region3D]).buttonY + - centerY(processGC, - (control->buttonQueue[region3D]).buttonHeight), - s,strL,Xoption); - redoSmooth = yes; - drawViewport(Xoption); - break; - - - - case bwColor: - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - if (!mono) { - if (viewport->monoOn) { - viewport->monoOn = no; - if (viewport->hueTop == viewport->hueOffset) redoColor = yes; - else redoDither = yes; - (control->buttonQueue[bwColor]).textColor = offColor; - (control->buttonQueue[bwColor]).text = "BW"; - } else { - viewport->monoOn = yes; - maxGreyShade = XInitShades(dsply,scrn); - if (viewport->hueTop == viewport->hueOffset) redoColor = yes; - else redoDither = yes; - (control->buttonQueue[bwColor]).textColor = onColor; - (control->buttonQueue[bwColor]).text = "BW"; - GSetForeground(globalGC1,(float)backgroundColor,Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[bwColor]).buttonX, - (control->buttonQueue[bwColor]).buttonY, - (control->buttonQueue[bwColor]).buttonWidth, - (control->buttonQueue[bwColor]).buttonHeight); - GSetForeground(globalGC1,(float)monoColor(buttonColor),Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[bwColor]).buttonX, - (control->buttonQueue[bwColor]).buttonY, - (control->buttonQueue[bwColor]).buttonWidth, - (control->buttonQueue[bwColor]).buttonHeight,Xoption); - } - - s = (control->buttonQueue[bwColor]).text; - strL = strlen(s); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[bwColor]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[bwColor]).buttonX + - centerX(processGC,s,strL, - (control->buttonQueue[bwColor]).buttonWidth), - (control->buttonQueue[bwColor]).buttonY + - centerY(processGC, - (control->buttonQueue[bwColor]).buttonHeight), - s,strL,Xoption); - drawColorMap(); - redoSmooth = yes; - writeTitle(); - drawViewport(Xoption); - } - break; - - - - case outlineOnOff: - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - if (viewData.outlineRenderOn) { - viewData.outlineRenderOn = 0; - (control->buttonQueue[outlineOnOff]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[outlineOnOff]).buttonX, - (control->buttonQueue[outlineOnOff]).buttonY, - (control->buttonQueue[outlineOnOff]).buttonWidth, - (control->buttonQueue[outlineOnOff]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[outlineOnOff]).buttonX, - (control->buttonQueue[outlineOnOff]).buttonY, - (control->buttonQueue[outlineOnOff]).buttonWidth, - (control->buttonQueue[outlineOnOff]).buttonHeight,Xoption); - } - } else { - viewData.outlineRenderOn = 1; - (control->buttonQueue[outlineOnOff]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1,(float)backgroundColor,Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[outlineOnOff]).buttonX, - (control->buttonQueue[outlineOnOff]).buttonY, - (control->buttonQueue[outlineOnOff]).buttonWidth, - (control->buttonQueue[outlineOnOff]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[outlineOnOff]).buttonX, - (control->buttonQueue[outlineOnOff]).buttonY, - (control->buttonQueue[outlineOnOff]).buttonWidth, - (control->buttonQueue[outlineOnOff]).buttonHeight,Xoption); - } - } - s = (control->buttonQueue[outlineOnOff]).text; - strL = strlen(s); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[outlineOnOff]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[outlineOnOff]).buttonX + - centerX(processGC,s,strL, - (control->buttonQueue[outlineOnOff]).buttonWidth), - (control->buttonQueue[outlineOnOff]).buttonY + - centerY(processGC, - (control->buttonQueue[outlineOnOff]).buttonHeight), - s,strL,Xoption); - if (viewData.style == render) { - drawViewport(Xoption); - } - break; - - - case lighting: - if (saveFlag) { - doingPanel = CONTROLpanel; - XUnmapWindow(dsply,saveWindow); - } - doingPanel = LIGHTpanel; - tempLightPointer[0] = viewport->lightVector[0]; - tempLightPointer[1] = viewport->lightVector[1]; - tempLightPointer[2] = viewport->lightVector[2]; - tempLightIntensity = lightIntensity; - XMapWindow(dsply,lightingWindow); - break; - - - case viewVolume: - if (saveFlag) { - doingPanel = CONTROLpanel; - XUnmapWindow(dsply,saveWindow); - } - doingPanel = VOLUMEpanel; - XMapWindow(dsply,volumeWindow); - redrawView = yes; - drawViewport(Xoption); /* draw it with doingVolume set to yes */ - break; - - - case volumeReturn: - doingPanel = CONTROLpanel; - redoSmooth = yes; - redrawView = yes; - XUnmapWindow(dsply,volumeWindow); - break; - - - case volumeAbort: - doingPanel = CONTROLpanel; - redrawView = yes; - XUnmapWindow(dsply,volumeWindow); - break; - - - case lightReturn: - doingPanel = CONTROLpanel; - viewport->lightVector[0] = lightPointer[0] = tempLightPointer[0]; - viewport->lightVector[1] = lightPointer[1] = tempLightPointer[1]; - viewport->lightVector[2] = lightPointer[2] = tempLightPointer[2]; - lightIntensity = tempLightIntensity; - normalizeVector(viewport->lightVector); - redrawView = ((viewData.style == render) || (viewData.style == smooth)); - if (movingLight || changedIntensity) redoSmooth = yes; - XUnmapWindow(dsply,lightingWindow); - break; - - - case lightAbort: - movingLight = no; changedIntensity = no; - doingPanel = CONTROLpanel; - XUnmapWindow(dsply,lightingWindow); - break; - - - case resetView: - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - viewport->axesOn = yes; - viewport->regionOn = no; viewData.box = 0; - viewData.outlineRenderOn = 0; - viewport->monoOn = no; - viewport->zoomXOn = viewport->zoomYOn = viewport->zoomZOn = yes; - viewport->originrOn = yes; viewport->objectrOn = no; - viewport->originFlag = no; - viewport->xyOn = viewport->xzOn = viewport->yzOn = no; - viewport->lightVector[0] = -0.5; - viewport->lightVector[1] = 0.5; - viewport->lightVector[2] = 0.5; - viewport->translucency = viewData.translucency; - viewport->deltaX = viewport->deltaX0; - viewport->deltaY = viewport->deltaY0; - viewport->deltaY = viewport->deltaZ0; - viewport->scale = viewport->scale0; - viewport->scaleX = viewport->scaleY = viewport->scaleZ = 1.0; - if (!equal(viewport->theta,viewport->theta0) || !equal(viewport->phi,viewport->phi0)) - rotated = yes; - viewport->theta = viewport->axestheta = viewport->theta0 = viewData.theta; - viewport->phi = viewport->axesphi = viewport->phi0 = viewData.phi; - viewport->thetaObj = 0.0; - viewport->phiObj = 0.0; - redoSmooth = yes; - drawViewport(Xoption); - if (viewport->haveControl) drawControlPanel(); - writeTitle(); - break; - - - case axesOnOff: - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - if (viewport->axesOn) { - viewport->axesOn = no; - (control->buttonQueue[axesOnOff]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[axesOnOff]).buttonX, - (control->buttonQueue[axesOnOff]).buttonY, - (control->buttonQueue[axesOnOff]).buttonWidth, - (control->buttonQueue[axesOnOff]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[axesOnOff]).buttonX, - (control->buttonQueue[axesOnOff]).buttonY, - (control->buttonQueue[axesOnOff]).buttonWidth, - (control->buttonQueue[axesOnOff]).buttonHeight,Xoption); - } - } else { /* draw invert-color button */ - viewport->axesOn = yes; - (control->buttonQueue[axesOnOff]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1,(float)backgroundColor,Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[axesOnOff]).buttonX, - (control->buttonQueue[axesOnOff]).buttonY, - (control->buttonQueue[axesOnOff]).buttonWidth, - (control->buttonQueue[axesOnOff]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[axesOnOff]).buttonX, - (control->buttonQueue[axesOnOff]).buttonY, - (control->buttonQueue[axesOnOff]).buttonWidth, - (control->buttonQueue[axesOnOff]).buttonHeight,Xoption); - } - } - - s = (control->buttonQueue[axesOnOff]).text; - strL = strlen(s); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[axesOnOff]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[axesOnOff]).buttonX + - centerX(processGC,s,strL, - (control->buttonQueue[axesOnOff]).buttonWidth), - (control->buttonQueue[axesOnOff]).buttonY + - centerY(processGC, - (control->buttonQueue[axesOnOff]).buttonHeight), - s,strL,Xoption); - if (viewData.style == smooth) { - if (multiColorFlag) redoDither = yes; - else redoColor = yes; - } - drawViewport(Xoption); - break; - - - case zoomx: - if (viewport->zoomXOn) { - viewport->zoomXOn = no; - (control->buttonQueue[zoomx]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[zoomx]).buttonX, - (control->buttonQueue[zoomx]).buttonY, - (control->buttonQueue[zoomx]).buttonWidth, - (control->buttonQueue[zoomx]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[zoomx]).buttonX, - (control->buttonQueue[zoomx]).buttonY, - (control->buttonQueue[zoomx]).buttonWidth, - (control->buttonQueue[zoomx]).buttonHeight,Xoption); - } - } else { - viewport->zoomXOn = yes; - (control->buttonQueue[zoomx]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1,(float)backgroundColor,Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[zoomx]).buttonX, - (control->buttonQueue[zoomx]).buttonY, - (control->buttonQueue[zoomx]).buttonWidth, - (control->buttonQueue[zoomx]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[zoomx]).buttonX, - (control->buttonQueue[zoomx]).buttonY, - (control->buttonQueue[zoomx]).buttonWidth, - (control->buttonQueue[zoomx]).buttonHeight,Xoption); - } - } - - s = (control->buttonQueue[zoomx]).text; - strL = strlen(s); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[zoomx]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[zoomx]).buttonX + - centerX(processGC,s,strL, - (control->buttonQueue[zoomx]).buttonWidth), - (control->buttonQueue[zoomx]).buttonY + - centerY(processGC, - (control->buttonQueue[zoomx]).buttonHeight), - s,strL,Xoption); - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - break; - - - case zoomy: - if (viewport->zoomYOn) { - viewport->zoomYOn = no; - (control->buttonQueue[zoomy]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[zoomy]).buttonX, - (control->buttonQueue[zoomy]).buttonY, - (control->buttonQueue[zoomy]).buttonWidth, - (control->buttonQueue[zoomy]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[zoomy]).buttonX, - (control->buttonQueue[zoomy]).buttonY, - (control->buttonQueue[zoomy]).buttonWidth, - (control->buttonQueue[zoomy]).buttonHeight,Xoption); - } - } else { - viewport->zoomYOn = yes; - (control->buttonQueue[zoomy]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1,(float)backgroundColor,Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[zoomy]).buttonX, - (control->buttonQueue[zoomy]).buttonY, - (control->buttonQueue[zoomy]).buttonWidth, - (control->buttonQueue[zoomy]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[zoomy]).buttonX, - (control->buttonQueue[zoomy]).buttonY, - (control->buttonQueue[zoomy]).buttonWidth, - (control->buttonQueue[zoomy]).buttonHeight,Xoption); - } - } - - s = (control->buttonQueue[zoomy]).text; - strL = strlen(s); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[zoomy]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[zoomy]).buttonX + - centerX(processGC,s,strL, - (control->buttonQueue[zoomy]).buttonWidth), - (control->buttonQueue[zoomy]).buttonY + - centerY(processGC, - (control->buttonQueue[zoomy]).buttonHeight), - s,strL,Xoption); - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - break; - - - case zoomz: - if (viewport->zoomZOn) { - viewport->zoomZOn = no; - (control->buttonQueue[zoomz]).textColor = offColor; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[zoomz]).buttonX, - (control->buttonQueue[zoomz]).buttonY, - (control->buttonQueue[zoomz]).buttonWidth, - (control->buttonQueue[zoomz]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[zoomz]).buttonX, - (control->buttonQueue[zoomz]).buttonY, - (control->buttonQueue[zoomz]).buttonWidth, - (control->buttonQueue[zoomz]).buttonHeight,Xoption); - } - } else { - viewport->zoomZOn = yes; - (control->buttonQueue[zoomz]).textColor = onColor; - if (mono) { - GSetForeground(globalGC1,(float)backgroundColor,Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[zoomz]).buttonX, - (control->buttonQueue[zoomz]).buttonY, - (control->buttonQueue[zoomz]).buttonWidth, - (control->buttonQueue[zoomz]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[zoomz]).buttonX, - (control->buttonQueue[zoomz]).buttonY, - (control->buttonQueue[zoomz]).buttonWidth, - (control->buttonQueue[zoomz]).buttonHeight,Xoption); - } - } - - s = (control->buttonQueue[zoomz]).text; - strL = strlen(s); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[zoomz]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[zoomz]).buttonX + - centerX(processGC,s,strL, - (control->buttonQueue[zoomz]).buttonWidth), - (control->buttonQueue[zoomz]).buttonY + - centerY(processGC, - (control->buttonQueue[zoomz]).buttonHeight), - s,strL,Xoption); - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - break; - - - case originr: - viewport->originrOn = yes; - (control->buttonQueue[originr]).textColor = onColor; - viewport->objectrOn = no; - (control->buttonQueue[objectr]).textColor = offColor; - viewport->originFlag = yes; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[objectr]).buttonX, - (control->buttonQueue[objectr]).buttonY, - (control->buttonQueue[objectr]).buttonWidth, - (control->buttonQueue[objectr]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[objectr]).buttonX, - (control->buttonQueue[objectr]).buttonY, - (control->buttonQueue[objectr]).buttonWidth, - (control->buttonQueue[objectr]).buttonHeight,Xoption); - GSetForeground(globalGC1,(float)backgroundColor,Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[originr]).buttonX, - (control->buttonQueue[originr]).buttonY, - (control->buttonQueue[originr]).buttonWidth, - (control->buttonQueue[originr]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[originr]).buttonX, - (control->buttonQueue[originr]).buttonY, - (control->buttonQueue[originr]).buttonWidth, - (control->buttonQueue[originr]).buttonHeight,Xoption); - } - s1 = (control->buttonQueue[objectr]).text; - strL1 = strlen(s1); - s2 = (control->buttonQueue[originr]).text; - strL2 = strlen(s2); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[objectr]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[objectr]).buttonX + - centerX(processGC,s1,strL1, - (control->buttonQueue[objectr]).buttonWidth), - (control->buttonQueue[objectr]).buttonY + - centerY(processGC, - (control->buttonQueue[objectr]).buttonHeight), - s1,strL1,Xoption); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[originr]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[originr]).buttonX + - centerX(processGC,s2,strL2, - (control->buttonQueue[originr]).buttonWidth), - (control->buttonQueue[originr]).buttonY + - centerY(processGC, - (control->buttonQueue[originr]).buttonHeight), - s2,strL2,Xoption); - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - break; - - - - case objectr: - viewport->objectrOn = yes; - (control->buttonQueue[objectr]).textColor = onColor; - viewport->originrOn = no; - (control->buttonQueue[originr]).textColor = offColor; - - viewport->originFlag = no; - if (mono) { - XChangeShade(dsply,offShade); - XShadeRectangle(dsply,control->controlWindow, - (control->buttonQueue[originr]).buttonX, - (control->buttonQueue[originr]).buttonY, - (control->buttonQueue[originr]).buttonWidth, - (control->buttonQueue[originr]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[originr]).buttonX, - (control->buttonQueue[originr]).buttonY, - (control->buttonQueue[originr]).buttonWidth, - (control->buttonQueue[originr]).buttonHeight,Xoption); - GSetForeground(globalGC1,(float)backgroundColor,Xoption); - XFillRectangle(dsply, control->controlWindow, globalGC1, - (control->buttonQueue[objectr]).buttonX, - (control->buttonQueue[objectr]).buttonY, - (control->buttonQueue[objectr]).buttonWidth, - (control->buttonQueue[objectr]).buttonHeight); - GSetForeground(globalGC1,(float)foregroundColor,Xoption); - GDrawRectangle(globalGC1, control->controlWindow, - (control->buttonQueue[objectr]).buttonX, - (control->buttonQueue[objectr]).buttonY, - (control->buttonQueue[objectr]).buttonWidth, - (control->buttonQueue[objectr]).buttonHeight,Xoption); - } - s1 = (control->buttonQueue[objectr]).text; - strL1 = strlen(s1); - s2 = (control->buttonQueue[originr]).text; - strL2 = strlen(s2); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[objectr]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[objectr]).buttonX + - centerX(processGC,s1,strL1, - (control->buttonQueue[objectr]).buttonWidth), - (control->buttonQueue[objectr]).buttonY + - centerY(processGC, - (control->buttonQueue[objectr]).buttonHeight), - s1,strL1,Xoption); - - GSetForeground(processGC, - (float)monoColor((control->buttonQueue[originr]).textColor),Xoption); - GDrawImageString(processGC,control->controlWindow, - (control->buttonQueue[originr]).buttonX + - centerX(processGC,s2,strL2, - (control->buttonQueue[originr]).buttonWidth), - (control->buttonQueue[originr]).buttonY + - centerY(processGC, - (control->buttonQueue[originr]).buttonHeight), - s2,strL2,Xoption); - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - break; - - - - case ps: - strcpy(control->message," Creating postscript file ... "); - writeControlMessage(); - if (PSInit(viewport->viewWindow, viewport->titleWindow) == psError) { - strcpy(control->message," Aborted: PSInit error. "); - writeControlMessage(); - return; /* make new tmpnam for new file */ - } - - redoSmooth = yes; - drawViewport(PSoption); /* draw picture in PS; create ps script file */ - - if (PSCreateFile(viewBorderWidth, viewport->viewWindow, - viewport->titleWindow, viewport->title) == psError) { - strcpy(control->message," Aborted: PSCreateFile error. "); - writeControlMessage(); - return; - } - - clearControlMessage(); - strcpy(control->message,PSfilename); - strcat(control->message," in working dir "); - writeControlMessage(); - break; - - - - case pixmap: - strcpy(control->message," Creating axiom3D.xpm now ... "); - writeControlMessage(); - XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); - write_pixmap_file(dsply,scrn,"axiom3D.xpm", - viewport->titleWindow,0,0,vwInfo.width, - vwInfo.height+titleHeight); - clearControlMessage(); - strcpy(control->message," axiom3D.xpm in working dir "); - writeControlMessage(); - break; - - - - case transparent: - case opaqueMesh: - case render: - case smooth: - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - viewData.style = bKey; - drawViewport(Xoption); /* draw picture in viewWindow with X routines */ - break; - - - case closeAll: - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - doingPanel = QUITpanel; - viewport->closing = yes; - XMapWindow(dsply,quitWindow); - break; - - - case quitReturn: - XUnmapWindow(dsply,quitWindow); - break; - - - case quitAbort: - doingPanel = CONTROLpanel; - XUnmapWindow(dsply,quitWindow); - break; - - - case saveit: - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - saveFlag = yes; - doingPanel = SAVEpanel; - XMapWindow(dsply,saveWindow); - break; - - - case saveExit: - saveFlag = no; - doingPanel = CONTROLpanel; - XUnmapWindow(dsply,saveWindow); - break; - - - case xy: - viewport->theta = pi; - viewport->phi = 0.0; - viewport->axestheta = pi; - viewport->axesphi = 0.0; - rotated = yes; - viewport->yzOn = viewport->xzOn = no; - viewport->xyOn = yes; - drawViewport(Xoption); - break; - - - case xz: - viewport->theta = pi; - viewport->phi = -pi_half; - viewport->axestheta = pi; - viewport->axesphi = -pi_half; - rotated = yes; - viewport->yzOn = viewport->xyOn = no; - viewport->xzOn = yes; - drawViewport(Xoption); - break; - - - case yz: - viewport->theta = pi_half; - viewport->phi = -pi_half; - viewport->axestheta = pi_half; - viewport->axesphi = -pi_half; - rotated = yes; - viewport->xzOn = viewport->xyOn = no; - viewport->yzOn = yes; - drawViewport(Xoption); - break; - - - default: - fprintf(stderr,"Received a non-functioning button request: %d \n",bKey); - break; - } /* switch (action) */ - -} /* processEvents() */ - - - -/************************** X Event Processing *****************************/ -void -#ifdef _NO_PROTO -processEvents() -#else -processEvents(void) -#endif -{ - - XEvent *event, tempEvent; - Window whichWindow; - buttonStruct *controlButton; - mouseCoord mouseXY, linearMouseXY; - int someInt, mouseW4, mouseH4; - int toggleReady =yes; - int checkButton = no; - int first_time = yes; - int changingColor = yes; - int gotEvent = 0, exposeView = no; - int tempTW, tempTH, tempVW, tempVH; - int buttonTablePtr; - float f1, f2; - int px, py, lx, ly; - unsigned int lbuttons; - Window dummy; - int Xcon,externalControl,len; - fd_set rd; - - externalControl = 0; - Xcon = ConnectionNumber(dsply); - - /** assign lightPointer for light panel **/ - lightPointer[0] = tempLightPointer[0] = viewport->lightVector[0]; - lightPointer[1] = tempLightPointer[1] = viewport->lightVector[1]; - lightPointer[2] = tempLightPointer[2] = viewport->lightVector[2]; - - if (!(event = (XEvent *)saymem("process.c",1,sizeof(XEvent)))) { - fprintf(stderr,"Ran out of memory initializing event processing.\n"); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - - controlButton = 0; - - while(1) { - - /* Store old viewport window size attributes for resizing comparison. */ - XGetWindowAttributes(dsply,viewport->titleWindow,&graphWindowAttrib); - tempTW = graphWindowAttrib.width; - tempTH = graphWindowAttrib.height; - XGetWindowAttributes(dsply,viewport->viewWindow,&graphWindowAttrib); - tempVW = graphWindowAttrib.width; - tempVH = graphWindowAttrib.height; - - /* Get the next X event. The check for pending events is so that - a held down mouse button is interpreted as an event - even if nothing is pending. */ - - len=0; - while(len<=0) { - FD_ZERO(&rd); - if (externalControl==0) FD_SET(0, &rd); - FD_SET(Xcon,&rd); - - if (XEventsQueued(dsply, QueuedAlready)) { - len=1; - break; - } - if (!followMouse) - len=select(FD_SETSIZE,(void *)&rd,0,0,0); - else - len=1; - } - - if (FD_ISSET(Xcon,&rd)|| - XEventsQueued(dsply, QueuedAfterFlush) || - followMouse) { - - if (followMouse) { - if (XPending(dsply)) - XNextEvent(dsply,event); - gotEvent++; - } else { - XNextEvent(dsply,event); - gotEvent++; - } - - if (gotToggle || !followMouse) - checkButton = no; - - if (gotEvent) { - whichWindow = ((XButtonEvent *)event)->window; - first_time = no; - - switch(((XEvent *)event)->type) { - case ClientMessage: - if (event->xclient.data.l[0] == wm_delete_window) { - goodbye(-1); - } - else { - fprintf(stderr,"Unknown Client Message ...\n"); - } - break; - case Expose: - if (whichWindow == viewport->titleWindow) { - exposeView = yes; - followMouse = no; - XSync(dsply,0); - /* get rid of redundant exposure events */ - XCheckWindowEvent(dsply,viewport->titleWindow, - ExposureMask,&tempEvent); - writeTitle(); - XGetWindowAttributes(dsply,viewport->titleWindow, - &graphWindowAttrib); - if ((graphWindowAttrib.width!=tempTW) || - ((graphWindowAttrib.height)!=tempTH)) { - XResizeWindow(dsply,viewport->viewWindow, - graphWindowAttrib.width, graphWindowAttrib.height); - redoSmooth = yes; /* recompute smooth image pixmap if resized */ - } - } else if (whichWindow == viewport->viewWindow) { - exposeView = yes; - followMouse = no; - XSync(dsply,0); - XCheckWindowEvent(dsply,viewport->viewWindow,ExposureMask, - &tempEvent); - XGetWindowAttributes(dsply,viewport->viewWindow,&graphWindowAttrib); - if ((graphWindowAttrib.width!=tempVW) || - ((graphWindowAttrib.height)!=tempVH)) { - XResizeWindow(dsply,viewport->viewWindow,graphWindowAttrib.width, - graphWindowAttrib.height); - redoSmooth = yes; /* recompute smooth image pixmap if resized */ - } - drawViewport(Xoption); - XMapWindow(dsply,whichWindow); - } else if (whichWindow == lightingWindow) { - XGetWindowAttributes(dsply,control->controlWindow, - &graphWindowAttrib); - /* do not allow resizing of control panel */ - if ((graphWindowAttrib.width!=controlWidth) || - (graphWindowAttrib.height!=controlHeight)) { - XResizeWindow(dsply,control->controlWindow,controlWidth, - controlHeight); - } - drawLightingPanel(); - } else if (whichWindow == volumeWindow) { - XGetWindowAttributes(dsply,control->controlWindow, - &graphWindowAttrib); - /* do not allow resizing of control panel */ - if ((graphWindowAttrib.width!=controlWidth) || - (graphWindowAttrib.height!=controlHeight)) { - XResizeWindow(dsply,control->controlWindow,controlWidth, - controlHeight); - } - drawVolumePanel(); - if (redrawView) { - redrawView = no; - drawViewport(Xoption); - } - } else if (whichWindow == quitWindow) { - XGetWindowAttributes(dsply,control->controlWindow, - &graphWindowAttrib); - /* do not allow resizing of control panel */ - if ((graphWindowAttrib.width!=controlWidth) || - (graphWindowAttrib.height!=controlHeight)) { - XResizeWindow(dsply,control->controlWindow,controlWidth, - controlHeight); - } - drawQuitPanel(); - } else if (whichWindow == saveWindow) { - XGetWindowAttributes(dsply,control->controlWindow, - &graphWindowAttrib); - /* do not allow resizing of control panel */ - if ((graphWindowAttrib.width!=controlWidth) || - (graphWindowAttrib.height!=controlHeight)) { - XResizeWindow(dsply,control->controlWindow,controlWidth, - controlHeight); - } - drawSavePanel(); - } else if (whichWindow == control->controlWindow) { - XGetWindowAttributes(dsply,control->controlWindow, - &graphWindowAttrib); - /* do not allow resizing of control panel */ - if ((graphWindowAttrib.width != controlWidth) || - (graphWindowAttrib.height != controlHeight)) { - XResizeWindow(dsply,control->controlWindow, - controlWidth,controlHeight); - } - if (viewport->haveControl) drawControlPanel(); - followMouse = no; - if (redrawView || exposeView) { - redrawView = no; - drawViewport(Xoption); - } - exposeView = no; - } else { - fprintf(stderr,"Not a valid window.\n"); - } - - XFlush(dsply); - while(XCheckTypedWindowEvent(dsply, whichWindow, Expose, &tempEvent)); - break; - - - case MotionNotify: - exposeView = no; - if (followMouse) { - if (whichWindow == control->colormapWindow) { - while (XCheckMaskEvent(dsply,ButtonMotionMask,event)); - first_time = checkButton = followMouse = changingColor = yes; - gotToggle = no; - } else if (whichWindow != control->controlWindow) { - if (controlButton->pot) { - while (XCheckMaskEvent(dsply,ButtonMotionMask,event)); - mouseXY = getPotValue(((XButtonEvent *)event)->x, - ((XButtonEvent *)event)->y, - controlButton->xHalf, - controlButton->yHalf); - linearMouseXY = getLinearPotValue(((XButtonEvent *)event)->x, - ((XButtonEvent *)event)->y, - controlButton->xHalf, - controlButton->yHalf); - first_time = checkButton = followMouse = yes; - gotToggle = no; - } - } - } - break; - - case ButtonRelease: - exposeView = followMouse = no; - toggleReady = yes; gotToggle = yes; - break; - - case LeaveNotify: - XQueryPointer(dsply,rtWindow,&dummy,&dummy,&px,&py,&lx,&ly,&lbuttons); - if ( (controlButton) && - ((whichWindow == control->colormapWindow) || - (controlButton->pot)) && - (lbuttons & Button1Mask || - lbuttons & Button2Mask || - lbuttons & Button3Mask)) { - followMouse = yes; - if (whichWindow == control->colormapWindow) - changingColor = yes; - } - else { - followMouse = no; - changingColor = no; - } - toggleReady = yes; - checkButton = exposeView = no; - break; - - case ButtonPress: - exposeView = no; changingColor = no; - if (whichWindow == viewport->viewWindow) { - /* find out where the mouse button is pressed on the viewport, - this determines where to put the control panel */ - XGetWindowAttributes(dsply,whichWindow,&graphWindowAttrib); - mouseW4 = graphWindowAttrib.width/4; - if (((XButtonEvent *)event)->x > (graphWindowAttrib.width-mouseW4)) - someInt = 1; - else { - mouseH4 = graphWindowAttrib.height/4; - if (((XButtonEvent *)event)->y > - (graphWindowAttrib.height - mouseH4)) someInt = 2; - else if (((XButtonEvent *)event)->x < mouseW4) someInt = 3; - else if (((XButtonEvent *)event)->y < mouseH4) someInt = 4; - else someInt = 0; - } - if (viewport->haveControl) { - XUnmapWindow(dsply,control->controlWindow); - } - putControlPanelSomewhere(someInt); - writeControlMessage(); - XSync(dsply,0); - } else if (whichWindow == control->colormapWindow) { - gotToggle = no; - first_time = checkButton = followMouse = changingColor = yes; - } else if (whichWindow != control->controlWindow) { - /* mouse clicked on one of the buttons */ - if (!controlButton || (controlButton->self != whichWindow)) { - buttonTablePtr = *((int *)XLookUpAssoc(dsply,table,whichWindow)); - /** lighting buttons have indices greater than 100 **/ - /** all buttons share the same array now **/ - controlButton = &(control->buttonQueue[buttonTablePtr]); - } - if (controlButton->pot) { - /* figure out [x,y] for this button in the range [-1..1,-1..1] */ - mouseXY = getPotValue(((XButtonEvent *)event)->x, - ((XButtonEvent *)event)->y, - controlButton->xHalf,controlButton->yHalf); - linearMouseXY = getLinearPotValue(((XButtonEvent *)event)->x, - ((XButtonEvent *)event)->y, - controlButton->xHalf, - controlButton->yHalf); - followMouse = yes; - gotToggle = no; - } else { - followMouse = no; - gotToggle = yes; /* auto-repeat of toggle buttons not allowed */ - if (toggleReady) toggleReady = no; - } - checkButton = yes; - first_time = yes; - } - break; - - default: - toggleReady = gotToggle = yes; - exposeView = changingColor = checkButton = followMouse = no; - break; - - } /* switch */ - gotEvent--; - } /* if gotEvent */ - - /* Allow a pressed mouse button on a potentiometer to poll repeatedly. */ - if (followMouse && !first_time && (followMouse++ > mouseWait)) { - /* reset for next timing loop */ - followMouse = yes; - checkButton = yes; - } - if (checkButton) { - if (viewport->closing && (controlButton->buttonKey == quitReturn)) { - goodbye(-1); - } else if (changingColor) { - viewport->closing = no; - /* moving top color map pointer */ - if (((XButtonEvent *)event)->y < colorOffsetY) { - if (((XButtonEvent *)event)->x < (colorOffset+colorWidth)) { - /* decreasing top hue number */ - if (viewport->hueTop > 0) viewport->hueTop--; - } else if (((XButtonEvent *)event)->x >= - (colorOffsetX + totalHues*colorWidth + colorWidth)) { - if (viewport->hueTop < totalHues) viewport->hueTop++; - } else { - viewport->hueTop = - (((XButtonEvent *)event)->x - - colorOffsetX + colorWidth/2 - 13) / colorWidth; - } - } else if (((XButtonEvent *)event)->y > - (colorOffsetY + colorHeight)) { - /* moving bottom color map pointer */ - if (((XButtonEvent *)event)->x < (colorOffset+colorWidth)) { - /* decreasing offset number */ - if (viewport->hueOffset > 0) viewport->hueOffset--; - } else if (((XButtonEvent *)event)->x >= - (colorOffsetX + totalHues*colorWidth + colorWidth)) { - if (viewport->hueOffset < totalHues) viewport->hueOffset++; - } else { - viewport->hueOffset = - (((XButtonEvent *)event)->x - - colorOffsetX + colorWidth/2 - 13) / colorWidth; - } - } - /* color map pointer does not wrap around */ - 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; - redoDither = no; - } else { - redoColor = no; - redoDither = yes; - } - /* update color map changes on control panel */ - drawColorMap(); - } else { - viewport->closing = no; - clearControlMessage(); - /* reset all the things that might affect a recalculation for - redrawing removing hidden surfaces */ - - /* determine what type of button has been pressed */ - switch(controlButton->buttonKey) { - - /*** Potentiometers ***/ - case rotate: - if (!((viewport->originrOn) && (viewport->objectrOn))) { - /* update the amount of rotation around the object center - of volume */ - if (viewport->objectrOn) { - viewport->thetaObj += mouseXY.x * rotateFactor; - viewport->phiObj -= mouseXY.y * rotateFactor; - while (viewport->thetaObj >= two_pi) { - viewport->thetaObj -= two_pi; - } - while (viewport->thetaObj < 0.0) { - viewport->thetaObj += two_pi; - } - while (viewport->phiObj > pi) { - viewport->phiObj -= two_pi; - } - while (viewport->phiObj <= -pi) { - viewport->phiObj += two_pi; - } - } - /* update amount of rotation around the world space origin */ - if (viewport->originrOn) { - viewport->theta += mouseXY.x * rotateFactor; - viewport->phi -= mouseXY.y * rotateFactor; - 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 += mouseXY.x * rotateFactor; - viewport->axesphi -= mouseXY.y * rotateFactor; - while (viewport->axestheta >= two_pi) { - viewport->axestheta -= two_pi; - } - while (viewport->axestheta < 0.0) { - viewport->axestheta += two_pi; - } - while (viewport->axesphi > pi) { - viewport->axesphi -= two_pi; - } - while (viewport->axesphi <= -pi) { - viewport->axesphi += two_pi; - } - } - rotated = yes; - viewport->yzOn = viewport->xzOn = viewport->xyOn = no; - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - drawViewport(Xoption); - } - break; - - case zoom: - /* if uniform scaling */ - if ((viewport->zoomXOn) && - (viewport->zoomYOn) && - (viewport->zoomZOn)) { - viewport->scale *= 1 - mouseXY.y * scaleFactor; - } else { /* else scale axes independently */ - if (viewport->zoomXOn) viewport->scaleX *= (1 - mouseXY.y); - if (viewport->zoomYOn) viewport->scaleY *= (1 - mouseXY.y); - if (viewport->zoomZOn) viewport->scaleZ *= (1 - mouseXY.y); - } - if (viewport->scale > maxScale) viewport->scale = maxScale; - else if (viewport->scale < minScale) viewport->scale = minScale; - if (viewport->scaleX > maxScale) viewport->scaleX = maxScale; - else if (viewport->scaleX < minScale) viewport->scaleX = minScale; - if (viewport->scaleY > maxScale) viewport->scaleY = maxScale; - else if (viewport->scaleY < minScale) viewport->scaleY = minScale; - if (viewport->scaleZ > maxScale) viewport->scaleZ = maxScale; - else if (viewport->scaleZ < minScale) viewport->scaleZ = minScale; - zoomed = yes; - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - if ((viewport->zoomXOn) || - (viewport->zoomYOn) || - (viewport->zoomZOn)) - drawViewport(Xoption); - break; - - case translate: - viewport->deltaX += mouseXY.x * translateFactor; - viewport->deltaY += mouseXY.y * translateFactor; - 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; - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - drawViewport(Xoption); - break; - - /*** Lighting panel ***/ - case lightMoveXY: - tempLightPointer[0] = linearMouseXY.x; - tempLightPointer[1] = linearMouseXY.y; - if (tempLightPointer[0] > 1) tempLightPointer[0] = 1; - else if (tempLightPointer[0] < -1) tempLightPointer[0] = -1; - if (tempLightPointer[1] > 1) tempLightPointer[1] = 1; - else if (tempLightPointer[1] < -1) tempLightPointer[1] = -1; - movingLight = yes; - drawLightingAxes(); - break; - - case lightMoveZ: - tempLightPointer[2] = linearMouseXY.y; - /* linearMouse => no checking necessary */ - if (tempLightPointer[2] > 1) tempLightPointer[2] = 1; - else if (tempLightPointer[2] < -1) tempLightPointer[2] = -1; - movingLight = yes; - drawLightingAxes(); - break; - - /* changes the light intensity */ - case lightTranslucent: - tempLightIntensity = (linearMouseXY.y+1)/2; - if (tempLightIntensity > 1) tempLightIntensity = 1; - else if (tempLightIntensity < 0) tempLightIntensity = 0; - changedIntensity = yes; - drawLightTransArrow(); - break; - - /*** volume panel ***/ - case frustrumBut: - screenX = ((XButtonEvent *)event)->x; - if inside(eyeMinX,eyeMaxX) { - /* object coordinate */ - f2 = mouseXY.x * (maxEyeDistance - minEyeDistance) + - minEyeDistance; - if (f2 != viewData.eyeDistance) { - doingVolume = 2; /* flag for using screenX */ - changedEyeDistance = yes; - viewData.eyeDistance = f2; - drawFrustrum(); - drawViewport(Xoption); - } - } - else if inside(hitherMinX,hitherMaxX) { - f1 = ((float)hitherMaxX - ((XButtonEvent *)event)->x) / - (hitherMaxX - hitherMinX); - /* object coordinate */ - f2 = f1 * (clipPlaneMax - clipPlaneMin) + clipPlaneMin; - if (f2 != viewData.clipPlane) { - doingVolume = 3; /* flag for using screenX */ - viewData.clipPlane = f2; - drawFrustrum(); - drawViewport(Xoption); - } - } - else { - doingVolume = 1; /* check out doingVolume */ - doingPanel = VOLUMEpanel; - } - break; - - case clipXBut: /* this is a horizontal button */ - clipValue = linearMouseXY.x * 0.5 + 0.5; /* normalize to 0..1 */ - if (lessThan(clipValue,0.0)) clipValue = 0.0; - if (greaterThan(clipValue,1.0)) clipValue = 1.0; - if (lessThan(linearMouseXY.y,0.0)) { - if (!equal(xClipMinN,clipValue)) { - if (greaterThan(xClipMaxN-clipValue,minDistXY)) - xClipMinN = clipValue; - else - xClipMinN = xClipMaxN - minDistXY; - viewData.clipXmin = xClipMinN * - (viewData.xmax - viewData.xmin) + - viewData.xmin; - drawClipXBut(); - drawClipVolume(); - if (viewData.clipbox) - drawViewport(Xoption); - } - } else { - if (!equal(xClipMaxN,clipValue)) { - if (greaterThan(clipValue-xClipMinN,minDistXY)) - xClipMaxN = clipValue; - else - xClipMaxN = xClipMinN + minDistXY; - viewData.clipXmax = xClipMaxN * - (viewData.xmax - viewData.xmin) + - viewData.xmin; - drawClipXBut(); - drawClipVolume(); - if (viewData.clipbox) - drawViewport(Xoption); - } - } - break; - - case clipYBut: /* this is a vertical button */ - /* normalize to 0..1, bottom up */ - clipValue = 1 - (linearMouseXY.y * 0.5 + 0.5); - if (lessThan(clipValue,0.0)) clipValue = 0.0; - if (greaterThan(clipValue,1.0)) clipValue = 1.0; - if (lessThan(linearMouseXY.x,0.0)) { - if (!equal(yClipMinN,clipValue)) { - if (greaterThan(yClipMaxN-clipValue,minDistXY)) - yClipMinN = clipValue; - else - yClipMinN = yClipMaxN - minDistXY; - viewData.clipYmin = yClipMinN * - (viewData.ymax - viewData.ymin) + - viewData.ymin; - drawClipYBut(); - drawClipVolume(); - if (viewData.clipbox) - drawViewport(Xoption); - } - } else { - if (!equal(yClipMaxN,clipValue)) { - if (greaterThan(clipValue-yClipMinN,minDistXY)) - yClipMaxN = clipValue; - else - yClipMaxN = yClipMinN + minDistXY; - viewData.clipYmax = yClipMaxN * - (viewData.ymax - viewData.ymin) + - viewData.ymin; - drawClipYBut(); - drawClipVolume(); - if (viewData.clipbox) - drawViewport(Xoption); - } - } - break; - - case clipZBut: /* this is a diagonally aligned button! */ - /* f1 is the distance from the center of the button along - the diagonal line with a slope of -1. If f1 is negative, - the direction is downward from the center, if f1 is - positive, the direction is upward from the center. - Note that there ought to be a constant factor, namely - cos(45), multiplied by f1 for the correct normalized value; - however, we exploit this by foreshortening the length of the - diagonal by that same factor (so instead of normalizing the - numbers to, the line we normalize the line to the numbers) - since we need to shorten the line at some point anyway - (both to match the length of the diagonal side of the box - and to allow more area for mouse input. */ - - /* cos(45), etc => 0.4 */ - f1 = (linearMouseXY.x - linearMouseXY.y) * 0.4 + 0.5; - if (lessThan(f1,0.0)) f1 = 0.0; - if (greaterThan(f1,1.0)) f1 = 1.0; - /* note that x<y => moving upward */ - if (lessThan(-linearMouseXY.x,linearMouseXY.y)) { - if (!equal(zClipMaxN,f1)) { - if (greaterThan(f1-zClipMinN,minDistZ)) - zClipMaxN = f1; - else - zClipMaxN = zClipMinN + minDistZ; - viewData.clipZmax = zClipMaxN * - (viewData.zmax - viewData.zmin) + - viewData.zmin; - drawClipZBut(); - drawClipVolume(); - if (viewData.clipbox) - drawViewport(Xoption); - } - } else { - if (!equal(zClipMinN,f1)) { - if (greaterThan(zClipMaxN-f1,minDistZ)) - zClipMinN = f1; - else - zClipMinN = zClipMaxN - minDistZ; - viewData.clipZmin = zClipMinN * - (viewData.zmax - viewData.zmin) + - viewData.zmin; - drawClipZBut(); - drawClipVolume(); - if (viewData.clipbox) - drawViewport(Xoption); - } - } /* if lessThan(x,y) */ - break; - - case perspectiveBut: - if ((viewData.perspective = !viewData.perspective)) { - switchedPerspective = yes; - GSetForeground(volumeGC, - (float)monoColor((control->buttonQueue[perspectiveBut]).textColor),Xoption); - GDrawString(volumeGC,volumeWindow, - controlButton->buttonX + - centerX(volumeGC,"x",1,controlButton->buttonWidth), - controlButton->buttonY + - centerY(volumeGC,controlButton->buttonHeight), - "x",1,Xoption); - } - else - XClearArea(dsply,volumeWindow, - controlButton->buttonX+1, - controlButton->buttonY+1, - controlButton->buttonHeight-2, - controlButton->buttonWidth-2, - False); - drawViewport(Xoption); - break; - - case clipRegionBut: - if ((viewData.clipbox = !viewData.clipbox)) { - GSetForeground(volumeGC, - (float)monoColor((control->buttonQueue[clipRegionBut]).textColor),Xoption); - GDrawString(volumeGC,volumeWindow, - controlButton->buttonX + - centerX(volumeGC,"x",1,controlButton->buttonWidth), - controlButton->buttonY + - centerY(volumeGC,controlButton->buttonHeight), - "x",1,Xoption); - } - else - XClearArea(dsply,volumeWindow, - controlButton->buttonX+1, - controlButton->buttonY+1, - controlButton->buttonWidth-2, - controlButton->buttonHeight-2, - False); - - drawViewport(Xoption); - break; - - case clipSurfaceBut: - if ((viewData.clipStuff = !viewData.clipStuff)) { - GSetForeground(volumeGC, - (float)monoColor((control->buttonQueue[clipSurfaceBut]).textColor),Xoption); - GDrawString(volumeGC,volumeWindow, - controlButton->buttonX + - centerX(volumeGC,"x",1,controlButton->buttonWidth), - controlButton->buttonY + - centerY(volumeGC,controlButton->buttonHeight), - "x",1,Xoption); - } - else - XClearArea(dsply,volumeWindow, - controlButton->buttonX+1, - controlButton->buttonY+1, - controlButton->buttonWidth-2, - controlButton->buttonHeight-2, - False); - break; - - default: - buttonAction(controlButton->buttonKey); - } /* switch on buttonKey */ - - } /* else - not closing */ - } /* if checkButton */ - } /* if FD_ISSET(Xcon,.. */ - else if FD_ISSET(0,&rd) { - externalControl = spadAction(); - if (spadDraw && (externalControl==0)) drawViewport(Xoption); - } - } /* for (until closed) */ -} /* processEvents() */ - - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/project3d.c.pamphlet b/src/graph/view3D/project3d.c index 1d6ca193..4108ec0e 100644 --- a/src/graph/view3D/project3d.c.pamphlet +++ b/src/graph/view3D/project3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D project3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _PROJECT3D_C #include "axiom-c-macros.h" @@ -123,7 +109,7 @@ project(viewTriple * aViewTriple,XPoint *someXpoints,int i) void #ifdef _NO_PROTO projectAPoint(aViewTriple) - viewTriple *aViewTriple; + viewTriple *aViewTriple; #else projectAPoint(viewTriple *aViewTriple) #endif @@ -215,7 +201,7 @@ projectAllPoints(void) void #ifdef _NO_PROTO projectAllPolys (pList) - poly *pList; + poly *pList; #else projectAllPolys (poly *pList) #endif @@ -295,7 +281,7 @@ projectAllPolys (poly *pList) void #ifdef _NO_PROTO projectAPoly (p) - poly *p; + poly *p; #else projectAPoly (poly *p) #endif @@ -437,9 +423,3 @@ projectStuff(float x,float y,float z,int *px,int *py,float *Pz) viewport->scaleZ = tempz; viewScale = temps; } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/quit3d.c b/src/graph/view3D/quit3d.c new file mode 100644 index 00000000..3b633852 --- /dev/null +++ b/src/graph/view3D/quit3d.c @@ -0,0 +1,172 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _QUIT3D_C +#include "axiom-c-macros.h" + +#include <string.h> +#include "header.h" +#include "cpanel.h" +#include "volume.h" +#include "../include/purty/volume.bitmap" +#include "../include/purty/volume.mask" + +#include "util.H1" +#include "Gfun.H1" +#include "XSpadFill.H1" +#include "all_3d.H1" + +#define quitMASK ExposureMask +#define quitCursorForeground monoColor(55) +#define quitCursorBackground monoColor(197) +#define quitTitleColor monoColor(69) +#define quitButtonColor monoColor(195) +#define quitFontHeight (quitFont->max_bounds.ascent+quitFont->max_bounds.descent) + + +/*************************** + * int makeQuitPanel() * + ***************************/ + +int +#ifdef _NO_PROTO +makeQuitPanel() +#else +makeQuitPanel(void) +#endif +{ + + int i; + XSetWindowAttributes quitter,QuitterAttrib; + XSizeHints sizeh; + Pixmap quitbits, quitmask; + XColor quitterColor,qColor; + + quitbits = XCreateBitmapFromData(dsply,rtWindow, volumeBitmap_bits, + volumeBitmap_width,volumeBitmap_height); + quitmask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits, + volumeMask_width,volumeMask_height); + quitter.background_pixel = backgroundColor; + quitter.border_pixel = foregroundColor; + quitter.event_mask = quitMASK; + quitter.colormap = colorMap; + quitter.override_redirect = overrideManager; + quitterColor.pixel = quitCursorForeground; + XQueryColor(dsply,colorMap,&quitterColor); + qColor.pixel = quitCursorBackground; + XQueryColor(dsply,colorMap,&qColor); + quitter.cursor = XCreatePixmapCursor(dsply,quitbits,quitmask, + &quitterColor,&qColor, + volumeBitmap_x_hot,volumeBitmap_y_hot); + quitWindow = XCreateWindow(dsply,control->controlWindow, + controlWidth-quitWidth-2,controlHeight-quitHeight-2, + quitWidth-2,quitHeight-2,2, + CopyFromParent,InputOutput,CopyFromParent, + controlCreateMASK,&quitter); + + sizeh.flags = USPosition | USSize; + sizeh.x = 0; + sizeh.y = 0; + sizeh.width = quitWidth-2; + sizeh.height = quitHeight-2; + + XSetNormalHints(dsply,quitWindow,&sizeh); + XSetStandardProperties(dsply,quitWindow,"Quit Panel","Quit Panel", + None,NULL,0,&sizeh); + + /*** do quit buttons ***/ + initQuitButtons(control->buttonQueue); + for (i=quitButtonsStart; i<(quitButtonsEnd); i++) { + QuitterAttrib.event_mask = (control->buttonQueue[i]).mask; + (control->buttonQueue[i]).self = + XCreateWindow(dsply,quitWindow, + (control->buttonQueue[i]).buttonX, + (control->buttonQueue[i]).buttonY, + (control->buttonQueue[i]).buttonWidth, + (control->buttonQueue[i]).buttonHeight, + 0,0,InputOnly,CopyFromParent, + buttonCreateMASK,&QuitterAttrib); + XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, + &((control->buttonQueue[i]).buttonKey)); + XMapWindow(dsply,(control->buttonQueue[i]).self); + } + + return(0); + +} /* makeQuitPanel() */ + + +/**************************** + * void drawQuitPanel() * + ****************************/ + +void +#ifdef _NO_PROTO +drawQuitPanel() +#else +drawQuitPanel(void) +#endif +{ + + char *s; + int i,strlength; + + s = "Really?"; + strlength = strlen(s); + GSetForeground(anotherGC,(float)quitTitleColor,Xoption); + GDrawString(anotherGC,quitWindow, + centerX(anotherGC,s,strlength,quitWidth),centerY(anotherGC,39),s,strlength,Xoption); + + GSetForeground(anotherGC,(float)quitButtonColor,Xoption); + for (i=quitButtonsStart; i<(quitButtonsEnd); i++) { + GDraw3DButtonOut(quitGC,quitWindow, + (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,quitWindow, + (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 */ + +} /* drawQuitPanel */ diff --git a/src/graph/view3D/quit3d.c.pamphlet b/src/graph/view3D/quit3d.c.pamphlet deleted file mode 100644 index 072e45ee..00000000 --- a/src/graph/view3D/quit3d.c.pamphlet +++ /dev/null @@ -1,192 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D quit3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _QUIT3D_C -#include "axiom-c-macros.h" - -#include <string.h> -#include "header.h" -#include "cpanel.h" -#include "volume.h" -#include "../include/purty/volume.bitmap" -#include "../include/purty/volume.mask" - -#include "util.H1" -#include "Gfun.H1" -#include "XSpadFill.H1" -#include "all_3d.H1" - -#define quitMASK ExposureMask -#define quitCursorForeground monoColor(55) -#define quitCursorBackground monoColor(197) -#define quitTitleColor monoColor(69) -#define quitButtonColor monoColor(195) -#define quitFontHeight (quitFont->max_bounds.ascent+quitFont->max_bounds.descent) - - -/*************************** - * int makeQuitPanel() * - ***************************/ - -int -#ifdef _NO_PROTO -makeQuitPanel() -#else -makeQuitPanel(void) -#endif -{ - - int i; - XSetWindowAttributes quitter,QuitterAttrib; - XSizeHints sizeh; - Pixmap quitbits, quitmask; - XColor quitterColor,qColor; - - quitbits = XCreateBitmapFromData(dsply,rtWindow, volumeBitmap_bits, - volumeBitmap_width,volumeBitmap_height); - quitmask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits, - volumeMask_width,volumeMask_height); - quitter.background_pixel = backgroundColor; - quitter.border_pixel = foregroundColor; - quitter.event_mask = quitMASK; - quitter.colormap = colorMap; - quitter.override_redirect = overrideManager; - quitterColor.pixel = quitCursorForeground; - XQueryColor(dsply,colorMap,&quitterColor); - qColor.pixel = quitCursorBackground; - XQueryColor(dsply,colorMap,&qColor); - quitter.cursor = XCreatePixmapCursor(dsply,quitbits,quitmask, - &quitterColor,&qColor, - volumeBitmap_x_hot,volumeBitmap_y_hot); - quitWindow = XCreateWindow(dsply,control->controlWindow, - controlWidth-quitWidth-2,controlHeight-quitHeight-2, - quitWidth-2,quitHeight-2,2, - CopyFromParent,InputOutput,CopyFromParent, - controlCreateMASK,&quitter); - - sizeh.flags = USPosition | USSize; - sizeh.x = 0; - sizeh.y = 0; - sizeh.width = quitWidth-2; - sizeh.height = quitHeight-2; - - XSetNormalHints(dsply,quitWindow,&sizeh); - XSetStandardProperties(dsply,quitWindow,"Quit Panel","Quit Panel", - None,NULL,0,&sizeh); - - /*** do quit buttons ***/ - initQuitButtons(control->buttonQueue); - for (i=quitButtonsStart; i<(quitButtonsEnd); i++) { - QuitterAttrib.event_mask = (control->buttonQueue[i]).mask; - (control->buttonQueue[i]).self = - XCreateWindow(dsply,quitWindow, - (control->buttonQueue[i]).buttonX, - (control->buttonQueue[i]).buttonY, - (control->buttonQueue[i]).buttonWidth, - (control->buttonQueue[i]).buttonHeight, - 0,0,InputOnly,CopyFromParent, - buttonCreateMASK,&QuitterAttrib); - XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, - &((control->buttonQueue[i]).buttonKey)); - XMapWindow(dsply,(control->buttonQueue[i]).self); - } - - return(0); - -} /* makeQuitPanel() */ - - -/**************************** - * void drawQuitPanel() * - ****************************/ - -void -#ifdef _NO_PROTO -drawQuitPanel() -#else -drawQuitPanel(void) -#endif -{ - - char *s; - int i,strlength; - - s = "Really?"; - strlength = strlen(s); - GSetForeground(anotherGC,(float)quitTitleColor,Xoption); - GDrawString(anotherGC,quitWindow, - centerX(anotherGC,s,strlength,quitWidth),centerY(anotherGC,39),s,strlength,Xoption); - - GSetForeground(anotherGC,(float)quitButtonColor,Xoption); - for (i=quitButtonsStart; i<(quitButtonsEnd); i++) { - GDraw3DButtonOut(quitGC,quitWindow, - (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,quitWindow, - (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 */ - -} /* drawQuitPanel */ -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/quitbut3d.c b/src/graph/view3D/quitbut3d.c new file mode 100644 index 00000000..ec85d09e --- /dev/null +++ b/src/graph/view3D/quitbut3d.c @@ -0,0 +1,88 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _QUITBUT3D_C +#include "axiom-c-macros.h" + +#include "header.h" +#include "cpanel.h" + +#include "all_3d.H1" + + + +int +#ifdef _NO_PROTO +initQuitButtons (quitButtons) +buttonStruct *quitButtons; +#else +initQuitButtons (buttonStruct *quitButtons) +#endif +{ + int ii; + int num = 0; + + ii = quitAbort; + quitButtons[ii].buttonX = 5; + quitButtons[ii].buttonY = 41; + quitButtons[ii].buttonWidth = 53; + quitButtons[ii].buttonHeight = 25; + quitButtons[ii].buttonKey = ii; + quitButtons[ii].pot = no; + quitButtons[ii].mask = buttonMASK; + quitButtons[ii].text = "No"; + quitButtons[ii].textColor = 6; + quitButtons[ii].xHalf = quitButtons[ii].buttonWidth/2; + quitButtons[ii].yHalf = quitButtons[ii].buttonHeight/2; + ++num; + + ii = quitReturn; + quitButtons[ii].buttonX = 5; + quitButtons[ii].buttonY = 75; + quitButtons[ii].buttonWidth = 53; + quitButtons[ii].buttonHeight = 25; + quitButtons[ii].buttonKey = ii; + quitButtons[ii].pot = no; + quitButtons[ii].mask = buttonMASK; + quitButtons[ii].text = "Yes"; + quitButtons[ii].textColor = onColor; + quitButtons[ii].xHalf = quitButtons[ii].buttonWidth/2; + quitButtons[ii].yHalf = quitButtons[ii].buttonHeight/2; + ++num; + + return(num); +} + + diff --git a/src/graph/view3D/quitbut3d.c.pamphlet b/src/graph/view3D/quitbut3d.c.pamphlet deleted file mode 100644 index befa1957..00000000 --- a/src/graph/view3D/quitbut3d.c.pamphlet +++ /dev/null @@ -1,108 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D quitbut3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _QUITBUT3D_C -#include "axiom-c-macros.h" - -#include "header.h" -#include "cpanel.h" - -#include "all_3d.H1" - - - -int -#ifdef _NO_PROTO -initQuitButtons (quitButtons) -buttonStruct *quitButtons; -#else -initQuitButtons (buttonStruct *quitButtons) -#endif -{ - int ii; - int num = 0; - - ii = quitAbort; - quitButtons[ii].buttonX = 5; - quitButtons[ii].buttonY = 41; - quitButtons[ii].buttonWidth = 53; - quitButtons[ii].buttonHeight = 25; - quitButtons[ii].buttonKey = ii; - quitButtons[ii].pot = no; - quitButtons[ii].mask = buttonMASK; - quitButtons[ii].text = "No"; - quitButtons[ii].textColor = 6; - quitButtons[ii].xHalf = quitButtons[ii].buttonWidth/2; - quitButtons[ii].yHalf = quitButtons[ii].buttonHeight/2; - ++num; - - ii = quitReturn; - quitButtons[ii].buttonX = 5; - quitButtons[ii].buttonY = 75; - quitButtons[ii].buttonWidth = 53; - quitButtons[ii].buttonHeight = 25; - quitButtons[ii].buttonKey = ii; - quitButtons[ii].pot = no; - quitButtons[ii].mask = buttonMASK; - quitButtons[ii].text = "Yes"; - quitButtons[ii].textColor = onColor; - quitButtons[ii].xHalf = quitButtons[ii].buttonWidth/2; - quitButtons[ii].yHalf = quitButtons[ii].buttonHeight/2; - ++num; - - return(num); -} - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/save3d.c b/src/graph/view3D/save3d.c new file mode 100644 index 00000000..45eae76f --- /dev/null +++ b/src/graph/view3D/save3d.c @@ -0,0 +1,167 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _SAVE3D_C +#include "axiom-c-macros.h" + +#include <stdio.h> +#include <string.h> +#include "header.h" +#include "cpanel.h" +#include "volume.h" +#include "../include/purty/volume.bitmap" +#include "../include/purty/volume.mask" + +#include "Gfun.H1" +#include "XSpadFill.H1" +#include "all_3d.H1" + +#define saveMASK ExposureMask +#define saveCursorForeground monoColor(55) +#define saveCursorBackground monoColor(197) +#define saveTitleColor monoColor(70) +#define saveButtonColor monoColor(195) +#define saveFontHeight (saveFont->max_bounds.ascent+saveFont->max_bounds.descent) + + +/*************************** + * int makeSavePanel() * + ***************************/ + +int +#ifdef _NO_PROTO +makeSavePanel() +#else +makeSavePanel(void) +#endif +{ + + int i; + XSetWindowAttributes saver,SaverAttrib; + XSizeHints sizeh; + Pixmap savebits, savemask; + XColor saveColor,sColor; + + savebits = XCreateBitmapFromData(dsply,rtWindow, volumeBitmap_bits, + volumeBitmap_width,volumeBitmap_height); + savemask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits, + volumeMask_width,volumeMask_height); + saver.background_pixel = backgroundColor; + saver.border_pixel = foregroundColor; + saver.event_mask = saveMASK; + saver.colormap = colorMap; + saver.override_redirect = overrideManager; + saveColor.pixel = saveCursorForeground; + XQueryColor(dsply,colorMap,&saveColor); + sColor.pixel = saveCursorBackground; + XQueryColor(dsply,colorMap,&sColor); + saver.cursor = XCreatePixmapCursor(dsply,savebits,savemask, + &saveColor,&sColor, + volumeBitmap_x_hot,volumeBitmap_y_hot); + + saveWindow = XCreateWindow(dsply,control->controlWindow, + controlWidth-saveWidth-2, controlHeight-saveHeight-2, + saveWidth-2,saveHeight-2,2, + CopyFromParent,InputOutput,CopyFromParent, + controlCreateMASK,&saver); + + sizeh.flags = USPosition | USSize; + sizeh.x = 0; + sizeh.y = 0; + sizeh.width = saveWidth-2; + sizeh.height = saveHeight-2; + + XSetNormalHints(dsply,saveWindow,&sizeh); + XSetStandardProperties(dsply,saveWindow,"Save Panel","Save Panel", + None,NULL,0,&sizeh); + + /*** Create save buttons ***/ + initSaveButtons(control->buttonQueue); + for (i=saveButtonsStart; i<(saveButtonsEnd); i++) { + SaverAttrib.event_mask = (control->buttonQueue[i]).mask; + (control->buttonQueue[i]).self = + XCreateWindow(dsply,saveWindow, + (control->buttonQueue[i]).buttonX, + (control->buttonQueue[i]).buttonY, + (control->buttonQueue[i]).buttonWidth, + (control->buttonQueue[i]).buttonHeight, + 0,0,InputOnly,CopyFromParent, + buttonCreateMASK,&SaverAttrib); + XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, + &((control->buttonQueue[i]).buttonKey)); + XMapWindow(dsply,(control->buttonQueue[i]).self); + } + + return(0); + +} /* makeSavePanel() */ + + +/**************************** + * void drawSavePanel() * + ****************************/ + +void +#ifdef _NO_PROTO +drawSavePanel() +#else +drawSavePanel(void) +#endif +{ + + 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 */ diff --git a/src/graph/view3D/save3d.c.pamphlet b/src/graph/view3D/save3d.c.pamphlet deleted file mode 100644 index 432c64ad..00000000 --- a/src/graph/view3D/save3d.c.pamphlet +++ /dev/null @@ -1,187 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D save3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _SAVE3D_C -#include "axiom-c-macros.h" - -#include <stdio.h> -#include <string.h> -#include "header.h" -#include "cpanel.h" -#include "volume.h" -#include "../include/purty/volume.bitmap" -#include "../include/purty/volume.mask" - -#include "Gfun.H1" -#include "XSpadFill.H1" -#include "all_3d.H1" - -#define saveMASK ExposureMask -#define saveCursorForeground monoColor(55) -#define saveCursorBackground monoColor(197) -#define saveTitleColor monoColor(70) -#define saveButtonColor monoColor(195) -#define saveFontHeight (saveFont->max_bounds.ascent+saveFont->max_bounds.descent) - - -/*************************** - * int makeSavePanel() * - ***************************/ - -int -#ifdef _NO_PROTO -makeSavePanel() -#else -makeSavePanel(void) -#endif -{ - - int i; - XSetWindowAttributes saver,SaverAttrib; - XSizeHints sizeh; - Pixmap savebits, savemask; - XColor saveColor,sColor; - - savebits = XCreateBitmapFromData(dsply,rtWindow, volumeBitmap_bits, - volumeBitmap_width,volumeBitmap_height); - savemask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits, - volumeMask_width,volumeMask_height); - saver.background_pixel = backgroundColor; - saver.border_pixel = foregroundColor; - saver.event_mask = saveMASK; - saver.colormap = colorMap; - saver.override_redirect = overrideManager; - saveColor.pixel = saveCursorForeground; - XQueryColor(dsply,colorMap,&saveColor); - sColor.pixel = saveCursorBackground; - XQueryColor(dsply,colorMap,&sColor); - saver.cursor = XCreatePixmapCursor(dsply,savebits,savemask, - &saveColor,&sColor, - volumeBitmap_x_hot,volumeBitmap_y_hot); - - saveWindow = XCreateWindow(dsply,control->controlWindow, - controlWidth-saveWidth-2, controlHeight-saveHeight-2, - saveWidth-2,saveHeight-2,2, - CopyFromParent,InputOutput,CopyFromParent, - controlCreateMASK,&saver); - - sizeh.flags = USPosition | USSize; - sizeh.x = 0; - sizeh.y = 0; - sizeh.width = saveWidth-2; - sizeh.height = saveHeight-2; - - XSetNormalHints(dsply,saveWindow,&sizeh); - XSetStandardProperties(dsply,saveWindow,"Save Panel","Save Panel", - None,NULL,0,&sizeh); - - /*** Create save buttons ***/ - initSaveButtons(control->buttonQueue); - for (i=saveButtonsStart; i<(saveButtonsEnd); i++) { - SaverAttrib.event_mask = (control->buttonQueue[i]).mask; - (control->buttonQueue[i]).self = - XCreateWindow(dsply,saveWindow, - (control->buttonQueue[i]).buttonX, - (control->buttonQueue[i]).buttonY, - (control->buttonQueue[i]).buttonWidth, - (control->buttonQueue[i]).buttonHeight, - 0,0,InputOnly,CopyFromParent, - buttonCreateMASK,&SaverAttrib); - XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, - &((control->buttonQueue[i]).buttonKey)); - XMapWindow(dsply,(control->buttonQueue[i]).self); - } - - return(0); - -} /* makeSavePanel() */ - - -/**************************** - * void drawSavePanel() * - ****************************/ - -void -#ifdef _NO_PROTO -drawSavePanel() -#else -drawSavePanel(void) -#endif -{ - - 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 */ -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/savebut3d.c b/src/graph/view3D/savebut3d.c new file mode 100644 index 00000000..2a2f8811 --- /dev/null +++ b/src/graph/view3D/savebut3d.c @@ -0,0 +1,98 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _SAVEBUT3D_C +#include "axiom-c-macros.h" + +#include "header.h" +#include "cpanel.h" + +#include "all_3d.H1" +int +#ifdef _NO_PROTO +initSaveButtons (saveButtons) + buttonStruct *saveButtons; +#else +initSaveButtons (buttonStruct *saveButtons) +#endif +{ + int ii; + int num = 0; + + ii = saveExit; + saveButtons[ii].buttonX = 5; + saveButtons[ii].buttonY = 7; + saveButtons[ii].buttonWidth = 53; + saveButtons[ii].buttonHeight = 25; + saveButtons[ii].buttonKey = ii; + saveButtons[ii].pot = no; + saveButtons[ii].mask = buttonMASK; + saveButtons[ii].text = "Cancel"; + saveButtons[ii].textColor = 6; + saveButtons[ii].xHalf = saveButtons[ii].buttonWidth/2; + saveButtons[ii].yHalf = saveButtons[ii].buttonHeight/2; + ++num; + + ii = pixmap; + saveButtons[ii].buttonX = 5; + saveButtons[ii].buttonY = 41; + saveButtons[ii].buttonWidth = 53; + saveButtons[ii].buttonHeight = 25; + saveButtons[ii].buttonKey = ii; + saveButtons[ii].pot = no; + saveButtons[ii].mask = buttonMASK; + saveButtons[ii].text = "Pixmap"; + saveButtons[ii].textColor = 28; + saveButtons[ii].xHalf = saveButtons[ii].buttonWidth/2; + saveButtons[ii].yHalf = saveButtons[ii].buttonHeight/2; + ++num; + + ii = ps; + saveButtons[ii].buttonX = 5; + saveButtons[ii].buttonY = 75; + saveButtons[ii].buttonWidth = 53; + saveButtons[ii].buttonHeight = 25; + saveButtons[ii].buttonKey = ii; + saveButtons[ii].pot = no; + saveButtons[ii].mask = buttonMASK; + saveButtons[ii].text = "PS"; + saveButtons[ii].textColor = 149; + saveButtons[ii].xHalf = saveButtons[ii].buttonWidth/2; + saveButtons[ii].yHalf = saveButtons[ii].buttonHeight/2; + + return(num); +} + + diff --git a/src/graph/view3D/savebut3d.c.pamphlet b/src/graph/view3D/savebut3d.c.pamphlet deleted file mode 100644 index 97645c3f..00000000 --- a/src/graph/view3D/savebut3d.c.pamphlet +++ /dev/null @@ -1,118 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D savebut3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _SAVEBUT3D_C -#include "axiom-c-macros.h" - -#include "header.h" -#include "cpanel.h" - -#include "all_3d.H1" -int -#ifdef _NO_PROTO -initSaveButtons (saveButtons) - buttonStruct *saveButtons; -#else -initSaveButtons (buttonStruct *saveButtons) -#endif -{ - int ii; - int num = 0; - - ii = saveExit; - saveButtons[ii].buttonX = 5; - saveButtons[ii].buttonY = 7; - saveButtons[ii].buttonWidth = 53; - saveButtons[ii].buttonHeight = 25; - saveButtons[ii].buttonKey = ii; - saveButtons[ii].pot = no; - saveButtons[ii].mask = buttonMASK; - saveButtons[ii].text = "Cancel"; - saveButtons[ii].textColor = 6; - saveButtons[ii].xHalf = saveButtons[ii].buttonWidth/2; - saveButtons[ii].yHalf = saveButtons[ii].buttonHeight/2; - ++num; - - ii = pixmap; - saveButtons[ii].buttonX = 5; - saveButtons[ii].buttonY = 41; - saveButtons[ii].buttonWidth = 53; - saveButtons[ii].buttonHeight = 25; - saveButtons[ii].buttonKey = ii; - saveButtons[ii].pot = no; - saveButtons[ii].mask = buttonMASK; - saveButtons[ii].text = "Pixmap"; - saveButtons[ii].textColor = 28; - saveButtons[ii].xHalf = saveButtons[ii].buttonWidth/2; - saveButtons[ii].yHalf = saveButtons[ii].buttonHeight/2; - ++num; - - ii = ps; - saveButtons[ii].buttonX = 5; - saveButtons[ii].buttonY = 75; - saveButtons[ii].buttonWidth = 53; - saveButtons[ii].buttonHeight = 25; - saveButtons[ii].buttonKey = ii; - saveButtons[ii].pot = no; - saveButtons[ii].mask = buttonMASK; - saveButtons[ii].text = "PS"; - saveButtons[ii].textColor = 149; - saveButtons[ii].xHalf = saveButtons[ii].buttonWidth/2; - saveButtons[ii].yHalf = saveButtons[ii].buttonHeight/2; - - return(num); -} - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/smoothShade3d.c b/src/graph/view3D/smoothShade3d.c new file mode 100644 index 00000000..4d74c5a0 --- /dev/null +++ b/src/graph/view3D/smoothShade3d.c @@ -0,0 +1,1122 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _SMOOTHSHADE_C +#include "axiom-c-macros.h" + +#include <string.h> +#include <math.h> +#include <stdlib.h> + +#include "header.h" +#include "draw.h" +#include "volume.h" +#include "mode.h" /* for #define components */ + +#include "spadcolors.H1" +#include "Gfun.H1" +#include "util.H1" +#include "XSpadFill.H1" +#include "all_3d.H1" + +#define SAFE_VALUE 892347 + + + + + + +char +#ifdef _NO_PROTO +get_cBuffer_axes(ix) + int ix; +#else +get_cBuffer_axes(int ix) +#endif +{ + if( ix >=0 && ix <ARRAY_WIDTH) return (cBuffer[ix].axes); + return ('0'); +} + +void +#ifdef _NO_PROTO +put_cBuffer_axes(ix,val) + int ix; + char val; +#else +put_cBuffer_axes(int ix,char val) +#endif +{ + if( ix >=0 && ix <ARRAY_WIDTH) cBuffer[ix].axes = val; +} + +int +#ifdef _NO_PROTO +get_cBuffer_indx(ix) + int ix; +#else +get_cBuffer_indx(int ix) +#endif +{ + if( ix >=0 && ix <ARRAY_WIDTH) return (cBuffer[ix].indx); + return (-1); +} + +void +#ifdef _NO_PROTO +put_cBuffer_indx(ix,val) + int ix; + int val; +#else +put_cBuffer_indx(int ix,int val) +#endif +{ + if( ix >=0 && ix <ARRAY_WIDTH) cBuffer[ix].indx = val; +} + +void +#ifdef _NO_PROTO +put_zBuffer(ix,val) + int ix; + float val; +#else +put_zBuffer(int ix,float val) +#endif +{ + if (ix >=0 && ix <ARRAY_WIDTH) zBuffer[ix] = val; +} + +float +#ifdef _NO_PROTO +get_zBuffer(ix) + int ix; +#else +get_zBuffer(int ix) +#endif +{ + return (zBuffer[ix]); +} + +void +#ifdef _NO_PROTO +put_imageX(ix,val) + int ix; + char val; +#else +put_imageX(int ix,char val) +#endif +{ + if (ix <=0 && ix <vwInfo.width) imageX->data[ix] = val; +} + + + + +/*************************** + * void drawPhongSpan() * + * * + * This routine sets the * + * buffer values for each * + * span of pixels which * + * intersect the current * + * scanline. * + ***************************/ +void +#ifdef _NO_PROTO +drawPhongSpan(pt,N,dFlag) + triple pt; + float N[3]; + int dFlag; +#else +drawPhongSpan(triple pt,float N[3],int dFlag) +#endif +{ + int xpixel,hue,shade; + float colorindx, col; + triple hs; + + + /* negative values of xleft and xright have been pushed to machine0 */ + + xpixel = (int)xleft; + + + while (xpixel <= (int)xright) { + /* if z is closer to viewer than value in zBuffer continue */ + if ( (zC < get_zBuffer(xpixel)) ) { + /* get the intensity for current point */ + col = phong(pt,N); + put_cBuffer_axes(xpixel,'0'); + put_zBuffer(xpixel,zC); + /* if mono (bw dsply) do black and white semi-random dithering */ + if (mono || (dFlag == PSoption) || viewport->monoOn) { + if (get_random() < 100.0*exp((double)-1.3*(pi_sq*(col-.2)*(col-.2)))) { + put_cBuffer_indx(xpixel,black); + } else { + put_cBuffer_indx(xpixel,white); + } + } else { + /* glossy shading for one hue else dithered for many hues */ + if (viewport->hueOffset == viewport->hueTop && !smoothError) { + colorindx = (float)(smoothConst+1) * col; + if (colorindx > (smoothConst+1)) colorindx = smoothConst+1; + put_cBuffer_indx(xpixel,XPixelColor((int)colorindx-1)); + } else { /* probabalistic multi-hued dithering */ + hs = norm_dist(); + hue = (int)(intersectColor[0]+hs.x/20.0); + /* cannot dither out of color map range */ + if (viewport->hueOffset < viewport->hueTop) { + if (hue < viewport->hueOffset) + hue = viewport->hueOffset; + else { + if (hue > viewport->hueTop) + hue = viewport->hueTop; + } + } else { + if (hue < viewport->hueTop) + hue = viewport->hueTop; + else { + if (hue > viewport->hueOffset) + hue = viewport->hueOffset; + } + } + col += hs.y/6.0; /* perturb intensity */ + if (col > 1.0) put_cBuffer_indx(xpixel,white); + else { + if (col < 0.0) put_cBuffer_indx(xpixel,black); + else { + shade = (int)(col * 4.0); + put_cBuffer_indx(xpixel,XSolidColor(hue,shade)); + } + } + } + } + } /* zC < zBuffer */ + zC += dzdx; + if (viewport->hueOffset != viewport->hueTop || smoothError || + viewport->monoOn) + intersectColor[0] += dcolor; + N[0] += dnorm.x; N[1] += dnorm.y; N[2] += dnorm.z; + pt.x += dpt.x; pt.y += dpt.y; pt.z += dpt.z; + xpixel++; + } /* while each pixel */ + +} + + +/*************************** + * void scanPhong() * + * * + * This routine takes all * + * polygons that intersect * + * with the current scan- * + * line and calculates the * + * intersecting x and z * + * points as well as the * + * color at each point. * + * Interpolation is done * + * according to Phong. * + ***************************/ + +void +#ifdef _NO_PROTO +scanPhong(dFlag) + int dFlag; +#else +scanPhong(int dFlag) +#endif +{ + viewTriple *p1, *p2; + polyList *polygon; + poly *p; + int i,num,xtemp,numttt; + int *anIndex, *start, *end; + float x1,x2,y1,y2,z2,zright,wx1,wx2,wy1,wy2,wz1,wz2; + float intersectionx[2], intersectionz[2]; + float c1,c2,colortemp,ztemp,dY,diffy,diffx,n1[3],n2[3],NV[3]; + triple ntemp, intersectPt[2], ptemp, pt, intersectN[2]; + + /* polygon list intersecting the current scanline, will be modified to + edge list structure */ + polygon = scanList[scanline]; + while (polygon != NIL(polyList) && polygon->polyIndx != NIL(poly) ) { + /* for each polygon in the list */ + p = polygon->polyIndx; + /* don't include clipped polygons */ + if ( ! ( p->partialClipPz || + p->totalClipPz || + (viewData.clipStuff && (p->partialClip || p->totalClip ) ) ) ) { + num = 0; /* 0 & 1, for the 2 edges of polygon that intersect scanline */ + numttt =0; + + if ((scanline >= (int)p->pymin) && (scanline <= (int)p->pymax)) { + /* which edges of the polygon intersect the scanline */ + for (i=0, anIndex=p->indexPtr; i<p->numpts; i++) { + start = anIndex + i; + p1 = refPt3D(viewData,*(start)); + x1 = p1->px; y1 = p1->py; zC = p1->pz; c1 = p1->sc; +/* if (x1 < machine0){ x1 = machine0; } */ + wx1 = p1->wx; wy1 = p1->wy; wz1 = p1->wz; + n1[0] = p1->norm[0]; n1[1] = p1->norm[1]; n1[2] = p1->norm[2]; + end = (i != (p->numpts - 1)) ? anIndex + (i + 1) : anIndex; + p2 = refPt3D(viewData,*(end)); + x2 = p2->px; y2 = p2->py; z2 = p2->pz; c2 = p2->sc; +/* if (x2 < machine0){ x2 = machine0; } */ + wx2 = p2->wx; wy2 = p2->wy; wz2 = p2->wz; + n2[0] = p2->norm[0]; n2[1] = p2->norm[1]; n2[2] = p2->norm[2]; + /* find beginning and end for intersecting edge */ + if ((scanline < y1 && scanline >= y2) || + (scanline >= y1 && scanline < y2)) { + dY = (float)scanline - y1; + diffy = y2 - y1; + if (absolute(diffy) < 0.01) diffy = 1.0; + intersectionx[num] = x1 + ((x2-x1)/diffy) * dY; + intersectionz[num] = zC + ((z2-zC)/diffy) * dY; + if (viewport->hueOffset != viewport->hueTop || smoothError || + viewport->monoOn) + intersectColor[num] = c1 + ((c2 - c1)/diffy) * dY; + intersectN[num].x = n1[0] + ((n2[0] - n1[0])/diffy)*dY; + intersectN[num].y = n1[1] + ((n2[1] - n1[1])/diffy)*dY; + intersectN[num].z = n1[2] + ((n2[2] - n1[2])/diffy)*dY; + intersectPt[num].x = wx1 + ((wx2 - wx1)/diffy)*dY; + intersectPt[num].y = wy1 + ((wy2 - wy1)/diffy)*dY; + intersectPt[num].z = wz1 + ((wz2 - wz1)/diffy)*dY; + num = 1-num; + numttt++; + } /* if edge intersects scanline */ + } /* for each edge */ + if (numttt>=2) { /* if numttt 0 or 1 something has gone wrong */ + xleft = intersectionx[0]; xright = intersectionx[1]; + zC = intersectionz[0]; zright = intersectionz[1]; + /* edges are drawn from left to right, so switch if necessary */ + if (xright < xleft) { + xtemp = xright; xright = xleft; xleft = xtemp; + ztemp = zright; zright = zC; zC = ztemp; + if (viewport->hueOffset != viewport->hueTop || smoothError || + viewport->monoOn) { + colortemp = intersectColor[1]; + intersectColor[1] = intersectColor[0]; + intersectColor[0] = colortemp; + } + ntemp = intersectN[1]; intersectN[1] = intersectN[0]; + intersectN[0] = ntemp; + ptemp = intersectPt[1]; + intersectPt[1] = intersectPt[0]; + intersectPt[0] = ptemp; + } + diffx = xright - xleft; + if (absolute(diffx) > .01) { + if (viewport->hueOffset != viewport->hueTop || smoothError || + viewport->monoOn) + dcolor = (intersectColor[1] - intersectColor[0]) / diffx; + dnorm.x = (intersectN[1].x - intersectN[0].x) / diffx; + dnorm.y = (intersectN[1].y - intersectN[0].y) / diffx; + dnorm.z = (intersectN[1].z - intersectN[0].z) / diffx; + dpt.x = (intersectPt[1].x - intersectPt[0].x) / diffx; + dpt.y = (intersectPt[1].y - intersectPt[0].y) / diffx; + dpt.z = (intersectPt[1].z - intersectPt[0].z) / diffx; + dzdx = (zright - zC) / diffx; + } else { + if (viewport->hueOffset != viewport->hueTop || smoothError || + viewport->monoOn) + dcolor = intersectColor[1]; + dnorm.x = 0.0; dnorm.y = 0.0; dnorm.z = 0.0; + dpt.x = 0.0; dpt.y = 0.0; dpt.z = 0.0; + dzdx = 0.0; + } + NV[0] = intersectN[0].x; + NV[1] = intersectN[0].y; + NV[2] = intersectN[0].z; + pt.x = intersectPt[0].x; + pt.y = intersectPt[0].y; + pt.z = intersectPt[0].z; + drawPhongSpan(pt,NV,dFlag); + } /* numttt guard */ + } /* if scanline intersect */ + } /* clipped */ + polygon = polygon->next; + } /* while still polygons */ + +} + +/******************************************** + * boxTObuffer() writes the projection of * + * the x,y bounding box to the z-buffer. * + ********************************************/ + +void +#ifdef _NO_PROTO +boxTObuffer() +#else +boxTObuffer(void) +#endif +{ + int xpix,i,j,k,count,decision; + int xA,xB,yA,yB; + float x,xend,y,yend,diffy,dX,dY,dXY,intersectionx; + + for (i=0;i<6;i++) { + if (box[i].inside) { + for (j=0; j<3; j++) { + quadMesh[j].x = box[i].pointsPtr[j]->px; + quadMesh[j].y = box[i].pointsPtr[j]->py; + } + + intersectionx = 0.0; + for (k=0; k<2; k++) { + xA = quadMesh[k].x; yA = quadMesh[k].y; + xB = quadMesh[k+1].x; yB = quadMesh[k+1].y; + +/* + if (xA > graphWindowAttrib.width+1) xA = graphWindowAttrib.width+1; + if (xB > graphWindowAttrib.width+1) xB = graphWindowAttrib.width+1; + if (yA > graphWindowAttrib.height) yA = graphWindowAttrib.height; + if (yB > graphWindowAttrib.height) yB = graphWindowAttrib.height; + if (xA < 0) xA = 0; if (xB < 0) xB = 0; + if (yA < 0) yA = 0; if (yB < 0) yB = 0; +*/ + x = xA; xend = xB; y = yA; yend = yB; + diffy = (float)scanline - y; + dX = xend - x; dY = yend - y; + if (absolute(dY) > machine0) { + dXY = dX/dY; + } else { + dXY = dX; + } + + if (dXY < 0.0) dXY = -dXY; + + if ((scanline == (int)y) && (absolute(dY) <= 1.0)) { + if (x <= xend) { + for (xpix = (int)x; xpix <= (int)xend; xpix++) { + put_cBuffer_axes(xpix,'b'); + } + } else { + for (xpix = (int)x; xpix >= (int)xend; xpix--) { + put_cBuffer_axes(xpix,'b'); + } + } + } else { + if (xend < x) + decision = (scanline < y && scanline >= yend) || + (scanline > y && scanline <= yend); + else + decision = (scanline <= y && scanline > yend) || + (scanline >= y && scanline < yend); + if (decision) { + intersectionx = x + dX/dY * diffy; + for (count = (int)intersectionx; + count <= (int)intersectionx + (int)dXY; count++) { + put_cBuffer_axes(count,'b'); + } + } + } + } + + } + } + +} + +/******************************************** + * clipboxTObuffer() writes the projection * + * of the x,y,z clipping region box to the * + * z-buffer. * + ********************************************/ + +void +#ifdef _NO_PROTO +clipboxTObuffer() +#else +clipboxTObuffer(void) +#endif +{ + int xpix,i,j,k,count,decision; + int xA,xB,yA,yB; + float x,xend,y,yend,diffy,dX,dY,dXY,intersectionx; + + for (i=0;i<6;i++) { + if (clipBox[i].inside) { + for (j=0; j<3; j++) { + quadMesh[j].x = clipBox[i].pointsPtr[j]->px; + quadMesh[j].y = clipBox[i].pointsPtr[j]->py; + } + + intersectionx = 0.0; + for (k=0; k<2; k++) { + xA = quadMesh[k].x; yA = quadMesh[k].y; + xB = quadMesh[k+1].x; yB = quadMesh[k+1].y; +/* + + if (xA > graphWindowAttrib.width+1) xA = graphWindowAttrib.width+1; + if (xB > graphWindowAttrib.width+1) xB = graphWindowAttrib.width+1; + if (yA > graphWindowAttrib.height) yA = graphWindowAttrib.height; + if (yB > graphWindowAttrib.height) yB = graphWindowAttrib.height; + if (xA < 0) xA = 0; if (xB < 0) xB = 0; + if (yA < 0) yA = 0; if (yB < 0) yB = 0; +*/ + x = xA; xend = xB; y = yA; yend = yB; + diffy = (float)scanline - y; + dX = xend - x; dY = yend - y; + if (absolute(dY) > machine0) { + dXY = dX/dY; + } else { + dXY = dX; + } + if (dXY < 0.0) dXY = -dXY; + + if ((scanline == (int)y) && (absolute(dY) <= 1.0)) { + if (x <= xend) { + for (xpix = (int)x; xpix <= (int)xend; xpix++) { + put_cBuffer_axes(xpix,'c'); + } + } else { + for (xpix = (int)x; xpix >= (int)xend; xpix--) { + put_cBuffer_axes(xpix,'c'); + } + } + } else { + if (xend < x) + decision = (scanline < y && scanline >= yend) || + (scanline > y && scanline <= yend); + else + decision = (scanline <= y && scanline > yend) || + (scanline >= y && scanline < yend); + if (decision) { + intersectionx = x + dX/dY * diffy; + for (count = (int)intersectionx; + count <= (int)intersectionx + (int)dXY; count++) { + put_cBuffer_axes(count,'c'); + } + } + } + } + + } + } + +} + + + +/******************************************** + * axesTObuffer() writes the projection of * + * the x,y,z axes to the z-buffer. * + ********************************************/ + +void +#ifdef _NO_PROTO +axesTObuffer() +#else +axesTObuffer(void) +#endif +{ + int xpix,i,count,decision; + int xA,xB,yA,yB; + float x,xend,y,yend,diffy,dX,dY,dXY,intersectionx; + float zA,zB,z,zend; + float dZ,dZX,dZY,intersectionz; + + intersectionz = 0.0; intersectionx = 0.0; + for (i=0; i<3; i++) { + xA = axesXY[i][0]; yA = axesXY[i][1]; zA = axesZ[i][0]; + xB = axesXY[i][2]; yB = axesXY[i][3]; zB = axesZ[i][1]; +/* + if (xA > graphWindowAttrib.width+1) xA = graphWindowAttrib.width+1; + if (xB > graphWindowAttrib.width+1) xB = graphWindowAttrib.width+1; + if (yA > graphWindowAttrib.height) yA = graphWindowAttrib.height; + if (yB > graphWindowAttrib.height) yB = graphWindowAttrib.height; + if (xA < 0) xA = 0; if (xB < 0) xB = 0; + if (yA < 0) yA = 0; if (yB < 0) yB = 0; +*/ + x = xA; xend = xB; y = yA; yend = yB; z = zA; zend = zB; + diffy = (float)scanline - y; + dX = xend - x; dY = yend - y; dZ = zend - z; + dZY = dZ/dY; + dXY = dX/dY; + if (dXY < 0.0) dXY = -dXY; + dZX = dZ/dX; + + if ((scanline == (int)y) && (absolute(dY) <= 1.0)) { + if (x <= xend) { + for (xpix = (int)x; xpix <= (int)xend; xpix++) { + put_cBuffer_axes(xpix,'a'); + put_zBuffer(xpix,z + dZY * diffy); + } /* for x */ + } else { + for (xpix = (int)x; xpix >= (int)xend; xpix--) { + put_cBuffer_axes(xpix,'a'); + put_zBuffer(xpix,z + dZY * diffy); + } /* for x */ + } + } else { + if (xend < x) + decision = (scanline < y && scanline >= yend) || + (scanline > y && scanline <= yend); + else + decision = (scanline <= y && scanline > yend) || + (scanline >= y && scanline < yend); + if (decision) { + intersectionx = x + dX/dY * diffy; + intersectionz = z + dZY * diffy; + for (count = (int)intersectionx; + count <= (int)intersectionx + (int)dXY; count++) { + put_cBuffer_axes(count,'a'); + put_zBuffer(count,intersectionz); + intersectionz += dZX; + } + } /* if edge intersects scanline */ + } + } /* for each axes */ + +} + +/******************************************** + * scanLines() scanline z-buffer algorithm * + * initialize z-buffer and color buffer for * + * all scanlines. * + ********************************************/ + +void +#ifdef _NO_PROTO +scanLines(dFlag) + int dFlag; +#else +scanLines(int dFlag) +#endif +{ + 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 freePolyList(); * + * * + * frees up the global scanList l-l * + *************************************/ + +void +#ifdef _NO_PROTO +freePolyList () +#else +freePolyList (void) +#endif +{ + polyList *P, *nextP; + int i; + + for (i = 0; (i < ARRAY_HEIGHT); i++) { + P = scanList[i]; + while((P != NIL(polyList))) { + nextP = P->next; + free(P); + P = nextP; + } + } + +} /* freePolyList() */ + + +/******************************************** + * showAxesLabels() writes the axes labels * + * onto the viewmap of a graph. * + ********************************************/ + +void +#ifdef _NO_PROTO +showAxesLabels(dFlag) + int dFlag; +#else +showAxesLabels(int dFlag) +#endif +{ + 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][2]) { + 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); + } + } +} + + + +/******************************************** + * changeColorMap() modifies the color map * + * for moving in and out of smooth shading. * + ********************************************/ + +void +#ifdef _NO_PROTO +changeColorMap() +#else +changeColorMap(void) +#endif +{ + int okay, i, hue, *index; + poly *cp; + viewTriple *pt; + + strcpy(control->message," Make New Color Map "); + writeControlMessage(); + if ((viewport->hueOffset == viewport->hueTop) && + !mono && !viewport->monoOn) { + + /* colormap is not an even distribution across spectrum */ + /* see spadcolors.c code to understand why this is done */ + + if (viewport->hueTop < 11) smoothHue = viewport->hueTop * 6; + else + if (viewport->hueTop > 10 && viewport->hueTop < 16) { + smoothHue = viewport->hueTop*20 - 140; + } + else { + smoothHue = viewport->hueTop*12 - 12; + } + + if (redoColor) { + /* reallocate colormap for new hue */ + redoColor = no; + if (pixelSetFlag) { + FreePixels(dsply,colorMap,smoothConst+1); + } + okay = makeNewColorMap(dsply,colorMap,smoothHue); + if (okay) { + pixelSetFlag = yes; + smoothError = no; } + else { + pixelSetFlag = no; + smoothError = yes; } + } /* if redoColor */ + } else { + redoDither = no; + if (pixelSetFlag && !mono) { + FreePixels(dsply,colorMap,smoothConst); + pixelSetFlag = no; + redoColor = no; + multiColorFlag = yes; + } + if (!mono && !viewport->monoOn) { + cp = quickList; + while (cp != NIL(poly) && keepDrawingViewport()) { + for (i = 0, index = cp->indexPtr; + i < cp->numpts; i++, index++) { + pt = refPt3D(viewData,*(index)); + /* get hue for each point if multi-dithering is used */ + if (absolute(cp->color) > 1.0) + hue = floor(absolute(cp->color)); + else + hue = floor(absolute(cp->color) * viewport->numberOfHues) + + viewport->hueOffset; + pt->sc = (float)hue; + } /* for each point in polygon */ + cp = cp->next; + } + } /* multi-color dither */ + } /* else hueOffset != hueTop */ +} + + +/*********************** + * void drawPhong() * + * * + * A general routine * + * for displaying a * + * list of polygons * + * using a simple * + * scanline z-buffer * + * algorithm with * + * phong shading. * + ***********************/ + +void +#ifdef _NO_PROTO +drawPhong(dFlag) + int dFlag; +#else +drawPhong(int dFlag) +#endif +{ + + poly *p, *head; + polyList *s; + int i,j,hue; + int *anIndex, redo; + viewTriple *aPoint, *polyPt; + + redo = (recalc || redoSmooth); + if (redo || redoColor || redoDither) { + rotated = no; zoomed = no; translated = no; + switchedPerspective = no; changedEyeDistance = no; + redoSmooth = no; movingLight = no; + + /* If only a color change don't recalculate polygon info. */ + if (!redo) { + /* glossy shading if a single hue is indicated */ + changeColorMap(); + scanLines(dFlag); + /* if axes are on then show axes labels */ + if (viewport->axesOn) showAxesLabels(dFlag); + + /* show pixmap of image */ + XCopyArea(dsply,viewmap,viewport->viewWindow,trashGC,0,0, + vwInfo.width,vwInfo.height,0,0); + } else { + if (keepDrawingViewport()) { + if (!firstTime && !(scanline > 0)) { + strcpy(control->message," Freeing Polygons "); + writeControlMessage(); + freeListOfPolygons(quickList); + freePointResevoir(); + } + if (keepDrawingViewport()) { + strcpy(control->message," Collecting Polygons "); + writeControlMessage(); + quickList = copyPolygons(viewData.polygons); + + if (keepDrawingViewport()) { + strcpy(control->message," Projecting Polygons "); + writeControlMessage(); + projectAllPolys(quickList); + if (keepDrawingViewport()) { + strcpy(control->message, + " Setting Polygon Extremes "); + writeControlMessage(); + minMaxPolygons(quickList); + if (keepDrawingViewport()) { + strcpy(control->message, + " Sorting Polygons "); + writeControlMessage(); + quickList = msort(quickList,0,viewData.numPolygons, + polyCompare); + calcEyePoint(); + head = p = quickList; + + /* glossy shading if a single hue is indicated */ + changeColorMap(); + + for (i=0, aPoint=viewData.points; + i<viewData.numOfPoints; i++,aPoint++) { + aPoint->norm[0]= 0.0; + aPoint->norm[1]= 0.0; + aPoint->norm[2]= 0.0; + } + freePolyList(); + for (i = 0; i < ARRAY_HEIGHT; i++) + scanList[i] = NIL(polyList); + /* for each polygon */ + /* calculate average normal for each vertex */ + strcpy(control->message, + " Build Polygon Lists "); + writeControlMessage(); + p = head; + while ((p != NIL(poly)) && keepDrawingViewport()) { + + for (j = 0, anIndex = p->indexPtr; + j < p->numpts; j++, anIndex++) { + polyPt = refPt3D(viewData,*(anIndex)); + polyPt->norm[0] += p->N[0]; + polyPt->norm[1] += p->N[1]; + polyPt->norm[2] += p->N[2]; + normalizeVector(polyPt->norm); + /* get hue for each point if multi-dithering is used */ + if ((viewport->hueOffset != viewport->hueTop || + smoothError) && !mono) { + if (absolute(p->color) > 1.0) { + hue = floor(absolute(p->color)); + } else { + hue = floor(absolute(p->color) * + viewport->numberOfHues) + + viewport->hueOffset; + } + polyPt->sc = (float)hue; + } /* multi-color dither */ + } /* for each point in polygon */ + + if ( ! ( p->partialClipPz || + p->totalClipPz || + (viewData.clipStuff && (p->partialClip || p->totalClip ) ) ) ) { + /* put polygon in each scanline list it intersects */ + for (i=(int)p->pymin; i<= (int)p->pymax; i++) { + if ( (i>=0) && (i<ARRAY_HEIGHT ) ){ + s = (polyList *)saymem("smoothShade.c",1,sizeof(polyList)); + s->polyIndx = p; + s->next = scanList[i]; + scanList[i] = s; + } + } /* put polygon in each scanline it intersects */ + } /* if polygon not clipped */ + p = p->next; + } /* while still polygons */ + + scanLines(dFlag); + + /* if axes are on then show axes labels */ + if (viewport->axesOn) showAxesLabels(dFlag); + + /* show pixmap of image */ + XCopyArea(dsply,viewmap,viewport->viewWindow,trashGC,0,0, + vwInfo.width,vwInfo.height,0,0); + /* freePolyList(scanList); */ + + } /* keepDrawingViewport() after setting extreme values */ + } /* keepDrawingViewport() after projecting all polygons */ + } /* keepDrawingViewport() after collecting polygons */ + } /* keepDrawingViewport() after freeing polygons */ + } /* keepDrawingViewport() after recalc */ + finishedList = !(scanline>0); + if (firstTime) firstTime = no; + } /* not only a color change */ + + } else { /* else just redisplay current pixmap of image */ + XCopyArea(dsply,viewmap,viewport->viewWindow,trashGC,0,0, + vwInfo.width,vwInfo.height,0,0); + } + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + +} /* drawPhong */ + + + + + + + + + + diff --git a/src/graph/view3D/smoothShade3d.c.pamphlet b/src/graph/view3D/smoothShade3d.c.pamphlet deleted file mode 100644 index 1d5f7986..00000000 --- a/src/graph/view3D/smoothShade3d.c.pamphlet +++ /dev/null @@ -1,1142 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D smoothShade3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _SMOOTHSHADE_C -#include "axiom-c-macros.h" - -#include <string.h> -#include <math.h> -#include <stdlib.h> - -#include "header.h" -#include "draw.h" -#include "volume.h" -#include "mode.h" /* for #define components */ - -#include "spadcolors.H1" -#include "Gfun.H1" -#include "util.H1" -#include "XSpadFill.H1" -#include "all_3d.H1" - -#define SAFE_VALUE 892347 - - - - - - -char -#ifdef _NO_PROTO -get_cBuffer_axes(ix) - int ix; -#else -get_cBuffer_axes(int ix) -#endif -{ - if( ix >=0 && ix <ARRAY_WIDTH) return (cBuffer[ix].axes); - return ('0'); -} - -void -#ifdef _NO_PROTO -put_cBuffer_axes(ix,val) - int ix; - char val; -#else -put_cBuffer_axes(int ix,char val) -#endif -{ - if( ix >=0 && ix <ARRAY_WIDTH) cBuffer[ix].axes = val; -} - -int -#ifdef _NO_PROTO -get_cBuffer_indx(ix) - int ix; -#else -get_cBuffer_indx(int ix) -#endif -{ - if( ix >=0 && ix <ARRAY_WIDTH) return (cBuffer[ix].indx); - return (-1); -} - -void -#ifdef _NO_PROTO -put_cBuffer_indx(ix,val) - int ix; - int val; -#else -put_cBuffer_indx(int ix,int val) -#endif -{ - if( ix >=0 && ix <ARRAY_WIDTH) cBuffer[ix].indx = val; -} - -void -#ifdef _NO_PROTO -put_zBuffer(ix,val) - int ix; - float val; -#else -put_zBuffer(int ix,float val) -#endif -{ - if (ix >=0 && ix <ARRAY_WIDTH) zBuffer[ix] = val; -} - -float -#ifdef _NO_PROTO -get_zBuffer(ix) - int ix; -#else -get_zBuffer(int ix) -#endif -{ - return (zBuffer[ix]); -} - -void -#ifdef _NO_PROTO -put_imageX(ix,val) - int ix; - char val; -#else -put_imageX(int ix,char val) -#endif -{ - if (ix <=0 && ix <vwInfo.width) imageX->data[ix] = val; -} - - - - -/*************************** - * void drawPhongSpan() * - * * - * This routine sets the * - * buffer values for each * - * span of pixels which * - * intersect the current * - * scanline. * - ***************************/ -void -#ifdef _NO_PROTO -drawPhongSpan(pt,N,dFlag) - triple pt; - float N[3]; - int dFlag; -#else -drawPhongSpan(triple pt,float N[3],int dFlag) -#endif -{ - int xpixel,hue,shade; - float colorindx, col; - triple hs; - - - /* negative values of xleft and xright have been pushed to machine0 */ - - xpixel = (int)xleft; - - - while (xpixel <= (int)xright) { - /* if z is closer to viewer than value in zBuffer continue */ - if ( (zC < get_zBuffer(xpixel)) ) { - /* get the intensity for current point */ - col = phong(pt,N); - put_cBuffer_axes(xpixel,'0'); - put_zBuffer(xpixel,zC); - /* if mono (bw dsply) do black and white semi-random dithering */ - if (mono || (dFlag == PSoption) || viewport->monoOn) { - if (get_random() < 100.0*exp((double)-1.3*(pi_sq*(col-.2)*(col-.2)))) { - put_cBuffer_indx(xpixel,black); - } else { - put_cBuffer_indx(xpixel,white); - } - } else { - /* glossy shading for one hue else dithered for many hues */ - if (viewport->hueOffset == viewport->hueTop && !smoothError) { - colorindx = (float)(smoothConst+1) * col; - if (colorindx > (smoothConst+1)) colorindx = smoothConst+1; - put_cBuffer_indx(xpixel,XPixelColor((int)colorindx-1)); - } else { /* probabalistic multi-hued dithering */ - hs = norm_dist(); - hue = (int)(intersectColor[0]+hs.x/20.0); - /* cannot dither out of color map range */ - if (viewport->hueOffset < viewport->hueTop) { - if (hue < viewport->hueOffset) - hue = viewport->hueOffset; - else { - if (hue > viewport->hueTop) - hue = viewport->hueTop; - } - } else { - if (hue < viewport->hueTop) - hue = viewport->hueTop; - else { - if (hue > viewport->hueOffset) - hue = viewport->hueOffset; - } - } - col += hs.y/6.0; /* perturb intensity */ - if (col > 1.0) put_cBuffer_indx(xpixel,white); - else { - if (col < 0.0) put_cBuffer_indx(xpixel,black); - else { - shade = (int)(col * 4.0); - put_cBuffer_indx(xpixel,XSolidColor(hue,shade)); - } - } - } - } - } /* zC < zBuffer */ - zC += dzdx; - if (viewport->hueOffset != viewport->hueTop || smoothError || - viewport->monoOn) - intersectColor[0] += dcolor; - N[0] += dnorm.x; N[1] += dnorm.y; N[2] += dnorm.z; - pt.x += dpt.x; pt.y += dpt.y; pt.z += dpt.z; - xpixel++; - } /* while each pixel */ - -} - - -/*************************** - * void scanPhong() * - * * - * This routine takes all * - * polygons that intersect * - * with the current scan- * - * line and calculates the * - * intersecting x and z * - * points as well as the * - * color at each point. * - * Interpolation is done * - * according to Phong. * - ***************************/ - -void -#ifdef _NO_PROTO -scanPhong(dFlag) - int dFlag; -#else -scanPhong(int dFlag) -#endif -{ - viewTriple *p1, *p2; - polyList *polygon; - poly *p; - int i,num,xtemp,numttt; - int *anIndex, *start, *end; - float x1,x2,y1,y2,z2,zright,wx1,wx2,wy1,wy2,wz1,wz2; - float intersectionx[2], intersectionz[2]; - float c1,c2,colortemp,ztemp,dY,diffy,diffx,n1[3],n2[3],NV[3]; - triple ntemp, intersectPt[2], ptemp, pt, intersectN[2]; - - /* polygon list intersecting the current scanline, will be modified to - edge list structure */ - polygon = scanList[scanline]; - while (polygon != NIL(polyList) && polygon->polyIndx != NIL(poly) ) { - /* for each polygon in the list */ - p = polygon->polyIndx; - /* don't include clipped polygons */ - if ( ! ( p->partialClipPz || - p->totalClipPz || - (viewData.clipStuff && (p->partialClip || p->totalClip ) ) ) ) { - num = 0; /* 0 & 1, for the 2 edges of polygon that intersect scanline */ - numttt =0; - - if ((scanline >= (int)p->pymin) && (scanline <= (int)p->pymax)) { - /* which edges of the polygon intersect the scanline */ - for (i=0, anIndex=p->indexPtr; i<p->numpts; i++) { - start = anIndex + i; - p1 = refPt3D(viewData,*(start)); - x1 = p1->px; y1 = p1->py; zC = p1->pz; c1 = p1->sc; -/* if (x1 < machine0){ x1 = machine0; } */ - wx1 = p1->wx; wy1 = p1->wy; wz1 = p1->wz; - n1[0] = p1->norm[0]; n1[1] = p1->norm[1]; n1[2] = p1->norm[2]; - end = (i != (p->numpts - 1)) ? anIndex + (i + 1) : anIndex; - p2 = refPt3D(viewData,*(end)); - x2 = p2->px; y2 = p2->py; z2 = p2->pz; c2 = p2->sc; -/* if (x2 < machine0){ x2 = machine0; } */ - wx2 = p2->wx; wy2 = p2->wy; wz2 = p2->wz; - n2[0] = p2->norm[0]; n2[1] = p2->norm[1]; n2[2] = p2->norm[2]; - /* find beginning and end for intersecting edge */ - if ((scanline < y1 && scanline >= y2) || - (scanline >= y1 && scanline < y2)) { - dY = (float)scanline - y1; - diffy = y2 - y1; - if (absolute(diffy) < 0.01) diffy = 1.0; - intersectionx[num] = x1 + ((x2-x1)/diffy) * dY; - intersectionz[num] = zC + ((z2-zC)/diffy) * dY; - if (viewport->hueOffset != viewport->hueTop || smoothError || - viewport->monoOn) - intersectColor[num] = c1 + ((c2 - c1)/diffy) * dY; - intersectN[num].x = n1[0] + ((n2[0] - n1[0])/diffy)*dY; - intersectN[num].y = n1[1] + ((n2[1] - n1[1])/diffy)*dY; - intersectN[num].z = n1[2] + ((n2[2] - n1[2])/diffy)*dY; - intersectPt[num].x = wx1 + ((wx2 - wx1)/diffy)*dY; - intersectPt[num].y = wy1 + ((wy2 - wy1)/diffy)*dY; - intersectPt[num].z = wz1 + ((wz2 - wz1)/diffy)*dY; - num = 1-num; - numttt++; - } /* if edge intersects scanline */ - } /* for each edge */ - if (numttt>=2) { /* if numttt 0 or 1 something has gone wrong */ - xleft = intersectionx[0]; xright = intersectionx[1]; - zC = intersectionz[0]; zright = intersectionz[1]; - /* edges are drawn from left to right, so switch if necessary */ - if (xright < xleft) { - xtemp = xright; xright = xleft; xleft = xtemp; - ztemp = zright; zright = zC; zC = ztemp; - if (viewport->hueOffset != viewport->hueTop || smoothError || - viewport->monoOn) { - colortemp = intersectColor[1]; - intersectColor[1] = intersectColor[0]; - intersectColor[0] = colortemp; - } - ntemp = intersectN[1]; intersectN[1] = intersectN[0]; - intersectN[0] = ntemp; - ptemp = intersectPt[1]; - intersectPt[1] = intersectPt[0]; - intersectPt[0] = ptemp; - } - diffx = xright - xleft; - if (absolute(diffx) > .01) { - if (viewport->hueOffset != viewport->hueTop || smoothError || - viewport->monoOn) - dcolor = (intersectColor[1] - intersectColor[0]) / diffx; - dnorm.x = (intersectN[1].x - intersectN[0].x) / diffx; - dnorm.y = (intersectN[1].y - intersectN[0].y) / diffx; - dnorm.z = (intersectN[1].z - intersectN[0].z) / diffx; - dpt.x = (intersectPt[1].x - intersectPt[0].x) / diffx; - dpt.y = (intersectPt[1].y - intersectPt[0].y) / diffx; - dpt.z = (intersectPt[1].z - intersectPt[0].z) / diffx; - dzdx = (zright - zC) / diffx; - } else { - if (viewport->hueOffset != viewport->hueTop || smoothError || - viewport->monoOn) - dcolor = intersectColor[1]; - dnorm.x = 0.0; dnorm.y = 0.0; dnorm.z = 0.0; - dpt.x = 0.0; dpt.y = 0.0; dpt.z = 0.0; - dzdx = 0.0; - } - NV[0] = intersectN[0].x; - NV[1] = intersectN[0].y; - NV[2] = intersectN[0].z; - pt.x = intersectPt[0].x; - pt.y = intersectPt[0].y; - pt.z = intersectPt[0].z; - drawPhongSpan(pt,NV,dFlag); - } /* numttt guard */ - } /* if scanline intersect */ - } /* clipped */ - polygon = polygon->next; - } /* while still polygons */ - -} - -/******************************************** - * boxTObuffer() writes the projection of * - * the x,y bounding box to the z-buffer. * - ********************************************/ - -void -#ifdef _NO_PROTO -boxTObuffer() -#else -boxTObuffer(void) -#endif -{ - int xpix,i,j,k,count,decision; - int xA,xB,yA,yB; - float x,xend,y,yend,diffy,dX,dY,dXY,intersectionx; - - for (i=0;i<6;i++) { - if (box[i].inside) { - for (j=0; j<3; j++) { - quadMesh[j].x = box[i].pointsPtr[j]->px; - quadMesh[j].y = box[i].pointsPtr[j]->py; - } - - intersectionx = 0.0; - for (k=0; k<2; k++) { - xA = quadMesh[k].x; yA = quadMesh[k].y; - xB = quadMesh[k+1].x; yB = quadMesh[k+1].y; - -/* - if (xA > graphWindowAttrib.width+1) xA = graphWindowAttrib.width+1; - if (xB > graphWindowAttrib.width+1) xB = graphWindowAttrib.width+1; - if (yA > graphWindowAttrib.height) yA = graphWindowAttrib.height; - if (yB > graphWindowAttrib.height) yB = graphWindowAttrib.height; - if (xA < 0) xA = 0; if (xB < 0) xB = 0; - if (yA < 0) yA = 0; if (yB < 0) yB = 0; -*/ - x = xA; xend = xB; y = yA; yend = yB; - diffy = (float)scanline - y; - dX = xend - x; dY = yend - y; - if (absolute(dY) > machine0) { - dXY = dX/dY; - } else { - dXY = dX; - } - - if (dXY < 0.0) dXY = -dXY; - - if ((scanline == (int)y) && (absolute(dY) <= 1.0)) { - if (x <= xend) { - for (xpix = (int)x; xpix <= (int)xend; xpix++) { - put_cBuffer_axes(xpix,'b'); - } - } else { - for (xpix = (int)x; xpix >= (int)xend; xpix--) { - put_cBuffer_axes(xpix,'b'); - } - } - } else { - if (xend < x) - decision = (scanline < y && scanline >= yend) || - (scanline > y && scanline <= yend); - else - decision = (scanline <= y && scanline > yend) || - (scanline >= y && scanline < yend); - if (decision) { - intersectionx = x + dX/dY * diffy; - for (count = (int)intersectionx; - count <= (int)intersectionx + (int)dXY; count++) { - put_cBuffer_axes(count,'b'); - } - } - } - } - - } - } - -} - -/******************************************** - * clipboxTObuffer() writes the projection * - * of the x,y,z clipping region box to the * - * z-buffer. * - ********************************************/ - -void -#ifdef _NO_PROTO -clipboxTObuffer() -#else -clipboxTObuffer(void) -#endif -{ - int xpix,i,j,k,count,decision; - int xA,xB,yA,yB; - float x,xend,y,yend,diffy,dX,dY,dXY,intersectionx; - - for (i=0;i<6;i++) { - if (clipBox[i].inside) { - for (j=0; j<3; j++) { - quadMesh[j].x = clipBox[i].pointsPtr[j]->px; - quadMesh[j].y = clipBox[i].pointsPtr[j]->py; - } - - intersectionx = 0.0; - for (k=0; k<2; k++) { - xA = quadMesh[k].x; yA = quadMesh[k].y; - xB = quadMesh[k+1].x; yB = quadMesh[k+1].y; -/* - - if (xA > graphWindowAttrib.width+1) xA = graphWindowAttrib.width+1; - if (xB > graphWindowAttrib.width+1) xB = graphWindowAttrib.width+1; - if (yA > graphWindowAttrib.height) yA = graphWindowAttrib.height; - if (yB > graphWindowAttrib.height) yB = graphWindowAttrib.height; - if (xA < 0) xA = 0; if (xB < 0) xB = 0; - if (yA < 0) yA = 0; if (yB < 0) yB = 0; -*/ - x = xA; xend = xB; y = yA; yend = yB; - diffy = (float)scanline - y; - dX = xend - x; dY = yend - y; - if (absolute(dY) > machine0) { - dXY = dX/dY; - } else { - dXY = dX; - } - if (dXY < 0.0) dXY = -dXY; - - if ((scanline == (int)y) && (absolute(dY) <= 1.0)) { - if (x <= xend) { - for (xpix = (int)x; xpix <= (int)xend; xpix++) { - put_cBuffer_axes(xpix,'c'); - } - } else { - for (xpix = (int)x; xpix >= (int)xend; xpix--) { - put_cBuffer_axes(xpix,'c'); - } - } - } else { - if (xend < x) - decision = (scanline < y && scanline >= yend) || - (scanline > y && scanline <= yend); - else - decision = (scanline <= y && scanline > yend) || - (scanline >= y && scanline < yend); - if (decision) { - intersectionx = x + dX/dY * diffy; - for (count = (int)intersectionx; - count <= (int)intersectionx + (int)dXY; count++) { - put_cBuffer_axes(count,'c'); - } - } - } - } - - } - } - -} - - - -/******************************************** - * axesTObuffer() writes the projection of * - * the x,y,z axes to the z-buffer. * - ********************************************/ - -void -#ifdef _NO_PROTO -axesTObuffer() -#else -axesTObuffer(void) -#endif -{ - int xpix,i,count,decision; - int xA,xB,yA,yB; - float x,xend,y,yend,diffy,dX,dY,dXY,intersectionx; - float zA,zB,z,zend; - float dZ,dZX,dZY,intersectionz; - - intersectionz = 0.0; intersectionx = 0.0; - for (i=0; i<3; i++) { - xA = axesXY[i][0]; yA = axesXY[i][1]; zA = axesZ[i][0]; - xB = axesXY[i][2]; yB = axesXY[i][3]; zB = axesZ[i][1]; -/* - if (xA > graphWindowAttrib.width+1) xA = graphWindowAttrib.width+1; - if (xB > graphWindowAttrib.width+1) xB = graphWindowAttrib.width+1; - if (yA > graphWindowAttrib.height) yA = graphWindowAttrib.height; - if (yB > graphWindowAttrib.height) yB = graphWindowAttrib.height; - if (xA < 0) xA = 0; if (xB < 0) xB = 0; - if (yA < 0) yA = 0; if (yB < 0) yB = 0; -*/ - x = xA; xend = xB; y = yA; yend = yB; z = zA; zend = zB; - diffy = (float)scanline - y; - dX = xend - x; dY = yend - y; dZ = zend - z; - dZY = dZ/dY; - dXY = dX/dY; - if (dXY < 0.0) dXY = -dXY; - dZX = dZ/dX; - - if ((scanline == (int)y) && (absolute(dY) <= 1.0)) { - if (x <= xend) { - for (xpix = (int)x; xpix <= (int)xend; xpix++) { - put_cBuffer_axes(xpix,'a'); - put_zBuffer(xpix,z + dZY * diffy); - } /* for x */ - } else { - for (xpix = (int)x; xpix >= (int)xend; xpix--) { - put_cBuffer_axes(xpix,'a'); - put_zBuffer(xpix,z + dZY * diffy); - } /* for x */ - } - } else { - if (xend < x) - decision = (scanline < y && scanline >= yend) || - (scanline > y && scanline <= yend); - else - decision = (scanline <= y && scanline > yend) || - (scanline >= y && scanline < yend); - if (decision) { - intersectionx = x + dX/dY * diffy; - intersectionz = z + dZY * diffy; - for (count = (int)intersectionx; - count <= (int)intersectionx + (int)dXY; count++) { - put_cBuffer_axes(count,'a'); - put_zBuffer(count,intersectionz); - intersectionz += dZX; - } - } /* if edge intersects scanline */ - } - } /* for each axes */ - -} - -/******************************************** - * scanLines() scanline z-buffer algorithm * - * initialize z-buffer and color buffer for * - * all scanlines. * - ********************************************/ - -void -#ifdef _NO_PROTO -scanLines(dFlag) - int dFlag; -#else -scanLines(int dFlag) -#endif -{ - 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 freePolyList(); * - * * - * frees up the global scanList l-l * - *************************************/ - -void -#ifdef _NO_PROTO -freePolyList () -#else -freePolyList (void) -#endif -{ - polyList *P, *nextP; - int i; - - for (i = 0; (i < ARRAY_HEIGHT); i++) { - P = scanList[i]; - while((P != NIL(polyList))) { - nextP = P->next; - free(P); - P = nextP; - } - } - -} /* freePolyList() */ - - -/******************************************** - * showAxesLabels() writes the axes labels * - * onto the viewmap of a graph. * - ********************************************/ - -void -#ifdef _NO_PROTO -showAxesLabels(dFlag) - int dFlag; -#else -showAxesLabels(int dFlag) -#endif -{ - 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][2]) { - 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); - } - } -} - - - -/******************************************** - * changeColorMap() modifies the color map * - * for moving in and out of smooth shading. * - ********************************************/ - -void -#ifdef _NO_PROTO -changeColorMap() -#else -changeColorMap(void) -#endif -{ - int okay, i, hue, *index; - poly *cp; - viewTriple *pt; - - strcpy(control->message," Make New Color Map "); - writeControlMessage(); - if ((viewport->hueOffset == viewport->hueTop) && - !mono && !viewport->monoOn) { - - /* colormap is not an even distribution across spectrum */ - /* see spadcolors.c code to understand why this is done */ - - if (viewport->hueTop < 11) smoothHue = viewport->hueTop * 6; - else - if (viewport->hueTop > 10 && viewport->hueTop < 16) { - smoothHue = viewport->hueTop*20 - 140; - } - else { - smoothHue = viewport->hueTop*12 - 12; - } - - if (redoColor) { - /* reallocate colormap for new hue */ - redoColor = no; - if (pixelSetFlag) { - FreePixels(dsply,colorMap,smoothConst+1); - } - okay = makeNewColorMap(dsply,colorMap,smoothHue); - if (okay) { - pixelSetFlag = yes; - smoothError = no; } - else { - pixelSetFlag = no; - smoothError = yes; } - } /* if redoColor */ - } else { - redoDither = no; - if (pixelSetFlag && !mono) { - FreePixels(dsply,colorMap,smoothConst); - pixelSetFlag = no; - redoColor = no; - multiColorFlag = yes; - } - if (!mono && !viewport->monoOn) { - cp = quickList; - while (cp != NIL(poly) && keepDrawingViewport()) { - for (i = 0, index = cp->indexPtr; - i < cp->numpts; i++, index++) { - pt = refPt3D(viewData,*(index)); - /* get hue for each point if multi-dithering is used */ - if (absolute(cp->color) > 1.0) - hue = floor(absolute(cp->color)); - else - hue = floor(absolute(cp->color) * viewport->numberOfHues) + - viewport->hueOffset; - pt->sc = (float)hue; - } /* for each point in polygon */ - cp = cp->next; - } - } /* multi-color dither */ - } /* else hueOffset != hueTop */ -} - - -/*********************** - * void drawPhong() * - * * - * A general routine * - * for displaying a * - * list of polygons * - * using a simple * - * scanline z-buffer * - * algorithm with * - * phong shading. * - ***********************/ - -void -#ifdef _NO_PROTO -drawPhong(dFlag) - int dFlag; -#else -drawPhong(int dFlag) -#endif -{ - - poly *p, *head; - polyList *s; - int i,j,hue; - int *anIndex, redo; - viewTriple *aPoint, *polyPt; - - redo = (recalc || redoSmooth); - if (redo || redoColor || redoDither) { - rotated = no; zoomed = no; translated = no; - switchedPerspective = no; changedEyeDistance = no; - redoSmooth = no; movingLight = no; - - /* If only a color change don't recalculate polygon info. */ - if (!redo) { - /* glossy shading if a single hue is indicated */ - changeColorMap(); - scanLines(dFlag); - /* if axes are on then show axes labels */ - if (viewport->axesOn) showAxesLabels(dFlag); - - /* show pixmap of image */ - XCopyArea(dsply,viewmap,viewport->viewWindow,trashGC,0,0, - vwInfo.width,vwInfo.height,0,0); - } else { - if (keepDrawingViewport()) { - if (!firstTime && !(scanline > 0)) { - strcpy(control->message," Freeing Polygons "); - writeControlMessage(); - freeListOfPolygons(quickList); - freePointResevoir(); - } - if (keepDrawingViewport()) { - strcpy(control->message," Collecting Polygons "); - writeControlMessage(); - quickList = copyPolygons(viewData.polygons); - - if (keepDrawingViewport()) { - strcpy(control->message," Projecting Polygons "); - writeControlMessage(); - projectAllPolys(quickList); - if (keepDrawingViewport()) { - strcpy(control->message, - " Setting Polygon Extremes "); - writeControlMessage(); - minMaxPolygons(quickList); - if (keepDrawingViewport()) { - strcpy(control->message, - " Sorting Polygons "); - writeControlMessage(); - quickList = msort(quickList,0,viewData.numPolygons, - polyCompare); - calcEyePoint(); - head = p = quickList; - - /* glossy shading if a single hue is indicated */ - changeColorMap(); - - for (i=0, aPoint=viewData.points; - i<viewData.numOfPoints; i++,aPoint++) { - aPoint->norm[0]= 0.0; - aPoint->norm[1]= 0.0; - aPoint->norm[2]= 0.0; - } - freePolyList(); - for (i = 0; i < ARRAY_HEIGHT; i++) - scanList[i] = NIL(polyList); - /* for each polygon */ - /* calculate average normal for each vertex */ - strcpy(control->message, - " Build Polygon Lists "); - writeControlMessage(); - p = head; - while ((p != NIL(poly)) && keepDrawingViewport()) { - - for (j = 0, anIndex = p->indexPtr; - j < p->numpts; j++, anIndex++) { - polyPt = refPt3D(viewData,*(anIndex)); - polyPt->norm[0] += p->N[0]; - polyPt->norm[1] += p->N[1]; - polyPt->norm[2] += p->N[2]; - normalizeVector(polyPt->norm); - /* get hue for each point if multi-dithering is used */ - if ((viewport->hueOffset != viewport->hueTop || - smoothError) && !mono) { - if (absolute(p->color) > 1.0) { - hue = floor(absolute(p->color)); - } else { - hue = floor(absolute(p->color) * - viewport->numberOfHues) + - viewport->hueOffset; - } - polyPt->sc = (float)hue; - } /* multi-color dither */ - } /* for each point in polygon */ - - if ( ! ( p->partialClipPz || - p->totalClipPz || - (viewData.clipStuff && (p->partialClip || p->totalClip ) ) ) ) { - /* put polygon in each scanline list it intersects */ - for (i=(int)p->pymin; i<= (int)p->pymax; i++) { - if ( (i>=0) && (i<ARRAY_HEIGHT ) ){ - s = (polyList *)saymem("smoothShade.c",1,sizeof(polyList)); - s->polyIndx = p; - s->next = scanList[i]; - scanList[i] = s; - } - } /* put polygon in each scanline it intersects */ - } /* if polygon not clipped */ - p = p->next; - } /* while still polygons */ - - scanLines(dFlag); - - /* if axes are on then show axes labels */ - if (viewport->axesOn) showAxesLabels(dFlag); - - /* show pixmap of image */ - XCopyArea(dsply,viewmap,viewport->viewWindow,trashGC,0,0, - vwInfo.width,vwInfo.height,0,0); - /* freePolyList(scanList); */ - - } /* keepDrawingViewport() after setting extreme values */ - } /* keepDrawingViewport() after projecting all polygons */ - } /* keepDrawingViewport() after collecting polygons */ - } /* keepDrawingViewport() after freeing polygons */ - } /* keepDrawingViewport() after recalc */ - finishedList = !(scanline>0); - if (firstTime) firstTime = no; - } /* not only a color change */ - - } else { /* else just redisplay current pixmap of image */ - XCopyArea(dsply,viewmap,viewport->viewWindow,trashGC,0,0, - vwInfo.width,vwInfo.height,0,0); - } - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - -} /* drawPhong */ - - - - - - - - - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/spadAction3d.c.pamphlet b/src/graph/view3D/spadAction3d.c index 6f451bbf..15ffa76f 100644 --- a/src/graph/view3D/spadAction3d.c.pamphlet +++ b/src/graph/view3D/spadAction3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D spadAction3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _SPADACTION3D_C #include "axiom-c-macros.h" @@ -81,7 +67,7 @@ readViewman (void *info,int size) void #ifdef _NO_PROTO scalePoint (p) - viewTriple *p; + viewTriple *p; #else scalePoint (viewTriple *p) #endif @@ -124,7 +110,7 @@ spadAction (void) switch (viewCommand) { case rotate: - readViewman(&f1, floatSize); + readViewman(&f1, floatSize); readViewman(&f2, floatSize); viewport->theta = f1; viewport->phi = f2; @@ -141,7 +127,7 @@ spadAction (void) break; case zoom: - readViewman(&f1, floatSize); + readViewman(&f1, floatSize); viewport->scale = f1; if (viewport->scale > maxScale) viewport->scale = maxScale; else if (viewport->scale < minScale) viewport->scale = minScale; @@ -151,13 +137,13 @@ spadAction (void) break; case zoomx: - readViewman(&f1, floatSize); - readViewman(&f2, floatSize); - readViewman(&f3, floatSize); + 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->scaleY == 1.0) && + (viewport->scaleZ == 1.0)) { viewport->zoomXOn = viewport->zoomYOn = viewport->zoomZOn = yes; } else { if (viewport->scaleX == 1.0) viewport->zoomXOn = no; @@ -422,9 +408,3 @@ spadAction (void) } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/static.h b/src/graph/view3D/static.h index 5f8b52d5..201f272b 100755..100644 --- a/src/graph/view3D/static.h +++ b/src/graph/view3D/static.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* This is a description of script character labels for the diff --git a/src/graph/view3D/stuff3d.c.pamphlet b/src/graph/view3D/stuff3d.c index 034f853d..5b828ed5 100644 --- a/src/graph/view3D/stuff3d.c.pamphlet +++ b/src/graph/view3D/stuff3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D stuff3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _STUFF3D_C #include "axiom-c-macros.h" @@ -72,7 +58,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. viewTriple * #ifdef _NO_PROTO traverse (n) - int n; + int n; #else traverse (int n) #endif @@ -95,7 +81,7 @@ traverse (int n) float #ifdef _NO_PROTO absolute (x) - float x; + float x; #else absolute (float x) #endif @@ -192,9 +178,3 @@ goodbye(int sig) -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/surface3d.c.pamphlet b/src/graph/view3D/surface3d.c index 030f03bf..652c3a1a 100644 --- a/src/graph/view3D/surface3d.c.pamphlet +++ b/src/graph/view3D/surface3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D surface3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _SURFACE3D_C #include "axiom-c-macros.h" @@ -113,10 +99,10 @@ drawLineComponent (poly * p, int dFlag) if (dFlag==Xoption) { if (mono || viewport->monoOn) - GSetForeground(opaqueGC, (float)foregroundColor, dFlag); + GSetForeground(opaqueGC, (float)foregroundColor, dFlag); else { - hue = hueValue(p->color); - GSetForeground(opaqueGC, (float)XSolidColor(hue,2), dFlag); + hue = hueValue(p->color); + GSetForeground(opaqueGC, (float)XSolidColor(hue,2), dFlag); } } else GSetForeground(opaqueGC, psBlack, dFlag); @@ -127,7 +113,7 @@ drawLineComponent (poly * p, int dFlag) PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,quadMesh,p->numpts); } else { GDrawLines(opaqueGC, viewport->viewWindow, quadMesh, p->numpts, - CoordModeOrigin, dFlag); + CoordModeOrigin, dFlag); } if (dFlag == Xoption) XMapWindow(dsply, viewport->viewWindow); @@ -137,7 +123,7 @@ drawLineComponent (poly * p, int dFlag) /************************************************** - * void drawOpaquePolygon(p,aGC,anotherGC) * + * void drawOpaquePolygon(p,aGC,anotherGC) * **************************************************/ void @@ -189,26 +175,26 @@ drawOpaquePolygon (poly *p,GC aGC,GC anotherGC,int dFlag) hue = getHue(p->color); col_rgb = hlsTOrgb((float)hue,0.5,0.8); if (viewport->diagonals) - PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,quadMesh,p->numpts+1); + PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,quadMesh,p->numpts+1); else - PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,quadMesh,p->numpts); + PSDrawColor(col_rgb.r,col_rgb.g,col_rgb.b,quadMesh,p->numpts); } else { if (mono || viewport->monoOn) { - GSetForeground(anotherGC, (float)foregroundColor, dFlag); + GSetForeground(anotherGC, (float)foregroundColor, dFlag); } else { - hue = hueValue(p->color); - GSetForeground(anotherGC, (float)XSolidColor(hue,2), dFlag); + hue = hueValue(p->color); + GSetForeground(anotherGC, (float)XSolidColor(hue,2), dFlag); } GSetForeground(aGC,(float)backgroundColor,dFlag); if (!isNaN) { XFillPolygon(dsply, viewport->viewWindow, aGC, quadMesh, p->numpts, - Convex,CoordModeOrigin); + Convex,CoordModeOrigin); if (viewport->diagonals) - GDrawLines(anotherGC,viewport->viewWindow,quadMesh,p->numpts+1, - CoordModeOrigin, dFlag); + GDrawLines(anotherGC,viewport->viewWindow,quadMesh,p->numpts+1, + CoordModeOrigin, dFlag); else - GDrawLines(anotherGC,viewport->viewWindow,quadMesh,p->numpts, - CoordModeOrigin, dFlag); + GDrawLines(anotherGC,viewport->viewWindow,quadMesh,p->numpts, + CoordModeOrigin, dFlag); } } if (dFlag == Xoption) XMapWindow(dsply,viewport->viewWindow); @@ -219,9 +205,9 @@ drawOpaquePolygon (poly *p,GC aGC,GC anotherGC,int dFlag) /************************************* * poly *copyPolygons(polygonList) * - * * + * * * copies the given list of polygons * - * into a newly allocated list * + * into a newly allocated list * *************************************/ poly * @@ -238,7 +224,7 @@ copyPolygons (poly *polygonList) prev = retval = aPoly = (poly *)saymem("surface.c",1,sizeof(poly)); aPoly->indexPtr = (int *)saymem("surface.c", - polygonList->numpts,sizeof(int)); + polygonList->numpts,sizeof(int)); aPoly->num = polygonList->num; aPoly->sortNum = polygonList->sortNum; aPoly->split = polygonList->split; @@ -270,7 +256,7 @@ copyPolygons (poly *polygonList) polygonList = polygonList->next) { prev->next = aPoly = (poly *)saymem("surface.c",1,sizeof(poly)); aPoly->indexPtr = (int *)saymem("surface.c", - polygonList->numpts,sizeof(int)); + polygonList->numpts,sizeof(int)); aPoly->num = polygonList->num; aPoly->sortNum = polygonList->sortNum; aPoly->numpts = polygonList->numpts; @@ -306,11 +292,11 @@ copyPolygons (poly *polygonList) /****************************** * void minMaxPolygons(aPoly) * - * * - * sets up the xmin, * + * * + * sets up the xmin, * * etc, for each polygon * - * for sorting and * - * extent checking. * + * for sorting and * + * extent checking. * ******************************/ void @@ -335,30 +321,30 @@ minMaxPolygons (poly *aPoly) aPoly->zmin = aPoly->zmax = refPt3D(viewData,*anIndex)->z; for (i=1,anIndex++; i<aPoly->numpts; i++,anIndex++) { if (refPt3D(viewData,*anIndex)->px < aPoly->pxmin) - aPoly->pxmin = refPt3D(viewData,*anIndex)->px; + aPoly->pxmin = refPt3D(viewData,*anIndex)->px; else if (refPt3D(viewData,*anIndex)->px > aPoly->pxmax) - aPoly->pxmax = refPt3D(viewData,*anIndex)->px; + aPoly->pxmax = refPt3D(viewData,*anIndex)->px; if (refPt3D(viewData,*anIndex)->py < aPoly->pymin) - aPoly->pymin = refPt3D(viewData,*anIndex)->py; + aPoly->pymin = refPt3D(viewData,*anIndex)->py; else if (refPt3D(viewData,*anIndex)->py > aPoly->pymax) - aPoly->pymax = refPt3D(viewData,*anIndex)->py; + aPoly->pymax = refPt3D(viewData,*anIndex)->py; if (refPt3D(viewData,*anIndex)->pz < aPoly->pzmin) - aPoly->pzmin = refPt3D(viewData,*anIndex)->pz; + aPoly->pzmin = refPt3D(viewData,*anIndex)->pz; else if (refPt3D(viewData,*anIndex)->pz > aPoly->pzmax) - aPoly->pzmax = refPt3D(viewData,*anIndex)->pz; + aPoly->pzmax = refPt3D(viewData,*anIndex)->pz; if (refPt3D(viewData,*anIndex)->x < aPoly->xmin) - aPoly->xmin = refPt3D(viewData,*anIndex)->x; + aPoly->xmin = refPt3D(viewData,*anIndex)->x; else if (refPt3D(viewData,*anIndex)->x > aPoly->xmax) - aPoly->xmax = refPt3D(viewData,*anIndex)->x; + aPoly->xmax = refPt3D(viewData,*anIndex)->x; if (refPt3D(viewData,*anIndex)->y < aPoly->ymin) - aPoly->ymin = refPt3D(viewData,*anIndex)->y; + aPoly->ymin = refPt3D(viewData,*anIndex)->y; else if (refPt3D(viewData,*anIndex)->y > aPoly->ymax) - aPoly->ymax = refPt3D(viewData,*anIndex)->y; + aPoly->ymax = refPt3D(viewData,*anIndex)->y; if (refPt3D(viewData,*anIndex)->z < aPoly->zmin) - aPoly->zmin = refPt3D(viewData,*anIndex)->z; + aPoly->zmin = refPt3D(viewData,*anIndex)->z; else if (refPt3D(viewData,*anIndex)->z > aPoly->zmax) - aPoly->zmax = refPt3D(viewData,*anIndex)->z; + aPoly->zmax = refPt3D(viewData,*anIndex)->z; } } } /* minMaxPolygons */ @@ -367,14 +353,14 @@ minMaxPolygons (poly *aPoly) /*********************************** * int polyCompare (p1,p2) * - * * - * returns -1 if p1 < p2 * - * 0 if p1 = p2 * - * 1 if p1 > p2 * + * * + * returns -1 if p1 < p2 * + * 0 if p1 = p2 * + * 1 if p1 > p2 * * note that this is the reverse * - * of what the msort requested. * + * of what the msort requested. * * this is so that the list will * - * be sorted from max to min. * + * be sorted from max to min. * ***********************************/ int @@ -393,7 +379,7 @@ polyCompare (poly *p1,poly *p2) /*********************** * void calcEyePoint() * - * * + * * * sets the global * * variable eyePoint[] * * to where the viewer * @@ -421,15 +407,15 @@ calcEyePoint (void) A general routine for displaying a list of polygons with the proper hidden surfaces removed. Assumes the list of polygons is in viewData.polygons. Needs a - routine to split intersecting polygons in object space. * + routine to split intersecting polygons in object space. * */ /************************************** * void drawRenderedPolygon(p,dFlag) * - * * - * calculate the color for the * - * polygon p and draw it * + * * + * calculate the color for the * + * polygon p and draw it * **************************************/ void @@ -442,16 +428,16 @@ drawRenderedPolygon (poly *p,int dFlag) #endif { - int i,hue,shade, isNaN = 0; - float whichSide,H[3],P[3],LN,HN,diff,spec,tempLight,lumens,E[3],N[3]; - int *anIndex, *indx; - RGB col_rgb; + int i,hue,shade, isNaN = 0; + float whichSide,H[3],P[3],LN,HN,diff,spec,tempLight,lumens,E[3],N[3]; + int *anIndex, *indx; + RGB col_rgb; if (!((p->partialClipPz) || (viewData.clipStuff && (p->partialClip)))) { /* This routine should eventually only be skipped if - p->totalClip is true and another routine would - handle the partialClip. This routine would handle - only those polygons without any clipped points. */ + p->totalClip is true and another routine would + handle the partialClip. This routine would handle + only those polygons without any clipped points. */ for (i=0, anIndex=p->indexPtr; i<p->numpts; i++,anIndex++) { quadMesh[i].x = refPt3D(viewData,*anIndex)->px; @@ -466,14 +452,14 @@ drawRenderedPolygon (poly *p,int dFlag) /* calculate polygon illumination */ indx = p->indexPtr; P[0] = (refPt3D(viewData,*(indx))->wx + - refPt3D(viewData,*(indx+1))->wx + - refPt3D(viewData,*(indx+2))->wx); + refPt3D(viewData,*(indx+1))->wx + + refPt3D(viewData,*(indx+2))->wx); P[1] = (refPt3D(viewData,*(indx))->wy + - refPt3D(viewData,*(indx+1))->wy + - refPt3D(viewData,*(indx+2))->wy); + refPt3D(viewData,*(indx+1))->wy + + refPt3D(viewData,*(indx+2))->wy); P[2] = (refPt3D(viewData,*(indx))->wz + - refPt3D(viewData,*(indx+1))->wz + - refPt3D(viewData,*(indx+2))->wz); + refPt3D(viewData,*(indx+1))->wz + + refPt3D(viewData,*(indx+2))->wz); normalizeVector(P); N[0] = p->N[0]; N[1] = p->N[1]; N[2] = p->N[2]; @@ -482,10 +468,10 @@ drawRenderedPolygon (poly *p,int dFlag) E[1] = 4.0*eyePoint[1] - P[1]; E[2] = 4.0*eyePoint[2] - P[2]; normalizeVector(E); - diff = 0.0; spec = 0.0; + diff = 0.0; spec = 0.0; LN = N[0]*viewport->lightVector[0] + - N[1]*viewport->lightVector[1] + - N[2]*viewport->lightVector[2]; + N[1]*viewport->lightVector[1] + + N[2]*viewport->lightVector[2]; if (LN < 0.0) LN = -LN; diff = LN*Cdiff; @@ -509,16 +495,16 @@ drawRenderedPolygon (poly *p,int dFlag) /* NTSC color to grey = .299 red + .587 green + .114 blue */ maxGreyShade = (int) psShadeMax; whichSide = (.299*col_rgb.r + .587*col_rgb.g + .114*col_rgb.b) * - (maxGreyShade-1); + (maxGreyShade-1); } else { if (mono || viewport->monoOn) { - hue = getHue(p->color); - col_rgb = hlsTOrgb((float)hue,lumens,0.8); - whichSide = (.299*col_rgb.r + .587*col_rgb.g + .114*col_rgb.b) * - (maxGreyShade-1); + hue = getHue(p->color); + col_rgb = hlsTOrgb((float)hue,lumens,0.8); + whichSide = (.299*col_rgb.r + .587*col_rgb.g + .114*col_rgb.b) * + (maxGreyShade-1); } else - whichSide = lumens*(totalShades-1); + whichSide = lumens*(totalShades-1); } tempLight = lightIntensity; @@ -528,55 +514,55 @@ drawRenderedPolygon (poly *p,int dFlag) lightIntensity = tempLight; if (shade < totalShades) { - /* shade < totalShades is (temporarily) necessary here - because, currently, parameterizations for things like - the sphere would produce triangular shaped polygons - close to the poles which get triangularized leaving a - triangle with coincidental points. the normal for this - would be undefined (since coincidental points would create - a zero vector) and the shade would be large, hence, - the conditional. */ + /* shade < totalShades is (temporarily) necessary here + because, currently, parameterizations for things like + the sphere would produce triangular shaped polygons + close to the poles which get triangularized leaving a + triangle with coincidental points. the normal for this + would be undefined (since coincidental points would create + a zero vector) and the shade would be large, hence, + the conditional. */ if (mono || viewport->monoOn) { - if (dFlag == Xoption) { - XChangeShade(dsply,maxGreyShade-shade-1); - XShadePolygon(dsply,viewport->viewWindow,quadMesh,p->numpts+1, - Convex,CoordModeOrigin); - } - else if (dFlag == PSoption) { /* renderGC has number 9991 - (see main.c, header.h) */ - GSetForeground(GC9991, - 1.0-(float)(maxGreyShade-shade-1)*psShadeMul,PSoption); - PSFillPolygon(GC9991, quadMesh, p->numpts+1); - } + if (dFlag == Xoption) { + XChangeShade(dsply,maxGreyShade-shade-1); + XShadePolygon(dsply,viewport->viewWindow,quadMesh,p->numpts+1, + Convex,CoordModeOrigin); + } + else if (dFlag == PSoption) { /* renderGC has number 9991 + (see main.c, header.h) */ + GSetForeground(GC9991, + 1.0-(float)(maxGreyShade-shade-1)*psShadeMul,PSoption); + PSFillPolygon(GC9991, quadMesh, p->numpts+1); + } } else { /* not mono */ - if (dFlag == Xoption) { - hue = hueValue(p->color); - XSpadFillPolygon(dsply, viewport->viewWindow, quadMesh, - p->numpts+1, Convex,CoordModeOrigin, hue, shade); - } - else if (dFlag == PSoption) /* draws it out in monochrome */ - PSColorPolygon(col_rgb.r,col_rgb.g,col_rgb.b,quadMesh,p->numpts+1); - } /* if mono-else */ + if (dFlag == Xoption) { + hue = hueValue(p->color); + XSpadFillPolygon(dsply, viewport->viewWindow, quadMesh, + p->numpts+1, Convex,CoordModeOrigin, hue, shade); + } + else if (dFlag == PSoption) /* draws it out in monochrome */ + PSColorPolygon(col_rgb.r,col_rgb.g,col_rgb.b,quadMesh,p->numpts+1); + } /* if mono-else */ if (viewData.outlineRenderOn) { - if (viewport->diagonals) { - if (dFlag == PSoption) { - GSetForeground(renderGC,psBlack, dFlag); - GDrawLines(renderGC,viewport->viewWindow,quadMesh,p->numpts+1, - CoordModeOrigin,dFlag); - } else - GDrawLines(renderGC,viewport->viewWindow,quadMesh,p->numpts+1, - CoordModeOrigin,dFlag); - } else { - if (dFlag == PSoption) { - GSetForeground(renderGC,psBlack,PSoption); - GDrawLines(renderGC,viewport->viewWindow,quadMesh,p->numpts, - CoordModeOrigin,PSoption); + if (viewport->diagonals) { + if (dFlag == PSoption) { + GSetForeground(renderGC,psBlack, dFlag); + GDrawLines(renderGC,viewport->viewWindow,quadMesh,p->numpts+1, + CoordModeOrigin,dFlag); } else - GDrawLines(renderGC,viewport->viewWindow,quadMesh,p->numpts, - CoordModeOrigin,dFlag); - } + GDrawLines(renderGC,viewport->viewWindow,quadMesh,p->numpts+1, + CoordModeOrigin,dFlag); + } else { + if (dFlag == PSoption) { + GSetForeground(renderGC,psBlack,PSoption); + GDrawLines(renderGC,viewport->viewWindow,quadMesh,p->numpts, + CoordModeOrigin,PSoption); + } else + GDrawLines(renderGC,viewport->viewWindow,quadMesh,p->numpts, + CoordModeOrigin,dFlag); + } } } } /* if not NaN */ @@ -606,8 +592,8 @@ freePointResevoir(void) /*********************************** * void freeListOfPolygons(pList); * - * * - * frees up a list of polygons. * + * * + * frees up a list of polygons. * ***********************************/ void @@ -656,119 +642,119 @@ drawPolygons(int dFlag) if (keepDrawingViewport()) { if (!firstTime) { - strcpy(control->message," Creating Polygons "); - writeControlMessage(); - freeListOfPolygons(quickList); - freePointResevoir(); + strcpy(control->message," Creating Polygons "); + writeControlMessage(); + freeListOfPolygons(quickList); + freePointResevoir(); } strcpy(control->message," Collecting Polygons "); writeControlMessage(); quickList = copyPolygons(viewData.polygons); if (keepDrawingViewport()) { - /* to get normal facing outside info */ - strcpy(control->message," Projecting Polygons "); - writeControlMessage(); - projectAllPolys(quickList); - if (keepDrawingViewport()) { - strcpy(control->message," Setting Extreme Values "); - writeControlMessage(); - minMaxPolygons(quickList); - if (keepDrawingViewport()) { - strcpy(control->message," Sorting Polygons "); - writeControlMessage(); - quickList = msort(quickList,0,viewData.numPolygons,polyCompare); - if (keepDrawingViewport()) { - calcEyePoint(); - head = p = quickList; - - clearControlMessage(); - strcpy(control->message,viewport->title); - writeControlMessage(); - - if (viewData.scaleDown) { - if (keepDrawingViewport()) { - for (p=quickList; - keepDrawingViewport() && (p != NIL(poly)); - p=p->next) { - switch (p->primitiveType) { - case pointComponent: - if (dFlag==Xoption) { - if (mono || viewport->monoOn) - GSetForeground(componentGC, - (float)foregroundColor, dFlag); - else - GSetForeground(componentGC, - (float)meshOutline, dFlag); - } else { - GSetForeground(componentGC, psBlack, dFlag); - GFillArc(componentGC, viewport->viewWindow, - (int)refPt3D(viewData,*(p->indexPtr))->px, - (int)refPt3D(viewData,*(p->indexPtr))->py, - viewData.pointSize,viewData.pointSize,0, - 360*64, dFlag); - } - break; - case lineComponent: - drawLineComponent(p,dFlag); - break; - default: - if (viewData.style == opaqueMesh) { - GSetForeground(globGC,(float)backgroundColor,dFlag); - drawOpaquePolygon(p,globGC,opaqueGC,dFlag); - } else { - drawRenderedPolygon(p,dFlag); - } - } /* switch */ - } - } - } - - if (!quickFirst) { - /* append the rest of the polygons onto the list */ - tempQuick->next = head; - /* but do not continue the drawing... */ - if (head != NIL(poly)) head->doNotStopDraw = no; - } /* if !quickFirst */ - finishedList = (p==NIL(poly)); - } /* for various */ - } /* steps */ - } /* of */ - } /* keepDrawingViewport() */ - } /* *** */ + /* to get normal facing outside info */ + strcpy(control->message," Projecting Polygons "); + writeControlMessage(); + projectAllPolys(quickList); + if (keepDrawingViewport()) { + strcpy(control->message," Setting Extreme Values "); + writeControlMessage(); + minMaxPolygons(quickList); + if (keepDrawingViewport()) { + strcpy(control->message," Sorting Polygons "); + writeControlMessage(); + quickList = msort(quickList,0,viewData.numPolygons,polyCompare); + if (keepDrawingViewport()) { + calcEyePoint(); + head = p = quickList; + + clearControlMessage(); + strcpy(control->message,viewport->title); + writeControlMessage(); + + if (viewData.scaleDown) { + if (keepDrawingViewport()) { + for (p=quickList; + keepDrawingViewport() && (p != NIL(poly)); + p=p->next) { + switch (p->primitiveType) { + case pointComponent: + if (dFlag==Xoption) { + if (mono || viewport->monoOn) + GSetForeground(componentGC, + (float)foregroundColor, dFlag); + else + GSetForeground(componentGC, + (float)meshOutline, dFlag); + } else { + GSetForeground(componentGC, psBlack, dFlag); + GFillArc(componentGC, viewport->viewWindow, + (int)refPt3D(viewData,*(p->indexPtr))->px, + (int)refPt3D(viewData,*(p->indexPtr))->py, + viewData.pointSize,viewData.pointSize,0, + 360*64, dFlag); + } + break; + case lineComponent: + drawLineComponent(p,dFlag); + break; + default: + if (viewData.style == opaqueMesh) { + GSetForeground(globGC,(float)backgroundColor,dFlag); + drawOpaquePolygon(p,globGC,opaqueGC,dFlag); + } else { + drawRenderedPolygon(p,dFlag); + } + } /* switch */ + } + } + } + + if (!quickFirst) { + /* append the rest of the polygons onto the list */ + tempQuick->next = head; + /* but do not continue the drawing... */ + if (head != NIL(poly)) head->doNotStopDraw = no; + } /* if !quickFirst */ + finishedList = (p==NIL(poly)); + } /* for various */ + } /* steps */ + } /* of */ + } /* keepDrawingViewport() */ + } /* *** */ /* May want to have a flag somewhere to stop the drawing yet continue the freeing */ if (firstTime) firstTime = no; } else { /* if recalc else if not recalc just draw stuff in list */ if (keepDrawingViewport()) { for (p=quickList; - keepDrawingViewport() && p != NIL(poly) && - (viewData.scaleDown || p->doNotStopDraw); p=p->next) { - projectAPoly(p); - switch (p->primitiveType) { - case pointComponent: - if (dFlag==Xoption) { - if (mono || viewport->monoOn) - GSetForeground(componentGC,(float)foregroundColor, dFlag); - else - GSetForeground(componentGC,(float)meshOutline, dFlag); - } else - GSetForeground(componentGC,psBlack, dFlag); - GFillArc(componentGC, viewport->viewWindow, - (int)refPt3D(viewData,*(p->indexPtr))->px, - (int)refPt3D(viewData,*(p->indexPtr))->py, - viewData.pointSize,viewData.pointSize,0,360*64,dFlag); - break; - case lineComponent: - drawLineComponent(p,dFlag); - break; - default: - if (viewData.style == opaqueMesh) { - GSetForeground(globGC,(float)backgroundColor,dFlag); - drawOpaquePolygon(p,globGC,opaqueGC,dFlag); - } else - drawRenderedPolygon(p,dFlag); - } /* switch */ + keepDrawingViewport() && p != NIL(poly) && + (viewData.scaleDown || p->doNotStopDraw); p=p->next) { + projectAPoly(p); + switch (p->primitiveType) { + case pointComponent: + if (dFlag==Xoption) { + if (mono || viewport->monoOn) + GSetForeground(componentGC,(float)foregroundColor, dFlag); + else + GSetForeground(componentGC,(float)meshOutline, dFlag); + } else + GSetForeground(componentGC,psBlack, dFlag); + GFillArc(componentGC, viewport->viewWindow, + (int)refPt3D(viewData,*(p->indexPtr))->px, + (int)refPt3D(viewData,*(p->indexPtr))->py, + viewData.pointSize,viewData.pointSize,0,360*64,dFlag); + break; + case lineComponent: + drawLineComponent(p,dFlag); + break; + default: + if (viewData.style == opaqueMesh) { + GSetForeground(globGC,(float)backgroundColor,dFlag); + drawOpaquePolygon(p,globGC,opaqueGC,dFlag); + } else + drawRenderedPolygon(p,dFlag); + } /* switch */ } } } @@ -781,17 +767,17 @@ drawPolygons(int dFlag) /************************** - * int lessThan(x,y) * - * int greaterThan(x,y) * - * int equal(x,y) * - * * + * int lessThan(x,y) * + * int greaterThan(x,y) * + * int equal(x,y) * + * * * Compares two floating * - * point numbers for * + * point numbers for * * precision of up to one * - * place in a thousand. * - * returns * - * 1 if true * - * o otherwise * + * place in a thousand. * + * returns * + * 1 if true * + * o otherwise * **************************/ int @@ -862,9 +848,3 @@ equal (float x,float y) return(xI==yI); } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/testcol.c.pamphlet b/src/graph/view3D/testcol.c index a9f6aa3f..ee61574e 100644 --- a/src/graph/view3D/testcol.c.pamphlet +++ b/src/graph/view3D/testcol.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D testcol.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _MAIN3D_C #include "axiom-c-macros.h" @@ -138,7 +124,7 @@ int spadMode=no, /* yes if receiving AXIOM command and int spadSignalReceived=0; /* yes if current state is a result of a signal from AXIOM */ int inNextEvent=no; /* true just before a call to - XNextEvent */ + XNextEvent */ jmp_buf jumpFlag; char errorStr[80]; @@ -168,7 +154,7 @@ float sinTheta, sinPhi, cosTheta, cosPhi, viewScale, int xCenter, yCenter; XWindowAttributes vwInfo; -XWindowAttributes graphWindowAttrib; +XWindowAttributes graphWindowAttrib; XPoint *quadMesh; XImage *imageX; @@ -199,7 +185,7 @@ XPoint polygonMesh[20]; int saveFlag=no; int firstTime=yes, noTrans = yes, startup = yes; int redrawView = no; /* set to yes when returning from - subpanels */ + subpanels */ int redoColor = no, pixelSetFlag = no, redoDither = no; int redoSmooth = no, multiColorFlag = no; @@ -227,9 +213,9 @@ int doingPanel=CONTROLpanel; /* rewrite titles in proper panel */ int doingVolume; int screenX; /* global floating point indicating mouse position - on frustrum screen */ + on frustrum screen */ float xClipMinN, xClipMaxN, /* normalized values for - clip volume */ + clip volume */ yClipMinN, yClipMaxN, zClipMinN, zClipMaxN, clipValue; /* mouse input */ @@ -277,9 +263,9 @@ main(void) XrmValue value; Atom wm_delete_window; - XColor foreColor, backColor; - XSizeHints titleSizeHints; - Window viewTitleWindow, viewGraphWindow; + XColor foreColor, backColor; + XSizeHints titleSizeHints; + Window viewTitleWindow, viewGraphWindow; XSetWindowAttributes viewAttrib; Pixmap spadbits,spadmask; @@ -319,13 +305,13 @@ main(void) GCBackground ,&controlGCVals); carefullySetFont(globalGC1,globalFont); PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* controlMessageGC */ controlGCVals.foreground = controlMessageColor; controlGCVals.background = backgroundColor; controlMessageGC = XCreateGC(dsply,rtWindow,GCForeground | - GCBackground ,&controlGCVals); + GCBackground ,&controlGCVals); carefullySetFont(controlMessageGC,globalFont); /* globalGC2 */ @@ -333,38 +319,38 @@ main(void) globalGC2 = XCreateGC(dsply,rtWindow,GCForeground,&controlGCVals); carefullySetFont(globalGC2,buttonFont); PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* trashGC */ controlGCVals.function = GXcopy; trashGC = XCreateGC(dsply,rtWindow,0 ,&controlGCVals); carefullySetFont(trashGC,buttonFont); PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* componentGC */ componentGC = XCreateGC(dsply,rtWindow,0 ,&controlGCVals); carefullySetFont(componentGC,buttonFont); PSCreateContext(componentGC, "componentGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* opaqueGC */ opaqueGC = XCreateGC(dsply,rtWindow,0 ,&controlGCVals); carefullySetFont(opaqueGC,buttonFont); PSCreateContext(opaqueGC, "opaqueGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* renderGC */ renderGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); carefullySetFont(renderGC,buttonFont); PSCreateContext(renderGC, "renderGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* globGC */ globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); carefullySetFont(globGC,headerFont); PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* anotherGC */ controlGCVals.line_width = colorWidth; @@ -372,50 +358,50 @@ main(void) GCFunction ,&controlGCVals); carefullySetFont(anotherGC,titleFont); PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); + psMiterJoin, psWhite, psBlack); /* also create one for rendering (grayscale only for now) */ /* assign arbitrary number to renderGC as 9991 - see header.h */ PSCreateContext(GC9991, "renderGC", psNormalWidth, psButtCap, - psRoundJoin, psWhite, psBlack ); + psRoundJoin, psWhite, psBlack ); /* processGC */ gcVals.background = backgroundColor; processGC = XCreateGC(dsply,rtWindow,GCBackground | - GCFillStyle,&gcVals); + GCFillStyle,&gcVals); carefullySetFont(processGC,buttonFont); /* lightingGC */ controlGCVals.foreground = monoColor(axesColor); controlGCVals.background = backgroundColor; lightingGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(lightingGC,lightingFont); /* volumeGC */ volumeGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(volumeGC,volumeFont); /* quitGC */ quitGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(quitGC,buttonFont); /* saveGC */ saveGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(saveGC,buttonFont); /* graphGC */ graphGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); + ,&controlGCVals); carefullySetFont(graphGC,buttonFont); if (!(viewport = (viewPoints *)saymem("viewport3D.c", - 1,sizeof(viewPoints)))) { + 1,sizeof(viewPoints)))) { fprintf(stderr,"Ran out of memory trying to create a viewport.\n"); exitWithAck(RootWindow(dsply,scrn),Window,-1); } @@ -425,57 +411,57 @@ main(void) I[2][0] = 0.0; I[2][1] = 0.0; I[2][2] = 1.0; I[2][3] = 0.0; I[3][0] = 0.0; I[3][1] = 0.0; I[3][2] = 0.0; I[3][3] = 1.0; - viewport->viewportKey = viewportKeyNum++; + viewport->viewportKey = viewportKeyNum++; viewport->nextViewport = 0; viewport->prevViewport = 0; - viewport->deltaX = viewport->deltaX0 = viewData.deltaX; - viewport->deltaY = viewport->deltaY0 = viewData.deltaY; - viewport->deltaZ = viewport->deltaZ0 = viewData.deltaZ; - viewport->scale = viewport->scale0 = viewData.scale; - viewport->scaleX = viewData.scaleX; - viewport->scaleY = viewData.scaleY; - viewport->scaleZ = viewData.scaleZ; - viewport->transX = (viewData.xmax + viewData.xmin)/2.0; - viewport->transY = (viewData.ymax + viewData.ymin)/2.0; - viewport->transZ = (viewData.zmax + viewData.zmin)/2.0; + viewport->deltaX = viewport->deltaX0 = viewData.deltaX; + viewport->deltaY = viewport->deltaY0 = viewData.deltaY; + viewport->deltaZ = viewport->deltaZ0 = viewData.deltaZ; + viewport->scale = viewport->scale0 = viewData.scale; + viewport->scaleX = viewData.scaleX; + viewport->scaleY = viewData.scaleY; + viewport->scaleZ = viewData.scaleZ; + viewport->transX = (viewData.xmax + viewData.xmin)/2.0; + viewport->transY = (viewData.ymax + viewData.ymin)/2.0; + viewport->transZ = (viewData.zmax + viewData.zmin)/2.0; viewport->theta = viewport->axestheta = viewport->theta0 = viewData.theta; - viewport->phi = viewport->axesphi = viewport->phi0 = viewData.phi; + viewport->phi = viewport->axesphi = viewport->phi0 = viewData.phi; viewport->thetaObj = 0.0; viewport->phiObj = 0.0; viewData.title = "untitled"; strcpy(viewport->title,viewData.title); - viewport->axesOn = yes; - viewport->regionOn = no; - viewport->monoOn = no; - viewport->zoomXOn = yes; - viewport->zoomYOn = yes; - viewport->zoomZOn = yes; + viewport->axesOn = yes; + viewport->regionOn = no; + viewport->monoOn = no; + viewport->zoomXOn = yes; + viewport->zoomYOn = yes; + viewport->zoomZOn = yes; - viewport->originrOn = yes; - viewport->objectrOn = no; - viewport->originFlag = no; + viewport->originrOn = yes; + viewport->objectrOn = no; + viewport->originFlag = no; - viewport->xyOn = no; - viewport->xzOn = no; - viewport->yzOn = no; + viewport->xyOn = no; + viewport->xzOn = no; + viewport->yzOn = no; - viewport->closing = no; - viewport->allowDraw = yes; /*if no, just draw axes the first time */ - viewport->needNorm = yes; + viewport->closing = no; + viewport->allowDraw = yes; /*if no, just draw axes the first time */ + viewport->needNorm = yes; viewport->lightVector[0] = -0.5; viewport->lightVector[1] = 0.5; viewport->lightVector[2] = 0.5; viewport->translucency = viewData.translucency; - viewport->hueOffset = viewData.hueOff; + viewport->hueOffset = viewData.hueOff; viewport->numberOfHues = viewData.numOfHues; - viewport->hueTop = viewData.hueOff + viewData.numOfHues; + viewport->hueTop = viewData.hueOff + viewData.numOfHues; if (viewport->hueTop > totalHues-1) viewport->hueTop = totalHues-1; - viewport->diagonals = viewData.diagonals; + viewport->diagonals = viewData.diagonals; /* make theta in [0..2pi) and phi in (-pi..pi] */ while (viewport->theta >= two_pi) { @@ -516,20 +502,20 @@ main(void) cosTheta = cos(-viewport->thetaObj); sinPhi = sin(viewport->phiObj); cosPhi = cos(viewport->phiObj); - ROTATE1(R1); /* angles theta and phi are global */ + ROTATE1(R1); /* angles theta and phi are global */ /* Initialize the non-uniform scaling matrix. */ SCALE(viewport->scaleX,viewport->scaleY,viewport->scaleZ,S); /* Initialize the translation matrix. */ TRANSLATE(-viewport->deltaX,-viewport->deltaY,0.0,T); - /**** make the windows for the viewport ****/ + /**** make the windows for the viewport ****/ spadbits = XCreateBitmapFromData(dsply,rtWindow, - spadBitmap_bits, - spadBitmap_width,spadBitmap_height); + spadBitmap_bits, + spadBitmap_width,spadBitmap_height); spadmask = XCreateBitmapFromData(dsply,rtWindow, - spadMask_bits, - spadMask_width,spadMask_height); + spadMask_bits, + spadMask_width,spadMask_height); viewAttrib.background_pixel = backgroundColor; viewAttrib.border_pixel = foregroundColor; @@ -545,12 +531,12 @@ main(void) XQueryColor(dsply,colorMap,&foreColor); XQueryColor(dsply,colorMap,&backColor); viewAttrib.cursor = XCreatePixmapCursor(dsply,spadbits,spadmask, - &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot); + &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot); viewAttrib.event_mask = titleMASK; if (viewData.vW) { titleSizeHints.flags = PPosition | PSize; - titleSizeHints.x = viewData.vX; - titleSizeHints.y = viewData.vY; + titleSizeHints.x = viewData.vX; + titleSizeHints.y = viewData.vY; titleSizeHints.width = viewData.vW; titleSizeHints.height = viewData.vH; } else { /* ain't gonna allow this for now... */ @@ -560,9 +546,9 @@ main(void) } viewTitleWindow = XCreateWindow(dsply,rtWindow,viewData.vX,viewData.vY, - viewData.vW,viewData.vH,viewBorderWidth+3, - CopyFromParent,InputOutput,CopyFromParent, - viewportTitleCreateMASK,&viewAttrib); + viewData.vW,viewData.vH,viewBorderWidth+3, + CopyFromParent,InputOutput,CopyFromParent, + viewportTitleCreateMASK,&viewAttrib); wm_delete_window = XInternAtom(dsply, "WM_DELETE_WINDOW", False); (void) XSetWMProtocols(dsply, viewTitleWindow, &wm_delete_window, 1); @@ -570,27 +556,27 @@ main(void) XSetNormalHints(dsply,viewTitleWindow,&titleSizeHints); if (strlen(viewport->title) < 30) XSetStandardProperties(dsply,viewTitleWindow,"AXIOM 3D",viewport->title, - None,NULL,0,&titleSizeHints); + None,NULL,0,&titleSizeHints); else XSetStandardProperties(dsply,viewTitleWindow,"AXIOM 3D","3D AXIOM Graph", - None,NULL,0,&titleSizeHints); + None,NULL,0,&titleSizeHints); viewport->titleWindow = viewTitleWindow; viewAttrib.event_mask = viewportMASK; - viewSizeHints.flags = PPosition | PSize; - viewSizeHints.x = -(viewBorderWidth+3); - viewSizeHints.y = titleHeight; - viewSizeHints.width = titleSizeHints.width; - viewSizeHints.height = titleSizeHints.height-(titleHeight+appendixHeight); + viewSizeHints.flags = PPosition | PSize; + viewSizeHints.x = -(viewBorderWidth+3); + viewSizeHints.y = titleHeight; + viewSizeHints.width = titleSizeHints.width; + viewSizeHints.height = titleSizeHints.height-(titleHeight+appendixHeight); viewGraphWindow = XCreateWindow(dsply,viewTitleWindow, - viewSizeHints.x,viewSizeHints.y, - viewSizeHints.width,viewSizeHints.height, - viewBorderWidth+3, - CopyFromParent,InputOutput,CopyFromParent, - viewportCreateMASK,&viewAttrib); + viewSizeHints.x,viewSizeHints.y, + viewSizeHints.width,viewSizeHints.height, + viewBorderWidth+3, + CopyFromParent,InputOutput,CopyFromParent, + viewportCreateMASK,&viewAttrib); XSetNormalHints(dsply,viewGraphWindow,&viewSizeHints); XSetStandardProperties(dsply,viewGraphWindow,"","",None,NULL,0, - &viewSizeHints); + &viewSizeHints); viewport->viewWindow = viewGraphWindow; graphWindowAttrib.width = viewSizeHints.width; graphWindowAttrib.height = viewSizeHints.height; @@ -603,7 +589,7 @@ main(void) smoothHue = viewport->hueTop*6; else { if (viewport->hueTop > 10 && viewport->hueTop < 16) - smoothHue = viewport->hueTop*20 - 140; + smoothHue = viewport->hueTop*20 - 140; else smoothHue = viewport->hueTop*12 - 12; } redoColor = yes; @@ -614,9 +600,3 @@ main(void) -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/transform3d.c.pamphlet b/src/graph/view3D/transform3d.c index 6061e70e..83d47210 100644 --- a/src/graph/view3D/transform3d.c.pamphlet +++ b/src/graph/view3D/transform3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D transform3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _TRANSFORM3D_C #include "axiom-c-macros.h" @@ -170,9 +156,3 @@ TRANSLATE(float x,float y,float z,float xxT[4][4]) xxT[2][0] = 0.0; xxT[2][1] = 0.0; xxT[2][2] = -1.0; xxT[2][3] = 0.0; xxT[3][0] = x; xxT[3][1] = y; xxT[3][2] = z; xxT[3][3] = 1.0; } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/viewport3d.c.pamphlet b/src/graph/view3D/viewport3d.c index 86869041..944b055b 100644 --- a/src/graph/view3D/viewport3d.c.pamphlet +++ b/src/graph/view3D/viewport3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D viewport3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _VIEWPORT3D_C #include "axiom-c-macros.h" @@ -61,12 +47,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "header.h" /*** definition for the axes and labels - this is the minimun that will be - drawn on the window - thus allowing the user some idea of the - orientation of the coordinate axes when rotating, etc. The - drawing of the mesh is aborted when an appropriate X event occurs. - The mesh should be scaled to the range of [-100..100] in all - directions. axisRange defines the range...change the stuff below - if that has changed. ***/ + drawn on the window - thus allowing the user some idea of the + orientation of the coordinate axes when rotating, etc. The + drawing of the mesh is aborted when an appropriate X event occurs. + The mesh should be scaled to the range of [-100..100] in all + directions. axisRange defines the range...change the stuff below + if that has changed. ***/ #include "static.h" #include "draw.h" #include "volume.h" @@ -83,7 +69,7 @@ Atom wm_delete_window; /*************************** - *** void writeTitle() *** + *** void writeTitle() *** ***************************/ void @@ -94,8 +80,8 @@ writeTitle (void) #endif { - int strlength; - XWindowAttributes twInfo; + int strlength; + XWindowAttributes twInfo; XGetWindowAttributes(dsply, viewport->titleWindow, &twInfo); if (mono || viewport->monoOn) @@ -106,29 +92,29 @@ writeTitle (void) strlength = strlen(viewport->title); GDrawImageString(anotherGC, viewport->titleWindow, - centerX(anotherGC, viewport->title, strlength, - twInfo.width), 15, - viewport->title, strlength, Xoption); + centerX(anotherGC, viewport->title, strlength, + twInfo.width), 15, + viewport->title, strlength, Xoption); } /**************************** * void drawPreViewport() * - * * + * * * draws the axes and boxes * * before the actual stuff. * - * all incoming signals * + * all incoming signals * * should be block and no * - * check for pending X * - * events are made. * - * * + * check for pending X * + * events are made. * + * * ****************************/ void #ifdef _NO_PROTO drawPreViewport (dFlag) - int dFlag; /* display flag: PS, X, etc. */ + int dFlag; /* display flag: PS, X, etc. */ #else drawPreViewport (int dFlag) #endif @@ -138,18 +124,18 @@ drawPreViewport (int dFlag) /* for drawing the box */ float vPz, absTransX, absTransY; XPoint blackbox[3], line[2]; - RGB axes_rgb, clipbox_rgb, boundbox_rgb; + RGB axes_rgb, clipbox_rgb, boundbox_rgb; - axes_rgb.r = 0.8; axes_rgb.g = 0.6; axes_rgb.b = 0.2; - clipbox_rgb.r = 0.4; clipbox_rgb.g = 0.5; clipbox_rgb.b = 0.9; + axes_rgb.r = 0.8; axes_rgb.g = 0.6; axes_rgb.b = 0.2; + clipbox_rgb.r = 0.4; clipbox_rgb.g = 0.5; clipbox_rgb.b = 0.9; boundbox_rgb.r = 0.4; boundbox_rgb.g = 0.7; boundbox_rgb.b = 0.9; XGetWindowAttributes(dsply, viewport->viewWindow, &vwInfo); graphWindowAttrib = vwInfo; - /* Calculate various factors for use in projection */ - /* Scale so that plot the scaling between the axes remains constant - and fits within the smaller of the two dimensions. */ + /* Calculate various factors for use in projection */ + /* Scale so that plot the scaling between the axes remains constant + and fits within the smaller of the two dimensions. */ xCenter = vwInfo.width / 2; yCenter = vwInfo.height / 2; @@ -161,7 +147,7 @@ drawPreViewport (int dFlag) viewScale = viewport->scale * vwInfo.width / viewWidth; } - /* Draw the projected image */ + /* Draw the projected image */ /** draw the axes without heeding to X interrupts, first **/ if (dFlag == Xoption) /* do this for X option only */ @@ -182,15 +168,15 @@ drawPreViewport (int dFlag) if ((dFlag == PSoption) && (foregroundColor == white)) { GSetForeground(globGC,(float)backgroundColor,dFlag); blackbox[0].x = vwInfo.width; blackbox[0].y = vwInfo.height; - blackbox[1].x = 0; blackbox[1].y = 0; - blackbox[2].x = 0; blackbox[2].y = vwInfo.height; + blackbox[1].x = 0; blackbox[1].y = 0; + blackbox[2].x = 0; blackbox[2].y = vwInfo.height; if (viewport->monoOn || mono) { PSFillPolygon(globGC, blackbox, 3); } else { PSColorPolygon(0.0,0.0,0.0,blackbox,4); } blackbox[0].x = vwInfo.width; blackbox[0].y = 0; - blackbox[1].x = 0; blackbox[1].y = 0; + blackbox[1].x = 0; blackbox[1].y = 0; blackbox[2].x = vwInfo.width; blackbox[2].y = vwInfo.height; if (viewport->monoOn || mono) { PSFillPolygon(globGC, blackbox, 3); @@ -208,48 +194,48 @@ drawPreViewport (int dFlag) axesXY[i][2] = vPx1; axesXY[i][3] = vPy1; axesZ[i][1] = vPz; if (viewport->axesOn) { if (viewport->monoOn || mono) { - GSetForeground(globalGC1,(float)foregroundColor,dFlag); - GSetForeground(globGC,(float)foregroundColor,dFlag); - GDrawLine(globalGC1,viewport->viewWindow,vPx0,vPy0,vPx1,vPy1,dFlag); + GSetForeground(globalGC1,(float)foregroundColor,dFlag); + GSetForeground(globGC,(float)foregroundColor,dFlag); + GDrawLine(globalGC1,viewport->viewWindow,vPx0,vPy0,vPx1,vPy1,dFlag); } else { - if (dFlag == PSoption) { - GSetForeground(globGC,(float)foregroundColor,dFlag); - line[0].x = vPx0; line[0].y = vPy0; - line[1].x = vPx1; line[1].y = vPy1; - PSDrawColor(axes_rgb.r,axes_rgb.g,axes_rgb.b,line,2); - } else { - GSetForeground(globalGC1,(float)monoColor(axesColor),dFlag); - GSetForeground(globGC,(float)monoColor(labelColor),dFlag); - GDrawLine(globalGC1,viewport->viewWindow,vPx0,vPy0,vPx1,vPy1,dFlag); - } + if (dFlag == PSoption) { + GSetForeground(globGC,(float)foregroundColor,dFlag); + line[0].x = vPx0; line[0].y = vPy0; + line[1].x = vPx1; line[1].y = vPy1; + PSDrawColor(axes_rgb.r,axes_rgb.g,axes_rgb.b,line,2); + } else { + GSetForeground(globalGC1,(float)monoColor(axesColor),dFlag); + GSetForeground(globGC,(float)monoColor(labelColor),dFlag); + GDrawLine(globalGC1,viewport->viewWindow,vPx0,vPy0,vPx1,vPy1,dFlag); + } } if (i == 0) { - if (axesXY[0][2] < axesXY[0][0]) vPx1 -= axesOffset; - else vPx1 += axesOffset; - if (axesXY[0][3] < axesXY[0][1]) vPy1 -= axesOffset; - else vPy1 += axesOffset; - if (!viewport->yzOn) - GDrawString(globGC,viewport->viewWindow,vPx1,vPy1,"X",1,dFlag); + if (axesXY[0][2] < axesXY[0][0]) vPx1 -= axesOffset; + else vPx1 += axesOffset; + if (axesXY[0][3] < axesXY[0][1]) vPy1 -= axesOffset; + else vPy1 += axesOffset; + if (!viewport->yzOn) + GDrawString(globGC,viewport->viewWindow,vPx1,vPy1,"X",1,dFlag); } else { - if (i == 1) { - if (axesXY[1][2] < axesXY[1][0]) vPx1 -= axesOffset; - else vPx1 += axesOffset; - if (axesXY[1][3] < axesXY[1][1]) vPy1 -= axesOffset; - else vPy1 += axesOffset; - if (!viewport->xzOn) - GDrawString(globGC,viewport->viewWindow,vPx1,vPy1,"Y",1,dFlag); - } else { - if (axesXY[2][2] < axesXY[2][0]) vPx1 -= axesOffset; - else vPx1 += axesOffset; - if (axesXY[2][3] < axesXY[2][1]) vPy1 -= axesOffset; - else vPy1 += axesOffset; - if (!viewport->xyOn) - GDrawString(globGC,viewport->viewWindow,vPx1,vPy1,"Z",1,dFlag); - } + if (i == 1) { + if (axesXY[1][2] < axesXY[1][0]) vPx1 -= axesOffset; + else vPx1 += axesOffset; + if (axesXY[1][3] < axesXY[1][1]) vPy1 -= axesOffset; + else vPy1 += axesOffset; + if (!viewport->xzOn) + GDrawString(globGC,viewport->viewWindow,vPx1,vPy1,"Y",1,dFlag); + } else { + if (axesXY[2][2] < axesXY[2][0]) vPx1 -= axesOffset; + else vPx1 += axesOffset; + if (axesXY[2][3] < axesXY[2][1]) vPy1 -= axesOffset; + else vPy1 += axesOffset; + if (!viewport->xyOn) + GDrawString(globGC,viewport->viewWindow,vPx1,vPy1,"Z",1,dFlag); + } } GSetForeground(globalGC1,(float)monoColor(buttonColor),dFlag); GSetForeground(globGC,(float)monoColor(buttonColor),dFlag); - } /* if viewport->axesOn */ + } /* if viewport->axesOn */ } viewport->transX = (viewData.xmax + viewData.xmin)/2.0; @@ -281,7 +267,7 @@ drawPreViewport (int dFlag) cosPhi = cos(viewport->axesphi); ROTATE(R); - /* region box */ + /* region box */ if (viewData.clipbox) { clipCorners[0].x = viewData.clipXmin; clipCorners[0].y = viewData.clipYmin; @@ -315,37 +301,37 @@ drawPreViewport (int dFlag) for (i=0;i<6;i++) { clipBox[i].inside = ((clipBox[i].pointsPtr[2]->px - - clipBox[i].pointsPtr[1]->px) * - (clipBox[i].pointsPtr[1]->py - - clipBox[i].pointsPtr[0]->py) - - (clipBox[i].pointsPtr[2]->py - - clipBox[i].pointsPtr[1]->py) * - (clipBox[i].pointsPtr[1]->px - - clipBox[i].pointsPtr[0]->px)) < 0; + clipBox[i].pointsPtr[1]->px) * + (clipBox[i].pointsPtr[1]->py - + clipBox[i].pointsPtr[0]->py) - + (clipBox[i].pointsPtr[2]->py - + clipBox[i].pointsPtr[1]->py) * + (clipBox[i].pointsPtr[1]->px - + clipBox[i].pointsPtr[0]->px)) < 0; if (clipBox[i].inside) { - for (j=0; j<3; j++) { - quadMesh[j].x = clipBox[i].pointsPtr[j]->px; - quadMesh[j].y = clipBox[i].pointsPtr[j]->py; - } - if (viewport->monoOn || mono) { - GSetForeground(trashGC,(float)foregroundColor,dFlag); - GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, - CoordModeOrigin, dFlag); - } else { - if (dFlag == PSoption) { - GSetForeground(trashGC,(float)clipBoxInline, dFlag); - line[0].x = quadMesh[0].x; line[0].y = quadMesh[0].y; - line[1].x = quadMesh[1].x; line[1].y = quadMesh[1].y; - PSDrawColor(clipbox_rgb.r,clipbox_rgb.g,clipbox_rgb.b,line,2); - line[0].x = quadMesh[1].x; line[0].y = quadMesh[1].y; - line[1].x = quadMesh[2].x; line[1].y = quadMesh[2].y; - PSDrawColor(clipbox_rgb.r,clipbox_rgb.g,clipbox_rgb.b,line,2); - } else { - GSetForeground(trashGC,(float)clipBoxInline, dFlag); - GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, - CoordModeOrigin, dFlag); - } - } + for (j=0; j<3; j++) { + quadMesh[j].x = clipBox[i].pointsPtr[j]->px; + quadMesh[j].y = clipBox[i].pointsPtr[j]->py; + } + if (viewport->monoOn || mono) { + GSetForeground(trashGC,(float)foregroundColor,dFlag); + GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, + CoordModeOrigin, dFlag); + } else { + if (dFlag == PSoption) { + GSetForeground(trashGC,(float)clipBoxInline, dFlag); + line[0].x = quadMesh[0].x; line[0].y = quadMesh[0].y; + line[1].x = quadMesh[1].x; line[1].y = quadMesh[1].y; + PSDrawColor(clipbox_rgb.r,clipbox_rgb.g,clipbox_rgb.b,line,2); + line[0].x = quadMesh[1].x; line[0].y = quadMesh[1].y; + line[1].x = quadMesh[2].x; line[1].y = quadMesh[2].y; + PSDrawColor(clipbox_rgb.r,clipbox_rgb.g,clipbox_rgb.b,line,2); + } else { + GSetForeground(trashGC,(float)clipBoxInline, dFlag); + GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, + CoordModeOrigin, dFlag); + } + } } } } /* if viewData.clipbox */ @@ -356,69 +342,69 @@ drawPreViewport (int dFlag) GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,dFlag); for (i=0;i<8;i++) { - /* project the 8 corners of the box */ - projectAPoint(&(corners[i])); - if (i) { - if (corners[i].pz > pzMax) pzMax = corners[i].pz; - else if (corners[i].pz < pzMin) pzMin = corners[i].pz; - } else - pzMax = pzMin = corners[i].pz; + /* project the 8 corners of the box */ + projectAPoint(&(corners[i])); + if (i) { + if (corners[i].pz > pzMax) pzMax = corners[i].pz; + else if (corners[i].pz < pzMin) pzMin = corners[i].pz; + } else + pzMax = pzMin = corners[i].pz; } for (i=0;i<6;i++) { - /* Process the 6 sides of the boxes. - Here, we calculate, for each side (defined by two segments) - whether it is facing towards or away from the viewer. if - facing, away, we draw them first. later we draw the ones - facing the viewer. (this is a sort of backface removal - scheme. */ - /* We define the normal vector for the box as vA X vB where - vA=p2-p0 and vB=p1-p0. All we really care about, though, - is what sign the normal is (whether it is towards or away - from the viewer - so we just take the triple product of - it against the eye vector, which is, conveniently enough, - simply [0 0 1]. Hence, only the Z component of the - cross product is calculated. (Actually, we are using the - projected normal - that's how we are able to use the - trick of just taking the Z component. */ + /* Process the 6 sides of the boxes. + Here, we calculate, for each side (defined by two segments) + whether it is facing towards or away from the viewer. if + facing, away, we draw them first. later we draw the ones + facing the viewer. (this is a sort of backface removal + scheme. */ + /* We define the normal vector for the box as vA X vB where + vA=p2-p0 and vB=p1-p0. All we really care about, though, + is what sign the normal is (whether it is towards or away + from the viewer - so we just take the triple product of + it against the eye vector, which is, conveniently enough, + simply [0 0 1]. Hence, only the Z component of the + cross product is calculated. (Actually, we are using the + projected normal - that's how we are able to use the + trick of just taking the Z component. */ box[i].inside = ((box[i].pointsPtr[2]->px - - box[i].pointsPtr[0]->px) * /* Ax * */ - (box[i].pointsPtr[1]->py - - box[i].pointsPtr[0]->py) - /* By - */ - (box[i].pointsPtr[2]->py - - box[i].pointsPtr[0]->py) * /* Ay * */ - (box[i].pointsPtr[1]->px - - box[i].pointsPtr[0]->px)) /* Bx */ - < 0; + box[i].pointsPtr[0]->px) * /* Ax * */ + (box[i].pointsPtr[1]->py - + box[i].pointsPtr[0]->py) - /* By - */ + (box[i].pointsPtr[2]->py - + box[i].pointsPtr[0]->py) * /* Ay * */ + (box[i].pointsPtr[1]->px - + box[i].pointsPtr[0]->px)) /* Bx */ + < 0; if (box[i].inside) { - for (j=0; j<3; j++) { - quadMesh[j].x = box[i].pointsPtr[j]->px; - quadMesh[j].y = box[i].pointsPtr[j]->py; - } - if (viewport->monoOn || mono) { - GSetForeground(trashGC,(float)foregroundColor,dFlag); - GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, - CoordModeOrigin, dFlag); - } else { - if (dFlag == PSoption) { - GSetForeground(trashGC,(float)boxInline, dFlag ); - line[0].x = quadMesh[0].x; line[0].y = quadMesh[0].y; - line[1].x = quadMesh[1].x; line[1].y = quadMesh[1].y; - PSDrawColor(boundbox_rgb.r,boundbox_rgb.g,boundbox_rgb.b,line,2); - line[0].x = quadMesh[1].x; line[0].y = quadMesh[1].y; - line[1].x = quadMesh[2].x; line[1].y = quadMesh[2].y; - PSDrawColor(boundbox_rgb.r,boundbox_rgb.g,boundbox_rgb.b,line,2); - } else { - GSetForeground(trashGC,(float)boxInline, dFlag ); - GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, - CoordModeOrigin, dFlag); - } - } + for (j=0; j<3; j++) { + quadMesh[j].x = box[i].pointsPtr[j]->px; + quadMesh[j].y = box[i].pointsPtr[j]->py; + } + if (viewport->monoOn || mono) { + GSetForeground(trashGC,(float)foregroundColor,dFlag); + GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, + CoordModeOrigin, dFlag); + } else { + if (dFlag == PSoption) { + GSetForeground(trashGC,(float)boxInline, dFlag ); + line[0].x = quadMesh[0].x; line[0].y = quadMesh[0].y; + line[1].x = quadMesh[1].x; line[1].y = quadMesh[1].y; + PSDrawColor(boundbox_rgb.r,boundbox_rgb.g,boundbox_rgb.b,line,2); + line[0].x = quadMesh[1].x; line[0].y = quadMesh[1].y; + line[1].x = quadMesh[2].x; line[1].y = quadMesh[2].y; + PSDrawColor(boundbox_rgb.r,boundbox_rgb.g,boundbox_rgb.b,line,2); + } else { + GSetForeground(trashGC,(float)boxInline, dFlag ); + GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, + CoordModeOrigin, dFlag); + } + } } } } /* if viewData.box */ - /* Write out view data */ + /* Write out view data */ if (dFlag == Xoption) { /* do this only for X option */ writeControlMessage(); XFlush(dsply); @@ -433,17 +419,17 @@ drawPreViewport (int dFlag) void #ifdef _NO_PROTO drawTheViewport (dFlag) - int dFlag; /* display flag: PS, X,... */ + int dFlag; /* display flag: PS, X,... */ #else drawTheViewport (int dFlag) #endif { - int i,j; + int i,j; XPoint line[2]; - RGB clipbox_rgb, boundbox_rgb; + RGB clipbox_rgb, boundbox_rgb; - clipbox_rgb.r = 0.4; clipbox_rgb.g = 0.5; clipbox_rgb.b = 0.9; + clipbox_rgb.r = 0.4; clipbox_rgb.g = 0.5; clipbox_rgb.b = 0.9; boundbox_rgb.r = 0.4; boundbox_rgb.g = 0.7; boundbox_rgb.b = 0.9; /**** Draw Routine ****/ @@ -464,29 +450,29 @@ drawTheViewport (int dFlag) GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,dFlag); for (i=0; i<6; i++) { if (!(clipBox[i].inside)) { - for (j=0; j<4; j++) { - quadMesh[j].x = clipBox[i].pointsPtr[j]->px; - quadMesh[j].y = clipBox[i].pointsPtr[j]->py; - } - if (viewport->monoOn || mono) { - GSetForeground(trashGC,(float)foregroundColor,dFlag); - GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, - CoordModeOrigin, dFlag); - } else { - if (dFlag == PSoption) { - GSetForeground(trashGC,(float)boxInline, dFlag ); - line[0].x = quadMesh[0].x; line[0].y = quadMesh[0].y; - line[1].x = quadMesh[1].x; line[1].y = quadMesh[1].y; - PSDrawColor(clipbox_rgb.r,clipbox_rgb.g,clipbox_rgb.b,line,2); - line[0].x = quadMesh[1].x; line[0].y = quadMesh[1].y; - line[1].x = quadMesh[2].x; line[1].y = quadMesh[2].y; - PSDrawColor(clipbox_rgb.r,clipbox_rgb.g,clipbox_rgb.b,line,2); - } else { - GSetForeground(trashGC,(float)boxInline, dFlag ); - GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, - CoordModeOrigin, dFlag); - } - } + for (j=0; j<4; j++) { + quadMesh[j].x = clipBox[i].pointsPtr[j]->px; + quadMesh[j].y = clipBox[i].pointsPtr[j]->py; + } + if (viewport->monoOn || mono) { + GSetForeground(trashGC,(float)foregroundColor,dFlag); + GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, + CoordModeOrigin, dFlag); + } else { + if (dFlag == PSoption) { + GSetForeground(trashGC,(float)boxInline, dFlag ); + line[0].x = quadMesh[0].x; line[0].y = quadMesh[0].y; + line[1].x = quadMesh[1].x; line[1].y = quadMesh[1].y; + PSDrawColor(clipbox_rgb.r,clipbox_rgb.g,clipbox_rgb.b,line,2); + line[0].x = quadMesh[1].x; line[0].y = quadMesh[1].y; + line[1].x = quadMesh[2].x; line[1].y = quadMesh[2].y; + PSDrawColor(clipbox_rgb.r,clipbox_rgb.g,clipbox_rgb.b,line,2); + } else { + GSetForeground(trashGC,(float)boxInline, dFlag ); + GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, + CoordModeOrigin, dFlag); + } + } } } } @@ -495,29 +481,29 @@ drawTheViewport (int dFlag) GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,dFlag); for (i=0; i<6; i++) { if (!(box[i].inside)) { - for (j=0; j<4; j++) { - quadMesh[j].x = box[i].pointsPtr[j]->px; - quadMesh[j].y = box[i].pointsPtr[j]->py; - } - if (viewport->monoOn || mono) { - GSetForeground(trashGC,(float)foregroundColor,dFlag); - GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, - CoordModeOrigin, dFlag); - } else { - if (dFlag == PSoption) { - GSetForeground(trashGC,(float)boxInline, dFlag ); - line[0].x = quadMesh[0].x; line[0].y = quadMesh[0].y; - line[1].x = quadMesh[1].x; line[1].y = quadMesh[1].y; - PSDrawColor(boundbox_rgb.r,boundbox_rgb.g,boundbox_rgb.b,line,2); - line[0].x = quadMesh[1].x; line[0].y = quadMesh[1].y; - line[1].x = quadMesh[2].x; line[1].y = quadMesh[2].y; - PSDrawColor(boundbox_rgb.r,boundbox_rgb.g,boundbox_rgb.b,line,2); - } else { - GSetForeground(trashGC,(float)boxInline, dFlag ); - GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, - CoordModeOrigin, dFlag); - } - } + for (j=0; j<4; j++) { + quadMesh[j].x = box[i].pointsPtr[j]->px; + quadMesh[j].y = box[i].pointsPtr[j]->py; + } + if (viewport->monoOn || mono) { + GSetForeground(trashGC,(float)foregroundColor,dFlag); + GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, + CoordModeOrigin, dFlag); + } else { + if (dFlag == PSoption) { + GSetForeground(trashGC,(float)boxInline, dFlag ); + line[0].x = quadMesh[0].x; line[0].y = quadMesh[0].y; + line[1].x = quadMesh[1].x; line[1].y = quadMesh[1].y; + PSDrawColor(boundbox_rgb.r,boundbox_rgb.g,boundbox_rgb.b,line,2); + line[0].x = quadMesh[1].x; line[0].y = quadMesh[1].y; + line[1].x = quadMesh[2].x; line[1].y = quadMesh[2].y; + PSDrawColor(boundbox_rgb.r,boundbox_rgb.g,boundbox_rgb.b,line,2); + } else { + GSetForeground(trashGC,(float)boxInline, dFlag ); + GDrawLines(trashGC, viewport->viewWindow, quadMesh, 3, + CoordModeOrigin, dFlag); + } + } } } } @@ -545,16 +531,16 @@ makeViewport (void) #endif { - Pixmap spadbits,spadmask; + Pixmap spadbits,spadmask; XSetWindowAttributes viewAttrib; - XSizeHints titleSizeHints; - Window viewTitleWindow, viewGraphWindow; - XColor foreColor, backColor; + XSizeHints titleSizeHints; + Window viewTitleWindow, viewGraphWindow; + XColor foreColor, backColor; - /**** create a viewport ****/ + /**** create a viewport ****/ if (!(viewport = (viewPoints *)saymem("viewport3D.c", - 1,sizeof(viewPoints)))) { + 1,sizeof(viewPoints)))) { fprintf(stderr,"Ran out of memory trying to create a viewport.\n"); exitWithAck(RootWindow(dsply,scrn),Window,-1); } @@ -564,56 +550,56 @@ makeViewport (void) I[2][0] = 0.0; I[2][1] = 0.0; I[2][2] = 1.0; I[2][3] = 0.0; I[3][0] = 0.0; I[3][1] = 0.0; I[3][2] = 0.0; I[3][3] = 1.0; - viewport->viewportKey = viewportKeyNum++; + viewport->viewportKey = viewportKeyNum++; viewport->nextViewport = 0; viewport->prevViewport = 0; - viewport->deltaX = viewport->deltaX0 = viewData.deltaX; - viewport->deltaY = viewport->deltaY0 = viewData.deltaY; - viewport->deltaZ = viewport->deltaZ0 = viewData.deltaZ; - viewport->scale = viewport->scale0 = viewData.scale; - viewport->scaleX = viewData.scaleX; - viewport->scaleY = viewData.scaleY; - viewport->scaleZ = viewData.scaleZ; - viewport->transX = (viewData.xmax + viewData.xmin)/2.0; - viewport->transY = (viewData.ymax + viewData.ymin)/2.0; - viewport->transZ = (viewData.zmax + viewData.zmin)/2.0; + viewport->deltaX = viewport->deltaX0 = viewData.deltaX; + viewport->deltaY = viewport->deltaY0 = viewData.deltaY; + viewport->deltaZ = viewport->deltaZ0 = viewData.deltaZ; + viewport->scale = viewport->scale0 = viewData.scale; + viewport->scaleX = viewData.scaleX; + viewport->scaleY = viewData.scaleY; + viewport->scaleZ = viewData.scaleZ; + viewport->transX = (viewData.xmax + viewData.xmin)/2.0; + viewport->transY = (viewData.ymax + viewData.ymin)/2.0; + viewport->transZ = (viewData.zmax + viewData.zmin)/2.0; viewport->theta = viewport->axestheta = viewport->theta0 = viewData.theta; - viewport->phi = viewport->axesphi = viewport->phi0 = viewData.phi; + viewport->phi = viewport->axesphi = viewport->phi0 = viewData.phi; viewport->thetaObj = 0.0; viewport->phiObj = 0.0; strcpy(viewport->title,viewData.title); - viewport->axesOn = yes; - viewport->regionOn = no; - viewport->monoOn = no; - viewport->zoomXOn = yes; - viewport->zoomYOn = yes; - viewport->zoomZOn = yes; + viewport->axesOn = yes; + viewport->regionOn = no; + viewport->monoOn = no; + viewport->zoomXOn = yes; + viewport->zoomYOn = yes; + viewport->zoomZOn = yes; - viewport->originrOn = yes; - viewport->objectrOn = no; - viewport->originFlag = no; + viewport->originrOn = yes; + viewport->objectrOn = no; + viewport->originFlag = no; - viewport->xyOn = no; - viewport->xzOn = no; - viewport->yzOn = no; + viewport->xyOn = no; + viewport->xzOn = no; + viewport->yzOn = no; - viewport->closing = no; - viewport->allowDraw = yes; /*if no, just draw axes the first time */ - viewport->needNorm = yes; + viewport->closing = no; + viewport->allowDraw = yes; /*if no, just draw axes the first time */ + viewport->needNorm = yes; viewport->lightVector[0] = -0.5; viewport->lightVector[1] = 0.5; viewport->lightVector[2] = 0.5; viewport->translucency = viewData.translucency; - viewport->hueOffset = viewData.hueOff; + viewport->hueOffset = viewData.hueOff; viewport->numberOfHues = viewData.numOfHues; - viewport->hueTop = viewData.hueOff + viewData.numOfHues; + viewport->hueTop = viewData.hueOff + viewData.numOfHues; if (viewport->hueTop > totalHues-1) viewport->hueTop = totalHues-1; - viewport->diagonals = viewData.diagonals; + viewport->diagonals = viewData.diagonals; /* make theta in [0..2pi) and phi in (-pi..pi] */ while (viewport->theta >= two_pi) { @@ -654,20 +640,20 @@ makeViewport (void) cosTheta = cos(-viewport->thetaObj); sinPhi = sin(viewport->phiObj); cosPhi = cos(viewport->phiObj); - ROTATE1(R1); /* angles theta and phi are global */ + ROTATE1(R1); /* angles theta and phi are global */ /* Initialize the non-uniform scaling matrix. */ SCALE(viewport->scaleX,viewport->scaleY,viewport->scaleZ,S); /* Initialize the translation matrix. */ TRANSLATE(-viewport->deltaX,-viewport->deltaY,0.0,T); - /**** make the windows for the viewport ****/ + /**** make the windows for the viewport ****/ spadbits = XCreateBitmapFromData(dsply,rtWindow, - spadBitmap_bits, - spadBitmap_width,spadBitmap_height); + spadBitmap_bits, + spadBitmap_width,spadBitmap_height); spadmask = XCreateBitmapFromData(dsply,rtWindow, - spadMask_bits, - spadMask_width,spadMask_height); + spadMask_bits, + spadMask_width,spadMask_height); viewAttrib.background_pixel = backgroundColor; viewAttrib.border_pixel = foregroundColor; @@ -683,12 +669,12 @@ makeViewport (void) XQueryColor(dsply,colorMap,&foreColor); XQueryColor(dsply,colorMap,&backColor); viewAttrib.cursor = XCreatePixmapCursor(dsply,spadbits,spadmask, - &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot); + &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot); viewAttrib.event_mask = titleMASK; if (viewData.vW) { titleSizeHints.flags = PPosition | PSize; - titleSizeHints.x = viewData.vX; - titleSizeHints.y = viewData.vY; + titleSizeHints.x = viewData.vX; + titleSizeHints.y = viewData.vY; titleSizeHints.width = viewData.vW; titleSizeHints.height = viewData.vH; } else { /* ain't gonna allow this for now... */ @@ -698,17 +684,17 @@ makeViewport (void) } viewTitleWindow = XCreateWindow(dsply /* display */, - rtWindow, /* parent */ - viewData.vX, /* x */ - viewData.vY, /* y */ - viewData.vW, /* width */ - viewData.vH, /* height */ - /* viewBorderWidth+3*/ 0, /* border width */ - CopyFromParent, /* depth */ - InputOutput, /* class */ - CopyFromParent, /* visual */ - viewportTitleCreateMASK,/* valuemask */ - &viewAttrib /* attributes */); + rtWindow, /* parent */ + viewData.vX, /* x */ + viewData.vY, /* y */ + viewData.vW, /* width */ + viewData.vH, /* height */ + /* viewBorderWidth+3*/ 0, /* border width */ + CopyFromParent, /* depth */ + InputOutput, /* class */ + CopyFromParent, /* visual */ + viewportTitleCreateMASK,/* valuemask */ + &viewAttrib /* attributes */); wm_delete_window = XInternAtom(dsply, "WM_DELETE_WINDOW", False); (void) XSetWMProtocols(dsply, viewTitleWindow, &wm_delete_window, 1); @@ -716,35 +702,35 @@ makeViewport (void) XSetNormalHints(dsply,viewTitleWindow,&titleSizeHints); if (strlen(viewport->title) < 30) XSetStandardProperties(dsply,viewTitleWindow,"AXIOM 3D",viewport->title, - None,NULL,0,&titleSizeHints); + None,NULL,0,&titleSizeHints); else XSetStandardProperties(dsply,viewTitleWindow,"AXIOM 3D","3D AXIOM Graph", - None,NULL,0,&titleSizeHints); + None,NULL,0,&titleSizeHints); viewport->titleWindow = viewTitleWindow; viewAttrib.event_mask = viewportMASK; - viewSizeHints.flags = PPosition | PSize; - viewSizeHints.x = -(viewBorderWidth+3); - viewSizeHints.x = 0; /* lose this */ - viewSizeHints.y = titleHeight; - viewSizeHints.width = titleSizeHints.width; - viewSizeHints.height = titleSizeHints.height-(titleHeight+appendixHeight); + viewSizeHints.flags = PPosition | PSize; + viewSizeHints.x = -(viewBorderWidth+3); + viewSizeHints.x = 0; /* lose this */ + viewSizeHints.y = titleHeight; + viewSizeHints.width = titleSizeHints.width; + viewSizeHints.height = titleSizeHints.height-(titleHeight+appendixHeight); viewGraphWindow = XCreateWindow(dsply, /* display */ - viewTitleWindow, /* parent */ - viewSizeHints.x, /* x */ - viewSizeHints.y, /* y */ - viewSizeHints.width, /* width */ - viewSizeHints.height, /* height */ - /* viewBorderWidth+3*/0, /* border width */ - CopyFromParent, /* depth */ - InputOutput, /* class */ - CopyFromParent, /* visual */ - viewportCreateMASK, /* valuemask */ - &viewAttrib /* attributes */); + viewTitleWindow, /* parent */ + viewSizeHints.x, /* x */ + viewSizeHints.y, /* y */ + viewSizeHints.width, /* width */ + viewSizeHints.height, /* height */ + /* viewBorderWidth+3*/0, /* border width */ + CopyFromParent, /* depth */ + InputOutput, /* class */ + CopyFromParent, /* visual */ + viewportCreateMASK, /* valuemask */ + &viewAttrib /* attributes */); XSetNormalHints(dsply,viewGraphWindow,&viewSizeHints); XSetStandardProperties(dsply,viewGraphWindow,"","",None,NULL,0, - &viewSizeHints); + &viewSizeHints); viewport->viewWindow = viewGraphWindow; graphWindowAttrib.width = viewSizeHints.width; graphWindowAttrib.height = viewSizeHints.height; @@ -757,13 +743,13 @@ makeViewport (void) smoothHue = viewport->hueTop*6; else { if (viewport->hueTop > 10 && viewport->hueTop < 16) - smoothHue = viewport->hueTop*20 - 140; + smoothHue = viewport->hueTop*20 - 140; else smoothHue = viewport->hueTop*12 - 12; } redoColor = yes; } - /**** Make the control panel for the viewport. ****/ + /**** Make the control panel for the viewport. ****/ XSync(dsply,0); @@ -784,9 +770,9 @@ makeViewport (void) /***************************** * void postMakeViewport() * - * * - * post processing when * - * creating a viewport. * + * * + * post processing when * + * creating a viewport. * * 1) assign min,max values * * for the box volume * *****************************/ @@ -903,16 +889,16 @@ keepDrawingViewport(void) if (XPending(dsply)) { XPeekEvent(dsply,&peekEvent); if (((peekEvent.type == Expose) && - ((peekEvent.xany).window == viewport->viewWindow)) || - ((peekEvent.type == Expose) && - ((peekEvent.xany).window == viewport->titleWindow)) || - ((peekEvent.type == Expose) && - ((peekEvent.xany).window == control->controlWindow))) { + ((peekEvent.xany).window == viewport->viewWindow)) || + ((peekEvent.type == Expose) && + ((peekEvent.xany).window == viewport->titleWindow)) || + ((peekEvent.type == Expose) && + ((peekEvent.xany).window == control->controlWindow))) { retVal = firstTime; } else if ((peekEvent.xbutton.type == ButtonRelease) || - ((peekEvent.type == LeaveNotify) && !(followMouse)) || - ((peekEvent.type == MotionNotify) && !(followMouse)) || - (peekEvent.type == ResizeRequest)) { + ((peekEvent.type == LeaveNotify) && !(followMouse)) || + ((peekEvent.type == MotionNotify) && !(followMouse)) || + (peekEvent.type == ResizeRequest)) { XNextEvent(dsply,&peekEvent); followMouse = no; retVal = yes; @@ -932,9 +918,3 @@ keepDrawingViewport(void) return(retVal); } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/volume.h b/src/graph/view3D/volume.h index 35d60c42..8f21071c 100755..100644 --- a/src/graph/view3D/volume.h +++ b/src/graph/view3D/volume.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /*#define rightLeft*/ diff --git a/src/graph/view3D/volume3d.c b/src/graph/view3D/volume3d.c new file mode 100644 index 00000000..aab93491 --- /dev/null +++ b/src/graph/view3D/volume3d.c @@ -0,0 +1,879 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VOLUME3D_C +#include "axiom-c-macros.h" + +#include <math.h> +#include <string.h> + +#include "header.h" +#include "cpanel.h" +#include "process.h" +#include "volume.h" +#include "../include/purty/volume.bitmap" +#include "../include/purty/volume.mask" + + + +#include "XSpadFill.H1" +#include "Gfun.H1" +#include "all_3d.H1" + +#define eyeDistMessX (frusX(eyeWinX+27)) +#define eyeDistMessY (frusY(eyeWinY-5)) +#define hitherMessX (frusX(hitherWinX+15)) +#define hitherMessY (frusY(hitherWinY)) + +#define clipXMessX (control->buttonQueue[clipXBut].buttonX + \ + control->buttonQueue[clipXBut].xHalf) +#define clipXMessY (control->buttonQueue[clipXBut].buttonY + 2) +#define clipYMessX (control->buttonQueue[clipYBut].buttonX + \ + control->buttonQueue[clipYBut].buttonWidth-2) +#define clipYMessY (control->buttonQueue[clipYBut].buttonY + \ + control->buttonQueue[clipYBut].yHalf) +#define clipZMessX (control->buttonQueue[clipZBut].buttonX + \ + control->buttonQueue[clipZBut].xHalf+4) +#define clipZMessY (control->buttonQueue[clipZBut].buttonY + \ + control->buttonQueue[clipZBut].yHalf-4) + +#define volumeCursorForeground monoColor(68) +#define volumeCursorBackground monoColor(197) + +#define hitherBoxColor monoColor(141) +#define hitherBoxTop (frustrumMidY - 10) +#define hitherBoxHeight 20 + +#define clipButtonColor 144 +#define toggleColor 42 +#define arcColor 75 + +#define arcSize 6 +#define tinyArc 5 +#define blank 4 +#define toggleX 190 +#define toggleY 280 + +#define oldWay + +#define frusX(x) (control->buttonQueue[frustrumBut].buttonX + x) +#define frusY(y) (control->buttonQueue[frustrumBut].buttonY + y) + +#define clipMessX 7 +#define clipMessY (control->buttonQueue[clipXBut].buttonY + 15) + /* someotherFont holds title font (see main.c) */ +#define clipMessDy (globalFont->max_bounds.ascent/2 + \ + globalFont->max_bounds.descent) +static char *clipMess = "Clip Volume"; + +#define eyeMess1Dy clipMessDy +#define eyeMess1X 7 +#define eyeMess1Y (frustrumY + 40 + 3*eyeMess1Dy) +static char *eyeMess1 = "Eye"; + +#define eyeMess2X (globalFont->max_bounds.width + 14) +#define eyeMess2Y (frustrumY + 40) +#define eyeMess2Dy eyeMess1Dy +static char *eyeMess2 = "Reference"; + + + /* global stuff */ +int flatClipBoxX[8], flatClipBoxY[8]; + + + + +/******************* volume buttons **********************/ + +int +#ifdef _NO_PROTO +initVolumeButtons (volumeButtons) + buttonStruct *volumeButtons; +#else +initVolumeButtons (buttonStruct *volumeButtons) +#endif +{ + int ii, num = 0; + + ii = volumeReturn; + volumeButtons[ii].buttonX = 154; + volumeButtons[ii].buttonY = 370; + volumeButtons[ii].buttonWidth = 110; + volumeButtons[ii].buttonHeight = 24; + volumeButtons[ii].buttonKey = ii; + volumeButtons[ii].pot = no; + volumeButtons[ii].mask = buttonMASK; + volumeButtons[ii].text = "Return"; + volumeButtons[ii].textColor = 52; + volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; + volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; + ++num; + + ii = volumeAbort; + volumeButtons[ii].buttonX = 36; + volumeButtons[ii].buttonY = 370; + volumeButtons[ii].buttonWidth = 110; + volumeButtons[ii].buttonHeight = 24; + volumeButtons[ii].buttonKey = ii; + volumeButtons[ii].pot = no; + volumeButtons[ii].mask = buttonMASK; + volumeButtons[ii].text = "Abort"; + volumeButtons[ii].textColor = 28; + volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; + volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; + ++num; + + ii = frustrumBut; + volumeButtons[ii].buttonX = frustrumWindowX; + volumeButtons[ii].buttonY = frustrumWindowY; + volumeButtons[ii].buttonWidth = frustrumWindowWidth; + volumeButtons[ii].buttonHeight = frustrumWindowHeight; + volumeButtons[ii].buttonKey = ii; + volumeButtons[ii].pot = yes; + volumeButtons[ii].mask = potMASK; + volumeButtons[ii].text = "Frustrum Window"; + volumeButtons[ii].textColor = frustrumColor; + volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; + volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; + ++num; + + ii = perspectiveBut; + volumeButtons[ii].buttonX = toggleX; + volumeButtons[ii].buttonY = toggleY; + volumeButtons[ii].buttonWidth = 10; + volumeButtons[ii].buttonHeight = 10; + volumeButtons[ii].buttonKey = ii; + volumeButtons[ii].pot = no; + volumeButtons[ii].mask = potMASK; + volumeButtons[ii].text = "Perspective"; + volumeButtons[ii].textColor = arcColor; + volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; + volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; + ++num; + + ii = clipRegionBut; + volumeButtons[ii].buttonX = toggleX; + volumeButtons[ii].buttonY = toggleY+20; + volumeButtons[ii].buttonWidth = 10; + volumeButtons[ii].buttonHeight = 10; + volumeButtons[ii].buttonKey = ii; + volumeButtons[ii].pot = no; + volumeButtons[ii].mask = potMASK; + volumeButtons[ii].text = "Show Region"; + volumeButtons[ii].textColor = arcColor; + volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; + volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; + ++num; + + ii = clipSurfaceBut; + volumeButtons[ii].buttonX = toggleX; + volumeButtons[ii].buttonY = toggleY+40; + volumeButtons[ii].buttonWidth = 10; + volumeButtons[ii].buttonHeight = 10; + volumeButtons[ii].buttonKey = ii; + volumeButtons[ii].pot = no; + volumeButtons[ii].mask = potMASK; + volumeButtons[ii].text = "Clipping On"; + volumeButtons[ii].textColor = arcColor; + volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; + volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; + ++num; + + ii = clipXBut; + volumeButtons[ii].buttonX = clipXButX; + volumeButtons[ii].buttonY = clipXButY; + volumeButtons[ii].buttonWidth = majorAxis; + volumeButtons[ii].buttonHeight = minorAxis; + volumeButtons[ii].buttonKey = ii; + volumeButtons[ii].pot = yes; + volumeButtons[ii].mask = potMASK; + volumeButtons[ii].text = "Clip X"; + volumeButtons[ii].textColor = clipButtonColor; + volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; + volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; + ++num; + + ii = clipYBut; + volumeButtons[ii].buttonX = clipYButX; + volumeButtons[ii].buttonY = clipYButY; + volumeButtons[ii].buttonWidth = minorAxis; + volumeButtons[ii].buttonHeight = majorAxis; + volumeButtons[ii].buttonKey = ii; + volumeButtons[ii].pot = yes; + volumeButtons[ii].mask = potMASK; + volumeButtons[ii].text = "Clip Y"; + volumeButtons[ii].textColor = clipButtonColor; + volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; + volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; + ++num; + + ii = clipZBut; + volumeButtons[ii].buttonX = clipZButX; + volumeButtons[ii].buttonY = clipZButY; + volumeButtons[ii].buttonWidth = midAxis; + volumeButtons[ii].buttonHeight = midAxis; + volumeButtons[ii].buttonKey = ii; + volumeButtons[ii].pot = yes; + volumeButtons[ii].mask = potMASK; + volumeButtons[ii].text = "Clip Z"; + volumeButtons[ii].textColor = clipButtonColor; + volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; + volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; + ++num; + + return(num); +} + + +/************************* + * int makeVolumePanel() * + *************************/ + +void +#ifdef _NO_PROTO +makeVolumePanel () +#else +makeVolumePanel (void) +#endif +{ + + int i; + XSetWindowAttributes cwAttrib, controlAttrib; + XSizeHints sizehint; + Pixmap volumebits, volumemask; + XColor foreColor, backColor; + + volumebits = XCreateBitmapFromData(dsply,rtWindow,volumeBitmap_bits, + volumeBitmap_width,volumeBitmap_height); + volumemask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits, + volumeMask_width,volumeMask_height); + cwAttrib.background_pixel = backgroundColor; + cwAttrib.border_pixel = foregroundColor; + cwAttrib.event_mask = volumeMASK; + cwAttrib.colormap = colorMap; + cwAttrib.override_redirect = overrideManager; + foreColor.pixel = volumeCursorForeground; + XQueryColor(dsply,colorMap,&foreColor); + backColor.pixel = volumeCursorBackground; + XQueryColor(dsply,colorMap,&backColor); + cwAttrib.cursor = XCreatePixmapCursor(dsply,volumebits,volumemask, + &foreColor,&backColor, + volumeBitmap_x_hot, + volumeBitmap_y_hot); + volumeWindow = XCreateWindow(dsply,control->controlWindow, + -3,-3,controlWidth,controlHeight,3, + CopyFromParent,InputOutput,CopyFromParent, + controlCreateMASK,&cwAttrib); + + sizehint.flags = USPosition | USSize; + sizehint.x = 0; + sizehint.y = 0; + sizehint.width = controlWidth; + sizehint.height = controlHeight; + /*** the None stands for icon pixmap ***/ + XSetNormalHints(dsply,volumeWindow,&sizehint); + XSetStandardProperties(dsply,volumeWindow,"Volume Panel 3D", + "View Volume",None,NULL,0,&sizehint); + + /*** volume frustrum window ***/ + + /*** do volume buttons ***/ + initVolumeButtons(control->buttonQueue); + for (i=volumeButtonsStart; i<(volumeButtonsEnd); i++) { + controlAttrib.event_mask = (control->buttonQueue[i]).mask; + (control->buttonQueue[i]).self = + XCreateWindow(dsply,volumeWindow, + (control->buttonQueue[i]).buttonX, + (control->buttonQueue[i]).buttonY, + (control->buttonQueue[i]).buttonWidth, + (control->buttonQueue[i]).buttonHeight, + 0,0,InputOnly,CopyFromParent, + buttonCreateMASK,&controlAttrib); + XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, + &((control->buttonQueue[i]).buttonKey)); + XMapWindow(dsply,(control->buttonQueue[i]).self); + } + +} /* makeVolumePanel() */ + + +void +#ifdef _NO_PROTO +drawClipXBut () +#else +drawClipXBut (void) +#endif +{ + + 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 +#ifdef _NO_PROTO +drawClipYBut () +#else +drawClipYBut (void) +#endif +{ + + 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 +#ifdef _NO_PROTO +drawClipZBut () +#else +drawClipZBut (void) +#endif +{ + + 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 +#ifdef _NO_PROTO +drawClipVolume () +#else +drawClipVolume (void) +#endif +{ + + float xminL,xmaxL,yminL,ymaxL,zminL,zmaxL; + + XClearArea(dsply,volumeWindow,backFaceX-1,backFaceY, + lengthFace+deltaFace+2,lengthFace+deltaFace+1,False); + + GSetForeground(trashGC,(float)boxInline,Xoption); /*boxOutline=133*/ + GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,Xoption); + + /* define corners of volume, clockwise, back to front */ + xminL = xClipMinN*lengthFace; + xmaxL = xClipMaxN*lengthFace; + yminL = yClipMinN*lengthFace; + ymaxL = yClipMaxN*lengthFace; + zminL = zClipMinN*zLength; + zmaxL = (1-zClipMaxN)*zLength; /* percentage upwards from bottom */ + + flatClipBoxX[0] = backFaceX + xminL + zminL; + flatClipBoxY[0] = backFaceY + yminL + zminL; + flatClipBoxX[1] = backFaceX + xmaxL + zminL; + flatClipBoxY[1] = flatClipBoxY[0]; + flatClipBoxX[2] = flatClipBoxX[1]; + flatClipBoxY[2] = backFaceY + ymaxL + zminL; + flatClipBoxX[3] = flatClipBoxX[0]; + flatClipBoxY[3] = flatClipBoxY[2]; + flatClipBoxX[4] = frontFaceX + xminL - zmaxL; + flatClipBoxY[4] = frontFaceY + yminL - zmaxL; + flatClipBoxX[5] = frontFaceX + xmaxL - zmaxL; + flatClipBoxY[5] = flatClipBoxY[4]; + flatClipBoxX[6] = flatClipBoxX[5]; + flatClipBoxY[6] = frontFaceY + ymaxL - zmaxL; + flatClipBoxX[7] = flatClipBoxX[4]; + flatClipBoxY[7] = flatClipBoxY[6]; + + /* now draw the volume */ + GDrawRectangle(trashGC,volumeWindow, + flatClipBoxX[0],flatClipBoxY[0], + flatClipBoxX[2]-flatClipBoxX[0], + flatClipBoxY[2]-flatClipBoxY[0],Xoption); + GDrawLine(trashGC,volumeWindow, + flatClipBoxX[0],flatClipBoxY[0],flatClipBoxX[4],flatClipBoxY[4],Xoption); + GDrawLine(trashGC,volumeWindow, + flatClipBoxX[1],flatClipBoxY[1],flatClipBoxX[5],flatClipBoxY[5],Xoption); + GDrawLine(trashGC,volumeWindow, + flatClipBoxX[2],flatClipBoxY[2],flatClipBoxX[6],flatClipBoxY[6],Xoption); + GDrawLine(trashGC,volumeWindow, + flatClipBoxX[3],flatClipBoxY[3],flatClipBoxX[7],flatClipBoxY[7],Xoption); + GSetForeground(trashGC,(float)boxOutline,Xoption); + GDrawRectangle(trashGC,volumeWindow, + flatClipBoxX[4],flatClipBoxY[4], + flatClipBoxX[6]-flatClipBoxX[4], + flatClipBoxY[6]-flatClipBoxY[4],Xoption); + /* make sure volumeGC is set properly before calling these functions */ + +} /* drawClipVolume() */ + + +void +#ifdef _NO_PROTO +drawHitherControl () +#else +drawHitherControl (void) +#endif +{ + + float xx,b,slope; + int hitherTop, hitherBot; + + float b0x,b1x; + + /* draw box indicating minimum and maximum distance of projection */ + GSetForeground(trashGC,(float)hitherBoxColor,Xoption); + b0x = (pzMin - clipPlaneMin)/(clipPlaneMax-clipPlaneMin); + b0x = hitherMaxX - b0x*(hitherMaxX - hitherMinX); /* screen x */ + b1x = (pzMax - clipPlaneMin)/(clipPlaneMax-clipPlaneMin); + b1x = hitherMaxX - b1x*(hitherMaxX - hitherMinX); /* screen x */ + GDraw3DButtonOut(trashGC,volumeWindow, + (int)(b0x),frusY(hitherBoxTop), + (int)fabs(b1x-b0x),hitherBoxHeight,Xoption); + + /* draw the hither plane */ + GSetForeground(trashGC,(float)hitherColor,Xoption); + + /* percentage x */ + xx = ((viewData.clipPlane-clipPlaneMin)/(clipPlaneMax-clipPlaneMin)); + xx = hitherMaxX - xx*(hitherMaxX - hitherMinX); /* screen x */ + slope = ((float)frustrumY - frustrumMidY)/(frustrumX - frustrumVertex); + b = ((float)frustrumX*frustrumMidY - frustrumVertex*frustrumY) / + (frustrumX - frustrumVertex); + hitherTop = slope * xx + b + 0.5; + slope = (float)(frustrumBotY - frustrumMidY)/(frustrumX - frustrumVertex); + b = ((float)frustrumX*frustrumMidY - frustrumVertex*frustrumBotY) / + (frustrumX - frustrumVertex); + hitherBot = slope * xx + b + 0.5; + GDrawLine(trashGC,volumeWindow, frusX((int)xx),frusY(hitherTop), + frusX((int)xx),frusY(hitherBot),Xoption); + + /* draw hither control box and bar */ + GDraw3DButtonOut(trashGC,volumeWindow, + frusX(hitherWinX),frusY(hitherWinY+5), + hitherWidth,hitherHeight,Xoption); + GDrawLine(trashGC,volumeWindow, + frusX(hitherMinX),frusY(hitherBarY+5), + frusX(hitherMaxX),frusY(hitherBarY+5),Xoption); + /* draw hither plane I/O pointer arrow */ + + GDrawLine(trashGC,volumeWindow, + frusX((int)xx),frusY(hitherBarY+2), + frusX((int)xx),frusY(hitherBarY+8),Xoption); + + /* print string label */ + GSetForeground(volumeGC,(float)hitherColor,Xoption); + GDrawString(volumeGC,volumeWindow,hitherMessX,hitherMessY,"Hither",6,Xoption); + +} + +void +#ifdef _NO_PROTO +drawEyeControl () +#else +drawEyeControl (void) +#endif +{ + + 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 drawFrustrum() * + **************************/ + +void +#ifdef _NO_PROTO +drawFrustrum () +#else +drawFrustrum (void) +#endif +{ + + float normalizedEyeDistance; + + XClearArea(dsply,volumeWindow, + control->buttonQueue[frustrumBut].buttonX, + control->buttonQueue[frustrumBut].buttonY, + control->buttonQueue[frustrumBut].buttonWidth+9, + control->buttonQueue[frustrumBut].buttonHeight,False); + GSetForeground(trashGC,(float)frustrumColor,Xoption); + normalizedEyeDistance = (viewData.eyeDistance - minEyeDistance) / + (maxEyeDistance - minEyeDistance); + normalizedEyeDistance = pow((double)normalizedEyeDistance,0.333333333); + frustrumVertex = normalizedEyeDistance * (frustrumMax - frustrumMin) + + frustrumMin - 4; + GDrawLine(trashGC,volumeWindow, + frusX(frustrumX),frusY(frustrumY), + frusX(frustrumX),frusY(frustrumY+frustrumLength),Xoption); + GDrawLine(trashGC,volumeWindow, + frusX(frustrumX),frusY(frustrumY), + frusX(frustrumVertex),frusY(frustrumMidY),Xoption); + GDrawLine(trashGC,volumeWindow, + frusX(frustrumX),frusY(frustrumBotY), + frusX(frustrumVertex),frusY(frustrumMidY),Xoption); + + /* draw controls */ + drawHitherControl(); + drawEyeControl(); + +} /* drawFrustrum() */ + + + +/************************** + * void drawVolumePanel() * + **************************/ + +void +#ifdef _NO_PROTO +drawVolumePanel () +#else +drawVolumePanel (void) +#endif +{ + + 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() */ + + diff --git a/src/graph/view3D/volume3d.c.pamphlet b/src/graph/view3D/volume3d.c.pamphlet deleted file mode 100644 index c3603972..00000000 --- a/src/graph/view3D/volume3d.c.pamphlet +++ /dev/null @@ -1,899 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D volume3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _VOLUME3D_C -#include "axiom-c-macros.h" - -#include <math.h> -#include <string.h> - -#include "header.h" -#include "cpanel.h" -#include "process.h" -#include "volume.h" -#include "../include/purty/volume.bitmap" -#include "../include/purty/volume.mask" - - - -#include "XSpadFill.H1" -#include "Gfun.H1" -#include "all_3d.H1" - -#define eyeDistMessX (frusX(eyeWinX+27)) -#define eyeDistMessY (frusY(eyeWinY-5)) -#define hitherMessX (frusX(hitherWinX+15)) -#define hitherMessY (frusY(hitherWinY)) - -#define clipXMessX (control->buttonQueue[clipXBut].buttonX + \ - control->buttonQueue[clipXBut].xHalf) -#define clipXMessY (control->buttonQueue[clipXBut].buttonY + 2) -#define clipYMessX (control->buttonQueue[clipYBut].buttonX + \ - control->buttonQueue[clipYBut].buttonWidth-2) -#define clipYMessY (control->buttonQueue[clipYBut].buttonY + \ - control->buttonQueue[clipYBut].yHalf) -#define clipZMessX (control->buttonQueue[clipZBut].buttonX + \ - control->buttonQueue[clipZBut].xHalf+4) -#define clipZMessY (control->buttonQueue[clipZBut].buttonY + \ - control->buttonQueue[clipZBut].yHalf-4) - -#define volumeCursorForeground monoColor(68) -#define volumeCursorBackground monoColor(197) - -#define hitherBoxColor monoColor(141) -#define hitherBoxTop (frustrumMidY - 10) -#define hitherBoxHeight 20 - -#define clipButtonColor 144 -#define toggleColor 42 -#define arcColor 75 - -#define arcSize 6 -#define tinyArc 5 -#define blank 4 -#define toggleX 190 -#define toggleY 280 - -#define oldWay - -#define frusX(x) (control->buttonQueue[frustrumBut].buttonX + x) -#define frusY(y) (control->buttonQueue[frustrumBut].buttonY + y) - -#define clipMessX 7 -#define clipMessY (control->buttonQueue[clipXBut].buttonY + 15) - /* someotherFont holds title font (see main.c) */ -#define clipMessDy (globalFont->max_bounds.ascent/2 + \ - globalFont->max_bounds.descent) -static char *clipMess = "Clip Volume"; - -#define eyeMess1Dy clipMessDy -#define eyeMess1X 7 -#define eyeMess1Y (frustrumY + 40 + 3*eyeMess1Dy) -static char *eyeMess1 = "Eye"; - -#define eyeMess2X (globalFont->max_bounds.width + 14) -#define eyeMess2Y (frustrumY + 40) -#define eyeMess2Dy eyeMess1Dy -static char *eyeMess2 = "Reference"; - - - /* global stuff */ -int flatClipBoxX[8], flatClipBoxY[8]; - - - - -/******************* volume buttons **********************/ - -int -#ifdef _NO_PROTO -initVolumeButtons (volumeButtons) - buttonStruct *volumeButtons; -#else -initVolumeButtons (buttonStruct *volumeButtons) -#endif -{ - int ii, num = 0; - - ii = volumeReturn; - volumeButtons[ii].buttonX = 154; - volumeButtons[ii].buttonY = 370; - volumeButtons[ii].buttonWidth = 110; - volumeButtons[ii].buttonHeight = 24; - volumeButtons[ii].buttonKey = ii; - volumeButtons[ii].pot = no; - volumeButtons[ii].mask = buttonMASK; - volumeButtons[ii].text = "Return"; - volumeButtons[ii].textColor = 52; - volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; - volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; - ++num; - - ii = volumeAbort; - volumeButtons[ii].buttonX = 36; - volumeButtons[ii].buttonY = 370; - volumeButtons[ii].buttonWidth = 110; - volumeButtons[ii].buttonHeight = 24; - volumeButtons[ii].buttonKey = ii; - volumeButtons[ii].pot = no; - volumeButtons[ii].mask = buttonMASK; - volumeButtons[ii].text = "Abort"; - volumeButtons[ii].textColor = 28; - volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; - volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; - ++num; - - ii = frustrumBut; - volumeButtons[ii].buttonX = frustrumWindowX; - volumeButtons[ii].buttonY = frustrumWindowY; - volumeButtons[ii].buttonWidth = frustrumWindowWidth; - volumeButtons[ii].buttonHeight = frustrumWindowHeight; - volumeButtons[ii].buttonKey = ii; - volumeButtons[ii].pot = yes; - volumeButtons[ii].mask = potMASK; - volumeButtons[ii].text = "Frustrum Window"; - volumeButtons[ii].textColor = frustrumColor; - volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; - volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; - ++num; - - ii = perspectiveBut; - volumeButtons[ii].buttonX = toggleX; - volumeButtons[ii].buttonY = toggleY; - volumeButtons[ii].buttonWidth = 10; - volumeButtons[ii].buttonHeight = 10; - volumeButtons[ii].buttonKey = ii; - volumeButtons[ii].pot = no; - volumeButtons[ii].mask = potMASK; - volumeButtons[ii].text = "Perspective"; - volumeButtons[ii].textColor = arcColor; - volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; - volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; - ++num; - - ii = clipRegionBut; - volumeButtons[ii].buttonX = toggleX; - volumeButtons[ii].buttonY = toggleY+20; - volumeButtons[ii].buttonWidth = 10; - volumeButtons[ii].buttonHeight = 10; - volumeButtons[ii].buttonKey = ii; - volumeButtons[ii].pot = no; - volumeButtons[ii].mask = potMASK; - volumeButtons[ii].text = "Show Region"; - volumeButtons[ii].textColor = arcColor; - volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; - volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; - ++num; - - ii = clipSurfaceBut; - volumeButtons[ii].buttonX = toggleX; - volumeButtons[ii].buttonY = toggleY+40; - volumeButtons[ii].buttonWidth = 10; - volumeButtons[ii].buttonHeight = 10; - volumeButtons[ii].buttonKey = ii; - volumeButtons[ii].pot = no; - volumeButtons[ii].mask = potMASK; - volumeButtons[ii].text = "Clipping On"; - volumeButtons[ii].textColor = arcColor; - volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; - volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; - ++num; - - ii = clipXBut; - volumeButtons[ii].buttonX = clipXButX; - volumeButtons[ii].buttonY = clipXButY; - volumeButtons[ii].buttonWidth = majorAxis; - volumeButtons[ii].buttonHeight = minorAxis; - volumeButtons[ii].buttonKey = ii; - volumeButtons[ii].pot = yes; - volumeButtons[ii].mask = potMASK; - volumeButtons[ii].text = "Clip X"; - volumeButtons[ii].textColor = clipButtonColor; - volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; - volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; - ++num; - - ii = clipYBut; - volumeButtons[ii].buttonX = clipYButX; - volumeButtons[ii].buttonY = clipYButY; - volumeButtons[ii].buttonWidth = minorAxis; - volumeButtons[ii].buttonHeight = majorAxis; - volumeButtons[ii].buttonKey = ii; - volumeButtons[ii].pot = yes; - volumeButtons[ii].mask = potMASK; - volumeButtons[ii].text = "Clip Y"; - volumeButtons[ii].textColor = clipButtonColor; - volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; - volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; - ++num; - - ii = clipZBut; - volumeButtons[ii].buttonX = clipZButX; - volumeButtons[ii].buttonY = clipZButY; - volumeButtons[ii].buttonWidth = midAxis; - volumeButtons[ii].buttonHeight = midAxis; - volumeButtons[ii].buttonKey = ii; - volumeButtons[ii].pot = yes; - volumeButtons[ii].mask = potMASK; - volumeButtons[ii].text = "Clip Z"; - volumeButtons[ii].textColor = clipButtonColor; - volumeButtons[ii].xHalf = volumeButtons[ii].buttonWidth/2; - volumeButtons[ii].yHalf = volumeButtons[ii].buttonHeight/2; - ++num; - - return(num); -} - - -/************************* - * int makeVolumePanel() * - *************************/ - -void -#ifdef _NO_PROTO -makeVolumePanel () -#else -makeVolumePanel (void) -#endif -{ - - int i; - XSetWindowAttributes cwAttrib, controlAttrib; - XSizeHints sizehint; - Pixmap volumebits, volumemask; - XColor foreColor, backColor; - - volumebits = XCreateBitmapFromData(dsply,rtWindow,volumeBitmap_bits, - volumeBitmap_width,volumeBitmap_height); - volumemask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits, - volumeMask_width,volumeMask_height); - cwAttrib.background_pixel = backgroundColor; - cwAttrib.border_pixel = foregroundColor; - cwAttrib.event_mask = volumeMASK; - cwAttrib.colormap = colorMap; - cwAttrib.override_redirect = overrideManager; - foreColor.pixel = volumeCursorForeground; - XQueryColor(dsply,colorMap,&foreColor); - backColor.pixel = volumeCursorBackground; - XQueryColor(dsply,colorMap,&backColor); - cwAttrib.cursor = XCreatePixmapCursor(dsply,volumebits,volumemask, - &foreColor,&backColor, - volumeBitmap_x_hot, - volumeBitmap_y_hot); - volumeWindow = XCreateWindow(dsply,control->controlWindow, - -3,-3,controlWidth,controlHeight,3, - CopyFromParent,InputOutput,CopyFromParent, - controlCreateMASK,&cwAttrib); - - sizehint.flags = USPosition | USSize; - sizehint.x = 0; - sizehint.y = 0; - sizehint.width = controlWidth; - sizehint.height = controlHeight; - /*** the None stands for icon pixmap ***/ - XSetNormalHints(dsply,volumeWindow,&sizehint); - XSetStandardProperties(dsply,volumeWindow,"Volume Panel 3D", - "View Volume",None,NULL,0,&sizehint); - - /*** volume frustrum window ***/ - - /*** do volume buttons ***/ - initVolumeButtons(control->buttonQueue); - for (i=volumeButtonsStart; i<(volumeButtonsEnd); i++) { - controlAttrib.event_mask = (control->buttonQueue[i]).mask; - (control->buttonQueue[i]).self = - XCreateWindow(dsply,volumeWindow, - (control->buttonQueue[i]).buttonX, - (control->buttonQueue[i]).buttonY, - (control->buttonQueue[i]).buttonWidth, - (control->buttonQueue[i]).buttonHeight, - 0,0,InputOnly,CopyFromParent, - buttonCreateMASK,&controlAttrib); - XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, - &((control->buttonQueue[i]).buttonKey)); - XMapWindow(dsply,(control->buttonQueue[i]).self); - } - -} /* makeVolumePanel() */ - - -void -#ifdef _NO_PROTO -drawClipXBut () -#else -drawClipXBut (void) -#endif -{ - - 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 -#ifdef _NO_PROTO -drawClipYBut () -#else -drawClipYBut (void) -#endif -{ - - 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 -#ifdef _NO_PROTO -drawClipZBut () -#else -drawClipZBut (void) -#endif -{ - - 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 -#ifdef _NO_PROTO -drawClipVolume () -#else -drawClipVolume (void) -#endif -{ - - float xminL,xmaxL,yminL,ymaxL,zminL,zmaxL; - - XClearArea(dsply,volumeWindow,backFaceX-1,backFaceY, - lengthFace+deltaFace+2,lengthFace+deltaFace+1,False); - - GSetForeground(trashGC,(float)boxInline,Xoption); /*boxOutline=133*/ - GSetLineAttributes(trashGC,0,LineSolid,CapButt,JoinMiter,Xoption); - - /* define corners of volume, clockwise, back to front */ - xminL = xClipMinN*lengthFace; - xmaxL = xClipMaxN*lengthFace; - yminL = yClipMinN*lengthFace; - ymaxL = yClipMaxN*lengthFace; - zminL = zClipMinN*zLength; - zmaxL = (1-zClipMaxN)*zLength; /* percentage upwards from bottom */ - - flatClipBoxX[0] = backFaceX + xminL + zminL; - flatClipBoxY[0] = backFaceY + yminL + zminL; - flatClipBoxX[1] = backFaceX + xmaxL + zminL; - flatClipBoxY[1] = flatClipBoxY[0]; - flatClipBoxX[2] = flatClipBoxX[1]; - flatClipBoxY[2] = backFaceY + ymaxL + zminL; - flatClipBoxX[3] = flatClipBoxX[0]; - flatClipBoxY[3] = flatClipBoxY[2]; - flatClipBoxX[4] = frontFaceX + xminL - zmaxL; - flatClipBoxY[4] = frontFaceY + yminL - zmaxL; - flatClipBoxX[5] = frontFaceX + xmaxL - zmaxL; - flatClipBoxY[5] = flatClipBoxY[4]; - flatClipBoxX[6] = flatClipBoxX[5]; - flatClipBoxY[6] = frontFaceY + ymaxL - zmaxL; - flatClipBoxX[7] = flatClipBoxX[4]; - flatClipBoxY[7] = flatClipBoxY[6]; - - /* now draw the volume */ - GDrawRectangle(trashGC,volumeWindow, - flatClipBoxX[0],flatClipBoxY[0], - flatClipBoxX[2]-flatClipBoxX[0], - flatClipBoxY[2]-flatClipBoxY[0],Xoption); - GDrawLine(trashGC,volumeWindow, - flatClipBoxX[0],flatClipBoxY[0],flatClipBoxX[4],flatClipBoxY[4],Xoption); - GDrawLine(trashGC,volumeWindow, - flatClipBoxX[1],flatClipBoxY[1],flatClipBoxX[5],flatClipBoxY[5],Xoption); - GDrawLine(trashGC,volumeWindow, - flatClipBoxX[2],flatClipBoxY[2],flatClipBoxX[6],flatClipBoxY[6],Xoption); - GDrawLine(trashGC,volumeWindow, - flatClipBoxX[3],flatClipBoxY[3],flatClipBoxX[7],flatClipBoxY[7],Xoption); - GSetForeground(trashGC,(float)boxOutline,Xoption); - GDrawRectangle(trashGC,volumeWindow, - flatClipBoxX[4],flatClipBoxY[4], - flatClipBoxX[6]-flatClipBoxX[4], - flatClipBoxY[6]-flatClipBoxY[4],Xoption); - /* make sure volumeGC is set properly before calling these functions */ - -} /* drawClipVolume() */ - - -void -#ifdef _NO_PROTO -drawHitherControl () -#else -drawHitherControl (void) -#endif -{ - - float xx,b,slope; - int hitherTop, hitherBot; - - float b0x,b1x; - - /* draw box indicating minimum and maximum distance of projection */ - GSetForeground(trashGC,(float)hitherBoxColor,Xoption); - b0x = (pzMin - clipPlaneMin)/(clipPlaneMax-clipPlaneMin); - b0x = hitherMaxX - b0x*(hitherMaxX - hitherMinX); /* screen x */ - b1x = (pzMax - clipPlaneMin)/(clipPlaneMax-clipPlaneMin); - b1x = hitherMaxX - b1x*(hitherMaxX - hitherMinX); /* screen x */ - GDraw3DButtonOut(trashGC,volumeWindow, - (int)(b0x),frusY(hitherBoxTop), - (int)fabs(b1x-b0x),hitherBoxHeight,Xoption); - - /* draw the hither plane */ - GSetForeground(trashGC,(float)hitherColor,Xoption); - - /* percentage x */ - xx = ((viewData.clipPlane-clipPlaneMin)/(clipPlaneMax-clipPlaneMin)); - xx = hitherMaxX - xx*(hitherMaxX - hitherMinX); /* screen x */ - slope = ((float)frustrumY - frustrumMidY)/(frustrumX - frustrumVertex); - b = ((float)frustrumX*frustrumMidY - frustrumVertex*frustrumY) / - (frustrumX - frustrumVertex); - hitherTop = slope * xx + b + 0.5; - slope = (float)(frustrumBotY - frustrumMidY)/(frustrumX - frustrumVertex); - b = ((float)frustrumX*frustrumMidY - frustrumVertex*frustrumBotY) / - (frustrumX - frustrumVertex); - hitherBot = slope * xx + b + 0.5; - GDrawLine(trashGC,volumeWindow, frusX((int)xx),frusY(hitherTop), - frusX((int)xx),frusY(hitherBot),Xoption); - - /* draw hither control box and bar */ - GDraw3DButtonOut(trashGC,volumeWindow, - frusX(hitherWinX),frusY(hitherWinY+5), - hitherWidth,hitherHeight,Xoption); - GDrawLine(trashGC,volumeWindow, - frusX(hitherMinX),frusY(hitherBarY+5), - frusX(hitherMaxX),frusY(hitherBarY+5),Xoption); - /* draw hither plane I/O pointer arrow */ - - GDrawLine(trashGC,volumeWindow, - frusX((int)xx),frusY(hitherBarY+2), - frusX((int)xx),frusY(hitherBarY+8),Xoption); - - /* print string label */ - GSetForeground(volumeGC,(float)hitherColor,Xoption); - GDrawString(volumeGC,volumeWindow,hitherMessX,hitherMessY,"Hither",6,Xoption); - -} - -void -#ifdef _NO_PROTO -drawEyeControl () -#else -drawEyeControl (void) -#endif -{ - - 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 drawFrustrum() * - **************************/ - -void -#ifdef _NO_PROTO -drawFrustrum () -#else -drawFrustrum (void) -#endif -{ - - float normalizedEyeDistance; - - XClearArea(dsply,volumeWindow, - control->buttonQueue[frustrumBut].buttonX, - control->buttonQueue[frustrumBut].buttonY, - control->buttonQueue[frustrumBut].buttonWidth+9, - control->buttonQueue[frustrumBut].buttonHeight,False); - GSetForeground(trashGC,(float)frustrumColor,Xoption); - normalizedEyeDistance = (viewData.eyeDistance - minEyeDistance) / - (maxEyeDistance - minEyeDistance); - normalizedEyeDistance = pow((double)normalizedEyeDistance,0.333333333); - frustrumVertex = normalizedEyeDistance * (frustrumMax - frustrumMin) + - frustrumMin - 4; - GDrawLine(trashGC,volumeWindow, - frusX(frustrumX),frusY(frustrumY), - frusX(frustrumX),frusY(frustrumY+frustrumLength),Xoption); - GDrawLine(trashGC,volumeWindow, - frusX(frustrumX),frusY(frustrumY), - frusX(frustrumVertex),frusY(frustrumMidY),Xoption); - GDrawLine(trashGC,volumeWindow, - frusX(frustrumX),frusY(frustrumBotY), - frusX(frustrumVertex),frusY(frustrumMidY),Xoption); - - /* draw controls */ - drawHitherControl(); - drawEyeControl(); - -} /* drawFrustrum() */ - - - -/************************** - * void drawVolumePanel() * - **************************/ - -void -#ifdef _NO_PROTO -drawVolumePanel () -#else -drawVolumePanel (void) -#endif -{ - - 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() */ - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view3D/write3d.c.pamphlet b/src/graph/view3D/write3d.c index 106bad7c..b836241b 100644 --- a/src/graph/view3D/write3d.c.pamphlet +++ b/src/graph/view3D/write3d.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view3D write3d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _WRITE3D_C #include "axiom-c-macros.h" @@ -71,7 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. int #ifdef _NO_PROTO writeViewport (thingsToWrite) - int thingsToWrite; + int thingsToWrite; #else writeViewport (int thingsToWrite) #endif @@ -109,23 +95,23 @@ writeViewport (int thingsToWrite) fprintf(viewDataFile,"%d\n",viewData.typeOf3D); fprintf(viewDataFile,"%g %g %g %g %g %g\n", viewData.xmin,viewData.xmax,viewData.ymin,viewData.ymax, - viewData.zmin,viewData.zmax); + viewData.zmin,viewData.zmax); fprintf(viewDataFile,"%s\n",viewport->title); fprintf(viewDataFile,"%g %g %g %g %g %g %g %g\n",viewport->deltaX, - viewport->deltaY,viewport->scale, - viewport->scaleX,viewport->scaleY,viewport->scaleZ, - viewport->theta,viewport->phi); + viewport->deltaY,viewport->scale, + viewport->scaleX,viewport->scaleY,viewport->scaleZ, + viewport->theta,viewport->phi); fprintf(viewDataFile,"%d %d %d %d\n",vwInfo.x,vwInfo.y,vwInfo.width, - vwInfo.height); + vwInfo.height); fprintf(viewDataFile,"%d %d %d %d %d %d %d\n",viewport->haveControl, - viewData.style, viewport->axesOn, + viewData.style, viewport->axesOn, viewport->hueOffset,viewport->numberOfHues, viewport->diagonals, viewData.outlineRenderOn); fprintf(viewDataFile,"%g %g %g %g\n",viewport->lightVector[0], - viewport->lightVector[1], viewport->lightVector[2], - viewport->translucency); + viewport->lightVector[1], viewport->lightVector[2], + viewport->translucency); fprintf(viewDataFile,"%d %g\n",viewData.perspective, - viewData.eyeDistance); + viewData.eyeDistance); /* write out the generalized 3D components */ fprintf(viewDataFile,"%d\n",viewData.numOfPoints); @@ -137,12 +123,12 @@ writeViewport (int thingsToWrite) anLLPoint = viewData.lllp.llp; for (i=0; i<viewData.lllp.numOfComponents; i++,anLLPoint++) { fprintf(viewDataFile,"%d %d\n",anLLPoint->prop.closed, - anLLPoint->prop.solid); + anLLPoint->prop.solid); fprintf(viewDataFile,"%d\n",anLLPoint->numOfLists); anLPoint = anLLPoint->lp; for (j=0; j<anLLPoint->numOfLists; j++,anLPoint++) { fprintf(viewDataFile,"%d %d\n",anLPoint->prop.closed, - anLPoint->prop.solid); + anLPoint->prop.solid); fprintf(viewDataFile,"%d\n",anLPoint->numOfPoints); anIndex = anLPoint->indices; for (k=0; k<anLPoint->numOfPoints; k++,anIndex++) { @@ -162,8 +148,8 @@ writeViewport (int thingsToWrite) sprintf(viewBitmapFilename,"%s%s%s",viewDirName,"/","image.bm"); XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); code = XWriteBitmapFile(dsply,viewBitmapFilename, - viewport->titleWindow,vwInfo.width, - vwInfo.height+vwInfo.border_width+20,-1,-1); + viewport->titleWindow,vwInfo.width, + vwInfo.height+vwInfo.border_width+20,-1,-1); break; case Pixmap: @@ -189,7 +175,7 @@ writeViewport (int thingsToWrite) viewData.outlineRenderOn = 1; } else { if (viewData.style == render) viewData.outlineRenderOn = 1; - } + } drawViewport(Xoption); writeTitle(); XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); @@ -203,8 +189,8 @@ writeViewport (int thingsToWrite) writeTitle(); sprintf(viewBitmapFilename,"%s%s%s",viewDirName,"/","image.bm"); code = XWriteBitmapFile(dsply,viewBitmapFilename, - viewport->titleWindow,vwInfo.width, - vwInfo.height+vwInfo.border_width+20,-1,-1); + viewport->titleWindow,vwInfo.width, + vwInfo.height+vwInfo.border_width+20,-1,-1); writeImage = no; break; @@ -212,12 +198,12 @@ writeViewport (int thingsToWrite) case Postscript: /*** Create postscript output for viewport (in axiom3D.ps) ***/ sprintf(PSfilename,"%s%s",viewDirName,"/axiom3D.ps"); - if (PSInit(viewport->viewWindow,viewport->titleWindow) == psError) - return(-1); + if (PSInit(viewport->viewWindow,viewport->titleWindow) == psError) + return(-1); drawViewport(PSoption); /* write new script file in /tmp */ - if (PSCreateFile(viewBorderWidth,viewport->viewWindow, - viewport->titleWindow, viewport->title) == psError) - return(-1); /* concat script & proc into axiom3D.ps */ + if (PSCreateFile(viewBorderWidth,viewport->viewWindow, + viewport->titleWindow, viewport->title) == psError) + return(-1); /* concat script & proc into axiom3D.ps */ break; } /* switch on ii */ } /* if thingsToWrite >> ii */ @@ -227,9 +213,3 @@ writeViewport (int thingsToWrite) } /* else create directory okay */ } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewAlone/Makefile.in b/src/graph/viewAlone/Makefile.in index dc65043a..7cb466fa 100644 --- a/src/graph/viewAlone/Makefile.in +++ b/src/graph/viewAlone/Makefile.in @@ -1,4 +1,4 @@ -# Copyright (C) 2007, Gabriel Dos Reis. +# Copyright (C) 2007-2008, Gabriel Dos Reis. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -40,17 +40,13 @@ build_libdir = $(abs_top_builddir)/src/lib bin_PROGRAMS = viewAlone$(EXEEXT) -viewAlone_sources = viewAlone.c spoonComp.c spoon2D.c +viewAlone_SOURCES = viewAlone.c spoonComp.c spoon2D.c -viewAlone_SOURCES = $(addsuffix .pamphlet, $(viewAlone_sources)) - -viewAlone_objects = $(viewAlone_sources:.c=.lo) +viewAlone_objects = $(viewAlone_SOURCES:.c=.lo) viewAlone_LDADD = $(axiom_target_libdir)/libspad.la viewAlone_DEPENDENCIES = -pamphlets = Makefile.pamphlet $(viewAlone_SOURCES) - subdir = src/graph/viewAlone/ AXIOM_CFLAGS = ${CCF} ${AXIOM_X11_CFLAGS} -I$(srcdir) -I${LINC} -I${GINC} \ @@ -76,20 +72,16 @@ $(axiom_target_bindir)/viewAlone$(EXEEXT): $(viewAlone_objects) \ $(AXIOM_X11_LDFLAGS) .PRECIOUS: %.lo -.PRECIOUS: %.c %.lo: $(HEADERS) %.lo: %.c $(axiom_c_macros_h) $(COMPILE) -o $@ $(CFLAGS) $(AXIOM_CFLAGS) $< -%.c: $(srcdir)/%.c.pamphlet - $(axiom_build_document) --tangle --output=$@ $< - mostlyclean-local: clean-local: mostlyclean-local - @rm -f $(viewAlone_sources) $(viewAlone_objects) + @rm -f $(viewAlone_objects) @rm -f $(axiom_target_bindir)/viewAlone$(EXEEXT) distclean-local: clean-local diff --git a/src/graph/viewAlone/parabola.VIEW/bitmap b/src/graph/viewAlone/parabola.VIEW/bitmap index 1ebff188..1ebff188 100755..100644 --- a/src/graph/viewAlone/parabola.VIEW/bitmap +++ b/src/graph/viewAlone/parabola.VIEW/bitmap diff --git a/src/graph/viewAlone/parabola.VIEW/data b/src/graph/viewAlone/parabola.VIEW/data index 487adba0..487adba0 100755..100644 --- a/src/graph/viewAlone/parabola.VIEW/data +++ b/src/graph/viewAlone/parabola.VIEW/data diff --git a/src/graph/viewAlone/parabola.VIEW/graph0 b/src/graph/viewAlone/parabola.VIEW/graph0 index cc962f2f..cc962f2f 100755..100644 --- a/src/graph/viewAlone/parabola.VIEW/graph0 +++ b/src/graph/viewAlone/parabola.VIEW/graph0 diff --git a/src/graph/viewAlone/parabola.VIEW/pixmap b/src/graph/viewAlone/parabola.VIEW/pixmap Binary files differindex 9e1d5778..9e1d5778 100755..100644 --- a/src/graph/viewAlone/parabola.VIEW/pixmap +++ b/src/graph/viewAlone/parabola.VIEW/pixmap diff --git a/src/graph/viewAlone/spoon2D.c.pamphlet b/src/graph/viewAlone/spoon2D.c index b06da50f..054ed5a3 100644 --- a/src/graph/viewAlone/spoon2D.c.pamphlet +++ b/src/graph/viewAlone/spoon2D.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewAlone spoon2D.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _SPOON2D_C #include "axiom-c-macros.h" @@ -248,57 +234,57 @@ makeView2DFromFileData(view2DStruct *doView2D) fgets(title,256,viewFile); printf("(spoon2D) title=%s\n",title); if (!(doView2D->title = - (char *)malloc((strlen(title)+1) * sizeof(char)))) { + (char *)malloc((strlen(title)+1) * sizeof(char)))) { fprintf(stderr, - "Ran out of memory (malloc) trying to get the title.\n"); + "Ran out of memory (malloc) trying to get the title.\n"); exit(-1); } sprintf(doView2D->title,"%s",title); /* put in a null terminator over the newline that the fgets reads */ doView2D->title[strlen(doView2D->title)-1] = '\0'; fscanf(viewFile,"%d %d %d %d\n", - &(doView2D->vX), - &(doView2D->vY), - &(doView2D->vW), - &(doView2D->vH)); + &(doView2D->vX), + &(doView2D->vY), + &(doView2D->vW), + &(doView2D->vH)); printf("(spoon2D) X=%d Y=%d W=%d H=%d \n", doView2D->vX,doView2D->vY,doView2D->vW,doView2D->vH); for (i=0; i<maxGraphs; i++) { fscanf(viewFile,"%d\n", - &(graphArray[i].key)); + &(graphArray[i].key)); printf("(spoon2D) i=%d key=%d\n", i,graphArray[i].key); fscanf(viewFile,"%g %g\n", - &(graphStateArray[i].scaleX), - &(graphStateArray[i].scaleY)); + &(graphStateArray[i].scaleX), + &(graphStateArray[i].scaleY)); printf("(spoon2D) scaleX=%g scaleY=%g\n", - graphStateArray[i].scaleX,graphStateArray[i].scaleY); + graphStateArray[i].scaleX,graphStateArray[i].scaleY); fscanf(viewFile,"%g %g\n", - &(graphStateArray[i].deltaX), - &(graphStateArray[i].deltaY)); + &(graphStateArray[i].deltaX), + &(graphStateArray[i].deltaY)); printf("(spoon2D) deltaX=%g deltaY=%g\n", - graphStateArray[i].deltaX,graphStateArray[i].deltaY); + graphStateArray[i].deltaX,graphStateArray[i].deltaY); fscanf(viewFile,"%g %g\n", - &(graphStateArray[i].centerX), - &(graphStateArray[i].centerY)); + &(graphStateArray[i].centerX), + &(graphStateArray[i].centerY)); printf("(spoon2D) centerX=%g centerY=%g\n", - graphStateArray[i].centerX,graphStateArray[i].centerY); + graphStateArray[i].centerX,graphStateArray[i].centerY); fscanf(viewFile,"%d %d %d %d %d %d %d\n", - &(graphStateArray[i].pointsOn), - &(graphStateArray[i].connectOn), - &(graphStateArray[i].splineOn), - &(graphStateArray[i].axesOn), - &(graphStateArray[i].axesColor), - &(graphStateArray[i].unitsOn), - &(graphStateArray[i].unitsColor)); + &(graphStateArray[i].pointsOn), + &(graphStateArray[i].connectOn), + &(graphStateArray[i].splineOn), + &(graphStateArray[i].axesOn), + &(graphStateArray[i].axesColor), + &(graphStateArray[i].unitsOn), + &(graphStateArray[i].unitsColor)); printf("(spoon2D) pointsOn=%d connectOn=%d splineOn=%d axesOn=%d axesColor=%d unitsOn=%d unitsColor=%d\n", graphStateArray[i].pointsOn,graphStateArray[i].connectOn, graphStateArray[i].splineOn,graphStateArray[i].axesOn, graphStateArray[i].axesColor,graphStateArray[i].unitsOn, graphStateArray[i].unitsColor); fscanf(viewFile,"%d %d\n", - &(graphStateArray[i].showing), - &(graphStateArray[i].selected)); + &(graphStateArray[i].showing), + &(graphStateArray[i].selected)); printf("(spoon2D) showing=%d selected=%d\n", graphStateArray[i].showing,graphStateArray[i].selected); } @@ -315,39 +301,39 @@ makeView2DFromFileData(view2DStruct *doView2D) printf("(spoon2d) \n\nGRAPH%i\n",i); fscanf(graphFile,"%g %g %g %g\n", &(graphArray[i].xmin), - &(graphArray[i].ymin), + &(graphArray[i].ymin), &(graphArray[i].xmax), - &(graphArray[i].ymax)); + &(graphArray[i].ymax)); printf("(spoon2d) xmin=%g ymin=%g xmax=%g ymax=%g\n", graphArray[i].xmin,graphArray[i].ymin, graphArray[i].xmax,graphArray[i].ymax); fscanf(graphFile,"%g %g\n", &(graphArray[i].xNorm), - &(graphArray[i].yNorm)); + &(graphArray[i].yNorm)); printf("(spoon2d) xNorm=%g yNorm=%g\n", graphArray[i].xNorm,graphArray[i].yNorm); fscanf(graphFile,"%g %g\n", &(graphArray[i].originX), - &(graphArray[i].originY)); + &(graphArray[i].originY)); printf("(spoon2d) originX=%g originY=%g\n", graphArray[i].originX,graphArray[i].originY); fscanf(graphFile,"%g %g\n", &(graphArray[i].spadUnitX), - &(graphArray[i].spadUnitY)); + &(graphArray[i].spadUnitY)); printf("(spoon2d) spadUnitX=%g spadUnitY=%g\n", graphArray[i].spadUnitX,graphArray[i].spadUnitY); fscanf(graphFile,"%g %g\n", &(graphArray[i].unitX), - &(graphArray[i].unitY)); + &(graphArray[i].unitY)); printf("(spoon2d) unitX=%g unitY=%g\n", graphArray[i].unitX,graphArray[i].unitY); fscanf(graphFile,"%d\n", - &(graphArray[i].numberOfLists)); + &(graphArray[i].numberOfLists)); printf("(spoon2d) numberOfLists=%d\n", - graphArray[i].numberOfLists); + graphArray[i].numberOfLists); if (!(aList = (pointListStruct *)malloc(graphArray[i].numberOfLists * - sizeof(pointListStruct)))) { + sizeof(pointListStruct)))) { fprintf(stderr,"viewAlone: Fatal Error>> Out of memory trying to receive a graph.\n"); exit(-1); } @@ -361,12 +347,12 @@ makeView2DFromFileData(view2DStruct *doView2D) aList->numberOfPoints); fscanf(graphFile,"%d %d %d\n", &(aList->pointColor), - &(aList->lineColor), - &(aList->pointSize)); + &(aList->lineColor), + &(aList->pointSize)); printf("(spoon2d) pointColor=%d lineColor=%d pointSize=%d\n", aList->pointColor,aList->lineColor,aList->pointSize); if (!(aPoint = (pointStruct *)malloc(aList->numberOfPoints * - sizeof(pointStruct)))) { + sizeof(pointStruct)))) { fprintf(stderr,"viewAlone: Fatal Error>> Out of memory trying to receive a graph.\n"); exit(-1); } @@ -375,10 +361,10 @@ makeView2DFromFileData(view2DStruct *doView2D) k<aList->numberOfPoints; k++,aPoint++) { fscanf(graphFile,"%g %g %g %g\n", - &(aPoint->x), - &(aPoint->y), - &(aPoint->hue), - &(aPoint->shade)); + &(aPoint->x), + &(aPoint->y), + &(aPoint->hue), + &(aPoint->shade)); printf("(spoon2d)k=%d x=%g y=%g hue=%g shade=%g\n", k,aPoint->x,aPoint->y,aPoint->hue,aPoint->shade); } @@ -388,9 +374,3 @@ makeView2DFromFileData(view2DStruct *doView2D) } /* if graph.key */ } /* for i */ } /* makeView2DFromFileData */ -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewAlone/spoonComp.c.pamphlet b/src/graph/viewAlone/spoonComp.c index d0b72ed5..857c3d5c 100644 --- a/src/graph/viewAlone/spoonComp.c.pamphlet +++ b/src/graph/viewAlone/spoonComp.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewAlone spoonComp.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _SPOONCOMP_C #include "axiom-c-macros.h" @@ -92,7 +78,7 @@ spoonView3D(int type) case 0: /* Child */ sprintf(errorStr,"%s", - "(viewAlone) mapping of pipes to standard I/O for view3D"); + "(viewAlone) mapping of pipes to standard I/O for view3D"); check(dup2(pipe0[0],0)); check(dup2(pipe1[1],1)); close(pipe0[0]); @@ -101,7 +87,7 @@ spoonView3D(int type) close(pipe1[1]); sprintf(errorStr,"%s", - "(viewAlone) execution of the ThreeDimensionalViewport process"); + "(viewAlone) execution of the ThreeDimensionalViewport process"); sprintf(envAXIOM,"%s",getenv("AXIOM")); sprintf(runView,"%s%s",envAXIOM,"/lib/view3D"); check(execl(runView,runView,NULL)); @@ -120,7 +106,7 @@ spoonView3D(int type) if (viewP.viewIn <0) { fprintf(stderr, - "can't set up pipes to viewport process. Try again.\n"); + "can't set up pipes to viewport process. Try again.\n"); return; } else { code = read(viewP.viewIn,&ack,intSize); @@ -138,9 +124,9 @@ spoonView3D(int type) write(viewP.viewOut,&doView3D,sizeof(view3DStruct)); i = strlen(doView3D.title)+1; write(viewP.viewOut,&i,intSize); /* tell the length of - the title to child */ + the title to child */ write(viewP.viewOut,doView3D.title,i); /* tell the title - to the child, child */ + to the child, child */ write(viewP.viewOut,&(doView3D.lightVec[0]),floatSize); write(viewP.viewOut,&(doView3D.lightVec[1]),floatSize); write(viewP.viewOut,&(doView3D.lightVec[2]),floatSize); @@ -203,16 +189,16 @@ makeView3DFromFileData(int type) /* &view3DType already read */ doView3D.typeOf3D = type; fscanf(viewFile,"%f %f %f %f %f %f\n", - &(doView3D.xmin), - &(doView3D.xmax), - &(doView3D.ymin), - &(doView3D.ymax), - &(doView3D.zmin), - &(doView3D.zmax)); + &(doView3D.xmin), + &(doView3D.xmax), + &(doView3D.ymin), + &(doView3D.ymax), + &(doView3D.zmin), + &(doView3D.zmax)); fgets(title,256,viewFile); if (!(doView3D.title = (char *)malloc((strlen(title)+1) * - sizeof(char)))) { + sizeof(char)))) { fprintf(stderr,"Ran out of memory (malloc) trying to get the title.\n"); exit(-1); } @@ -221,67 +207,67 @@ makeView3DFromFileData(int type) doView3D.title[strlen(doView3D.title)-1] = '\0'; fscanf(viewFile,"%f %f %f %f %f %f %f %f\n", - &(doView3D.deltaX), - &(doView3D.deltaY), - &(doView3D.scale), - &(doView3D.scaleX), - &(doView3D.scaleY), - &(doView3D.scaleZ), - &(doView3D.theta), - &(doView3D.phi)); + &(doView3D.deltaX), + &(doView3D.deltaY), + &(doView3D.scale), + &(doView3D.scaleX), + &(doView3D.scaleY), + &(doView3D.scaleZ), + &(doView3D.theta), + &(doView3D.phi)); fscanf(viewFile,"%d %d %d %d\n", - &(doView3D.vX), - &(doView3D.vY), - &(doView3D.vW), - &(doView3D.vH)); + &(doView3D.vX), + &(doView3D.vY), + &(doView3D.vW), + &(doView3D.vH)); fscanf(viewFile,"%d %d %d %d %d %d %d\n", - &(doView3D.showCP), - &(doView3D.style), - &(doView3D.AxesOn), - &(doView3D.hueOff), - &(doView3D.numOfHues), - &(doView3D.diagonals), - &(doView3D.outlineRenderOn)); + &(doView3D.showCP), + &(doView3D.style), + &(doView3D.AxesOn), + &(doView3D.hueOff), + &(doView3D.numOfHues), + &(doView3D.diagonals), + &(doView3D.outlineRenderOn)); fscanf(viewFile,"%f %f %f %f\n", - &(doView3D.lightVec[0]), - &(doView3D.lightVec[1]), - &(doView3D.lightVec[2]), - &(doView3D.translucency)); + &(doView3D.lightVec[0]), + &(doView3D.lightVec[1]), + &(doView3D.lightVec[2]), + &(doView3D.translucency)); fscanf(viewFile,"%d %f\n", - &(doView3D.perspective), - &(doView3D.eyeDistance)); + &(doView3D.perspective), + &(doView3D.eyeDistance)); /* get generalized 3D components */ fscanf(viewFile,"%d\n", - &(doView3D.numOfPoints)); + &(doView3D.numOfPoints)); aPoint = doView3D.points = (viewTriple *)malloc(doView3D.numOfPoints* - sizeof(viewTriple)); + sizeof(viewTriple)); for (i=0; i<doView3D.numOfPoints; i++, aPoint++) fscanf(viewFile,"%g %g %g %g\n", &(aPoint->x), - &(aPoint->y), - &(aPoint->z), - &(aPoint->c)); + &(aPoint->y), + &(aPoint->z), + &(aPoint->c)); fscanf(viewFile,"%d\n", - &(doView3D.lllp.numOfComponents)); + &(doView3D.lllp.numOfComponents)); anLLPoint = doView3D.lllp.llp = (LLPoint *)malloc(doView3D.lllp.numOfComponents*sizeof(LLPoint)); for (i=0; i<doView3D.lllp.numOfComponents; i++,anLLPoint++) { fscanf(viewFile,"%d %d\n", - &(anLLPoint->prop.closed), - &(anLLPoint->prop.solid)); + &(anLLPoint->prop.closed), + &(anLLPoint->prop.solid)); fscanf(viewFile,"%d\n", - &(anLLPoint->numOfLists)); + &(anLLPoint->numOfLists)); anLPoint = anLLPoint->lp = (LPoint *)malloc(anLLPoint->numOfLists*sizeof(LPoint)); for (j=0; j<anLLPoint->numOfLists; j++,anLPoint++) { fscanf(viewFile,"%d %d\n", - &(anLPoint->prop.closed), - &(anLPoint->prop.solid)); + &(anLPoint->prop.closed), + &(anLPoint->prop.solid)); fscanf(viewFile,"%d\n", - &(anLPoint->numOfPoints)); + &(anLPoint->numOfPoints)); anIndex = anLPoint->indices = (int *)malloc(anLPoint->numOfPoints*sizeof(int)); for (k=0; k<anLPoint->numOfPoints; k++,anIndex++) { @@ -294,9 +280,3 @@ makeView3DFromFileData(int type) doView3D.scaleDown = no ; } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewAlone/viewAlone.c b/src/graph/viewAlone/viewAlone.c new file mode 100644 index 00000000..4d18ecc3 --- /dev/null +++ b/src/graph/viewAlone/viewAlone.c @@ -0,0 +1,120 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + all rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _VIEWALONE_C +#include "axiom-c-macros.h" + +#include <stdlib.h> +#include "viewAlone.h" + +#include "all_alone.H1" + +/************* global variables **************/ + +viewManager viewP; /* note that in viewman, this is called viewports */ + +/* 3D stuff */ +view3DStruct doView3D; + +/* 2D stuff */ +view2DStruct doView2D; +graphStruct graphArray[maxGraphs]; +graphStateStruct graphStateArray[maxGraphs]; + +/* tube stuff */ +tubeModel doViewTube; + +int viewType; +int filedes,ack; + +char errorStr[80]; + + +int viewOkay = 0; +int viewError = -1; + +FILE *viewFile; +char filename[256]; +char pathname[256]; + +/************* main program **************/ + +#ifdef _NO_PROTO +int main (argc,argv) + int argc; + char *argv[]; +#else +int main (int argc,char *argv[]) +#endif +{ + printf("viewAlone called with argc=%d\n",argc); + printf("viewAlone called with argv[1]=%s\n",argv[0]); + printf("viewAlone called with argv[2]=%s\n",argv[1]); +/******** Open files and Figure out the viewport type ********/ + + sprintf(filename,"%s%s",argv[1],".VIEW/data"); + if((viewFile = fopen(filename,"r")) == NULL ) { + + sprintf(filename,"%s%s",argv[1],"/data"); + if((viewFile = fopen(filename,"r")) == NULL ){ + fprintf(stderr,"Error: Cannot find the file %s%s or %s%s\n", + argv[1],".VIEW/data",argv[1],"/data"); + exit(-1); + } + sprintf(pathname,"%s",argv[1]); + } + else{ + sprintf(pathname,"%s%s",argv[1],".VIEW"); + } + fscanf(viewFile,"%d\n",&viewType); + printf("filename = %s\n",filename); + printf("viewType = %d\n",viewType); + switch (viewType) { + + case view3DType: + case viewTubeType: + printf("calling spoonView3D\n"); + spoonView3D(viewType); + break; + + case view2DType: + printf("calling spoonView2D\n"); + spoonView2D(); + break; + + } /* switch */ + printf("The first number in the file, %d, called the viewType, not a valid value. It must be a number in the range of [1..4]\n",viewType); + return(0); + } diff --git a/src/graph/viewAlone/viewAlone.c.pamphlet b/src/graph/viewAlone/viewAlone.c.pamphlet deleted file mode 100644 index 5d178583..00000000 --- a/src/graph/viewAlone/viewAlone.c.pamphlet +++ /dev/null @@ -1,140 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewAlone viewAlone.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _VIEWALONE_C -#include "axiom-c-macros.h" - -#include <stdlib.h> -#include "viewAlone.h" - -#include "all_alone.H1" - -/************* global variables **************/ - -viewManager viewP; /* note that in viewman, this is called viewports */ - -/* 3D stuff */ -view3DStruct doView3D; - -/* 2D stuff */ -view2DStruct doView2D; -graphStruct graphArray[maxGraphs]; -graphStateStruct graphStateArray[maxGraphs]; - -/* tube stuff */ -tubeModel doViewTube; - -int viewType; -int filedes,ack; - -char errorStr[80]; - - -int viewOkay = 0; -int viewError = -1; - -FILE *viewFile; -char filename[256]; -char pathname[256]; - -/************* main program **************/ - -#ifdef _NO_PROTO -int main (argc,argv) - int argc; - char *argv[]; -#else -int main (int argc,char *argv[]) -#endif -{ - printf("viewAlone called with argc=%d\n",argc); - printf("viewAlone called with argv[1]=%s\n",argv[0]); - printf("viewAlone called with argv[2]=%s\n",argv[1]); -/******** Open files and Figure out the viewport type ********/ - - sprintf(filename,"%s%s",argv[1],".VIEW/data"); - if((viewFile = fopen(filename,"r")) == NULL ) { - - sprintf(filename,"%s%s",argv[1],"/data"); - if((viewFile = fopen(filename,"r")) == NULL ){ - fprintf(stderr,"Error: Cannot find the file %s%s or %s%s\n", - argv[1],".VIEW/data",argv[1],"/data"); - exit(-1); - } - sprintf(pathname,"%s",argv[1]); - } - else{ - sprintf(pathname,"%s%s",argv[1],".VIEW"); - } - fscanf(viewFile,"%d\n",&viewType); - printf("filename = %s\n",filename); - printf("viewType = %d\n",viewType); - switch (viewType) { - - case view3DType: - case viewTubeType: - printf("calling spoonView3D\n"); - spoonView3D(viewType); - break; - - case view2DType: - printf("calling spoonView2D\n"); - spoonView2D(); - break; - - } /* switch */ - printf("The first number in the file, %d, called the viewType, not a valid value. It must be a number in the range of [1..4]\n",viewType); - return(0); - } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewAlone/viewAlone.h b/src/graph/viewAlone/viewAlone.h index 686f2d55..a2d5d5fe 100755..100644 --- a/src/graph/viewAlone/viewAlone.h +++ b/src/graph/viewAlone/viewAlone.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdio.h> diff --git a/src/graph/viewman/Makefile.in b/src/graph/viewman/Makefile.in index 07578c6f..cc857bc6 100644 --- a/src/graph/viewman/Makefile.in +++ b/src/graph/viewman/Makefile.in @@ -1,4 +1,4 @@ -# Copyright (C) 2007, Gabriel Dos Reis. +# Copyright (C) 2007-2008, Gabriel Dos Reis. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -40,12 +40,10 @@ build_libdir = $(abs_top_builddir)/src/lib bin_PROGRAMS = viewman$(EXEEXT) -viewman_sources = cleanup.c fun2D.c fun3D.c make2D.c make3D.c \ +viewman_SOURCES = cleanup.c fun2D.c fun3D.c make2D.c make3D.c \ makeGraph.c readView.c sselect.c viewman.c -viewman_SOURCES = $(addsuffix .pamphlet, $(viewman_sources)) - -viewman_objects = $(viewman_sources:.c=.lo) +viewman_objects = $(viewman_SOURCES:.c=.lo) viewman_headers = $(srcdir)/viewman.h \ $(addprefix $(axiom_src_srcdir)/graph/include/,\ @@ -57,8 +55,6 @@ viewman_headers = $(srcdir)/viewman.h \ viewman_DEPENDENCIES = viewman_LDFLAGS = $(axiom_target_libdir)/libspad.la -pamphlets = Makefile.pamphlet $(viewman_SOURCES) - subdir = src/graph/viewman/ AXIOM_CFLAGS = ${CCF} ${AXIOM_X11_CFLAGS} -I${LINC} -I${GINC} -I$(srcdir) \ @@ -75,7 +71,6 @@ stamp: $(axiom_target_libdir)/viewman$(EXEEXT) $(STAMP) stamp -.PRECIOUS: %.c .PRECIOUS: %.lo %.lo: $(viewman_HEADERS) @@ -83,9 +78,6 @@ stamp: $(axiom_target_libdir)/viewman$(EXEEXT) %.lo: %.c $(axiom_c_macros_h) $(COMPILE) -o $@ $(CFLAGS) $(AXIOM_CFLAGS) $< -%.c: $(srcdir)/%.c.pamphlet - $(axiom_build_document) --tangle --output=$@ $< - $(axiom_target_libdir)/viewman$(EXEEXT): $(viewman_objects) $(viewman_DEPENDENCIES) $(LINK) -o $@ $(viewman_objects) $(viewman_LDFLAGS) \ $(AXIOM_X11_LDFLAGS) @@ -93,7 +85,7 @@ $(axiom_target_libdir)/viewman$(EXEEXT): $(viewman_objects) $(viewman_DEPENDENCI mostlyclean-local: clean-local: mostlyclean-local - @rm -f $(viewman_sources) $(viewman_objects) + @rm -f $(viewman_objects) @rm -f $(axiom_target_libdir)/viewman$(EXEEXT) distclean-local: clean-local diff --git a/src/graph/viewman/cleanup.c.pamphlet b/src/graph/viewman/cleanup.c index 24103128..73cb0a94 100644 --- a/src/graph/viewman/cleanup.c.pamphlet +++ b/src/graph/viewman/cleanup.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewman cleanup.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _CLEANUP_C #include "axiom-c-macros.h" @@ -122,8 +108,8 @@ rmViewMgr(viewManager *slotPtr) somePort=(someOtherPort=somePort)->nextViewport) {} assert ((somePort == 0) || - (somePort == viewports) || - (somePort == someOtherPort->nextViewport)); + (somePort == viewports) || + (somePort == someOtherPort->nextViewport)); if (somePort) { if (somePort == viewports) viewports=viewports->nextViewport; @@ -136,45 +122,45 @@ rmViewMgr(viewManager *slotPtr) if (code == -1) break; /* read failure - give up */ if (throwAway) { /* zero means no graph */ - for (someGraph = someOtherGraph = graphList; + for (someGraph = someOtherGraph = graphList; (someGraph != 0) && (someGraph->key != throwAway); - someGraph=(someOtherGraph=someGraph)->nextGraph) - { - } + someGraph=(someOtherGraph=someGraph)->nextGraph) + { + } /* someGraph is 0 if not found */ - /* someGraph == graphList if found at first */ - /* otherwise someGraph == someOtherGraph->nextGraph */ - assert( (someGraph == 0) || - (someGraph == graphList) || - (someGraph == someOtherGraph->nextGraph)); + /* someGraph == graphList if found at first */ + /* otherwise someGraph == someOtherGraph->nextGraph */ + assert( (someGraph == 0) || + (someGraph == graphList) || + (someGraph == someOtherGraph->nextGraph)); if (someGraph) { /* if found (should always be true) */ - for(someView=someOtherView=someGraph->views; - (someView !=0 ) && (someView->viewGr != slotPtr); - someView=(someOtherView=someView)->nextViewthing) - { - } - /* similarly */ - assert( (someView == 0) || - (someView == someGraph->views) || - (someView == someOtherView->nextViewthing)); + for(someView=someOtherView=someGraph->views; + (someView !=0 ) && (someView->viewGr != slotPtr); + someView=(someOtherView=someView)->nextViewthing) + { + } + /* similarly */ + assert( (someView == 0) || + (someView == someGraph->views) || + (someView == someOtherView->nextViewthing)); if (someView) { /* if found (should always be true) */ - if (someView == someGraph->views) - /* first */ - someGraph->views = someGraph->views->nextViewthing; - else - someOtherView->nextViewthing = someView->nextViewthing; + if (someView == someGraph->views) + /* first */ + someGraph->views = someGraph->views->nextViewthing; + else + someOtherView->nextViewthing = someView->nextViewthing; free(someView); /* remove this viewport - from list */ + 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; - else - someOtherGraph->nextGraph = someGraph->nextGraph; + if (someGraph == graphList) + graphList = graphList->nextGraph; + else + someOtherGraph->nextGraph = someGraph->nextGraph; discardGraph(someGraph); /* free the graph */ } } /* if someGraph */ @@ -246,9 +232,3 @@ goodbye(int sig) -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewman/fun2D.c.pamphlet b/src/graph/viewman/fun2D.c index 6cc08f47..f2cdda03 100644 --- a/src/graph/viewman/fun2D.c.pamphlet +++ b/src/graph/viewman/fun2D.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewman fun2D.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _FUN2D_C #include "axiom-c-macros.h" @@ -404,9 +390,3 @@ sendGraphToView2D(int i,int there,viewManager *viewport,graphStateStruct *doGrap } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewman/fun3D.c.pamphlet b/src/graph/viewman/fun3D.c index f840fb0b..d50f06b4 100644 --- a/src/graph/viewman/fun3D.c.pamphlet +++ b/src/graph/viewman/fun3D.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewman fun3D.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _FUN3D_C #include "axiom-c-macros.h" @@ -387,9 +373,3 @@ forkView3D(int typeOfViewport) } /* forkView3D() */ -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewman/globalsM.h b/src/graph/viewman/globalsM.h index 019ecc3a..e7e3846b 100755..100644 --- a/src/graph/viewman/globalsM.h +++ b/src/graph/viewman/globalsM.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights resrved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ extern viewManager *viewports,*slot,*stepSlot; diff --git a/src/graph/viewman/make2D.c b/src/graph/viewman/make2D.c new file mode 100644 index 00000000..a4beba4e --- /dev/null +++ b/src/graph/viewman/make2D.c @@ -0,0 +1,85 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _MAKE2D_C +#include "axiom-c-macros.h" + +#include "viewman.h" + +#include "sockio.h" +#include "make2D.H1" + +void +#ifdef _NO_PROTO +makeView2DFromSpadData(viewdata,graphState) + view2DStruct *viewdata; + graphStateStruct graphState[]; +#else +makeView2DFromSpadData(view2DStruct *viewdata,graphStateStruct graphState[]) +#endif +{ + + 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; i<maxGraphs; i++) { + viewdata->graphKeyArray[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); + graphState[i].deltaY = get_float(spadSock); + graphState[i].pointsOn = get_int(spadSock); + graphState[i].connectOn = get_int(spadSock); + graphState[i].splineOn = get_int(spadSock); + graphState[i].axesOn = get_int(spadSock); + graphState[i].axesColor = get_int(spadSock); + 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? */ + + } + } +} diff --git a/src/graph/viewman/make2D.c.pamphlet b/src/graph/viewman/make2D.c.pamphlet deleted file mode 100644 index 0f4a3e3e..00000000 --- a/src/graph/viewman/make2D.c.pamphlet +++ /dev/null @@ -1,105 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewman make2D.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _MAKE2D_C -#include "axiom-c-macros.h" - -#include "viewman.h" - -#include "sockio.h" -#include "make2D.H1" - -void -#ifdef _NO_PROTO -makeView2DFromSpadData(viewdata,graphState) - view2DStruct *viewdata; - graphStateStruct graphState[]; -#else -makeView2DFromSpadData(view2DStruct *viewdata,graphStateStruct graphState[]) -#endif -{ - - 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; i<maxGraphs; i++) { - viewdata->graphKeyArray[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); - graphState[i].deltaY = get_float(spadSock); - graphState[i].pointsOn = get_int(spadSock); - graphState[i].connectOn = get_int(spadSock); - graphState[i].splineOn = get_int(spadSock); - graphState[i].axesOn = get_int(spadSock); - graphState[i].axesColor = get_int(spadSock); - 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? */ - - } - } -} -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewman/make3D.c.pamphlet b/src/graph/viewman/make3D.c index 61d84c82..7cac382b 100644 --- a/src/graph/viewman/make3D.c.pamphlet +++ b/src/graph/viewman/make3D.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewman make3D.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _MAKE3D_C #include "axiom-c-macros.h" @@ -177,9 +163,3 @@ makeView3DFromSpadData(view3DStruct *viewdata,int typeOfViewport) } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewman/makeGraph.c.pamphlet b/src/graph/viewman/makeGraph.c index 39e9b2c6..8f8fc540 100644 --- a/src/graph/viewman/makeGraph.c.pamphlet +++ b/src/graph/viewman/makeGraph.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewman makeGraph.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _MAKEGRAPH_C #include "axiom-c-macros.h" @@ -156,9 +142,3 @@ discardGraph (graphStruct *theGraph) free(theGraph); } -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewman/readView.c b/src/graph/viewman/readView.c new file mode 100644 index 00000000..ba65b435 --- /dev/null +++ b/src/graph/viewman/readView.c @@ -0,0 +1,66 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _READVIEW_C +#include "axiom-c-macros.h" + +#include <unistd.h> +#include <stdio.h> +#include <errno.h> + +#include "viewman.h" + +#include "cleanup.H1" + +int +#ifdef _NO_PROTO +readViewport (viewPort,info,size) + viewManager *viewPort; + void *info; + int size; +#else +readViewport (viewManager *viewPort,void *info,int size) +#endif +{ + + int canRead; + +again: + if ((canRead=read(viewPort->viewIn,info,size)) > 0) return(canRead); + if (errno==EINTR || errno==EAGAIN) goto again; + return(-1); +} + + diff --git a/src/graph/viewman/readView.c.pamphlet b/src/graph/viewman/readView.c.pamphlet deleted file mode 100644 index 36614400..00000000 --- a/src/graph/viewman/readView.c.pamphlet +++ /dev/null @@ -1,86 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewman readView.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _READVIEW_C -#include "axiom-c-macros.h" - -#include <unistd.h> -#include <stdio.h> -#include <errno.h> - -#include "viewman.h" - -#include "cleanup.H1" - -int -#ifdef _NO_PROTO -readViewport (viewPort,info,size) - viewManager *viewPort; - void *info; - int size; -#else -readViewport (viewManager *viewPort,void *info,int size) -#endif -{ - - int canRead; - -again: - if ((canRead=read(viewPort->viewIn,info,size)) > 0) return(canRead); - if (errno==EINTR || errno==EAGAIN) goto again; - return(-1); -} - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewman/sselect.c b/src/graph/viewman/sselect.c new file mode 100644 index 00000000..1cb584c5 --- /dev/null +++ b/src/graph/viewman/sselect.c @@ -0,0 +1,103 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _SSELECT_C +#include "axiom-c-macros.h" + +#include <stdio.h> +#include <errno.h> +#include <sys/time.h> +#include <sys/wait.h> +#include <signal.h> + +#include "viewman.h" +#include "bsdsignal.h" + +#include "sockio.h" +#include "bsdsignal.H1" +#include "cleanup.H1" +#include "sselect.H1" + +/******************************************* + * 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 +#ifdef _NO_PROTO +superSelect(n, rd, wr, ex, timeout) + int n; + int *rd, *wr, *ex; + char *timeout; +#else +superSelect(int n, int *rd, int *wr, int *ex, char *timeout) +#endif +{ + + 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 */ + if (checkClosedChild) { + while ((waiting = wait(0)) == -1 ); + viewport = viewports; + while ((viewport) && (viewport->PID != waiting)) + viewport = viewport->nextViewport; + if (viewport) { + /* we shouldn't really be doing this since child is dead */ + /* rmViewMgr(viewport); */ + /* flush(spadSock); */ + /* send_int(spadSock,1); acknowledge to spad */ + checkClosedChild = no; +#if defined(BSDplatform) || defined(MACOSXplatform) + bsdSignal(SIGCHLD,endChild,DontRestartSystemCalls); +#else + bsdSignal(SIGCLD,endChild,DontRestartSystemCalls); +#endif + } + } + ret_val = select(n, (void *)rd, (void *)wr, (void *)ex, (void *)timeout); + } + return ret_val; +} diff --git a/src/graph/viewman/sselect.c.pamphlet b/src/graph/viewman/sselect.c.pamphlet deleted file mode 100644 index 929ced90..00000000 --- a/src/graph/viewman/sselect.c.pamphlet +++ /dev/null @@ -1,123 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewman sselect.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<<license>> - -#define _SSELECT_C -#include "axiom-c-macros.h" - -#include <stdio.h> -#include <errno.h> -#include <sys/time.h> -#include <sys/wait.h> -#include <signal.h> - -#include "viewman.h" -#include "bsdsignal.h" - -#include "sockio.h" -#include "bsdsignal.H1" -#include "cleanup.H1" -#include "sselect.H1" - -/******************************************* - * 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 -#ifdef _NO_PROTO -superSelect(n, rd, wr, ex, timeout) - int n; - int *rd, *wr, *ex; - char *timeout; -#else -superSelect(int n, int *rd, int *wr, int *ex, char *timeout) -#endif -{ - - 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 */ - if (checkClosedChild) { - while ((waiting = wait(0)) == -1 ); - viewport = viewports; - while ((viewport) && (viewport->PID != waiting)) - viewport = viewport->nextViewport; - if (viewport) { - /* we shouldn't really be doing this since child is dead */ - /* rmViewMgr(viewport); */ - /* flush(spadSock); */ - /* send_int(spadSock,1); acknowledge to spad */ - checkClosedChild = no; -#if defined(BSDplatform) || defined(MACOSXplatform) - bsdSignal(SIGCHLD,endChild,DontRestartSystemCalls); -#else - bsdSignal(SIGCLD,endChild,DontRestartSystemCalls); -#endif - } - } - ret_val = select(n, (void *)rd, (void *)wr, (void *)ex, (void *)timeout); - } - return ret_val; -} -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewman/viewman.c.pamphlet b/src/graph/viewman/viewman.c index f90fe853..63136731 100644 --- a/src/graph/viewman/viewman.c.pamphlet +++ b/src/graph/viewman/viewman.c @@ -1,51 +1,37 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/viewman viewman.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<<license>>= /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@ -<<*>>= -<<license>> #define _VIEWMAN_C #include "axiom-c-macros.h" @@ -166,19 +152,19 @@ 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"); @@ -192,7 +178,7 @@ main (void) fprintf(stderr,"The viewport manager cannot drop a graph because nothing has been picked yet.\n"); } break; - + case viewportClosing: #ifdef DEBUG fprintf(stderr,"viewman: closing viewport\n"); @@ -201,7 +187,7 @@ main (void) break; }; /* switch */ - + }; /* if reading slot->viewIn */ stepSlot = slot; slot = slot->nextViewport; @@ -223,18 +209,18 @@ main (void) #endif if (viewCommand == makeViewport) forkView3D(view3DType); - else - funView3D(viewCommand); + else + funView3D(viewCommand); break; - + case viewTubeType: #ifdef DEBUG fprintf(stderr,"viewman: viewing a tube\n"); #endif if (viewCommand == makeViewport) forkView3D(viewTubeType); - else + else funView3D(viewCommand); break; @@ -252,7 +238,7 @@ main (void) case view2DType: #ifdef DEBUG - fprintf(stderr,"viewman: forking 2D\n"); + fprintf(stderr,"viewman: forking 2D\n"); #endif if (viewCommand == makeViewport) { forkView2D(); @@ -268,9 +254,3 @@ main (void) -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/viewman/viewman.h b/src/graph/viewman/viewman.h index 3935f087..3935f087 100755..100644 --- a/src/graph/viewman/viewman.h +++ b/src/graph/viewman/viewman.h |