Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

open-axiom repository from github

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