-
Notifications
You must be signed in to change notification settings - Fork 1
/
MrsvrPlotCanvas.h
238 lines (183 loc) · 5.96 KB
/
MrsvrPlotCanvas.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
//====================================================================
//
// MRI guided robot control system
//
// Copyright (C) 2002-2005 by Junichi Tokuda. All Right Reserved.
// Copyright (C) 2002-2005 by The Univ. of Tokyo, All Right Reserved.
//
//====================================================================
// $RCSfile: MrsvrPlotCanvas.h,v $
// $Revision: 1.1.1.1 $
// $Author: junichi $
// $Date: 2005/01/11 11:38:33 $
//====================================================================
//====================================================================
// Description:
// Plotter module for the consol of MRI guided robot control system.
//
//====================================================================
#ifndef _INC_MRSVR_PLOT_CANVS
#define _INC_MRSVR_PLOT_CANVS
#ifdef DEBUG
//#define DEBUG_MRSVR_PLOT_CANVAS
#endif
#define PLOT_NUM_DATA 10
#include "fx.h"
class MrsvrPlotCanvas : public FXCanvas {
FXDECLARE(MrsvrPlotCanvas);
public:
//Messages
enum {
ID_PLOT,
ID_GAIN,
ID_YOFFSET,
ID_LAST
};
// plot mode
enum {
MODE_REFRESH_ALL,
MODE_SWEEP,
};
protected:
//FXCanvas* canvas;
FXComposite* parentComp;
FXImage* offscreen; // offscreen buffer
FXColor colorBg;
FXColor colorAxis;
// Parameters for drawing waveforms
// - common parameters
FXFunction lineDrawFunction;
FXCapStyle lineCapStyle;
FXJoinStyle lineJoinStyle;
int plotMode;
int nLines; // < PLOT_NUM_DATA
float offsetYAll;
float scaleYAll;
int numGradX; // number of graduations on x axis
int numGradY; // number of graduations on y axis
float pUnitX; // unit length for 1st dim.
float pUnitY; // unit length for 2nd dim. (usually < 0)
int gradSpaceX; // spacing of graduations on x axis (# of units)
int gradSpaceY; // spacing of graduations on y axis (# of units)
float valuePerUnitX; // value per unit for x axis graduations
int gradOrgX; // origin of graduation
int gradOrgY; // origin of graduation
int maxXGradNumHeight; // height of graduation label
int maxXGradNumWidth; // width of graduation label
int maxYGradNumHeight;
int maxYGradNumWidth;
float unitX; // unit length for 1st dim. (in pixel)
float unitY; // unit length for 2nd dim. (in pixel)
FXString* xLabel;
FXString* yLabel;
FXFont* labelFont;
FXString** xGrad;
FXString** yGrad;
int* xGradPos;
int* yGradPos;
// - parameters for each plot
int plotPoints[PLOT_NUM_DATA];
int plotCursor[PLOT_NUM_DATA]; // currentn point in sweep mode
float scaleX[PLOT_NUM_DATA];
float scaleY[PLOT_NUM_DATA];
float offsetY[PLOT_NUM_DATA];
float* data[PLOT_NUM_DATA];
FXColor lineColor[PLOT_NUM_DATA];
FXLineStyle lineStyle[PLOT_NUM_DATA];
FXuint lineWidth[PLOT_NUM_DATA];
FXfloat lineStepX[PLOT_NUM_DATA];
FXString* legend[PLOT_NUM_DATA];
int legendW[PLOT_NUM_DATA];
int legendH[PLOT_NUM_DATA];
private:
// Graph Layout Parameters in pixel
int zeroX;
int zeroY;
int xAxisMin;
int xAxisMax;
int yAxisMin;
int yAxisMax;
int xAxisIntv;
int yAxisIntv;
int xAxisWidth;
int yAxisWidth;
int xLabelX;
int xLabelY;
int xLabelW;
int xLabelH;
int yLabelX;
int yLabelY;
int yLabelW;
int yLabelH;
int windowSizeX;
int windowSizeY;
int windowMargTop; // Top margin (in pixel)
int windowMargBot; // Bottom margin
int windowMargLt; // Left margin
int windowMargRt; // Right margin
int legendTotalW;
int legendTotalH;
// proportional
FXfloat pZeroX;
FXfloat pZeroY;
FXfloat pXAxisMin;
FXfloat pXAxisMax;
FXfloat pYAxisMin;
FXfloat pYAxisMax;
FXfloat pXAxisIntv;
FXfloat pYAxisIntv;
FXfloat pXLabelX;
FXfloat pXLabelY;
FXfloat pYLabelX;
FXfloat pYLabelY;
//FXfloat pLegendX;
//FXfloat pLegendY;
// for plot
FXPoint* pointsBuffer;
int maxPoints;
int triggerFd;
// flag for updates in axis parameters
int fUpdateAxisParam;
public: // Event handler
long onCmdGain(FXObject*, FXSelector, void*);
long onCmdYOffset(FXObject*, FXSelector, void*);
private:
void calcAxisParam();
protected:
MrsvrPlotCanvas();
public:
MrsvrPlotCanvas(FXComposite* p, FXuint opts=FRAME_NORMAL,
FXint x=0,FXint y=0,FXint w=0,FXint h=0);
~MrsvrPlotCanvas();
long onCanvasRepaint(FXObject*, FXSelector, void*);
void setBgColor(FXColor color) {colorBg = color;};
void setAxisStyle(FXColor, FXuint);
void setAxisScaleX(float, int, float);
void setAxisScaleY(float, int);
void setLineProperty(int, FXColor, FXLineStyle, FXuint);
inline void setPlotScale(int id, float scale)
{scaleY[id] = scale;};
inline void setPlotOffset(int id, float offset)
{offsetY[id] = offset;};
inline void setPlotScaleAll(float scale)
{scaleYAll = scale;};
inline void setPlotOffsetAll(float offset)
{offsetYAll = offset;};
void setPlotMode(int);
void resetSweep();
void setLabel(FXchar*, FXchar*);
int addData(short*, int, int); // to be erased
//int addData(short*, int, int, FXString, FXString);
int newData(int);
int newData(int, FXchar*);
void setLegend(int, FXchar*);
void updateData(short*, int);
void updateData(float*, int);
void updateData(short, int); // for sweep mode
void updateData(float, int); // for sweep mode
void create();
void update();
void setTriggerFd(int);
void repaintTrigger();
};
#endif // _INC_MRSVR_PLOT_CANVS