-
Notifications
You must be signed in to change notification settings - Fork 1
/
panel.c
321 lines (246 loc) · 7.32 KB
/
panel.c
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/*
-------------------------------------------------------------------------
OBJECT NAME: panel.c
FULL NAME: Callbacks for Panels from Control Window
ENTRY POINTS: SetPlotShape()
AddPanel()
DeletePanel()
ClearPanel()
SetCurrentPanel()
SetActivePanels()
STATIC FNS: clearSet()
DESCRIPTION:
MODIFIES: CurrentDataFile, CurrentPanel, NumberOfPanels
COPYRIGHT: University Corporation for Atmospheric Research, 1998-2022
-------------------------------------------------------------------------
*/
#include "define.h"
#include "ps.h"
#include <Xm/Form.h>
#include <Xm/Frame.h>
#include <Xm/Label.h>
#include <Xm/List.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/TextF.h>
#include <Xm/ToggleB.h>
void SetInvertLogScale(Widget, XtPointer, XmToggleButtonCallbackStruct *);
extern Widget MainShell, MainWindow;
extern std::vector<Widget> panelB;
/* -------------------------------------------------------------------- */
void SetPlotShape(PLOT_INFO *plot, int shape)
{
int n;
Arg args[4];
if (shape == PORTRAIT)
{
plot->x.windowWidth = 703;
plot->x.windowHeight = 900;
n = 0;
XtSetArg(args[n], XmNx, 10); ++n;
XtSetArg(args[n], XmNy, 30); ++n;
XtSetValues(MainShell, args, n);
}
else
{
plot->x.windowWidth = 900;
plot->x.windowHeight = 703;
n = 0;
XtSetArg(args[n], XmNx, 10); ++n;
XtSetArg(args[n], XmNy, 50); ++n;
XtSetValues(MainShell, args, n);
}
n = 0;
XtSetArg(args[n], XmNwidth, plot->x.windowWidth); ++n;
XtSetArg(args[n], XmNheight, plot->x.windowHeight); ++n;
XtSetValues(plot->canvas, args, n);
SetPrinterShape(shape);
} /* END SETPLOTSHAPE */
/* -------------------------------------------------------------------- */
void SetCurrentPanel(Widget w, XtPointer client, XmToggleButtonCallbackStruct *call)
{
if (call == NULL || call->set)
CurrentPanel = (long)client;
SetInvertLogScale(NULL, NULL, NULL);
} /* END SETCURRENTPANEL */
/* -------------------------------------------------------------------- */
void SetActivePanels(size_t n)
{
size_t i;
XmToggleButtonSetState(panelB[0], True, True);
for (i = 0; i < n; ++i)
XtSetSensitive(panelB[i], True);
for (; i < MAX_PANELS; ++i)
XtSetSensitive(panelB[i], False);
}
/* -------------------------------------------------------------------- */
static int clearSet(DATASET_INFO set[], size_t nSets, size_t panel)
{
size_t i, cnt;
for (i = cnt = 0; i < nSets; ++i)
{
set[cnt] = set[i];
if (set[i].panelIndex == panel)
{
delete [] set[i].data;
set[i].nPoints = 0;
}
else
++cnt;
}
return(cnt);
} /* END CLEARSET */
/* -------------------------------------------------------------------- */
void ClearPanel(Widget w, XtPointer client, XtPointer call)
{
if (PlotType == TIME_SERIES)
{
NumberDataSets = clearSet(dataSet, NumberDataSets, CurrentPanel);
SetYlabels(mainPlot, dataSet, NumberDataSets);
}
else
if (PlotType == XY_PLOT)
{
ShowRegression = 0;
NumberXYXsets = clearSet(xyXset, NumberXYXsets, CurrentPanel);
NumberXYYsets = clearSet(xyYset, NumberXYYsets, CurrentPanel);
SetXlabels(xyyPlot, xyXset, NumberXYXsets);
SetYlabels(xyyPlot, xyYset, NumberXYYsets);
}
DataChanged = True;
DrawMainWindow();
} /* END CLEARPANEL */
/* -------------------------------------------------------------------- */
void AddPanel(Widget w, XtPointer client, XtPointer call)
{
size_t i, nPanels = 0;
PLOT_INFO *plot = 0;
switch (PlotType)
{
case TIME_SERIES:
plot = mainPlot;
nPanels = NumberOfPanels;
break;
case XY_PLOT:
plot = xyyPlot;
nPanels = NumberOfXYpanels;
break;
}
if (nPanels == MAX_PANELS)
{
HandleError("Currently at maximum allowed panels.", Interactive, IRET);
return;
}
ClearAnnotations();
plot[nPanels].Yaxis[0].label = plot[nPanels].Yaxis[1].label = "";
plot[nPanels].Xaxis.label = plot[nPanels-1].Xaxis.label;
plot[nPanels].windowOpen = plot[nPanels].autoScale = plot[nPanels].autoTics = true;
++nPanels;
if (nPanels > 1)
Statistics = False;
CurrentPanel = nPanels-1;
XtSetSensitive(panelB[CurrentPanel], True);
XmToggleButtonSetState(panelB[CurrentPanel], True, True);
switch (PlotType)
{
case TIME_SERIES:
if (!allLabels)
plot[CurrentPanel-1].Xaxis.label = "";
for (i = 0; i < nPanels; ++i)
plot[i].Yaxis[0].nMajorTics =
plot[i].Yaxis[1].nMajorTics = 10 - (nPanels * 2);
if ((NumberOfPanels = nPanels) == 3)
SetPlotShape(&mainPlot[0], PORTRAIT);
else
ResizeMainWindow(NULL, NULL, NULL);
SetMainDefaults();
break;
case XY_PLOT:
if (!allLabels)
{
plot[CurrentPanel].Yaxis[0].label = "";
plot[CurrentPanel].Yaxis[1].label = "";
}
for (i = 0; i < nPanels; ++i)
plot[i].Xaxis.nMajorTics = 10 - (nPanels * 2);
if ((NumberOfXYpanels = nPanels) == 2)
SetPlotShape(&xyyPlot[0], LANDSCAPE);
else
ResizeMainWindow(NULL, NULL, NULL);
SetXYDefaults();
break;
}
} /* END ADDPANEL */
/* -------------------------------------------------------------------- */
void DeletePanel(Widget w, XtPointer client, XtPointer call)
{
size_t i, nPanels = 0;
PLOT_INFO *plot = 0;
switch (PlotType)
{
case TIME_SERIES:
nPanels = NumberOfPanels;
if (nPanels < 2)
return;
plot = mainPlot;
plot[nPanels-2].Xaxis.label = plot[nPanels-1].Xaxis.label;
NumberDataSets = clearSet(dataSet, NumberDataSets, CurrentPanel);
for (i = 0; i < NumberDataSets; ++i)
if (dataSet[i].panelIndex > CurrentPanel)
--dataSet[i].panelIndex;
break;
case XY_PLOT:
nPanels = NumberOfXYpanels;
if (nPanels < 2)
return;
plot = xyyPlot;
NumberXYXsets = clearSet(xyXset, NumberXYXsets, CurrentPanel);
NumberXYYsets = clearSet(xyYset, NumberXYYsets, CurrentPanel);
for (i = 0; i < NumberXYXsets; ++i)
if (xyXset[i].panelIndex > CurrentPanel)
--xyXset[i].panelIndex;
for (i = 0; i < NumberXYYsets; ++i)
if (xyYset[i].panelIndex > CurrentPanel)
--xyYset[i].panelIndex;
break;
}
ClearAnnotations();
if (CurrentPanel == 0)
{
plot[1].title = plot[0].title;
plot[1].subTitle = plot[0].subTitle;
}
--nPanels;
plot[CurrentPanel].windowOpen = False;
for (i = CurrentPanel; i < nPanels; ++i)
plot[i] = plot[i+1];
if (nPanels == 1)
Statistics = True;
XtSetSensitive(panelB[nPanels], False);
if (CurrentPanel >= nPanels)
{
CurrentPanel = nPanels - 1;
XmToggleButtonSetState(panelB[CurrentPanel], True, True);
}
switch (PlotType)
{
case TIME_SERIES:
for (i = 0; i < nPanels; ++i)
plot[i].Yaxis[0].nMajorTics =
plot[i].Yaxis[1].nMajorTics = 10 - (nPanels * 2);
if ((NumberOfPanels = nPanels) == 2)
SetPlotShape(&mainPlot[0], LANDSCAPE);
else
ResizeMainWindow(NULL, NULL, NULL);
break;
case XY_PLOT:
for (i = 0; i < nPanels; ++i)
plot[i].Xaxis.nMajorTics = 10 - (nPanels * 2);
if ((NumberOfXYpanels = nPanels) == 1)
SetPlotShape(&xyyPlot[0], PORTRAIT);
else
ResizeMainWindow(NULL, NULL, NULL);
break;
}
} /* END DELETEPANEL */
/* END PANEL.C */