open-axiom repository from github
/*1Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd.2All rights reserved.3Copyright (C) 2007-2008, Gabriel Dos Reis.4All rights resrved.56Redistribution and use in source and binary forms, with or without7modification, are permitted provided that the following conditions are8met:910- Redistributions of source code must retain the above copyright11notice, this list of conditions and the following disclaimer.1213- Redistributions in binary form must reproduce the above copyright14notice, this list of conditions and the following disclaimer in15the documentation and/or other materials provided with the16distribution.1718- Neither the name of The Numerical ALgorithms Group Ltd. nor the19names of its contributors may be used to endorse or promote products20derived from this software without specific prior written permission.2122THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS23IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED24TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A25PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER26OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,27EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,28PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR29PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF30LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING31NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS32SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.33*/3435#include <X11/Xlib.h>36#include <X11/Xresource.h>37#include <setjmp.h>3839/* for XDefs */40#define view2D4142#include "hash.h"43#include "noX10.h"44#include "view.h"45#include "view2D.h"46#include "actions.h"47#include "viewCommand.h"48#include "XDefs.h"49#include "override.h"50#include "G.h" /* Gdraw functions header file */51525354#define carefullySetFont(gc,font) if (font != serverFont) XSetFont(dsply,gc,font->fid)5556#define controlMASK (ButtonPressMask + ExposureMask)57#define potMASK (ButtonPressMask + ButtonReleaseMask + ButtonMotionMask + LeaveWindowMask)58#define buttonMASK (ButtonPressMask + ButtonReleaseMask + LeaveWindowMask)59#define colorMASK (ButtonPressMask + ButtonReleaseMask + LeaveWindowMask)6061/* make mouse grab for stationery mouse on a potentiometer slower */62#define mouseWait 506364#define controlCreateMASK (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor |CWColormap | CWOverrideRedirect)65#define buttonCreateMASK CWEventMask66#define messageCreateMASK 067#define colormapCreateMASK CWEventMask6869#define controlWidth 23670#define controlHeight 4007172#define closeLeft cp->buttonQueue[closeAll2D].buttonX - 573#define closeTop cp->buttonQueue[closeAll2D].buttonY - 57475#define controlBackground WhitePixel(dsply,scrn)76#define controlCursorForeground monoColor(4)77#define controlCursorBackground monoColor(44)78#define controlTitleColor monoColor(36)79#define controlPotHeaderColor monoColor(52)80#define controlColorColor monoColor(13)81#define controlColorSignColor monoColor(22)8283#define controlMessageHeight globalFont->max_bounds.ascent + globalFont->max_bounds.descent+484#define messageBot controlMessageY + controlMessageHeight8586#define headerHeight headerFont->max_bounds.ascent87#define graphHeaderHeight messageBot + headerHeight8889#define graphBarTop graphHeaderHeight + 1290#define graphBarLeft 6691#define graphBarWidth graphFont->max_bounds.width92#define graphBarHeight graphFont->max_bounds.ascent + graphFont->max_bounds.descent9394#define colormapX 1095#define colormapY 23596#define colormapW 28097#define colormapH 609899#define colorWidth 8100#define colorHeight 12101102#define colorOffset 3103#define colorOffsetX 24104#define colorOffsetY 20105#define colorPointer 18106107#define buttonColor monoColor(105)108109#define graphBarDefaultColor monoColor(15)110#define graphBarShowingColor monoColor(15)111#define graphBarHiddenColor monoColor(138)112#define graphBarSelectColor monoColor(15)113#define graphBarNotSelectColor monoColor(138)114115#define viewportCreateMASK (CWBackPixel|CWBorderPixel|CWEventMask|CWCursor|CWColormap)116#define viewportTitleCreateMASK (CWBackPixel|CWBorderPixel|CWCursor|CWColormap|CWEventMask|CWOverrideRedirect)117118#define viewportMASK (KeyPressMask + ButtonPressMask + ExposureMask)119#define titleMASK ExposureMask120121#define lineWidth 1122#define lineHeight 1123124#define titleColor monoColor(36)125#define titleHeight 24126#define appendixHeight 0127128#define viewWidth 400129#define viewHeight 400130131#define viewBorderWidth 0132#define borderWidth 22133#define borderHeight 45134135#define initDeltaX 0.0136#define initDeltaY 0.0137#define initScale 1.3138139#define minScale 0.01140#define maxScale 1000.0141#define maxDelta 1000.0142143#define scaleFactor 0.5144#define translateFactor 10145146#define viewCursorForeground monoColor(166)147#define viewCursorBackground monoColor(5)148149#define axisLength 100.0150151#define axesColorDefault 35152#define labelColor 22153154#define meshOutline monoColor(132)155#define opaqueOutline monoColor(53)156#define opaqueForeground monoColor(236)157158#define drawWireFrame 0159#define drawOpaque 1160#define drawRendered 2161162163#define numOfColors 240164165#define totalHuesConst 27166#define totalShadesConst 8167#define hueEnd 360168#define hueStep hueEnd/totalHuesConst169170#define numPlanes 1171#define numColors 10172#define startColor 0173#define endColor startColor+numColors174#define maxColors DisplayCells(dsply,scrn)-1175176#define colorStep (maxColors+1)/numColors177178179#define physicalWidth DisplayWidth(dsply,scrn)180#define physicalHeight DisplayHeight(dsply,scrn)181#define deep DisplayPlanes(dsply,scrn)182183#define basicScreen 19184185#define yes 1186#define no 0187188#define potA 25 /* line dividing potentiometers from stuff above it */189#define potB 173 /* line dividing potentiometers from title */190#define butA 260 /* line dividing buttons from stuff above it */191192#define controlMessageY 181193#define controlMessageColor monoColor(29)194195#define pi_half 1.570796326794896619231321691639751442099196#define pi 3.141592653589793238462643383279502884197197#define three_pi_halves 4.712388980384689857693965074919254326296198#define two_pi 6.283185307179586476925286766559005768394199200#define degrees_in_two_pi 57201#define d2Pi 57202203#define viewBackground 0204205#define nbuckets 128206207#define anywhere 0208209210#define intSize sizeof(int)211#define floatSize sizeof(float)212213/* type is X, PS,... */214215#define drawViewport(type) drawTheViewport(type);216#define spadDrawViewport() spadMode++; drawTheViewport(X); spadMode--;217218219typedef struct _buttonStruct {220int buttonKey, pot, mask, graphNum, graphSelect;221short buttonX,buttonY,buttonWidth,buttonHeight,xHalf,yHalf;222Window self;223char text[40];224int textColor, textHue, textShade;225} buttonStruct;226227typedef struct _controlPanelStruct {228int numOfButtons;229Window controlWindow,messageWindow,colormapWindow;230char message[40];231struct _buttonStruct buttonQueue[maxButtons2D];232} controlPanelStruct;233234typedef struct _mouseCoord {235float x,y;236} mouseCoord;237238typedef struct _viewPoints {239int viewportKey;240char title[80];241Window viewWindow,titleWindow;242controlPanelStruct *controlPanel;243int justMadeControl,haveControl,244axesOn,unitsOn,pointsOn,linesOn,splineOn,closing,245allowDraw;246struct _viewPoints *prevViewport,*nextViewport;247} viewPoints;248249250typedef struct _controlXY {251int putX,putY;252} controlXY;253254255typedef struct _xPointStruct {256XPoint *xPoint;257Vertex *x10Point;258XArc *arc;259} xPointStruct;260261262263#define calcUnitX(ii) (vwInfo.width * \264((graphArray[0].unitX * ii + \265graphArray[0].originX - graphStateArray[0].centerX) *\266graphStateArray[0].scaleX + 0.5))267#define calcUnitY(ii) (vwInfo.height * aspectR * \268(1 - ((graphArray[0].unitY*aspectR * ii + \269graphArray[0].originY*aspectR - \270graphStateArray[0].centerY) * \271graphStateArray[0].scaleY + 0.5*aspectR )))272273#define projX(x,w,i) ((((float)x/w-0.5)/graphStateArray[i].scaleX + \274graphStateArray[i].centerX + 0.5) / \275graphArray[i].xNorm + graphArray[i].xmin)276277#define projY(y,h,i) (((0.5-(float)y/h*aspectR)/graphStateArray[i].scaleY + \278graphStateArray[i].centerY + 0.5) / \279graphArray[i].yNorm + graphArray[i].ymin)280281#define isNaN(v) (v != v)282283#include "globals2.h"284285286287