-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathed_xy.c
176 lines (123 loc) · 5 KB
/
ed_xy.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
/*
-------------------------------------------------------------------------
OBJECT NAME: ed_xy.c
FULL NAME: Callbacks for Edit XY Parameteres
ENTRY POINTS: EditXYParms()
SetXYDefaults()
STATIC FNS: CreateXYParmsWindow()
ApplyXYParms()
SetXYAutoScale()
DESCRIPTION:
COPYRIGHT: University Corporation for Atmospheric Research, 1992-2022
-------------------------------------------------------------------------
*/
#include "define.h"
#include <Xm/RowColumn.h>
#include <Xm/TextF.h>
#include <Xm/ToggleB.h>
static const size_t TOTAL_PARMS = 17;
extern Widget AppShell;
static Widget XYShell = NULL, XYParmsWindow, parmsText[TOTAL_PARMS],
autoScaleButton, autoTicsButton;
static std::vector<Widget> panelB;
static int currentPanel = 0;
static void CreateXYParmsWindow(),
ApplyXYParms(Widget w, XtPointer client, XtPointer call);
/* -------------------------------------------------------------------- */
void EditXYParms(Widget w, XtPointer client, XtPointer call)
{
static bool firstTime = True;
if (firstTime)
{
CreateXYParmsWindow();
firstTime = False;
}
XtManageChild(XYParmsWindow);
XtPopup(XtParent(XYParmsWindow), XtGrabNone);
SetXYDefaults();
} /* END EDITXYPARMS */
/* -------------------------------------------------------------------- */
void SetXYDefaults()
{
size_t i;
if (XYShell == NULL)
return;
SetDefaults(parmsText, &xyyPlot[currentPanel]);
// SetLogInvert(parmsTB, &xyyPlot[currentPanel], X_AXIS | Y_AXIS);
XmTextFieldSetString(parmsText[0], const_cast<char *>(xyyPlot[0].title.c_str()));
XmTextFieldSetString(parmsText[1], const_cast<char *>(xyyPlot[0].subTitle.c_str()));
for (i = 0; i < NumberOfXYpanels; ++i)
XtSetSensitive(panelB[i], True);
for (; i < MAX_PANELS; ++i)
XtSetSensitive(panelB[i], False);
XmToggleButtonSetState(autoScaleButton, xyyPlot[currentPanel].autoScale, False);
XmToggleButtonSetState(autoTicsButton, xyyPlot[currentPanel].autoTics, False);
for (i = 5; i < 11; ++i)
XtSetSensitive(parmsText[i], 1-xyyPlot[currentPanel].autoScale);
for (i = 11; i < 15; ++i)
XtSetSensitive(parmsText[i], 1-xyyPlot[currentPanel].autoTics);
} /* END SETXYDEFAULTS */
/* -------------------------------------------------------------------- */
static void SetXYAutoScale(Widget w, XtPointer client, XtPointer call)
{
int i;
for (i = 5; i < 11; ++i)
XtSetSensitive(parmsText[i], xyyPlot[currentPanel].autoScale);
xyyPlot[currentPanel].autoScale = 1 - xyyPlot[currentPanel].autoScale;
} /* END SETXYDEFAULTS */
/* -------------------------------------------------------------------- */
static void SetXYAutoTics(Widget w, XtPointer client, XtPointer call)
{
int i;
for (i = 11; i < 15; ++i)
XtSetSensitive(parmsText[i], xyyPlot[currentPanel].autoTics);
xyyPlot[currentPanel].autoTics = 1 - xyyPlot[currentPanel].autoTics;
} /* END SETXYDEFAULTS */
/* -------------------------------------------------------------------- */
static void ApplyXYParms(Widget w, XtPointer client, XtPointer call)
{
ApplyParms(parmsText, &xyyPlot[currentPanel]);
// ApplyLogInvert(parmsTB, &xyyPlot[currentPanel], X_AXIS | Y_AXIS);
for (size_t i = 0; i < MAX_PANELS; ++i)
{
xyyPlot[i].title = xyyPlot[currentPanel].title;
xyyPlot[i].subTitle = xyyPlot[currentPanel].subTitle;
}
DrawMainWindow();
} /* END APPLYXYPARMS */
/* -------------------------------------------------------------------- */
static void SetXYPanel(Widget w, XtPointer client, XtPointer call)
{
currentPanel = (long)client;
EditXYParms(NULL, NULL, NULL);
} /* END SETPLOTPANEL */
/* -------------------------------------------------------------------- */
static void CreateXYParmsWindow()
{
size_t i;
Widget RC[6];
XYShell = XtCreatePopupShell("editXYShell",
topLevelShellWidgetClass, AppShell, NULL, 0);
XYParmsWindow = XmCreateRowColumn(XYShell, (char *)"parmsRC", NULL, 0);
for (i = 0; i < TOTAL_PARMS; ++i)
parmsText[i] = NULL;
RC[0] = createParamsTitles(XYParmsWindow, parmsText);
createPanelButts(RC[0], panelB, SetXYPanel);
RC[1] = createParamsLabels(XYParmsWindow, parmsText, &xyyPlot[0]);
RC[2] = createParamsMinMax(XYParmsWindow, parmsText, &xyyPlot[0], &autoScaleButton);
RC[3] = createParamsTics(XYParmsWindow, parmsText, &xyyPlot[0], &autoTicsButton);
// RC[4] = createLogInvert(XYParmsWindow, parmsTB, ApplyXYParms,
// &xyyPlot[0], X_AXIS | Y_AXIS);
RC[4] = createARDbuttons(XYParmsWindow);
XtManageChild(RC[0]); XtManageChild(RC[1]);
XtManageChild(RC[2]); XtManageChild(RC[3]);
XtManageChild(RC[4]);
XtAddCallback(autoScaleButton, XmNvalueChangedCallback, SetXYAutoScale, NULL);
XtAddCallback(autoTicsButton, XmNvalueChangedCallback, SetXYAutoTics, NULL);
XtAddCallback(autoScaleButton, XmNvalueChangedCallback, ApplyXYParms, NULL);
XtAddCallback(autoTicsButton, XmNvalueChangedCallback, ApplyXYParms, NULL);
for (i = 0; i < TOTAL_PARMS-1; ++i)
if (parmsText[i])
XtAddCallback(parmsText[i], XmNlosingFocusCallback, ApplyXYParms, NULL);
} /* END CREATEXYPARMSWINDOW */
/* END ED_XY.C */