1 /* 2 Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without 6 modification, are permitted provided that the following conditions are 7 met: 8 9 - Redistributions of source code must retain the above copyright 10 notice, this list of conditions and the following disclaimer. 11 12 - Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in 14 the documentation and/or other materials provided with the 15 distribution. 16 17 - Neither the name of The Numerical ALgorithms Group Ltd. nor the 18 names of its contributors may be used to endorse or promote products 19 derived from this software without specific prior written permission. 20 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 24 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 25 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #include <X11/Xlib.h> 35 #include <X11/Xresource.h> 36 #include <setjmp.h> 37 38 /* for XDefs */ 39 #define view2D 40 41 #include "hash.h" 42 #include "noX10.h" 43 #include "view.h" 44 #include "view2D.h" 45 #include "actions.h" 46 #include "viewCommand.h" 47 #include "XDefs.h" 48 #include "override.h" 49 #include "G.h" /* Gdraw functions header file */ 50 51 52 53 #define carefullySetFont(gc,font) if (font != serverFont) XSetFont(dsply,gc,font->fid) 54 55 #define controlMASK (ButtonPressMask + ExposureMask) 56 #define potMASK (ButtonPressMask + ButtonReleaseMask + ButtonMotionMask + LeaveWindowMask) 57 #define buttonMASK (ButtonPressMask + ButtonReleaseMask + LeaveWindowMask) 58 #define colorMASK (ButtonPressMask + ButtonReleaseMask + LeaveWindowMask) 59 60 /* make mouse grab for stationery mouse on a potentiometer slower */ 61 #define mouseWait 50 62 63 #define controlCreateMASK (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor |CWColormap | CWOverrideRedirect) 64 #define buttonCreateMASK CWEventMask 65 #define messageCreateMASK 0 66 #define colormapCreateMASK CWEventMask 67 68 #define controlWidth 236 69 #define controlHeight 400 70 71 #define closeLeft cp->buttonQueue[closeAll2D].buttonX - 5 72 #define closeTop cp->buttonQueue[closeAll2D].buttonY - 5 73 74 #define controlBackground WhitePixel(dsply,scrn) 75 #define controlCursorForeground monoColor(4) 76 #define controlCursorBackground monoColor(44) 77 #define controlTitleColor monoColor(36) 78 #define controlPotHeaderColor monoColor(52) 79 #define controlColorColor monoColor(13) 80 #define controlColorSignColor monoColor(22) 81 82 #define controlMessageHeight globalFont->max_bounds.ascent + globalFont->max_bounds.descent+4 83 #define messageBot controlMessageY + controlMessageHeight 84 85 #define headerHeight headerFont->max_bounds.ascent 86 #define graphHeaderHeight messageBot + headerHeight 87 88 #define graphBarTop graphHeaderHeight + 12 89 #define graphBarLeft 66 90 #define graphBarWidth graphFont->max_bounds.width 91 #define graphBarHeight graphFont->max_bounds.ascent + graphFont->max_bounds.descent 92 93 #define colormapX 10 94 #define colormapY 235 95 #define colormapW 280 96 #define colormapH 60 97 98 #define colorWidth 8 99 #define colorHeight 12 100 101 #define colorOffset 3 102 #define colorOffsetX 24 103 #define colorOffsetY 20 104 #define colorPointer 18 105 106 #define buttonColor monoColor(105) 107 108 #define graphBarDefaultColor monoColor(15) 109 #define graphBarShowingColor monoColor(15) 110 #define graphBarHiddenColor monoColor(138) 111 #define graphBarSelectColor monoColor(15) 112 #define graphBarNotSelectColor monoColor(138) 113 114 #define viewportCreateMASK (CWBackPixel|CWBorderPixel|CWEventMask|CWColormap) 115 #define viewportTitleCreateMASK (CWBackPixel|CWBorderPixel|CWColormap|CWEventMask|CWOverrideRedirect) 116 117 #define viewportMASK (KeyPressMask + ButtonPressMask + ExposureMask) 118 #define titleMASK ExposureMask 119 120 #define lineWidth 1 121 #define lineHeight 1 122 123 #define titleColor monoColor(36) 124 #define titleHeight 24 125 #define appendixHeight 0 126 127 #define viewWidth 400 128 #define viewHeight 400 129 130 #define viewBorderWidth 0 131 #define borderWidth 22 132 #define borderHeight 45 133 134 #define initDeltaX 0.0 135 #define initDeltaY 0.0 136 #define initScale 1.3 137 138 #define minScale 0.01 139 #define maxScale 1000.0 140 #define maxDelta 1000.0 141 142 #define scaleFactor 0.5 143 #define translateFactor 10 144 145 #define viewCursorForeground monoColor(166) 146 #define viewCursorBackground monoColor(5) 147 148 #define axisLength 100.0 149 150 #define axesColorDefault 35 151 #define labelColor 22 152 153 #define meshOutline monoColor(132) 154 #define opaqueOutline monoColor(53) 155 #define opaqueForeground monoColor(236) 156 157 #define drawWireFrame 0 158 #define drawOpaque 1 159 #define drawRendered 2 160 161 162 #define numOfColors 240 163 164 #define totalHuesConst 27 165 #define totalShadesConst 8 166 #define hueEnd 360 167 #define hueStep hueEnd/totalHuesConst 168 169 #define numPlanes 1 170 #define numColors 10 171 #define startColor 0 172 #define endColor startColor+numColors 173 #define maxColors DisplayCells(dsply,scrn)-1 174 175 #define colorStep (maxColors+1)/numColors 176 177 178 #define physicalWidth DisplayWidth(dsply,scrn) 179 #define physicalHeight DisplayHeight(dsply,scrn) 180 #define deep DisplayPlanes(dsply,scrn) 181 182 #define basicScreen 19 183 184 #define yes 1 185 #define no 0 186 187 #define potA 25 /* line dividing potentiometers from stuff above it */ 188 #define potB 173 /* line dividing potentiometers from title */ 189 #define butA 260 /* line dividing buttons from stuff above it */ 190 191 #define controlMessageY 181 192 #define controlMessageColor monoColor(29) 193 194 #define nbuckets 128 195 196 #define anywhere 0 197 198 199 #define intSize sizeof(int) 200 #define floatSize sizeof(float) 201 202 /* type is X, PS,... */ 203 204 #define drawViewport(type) drawTheViewport(type); 205 206 typedef struct _buttonStruct { 207 int buttonKey, pot, mask, graphNum, graphSelect; 208 short buttonX,buttonY,buttonWidth,buttonHeight,xHalf,yHalf; 209 Window self; 210 char text[40]; 211 int textColor, textHue, textShade; 212 } buttonStruct; 213 214 typedef struct _controlPanelStruct { 215 int numOfButtons; 216 Window controlWindow,messageWindow,colormapWindow; 217 char message[40]; 218 struct _buttonStruct buttonQueue[maxButtons2D]; 219 } controlPanelStruct; 220 221 typedef struct _mouseCoord { 222 float x,y; 223 } mouseCoord; 224 225 typedef struct _viewPoints { 226 int viewportKey; 227 char title[80]; 228 Window viewWindow,titleWindow; 229 controlPanelStruct *controlPanel; 230 int justMadeControl,haveControl, 231 axesOn,unitsOn,pointsOn,linesOn,splineOn,closing, 232 allowDraw; 233 struct _viewPoints *prevViewport,*nextViewport; 234 } viewPoints; 235 236 237 typedef struct _controlXY { 238 int putX,putY; 239 } controlXY; 240 241 242 typedef struct _xPointStruct { 243 XPoint *xPoint; 244 Vertex *x10Point; 245 XArc *arc; 246 } xPointStruct; 247 248 #define projX(x,w,i) ((((float)x/w-0.5)/graphStateArray[i].scaleX + \ 249 graphStateArray[i].centerX + 0.5) / \ 250 graphArray[i].xNorm + graphArray[i].xmin) 251 252 #define projY(y,h,i) (((0.5-(float)y/h*aspectR)/graphStateArray[i].scaleY + \ 253 graphStateArray[i].centerY + 0.5) / \ 254 graphArray[i].yNorm + graphArray[i].ymin) 255 256 #define isNaN(v) (v != v) 257 258 #include "globals2.h" 259