-
Notifications
You must be signed in to change notification settings - Fork 1
/
ed_spec.c
157 lines (110 loc) · 4.28 KB
/
ed_spec.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
/*
-------------------------------------------------------------------------
OBJECT NAME: ed_spec.c
FULL NAME: Callbacks for Edit Spectral Parameteres
ENTRY POINTS: CreateSpecParmsWindow()
EditSpecParms()
STATIC FNS: SetSpecDefaults()
ApplySpecParms()
SetSpecAutoScale()
SetSpecAutoTics()
DESCRIPTION:
COPYRIGHT: University Corporation for Atmospheric Research, 1992-2022
-------------------------------------------------------------------------
*/
#include "define.h"
#include "spec.h"
#include <Xm/RowColumn.h>
#include <Xm/ToggleB.h>
static const int TOTAL_PARMS = 17;
extern Widget AppShell;
static Widget SpecShell = NULL, SpecParmsWindow, parmsText[TOTAL_PARMS],
parmsTB[6], autoScaleButton, autoTicsButton;
static void CreateSpecParmsWindow(),
ApplySpecParms(Widget w, XtPointer client, XtPointer call);
void SetSpecDefaults();
/* -------------------------------------------------------------------- */
void EditSpecParms(Widget w, XtPointer client, XtPointer call)
{
static bool firstTime = True;
if (firstTime)
{
CreateSpecParmsWindow();
firstTime = False;
}
XtManageChild(SpecParmsWindow);
XtPopup(XtParent(SpecParmsWindow), XtGrabNone);
SetSpecDefaults();
} /* END EDITSPECPARMS */
/* -------------------------------------------------------------------- */
void SetSpecDefaults()
{
int i;
if (SpecShell == NULL)
return;
SetDefaults(parmsText, &specPlot);
SetLogInvert(parmsTB, &specPlot, X_AXIS | Y_AXIS);
XmToggleButtonSetState(autoScaleButton, specPlot.autoScale, False);
XmToggleButtonSetState(autoTicsButton, specPlot.autoTics, False);
for (i = 5; i < 9; ++i)
XtSetSensitive(parmsText[i], 1-specPlot.autoScale);
for (i = 11; i < 15; ++i)
XtSetSensitive(parmsText[i], 1-specPlot.autoTics);
} /* END SETSPECDEFAULTS */
/* -------------------------------------------------------------------- */
static void ApplySpecParms(Widget w, XtPointer client, XtPointer call)
{
ApplyParms(parmsText, &specPlot);
ApplyLogInvert(parmsTB, &specPlot, X_AXIS | Y_AXIS);
if (specPlot.windowOpen)
PlotSpectrum(NULL, NULL, NULL);
SetSpecDefaults();
} /* END APPLYSPECPARMS */
/* -------------------------------------------------------------------- */
static void SetSpecAutoScale(Widget w, XtPointer client, XtPointer call)
{
int i;
for (i = 5; i < 9; ++i)
XtSetSensitive(parmsText[i], specPlot.autoScale);
specPlot.autoScale = 1 - specPlot.autoScale;
} /* END SETDIFFDEFAULTS */
/* -------------------------------------------------------------------- */
static void SetSpecAutoTics(Widget w, XtPointer client, XtPointer call)
{
int i;
for (i = 11; i < 15; ++i)
XtSetSensitive(parmsText[i], specPlot.autoTics);
specPlot.autoTics = 1 - specPlot.autoTics;
} /* END SETDIFFDEFAULTS */
/* -------------------------------------------------------------------- */
void CreateSpecParmsWindow()
{
int n, i;
Widget RC[6];
Arg args[10];
n = 0;
SpecShell = XtCreatePopupShell("editSpecShell",
topLevelShellWidgetClass, AppShell, args, n);
n = 0;
SpecParmsWindow = XmCreateRowColumn(SpecShell, (char *)"parmsRC", args, n);
for (i = 0; i < TOTAL_PARMS; ++i)
parmsText[i] = NULL;
RC[0] = createParamsTitles(SpecParmsWindow, parmsText);
RC[1] = createParamsLabels(SpecParmsWindow, parmsText, &specPlot);
RC[2] = createParamsMinMax(SpecParmsWindow, parmsText, &specPlot, &autoScaleButton);
RC[3] = createParamsTics(SpecParmsWindow, parmsText, &specPlot, &autoTicsButton);
RC[4] = createLogInvert(SpecParmsWindow, parmsTB, ApplySpecParms,
&specPlot, X_AXIS | Y_AXIS);
RC[5] = createARDbuttons(SpecParmsWindow);
XtManageChild(RC[0]); XtManageChild(RC[1]);
XtManageChild(RC[2]); XtManageChild(RC[3]);
XtManageChild(RC[4]); XtManageChild(RC[5]);
XtAddCallback(autoScaleButton, XmNvalueChangedCallback, SetSpecAutoScale, NULL);
XtAddCallback(autoTicsButton, XmNvalueChangedCallback, SetSpecAutoTics, NULL);
XtAddCallback(autoScaleButton, XmNvalueChangedCallback, ApplySpecParms, NULL);
XtAddCallback(autoTicsButton, XmNvalueChangedCallback, ApplySpecParms, NULL);
for (i = 0; i < TOTAL_PARMS-1; ++i)
if (parmsText[i])
XtAddCallback(parmsText[i], XmNlosingFocusCallback, ApplySpecParms, NULL);
} /* END CREATESPECPARMSWINDOW */
/* END ED_SPEC.C */