-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathas_qcalibration__define.pro
231 lines (170 loc) · 10.5 KB
/
as_qcalibration__define.pro
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
PRO as_QCalibration_event, event
@as_scatterheader.macro
Widget_Control, event.top, GET_UVALUE = as_QCalibration
as_QCalibration.event, event
END
PRO as_QCalibration::event, event
@as_scatterheader.macro
widgetName = Widget_Info(event.ID, /UNAME)
CASE widgetName OF
'QCALIB BASE' : BEGIN
; IF Tag_Names(event, /STRUCTURE_NAME) EQ 'WIDGET_KILL_REQUEST' THEN BEGIN
; Widget_Control, self.wQCalibBase, /DESTROY
; Obj_Destroy, self
; ENDIF
IF Tag_Names(event, /STRUCTURE_NAME) EQ 'WIDGET_KILL_REQUEST' THEN Widget_Control, self.wQCalibBase, MAP = 0
END
'CONFIG COMBO' :
'ENERGY' : BEGIN
Widget_Control, event.id, GET_VALUE = energy
wavelength = 12398.4172 / energy
Widget_Control, Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'WAVELENGTH'), SET_VALUE = String(wavelength)
self.calcLength
END
'WAVELENGTH' : BEGIN
Widget_Control, event.id, GET_VALUE = wavelength
energy = 12398.4172 / wavelength
Widget_Control, Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'ENERGY'), SET_VALUE = String(energy)
self.calcLength
END
'DETECTOR ANGLE': BEGIN
END
'STANDARD' : BEGIN
Widget_Control, event.id, GET_UVALUE = standards
Widget_Control, Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'STANDARD PEAKS'), $
SET_VALUE = (standards[event.index].peaks)[0] + String((standards[event.index].peaks)[1],FORMAT = '(F7.4)')
self.calcLength
END
'STANDARD PEAKS': BEGIN
self.calcLength
END
'APPLY' : BEGIN
wWavelength = Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'WAVELENGTH')
wDetectorAngle = Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'DETECTOR ANGLE')
wCameraLength = Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'CAMERA LENGTH')
wCurrentCameraLength = Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'CURRENT CAMERA LENGTH')
Widget_Control, wWaveLength, GET_VALUE = wavelength
self.currWavelength = wavelength
Widget_Control, wCameraLength, GET_VALUE = cameraLength
Widget_Control, wDetectorAngle, GET_VALUE = detectorAngle
IF cameraLength LT 1 THEN BEGIN
result = Dialog_Message('Error calculating camera length (zero). Not applying.', /ERROR)
BREAK
ENDIF
Widget_Control, wCurrentCameraLength, SET_VALUE = cameraLength
self.notify, {cameralength : cameraLength, wavelength : wavelength, detectorAngle : detectorAngle}
;Widget_Control, self.wQCalibBase, /DESTROY
;Obj_Destroy, self
Widget_Control, self.wQCalibBase, MAP = 0
END
ELSE : Print, 'Widget Name ' + widgetName + ' not handled by event case.'
ENDCASE
END
FUNCTION as_QCalibration::init, GROUPLEADER = groupLeader, NOTIFY_OBJ = notifyObj, SHOWGUI = showGUI
@as_scatterheader.macro
IF KeyWord_Set(notifyObj) THEN $
IF TypeName(notifyObj[0]) EQ 'NOTIFY' $
THEN self.notifyObj = List(notifyObj, /EXTRACT)
void = {standards, standardName : '', peaks : list()}
standards = Replicate({standards},4)
standards[0] = {standardName : 'Silver Behenate (AgBeh)', peaks : list(['001 : ','002 : ','003 : '],[0.1076,0.2153,0.3229])}
standards[1] = {standardName : 'Rat Tail Tendon', peaks : list(['1st : ','2nd : ','3rd : '],[0.0096,0.0192,0.0288,0.0384])}
standards[2] = {standardName : 'Lanthanum Hexaboride (LaB6)', peaks : list(['100 : ','110 : ','111 : ','200 : '],[1.5115, 2.1376, 2.6180, 3.0230])}
standards[3] = {standardName : 'Custom...', peaks : list([''],[''])}
IF KeyWord_Set(groupLeader) THEN BEGIN
IF Widget_Info(groupLeader,/VALID) THEN BEGIN
self.groupLeader = groupLeader
self.wQCalibBase = Widget_Base(GROUP_LEADER=groupLeader, TITLE = 'Q Calibration GUI', EVENT_PRO = 'as_QCalibration_event', /FLOATING, /COLUMN, /TLB_KILL_REQUEST_EVENTS, MAP = KeyWord_Set(showGUI), UNAME = 'QCALIB BASE')
ENDIF
ENDIF ELSE self.wQCalibBase = Widget_Base(TITLE = 'Q Calibration GUI',EVENT_PRO = 'as_QCalibration_event', /COLUMN, /TLB_KILL_REQUEST_EVENTS, MAP = KeyWord_Set(showGUI), UNAME = 'QCALIB BASE')
wFrameBase = Widget_Base(self.wQCalibBase, /COLUMN, /FRAME)
wWavelengthBase = Widget_Base(wFrameBase, /COLUMN, /FRAME)
wWavelengthLabel = Widget_Label(wWavelengthBase, VALUE = 'Enter Current Beam Energy or Wavelength:')
wWavelengthRow = Widget_Base(wWavelengthBase, /ROW)
wEnergyText = Widget_Text(wWavelengthRow, /EDITABLE, UNAME = 'ENERGY')
wEnergyLabel = Widget_Label(wWavelengthRow, VALUE = 'eV')
wWavelengthText = Widget_Text(wWavelengthRow, /EDITABLE, UNAME = 'WAVELENGTH')
wWavelengthLabel = Widget_Label(wWavelengthRow, VALUE = String([197b]))
wDetAngLabel = Widget_Label(wWavelengthBase, VALUE = 'Enter Current Detector Angle (WAXS):')
wDetAngRow = Widget_Base(wWavelengthBase, /ROW)
wDetAngText = Widget_Text(wDetAngRow, /EDITABLE, UNAME = 'DETECTOR ANGLE')
wDetAngLabel = Widget_Label(wDetAngRow, FONT = '18', VALUE = String([176b]))
wBuffer2 = Widget_Label(wFrameBase, VALUE = '')
wQCalibPeakBase = Widget_Base(wFrameBase, /COLUMN, /FRAME)
wPeakPosition = FSC_Field(wQCalibPeakBase, TITLE = 'Fitted Peak Position:', VALUE = Float(0.0), DECIMAL = 5, OBJECT = peakPosObj, UNAME = 'FITTED POS')
Widget_Control, wPeakPosition, SET_UVALUE = peakPosObj
wFittedPeakLabel = Widget_Label(wQCalibPeakBase, VALUE = 'Choose Fitted Peak:')
wStandardRow = Widget_Base(wQCalibPeakBase, /ROW)
wStandardCombo = Widget_Combobox(wStandardRow, VALUE = standards.standardName, UNAME = 'STANDARD', UVALUE = standards)
wStandardPeakCombo = Widget_Combobox(wStandardRow, /EDITABLE, /DYNAMIC_RESIZE, VALUE = (standards[0].peaks)[0] + String((standards[0].peaks)[1],FORMAT = '(F7.4)'), UNAME = 'STANDARD PEAKS')
wStandardPeakLabel = Widget_Label(wStandardRow, VALUE = '1/'+String([197b]))
wBuffer = Widget_Label(wFrameBase, VALUE = '')
wCameraLength = FSC_Field(wFrameBase, TITLE = 'Calibrated Camera Length:', UNAME = 'CAMERA LENGTH')
wCurrentCameraLength = FSC_Field(wFrameBase, TITLE = 'Current Camera Length:', UNAME = 'CURRENT CAMERA LENGTH')
wConfigBase = Widget_Base(self.wQCalibBase, /ROW)
wConfigLabel = Widget_Label(wConfigBase, VALUE = 'Choose Configuration to Edit:')
wConfigCombo = Widget_Combobox(wConfigBase, VALUE = 'All', UNAME = 'CONFIG COMBO')
wApplyCalibration = Widget_Button(self.wQCalibBase, VALUE = 'Apply Q Calibration', UNAME = 'APPLY')
Widget_Control, self.wQCalibBase, /REALIZE
Widget_Control, self.wQCalibBase, SET_UVALUE = self
RETURN, 1
END
PRO as_QCalibration::notify, event
@as_scatterheader.macro
FOREACH notify, self.notifyObj DO IF Obj_Valid(notify) THEN notify.notify, event
END
PRO as_QCalibration::SetProperty, PEAK = peak, GROUPLEADER = groupLeader, CAMERALENGTH = cameraLength, WAVELENGTH = waveLength, DETECTORANGLE = detectorAngle
@as_scatterheader.macro
IF KeyWord_Set(peak) THEN BEGIN
Widget_Control, Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'FITTED POS'), GET_UVALUE = peakPosObj
peakPosObj.object->Set_Value, peak
ENDIF
IF KeyWord_Set(cameraLength) THEN Widget_Control, Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'CURRENT CAMERA LENGTH'), SET_VALUE = String(cameraLength)
IF KeyWord_Set(waveLength) THEN BEGIN
self.currWavelength = wavelength
Widget_Control, Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'WAVELENGTH'), SET_VALUE = String(waveLength)
energy = 12398.4172 / wavelength
Widget_Control, Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'ENERGY'), SET_VALUE = String(energy)
ENDIF
IF KeyWord_Set(detectorAngle) THEN Widget_Control, Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'DETECTOR ANGLE'), SET_VALUE = String(detectorAngle)
IF KeyWord_Set(groupLeader) THEN BEGIN
self.groupLeader = groupLeader
Widget_Control, self.wQCalibBase, GROUP_LEADER = groupLeader
ENDIF
self.calcLength
END
PRO as_QCalibration::CalcLength
@as_scatterheader.macro
standardPeaksCombo = Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'STANDARD PEAKS')
chosenPeak = Widget_Info(standardPeaksCombo, /COMBOBOX_GETTEXT)
chosenPeak = Float((StrSplit(chosenPeak, ' ', /EXTRACT))[-1])
wPeakFit = Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'FITTED POS')
wWavelength = Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'WAVELENGTH')
wCurrentCameraLength = Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'CURRENT CAMERA LENGTH')
wCameraLength = Widget_Info(self.wQCalibBase, FIND_BY_UNAME = 'CAMERA LENGTH')
Widget_Control, wPeakFit, GET_VALUE = peak
Widget_Control, wWavelength, GET_VALUE = wavelength
Widget_Control, wCurrentCameraLength, GET_VALUE = currentCameraLength
peak = Float(peak)
wavelength = Float(wavelength)
currentCameraLength = Float(currentCameraLength)
cameraLength = currentCameraLength * Tan(2*Asin(peak*self.currWavelength/2/!dpi)) $
/Tan(2*Asin(chosenPeak*wavelength/2/!dpi))
Widget_Control, wCameraLength , SET_VALUE = String(cameraLength)
END
PRO as_QCalibration::ShowGUI
@as_scatterheader.macro
Widget_Control, self.wQCalibBase, /MAP
END
PRO as_QCalibration::EditConfig, RENAME=rename, DELETE=delete
@as_scatterheader.macro
END
PRO as_QCalibration__define
void = {QCALIBRETURN, qCalib : 0}
void = {as_QCalibration, $
groupLeader : 0L, $
notifyObj : List(), $
currWavelength : 0.0, $
qCalib : 0.0, $
wQCalibBase : 0L }
END