-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathas_profilecontainerobj__define.pro
1666 lines (1288 loc) · 69 KB
/
as_profilecontainerobj__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
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
PRO as_profilecontainerobj_baseevent, event
@as_scatterheader.macro
Widget_Control, event.top, GET_UVALUE=as_profilecontainerobj
as_profilecontainerobj->baseEvent, event
END
PRO as_profilecontainerobj_drawevent, event
@as_scatterheader.macro
Widget_Control, Widget_Info(event.id, /PARENT), GET_UVALUE=as_profilecontainerobj
as_profilecontainerobj->drawEvent, event
END
PRO AS_ProfileContainerObj::baseEvent, event
@as_scatterheader.macro
widgetName = Widget_Info(event.id, /UNAME)
CASE widgetName OF
'Base' : BEGIN
IF Tag_Names(event,/STRUCTURE_NAME) EQ 'WIDGET_KILL_REQUEST' THEN BREAK
children = Widget_Info(event.top, /ALL_CHILDREN)
whereNotMenu = Where(Widget_Info(children,/UNAME) NE 'menuBar')
children = children[whereNotMenu]
xAux = Total((Widget_Info(children,/GEOM)).xsize) - self.drawSize[0]
x = event.x - xAux
y = event.y
self->ReSize, x, y
self->NotifyObject, {type: 'Resize', x: x, y: y}
END
'SAVE SINGLE' : self.SaveProfiles
'SAVE MULTIPLE': self.SaveProfiles, /MULTIPLE
'SAVE PLOT IMAGE' : self.SavePlotImage
'Norm' : BEGIN
IF ~Obj_Valid(self.normGUI) THEN self.normGUI = as_normalisation(GROUPLEADER=self.wBase, NOTIFY_OBJ = [{OBJECT:self, METHOD:'SetNormParams'},{OBJECT:self, METHOD:'UpdatePlot'}])
self.normGUI->showGUI
self.normGUI.DetCounts, self.ionrm, self.ibsnrm, 1
END
'Abs Cal' : BEGIN
IF ~Obj_Valid(self.absGUI) THEN self.absGUI = as_abscal(GROUPLEADER=self.wBase, NOTIFY_OBJ = [notify('SetNormParams',self),notify('UpdatePlot',self)])
self.absGUI->showGUI
self.absGUI.DetCounts, self.ionrm, self.ibsnrm, 1, /APPLIED
self.absGUI.SetCurrentCalibration, self.cscalib, USE = self.useCalib
END
'Q Calibration': BEGIN
IF ~Obj_Valid(self.qCalibGUI) THEN BEGIN
Widget_Control, self.groupleader, GET_UVALUE = scatterBrain
self.qCalibGUI = scatterBrain.qCalibGUI(GROUPLEADER=self.wBase);, NOTIFY_OBJ = [{OBJECT:self, METHOD:'SetQCalibParams'},{OBJECT:self, METHOD:'UpdatePlot'}])
ENDIF
self.qCalibGUI->showGUI
;self.qCalibGUI.SetProperty, WAVELENGTH = ,CAMERALENGTH =
END
'Help' : BEGIN
Widget_Control, self.groupleader, GET_UVALUE = scatterBrain
scatterBrain.help, 'Plot_Control'
END
ENDCASE
END
PRO AS_ProfileContainerObj::drawEvent, event
@as_scatterheader.macro
IF event.type NE 4 THEN BEGIN
self.profileXAxis->GetProperty, LOCATION=location, CRANGE=crange, XCOORD_CONV=xcoord_conv
geom = Widget_Info(event.id, /GEOMETRY)
dataX = ((event.x/geom.xsize)-xcoord_conv[0])/xcoord_conv[1]
IF self.xLog THEN dataX = 10^dataX
x = event.x/geom.xsize
self.profileYAxis->GetProperty, LOCATION=location, CRANGE=crange, YCOORD_CONV=ycoord_conv
dataY = ((event.y/geom.ysize)-ycoord_conv[0])/ycoord_conv[1]
IF self.yLog THEN dataY = 10^dataY
y = event.y/geom.ysize
IF event.modifiers EQ 1 THEN BEGIN
IF event.type EQ 0 THEN BEGIN
Widget_Control, self.groupLeader, GET_UVALUE=info, /NO_COPY
expo = 10.0d^(3 -1 - floor(alog10(abs(dataX))))
q = long(dataX*expo)/expo
self->AddQMarker, q
info.frame_obj->Overlay_QCirc, q
Widget_Control, self.groupLeader, SET_UVALUE=info, /NO_COPY
ENDIF
ENDIF ELSE BEGIN
IF self.boxActive EQ 1 THEN BEGIN
self.boxObj->GetProperty, DATA = DATA
DATA[0,2:3] = x
DATA[1,0] = y
DATA[1,3:4] = y
self.boxObj->SetProperty, DATA = DATA
self.profileWindow->Draw, self.profileView
ENDIF
IF event.press EQ 1 THEN BEGIN
Widget_Control, event.id, /DRAW_MOTION_EVENTS
DATA = Transpose([[x,x,x,x,x],[y,y,y,y,y]])
self.boxObj->SetProperty, DATA = DATA
self.boxActive = 1
self.xRangeZoom = [dataX,dataX]
self.yRangeZoom = [dataY,dataY]
ENDIF
IF event.release EQ 1 THEN BEGIN
Widget_Control, event.id, DRAW_MOTION_EVENTS=0
DATA = Transpose([[0,0,0,0,0],[0,0,0,0,0]])
self.boxObj->SetProperty, DATA = DATA
self.boxActive = 0
self.xRangeZoom[1] = dataX
self.yRangeZoom[1] = dataY
self.xRangeZoom = [min(self.xRangeZoom),max(self.xRangeZoom)]
self.yRangeZoom = [min(self.yRangeZoom),max(self.yRangeZoom)]
IF self.xRangeZoom[0] EQ self.xRangeZoom[1] THEN RETURN
IF self.yRangeZoom[0] EQ self.yRangeZoom[1] THEN RETURN
self.xRange = self.xRangeZoom
self.yRange = self.yRangeZoom
self.profileXAxis->SetProperty, RANGE=self.xrangezoom
self.profileYAxis->SetProperty, RANGE=self.yrangezoom
self.profileXAxisGrid->SetProperty, RANGE=self.xrangezoom
self.profileYAxisGrid->SetProperty, RANGE=self.yrangezoom
self.profileXAxis->GetProperty, CRange=xrange
self.profileYAxis->GetProperty, CRange=yrange
; Set up the scaling so that the axes for the plot and the
; plot data extends from 0->1 in the X and Y directions.
xs = [((self.position[0]*xrange[1])-(self.position[2]*xrange[0])) / $
(xrange[1]-xrange[0]), (self.position[2]-self.position[0])/(xrange[1]-xrange[0])]
ys = [((self.position[1]*yrange[1])-(self.position[3]*yrange[0])) / $
(yrange[1]-yrange[0]), (self.position[3]-self.position[1])/(yrange[1]-yrange[0])]
; Scale the plot data and axes into 0->1.
IF Ptr_Valid(self.profileRefs) THEN IF N_Elements(*self.profileRefs) GT 0 THEN BEGIN
FOR i = 0, N_Elements(*self.profileRefs) - 1 DO BEGIN
IF Obj_Valid((*self.profileRefs)[i].profilePlot) THEN (*self.profileRefs)[i].profilePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys, XRANGE = xrange, YRANGE = yrange
ENDFOR
ENDIF
self.livePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys, XRANGE = xrange, YRANGE = yrange
self.peakFit->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys, XRANGE = xrange, YRANGE = yrange
self.profileXAxis->SetProperty, XCoord_Conv=xs, MAJOR = -1, MINOR = 4 + self.xlog*4
self.profileYAxis->SetProperty, YCoord_Conv=ys
self.profileXAxisGrid->SetProperty, XCoord_Conv=xs, MAJOR = -1
self.profileYAxisGrid->SetProperty, YCoord_Conv=ys
self->LinLogQMarkers
ENDIF
IF event.press EQ 4 THEN BEGIN
xranges = List()
yranges = List()
IF Ptr_Valid(self.profileRefs) THEN IF N_Elements(*self.profileRefs) GT 0 THEN BEGIN
FOR i = 0, N_Elements(*self.profileRefs) - 1 DO BEGIN
IF Obj_Valid((*self.profileRefs)[i].profilePlot) THEN BEGIN
(*self.profileRefs)[i].profilePlot->GetProperty, HIDE = hide, THICK = thick
data = (*self.profileRefs)[i].profiles->GetData(/BACK)
IF N_Elements(data) EQ 1 and data[0] EQ -1 THEN RETURN
xrange = [min(data[0,*]),max(data[0,*])]
yrange = [min(data[1,*]),max(data[1,*])]
IF self.xlog EQ 1 AND xrange[0] LE 0 THEN BEGIN
data[0,Where(data[0,*] LE 0)] = max(data[0,*])
xrange = [min(data[0,*]),max(data[0,*])]
ENDIF
IF self.ylog EQ 1 AND yrange[0] LE 0 THEN BEGIN
data[1,Where(data[1,*] LE 0)] = max(data[1,*])
yrange = [min(data[1,*]),max(data[1,*])]
ENDIF
xranges.add, xrange, /EXTRACT
yranges.add, yrange, /EXTRACT
Obj_Destroy, (*self.profileRefs)[i].profilePlot
self->PlotProfile, i, /REPLOT, XLOG = self.xLog, YLOG = self.yLog, _Extra=extra
(*self.profileRefs)[i].profilePlot->SetProperty, HIDE = hide, THICK = thick
ENDIF
ENDFOR
ENDIF
IF Obj_Valid(self.livePlot) THEN BEGIN
self.livePlot->GetProperty, HIDE = hide
IF HIDE EQ 0 THEN BEGIN
self.livePlot->GetProperty, DATA = data
IF N_Elements(data) GT 0 THEN BEGIN
xrange = [min(data[0,*]),max(data[0,*])]
yrange = [min(data[1,*]),max(data[1,*])]
ENDIF
IF self.xlog EQ 1 AND xrange[0] LE 0 THEN BEGIN
data[Where(data LE 0)] = max(data)
xrange = [min(data[0,*]),max(data[0,*])]
ENDIF
IF self.ylog EQ 1 AND yrange[0] LE 0 THEN BEGIN
data[Where(data LE 0)] = max(data)
yrange = [min(data[1,*]),max(data[1,*])]
ENDIF
xranges.add, xrange, /EXTRACT
yranges.add, yrange, /EXTRACT
ENDIF
self->PlotProfile, LIVE=1
self.livePlot->SetProperty, HIDE = hide
ENDIF
IF Obj_Valid(self.peakFit) THEN BEGIN
self.profileXAxis->GetProperty, CRange=xrange
self.profileYAxis->GetProperty, CRange=yrange
; Set up the scaling so that the axes for the plot and the
; plot data extends from 0->1 in the X and Y directions.
xs = [((self.position[0]*xrange[1])-(self.position[2]*xrange[0])) / $
(xrange[1]-xrange[0]), (self.position[2]-self.position[0])/(xrange[1]-xrange[0])]
ys = [((self.position[1]*yrange[1])-(self.position[3]*yrange[0])) / $
(yrange[1]-yrange[0]), (self.position[3]-self.position[1])/(yrange[1]-yrange[0])]
; Scale the plot data and axes into 0->1.
self.peakFit->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys, XRANGE = xrange, YRANGE = yrange
ENDIF
IF xranges.count() EQ 0 THEN xrange = [0.01, 1] ELSE xrange = [min(xranges.toarray(),/NAN),max(xranges.toarray(),/NAN)]
IF yranges.count() EQ 0 THEN yrange = [0.01, 1] ELSE yrange = [min(yranges.toarray(),/NAN),max(yranges.toarray(),/NAN)]
IF Finite(yrange[0]) EQ 0 THEN yrange[0] = 0
IF Finite(yrange[1]) EQ 0 THEN yrange[1] = yrange[0]
IF Finite(xrange[0]) EQ 0 THEN xrange[0] = 0
IF Finite(xrange[1]) EQ 0 THEN xrange[1] = xrange[0]
IF xrange[0] EQ xrange[1] THEN xrange[1] = xrange[0]+1
IF yrange[0] EQ yrange[1] THEN yrange[1] = yrange[0]+1
self.xRangeZoom = xRange
self.yRangeZoom = yRange
self.profileXAxis->SetProperty, RANGE=xrange
self.profileYAxis->SetProperty, RANGE=yrange
self.profileXAxisGrid->SetProperty, RANGE=xrange
self.profileYAxisGrid->SetProperty, RANGE=yrange
self.profileXAxis->GetProperty, CRange=xrange
self.profileYAxis->GetProperty, CRange=yrange
; Set up the scaling so that the axes for the plot and the
; plot data extends from 0->1 in the X and Y directions.
xs = [((self.position[0]*xrange[1])-(self.position[2]*xrange[0])) / $
(xrange[1]-xrange[0]), (self.position[2]-self.position[0])/(xrange[1]-xrange[0])]
ys = [((self.position[1]*yrange[1])-(self.position[3]*yrange[0])) / $
(yrange[1]-yrange[0]), (self.position[3]-self.position[1])/(yrange[1]-yrange[0])]
; Scale the plot data and axes into 0->1.
IF Ptr_Valid(self.profileRefs) THEN IF N_Elements(*self.profileRefs) GT 0 THEN BEGIN
IF N_Elements(*self.profileRefs) GT 0 THEN BEGIN
FOR i = 0, N_Elements(*self.profileRefs) - 1 DO BEGIN
IF Obj_Valid((*self.profileRefs)[i].profilePlot) THEN (*self.profileRefs)[i].profilePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys, XRANGE = xrange, YRANGE = yrange
ENDFOR
ENDIF
ENDIF
self.livePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys, XRANGE = xrange, YRANGE = yrange
self.profileXAxis->SetProperty, XCoord_Conv=xs, MAJOR = -1
self.profileYAxis->SetProperty, YCoord_Conv=ys
self.profileXAxisGrid->SetProperty, XCoord_Conv=xs, MAJOR = -1
self.profileYAxisGrid->SetProperty, YCoord_Conv=ys
self->LinLogQMarkers
ENDIF
ENDELSE
ENDIF
self.profileWindow->Draw, self.profileView
END
FUNCTION AS_ProfileContainerObj::Init, GROUPLEADER=groupLeader, PLOTPALETTE = plotPalette, NOTIFY_OBJ = notifyObj, _REF_Extra=extra
@as_scatterheader.macro
IF KeyWord_Set(plotPalette) THEN self.plotPalette = plotPalette ELSE BEGIN
profilePalette_obj = Obj_New('IDLgrPalette')
profilePalette_obj->LoadCT, 34
ENDELSE
IF Keyword_Set(notifyObj) THEN $
IF TypeName(notifyObj[0]) EQ 'NOTIFY' $
THEN self.notifyObj = List(notifyObj,/EXTRACT)
CD, CURRENT=current
self.profilePath = current
self.drawSize = [600,400]
self.position = [0.15, 0.15, 0.925, 0.925]
self.ionrm = 300000.0
self.ibsnrm = 300000.0
self.CSCalib = 1.0
self.xLog = 0
self.yLog = 0
self.nrmType = 0
self.useCalib = 0
self.profileRefs = Ptr_New()
self.blankColour = [0,0,0]
self.xRange = [0,0.001]
self.yRange = [0,0.001]
self.profileFont = Obj_New('IDLgrFont','Helvetica', SIZE = 10)
self.xAxisTitle_obj = OBJ_NEW('IDLgrText','q (' + String("305B) + '!U-1!N)', FONT = self.profileFont, /ENABLE_FORMATTING)
self.yAxisTitle_obj = OBJ_NEW('IDLgrText','Intensity Counts/s(Arb. Units)', FONT = self.profileFont, /ENABLE_FORMATTING)
self.profileXAxis = Obj_New('IDLgrAxis', 0, RANGE = self.xrange, TICKLEN=0.03, NAME = 'X_AXIS', LOCATION=[1000,self.position[1],0], TITLE=self.xAxisTitle_obj, COLOR = [0,0,0], /EXACT)
self.profileYAxis = Obj_New('IDLgrAxis', 1, RANGE = self.yrange, TICKLEN=0.03, NAME = 'Y_AXIS', LOCATION=[self.position[0],1000,0], TITLE=self.yAxisTitle_obj, COLOR = [0,0,0], /EXACT)
self.profileXAxisGrid = Obj_New('IDLgrAxis', 0, /NOTEXT, RANGE = self.xrange, TICKLEN=[self.position[2] - self.position[0]], SUBTICKLEN = 1, LOCATION=[1000,self.position[1],-1], COLOR = [200,200,200], /EXACT, GRIDSTYLE = 0)
self.profileYAxisGrid = Obj_New('IDLgrAxis', 1, /NOTEXT, RANGE = self.yrange, TICKLEN=[self.position[3] - self.position[1]], SUBTICKLEN = 1, LOCATION=[self.position[0],1000,-1], COLOR = [200,200,200], /EXACT, GRIDSTYLE = 0)
messageFont = Obj_New('IDLgrFont','Helvetica')
self.messageObj = IDLgrText('',FONT = messageFont, CHAR_DIMENSIONS = [0.01,0.01], COLOR = [0,0,0])
self.liveProfile = AS__saxsprofileaddons(I0Norm=1)
self.livePlot = IDLgrPlot()
self.peakFit = IDLgrPlot(LINESTYLE = 1)
self.peakFit.SetProperty, HIDE = 1
; Because we may not be using exact axis ranging, the axes
; may extend further than the xrange and yrange. Get the
; actual axis range so that the plot, etc. can be scaled
; appropriately.
self.profileXAxis->GetProperty, CRange=xrange
self.profileYAxis->GetProperty, CRange=yrange
self.xrange = xrange
self.yrange = yrange
; Set up the scaling so that the axes for the plot and the
; plot data extends from 0->1 in the X and Y directions.
xs = [((self.position[0]*self.xrange[1])-(self.position[2]*self.xrange[0])) / $
(self.xrange[1]-self.xrange[0]), (self.position[2]-self.position[0])/(self.xrange[1]-self.xrange[0])]
ys = [((self.position[1]*self.yrange[1])-(self.position[3]*self.yrange[0])) / $
(self.yrange[1]-self.yrange[0]), (self.position[3]-self.position[1])/(self.yrange[1]-self.yrange[0])]
; Scale the plot data and axes into 0->1.
self.profileXAxis->SetProperty, XCoord_Conv=xs
self.profileXAxisGrid->SetProperty, XCoord_Conv=xs
self.profileYAxis->SetProperty, YCoord_Conv=ys
self.profileYAxisGrid->SetProperty, YCoord_Conv=ys
self.profileXAxis->GetProperty, TICKTEXT = xAxisText_obj
self.profileYAxis->GetProperty, TICKTEXT = yAxisText_obj
self.xAxisText_obj = xAxisText_obj
self.yAxisText_obj = yAxisText_obj
self.xAxisText_obj->SetProperty, RECOMPUTE_DIMENSIONS=2
self.yAxisText_obj->SetProperty, RECOMPUTE_DIMENSIONS=2
self.xAxisTitle_obj->SetProperty, RECOMPUTE_DIMENSIONS=2
self.yAxisTitle_obj->SetProperty, RECOMPUTE_DIMENSIONS=2
self.legend = Obj_New('IDLgrLegend', FONT = self.profileFont, ITEM_COLOR = [0], COLUMNS = 3)
modelInit = self->IDLgrModel::Init(_EXTRA=extra)
self->Add, self.profileXAxis
self->Add, self.profileYAxis
self->Add, self.profileXAxisGrid
self->Add, self.profileYAxisGrid
self->Add, self.messageObj
self->Add, self.legend
self.legend->Translate, 0.5,0.8,0
self->Add, self.livePlot
self->Add, self.peakFit
IF KeyWord_Set(groupLeader) THEN BEGIN
self.groupLeader = groupLeader
geom = Widget_Info(groupLeader,/GEOMETRY)
self.wBase = Widget_Base(Group_Leader=groupLeader, TITLE = 'scatterBrain Plot', XOFFSET = geom.xoffset + geom.xsize + 2*geom.margin + 200, /ROW, /TLB_SIZE_EVENTS, /TLB_KILL_REQUEST_EVENTS, MBAR=wMenuBase, EVENT_PRO='as_profilecontainerobj_baseEvent', UNAME = 'Base')
ENDIF ELSE self.wBase = Widget_Base(TITLE = 'scatterBrain Plot', /ROW, /TLB_SIZE_EVENTS, MBAR=wMenuBase, UNAME = 'Base')
wDraw = Widget_Draw(self.wBase, XSIZE = self.drawSize[0], YSIZE = self.drawSize[1], GRAPHICS_LEVEL=2, /BUTTON_EVENTS, /EXPOSE_EVENTS, EVENT_PRO='as_profilecontainerobj_drawEvent')
Widget_Control, wMenuBase, SET_UNAME = 'menuBar'
wSaveMenu = Widget_Button(wMenuBase, /MENU, VALUE = 'Save Profiles')
wSaveSingleFile = Widget_Button(wSaveMenu, VALUE = 'Save ALL profiles to ONE large file', UNAME = 'SAVE SINGLE')
wSaveSingleFile = Widget_Button(wSaveMenu, VALUE = 'Save EACH profile to individual files', UNAME = 'SAVE MULTIPLE')
wSaveImage = Widget_Button(wSaveMenu, VALUE = 'Save current plot as image', UNAME = 'SAVE PLOT IMAGE')
;wNormMenu = Widget_Button(wMenuBase, /MENU, VALUE = 'Normalisation')
;wNormButton = Widget_Button(wNormMenu, VALUE = 'Normalisation', UNAME='Norm')
wAbsMenu = Widget_Button(wMenuBase, /MENU, VALUE = 'Intensity Normalisation and Calibration')
wAbsButton = Widget_Button(wAbsMenu, VALUE = 'Intensity Normalisation and Calibration', UNAME='Abs Cal')
wQCalibMenu = Widget_Button(wMenuBase, /MENU, VALUE = 'Q Calibration')
wQCalibButton = Widget_Button(wQCalibMenu, VALUE = 'Q Calibration', UNAME='Q Calibration')
wHelpButton = Widget_Button(wMenuBase, /MENU, VALUE = 'Help');, UNAME = 'Help', EVENT_PRO='as_profilecontainerobj_baseEvent')
wContextHelp= Widget_Button(wHelpButton, VALUE = 'Context Help', UNAME = 'Help')
Widget_Control, self.wBase, /REALIZE
Widget_Control, self.wBase, SET_UVALUE = self
Widget_Control, wDraw, GET_VALUE = temp
self.profileWindow = temp
self.profileWindow->SetProperty, PALETTE=self.plotPalette
self.profileView = Obj_New('IDLgrView', Viewplane_Rect=[0.0, 0.0, 1.0, 1.0], Location=[0,0], color = [255,255,255])
DATA = Transpose([[50,50,100,100,50],[100,200,200,100,100]])
self.boxObj = Obj_New('IDLgrPolyline',DATA)
self->Add, self.boxObj
self.profileView->Add, self
self.profileWindow->Draw, self.profileView
self.absGUI = as_abscal(GROUPLEADER=self.wBase, NOTIFY_OBJ = [notify('SetNormParams',self),notify('UpdatePlot',self)])
RETURN, modelInit
END
PRO AS_ProfileContainerObj::Cleanup
@as_scatterheader.macro
Obj_Destroy, self.profileWindow
Obj_Destroy, self.profileView
Obj_Destroy, self.profileXAxis
Obj_Destroy, self.profileYAxis
Obj_Destroy, self.profileXAxisGrid
Obj_Destroy, self.profileYAxisGrid
Obj_Destroy, self.xAxisText_obj
Obj_Destroy, self.yAxisText_obj
Obj_Destroy, self.xAxisTitle_obj
Obj_Destroy, self.yAxisTitle_obj
Obj_Destroy, self.profileFont
Obj_Destroy, self.legend
Obj_Destroy, self.plotPalette
Obj_Destroy, self.boxObj
Obj_Destroy, self.liveProfile
Obj_Destroy, self.livePlot
Obj_Destroy, self.normGui
Ptr_Free, self.profileRefs
Ptr_Free, self.qMarkersObj
Ptr_Free, self.qMarkersQ
END
PRO AS_ProfileContainerObj::NewParams, paramObj, configNo, ALL=all
@as_scatterheader.macro
IF N_Elements(configNo) GT 0 THEN normParams = configNo[0] ELSE normParams = 0
paramObj.GetParameters, NORMPARAMS = normParams
self.SetNormParams, normParams, NOUPDATEPLOTS=~KeyWord_Set(ALL)
IF normParams.useAbsCal EQ 0 THEN self.setNormParams, {NORMTYPE : normParams.normType}, NOUPDATEPLOTS=~KeyWord_Set(ALL)
END
PRO AS_ProfileContainerObj::StoreParams, paramObj, CONFIGNO = config
@as_scatterheader.macro
paramObj->SetParameters, ABSCAL=self.CSCalib, USEABSCAL=self.usecalib, NORMTYPE = self.nrmType, I0Norm = self.IoNrm, IBSNORM = self.ibsnrm, CONFIGNO = config
END
FUNCTION AS_ProfileContainerObj::GetProfiles, plotIndex
@as_scatterheader.macro
data = list()
FOREACH index, plotIndex DO BEGIN
plotRef = Where((*self.profileRefs).refNum EQ index)
data.add,(*self.profileRefs)[plotRef].profiles->GetData(/BACK, XLOG=0, YLOG=0)
ENDFOREACH
RETURN, data
END
PRO AS_ProfileContainerObj::SaveProfiles, fileName, MULTIPLE=multiple
@as_scatterheader.macro
IF N_Elements(fileName) EQ 0 THEN fileName = ''
IF ~File_Test(fileName) THEN BEGIN
IF KeyWord_Set(multiple) THEN fileName = Dialog_Pickfile(TITLE = 'Select directory to store profiles. Filenames will be built from image filenames.', /DIRECTORY, GET_PATH = tempPath, PATH = self.profilePath, /WRITE) $
ELSE fileName = Dialog_Pickfile(TITLE = 'Enter Filename...', /WRITE, /OVERWRITE_PROMPT, GET_PATH = tempPath, PATH = self.profilePath)
ENDIF
IF tempPath NE '' THEN self.profilePath = tempPath
IF fileName EQ '' THEN RETURN
profileList = list()
nameList = list()
maxElem = 0
FOR profileIndex = 0, N_Elements(*self.profileRefs) - 1 DO BEGIN
profileRef = (*self.profileRefs)[profileIndex]
profileList.add, profileRef.profiles.GetData(/BACK, XLOG=0, YLOG=0)
profileRef.profiles.GetProperty, fname=name
nameList.add, name
maxElem = maxElem > N_Elements(profileList[-1])/3
ENDFOR
numProfiles = N_Elements(profileList)
titleList = list('q ', 'I ', 'Err ')
i = 0
IF KeyWord_Set(multiple) THEN BEGIN
FOREACH name, nameList DO BEGIN
OpenW, profileFile, fileName + StrMid(name,0,(strsplit(name, '.'))[-1]-1) + '.dat', /GET_LUN
PrintF, profileFile, name
PrintF, profileFile, titleList.toarray(), FORMAT = '(' + StrCompress(3,/REMOVE) + 'A' + StrCompress(1+StrLen((profileList[i])[0]),/REMOVE) + ')'
PrintF, profileFile, profileList[i], FORMAT = '(' + StrCompress(3,/REMOVE) + 'A' + StrCompress(1+StrLen((profileList[i])[0]),/REMOVE) + ')'
Free_Lun, profileFile
i += 1
ENDFOREACH
ENDIF ELSE BEGIN
profileArr = FltArr(3,maxElem,numProfiles)
FOREACH item, profileList DO BEGIN
profileArr[*,0:N_Elements(item[0,*])-1,i] = item
i += 1
ENDFOREACH
IF numProfiles GT 1 THEN profileArr = Reform(Transpose(profileArr,[0,2,1]), 3*numProfiles, maxElem)
FOR i = 0, numProfiles-2 DO titleList +=titleList[0:2]
nameListArr = StrArr(3*numProfiles)
nameListArr[1:*:3] = nameList.toArray()
OpenW, profileFile, fileName, /GET_LUN
PrintF, profileFile, nameListArr, FORMAT = '(' + StrCompress(3*numProfiles,/REMOVE) + 'A' + StrCompress(1+StrLen(profileArr[0]),/REMOVE) + ')'
PrintF, profileFile, titleList.toArray(), FORMAT = '(' + StrCompress(3*numProfiles,/REMOVE) + 'A' + StrCompress(1+StrLen(profileArr[0]),/REMOVE) + ')'
PrintF, profileFile, profileArr, FORMAT = '(' + StrCompress(3*numProfiles,/REMOVE) + 'A' + StrCompress(1+StrLen(profileArr[0]),/REMOVE) + ')'
Free_Lun, profileFile
ENDELSE
END
FUNCTION AS_ProfileContainerObj::GetPlotImage
@as_scatterheader.macro
imageObj = self.profileWindow.read()
imageObj.GetProperty, DATA = image
RETURN, image
END
PRO AS_ProfileContainerObj::SavePlotImage, FILENAME = fileName
@as_scatterheader.macro
filters = [['*.bmp;*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff','*.bmp', '*.gif', '*.jpg;*.jpeg', '*.png', '*.tif;*.tiff','*.*'], $
['All Image Formats','Bitmap','GIF','JPEG','PNG','TIFF','All Files']]
IF ~KeyWord_Set(fileName) THEN fileName = Dialog_Pickfile(DEFAULT_EXTENSION = '*.jpg', FILTER = filters, /FIX_FILTER, /OVERWRITE_PROMPT,/WRITE)
IF fileName EQ '' THEN RETURN
image = self.GetPlotImage()
extension = StrUpCase((StrSplit(fileName, '.',/EXTRACT))[-1])
IF extension EQ 'TIF' THEN extension = 'TIFF'
IF extension EQ 'JPG' THEN extension = 'JPEG'
Write_Image, fileName, extension, image
END
FUNCTION AS_ProfileContainerObj::FitPeak, index, FULLRANGE = fullRange, PLOT = plot
@as_scatterheader.macro
temp = IntArr(N_Elements(index))
peak = Float(temp)
FOR i = 0, N_Elements(index) - 1 DO temp[i] = Where((*self.profileRefs).refNum EQ index[i])
index = temp
FOREACH j, index DO peak = ((*self.profileRefs)[j].profiles).FitPeak(self.xRangeZoom, PEAKSIGMA = peakSigma, CHI = fitChi, PLOT = fitPlot)
IF ~Obj_Valid(self.qCalibGUI) THEN BEGIN
Widget_Control, self.groupleader, GET_UVALUE = scatterBrain
self.qCalibGUI = scatterBrain.qCalibGUI(GROUPLEADER=self.wBase)
ENDIF
self.qCalibGUI.SetProperty, PEAK = peak[0]
IF self.xlog THEN fitPlot[0,*] = Alog10(fitPlot[0,*])
IF self.ylog THEN fitPlot[1,*] = Alog10(fitPlot[1,*])
self.peakFit.SetProperty, DATAX = fitPlot[0,*], DATAY = fitPlot[1,*], HIDE = 0
self.profileXAxis->GetProperty, CRange=xrange
self.profileYAxis->GetProperty, CRange=yrange
; Set up the scaling so that the axes for the plot and the
; plot data extends from 0->1 in the X and Y directions.
xs = [((self.position[0]*xrange[1])-(self.position[2]*xrange[0])) / $
(xrange[1]-xrange[0]), (self.position[2]-self.position[0])/(xrange[1]-xrange[0])]
ys = [((self.position[1]*yrange[1])-(self.position[3]*yrange[0])) / $
(yrange[1]-yrange[0]), (self.position[3]-self.position[1])/(yrange[1]-yrange[0])]
; Scale the plot data and axes into 0->1.
self.peakFit->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys
self.messageObj.SetProperty, CHAR_DIMENSIONS = [0.03,0.03], STRINGS = 'Fit: Peak = ' + StrCompress(String(peak, FORMAT = '(D6.4)'), /REMOVE_ALL) + ', Peak Sigma = ' + StrCompress(String(peakSigma, FORMAT = '(E10.2)'), /REMOVE_ALL) + ', Chi = ' + StrCompress(String(fitChi, FORMAT = '(D10.3)'), /REMOVE_ALL)
self.UpdatePlot, /KEEPFIT
RETURN, peak
END
PRO AS_ProfileContainerObj::LinLog, AXIS, _REF_Extra=extra
@as_scatterheader.macro
CASE AXIS OF
'X' : BEGIN
IF self.xLog EQ 0 THEN BEGIN
self.xLog = 1
self.profileXAxis->SetProperty, /LOG, EXACT=1, MAJOR=-1, MINOR = 8
self.profileXAxisGrid->SetProperty, /LOG, EXACT=1, MAJOR=-1, MINOR = 8
ENDIF ELSE BEGIN
self.xLog = 0
self.profileXAxis->SetProperty, LOG = 0, MAJOR = -1, MINOR = 4
self.profileXAxisGrid->SetProperty, LOG = 0, MAJOR = -1, MINOR = 4
ENDELSE
END
'Y' : BEGIN
IF self.yLog EQ 0 THEN BEGIN
self.yLog = 1
self.profileYAxis->SetProperty, /LOG, EXACT=1, MAJOR=-1, MINOR=8
self.profileYAxisGrid->SetProperty, /LOG, EXACT=1, MAJOR=-1, MINOR=8
ENDIF ELSE BEGIN
self.yLog = 0
self.profileYAxis->SetProperty, LOG = 0, MAJOR = -1, MINOR = 4
self.profileYAxisGrid->SetProperty, LOG = 0, MAJOR = -1, MINOR = 4
ENDELSE
END
ENDCASE
IF Ptr_Valid(self.profileRefs) THEN IF N_Elements(*self.profileRefs) GT 0 THEN BEGIN
FOR i = 0, N_Elements(*self.profileRefs) - 1 DO BEGIN
IF Obj_Valid((*self.profileRefs)[i].profilePlot) THEN BEGIN
(*self.profileRefs)[i].profilePlot->GetProperty, HIDE = hide
(*self.profileRefs)[i].profilePlot->GetProperty, THICK = thick
(*self.profileRefs)[i].profilePlot->GetProperty, NAME = name
Obj_Destroy, (*self.profileRefs)[i].profilePlot
self->PlotProfile, i, name, /REPLOT, XLOG = self.xLog, YLOG = self.yLog, /KEEPZOOM, _Extra=extra
(*self.profileRefs)[i].profilePlot->SetProperty, HIDE = hide
(*self.profileRefs)[i].profilePlot->SetProperty, THICK = thick
ENDIF
ENDFOR
ENDIF
IF Obj_Valid(self.livePlot) THEN BEGIN
self.livePlot->GetProperty, HIDE = hide
self->PlotProfile, LIVE=1, /KEEPZOOM
self.livePlot->SetProperty, HIDE = hide
ENDIF
IF Obj_Valid(self.peakFit) THEN BEGIN
self.peakFit.GetProperty, DATA = data
IF N_Elements(data) GT 0 THEN BEGIN
CASE Axis OF
'X' : IF self.xlog THEN data[0,*] = Alog10(data[0,*]) ELSE data[0,*] = 10^(data[0,*])
'Y' : IF self.ylog THEN data[1,*] = Alog10(data[1,*]) ELSE data[1,*] = 10^(data[1,*])
ENDCASE
self.peakFit.SetProperty, DATAX = data[0,*], DATAY = data[1,*]
ENDIF
ENDIF
self->LinLogQMarkers
END
PRO AS_ProfileContainerObj::SetNormParams, normStruct, NOUPDATEPLOTS=noUpdatePlots
@as_scatterheader.macro
IF Where(Tag_Names(normStruct) EQ 'NORMTYPE') GE 0 THEN BEGIN
IF normStruct.normType GE 0 THEN BEGIN
self.useCalib = 0
self.nrmType = normStruct.normType
IF Obj_Valid(self.absGUI) THEN self.absGUI.SetProperty, NORMTYPE = self.nrmType
IF Ptr_Valid(self.profileRefs) AND ~KeyWord_Set(noUpdatePlots) THEN FOREACH profile, ((*self.profileRefs).profiles) DO profile.SetNorm, normStruct.normType
CASE normStruct.normType OF
0: self.yAxisTitle_obj.SetProperty, STRINGS = 'Intensity Counts/s (No Norm.)'
1: self.yAxisTitle_obj.SetProperty, STRINGS = 'Intensity Counts/s (Norm. To I0)'
2: self.yAxisTitle_obj.SetProperty, STRINGS = 'Intensity Counts/s (Norm. To BeamStop)'
3: self.yAxisTitle_obj.SetProperty, STRINGS = 'Intensity Counts/s (Norm. To I0 & BeamStop)'
ELSE:
ENDCASE
ENDIF
ENDIF
IF Where(Tag_Names(normStruct) EQ 'COUNTERRATIO') GE 0 THEN BEGIN
IF normStruct.counterRatio GE 0 THEN BEGIN
IF Ptr_Valid(self.profileRefs) AND ~KeyWord_Set(noUpdatePlots) THEN FOREACH profile, ((*self.profileRefs).profiles) DO profile.SetProperty, COUNTERNORM = normStruct.counterRatio
ENDIF
ENDIF
IF Where(Tag_Names(normStruct) EQ 'I0NORM') GE 0 THEN BEGIN
IF normStruct.I0Norm GE 0 THEN self.ionrm = normStruct.I0Norm
IF Ptr_Valid(self.profileRefs) AND ~KeyWord_Set(noUpdatePlots) THEN FOREACH profile, ((*self.profileRefs).profiles) DO profile.SetProperty, I0Norm = self.ionrm
ENDIF
IF Where(Tag_Names(normStruct) EQ 'IBSNORM') GE 0 THEN BEGIN
IF normStruct.IBSNorm GE 0 THEN self.ibsnrm = normStruct.IBSNorm
IF Obj_Valid(self.normGUI) THEN self.normGUI.DetCounts, self.ionrm, self.ibsnrm, 1
IF Obj_Valid(self.absGUI) THEN self.absGUI.DetCounts, self.ionrm, self.ibsnrm, 1, /APPLIED
IF Ptr_Valid(self.profileRefs) AND ~KeyWord_Set(noUpdatePlots) THEN FOREACH profile, ((*self.profileRefs).profiles) DO profile.SetProperty, IBSNorm = self.ibsnrm
ENDIF
IF Where(Tag_Names(normStruct) EQ 'ABSCAL') GE 0 THEN BEGIN
IF normStruct.absCal GE 0 THEN BEGIN
self.usecalib = 1
self.yAxisTitle_obj.SetProperty, STRINGS = 'Absolute Intensity cm!U-1'
self.cscalib = normStruct.absCal
;IF Obj_Valid(self.absGUI) THEN self.absGUI.SetCurrentCalibration, self.cscalib, /USE
IF Ptr_Valid(self.profileRefs) AND ~KeyWord_Set(noUpdatePlots) THEN FOREACH profile, ((*self.profileRefs).profiles) DO profile.SetCalib, normStruct.absCal
ENDIF
ENDIF
IF Ptr_Valid(self.profileRefs) THEN BEGIN
FOREACH profile, ((*self.profileRefs).profiles),key DO BEGIN
data = profile.GetData(/BACK, XLOG=self.xlog, YLOG=self.ylog)
(((*self.profileRefs)[key]).profilePlot).SetProperty, DATAX = data[0,*], DATAY=data[1,*]
ENDFOREACH
ENDIF
END
PRO AS_ProfileContainerObj::ShowHidePlot, index
@as_scatterheader.macro
temp = (hidden = IntArr(N_Elements(index)))
FOR i = 0, N_Elements(index) - 1 DO temp[i] = Where((*self.profileRefs).refNum EQ index[i])
index = temp
FOR i =0, N_Elements(index) - 1 DO BEGIN
(*self.profileRefs)[index[i]].profilePlot->GetProperty, HIDE = temp
hidden[i] = temp
END
FOR i =0, N_Elements(index) - 1 DO (*self.profileRefs)[index[i]].profilePlot->SetProperty, HIDE = ~hidden[i]
END
PRO AS_ProfileContainerObj::HidePlot, index
@as_scatterheader.macro
temp = IntArr(N_Elements(index))
FOR i = 0, N_Elements(index) - 1 DO temp[i] = Where((*self.profileRefs).refNum EQ index[i])
index = temp
FOR i =0, N_Elements(index) - 1 DO (*self.profileRefs)[index[i]].profilePlot->SetProperty, /HIDE
END
PRO AS_ProfileContainerObj::ShowPlot, index
@as_scatterheader.macro
temp = IntArr(N_Elements(index))
FOR i = 0, N_Elements(index) - 1 DO temp[i] = Where((*self.profileRefs).refNum EQ index[i])
index = temp
FOR i =0, N_Elements(index) - 1 DO (*self.profileRefs)[index[i]].profilePlot->SetProperty, HIDE = 0
END
PRO AS_ProfileContainerObj::ShowErrorPlot, show
@as_scatterheader.macro
IF N_Elements(show) GT 0 THEN self.showErrorBars = show
IF ~Ptr_Valid(self.profileRefs) THEN RETURN
SWITCH self.showErrorBars OF
0:
2: BEGIN
FOREACH profile, ((*self.profileRefs).profilePlot) DO profile.showErrorPlot, self.showErrorBars
BREAK
END
1: BEGIN
FOREACH profile, ((*self.profileRefs).profilePlot) DO profile.showErrorPlot, 0
IF self.current EQ -1 THEN RETURN
((*self.profileRefs)[self.current].profilePlot).showErrorPlot, 1
END
ENDSWITCH
self.UpdatePlot
END
PRO AS_ProfileContainerObj::LineWidth, index, width, ADD = add
@as_scatterheader.macro
IF ~Ptr_Valid(self.profileRefs) THEN RETURN
temp = IntArr(N_Elements(index))
FOR i = 0, N_Elements(index) - 1 DO temp[i] = Where((*self.profileRefs).refNum EQ index[i])
index = temp
FOR i =0, N_Elements(index) - 1 DO BEGIN
currentWidth = 0
IF KeyWord_Set(Add) THEN BEGIN
(*self.profileRefs)[index[i]].profilePlot->GetProperty, THICK = currentWidth
ENDIF
(*self.profileRefs)[index[i]].profilePlot->SetProperty, THICK = width + currentWidth
ENDFOR
END
PRO AS_ProfileContainerObj::LineOpacity, index, opacity
@as_scatterheader.macro
temp = IntArr(N_Elements(index))
FOR i = 0, N_Elements(index) - 1 DO temp[i] = Where((*self.profileRefs).refNum EQ index[i])
index = temp
FOR i =0, N_Elements(index) - 1 DO (*self.profileRefs)[index[i]].profilePlot->SetProperty, ALPHA_CHANNEL = opacity
END
PRO AS_ProfileContainerObj::MultOffset, index, MULT=mult, OFFSET=offset
@as_scatterheader.macro
temp = IntArr(N_Elements(index))
FOR i = 0, N_Elements(index) - 1 DO temp[i] = Where((*self.profileRefs).refNum EQ index[i])
index = temp
FOR i =0, N_Elements(index) - 1 DO BEGIN
(*self.profileRefs)[index[i]].profiles->SetProperty, MULT = mult, OFFSET = offset
data = (*self.profileRefs)[index[i]].profiles->GetData(/BACK,XLOG=self.xlog, YLOG=self.ylog)
(*self.profileRefs)[index[i]].profilePlot->SetProperty, DATAX= data[0,*], DATAY=data[1,*]
(*self.profileRefs)[index[i]].profiles->GetProperty, NOTIFYPROFILE=notifyProfile
FOR j = 0, N_Elements(notifyProfile) - 1 DO BEGIN
data = notifyProfile[j]->GetData(/BACK,XLOG=self.xlog, YLOG=self.ylog)
(*self.profileRefs)[Where((*self.profileRefs).profiles EQ notifyProfile[j])].profilePlot->SetProperty, DATAX= data[0,*], DATAY=data[1,*]
ENDFOR
ENDFOR
self->UpdatePlot
END
PRO AS_ProfileContainerObj::PlotProfile, profile, fname, LIVE = live, REPLOT = Replot, XLOG = xLog, YLOG = yLog, KEEPZOOM = keepZoom, _Extra=extra
@as_scatterheader.macro
IF ~KeyWord_Set(xLog) THEN xLog = self.xLog
IF ~KeyWord_Set(yLog) THEN yLog = self.yLog
IF ~KeyWord_Set(keepZoom) THEN keepZoom = 0
IF KeyWord_Set(live) AND Obj_Valid(self.liveProfile) THEN BEGIN
data = self.liveProfile->GetData(/BACK,XLOG=xlog, YLOG=ylog,_Extra=extra)
IF N_Elements(data) GT 1 THEN self.livePlot->SetProperty, DATAX = data[0,*], DATAY = data[1,*], THICK = 2, COLOR = [0,0,0],_EXTRA=extra $
ELSE RETURN
ENDIF ELSE BEGIN
data = (*self.profileRefs)[profile].profiles->GetData(/BACK,XLOG=xlog, YLOG=ylog,_Extra=extra)
IF ~KeyWord_Set(replot) THEN BEGIN
IF KeyWord_Set(extra) THEN BEGIN
IF Where(Tag_Names(extra) EQ 'COLOR') GE 0 THEN plotColourTemp = extra.color ELSE plotColourTemp = profile
ENDIF ELSE plotColourTemp = profile
(*self.profileRefs)[profile].plotColour = Ptr_New(plotColourTemp)
ENDIF
(*self.profileRefs)[profile].profilePlot = Obj_New('as_plotobject', NAME= fname, COLOR = *(*self.profileRefs)[profile].plotColour)
self->Add, (*self.profileRefs)[profile].profilePlot
IF KeyWord_Set(ylog) AND N_Elements(DATA) GT 1 THEN errorBars = data[2:3, *] ELSE errorBars = Reform(data[2,*])
IF self.showErrorBars EQ 2 THEN showErrorBars = 1 ELSE showErrorBars = 0
(*self.profileRefs)[profile].profilePlot->SetProperty, DATAX = data[0,*], DATAY = data[1,*], ERRORBARS = errorBars, SHOWERRORBARS = showErrorBars, _EXTRA=extra
(*self.profileRefs)[profile].showPlot = 1
ENDELSE
;IF N_Elements((*self.profileRefs).profilePlot) EQ 1 THEN BEGIN
IF Ptr_Valid(self.profileRefs) THEN BEGIN
IF N_Elements(*self.profileRefs) EQ 1 THEN BEGIN
IF XLOG EQ 0 THEN self.xRange[0] = Max(data[0,Where(data[0,*] GT 0)]) ELSE self.xRange[0] = Max(10^data[0,Where(Finite(data[0,*]))])
IF YLOG EQ 0 THEN self.yRange[0] = Max(data[1,*]) ELSE self.yRange[0] = Max(10^data[1,Where(Finite(data[0,*]))])
ENDIF
ENDIF
IF KeyWord_Set(xLog) THEN BEGIN
IF self.xRange[0] LE 0 THEN self.xRange[0] = self.xRange[1]
self.xRange = [MIN(10^data[0,Where(Finite(data[0,*])AND data[1,*] GT 0)]) < self.xRange[0],MAX(10^data[0,Where(Finite(data[0,*]))]) > self.xRange[1]]
IF ~KeyWord_Set(live) THEN (*self.profileRefs)[profile].profilePlot->SetProperty, xrange = ALog10(self.xrange) $
ELSE self.livePlot.SetProperty, xrange = ALog10(self.xrange)
ENDIF ELSE self.xRange = [MIN(data[0,*]) < self.xRange[0],MAX(data[0,*]) > self.xRange[1]]
IF KeyWord_Set(yLog) THEN BEGIN
IF self.yRange[0] LE 0 THEN self.yRange[0] = self.yRange[1]
self.yRange = [MIN(10^data[1,Where(Finite(data[1,*]))]) < (self.yRange[0]),MAX(10^data[1,Where(Finite(data[1,*]))]) > self.yRange[1]]
ENDIF ELSE self.yRange = [MIN(data[1,*]) < self.yRange[0],MAX(data[1,*]) > self.yRange[1]]
IF self.yrange[0]-self.yrange[1] EQ 0 THEN self.yrange[1]=self.yrange[1]*10
IF self.xrange[0]-self.xrange[1] EQ 0 THEN self.xrange[1]=self.xrange[1]*10
IF Total(Finite(self.xRange)) NE 2 THEN self.xRange = [0,1]
IF Total(Finite(self.yRange)) NE 2 THEN self.yRange = [0,1]
IF ~keepZoom THEN BEGIN
IF self.xrange[0] - self.xrange[1] EQ 0 THEN self.xrange = [0,1]
IF self.yrange[0] - self.yrange[1] EQ 0 THEN self.yrange = [0,1]
self.profileXAxis->SetProperty, RANGE=self.xrange
self.profileYAxis->SetProperty, RANGE=self.yrange
self.profileXAxisGrid->SetProperty, RANGE=self.xrange
self.profileYAxisGrid->SetProperty, RANGE=self.yrange
ENDIF
;ENDIF
; Because we may not be using exact axis ranging, the axes
; may extend further than the xrange and yrange. Get the
; actual axis range so that the plot, etc. can be scaled
; appropriately.
self.profileXAxis->GetProperty, CRange=xrange
self.profileYAxis->GetProperty, CRange=yrange
; Set up the scaling so that the axes for the plot and the
; plot data extends from 0->1 in the X and Y directions.
xs = [((self.position[0]*xrange[1])-(self.position[2]*xrange[0])) / $
(xrange[1]-xrange[0]), (self.position[2]-self.position[0])/(xrange[1]-xrange[0])]
ys = [((self.position[1]*yrange[1])-(self.position[3]*yrange[0])) / $
(yrange[1]-yrange[0]), (self.position[3]-self.position[1])/(yrange[1]-yrange[0])]
; Scale the plot data and axes into 0->1.
IF ~KeyWord_Set(live) THEN (*self.profileRefs)[profile].profilePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys $
ELSE self.livePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys
self.profileXAxis->SetProperty, XCoord_Conv=xs
self.profileYAxis->SetProperty, YCoord_Conv=ys
self.profileXAxisGrid->SetProperty, XCoord_Conv=xs
self.profileYAxisGrid->SetProperty, YCoord_Conv=ys
;thickness = FltArr(N_Elements(*self.profiles))
;thickness[*] = 2
IF Ptr_Valid(self.profileRefs) THEN BEGIN
FOR i = 0, N_Elements(*self.profileRefs) - 1 DO BEGIN
IF Obj_Valid((*self.profileRefs)[i].profilePlot) THEN (*self.profileRefs)[i].profilePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys, XRANGE = xrange, YRANGE = yrange
ENDFOR
ENDIF
self.livePlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys, XRANGE = xrange, YRANGE = yrange
self.peakFit->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys, XRANGE = xrange, YRANGE = yrange
self.profileWindow->Draw, self.profileView
END
;PRO AS_ProfileContainerObj::SetBlank, profile, PLOT = plot
;
;IF KeyWord_Set(plot) THEN profile =
;
;IF ~Ptr_Valid(self.blanks) THEN BEGIN
; numBlank = 1
; self.blanks = Ptr_New(self.)
; self.dispBlank = Ptr_New(IntArr(1))
;
; ENDIF ELSE BEGIN
; numBlank = N_Elements(*self.blanks) + 1
; blanksTemp = ObjArr(numBlank)
; blanksTemp[0:numBlank-2] = *self.Blank
; dispBlankTemp = IntArr(numBlank)
; dispBlankTemp[0:numBlank-2] = *self.dispBlank
; ENDELSE
;
;END
PRO AS_ProfileContainerObj::UpdatePlot, void, KEEPFIT = keepFit
@as_scatterheader.macro
IF ~KeyWord_Set(keepFit) THEN BEGIN
self.messageObj.SetProperty, STRINGS = ''
self.peakFit.SetProperty, HIDE = 1
ENDIF
self.profileWindow->Draw, self.profileView
END
PRO AS_ProfileContainerObj::ReplaceWithLast, index
@as_scatterheader.macro