-
Notifications
You must be signed in to change notification settings - Fork 6
/
jlAxis.h
299 lines (253 loc) · 10.9 KB
/
jlAxis.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/*************************************************************************\
* Copyright (c) 1994-2004 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 1997-2003 Southeastern Universities Research Association,
* as Operator of Thomas Jefferson National Accelerator Facility.
* Copyright (c) 1997-2002 Deutches Elektronen-Synchrotron in der Helmholtz-
* Gemelnschaft (DESY).
* This file is distributed subject to a Software License Agreement found
* in the file LICENSE that is included with this distribution.
\*************************************************************************/
#ifndef _jlAxis
#define _jlAxis
#include <Xm/Xm.h>
#include <limits.h>
#define AXIS_MIN_MAJOR_TICS 4
#define AXIS_MAX_MAJOR_TICS 6
/* AXIS_(MIN/MAX)_TICS
*
* Min/max number of tics permitted on axis.
*/
#define AXIS_MIN_TICS AXIS_MIN_MAJOR_TICS
#define AXIS_MAX_TICS (AXIS_MAX_MAJOR_TICS * 12)
/* AxisDirection
*
* Specifies how the axis should be drawn. UP and DOWN indicate
* horizontal axes while LEFT and RIGHT indicate vertical. In each
* case, the labels and tic marks will be drawn on the nominal side
* of the axis line.
*/
typedef enum _AxisDirection
{
XjAXIS_UP, XjAXIS_DOWN, XjAXIS_LEFT, XjAXIS_RIGHT
}
AxisDirection;
/* AxisEndpointPosition
*
* Indicates the offset of an axis line end point, relative to the
* beginning of the axis widget. The default values of XjAXIS_ORIGIN
* and XjAXIS_TERMINUS indicate that the axis line should stretch the
* entire extent of the widget. Note that numbers outside of
* the range (0, width-1), with the exception of the special values
* noted above, will result in clipping.
*
* NB: min_pos must be less than max_pos.
*/
typedef int AxisEndpointPosition;
#define XjAXIS_ORIGIN INT_MIN
#define XjAXIS_TERMINUS INT_MAX
/* AxisValueType
*
* Specifies how the values are interpreted --as real numbers or
* as dates. If dates, then the value is converted to a struct
* timeval by extracing the integer and fractional parts.
*
* ABSTIME: nicest intervals and tic locations chosen.
* RELTIME_DATES: max point is always labeled, and intuitive
* interval widths are chosen, but the labels
* will not fall on intuitive points.
* RELTIME_NUMBERS: max point is always labeled, and intuitive
* interval widths are chosen, and the labels
* will be numbers relative to the max point,
* which is always 0.
*/
typedef enum _AxisValueType
{
XjAXIS_REAL = 0,
XjAXIS_ABSTIME,
XjAXIS_RELTIME_DATES,
XjAXIS_RELTIME_NUMBERS
}
AxisValueType;
/* AxisTransform
*
* Specifies what function transforms the values
* along the axis interval into points in axis space.
*/
typedef enum _AxisTransform
{
XjAXIS_LINEAR = 0, XjAXIS_LOG10
}
AxisTransform;
/* ====== New resource names ======
*/
#define XjNunitString "unitString"
#define XjNdirection "direction"
#define XjNtransform "transform"
#define XjNvalueType "valueType"
#define XjNlogEpsilon "logEpsilon"
#define XjNminVal "minVal"
#define XjNmaxVal "maxVal"
#define XjNminPos "minPos"
#define XjNmaxPos "maxPos"
#define XjNminMargin "minMargin"
#define XjNusePixmap "usePixmap"
#define XjNtextColor "textColor"
#define XjNpMinVal "pMinVal"
#define XjNpMaxVal "pMaxVal"
#define XjNpLogEpsilon "pLogEpsilon"
/* ====== New resource classes ======
*/
#define XjCUnitString "UnitString"
#define XjCDirection "Direction"
#define XjCValueType "ValueType"
#define XjCTransform "Transform"
#define XjCLogEpsilon "LogEpsilon"
#define XjCMinVal "MinVal"
#define XjCMaxVal "MaxVal"
#define XjCMinPos "MinPos"
#define XjCMaxPos "MaxPos"
#define XjCMinMargin "MinMargin"
#define XjCUsePixmap "UsePixmap"
#define XjCTextColor "TextColor"
#define XjCPMinVal "PMinVal"
#define XjCPMaxVal "PMaxVal"
#define XjCPLogEpsilon "PLogEpsilon"
/* ====== New resource types ======
*/
#define XjRAxisDirection "AxisDirection"
#define XjRAxisEndpointPosition "AxisEndpointPosition"
#define XjRAxisValueType "AxisValueType"
#define XjRAxisTransform "AxisTransform"
#define XjRDouble "Double"
/* ====== Class record constants ====== */
extern WidgetClass axisWidgetClass;
typedef struct _AxisClassRec * AxisWidgetClass;
typedef struct _AxisRec * AxisWidget;
/* ====== some useful public functions ====== */
/* XjAxisGet(Minor/Major)TicOffsets
*
* Fills an array with the tic offsets for the given axis widget,
* returning the number of valid entries written in to the array.
* The integer offsets are from the min endpoint for the currently
* rendered widget.
*/
int XjAxisGetMajorTicOffsets (Widget,
int *, /* array */
int); /* array elem count */
int XjAxisGetMinorTicOffsets (Widget,
int *, /* array */
int); /* array elem count */
/* XjAxisTransformValues(Rasterized/Normalized)
*
* Rasterized: Transforms given array of values from
* (min, max) --> (minPos, maxPos).
*
* Normalized: Transforms given array of values from
* (min, max) --> (0, 1).
*
* NB: Input and output buffers may reference the same array,
* with no ill effects, for in-place transform.
*/
void XjAxisTransformValuesRasterized (Widget,
double *, /* input buffer */
double *, /* result buffer */
int); /* buffer count */
void XjAxisTransformValuesNormalized (Widget,
double *, /* input buffer */
double *, /* result buffer */
int); /* buffer count */
/* XjAxisUntransform(Rasterized/Normalized)Values
*
* Perform inverse transform of above, mapping to a value along the axis.
*
* NB: Input and output buffers may reference the same array,
* with no ill effects, for in-place transform.
*/
void XjAxisTransformValuesRasterized (Widget,
double *, /* input buffer */
double *, /* result buffer */
int); /* buffer count */
void XjAxisTransformValuesNormalized (Widget,
double *, /* input buffer */
double *, /* result buffer */
int); /* buffer count */
/* jlaTransformInfo
*
* This structure contains pre-computed info needed by the following
* transform functions.
*/
typedef struct _jlaTransformInfo
{
AxisTransform transform;
AxisValueType value_type;
AxisEndpointPosition min_pos, max_pos;
double min_val, max_val;
double log_epsilon;
double log_delta;
double log_epsilon_offset;
short log_n_powers;
} jlaTransformInfo;
/* XjAxisGetTransform
*
* Fills the caller-supplied buffer with transform info for
* the given widget.
*/
void XjAxisGetTransform (Widget, jlaTransformInfo *);
/* jlaBuildTransform
*
* Builds a transform structure suitable for subsequent calls
* to jlaTransform...
*
* The whole point of this facility is to allow the outside world
* to use the axis transform algorithms separate from any widget.
* This is good for several reasons: it promotes consistency,
* centralizes complex code, and avoids redundancy.
*/
int jlaBuildTransform (jlaTransformInfo *, /* result buffer */
AxisTransform, /* transform */
AxisValueType, /* value_type */
AxisEndpointPosition, /* min_pos */
AxisEndpointPosition, /* max_pos */
double, /* min_val */
double, /* max_val */
double); /* log_epsilon */
/* jlaTransformValues(Rasterized / Normalized)
*
* Rasterized: Transforms given array of values from
* (min, max) --> (minPos, maxPos).
*
* Normalized: Transforms given array of values from
* (min, max) --> (0, 1).
*
* NB: Input and output buffers may reference the same array,
* with no ill effects, for in-place transform.
*/
void jlaTransformValuesRasterized (jlaTransformInfo *,
double *, /* input buffer */
double *, /* result buffer */
int); /* buffer count */
void jlaTransformValuesNormalized (jlaTransformInfo *,
double *, /* input buffer */
double *, /* result buffer */
int); /* buffer count */
/* jlaUntransform(Rasterized/Normalized)Values
*
* Perform inverse transform of above, mapping to a value along the axis.
*
* NB: Input and output buffers may reference the same array,
* with no ill effects, for in-place transform.
*/
void jlaUntransformRasterizedValues (jlaTransformInfo *,
double *, /* input buffer */
double *, /* result buffer */
int); /* buffer count */
void jlaUntransformNormalizedValues (jlaTransformInfo *,
double *, /* input buffer */
double *, /* result buffer */
int); /* buffer count */
void XjAxisUntransformRasterizedValues (Widget w,
register double *x_in,
register double *x_out,
register int n);
#endif /* #ifndef _jlAxis */