source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf @ 1249

Last change on this file since 1249 was 1249, checked in by srkline, 2 years ago

minor changes - can't find the diff command in TortoiseSVN...

File size: 55.0 KB
RevLine 
[954]1#pragma rtGlobals=1             // Use modern global access method.
[1242]2#pragma IgorVersion = 7.00
[954]3
4//
5//
6// mockup of the panel for VCALC
7//
8// -- all is housed in the folder:
9//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC
10//
11// -- Put all of the constants to define the instrument plus all of the VCALC stuff
12//
13// anticipating that at the same level as VCALC will be all of the reduction folders
14// in a similar way as for SANS reduction
15//
16//
[1245]17// TODO:
18// -- adjust the size of the panel to better fit a laptop (for my telework)
19//
[954]20
21
[1051]22Proc VCALC_Panel()
[954]23        DoWindow/F VCALC
24        if(V_flag==0)
25       
26                //initialize space = folders, parameters, instrument constants, etc.
[982]27                VC_Initialize_Space()
[954]28               
29                //open the panel
30                DrawVCALC_Panel()
[1133]31
32                // check for a mask, if not present, generate a default mask (this will be updated later)
33                if(!Exists("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_FT:data"))
34                        V_GenerateDefaultMask()
35                endif
[954]36               
37                // two graphs with the ray-tracing side/top views
38                SetupSideView()
39                SetupTopView()
40               
41                // a front view of the panels
[1134]42//              FrontView_1x()
[954]43               
[1133]44                // pop one of the presets to get everything to update
45                VC_Preset_WhiteBeam()
46               
47                // a recalculation is needed after the change
48                // this re-bins the I(q) data too
49                Recalculate_AllDetectors()
[1134]50
51                // update the views
52                VC_UpdateViews()
53                               
[954]54        endif
55End
56
57Function FakeFrontMiddleSDDClick()
58       
59        STRUCT WMSetVariableAction sva
60        sva.eventCode = 3
61//      sva.dval = 0.3
62
[982]63        VC_BDet_SDD_SetVarProc(sva)             
64        VC_MDet_SDD_SetVarProc(sva)
65        VC_FDet_SDD_SetVarProc(sva)
[954]66
67        return(0)
68end
69
70
71Proc DrawVCALC_Panel()
[1247]72        Variable sc = 1
73                       
74        if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)
75                sc = 0.7
76        endif
77       
[954]78        PauseUpdate; Silent 1           // building window...
[1247]79               
80        if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)   
[1248]81                NewPanel /W=(34*sc,44*sc,1274*sc,660*sc)/N=VCALC/K=1
[1247]82        else
83                NewPanel /W=(34,44,1274,699)/N=VCALC/K=1
84        endif
85       
[954]86        ModifyPanel cbRGB=(49151,60031,65535)
87//      ShowTools/A
88        SetDrawLayer UserBack
89       
90// always visible stuff, not on any tab
91       
[1247]92        GroupBox group0,pos={sc*10,10*sc},size={sc*440,125*sc},title="Setup"
93        TabControl Vtab,labelBack=(45000,61000,58000),pos={sc*14,150*sc},size={sc*430,200*sc},tabLabel(0)="Collim"
[954]94        TabControl Vtab,tabLabel(1)="Sample",tabLabel(2)="Front Det",tabLabel(3)="Mid Det"
95        TabControl Vtab,tabLabel(4)="Back Det",tabLabel(5)="Simul",value= 0,proc=VCALCTabProc
96
[1247]97        if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)   
[1248]98                GroupBox group1,pos={sc*460,10*sc},size={sc*762,595*sc},title="Detector Panel Positions + Data"
[1247]99        else   
100                GroupBox group1,pos={460,10},size={762,635},title="Detector Panel Positions + Data"
101        endif
102        Button button_a,pos={sc*210,70*sc},size={sc*100,20*sc},title="Show Mask",proc=V_VCALCShowMaskButtonProc
103        Button button_b,pos={sc*210,100*sc},size={sc*100,20*sc},title="Recalculate",proc=V_VCALCRecalcButtonProc
104        Button button_c,pos={sc*330,70*sc},size={sc*100,20*sc},title="Save Config",proc=V_VCALCSaveConfiguration
105        Button button_d,pos={sc*330,100*sc},size={sc*100,20*sc},title="Save NICE",proc=V_VCALCSaveNICEConfiguration
[1133]106
[1247]107
108        PopupMenu popup_a,pos={sc*50,40*sc},size={sc*142,20*sc},title="Presets"
[1133]109        PopupMenu popup_a,mode=1,popvalue="White Beam",value= root:Packages:NIST:VSANS:VCALC:gPresetPopStr
[1108]110        PopupMenu popup_a,proc=VC_PresetConfigPopup
[954]111
[1247]112        if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)   
113                PopupMenu popup_b,pos={sc*670,280*sc},size={sc*142,20*sc},title="Binning type",proc=VC_RebinIQ_PopProc
114                PopupMenu popup_b,mode=1,value= root:Packages:NIST:VSANS:VCALC:gBinTypeStr
115                SetVariable setVar_b,pos={sc*476,280*sc},size={sc*120,15*sc},title="axis Q",proc=Front2DQ_Range_SetVarProc
116                SetVariable setVar_b,limits={0.02,1,0.02},value=_NUM:0.52
117                CheckBox check_0a title="Log?",size={sc*60,20*sc},pos={sc*619,280*sc},proc=Front2DQ_Log_CheckProc
118        else   
119                PopupMenu popup_b,pos={670,311},size={142,20},title="Binning type",proc=VC_RebinIQ_PopProc
120                PopupMenu popup_b,mode=1,value= root:Packages:NIST:VSANS:VCALC:gBinTypeStr
121                SetVariable setVar_b,pos={476,313},size={120,15},title="axis Q",proc=Front2DQ_Range_SetVarProc
122                SetVariable setVar_b,limits={0.02,1,0.02},value=_NUM:0.52
123                CheckBox check_0a title="Log?",size={60,20},pos={619,313},proc=Front2DQ_Log_CheckProc
124        endif
125
126
[1108]127               
[1247]128        SetVariable setVar_a,pos={sc*476,26*sc},size={sc*120,15*sc},title="axis degrees",proc=FrontView_Range_SetVarProc
[1133]129        SetVariable setVar_a,limits={0.3,30,0.2},value=_NUM:28
[954]130
[1247]131        ValDisplay valDisp_a,pos={sc*30,380*sc},size={sc*200,15*sc},fstyle=1,title="Beam Intensity",value=root:Packages:NIST:VSANS:VCALC:gBeamIntensity
[1108]132
[1133]133        SetDrawEnv fstyle= 1
[1247]134        DrawText 20*sc,420*sc,"Back"
135        DrawText 80*sc,420*sc,"Q min"
136        DrawText 150*sc,420*sc,"Q max"
137        ValDisplay valDisp_b,pos={sc*30,420*sc},size={sc*100,15*sc},title="",value=root:Packages:NIST:VSANS:VCALC:gQmin_B
138        ValDisplay valDisp_c,pos={sc*130,420*sc},size={sc*100,15*sc},title="",value=root:Packages:NIST:VSANS:VCALC:gQmax_B
[1108]139
[1133]140        SetDrawEnv fstyle= 1
[1247]141        DrawText 120*sc,460*sc,"Middle"
142        DrawText 180*sc,460*sc,"Q min"
143        DrawText 250*sc,460*sc,"Q max" 
144        ValDisplay valDisp_d,pos={sc*130,460*sc},size={sc*100,15*sc},title="",value=root:Packages:NIST:VSANS:VCALC:gQmin_M
145        ValDisplay valDisp_e,pos={sc*230,460*sc},size={sc*100,15*sc},title="",value=root:Packages:NIST:VSANS:VCALC:gQmax_M
[1108]146
[1133]147        SetDrawEnv fstyle= 1
[1247]148        DrawText 220*sc,500*sc,"Front" 
149        DrawText 280*sc,500*sc,"Q min"
150        DrawText 350*sc,500*sc,"Q max" 
151        ValDisplay valDisp_f,pos={sc*230,500*sc},size={sc*100,15*sc},title="",value=root:Packages:NIST:VSANS:VCALC:gQmin_F
152        ValDisplay valDisp_g,pos={sc*330,500*sc},size={sc*100,15*sc},title="",value=root:Packages:NIST:VSANS:VCALC:gQmax_F
[1128]153
[1133]154
[1247]155        ValDisplay valDisp_h,pos={sc*50,530*sc},size={sc*200,15*sc},title="Beam Diam (middle) (cm)",value=root:Packages:NIST:VSANS:VCALC:gBeamDiam
156        ValDisplay valDisp_i,pos={sc*50,560*sc},size={sc*200,15*sc},title="Beam Stop Diam (middle) (in)",value=root:Packages:NIST:VSANS:VCALC:gBeamStopDiam
157        ValDisplay valDisp_j,pos={sc*50,590*sc},size={sc*200,15*sc},title="Beam Stop Q min (1/A)",value=root:Packages:NIST:VSANS:VCALC:gRealQMin
[1133]158
159
160
[954]161        // for panels (in degrees)     
[1247]162        if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)
163                Display/W=(476*sc,45*sc,757*sc,270*sc)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
164        else
165                Display/W=(476,45,757,303)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
166        endif
[954]167        RenameWindow #,FrontView
168        ModifyGraph mode=2              // mode = 2 = dots
169        ModifyGraph marker=19
170        ModifyGraph rgb=(0,0,0)
171        ModifyGraph tick=2,mirror=1
172        Label left "degrees"
173        Label bottom "degrees" 
174        SetActiveSubwindow ##
175
176
177        // for side view
[1247]178        Display/W=(842*sc,25*sc,1200*sc,170*sc)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
[954]179        RenameWindow #,SideView
180        ModifyGraph mode=2              // mode = 2 = dots
181        ModifyGraph marker=19
182        ModifyGraph rgb=(0,0,0)
183        ModifyGraph tick=2,mirror=1
[1108]184        Label left "Vertical position (cm)"
[1133]185        Label bottom "SDD (cm)"
186        SetAxis/A/R left       
[954]187        SetActiveSubwindow ##   
188       
189        // for top view
[1247]190        Display/W=(842*sc,180*sc,1200*sc,325*sc)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
[954]191        RenameWindow #,TopView
192        ModifyGraph mode=2              // mode = 2 = dots
193        ModifyGraph marker=19
194        ModifyGraph rgb=(0,0,0)
195        ModifyGraph tick=2,mirror=1
[1108]196        Label left "Horizontal position (cm)"
197        Label bottom "SDD (cm)"
[954]198        SetActiveSubwindow ##   
199
[1247]200
[954]201        // for panels (as 2D Q)
[1247]202        if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)
203        // note that the dimensions here are not strictly followed since the aspect ratio is set below
[1248]204                Display/W=(475*sc,310*sc,790*sc,590*sc)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
[1247]205        else
206                Display/W=(475,332,814,631)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
207        endif   
[954]208        RenameWindow #,Panels_Q
209        ModifyGraph mode=2              // mode = 2 = dots
210        ModifyGraph tick=2,mirror=1,grid=2,standoff=0
211        ModifyGraph width={Aspect,1},height={Aspect,1},gbRGB=(56797,56797,56797)
212        SetAxis left -0.2,0.2
213        SetAxis bottom -0.2,0.2
214        Label left "Qy"
215        Label bottom "Qx"       
216        SetActiveSubwindow ##
217
218
[1108]219
[954]220        // for averaged I(Q)
[1247]221        if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)
[1248]222                Display/W=(842*sc,330*sc,1204*sc,590*sc)/HOST=# //root:Packages:NIST:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
[1247]223        else
224                Display/W=(842,334,1204,629)/HOST=# //root:Packages:NIST:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
225        endif   
[954]226        RenameWindow #,Panels_IQ
227//      ModifyGraph mode=2              // mode = 2 = dots
228        ModifyGraph tick=2,mirror=1,grid=2
229//      Label left "Intensity"
230//      Label bottom "Q"       
231        SetActiveSubwindow ##
232
233
234       
[1081]235// all controls are named VCALCCtrl_NA where N is the tab number and A is the letter indexing items on tab
[954]236
237       
238// tab(0), collimation - initially visible
[1247]239        Slider VCALCCtrl_0a,pos={sc*223,(324-50)*sc},size={sc*200,45*sc},limits={0,9,1},value= 1,vert= 0,proc=V_GuideSliderProc
240        SetVariable VCALCCtrl_0b,pos={sc*25,(294-50)*sc},size={sc*120,15*sc},title="wavelength"
[982]241        SetVariable VCALCCtrl_0b,limits={4,20,1},value=_NUM:8,proc=VC_Lambda_SetVarProc
[1247]242        PopupMenu VCALCCtrl_0c,pos={sc*26,(257-50)*sc},size={sc*150,20*sc},title="monochromator"
[954]243        PopupMenu VCALCCtrl_0c,mode=1,popvalue="Velocity Selector",value= root:Packages:NIST:VSANS:VCALC:gMonochromatorType
[1108]244        PopupMenu VCALCCtrl_0c,proc=VC_MonochromSelectPopup
[1247]245        PopupMenu VCALCCtrl_0d,pos={sc*26,(321-50)*sc},size={sc*115,20*sc},title="delta lambda"
[1128]246        PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda
[1108]247        PopupMenu VCALCCtrl_0d,proc=VC_DeltaLamSelectPopup
[1247]248        PopupMenu VCALCCtrl_0e,pos={sc*291,(262-50)*sc},size={sc*132,20*sc},title="source shape"
[954]249        PopupMenu VCALCCtrl_0e,mode=1,popvalue="circular",value= root:Packages:NIST:VSANS:VCALC:gSourceShape
[1108]250        PopupMenu VCALCCtrl_0e,proc=VC_SourceApShapeSelectPopup
[1247]251        PopupMenu VCALCCtrl_0f,pos={sc*283,(293-50)*sc},size={sc*141,20*sc},title="source aperture"
[1128]252        PopupMenu VCALCCtrl_0f,mode=1,popvalue="6.0 cm",value= root:Packages:NIST:VSANS:VCALC:gSourceDiam
[1108]253        PopupMenu VCALCCtrl_0f,proc=VC_SourceAperDiamSelectPopup
[954]254
[1108]255
[954]256// tab(1) - Sample conditions, initially not visible
[1247]257        PopupMenu VCALCCtrl_1a,pos={sc*38,(250-50)*sc},size={sc*142,20*sc},title="table location",disable=1
[954]258        PopupMenu VCALCCtrl_1a,mode=1,popvalue="Changer",value= root:Packages:NIST:VSANS:VCALC:gTableLocation
[1247]259        PopupMenu VCALCCtrl_1b,pos={sc*270,(250-50)*sc},size={sc*115,20*sc},title="Aperture Shape",disable=1
[954]260        PopupMenu VCALCCtrl_1b,mode=1,popvalue="circular",value= root:Packages:NIST:VSANS:VCALC:gSampleApertureShape
[1247]261        PopupMenu VCALCCtrl_1c,pos={sc*270,(310-50)*sc},size={sc*132,20*sc},title="Aperture Diam (cm)",disable=1
[1128]262        PopupMenu VCALCCtrl_1c,mode=1,popvalue="1.27",value= root:Packages:NIST:VSANS:VCALC:gSampleApertureDiam
[1247]263        SetVariable VCALCCtrl_1d,pos={sc*25,(280-50)*sc},size={sc*210,15*sc},title="Sample Aper. to Gate Valve (cm)"//,bodywidth=50
[1128]264        SetVariable VCALCCtrl_1d,limits={4,40,0.1},value=_NUM:22,proc=VC_A2_to_GV_SetVarProc,disable=1
[1247]265        SetVariable VCALCCtrl_1e,pos={sc*25,(310-50)*sc},size={sc*210,15*sc},title="Sample Pos to Gate Valve (cm)"
[1128]266        SetVariable VCALCCtrl_1e,limits={4,40,0.1},value=_NUM:11,proc=VC_Sam_to_GV_SetVarProc,disable=1
[954]267
268// tab(2) - Front detector panels, initially not visible
[1247]269        SetVariable VCALCCtrl_2a,pos={sc*30,(260-50)*sc},size={sc*160,15*sc},title="LEFT Offset (cm)",proc=VC_FDet_LR_SetVarProc
[1081]270        SetVariable VCALCCtrl_2a,limits={-20,19,0.1},disable=1,value=_NUM:-10
[1247]271        SetVariable VCALCCtrl_2aa,pos={sc*30,(290-50)*sc},size={sc*160,15*sc},title="RIGHT Offset (cm)",proc=VC_FDet_LR_SetVarProc
[1081]272        SetVariable VCALCCtrl_2aa,limits={-19,20,0.1},disable=1,value=_NUM:10
273       
[1247]274        SetVariable VCALCCtrl_2b,pos={sc*30,(330-50)*sc},size={sc*160,15*sc},title="TOP Offset (cm)",proc=VC_FDet_LR_SetVarProc
[1081]275        SetVariable VCALCCtrl_2b,limits={0,18,0.1},disable=1,value=_NUM:10
[1247]276        SetVariable VCALCCtrl_2bb,pos={sc*30,(360-50)*sc},size={sc*160,15*sc},title="BOTTOM Offset (cm)",proc=VC_FDet_LR_SetVarProc
[1081]277        SetVariable VCALCCtrl_2bb,limits={-18,0,0.1},disable=1,value=_NUM:-10
278       
[1247]279        SetVariable VCALCCtrl_2d,pos={sc*205,(260-50)*sc},size={sc*235,15*sc},title="Gate Valve to Detector Dist (cm)",proc=VC_FDet_SDD_SetVarProc
[1130]280        SetVariable VCALCCtrl_2d,limits={70,800,1},disable=1    ,value=_NUM:150
[954]281       
282
283// tab(3) - Middle detector panels, initially not visible
[1247]284        SetVariable VCALCCtrl_3a,pos={sc*30,(260-50)*sc},size={sc*160,15*sc},title="LEFT Offset (cm)",proc=VC_MDet_LR_SetVarProc
[1093]285        SetVariable VCALCCtrl_3a,limits={-20,19,0.1},disable=1,value=_NUM:-7
[1247]286        SetVariable VCALCCtrl_3aa,pos={sc*30,(290-50)*sc},size={sc*160,15*sc},title="RIGHT Offset (cm)",proc=VC_MDet_LR_SetVarProc
[1093]287        SetVariable VCALCCtrl_3aa,limits={-19,20,0.1},disable=1,value=_NUM:7
[1081]288               
[1247]289        SetVariable VCALCCtrl_3b,pos={sc*30,(330-50)*sc},size={sc*160,15*sc},title="TOP Offset (cm)",proc=VC_MDet_LR_SetVarProc
[1093]290        SetVariable VCALCCtrl_3b,limits={0,18,0.1},disable=1,value=_NUM:14
[1247]291        SetVariable VCALCCtrl_3bb,pos={sc*30,(360-50)*sc},size={sc*160,15*sc},title="BOTTOM Offset (cm)",proc=VC_MDet_LR_SetVarProc
[1093]292        SetVariable VCALCCtrl_3bb,limits={-18,0,0.1},disable=1,value=_NUM:-14
[1081]293
[1247]294        SetVariable VCALCCtrl_3d,pos={sc*205,(260-50)*sc},size={sc*235,15*sc},title="Gate Valve to Detector Dist (cm)",proc=VC_MDet_SDD_SetVarProc
[1130]295        SetVariable VCALCCtrl_3d,limits={250,2000,1},disable=1,value=_NUM:1000
[1081]296
[954]297       
298// tab(4) - Back detector panel
[1247]299        SetVariable VCALCCtrl_4a,pos={sc*168,(290-50)*sc},size={sc*160,15*sc},title="Lateral Offset (cm)"
[1062]300        SetVariable VCALCCtrl_4a,limits={0,20,0.1},disable=1,value=_NUM:0
[1247]301        SetVariable VCALCCtrl_4b,pos={sc*168,(260-50)*sc},size={sc*250,15*sc},title="Gate Valve to Detector Dist (cm)",proc=VC_BDet_SDD_SetVarProc
[1093]302        SetVariable VCALCCtrl_4b,limits={2000,2500,1},disable=1,value=_NUM:2200
[1247]303//      PopupMenu VCALCCtrl_4c,pos={sc*40,260*sc},size={sc*180,20*sc},title="Detector type",disable=1
[1062]304//      PopupMenu VCALCCtrl_4c,mode=1,popvalue="2D",value= root:Packages:NIST:VSANS:VCALC:gBackDetType
[954]305
306// tab(5) - Simulation setup
[1247]307        SetVariable VCALCCtrl_5a,pos={sc*40,(290-50)*sc},size={sc*220,15*sc},title="Neutrons on Sample (imon)"
[1093]308        SetVariable VCALCCtrl_5a,limits={1e7,1e15,1e7},disable=1,value=_NUM:1e11,proc=VC_SimImon_SetVarProc
[1247]309        PopupMenu VCALCCtrl_5b,pos={sc*40,(260-50)*sc},size={sc*200,20*sc},title="Model Function",disable=1
[982]310        PopupMenu VCALCCtrl_5b,mode=1,popvalue="Debye",value= root:Packages:NIST:VSANS:VCALC:gModelFunctionType,proc=VC_SimModelFunc_PopProc
[954]311       
312End
313
[1133]314Function V_VCALCShowMaskButtonProc(ba) : ButtonControl
315        STRUCT WMButtonAction &ba
316
317        switch( ba.eventCode )
318                case 2: // mouse up
319                        // click code here
320                       
321                        V_SetupPanelDisplay()
322                       
323                        PopupMenu popup1 win=VSANS_Det_Panels,mode=14,popvalue="VCALC"
324                        PopupMenu popup0 win=VSANS_Det_Panels,popvalue="F"
325                        ControlUpdate/A/W=VSANS_Det_Panels
326
327                //pop the carriage menu to refresh the VCALC data
328                        STRUCT WMPopupAction pa
329                        pa.eventCode = 2                //fake click
330                        V_PickCarriagePopMenuProc(pa)
331                       
332// risky, but I can pass the button "click" to the next button to toggle the mask "On"                 
333                        V_ToggleFourMaskButtonProc(ba)
334                       
335                        break
336                case -1: // control being killed
337                        break
338        endswitch
339
340        return 0
341End
342
343
[1134]344Function V_VCALCSaveConfiguration(ba) : ButtonControl
345        STRUCT WMButtonAction &ba
[1133]346
[1134]347        switch( ba.eventCode )
348                case 2: // mouse up
349                        // click code here
350                       
351                        V_DisplayConfigurationText()
352                       
353                        break
354                case -1: // control being killed
355                        break
356        endswitch
357
358        return 0
359End
360
361
362Function V_DisplayConfigurationText()
363
364        if(WinType("Trial_Configuration")==0)
365                NewNotebook/F=0/K=1/N=Trial_Configuration /W=(480,44,880,369)
366        endif
367        //replace the text
368        Notebook Trial_Configuration selection={startOfFile, endOfFile}
369        Notebook Trial_Configuration font="Monaco",fSize=10,text=V_SetConfigurationText()
370        return(0)
371end
372
373
374//Export NICE VSANS configurations to a plain text noteboox that can be saved as a text file.
375Function V_SaveNICEConfigs()
376
377        String str=""
378
379        if(WinType("NICE_Configuration")==0)
380                NewNotebook/F=0/K=1/N=NICE_Configuration /W=(480,44,880,369)
381        endif
382        //replace the text
383        Notebook NICE_Configuration selection={startOfFile, endOfFile}
384        Notebook NICE_Configuration font="Monaco",fSize=10,text=V_SetNICEConfigText()
385       
386//      SaveNotebook/S=6/I NICE_Configuration as "NICE_Configs.txt"
387//      KillWindow NICE_Configuration   
388                       
389        return (0)
390
391end
392
393Function V_VCALCSaveNICEConfiguration(ba) : ButtonControl
394        STRUCT WMButtonAction &ba
395
396        switch( ba.eventCode )
397                case 2: // mouse up
398                        // click code here
399                       
400//                      Recalculate_AllDetectors()
401                        V_SaveNICEConfigs()
402                       
403                        break
404                case -1: // control being killed
405                        break
406        endswitch
407
408        return 0
409End
410
[1133]411Function V_VCALCRecalcButtonProc(ba) : ButtonControl
412        STRUCT WMButtonAction &ba
413
414        switch( ba.eventCode )
415                case 2: // mouse up
416                        // click code here
417                       
418                        Recalculate_AllDetectors()
419                               
420                        break
421                case -1: // control being killed
422                        break
423        endswitch
424
425        return 0
426End
427
[958]428//
[1129]429//  recalculates the detector panels, doesn't adjust the views
[958]430//
431Function Recalculate_AllDetectors()
[954]432
[1129]433// calculates Q for each panel
434// and fills 2D panels with model data
[1133]435// then plots the 2D panel
[958]436        fPlotBackPanels()
437        fPlotMiddlePanels()
438        fPlotFrontPanels()
439
[1133]440// generate a proper mask based on hard+soft shadowing
441        VC_ResetVCALCMask()
442        VC_DrawVCALCMask()
443
444
445// generate the 1D I(q)
[1129]446        String popStr
447        String collimationStr = "pinhole"
448        ControlInfo/W=VCALC popup_b
449        popStr = S_Value                //
450        V_QBinAllPanels_Circular("VCALC",V_BinTypeStr2Num(popStr),collimationStr)
451
452        // plot the results (1D)
453        String type = "VCALC"
454        String str,winStr="VCALC#Panels_IQ",workTypeStr
455        workTypeStr = "root:Packages:NIST:VSANS:"+type
456       
457        sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,V_BinTypeStr2Num(popStr),winStr
458        Execute ("V_Back_IQ_Graph"+str)
459               
460        Execute ("V_Middle_IQ_Graph"+str)
461       
462        Execute ("V_Front_IQ_Graph"+str)
463
464
[1133]465// update values on the panel
[1109]466        V_beamIntensity()
[1108]467       
[1128]468//      Print "Beam diam (middle) = ",VC_beamDiameter("horizontal",2)           //middle carriage
469       
[1133]470        // fill in the Qmin and Qmax values, based on Q_Tot for the 2D panels (not including mask)
[1128]471        V_QMinMax_Back()
472        V_QMinMax_Middle()
473        V_QMinMax_Front()
474       
475        //calculate beam diameter and beamstop size
476        V_BeamDiamDisplay("maximum", "MR")      //TODO -- hard-wired here for the Middle carriage (and in the SetVar label)
477        V_BeamStopDiamDisplay("MR")
478       
479        //calculate the "real" QMin with the beamstop
480        V_QMin_withBeamStop("MR")               //TODO -- hard-wired here as the middle carriage and MR panel
481       
482        // multiply the averaged data by the shadow factor to simulate a beamstop
483        V_IQ_BeamstopShadow()
484       
[958]485        return(0)
486End
487
[1128]488
489
[954]490// function to control the drawing of controls in the TabControl on the main panel
491// Naming scheme for the controls MUST be strictly adhered to... else controls will
492// appear in odd places...
493// all controls are named VCALCCtrl_NA where N is the tab number and A is the letter denoting
494// the controls position on that particular tab.
495// in this way, they will always be drawn correctly..
496//
497//
498// -- this will need to be modified to allow for the graph to be drawn of the detector bank positions
499//     if that is individual to each tab - or if it's  always visible - that's still to be decided.
500//
501//
502Function VCALCTabProc(name,tab)
503        String name
504        Variable tab
505       
506//      Print "name,number",name,tab
507        String ctrlList = ControlNameList("",";"),item="",nameStr=""
508        Variable num = ItemsinList(ctrlList,";"),ii,onTab
509        for(ii=0;ii<num;ii+=1)
510                //items all start w/"VCALCCtrl_", 10 characters
511                item=StringFromList(ii, ctrlList ,";")
512                nameStr=item[0,9]
513                if(cmpstr(nameStr,"VCALCCtrl_")==0)
514                        onTab = str2num(item[10])                       //[10] is a number
515                        ControlInfo $item
516                        switch(abs(V_flag))     
517                                case 1:
518                                        Button $item,disable=(tab!=onTab)
519                                        break
520                                case 2:
521                                        CheckBox $item,disable=(tab!=onTab)
522                                        break
523                                case 3:
524                                        PopupMenu $item,disable=(tab!=onTab)
525                                        break
526                                case 4:
527                                        ValDisplay $item,disable=(tab!=onTab)
528                                        break
529                                case 5:
530                                        SetVariable $item,disable=(tab!=onTab)
531                                        break
532                                case 7:
533                                        Slider $item,disable=(tab!=onTab)
534                                        break
535                                case 9:
536                                        GroupBox $item,disable=(tab!=onTab)
537                                        break
538                                case 10:       
539                                        TitleBox $item,disable=(tab!=onTab)
540                                        break
541                                // add more items to the switch if different control types are used
542                        endswitch
543                endif
544        endfor
545       
[1128]546        return(0)
547End
[954]548
[1128]549
550
551// TODO
552//changing the number of guides changes the SSD
553// the source aperture popup may need to be updated
554//
555Function V_GuideSliderProc(ctrlName,sliderValue,event)
556        String ctrlName
557        Variable sliderValue
558        Variable event  // bit field: bit 0: value set, 1: mouse down, 2: mouse up, 3: mouse moved
[954]559       
[1128]560        Variable recalc=0
561        SVAR apStr = root:Packages:NIST:VSANS:VCALC:gSourceDiam
562       
563        if(event %& 0x1)        // bit 0, value set
[1134]564
[1128]565                //change the sourceAp popup, SDD range, etc
566                switch(sliderValue)
567                        case 0:
568                                apStr = "0.75 cm;1.5 cm;3.0 cm;"
569                                break
570                        default:
571                                apStr = "6 cm;"
572                endswitch
573                ControlUpdate/W=VCALC VCALCCtrl_0f
[1134]574
575//              Recalculate_AllDetectors()
576
[1128]577        endif
578        return 0
[954]579End
580
[1128]581
582
583
584
[954]585Function Front2DQ_Log_CheckProc(cba) : CheckBoxControl
586        STRUCT WMCheckboxAction &cba
587
588        switch( cba.eventCode )
589                case 2: // mouse up
590                        Variable checked = cba.checked
591                       
592                        Execute "FrontPanels_AsQ()"
593                        Execute "MiddlePanels_AsQ()"
594                        Execute "BackPanels_AsQ()"
[958]595                       
[954]596                        break
597                case -1: // control being killed
598                        break
599        endswitch
600
601        return 0
602End
603
[1108]604
605
606Function VC_SourceAperDiamSelectPopup(pa) : PopupMenuControl
607        STRUCT WMPopupAction &pa
608
609        switch( pa.eventCode )
610                case 2: // mouse up
611                        Variable popNum = pa.popNum
612                        String popStr = pa.popStr
613                       
614                        Print "Not filled in yet"
615                       
616                        // a recalculation is needed after the change
617                        //Recalculate_AllDetectors()
618                                       
619                        break
620                case -1: // control being killed
621                        break
622        endswitch
623
624        return 0
625End
626
627Function VC_SourceApShapeSelectPopup(pa) : PopupMenuControl
628        STRUCT WMPopupAction &pa
629
630        switch( pa.eventCode )
631                case 2: // mouse up
632                        Variable popNum = pa.popNum
633                        String popStr = pa.popStr
634                       
635                        Print "Not filled in yet"
636
637                        // a recalculation is needed after the change
638                        //Recalculate_AllDetectors()
639                                                                       
640                        break
641                case -1: // control being killed
642                        break
643        endswitch
644
645        return 0
646End
647
648Function VC_DeltaLamSelectPopup(pa) : PopupMenuControl
649        STRUCT WMPopupAction &pa
650
651        switch( pa.eventCode )
652                case 2: // mouse up
653                        Variable popNum = pa.popNum
654                        String popStr = pa.popStr
655                       
656                        // a recalculation is needed after the change
[1134]657//                      Recalculate_AllDetectors()
[1108]658                                                                       
659                        break
660                case -1: // control being killed
661                        break
662        endswitch
663
664        return 0
665End
666
667// change the choices for deltaLam based on the
668// type of monochromator selected
[958]669//
[1108]670// some cases force a change of the wavelength
671//
672// then recalculate
673Function VC_MonochromSelectPopup(pa) : PopupMenuControl
674        STRUCT WMPopupAction &pa
675
676        switch( pa.eventCode )
677                case 2: // mouse up
678                        Variable popNum = pa.popNum
679                        String popStr = pa.popStr
680                       
681                        SVAR DLStr = root:Packages:NIST:VSANS:VCALC:gDeltaLambda
682                       
683                        strswitch(popStr)
684                                case "Velocity Selector":
685                                        DLStr = "0.12;"
[1109]686//                                      PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda
687                                        PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.12"
[1108]688                                       
689                                        SetVariable VCALCCtrl_0b,disable=0,noedit=0             // allow user editing again
690
691                                        break
692                                case "Graphite":
693                                        DLStr = "0.01;"
[1109]694//                                      PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.01",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda
695                                        PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.01"
[1108]696                                       
697                                        SetVariable VCALCCtrl_0b,value=_NUM:4.75,disable=2              // wavelength
698                                        break
699                                case "White Beam":
700                                        DLStr = "0.40;"
[1109]701//                                      PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda
702                                        PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.40"
[1108]703
704                                        SetVariable VCALCCtrl_0b,value=_NUM:5.3,disable=2               //wavelength
705                                        break           
706                                default:
707                                        Print "Error--No match in VC_MonochromSelectPopup"
708                                        return(0)
709                        endswitch
710                       
711
712                        // a recalculation is needed after the change
[1134]713//                      Recalculate_AllDetectors()
[1108]714                                                               
715                        break
716                case -1: // control being killed
717                        break
718        endswitch
719
720        return 0
721End
722
[1129]723//
724//
725// "F+M Ng0 Low Q;F+M Ng2 Mid Q;F+M Ng7 Mid Q;F+M Ng9 High Q;Converging Pinholes;Narrow Slit;White Beam;Graphite;Polarizer;"
726//
[1108]727Function VC_PresetConfigPopup(pa) : PopupMenuControl
728        STRUCT WMPopupAction &pa
729
730        switch( pa.eventCode )
731                case 2: // mouse up
732                        Variable popNum = pa.popNum
733                        String popStr = pa.popStr
734                       
[1109]735                        String BinStr = "F2-M2xTB-B"
[1108]736               
737                        strswitch(popStr)
[1129]738                                case "F+M Ng0 Low Q":
739                                        VC_Preset_FrontMiddle_Ng0()
[1108]740                                        break
[1129]741                                case "F+M Ng2 Mid Q":
742                                        VC_Preset_FrontMiddle_Ng2()
743                                        break
744                                case "F+M Ng7 Mid Q":
745                                        VC_Preset_FrontMiddle_Ng7()
746                                        break
747                                case "F+M Ng9 High Q":
748                                        VC_Preset_FrontMiddle_Ng9()
749                                        break
[1108]750                                       
751                                case "White Beam":
[1129]752                                        VC_Preset_WhiteBeam()
[1108]753                                        break   
[1109]754                                case "Graphite":
[1129]755                                        VC_Preset_GraphiteMono()
[1109]756                                        break
[1108]757                                case "Narrow Slit":
758                                       
759                                        break
760                                case "Converging Pinholes":
761                                       
762                                        break
763                                case "Polarizer":
764                                       
765                                        break
766                                       
767                                default:
768                                        Print "Error--No match in VC_PresetConfigPopup"
769                                        return(0)
770                        endswitch
771                       
772                        // update the views
773                        VC_UpdateViews()
774                       
775                        // a recalculation is needed after the change
[1129]776                        // this re-bins the data too
[1108]777                        Recalculate_AllDetectors()
778                       
[1134]779
[1108]780                        break
781                case -1: // control being killed
782                        break
783        endswitch
784
785        return 0
786End
787
788
789
790
791
792//
[958]793// recalculate the detectors with a preset model function
794//
[982]795Function VC_SimModelFunc_PopProc(ctrlName,popNum,popStr) : PopupMenuControl
[958]796        String ctrlName
797        Variable popNum // which item is currently selected (1-based)
798        String popStr           // contents of current popup item as string
[954]799
[1134]800//      Recalculate_AllDetectors()
[958]801       
802        return(0)       
803End
[954]804
[958]805
806//
807// recalculate the I(q) binning. no need to adjust model function or views
808// just rebin
809//
[1081]810// this is for the VCALC 1-D plot subwindow only. so it is set up to
811// operate on that window - but uses the same binning and plotting routines
812// as the regualr VSANS data display
813//
[982]814Function VC_RebinIQ_PopProc(ctrlName,popNum,popStr) : PopupMenuControl
[958]815        String ctrlName
816        Variable popNum // which item is currently selected (1-based)
817        String popStr           // contents of current popup item as string
818
819
[1081]820        String type = "VCALC"
821        String str,winStr="VCALC#Panels_IQ",workTypeStr
822        workTypeStr = "root:Packages:NIST:VSANS:"+type
[958]823       
[1097]824        String collimationStr = "pinhole"               //TODO: fill this in from the VCALC panel
825       
[1081]826// dispatch based on the string, not on the number of selection in the pop string
[1097]827        V_QBinAllPanels_Circular(type,V_BinTypeStr2Num(popStr),collimationStr)
[958]828       
[1081]829        sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,V_BinTypeStr2Num(popStr),winStr
830
831        Execute ("V_Back_IQ_Graph"+str)
832        Execute ("V_Middle_IQ_Graph"+str)
833        Execute ("V_Front_IQ_Graph"+str)
834
835//     
[958]836        return(0)       
837End
838
839
[1128]840//
841// setVar for the distance from Sample Position to Gave Valve
842//
843Function VC_Sam_to_GV_SetVarProc(sva) : SetVariableControl
844        STRUCT WMSetVariableAction &sva
[958]845
[1128]846        switch( sva.eventCode )
847                case 1: // mouse up
848                case 2: // Enter key
849                case 3: // Live update
850                        Variable dval = sva.dval
851                        String sval = sva.sval
852                       
853//                      // don't need to recalculate the views, but need to recalculate the detectors
854
[1129]855//                      Recalculate_AllDetectors()             
[1128]856                               
857                        break
858                case -1: // control being killed
859                        break
860        endswitch
861
862        return 0
863End
[958]864       
[1128]865
866//
867// setVar for the distance from Sample Aperture to Gave Valve
868//
869Function VC_A2_to_GV_SetVarProc(sva) : SetVariableControl
870        STRUCT WMSetVariableAction &sva
871
872        switch( sva.eventCode )
873                case 1: // mouse up
874                case 2: // Enter key
875                case 3: // Live update
876                        Variable dval = sva.dval
877                        String sval = sva.sval
878                       
879//                      // don't need to recalculate the views, but need to recalculate the detectors
880
[1129]881//                      Recalculate_AllDetectors()             
[1128]882                               
883                        break
884                case -1: // control being killed
885                        break
886        endswitch
887
888        return 0
889End
[958]890       
891//
[954]892// setVar for the wavelength
893//
[982]894Function VC_Lambda_SetVarProc(sva) : SetVariableControl
[954]895        STRUCT WMSetVariableAction &sva
896
897        switch( sva.eventCode )
898                case 1: // mouse up
899                case 2: // Enter key
900                case 3: // Live update
901                        Variable dval = sva.dval
902                        String sval = sva.sval
903                       
[958]904//                      // don't need to recalculate the views, but need to recalculate the detectors
905
[1134]906//                      Recalculate_AllDetectors()             
[958]907                               
[954]908                        break
909                case -1: // control being killed
910                        break
911        endswitch
912
913        return 0
914End
915
[958]916//
917// setVar for the simulation monitor count
918//
[982]919Function VC_SimImon_SetVarProc(sva) : SetVariableControl
[958]920        STRUCT WMSetVariableAction &sva
[954]921
[958]922        switch( sva.eventCode )
923                case 1: // mouse up
924                case 2: // Enter key
925                case 3: // Live update
926                        Variable dval = sva.dval
927                        String sval = sva.sval
928
[1134]929//                      Recalculate_AllDetectors()             
[958]930                               
931                        break
932                case -1: // control being killed
933                        break
934        endswitch
935
936        return 0
937End
938
939
[954]940// setVar for the range (in degrees) for the FrontView plot of the detectors
941//
942Function FrontView_Range_SetVarProc(sva) : SetVariableControl
943        STRUCT WMSetVariableAction &sva
944
945        switch( sva.eventCode )
946                case 1: // mouse up
947                case 2: // Enter key
948                case 3: // Live update
949                        Variable dval = sva.dval
950                        String sval = sva.sval
951                       
952                        FrontView_1x()
953                       
954                        break
955                case -1: // control being killed
956                        break
957        endswitch
958
959        return 0
960End
961
962// setVar for the range (in Q) for the FrontView plot of the detectors
963//
964// TODO: this assumes that everything (the data) is already updated - this only updates the plot range
965Function Front2DQ_Range_SetVarProc(sva) : SetVariableControl
966        STRUCT WMSetVariableAction &sva
967
968        switch( sva.eventCode )
969                case 1: // mouse up
970                case 2: // Enter key
971                case 3: // Live update
972                        Variable dval = sva.dval
973                        String sval = sva.sval
974                       
975                        SetAxis/W=VCALC#Panels_Q left -dval,dval
976                        SetAxis/W=VCALC#Panels_Q bottom -dval,dval
977                       
978//                      FrontPanels_AsQ()
979                       
980                        break
981                case -1: // control being killed
982                        break
983        endswitch
984
985        return 0
986End
987
988// SDD for the Front detector. triggers a recalculation
989// of the intensity and a redraw of the banks
990//
[982]991Function VC_FDet_SDD_SetVarProc(sva) : SetVariableControl
[954]992        STRUCT WMSetVariableAction &sva
993
994        switch( sva.eventCode )
995                case 1: // mouse up
996                case 2: // Enter key
997                case 3: // Live update
998                        Variable dval = sva.dval
999                        String sval = sva.sval
1000                       
1001//                      Variable LR_sep,TB_sep
1002//                      // don't know if LR or TB called, so get the explicit values
1003//                      //
1004//                      ControlInfo VCALCCtrl_2a
1005//                      LR_sep = V_Value
1006//                      ControlInfo VCALCCtrl_2b
1007//                      TB_sep = V_Value
1008//                     
1009//                      UpdateFrontDetector(LR_sep,TB_sep)
1010                       
1011                        UpdateSideView()
1012                        UpdateTopView()
1013                        FrontView_1x()
1014                       
1015                        fPlotFrontPanels()
1016                       
1017                        break
1018                case -1: // control being killed
1019                        break
1020        endswitch
1021
1022        return 0
1023End
1024
1025// SDD for the Middle detector. triggers a recalculation
1026// of the intensity and a redraw of the banks
1027//
[982]1028Function VC_MDet_SDD_SetVarProc(sva) : SetVariableControl
[954]1029        STRUCT WMSetVariableAction &sva
1030
1031        switch( sva.eventCode )
1032                case 1: // mouse up
1033                case 2: // Enter key
1034                case 3: // Live update
1035                        Variable dval = sva.dval
1036                        String sval = sva.sval
1037                       
1038//                      Variable LR_sep,TB_sep
1039//                      // don't know if LR or TB called, so get the explicit values
1040//                      //
1041//                      ControlInfo VCALCCtrl_2a
1042//                      LR_sep = V_Value
1043//                      ControlInfo VCALCCtrl_2b
1044//                      TB_sep = V_Value
1045//                     
1046//                      UpdateFrontDetector(LR_sep,TB_sep)
1047                       
1048                        UpdateSideView()
1049                        UpdateTopView()
1050                        FrontView_1x()
1051                       
1052                        fPlotMiddlePanels()
1053                       
1054                        break
1055                case -1: // control being killed
1056                        break
1057        endswitch
1058
1059        return 0
1060End
1061
1062// SDD for the Back detector. triggers a recalculation
1063// of the intensity and a redraw of the banks
1064//
[982]1065Function VC_BDet_SDD_SetVarProc(sva) : SetVariableControl
[954]1066        STRUCT WMSetVariableAction &sva
1067
1068        switch( sva.eventCode )
1069                case 1: // mouse up
1070                case 2: // Enter key
1071                case 3: // Live update
1072                        Variable dval = sva.dval
1073                        String sval = sva.sval
1074                       
1075//                      Variable LR_sep,TB_sep
1076//                      // don't know if LR or TB called, so get the explicit values
1077//                      //
1078//                      ControlInfo VCALCCtrl_2a
1079//                      LR_sep = V_Value
1080//                      ControlInfo VCALCCtrl_2b
1081//                      TB_sep = V_Value
1082//                     
1083//                      UpdateFrontDetector(LR_sep,TB_sep)
1084                       
1085                        UpdateSideView()
1086                        UpdateTopView()
1087                        FrontView_1x()
1088                       
1089                        fPlotBackPanels()
1090                       
1091                        break
1092                case -1: // control being killed
1093                        break
1094        endswitch
1095
1096        return 0
1097End
1098
1099// separation, either LR or TB of the front detector. triggers a recalculation
1100// of the intensity and a redraw of the banks
1101//
[982]1102Function VC_FDet_LR_SetVarProc(sva) : SetVariableControl
[954]1103        STRUCT WMSetVariableAction &sva
1104
1105        switch( sva.eventCode )
1106                case 1: // mouse up
1107                case 2: // Enter key
1108                case 3: // Live update
1109                        Variable dval = sva.dval
1110                        String sval = sva.sval
1111                       
[1081]1112//                      Variable LR_sep,TB_sep
1113//                      // don't know if LR or TB called, so get the explicit values
1114//                      //
1115//                      ControlInfo VCALCCtrl_2a
1116//                      LR_sep = V_Value
1117//                      ControlInfo VCALCCtrl_2b
1118//                      TB_sep = V_Value
1119//                     
[954]1120//                      UpdateFrontDetector(LR_sep,TB_sep)
1121                       
1122                        UpdateSideView()
1123                        UpdateTopView()
1124                        FrontView_1x()
1125                       
1126                        fPlotFrontPanels()
1127                       
1128                        break
1129                case -1: // control being killed
1130                        break
1131        endswitch
1132
1133        return 0
1134End
1135
1136
1137// separation, either LR or TB of the middle detector. triggers a recalculation
1138// of the intensity and a redraw of the banks
1139//
[982]1140Function VC_MDet_LR_SetVarProc(sva) : SetVariableControl
[954]1141        STRUCT WMSetVariableAction &sva
1142
1143        switch( sva.eventCode )
1144                case 1: // mouse up
1145                case 2: // Enter key
1146                case 3: // Live update
1147                        Variable dval = sva.dval
1148                        String sval = sva.sval
1149                       
[1081]1150//                      Variable LR_sep,TB_sep
1151//                      // don't know if LR or TB called, so get the explicit values
1152//                      //
1153//                      ControlInfo VCALCCtrl_3a
1154//                      LR_sep = V_Value
1155//                      ControlInfo VCALCCtrl_3b
1156//                      TB_sep = V_Value
[954]1157                       
1158//                      UpdateMiddleDetector(LR_sep,TB_sep)
1159                       
1160                        UpdateSideView()
1161                        UpdateTopView()
1162                        FrontView_1x()
1163                       
1164                        fPlotMiddlePanels()
1165                       
1166                        break
1167                case -1: // control being killed
1168                        break
1169        endswitch
1170
1171        return 0
1172End
1173
[1108]1174// call to update the views (not the q-calculation, that is a separate call)
1175Function VC_UpdateViews()
[954]1176
[1108]1177        UpdateSideView()
1178        UpdateTopView()
1179        FrontView_1x()
1180       
1181        return(0)
1182End
[954]1183
[1108]1184// this all needs to be fixed and updated - not yet specific to VSANS
[954]1185//
1186// -- all of the simulation stuff will need to be re-thought
1187// -- all of the integersRead, data, etc. will need to be re-thought...
1188// -- but the space needs to be allocated.
1189// -- parameters and constants need to be defined in their own space
1190//
[982]1191// FEB 2016 -- changed the data folder space to mimic the HDF folder structure
1192// so that the averaging routines could be re-used (along with everything else)
1193// -- painful, but better in the long run
[954]1194//
[982]1195// -- I have not re-named the detector arrays to all be "data" since that is very difficult to
1196//   deal with on images. Added a global "gVCALC_Active" as a crude workaround as needed. Turn it
1197//   on when needed and then immediately off
[954]1198//
[982]1199Proc VC_Initialize_Space()
1200//
[954]1201        NewDataFolder/O root:Packages
1202        NewDataFolder/O root:Packages:NIST
1203        NewDataFolder/O root:Packages:NIST:VSANS
1204        NewDataFolder/O root:Packages:NIST:VSANS:VCALC
[999]1205        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry
1206        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument
1207        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B
1208        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB
1209        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT
1210        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML
1211        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR
1212        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB
1213        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT
1214        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL
1215        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR
[982]1216
1217//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Front
1218//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Middle
1219//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Back
1220
[970]1221        NewDataFolder/O root:Packages:NIST:VSANS:RawVSANS
[954]1222       
[982]1223        Variable/G root:Packages:NIST:VSANS:VCALC:gVCALC_Active = 1
[993]1224        Variable/G root:Packages:NIST:VSANS:VCALC:gUseNonLinearDet = 0          //if == 1, use RAW non-linear corrections
[954]1225       
1226        SetDataFolder root:Packages:NIST:VSANS:VCALC
1227       
1228
1229///// FRONT DETECTOR BANKS
1230// dimensions for the detector banks (then get them in the drawing functions)
[983]1231// Width and height are not part of the Nexus file definition, but are needed for VCALC drawing
1232// so keep them as variables
[1133]1233        Variable/G gFront_LR_w = 40.3           //front bank, nominal LR panel width [cm]  0.84cm/tube*48 = 40.3 cm
[1062]1234        Variable/G gFront_LR_h = 100.0
1235        Variable/G gFront_TB_w = 50.0
[1133]1236        Variable/G gFront_TB_h = 40.3
[954]1237
[1062]1238// SDD setback of T/B (decide on units??)
[983]1239// for the Nexus file, the detector distance should already be corrected for the "setback"
1240// of the T/B panels. keep as VCALC variable
[1062]1241        Variable/G gFront_SDDsetback = 41.0                     // [cm]
[954]1242       
[983]1243       
[954]1244// detector resolution (xy for each bank!)
[992]1245        Make/O/D/N=1 :entry:instrument:detector_FL:x_pixel_size = 0.84          // (cm)         these tubes are vertical 8.4 mm x-spacing (JGB 2/2106)
1246        Make/O/D/N=1 :entry:instrument:detector_FL:y_pixel_size = 0.8           // (cm)         //!! now 8 mm, since nPix=128, rather than 256
1247        Make/O/D/N=1 :entry:instrument:detector_FR:x_pixel_size = 0.84
1248        Make/O/D/N=1 :entry:instrument:detector_FR:y_pixel_size = 0.8
[983]1249        //T/B
[992]1250        Make/O/D/N=1 :entry:instrument:detector_FT:x_pixel_size = 0.4           //these tubes are horizontal
1251        Make/O/D/N=1 :entry:instrument:detector_FT:y_pixel_size = 0.84
1252        Make/O/D/N=1 :entry:instrument:detector_FB:x_pixel_size = 0.4
1253        Make/O/D/N=1 :entry:instrument:detector_FB:y_pixel_size = 0.84
[954]1254       
[1081]1255
[954]1256// number of pixels in each bank (this can be modified at acquisition time, so it must be adjustable here)
[992]1257        Make/O/D/N=1 :entry:instrument:detector_FL:pixel_num_x = 48     // == number of tubes
1258        Make/O/D/N=1 :entry:instrument:detector_FL:pixel_num_y = 128    // == pixels in vertical direction (was 256, John says likely will run @ 128 9/2015)
1259        Make/O/D/N=1 :entry:instrument:detector_FR:pixel_num_x = 48     // == number of tubes
1260        Make/O/D/N=1 :entry:instrument:detector_FR:pixel_num_y = 128    // == pixels in vertical direction
1261        Make/O/D/N=1 :entry:instrument:detector_FT:pixel_num_x = 128    // == pixels in horizontal direction
1262        Make/O/D/N=1 :entry:instrument:detector_FT:pixel_num_y = 48     // == number of tubes
1263        Make/O/D/N=1 :entry:instrument:detector_FB:pixel_num_x = 128    // == pixels in horizontal direction
1264        Make/O/D/N=1 :entry:instrument:detector_FB:pixel_num_y = 48     // == number of tubes
[954]1265
1266
[1081]1267
[993]1268// pixel beam center - HDF style
1269        Make/O/D/N=1 :entry:instrument:detector_FL:beam_center_x = 55           // == x beam center, in pixels
1270        Make/O/D/N=1 :entry:instrument:detector_FL:beam_center_y = 64           // == y beam center, in pixels
1271        Make/O/D/N=1 :entry:instrument:detector_FR:beam_center_x = -8   
1272        Make/O/D/N=1 :entry:instrument:detector_FR:beam_center_y = 64   
1273        Make/O/D/N=1 :entry:instrument:detector_FT:beam_center_x = 64   
1274        Make/O/D/N=1 :entry:instrument:detector_FT:beam_center_y = -8   
1275        Make/O/D/N=1 :entry:instrument:detector_FB:beam_center_x = 64   
1276        Make/O/D/N=1 :entry:instrument:detector_FB:beam_center_y = 55   
[963]1277
1278
[983]1279
[954]1280///// MIDDLE DETECTOR BANKS
[983]1281// Width and height are not part of the Nexus file definition, but are needed for VCALC drawing
1282// so keep them as variables
[1133]1283        Variable/G gMiddle_LR_w = 40.3                  //middle bank, nominal LR panel width (cm) 0.84cm/tube*48 = 40.3 cm
[1062]1284        Variable/G gMiddle_LR_h = 100.0
1285        Variable/G gMiddle_TB_w = 50.0
[1133]1286        Variable/G gMiddle_TB_h = 40.3
[954]1287// SDD offset of T/B (decide on units??)
[983]1288// for the Nexus file, the detector distance should already be corrected for the "setback"
1289// of the T/B panels. keep as VCALC variable
[1062]1290        Variable/G gMiddle_SDDsetback = 41.0                    // [cm]
[954]1291       
1292// detector resolution (xy for each bank!)
[992]1293        Make/O/D/N=1 :entry:instrument:detector_ML:x_pixel_size = 0.84          // (cm)         these tubes are vertical 8.4 mm x-spacing (JGB 2/2106)
1294        Make/O/D/N=1 :entry:instrument:detector_ML:y_pixel_size = 0.8           // (cm)         //!! now 8 mm, since nPix=128, rather than 256
1295        Make/O/D/N=1 :entry:instrument:detector_MR:x_pixel_size = 0.84
1296        Make/O/D/N=1 :entry:instrument:detector_MR:y_pixel_size = 0.8
[983]1297        //T/B
[992]1298        Make/O/D/N=1 :entry:instrument:detector_MT:x_pixel_size = 0.4           //these tubes are horizontal
1299        Make/O/D/N=1 :entry:instrument:detector_MT:y_pixel_size = 0.84
1300        Make/O/D/N=1 :entry:instrument:detector_MB:x_pixel_size = 0.4
1301        Make/O/D/N=1 :entry:instrument:detector_MB:y_pixel_size = 0.84
[954]1302
[983]1303
[1081]1304
[963]1305// number of pixels in each bank (this can be modified at acquisition time, so it must be adjustable here)
[992]1306        Make/O/D/N=1 :entry:instrument:detector_ML:pixel_num_x = 48     // == number of tubes
1307        Make/O/D/N=1 :entry:instrument:detector_ML:pixel_num_y = 128    // == pixels in vertical direction (was 256, John says likely will run @ 128 9/2015)
1308        Make/O/D/N=1 :entry:instrument:detector_MR:pixel_num_x = 48     // == number of tubes
1309        Make/O/D/N=1 :entry:instrument:detector_MR:pixel_num_y = 128    // == pixels in vertical direction
1310        Make/O/D/N=1 :entry:instrument:detector_MT:pixel_num_x = 128    // == pixels in horizontal direction
1311        Make/O/D/N=1 :entry:instrument:detector_MT:pixel_num_y = 48     // == number of tubes
1312        Make/O/D/N=1 :entry:instrument:detector_MB:pixel_num_x = 128    // == pixels in horizontal direction
1313        Make/O/D/N=1 :entry:instrument:detector_MB:pixel_num_y = 48     // == number of tubes
[983]1314       
[954]1315
[1081]1316
[993]1317// pixel beam center - HDF style
1318        Make/O/D/N=1 :entry:instrument:detector_ML:beam_center_x = 55           // == x beam center, in pixels
1319        Make/O/D/N=1 :entry:instrument:detector_ML:beam_center_y = 64           // == y beam center, in pixels
1320        Make/O/D/N=1 :entry:instrument:detector_MR:beam_center_x = -8   
1321        Make/O/D/N=1 :entry:instrument:detector_MR:beam_center_y = 64   
1322        Make/O/D/N=1 :entry:instrument:detector_MT:beam_center_x = 64   
1323        Make/O/D/N=1 :entry:instrument:detector_MT:beam_center_y = -8   
1324        Make/O/D/N=1 :entry:instrument:detector_MB:beam_center_x = 64   
1325        Make/O/D/N=1 :entry:instrument:detector_MB:beam_center_y = 55   
[954]1326
[963]1327
1328
1329
[954]1330//// BACK DETECTOR
[1093]1331        Variable/G gBack_w = 22.2                               //w and h for the back detector [cm]
1332        Variable/G gBack_h = 50.4
[983]1333       
[1081]1334       
[1117]1335        // TODOHIRES -- be sure that all of this is correct, since it is hard-wired values
1336        // -- can't use a switch so I'm using an if(), where the default is 4x4 binning
1337        if(root:Packages:NIST:VSANS:Globals:gHighResBinning == 1)
1338                Make/O/D/N=1 :entry:instrument:detector_B:x_pixel_size = 0.00845                // 340 micron resolution (units of [cm] here)
1339                Make/O/D/N=1 :entry:instrument:detector_B:y_pixel_size = 0.00845               
1340       
1341                Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_x = 2720            // detector pixels in x-direction
1342                Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_y = 6624
1343               
1344        // pixel beam center - HDF style
1345                Make/O/D/N=1 :entry:instrument:detector_B:beam_center_x = 1360.1        // == x beam center, in pixels +0.1 so I know it's from here
1346                Make/O/D/N=1 :entry:instrument:detector_B:beam_center_y = 3312.1                // == y beam center, in pixels
1347        else
1348                Make/O/D/N=1 :entry:instrument:detector_B:x_pixel_size = 0.034          // 340 micron resolution (units of [cm] here)
1349                Make/O/D/N=1 :entry:instrument:detector_B:y_pixel_size = 0.034         
1350       
1351                Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_x = 680             // detector pixels in x-direction
1352                Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_y = 1656
1353               
1354        // pixel beam center - HDF style
1355                Make/O/D/N=1 :entry:instrument:detector_B:beam_center_x = 340.1 // == x beam center, in pixels +0.1 so I know it's from here
1356                Make/O/D/N=1 :entry:instrument:detector_B:beam_center_y = 828.1         // == y beam center, in pixels
1357        endif
[954]1358
[983]1359
[954]1360// Generate all of the waves used for the detector and the q values
1361//
1362// TODO: the detector dimensions need to be properly defined here...
1363// FRONT
[982]1364//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front
[954]1365
[992]1366        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL
[983]1367        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FL
[954]1368        Duplicate/O det_FL qTot_FL,qx_FL,qy_FL,qz_FL
[982]1369
[992]1370        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR
[983]1371        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FR
[954]1372        Duplicate/O det_FR qTot_FR,qx_FR,qy_FR,qz_FR
[982]1373
[992]1374        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT
[983]1375        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FT
[954]1376        Duplicate/O det_FT qTot_FT,qx_FT,qy_FT,qz_FT
[982]1377       
[992]1378        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB
[983]1379        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FB
[954]1380        Duplicate/O det_FB qTot_FB,qx_FB,qy_FB,qz_FB
1381
[982]1382
[954]1383//MIDDLE
1384// TODO: the detector dimensions need to be properly defined here...
[982]1385//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle
[954]1386
[992]1387        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML
[983]1388        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_ML
[954]1389        Duplicate/O det_ML qTot_ML,qx_ML,qy_ML,qz_ML
[982]1390       
[992]1391        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR
[983]1392        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MR
[954]1393        Duplicate/O det_MR qTot_MR,qx_MR,qy_MR,qz_MR
[982]1394
[992]1395        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT
[983]1396        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MT
[954]1397        Duplicate/O det_MT qTot_MT,qx_MT,qy_MT,qz_MT
[982]1398       
[992]1399        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB
[983]1400        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MB
[954]1401        Duplicate/O det_MB qTot_MB,qx_MB,qy_MB,qz_MB
1402
1403// BACK
1404// TODO: the detector dimensions need to be properly defined here...
[982]1405//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Back
1406
[992]1407        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B
[983]1408        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_B
[954]1409        Duplicate/O det_B qTot_B,qx_B,qy_B,qz_B
1410
1411
1412////////////    FOR THE PANEL
1413
1414        SetDataFolder root:Packages:NIST:VSANS:VCALC
1415
[963]1416        Make/O/D/N=2 fpx1,fpy1,mpx1,mpy1                // for display of the detector panels
1417        Make/O/D/N=2 fv_degX,fv_degY
1418
1419
1420// to fill in:
1421// values for always-visible items
[1129]1422        String/G gPresetPopStr = "F+M Ng0 Low Q;F+M Ng2 Mid Q;F+M Ng7 Mid Q;F+M Ng9 High Q;Converging Pinholes;Narrow Slit;White Beam;Graphite;Polarizer;"
[1035]1423        String/G gBinTypeStr = ksBinTypeStr
[1108]1424        Variable/G gBeamIntensity= 0
[963]1425
[1128]1426        Variable/G gQmin_F,gQmax_F,gQmin_M,gQmax_M,gQmin_B,gQmax_B
1427        Variable/G gBeamDiam,gBeamStopDiam
1428        Variable/G gRealQMin
[963]1429
[954]1430// popup strings for each tab (then use the string in the panel)
1431// tab 0 - collimation
1432        String/G gMonochromatorType = "Velocity Selector;Graphite;White Beam;"
[978]1433        String/G gSourceShape = "circular;rectangular;converging pinholes;"
[1128]1434        String/G gSourceDiam = "6.0 cm;"
[1092]1435        String/G gSourceDiam_0g = "0.75 cm;1.5 cm;3.0 cm;"              // values from John Mar 2018
[1128]1436        String/G gDeltaLambda = "0.12;"
[954]1437       
1438// tab 1 - sample conditions
1439        String/G gTableLocation = "Changer;Stage;"
[978]1440        String/G gSampleApertureShape = "circular;rectangular;converging pinholes;"
[1128]1441        String/G gSampleApertureDiam = "1.27;1.59;1.0;2.0;"
[954]1442       
1443// tab 2
1444
1445// tab 3
1446
1447// tab 4 - back detector
1448        String/G gBackDetType = "1D;2D;"
1449
1450// tab 5
[955]1451        String/G gModelFunctionType = "Debye;Sphere;Big Debye;Big Sphere;AgBeh;Vycor;Empty Cell;Blocked Beam;"
[1022]1452        gModelFunctionType += "Debye +;AgBeh +;Empty Cell +;"
[954]1453
1454////////////////////
1455
1456
1457
1458// limits for detector travel? or are these limits part of the panel, hard-wired there
1459
1460
1461//      // for the panel
1462
[1133]1463//      Variable/G gNg=0
[954]1464//      Variable/G gOffset=0
[1133]1465//      Variable/G gSamAp=1.27          //samAp diameter in cm
[1128]1466//      String/G gSourceApString = "1.43 cm;2.54 cm;3.81 cm;"
[1133]1467//      String/G gApPopStr = "1/16\";1/8\";3/16\";1/4\";5/16\";3/8\";7/16\";1/2\";9/16\";5/8\";11/16\";3/4\";other;"
1468//      Variable/G gSamApOther = 10             //non-standard aperture diameter, in mm
1469//      Variable/G gUsingLenses = 0             //0=no lenses, 1=lenses(or prisms)
[954]1470//      Variable/G gModelOffsetFactor = 1
1471//     
1472//      // for the MC simulation
1473//      Variable/G doSimulation =0              // == 1 if 1D simulated data, 0 if other from the checkbox
1474//      Variable/G gRanDateTime=datetime
1475//      Variable/G gImon = 10000
1476//      Variable/G gThick = 0.1
1477//      Variable/G gSig_incoh = 0.1
1478//      String/G gFuncStr = ""
1479//      Variable/G gR2 = 2.54/2
1480//      Variable/G gSamTrans=0.8                        //for 1D, default value
1481//      Variable/G gCntTime = 300
1482//      Variable/G gDoMonteCarlo = 0
1483//      Variable/G gUse_MC_XOP = 1                              //set to zero to use Igor code
1484//      Variable/G gBeamStopIn = 1                      //set to zero for beamstop out (transmission)
1485//      Variable/G gRawCounts = 0
1486//      Variable/G gSaveIndex = 100
1487//      String/G gSavePrefix = "SIMUL"
1488//      Variable/G gAutoSaveIndex = 100                 //a way to set the index for automated saves
1489//      String/G gAutoSaveLabel = ""                            //a way to set the "sample" label for automated saves
1490//      Make/O/D/N=10 results = 0
1491//      Make/O/T/N=10 results_desc = {"total X-section (1/cm)","SAS X-section (1/cm)","number that scatter","number that reach detector","avg # times scattered","fraction single coherent","fraction multiple coherent","fraction multiple scattered","fraction transmitted","detector counts w/beamstop"}
1492//
1493//      Variable/G g_1DTotCts = 0                       //summed counts (simulated)
1494//      Variable/G g_1DEstDetCR = 0             // estimated detector count rate
1495//      Variable/G g_1DFracScatt = 0            // fraction of beam captured on detector
1496//      Variable/G g_1DEstTrans = 0             // estimated transmission of sample
1497//      Variable/G g_1D_DoABS = 1
1498//      Variable/G g_1D_AddNoise = 1
1499//      Variable/G g_MultScattFraction=0
1500//      Variable/G g_detectorEff=0.75                   //average value for most wavelengths
1501//      Variable/G g_actSimTime = 0                             //for the save
1502//      Variable/G g_SimTimeWarn = 10                   //manually set to a very large value for scripted operation
1503//     
1504
1505//     
1506//      //for the fake dependency
1507//      Variable/G gTouched=0
1508//      Variable/G gCalculate=0
1509//      //for plotting
1510//      Variable/G gFreezeCount=1               //start the count at 1 to keep Jeff happy
1511//      Variable/G gDoTraceOffset=0             // (1==Yes, offset 2^n), 0==turn off the offset
1512
1513//
1514// instrument - specific dimensions
1515//
1516
1517//     
[1133]1518//      Variable/G gInstrument = 6              // files (may) be tagged SA6 as the 6th SANS instrument
1519//      Variable/G gS12 = 54.8
[954]1520//      Variable/G d_det = 0.5
1521//      Variable/G a_pixel = 0.5
1522//      Variable/G del_r = 0.5
1523//      Variable/G det_width = 64.0
[1133]1524//      Variable/G gLambda_t = 5.50
1525//      Variable/G gL2r_lower = 132.3
1526//      Variable/G gL2r_upper =  1317
1527//      Variable/G gLambda_lower = 2.5
1528//      Variable/G gLambda_upper = 20.0
1529//      Variable/G gD_upper = 25.0
1530//      Variable/G gBs_factor = 1.05
1531//      Variable/G gT1 = 0.63
1532//      Variable/G gT2 = 1.0
1533//      Variable/G gT3 = 0.75
1534//      Variable/G gL_gap = 100.0
1535//      Variable/G gGuide_width = 6.0
1536//      Variable/G gIdmax = 100.0
[954]1537
1538//
1539//      //new values, from 11/2009 --- BeamFluxReport_2009.ifn
[1133]1540//      Variable/G gPhi_0 = 2.42e13
1541//      Variable/G gB = 0.0
1542//      Variable/G gC = -0.0243
1543//      Variable/G gGuide_loss = 0.924
[954]1544//     
1545//      //fwhm values (new variables) (+3, 0, -3, calibrated 2009)
[1133]1546//      Variable/G gFwhm_narrow = 0.109
1547//      Variable/G gFwhm_mid = 0.125
1548//      Variable/G gFwhm_wide = 0.236
[954]1549//     
1550//      //source apertures (cm)
[1133]1551//      Variable/G gA1_0_0 = 1.43
1552//      Variable/G gA1_0_1 = 2.54
1553//      Variable/G gA1_0_2 = 3.81
1554//      Variable/G gA1_7_0 = 2.5                        // after the polarizer         
1555//      Variable/G gA1_7_1 = 5.0
1556//      Variable/G gA1_7_1 = 0.95               //
1557//      Variable/G gA1_def = 5.00
[954]1558//     
1559        SetDataFolder root:
1560end
[1128]1561
1562// set the global values for display
1563Function V_QMinMax_Back()
1564
1565        NVAR min_b = root:Packages:NIST:VSANS:VCALC:gQmin_B
1566        NVAR max_b = root:Packages:NIST:VSANS:VCALC:gQmax_B
1567
1568        String folderStr = "VCALC"
1569        String detStr = ""
1570
1571        String folderPath = "root:Packages:NIST:VSANS:"+folderStr
1572        String instPath = ":entry:instrument:detector_"
1573
1574        detStr = "B"
1575        WAVE qTot_B = $(folderPath+instPath+detStr+":qTot_"+detStr)
[1133]1576        WAVE mask_B = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
[1128]1577
[1133]1578        Duplicate/O qTot_B tmp_B
1579        // for the minimum
1580        tmp_B = (mask_B == 0) ? qTot_B : 1e6
1581        min_b = WaveMin(tmp_B)
[1128]1582
[1133]1583        // for the maximum
1584        tmp_B = (mask_B == 0) ? qTot_B : -1e6
1585        max_b = WaveMax(tmp_B)
[1128]1586
[1133]1587        KillWaves/Z tmp_B
1588
[1128]1589        return(0)
1590end
1591
1592// set the global values for display
1593Function V_QMinMax_Middle()
1594
1595        NVAR min_m = root:Packages:NIST:VSANS:VCALC:gQmin_M
1596        NVAR max_m = root:Packages:NIST:VSANS:VCALC:gQmax_M
1597
1598        String folderStr = "VCALC"
1599        String detStr = ""
1600
1601        String folderPath = "root:Packages:NIST:VSANS:"+folderStr
1602        String instPath = ":entry:instrument:detector_"
1603
1604        detStr = "ML"
1605        WAVE qTot_ML = $(folderPath+instPath+detStr+":qTot_"+detStr)
[1133]1606        WAVE mask_ML = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
[1128]1607
1608        detStr = "MR"
1609        WAVE qTot_MR = $(folderPath+instPath+detStr+":qTot_"+detStr)
[1133]1610        WAVE mask_MR = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
[1128]1611
1612        detStr = "MT"
1613        WAVE qTot_MT = $(folderPath+instPath+detStr+":qTot_"+detStr)
[1133]1614        WAVE mask_MT = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
[1128]1615
1616        detStr = "MB"
1617        WAVE qTot_MB = $(folderPath+instPath+detStr+":qTot_"+detStr)
[1133]1618        WAVE mask_MB = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
[1128]1619
[1133]1620        Variable min1,min2,min3,min4
1621        Variable max1,max2,max3,max4
1622        // WaveMin(), WaveMax() will report NaN or inf
1623        // so for the min, set masked values to 1e6
1624        Duplicate/O qTot_ML tmp_ML
1625        tmp_ML = (mask_ML == 0) ? qTot_ML : 1e6
[1128]1626
[1133]1627        Duplicate/O qTot_MR tmp_MR
1628        tmp_MR = (mask_MR == 0) ? qTot_MR : 1e6
1629       
1630        Duplicate/O qTot_MT tmp_MT
1631        tmp_MT = (mask_MT == 0) ? qTot_MT : 1e6
1632       
1633        Duplicate/O qTot_MB tmp_MB
1634        tmp_MB = (mask_MB == 0) ? qTot_MB : 1e6
1635       
1636        min1 = WaveMin(tmp_ML)
1637        min2 = WaveMin(tmp_MR)
1638        min3 = WaveMin(tmp_MT)
1639        min4 = WaveMin(tmp_MB)
[1128]1640
[1133]1641        // so for the max, set masked values to -1e6
1642        tmp_ML = (mask_ML == 0) ? qTot_ML : -1e6
1643        tmp_MR = (mask_MR == 0) ? qTot_MR : -1e6
1644        tmp_MT = (mask_MT == 0) ? qTot_MT : -1e6
1645        tmp_MB = (mask_MB == 0) ? qTot_MB : -1e6
1646       
1647        max1 = WaveMax(tmp_ML)
1648        max2 = WaveMax(tmp_MR)
1649        max3 = WaveMax(tmp_MT)
1650        max4 = WaveMax(tmp_MB)
1651
1652//      print min1,min2,min3,min4
1653//      print max1,max2,max3,max4
1654               
1655        min_m = min(min1,min2,min3,min4)
1656        max_m = max(max1,max2,max3,max4)
1657
1658//      min_m = min(WaveMin(tmp_ML),WaveMin(tmp_MT),WaveMin(tmp_MR),WaveMin(tmp_MB))
1659//      max_m = max(WaveMax(tmp_ML),WaveMax(tmp_MT),WaveMax(tmp_MR),WaveMax(tmp_MB))
1660       
1661        KillWaves/Z tmp_ML,tmp_MR,tmp_MT,tmp_MB
1662
[1128]1663        return(0)
1664end
1665
1666// set the global values for display
1667Function V_QMinMax_Front()
1668
1669        NVAR min_f = root:Packages:NIST:VSANS:VCALC:gQmin_F
1670        NVAR max_f = root:Packages:NIST:VSANS:VCALC:gQmax_F
1671
1672        String folderStr = "VCALC"
1673        String detStr = ""
1674       
1675        String folderPath = "root:Packages:NIST:VSANS:"+folderStr
1676        String instPath = ":entry:instrument:detector_"
1677
1678        detStr = "FL"
1679        WAVE qTot_FL = $(folderPath+instPath+detStr+":qTot_"+detStr)
[1133]1680        WAVE mask_FL = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
1681       
[1128]1682        detStr = "FR"
1683        WAVE qTot_FR = $(folderPath+instPath+detStr+":qTot_"+detStr)
[1133]1684        WAVE mask_FR = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
[1128]1685
1686        detStr = "FT"
1687        WAVE qTot_FT = $(folderPath+instPath+detStr+":qTot_"+detStr)
[1133]1688        WAVE mask_FT = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
[1128]1689
1690        detStr = "FB"
1691        WAVE qTot_FB = $(folderPath+instPath+detStr+":qTot_"+detStr)
[1133]1692        WAVE mask_FB = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data")
[1128]1693
[1133]1694        Variable min1,min2,min3,min4
1695        Variable max1,max2,max3,max4
1696        // WaveMin(), WaveMax() will report NaN or inf
1697        // so for the min, set masked values to 1e6
1698        Duplicate/O qTot_FL tmp_FL
1699        tmp_FL = (mask_FL == 0) ? qTot_FL : 1e6
[1128]1700
[1133]1701        Duplicate/O qTot_FR tmp_FR
1702        tmp_FR = (mask_FR == 0) ? qTot_FR : 1e6
1703       
1704        Duplicate/O qTot_FT tmp_FT
1705        tmp_FT = (mask_FT == 0) ? qTot_FT : 1e6
1706       
1707        Duplicate/O qTot_FB tmp_FB
1708        tmp_FB = (mask_FB == 0) ? qTot_FB : 1e6
[1128]1709
[1133]1710        min1 = WaveMin(tmp_FL)
1711        min2 = WaveMin(tmp_FR)
1712        min3 = WaveMin(tmp_FT)
1713        min4 = WaveMin(tmp_FB)
1714       
1715        // so for the max, set masked values to -1e6
1716        tmp_FL = (mask_FL == 0) ? qTot_FL : -1e6
1717        tmp_FR = (mask_FR == 0) ? qTot_FR : -1e6
1718        tmp_FT = (mask_FT == 0) ? qTot_FT : -1e6
1719        tmp_FB = (mask_FB == 0) ? qTot_FB : -1e6
1720
1721
1722        max1 = WaveMax(tmp_FL)
1723        max2 = WaveMax(tmp_FR)
1724        max3 = WaveMax(tmp_FT)
1725        max4 = WaveMax(tmp_FB)
1726
1727//      print min1,min2,min3,min4
1728//      print max1,max2,max3,max4
1729               
1730        min_f = min(min1,min2,min3,min4)
1731        max_f = max(max1,max2,max3,max4)
1732       
1733//      min_f = min(WaveMin(tmp_FL),WaveMin(tmp_FT),WaveMin(tmp_FR),WaveMin(tmp_FB))
1734//      max_f = max(WaveMax(tmp_FL),WaveMax(tmp_FT),WaveMax(tmp_FR),WaveMax(tmp_FB))
1735
1736        KillWaves/Z tmp_FL,tmp_FR,tmp_FT,tmp_FB
[1128]1737        return(0)
1738end
1739
1740Function V_QMin_withBeamStop(detStr)
1741        String detStr
1742       
1743        NVAR val = root:Packages:NIST:VSANS:VCALC:gRealQMin
1744
1745        Variable BSDiam,SDD,two_theta,lambda,qMin
1746
1747        BSDiam = VC_beamstopDiam(detStr)
1748        SDD = VC_getSDD(detStr)
[1249]1749        SDD += VCALC_getTopBottomSDDSetback(detStr)
[1128]1750        lambda = VCALC_getWavelength()
1751       
1752        two_theta = atan(BSDiam/2/SDD)
1753        qMin = 4*pi/lambda*sin(two_theta/2)
1754               
1755        val = qMin
1756       
1757        return(0)
1758End
1759
1760
1761Function V_BeamDiamDisplay(direction, detStr)
1762        String direction
1763        String detStr
1764       
1765        NVAR val = root:Packages:NIST:VSANS:VCALC:gBeamDiam
1766
1767        val = VC_beamDiameter(direction, detStr)                //middle carriage, maximum extent, includes gravity
1768
1769        return(0)
1770End
1771
1772
1773// carrNum 1=front, 2=middle, 3=back
1774Function V_BeamStopDiamDisplay(detStr)
1775        String detStr
1776
1777        NVAR val = root:Packages:NIST:VSANS:VCALC:gBeamStopDiam
1778
1779        val = VC_beamstopDiam(detStr)/2.54              //return the value in inches
1780
1781        return(0)
1782End
1783       
1784               
1785       
Note: See TracBrowser for help on using the repository browser.