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
|
/*
* Smithsonian Astrophysical Observatory, Cambridge, MA, USA
* This code has been modified under the terms listed below and is made
* available under the same terms.
*/
/*
* Copyright 1993-2004 George A Howlett.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
* KIND, EXPRESS OR IMPIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
* OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef ___BltGrAxis_h__
#define ___BltGrAxis_h__
#include <tk.h>
#include "tkbltChain.h"
#include "tkbltGrMisc.h"
#include "tkbltGrText.h"
#include "tkbltGrPSOutput.h"
namespace Blt {
class Graph;
class Postscript;
typedef struct {
int axis;
int t1;
int t2;
int label;
} AxisInfo;
typedef struct {
const char* name;
ClassId classId;
} AxisName;
extern AxisName axisNames[];
typedef struct {
Dashes dashes;
int lineWidth;
XColor* color;
GC gc;
Segment2d *segments;
int nUsed;
int nAllocated;
} Grid;
typedef struct {
double min;
double max;
double range;
double scale;
} AxisRange;
class TickLabel {
public:
Point2d anchorPos;
unsigned int width;
unsigned int height;
char* string;
public:
TickLabel(char*);
virtual ~TickLabel();
};
class Ticks {
public:
int nTicks;
double* values;
public:
Ticks(int);
virtual ~Ticks();
};
typedef struct {
double initial;
double step;
int nSteps;
} TickSweep;
typedef struct {
const char** tags;
int checkLimits;
int exterior;
int showGrid;
int showGridMinor;
int hide;
int showTicks;
double windowSize;
const char *tickFormatCmd;
int descending;
int labelOffset;
TextStyleOptions limitsTextStyle;
const char *limitsFormat;
int lineWidth;
int logScale;
int looseMin;
int looseMax;
Ticks* t1UPtr;
Ticks* t2UPtr;
double reqMin;
double reqMax;
Tcl_Obj *scrollCmdObjPtr;
int scrollUnits;
double reqScrollMin;
double reqScrollMax;
double shiftBy;
double reqStep;
int reqNumMajorTicks;
int reqNumMinorTicks;
int tickLength;
const char *title;
int titleAlternate;
XColor* activeFgColor;
int activeRelief;
Tk_3DBorder normalBg;
int borderWidth;
XColor* tickColor;
Grid major;
Grid minor;
Tk_Justify titleJustify;
int relief;
double tickAngle;
Tk_Anchor reqTickAnchor;
Tk_Font tickFont;
Tk_Font titleFont;
XColor* titleColor;
const char *tickFormat;
} AxisOptions;
class Axis {
protected:
Tk_OptionTable optionTable_;
void* ops_;
public:
Graph* graphPtr_;
ClassId classId_;
const char* name_;
const char* className_;
Tcl_HashEntry* hashPtr_;
int refCount_;
int use_;
int active_;
ChainLink* link;
Chain* chain;
Point2d titlePos_;
unsigned int titleWidth_;
unsigned int titleHeight_;
double min_;
double max_;
double scrollMin_;
double scrollMax_;
AxisRange valueRange_;
AxisRange axisRange_;
double prevMin_;
double prevMax_;
Ticks* t1Ptr_;
Ticks* t2Ptr_;
TickSweep minorSweep_;
TickSweep majorSweep_;
int margin_;
Segment2d *segments_;
int nSegments_;
Chain* tickLabels_;
int left_;
int right_;
int top_;
int bottom_;
int width_;
int height_;
int maxTickWidth_;
int maxTickHeight_;
Tk_Anchor tickAnchor_;
GC tickGC_;
GC activeTickGC_;
double titleAngle_;
Tk_Anchor titleAnchor_;
double screenScale_;
int screenMin_;
int screenRange_;
protected:
double niceNum(double, int);
void setRange(AxisRange*, double, double);
void makeGridLine(double, Segment2d*);
void makeSegments(AxisInfo*);
void resetTextStyles();
void makeLine(int, Segment2d*);
void makeTick(double, int, int, Segment2d*);
void offsets(int, int, AxisInfo*);
void updateScrollbar(Tcl_Interp*, Tcl_Obj*, int, int, int);
public:
Axis(Graph*, const char*, int, Tcl_HashEntry*);
virtual ~Axis();
Tk_OptionTable optionTable() {return optionTable_;}
void* ops() {return ops_;}
ClassId classId() {return classId_;}
const char* className() {return className_;}
int configure();
void map(int, int);
void draw(Drawable);
void drawGrids(Drawable);
void drawLimits(Drawable);
void print(PSOutput*);
void printGrids(PSOutput*);
void printLimits(PSOutput*);
void mapStacked(int, int);
void mapGridlines();
void setClass(ClassId);
void logScale(double, double);
void linearScale(double, double);
void fixRange();
int isHorizontal();
void freeTickLabels();
TickLabel* makeLabel(double);
void getDataLimits(double, double);
Ticks* generateTicks(TickSweep*);
int inRange(double, AxisRange*);
void getGeometry();
double invHMap(double x);
double invVMap(double y);
double hMap(double x);
double vMap(double y);
};
};
#endif
|