source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_PatchFiles.ipf @ 1018

Last change on this file since 1018 was 1018, checked in by srkline, 6 years ago

changes to (mostly) PatchFiles? to be more VSANS-aware, and to update the installed version to report the correct version. Apparently people actually check, and are confused when they don't match.

  • Property svn:executable set to *
File size: 41.2 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=5.0
3#pragma IgorVersion=6.1
4
5
6//////////////////////////////////
7//
8// TODO --  January 2107
9//
10// This is experimental, making the patch work with list boxes as "groups" of the Nexus file structure
11//
12// some of the groupings are more natural, some will need to be re-organized for the
13// more natural needs of what will typically be patched in the most common cases.
14//
15///////////////////////////////
16
17//
18// Updated for use with VSANS (in process)
19// -- currently very crude, and needs to be changed to accomodate the
20//   large number of parameters in the file that may/will need to be patched.
21// -- if this turns out to be too crude or too difficult to work with for what
22//   VSANS needs, I may ditch the entire procedure and start fresh
23//
24// June 2016 SRK
25//
26
27// TODOs have been inserted to comment out all of the calls that don't compile and need to be replaced
28
29// TODO
30// -- not all of the functions here have been prefixed with "V_", especially the action procedures from the panel
31//   so this cannot be opened with the SANS Reduction, or there will be clashes
32// -- same file load/reload issue as with other operations that read a field from the file. ANY read requires
33//   that the entire file is read in, even just to check and see if it's raw data... then there is a local
34//   copy present to confuse matters of what was actually written
35//
36// -- for the batch entering of fields, when all of the proper beam center values are determined, then
37//    all (2 x 9 = 18) of these values will need to be entered in all of the data files that "match" this
38//    "configuration" - however a configuration is to be defined and differentiated from other configurations.
39//
40// -- there may be other situations where batch entering needs are
41//               different, and this may lead to different interface choices
42//
43//
44
45
46//**************************
47// Vers. 1.2 092101
48//
49//procedures required to allow patching of raw SANS data headers
50//only a limited number of fields are allowable for changes, although the list could
51//be enhanced quite easily, at the expense of a larger, more complex panel
52//information for the Patch Panel is stored in the root:Packages:NIST:VSANS:Globals:Patch subfolder
53//
54// writes changes directly to the raw data headers as requested
55// * note that if a data file is currently in a work folder, the (real) header on disk
56// will be updated, but the data in the (WORK) folder will not reflect these changes, unless
57// the data folder is first cleared and the data is re-loaded
58//
59//**************************
60
61//main entry procedure for displaying the Patch Panel
62//
63Proc V_PatchFiles()
64       
65        DoWindow/F V_Patch_Panel
66        If(V_flag == 0)
67                V_InitializePatchPanel()
68                //draw panel
69                V_Patch_Panel()
70        Endif
71End
72
73//initialization of the panel, creating the necessary data folder and global
74//variables if necessary - simultaneously initialize the globals for the Trans
75//panel at this time, to make sure they all exist
76//
77// root:Packages:NIST:VSANS:Globals:
78Proc V_InitializePatchPanel()
79        //create the global variables needed to run the Patch Panel
80        //all are kept in root:Packages:NIST:VSANS:Globals:Patch
81        If( ! (DataFolderExists("root:Packages:NIST:VSANS:Globals:Patch"))  )
82                //create the data folder and the globals for BOTH the Patch and Trans panels
83                NewDataFolder/O root:Packages:NIST:VSANS:Globals:Patch
84        Endif
85        V_CreatePatchGlobals()          //re-create them every time (so text and radio buttons are correct)
86End
87
88//the data folder root:Packages:NIST:VSANS:Globals:Patch must exist
89//
90Proc V_CreatePatchGlobals()
91        //ok, create the globals
92        String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr = "*"
93        PathInfo catPathName
94        If(V_flag==1)
95                String dum = S_path
96                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = dum
97        else
98                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = "no path selected"
99        endif
100        String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = "none"
101//      String/G root:Packages:NIST:VSANS:Globals:Patch:gPS1 = "no file selected"
102//      String/G root:Packages:NIST:VSANS:Globals:Patch:gPS2 = "no file selected"
103//      String/G root:Packages:NIST:VSANS:Globals:Patch:gPS3 = "no box selected"
104//      String/G root:Packages:NIST:VSANS:Globals:Patch:gPS4 = "no file selected"
105//      String/G root:Packages:NIST:VSANS:Globals:Patch:gPS5 = "no file selected"
106//      String/G root:Packages:NIST:VSANS:Globals:Patch:gPS6 = "no file selected"
107//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV1 =0
108//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV2 = 0
109//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV3 = 0
110//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV4 = 0
111//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV5 = 0
112//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV6 = 0
113//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV7 = 0
114//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV8 = 0
115//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV9 = 0
116//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV10 = 0
117//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV11 = 0
118//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV12 = 0
119//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV13 = 0
120//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV14 = 0
121//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV15 = 0
122//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV16 = 0
123//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV17 = 0
124//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV18 = 0
125//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV19 = 0
126//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gTransCts = 0
127        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gRadioVal = 1
128       
129
130        SetDataFolder root:Packages:NIST:VSANS:Globals:Patch:   
131        Make/O/T/N=(10,3) PP_ListWave
132        Make/O/B/N=(10,3) PP_SelWave
133        Make/O/T/N=3 PP_TitleWave
134       
135        PP_TitleWave = {"Ch?","Label","Value"}
136       
137        PP_SelWave[][0] = 2^5           // checkboxes
138        PP_SelWave[][2] = 2^1           // 3rd column editable
139       
140       
141        SetDataFolder root:
142       
143End
144
145
146//panel recreation macro for the PatchPanel...
147//
148Proc V_Patch_Panel()
149        PauseUpdate; Silent 1      // building window...
150        NewPanel /W=(533,50,1140,588)/K=2 as "Patch Raw VSANS Data Files"
151        DoWindow/C V_Patch_Panel
152        ShowTools/A
153        SetDataFolder root:Packages:NIST:VSANS:Globals:Patch:
154
155       
156        ModifyPanel cbRGB=(11291,48000,3012)
157        ModifyPanel fixedSize=1
158        SetDrawLayer UserBack
159        DrawLine 7,30,422,30
160
161       
162        SetVariable PathDisplay,pos={77,7},size={310,13},title="Path"
163        SetVariable PathDisplay,help={"This is the path to the folder that will be used to find the SANS data while patching. If no files appear in the popup, make sure that this folder is set correctly"}
164        SetVariable PathDisplay,font="Courier",fSize=10
165        SetVariable PathDisplay,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr
166        Button PathButton,pos={2,3},size={70,20},proc=V_PickPathButton,title="Pick Path"
167        Button PathButton,help={"Select the folder containing the raw SANS data files"}
168        Button helpButton,pos={400,3},size={25,20},proc=V_ShowPatchHelp,title="?"
169        Button helpButton,help={"Show the help file for patching raw data headers"}
170        PopupMenu PatchPopup,pos={4,37},size={156,19},proc=V_PatchPopMenuProc,title="File(s) to Patch"
171        PopupMenu PatchPopup,help={"The displayed file is the one that will be edited. The entire list will be edited if \"Change All..\" is selected. \r If no items, or the wrong items appear, click on the popup to refresh. \r List items are selected from the file based on MatchString"}
172        PopupMenu PatchPopup,mode=1,popvalue="none",value= #"root:Packages:NIST:VSANS:Globals:Patch:gPatchList"
173//      Button SHButton,pos={324,37},size={100,20},proc=ShowHeaderButtonProc,title="Show Header"
174//      Button SHButton,help={"This will display the header of the file indicated in the popup menu."}
175        Button CHButton,pos={314,37},size={110,20},proc=V_ChangeHeaderButtonProc,title="Change Header"
176        Button CHButton,help={"This will change the checked values (ONLY) in the single file selected in the popup."}
177        SetVariable PMStr,pos={6,63},size={174,13},proc=V_SetMatchStrProc,title="Match String"
178        SetVariable PMStr,help={"Enter the search string to narrow the list of files. \"*\" is the wildcard character. After entering, \"pop\" the menu to refresh the file list."}
179        SetVariable PMStr,font="Courier",fSize=10
180        SetVariable PMStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr
181        Button ChAllButton,pos={245,60},size={180,20},proc=V_ChAllHeadersButtonProc,title="Change All Headers in List"
182        Button ChAllButton,help={"This will change the checked values (ONLY) in ALL of the files in the popup list, not just the top file. If the \"change\" checkbox for the item is not checked, nothing will be changed for that item."}
183        Button DoneButton,pos={314,85},size={110,20},proc=V_DoneButtonProc,title="Done Patching"
184        Button DoneButton,help={"When done Patching files, this will close this control panel."}
185        CheckBox check0,pos={18,80},size={40,15},title="Run #",value= 1,mode=1,proc=V_MatchCheckProc
186        CheckBox check1,pos={78,80},size={40,15},title="Text",value= 0,mode=1,proc=V_MatchCheckProc
187        CheckBox check2,pos={138,80},size={40,15},title="SDD",value= 0,mode=1,proc=V_MatchCheckProc
188
189
190        TabControl PatchTab,pos={20,120},size={570,400}
191        TabControl PatchTab,tabLabel(0)="Control",tabLabel(1)="Reduction",tabLabel(2)="Sample"
192        TabControl PatchTab,tabLabel(3)="Instrument",tabLabel(4)="Detectors",tabLabel(5)="PolSANS"
193        TabControl PatchTab,value=0,labelBack=(47748,57192,54093),proc=V_PatchTabProc
194
195
196        ListBox list0,pos={30,150.00},size={550.00,350},proc=V_PatchListBoxProc,frame=1
197        ListBox list0,fSize=10,userColumnResize= 1,listWave=PP_ListWave,selWave=PP_SelWave,titleWave=PP_TitleWave
198        ListBox list0,mode=2,widths={30,200}
199
200
201// put these in a tabbed? section for the 9 different panels
202// will it be able to patch all "FL" with the proper values, then all "FR", etc. to batchwise correct files?
203//      PopupMenu popup_0,pos={30,base-step-10},size={109,20},title="Detector Panel",proc=PatchPopMenuProc
204//      PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;ML;MR;MT;MB;B;\""
205
206// TODO: add functions for these, make the intent a popup (since it's an enumerated type)
207
208//      PopupMenu popup_1,pos={42,base+14*step},size={109,20},title="File intent"
209//      PopupMenu popup_1,mode=1,popvalue="SCATTER",value= #"\"SCATTER;EMPTY;BLOCKED BEAM;TRANS;EMPTY BEAM;\""
210
211
212
213        SetDataFolder root:
214End
215
216//
217// function to control the display of the list box, based on the selection of the tab
218//
219Function V_PatchTabProc(name,tab)
220        String name
221        Variable tab
222       
223//      Print "name,number",name,tab
224        SetDataFolder root:Packages:NIST:VSANS:Globals:Patch:
225       
226        Wave/T PP_listWave = PP_ListWave
227        Wave PP_selWave = PP_selWave
228       
229        //clear the listWave and SelWave
230        PP_ListWave = ""
231        PP_SelWave = 0
232       
233        Variable nRows=1
234        // switch based on the tab number
235        switch(tab)     
236                case 0:
237                        //Print "tab 0"
238                       
239                        V_FillListBox0(PP_ListWave,PP_SelWave)
240                        break           
241                case 1:
242                        //Print "tab 1"
243                       
244                        V_FillListBox1(PP_ListWave,PP_SelWave)
245                        break
246                case 2:
247                        //Print "tab 2"
248                       
249                        V_FillListBox2(PP_ListWave,PP_SelWave)
250                        break
251                case 3:
252                        //Print "tab 3"
253                       
254                        V_FillListBox3(PP_ListWave,PP_SelWave)
255                        break
256                case 4:
257                        //Print "tab 4"
258                       
259                        V_FillListBox4(PP_ListWave,PP_SelWave)
260                        break
261                case 5:
262                        //Print "tab 5"
263
264                        V_FillListBox5(PP_ListWave,PP_SelWave)
265                        break
266                default:                        // optional default expression executed
267                        SetDataFolder root:
268                        Abort "No tab found -- PatchTabProc"            // when no case matches
269        endswitch
270
271
272        SetDataFolder root:
273        return(0)
274End
275
276// fill list boxes based on the tab
277//
278// CONTROL
279//
280Function V_FillListBox0(listWave,selWave)
281        Wave/T listWave
282        Wave selWave
283       
284        // trust that I'm getting a valid raw data file name from the popup
285        String fname
286        ControlInfo/W=V_Patch_Panel PatchPopup
287        If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0)
288                Abort "no file selected in popup menu"          //null selection
289        else
290                fname = S_value                         //selection not null
291        Endif
292        //prepend path for read routine
293        PathInfo catPathName
294        fname = S_path + fname
295
296        Variable nRows = 3
297        Redimension/N=(nRows,3) ListWave
298        Redimension/N=(nRows,3) selWave
299        // clear the contents
300        listWave = ""
301        selWave = 0
302        SelWave[][0] = 2^5              // checkboxes
303        SelWave[][2] = 2^1              // 3rd column editable
304       
305       
306       
307        listWave[0][1] = "count_time"
308        listWave[0][2] = num2str(V_getCount_time(fname))
309       
310        listWave[1][1] = "detector_counts"
311        listWave[1][2] = num2str(V_getDetector_counts(fname))
312       
313        listWave[2][1] = "monitor_counts"
314        listWave[2][2] = num2str(V_getMonitorCount(fname))
315       
316        return(0)
317End
318
319// fill list boxes based on the tab
320//
321// Reduction items
322//
323Function V_FillListBox1(listWave,selWave)
324        Wave/T listWave
325        Wave selWave
326
327        // trust that I'm getting a valid raw data file name from the popup
328        String fname
329        ControlInfo/W=V_Patch_Panel PatchPopup
330        If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0)
331                Abort "no file selected in popup menu"          //null selection
332        else
333                fname = S_value                         //selection not null
334        Endif
335        //prepend path for read routine
336        PathInfo catPathName
337        fname = S_path + fname
338
339        Variable nRows = 13
340        Redimension/N=(nRows,3) ListWave
341        Redimension/N=(nRows,3) selWave
342        // clear the contents
343        listWave = ""
344        selWave = 0
345        SelWave[][0] = 2^5              // checkboxes
346        SelWave[][2] = 2^1              // 3rd column editable
347       
348       
349        listWave[0][1] = "empty_beam_file_name"
350        listWave[0][2] = V_getEmptyBeamFileName(fname)
351       
352        listWave[1][1] = "background_file_name"
353        listWave[1][2] = V_getBackgroundFileName(fname)
354       
355        listWave[2][1] = "empty_file_name"
356        listWave[2][2] = V_getEmptyFileName(fname)
357       
358        listWave[3][1] = "sensitivity_file_name"
359        listWave[3][2] = V_getSensitivityFileName(fname)
360       
361        listWave[4][1] = "mask_file_name"
362        listWave[4][2] = V_getMaskFileName(fname)
363       
364        listWave[5][1] = "transmission_file_name"
365        listWave[5][2] = V_getTransmissionFileName(fname)
366       
367        listWave[6][1] = "intent"
368        listWave[6][2] = V_getReduction_intent(fname)
369       
370        listWave[7][1] = "file_purpose (polSANS)"
371        listWave[7][2] = V_getReduction_polSANSPurpose(fname)
372       
373        listWave[8][1] = "group_id (sample)"
374        listWave[8][2] = num2str(V_getSample_group_ID(fname))
375
376        listWave[9][1] = "box_count"
377        listWave[9][2] = num2str(V_getBoxCounts(fname))
378       
379        listWave[10][1] = "box_count_error"
380        listWave[10][2] = num2str(V_getBoxCountsError(fname))
381       
382        listWave[11][1] = "whole_trans"
383        listWave[11][2] = num2str(V_getSampleTransWholeDetector(fname))
384       
385        listWave[12][1] = "whole_trans_error"
386        listWave[12][2] = num2str(V_getSampleTransWholeDetErr(fname))
387       
388       
389               
390       
391
392        return(0)
393End
394
395// fill list boxes based on the tab
396//
397// SAMPLE
398//
399Function V_FillListBox2(listWave,selWave)
400        Wave/T listWave
401        Wave selWave
402       
403        // trust that I'm getting a valid raw data file name from the popup
404        String fname
405        ControlInfo/W=V_Patch_Panel PatchPopup
406        If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0)
407                Abort "no file selected in popup menu"          //null selection
408        else
409                fname = S_value                         //selection not null
410        Endif
411        //prepend path for read routine
412        PathInfo catPathName
413        fname = S_path + fname
414
415        Variable nRows = 4
416        Redimension/N=(nRows,3) ListWave
417        Redimension/N=(nRows,3) selWave
418        // clear the contents
419        listWave = ""
420        selWave = 0
421        SelWave[][0] = 2^5              // checkboxes
422        SelWave[][2] = 2^1              // 3rd column editable
423       
424       
425        listWave[0][1] = "description"
426        listWave[0][2] = V_getSampleDescription(fname)
427       
428        listWave[1][1] = "thickness"
429        listWave[1][2] = num2str(V_getSampleThickness(fname))
430       
431        listWave[2][1] = "transmission"
432        listWave[2][2] = num2str(V_getSampleTransmission(fname))
433       
434        listWave[3][1] = "transmission_error"
435        listWave[3][2] = num2str(V_getSampleTransError(fname))
436       
437
438
439        return(0)
440End
441
442// fill list boxes based on the tab
443//
444// INSTRUMENT
445//
446Function V_FillListBox3(listWave,selWave)
447        Wave/T listWave
448        Wave selWave
449       
450        // trust that I'm getting a valid raw data file name from the popup
451        String fname
452        ControlInfo/W=V_Patch_Panel PatchPopup
453        If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0)
454                Abort "no file selected in popup menu"          //null selection
455        else
456                fname = S_value                         //selection not null
457        Endif
458        //prepend path for read routine
459        PathInfo catPathName
460        fname = S_path + fname
461
462        Variable nRows = 6
463        Redimension/N=(nRows,3) ListWave
464        Redimension/N=(nRows,3) selWave
465        // clear the contents
466        listWave = ""
467        selWave = 0
468        SelWave[][0] = 2^5              // checkboxes
469        SelWave[][2] = 2^1              // 3rd column editable
470       
471       
472        listWave[0][1] = "attenuator_transmission"
473        listWave[0][2] = num2str(V_getAttenuator_transmission(fname))   
474       
475        listWave[1][1] = "attenuator_transmission_error"
476        listWave[1][2] = num2str(V_getAttenuator_trans_err(fname))     
477
478        listWave[2][1] = "monochromator type"
479        listWave[2][2] = V_getMonochromatorType(fname)
480       
481        listWave[3][1] = "wavelength"
482        listWave[3][2] = num2str(V_getWavelength(fname))       
483       
484        listWave[4][1] = "wavelength_spread"
485        listWave[4][2] = num2str(V_getWavelength_spread(fname))
486
487        listWave[5][1] = "distance (source aperture)"
488        listWave[5][2] = num2str(V_getSourceAp_distance(fname))         
489               
490        return(0)
491End
492
493
494// fill list boxes based on the tab
495//
496// DETECTORS
497//
498Function V_FillListBox4(listWave,selWave)
499        Wave/T listWave
500        Wave selWave
501       
502        // trust that I'm getting a valid raw data file name from the popup
503        String fname
504        ControlInfo/W=V_Patch_Panel PatchPopup
505        If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0)
506                Abort "no file selected in popup menu"          //null selection
507        else
508                fname = S_value                         //selection not null
509        Endif
510        //prepend path for read routine
511        PathInfo catPathName
512        fname = S_path + fname
513
514        Variable nRows = 3
515        Redimension/N=(nRows,3) ListWave
516        Redimension/N=(nRows,3) selWave
517        // clear the contents
518        listWave = ""
519        selWave = 0
520        SelWave[][0] = 2^5              // checkboxes
521        SelWave[][2] = 2^1              // 3rd column editable
522       
523       
524        listWave[0][1] = "count_time"
525        listWave[0][2] = num2str(V_getCount_time(fname))       
526
527        return(0)
528End
529
530
531// fill list boxes based on the tab
532//
533// PolSANS
534//
535Function V_FillListBox5(listWave,selWave)
536        Wave/T listWave
537        Wave selWave
538       
539        // trust that I'm getting a valid raw data file name from the popup
540        String fname
541        ControlInfo/W=V_Patch_Panel PatchPopup
542        If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0)
543                Abort "no file selected in popup menu"          //null selection
544        else
545                fname = S_value                         //selection not null
546        Endif
547        //prepend path for read routine
548        PathInfo catPathName
549        fname = S_path + fname
550
551        Variable nRows = 3
552        Redimension/N=(nRows,3) ListWave
553        Redimension/N=(nRows,3) selWave
554        // clear the contents
555        listWave = ""
556        selWave = 0
557        SelWave[][0] = 2^5              // checkboxes
558        SelWave[][2] = 2^1              // 3rd column editable
559       
560       
561        listWave[0][1] = "count_time"
562        listWave[0][2] = num2str(V_getCount_time(fname))       
563
564        return(0)
565End
566
567
568// TODO - determine if I really need this --- I don't
569//  think I really have any reason to respond to events from list box actions
570// or edits. the final action of patching is done with the button
571//
572Function V_PatchListBoxProc(lba) : ListBoxControl
573        STRUCT WMListboxAction &lba
574
575        Variable row = lba.row
576        Variable col = lba.col
577        WAVE/T/Z listWave = lba.listWave
578        WAVE/Z selWave = lba.selWave
579
580        switch( lba.eventCode )
581                case -1: // control being killed
582                        break
583                case 1: // mouse down
584                        break
585                case 3: // double click
586                        break
587                case 4: // cell selection
588                case 5: // cell selection plus shift key
589                        break
590                case 6: // begin edit
591                        break
592                case 7: // finish edit
593                        break
594                case 13: // checkbox clicked (Igor 6.2 or later)
595                        break
596        endswitch
597
598        return 0
599End
600
601
602
603
604
605
606//button action procedure to select the local path to the folder that
607//contains the SANS data
608//sets catPathName, updates the path display and the popup of files (in that folder)
609//
610Function V_PickPathButton(PathButton) : ButtonControl
611        String PathButton
612       
613        //set the global string to the selected pathname
614        V_PickPath()
615        //set a local copy of the path for Patch
616        PathInfo/S catPathName
617        String dum = S_path
618        if (V_flag == 0)
619                //path does not exist - no folder selected
620                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = "no folder selected"
621        else
622                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = dum
623        endif
624       
625        //Update the pathStr variable box
626        ControlUpdate/W=V_Patch_Panel $"PathDisplay"
627       
628        //then update the popup list
629        // (don't update the list - not until someone enters a search critera) -- Jul09
630        //
631        V_SetMatchStrProc("",0,"*","")          //this is equivalent to finding everything, typical startup case
632
633End
634
635
636//returns a list of valid files (raw data, no version numbers, no averaged files)
637//that is semicolon delimited, and is suitable for display in a popup menu
638//
639Function/S xGetValidPatchPopupList()
640
641        //make sure that path exists
642        PathInfo catPathName
643        String path = S_path
644        if (V_flag == 0)
645                Abort "folder path does not exist - use Pick Path button"
646        Endif
647       
648        String newList = ""
649
650        newList = V_GetRawDataFileList()
651
652        //trim list to include only selected files
653        SVAR match = root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr
654        if(strlen(match) == 0)          //if nothing is entered for a match string, return everything, rather than nothing
655                match = "*"
656        endif
657
658        newlist = V_MyMatchList(match,newlist,";")
659       
660        newList = SortList(newList,";",0)
661        Return(newList)
662End
663
664//returns a list of valid files (raw data, no version numbers, no averaged files)
665//that is semicolon delimited, and is suitable for display in a popup menu
666//
667// Uses Grep to look through the any text in the file, which includes the sample label
668// can be very slow across the network, as it re-pops the menu on a selection (since some folks don't hit
669// enter when inputing a filter string)
670//
671// - or -
672// a list or range of run numbers
673// - or -
674// a SDD (to within 0.001m)
675// - or -
676// * to get everything
677//
678//      NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal
679 // 1== Run # (comma range OK)
680 // 2== Grep the text (SLOW)
681 // 3== filter by SDD (within 0.001 m)
682Function/S V_GetValidPatchPopupList()
683
684        //make sure that path exists
685        PathInfo catPathName
686        String path = S_path
687        if (V_flag == 0)
688                Abort "folder path does not exist - use Pick Path button"
689        Endif
690       
691        String newList = ""
692
693        newList = V_GetRawDataFileList()
694
695        //trim list to include only selected files
696        SVAR match = root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr
697        if(strlen(match) == 0 || cmpstr(match,"*")==0)          //if nothing or "*" entered for a match string, return everything, rather than nothing
698                match = "*"
699        // old way, with simply a wildcard
700                newlist = V_MyMatchList(match,newlist,";")
701                newList = SortList(newList,";",0)
702                return(newList)
703        endif
704       
705        //loop through all of the files as needed
706
707       
708        String list="",item="",fname,runList="",numStr=""
709        Variable ii,num=ItemsInList(newList),val,sdd
710        NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal
711       
712        // run number list
713        if(gRadioVal == 1)
714                       
715                list = V_ExpandNumRanges(match)         //now simply comma delimited
716                num=ItemsInList(list,",")
717                for(ii=0;ii<num;ii+=1)
718                        item = StringFromList(ii,list,",")
719                        val=str2num(item)
720
721                        runList += V_GetFileNameFromPathNoSemi(V_FindFileFromRunNumber(val)) + ";"             
722                endfor
723                newlist = runList
724               
725        endif
726       
727        //grep through what text I can find in the VAX binary
728        // Grep Note: the \\b sequences limit matches to a word boundary before and after
729        // "boondoggle", so "boondoggles" and "aboondoggle" won't match.
730        if(gRadioVal == 2)
731                for(ii=0;ii<num;ii+=1)
732                        item=StringFromList(ii, newList , ";")
733//                      Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item
734                        Grep/P=catPathName/Q/E=("(?i)"+match) item
735                        if( V_value )   // at least one instance was found
736//                              Print "found ", item,ii
737                                list += item + ";"
738                        endif
739                endfor
740
741                newList = list
742        endif
743       
744        // SDD
745        Variable pos
746        String SDDStr=""
747        if(gRadioVal == 3)
748                pos = strsearch(match, "*", 0)
749                if(pos == -1)           //no wildcard
750                        val = str2num(match)
751                else
752                        val = str2num(match[0,pos-1])
753                endif
754               
755//              print val
756                for(ii=0;ii<num;ii+=1)
757                        item=StringFromList(ii, newList , ";")
758                        fname = path + item
759// TODO -- replace call -- this is hard-wired for "FL"
760                        sdd = V_getDet_ActualDistance(fname,"FL")
761                        if(pos == -1)
762                                //no wildcard
763                                if(abs(val - sdd) < 0.01        )               //if numerically within 0.01 meter, they're the same
764                                        list += item + ";"
765                                endif
766                        else
767                                //yes, wildcard, try a string match?
768                                // string match doesn't work -- 1* returns 1m and 13m data
769                                // round the value (or truncate?)
770                               
771                                //SDDStr = num2str(sdd)
772                                //if(strsearch(SDDStr,match[0,pos-1],0) != -1)
773                                //      list += item + ";"
774                                //endif
775                               
776                                if(abs(val - round(sdd)) < 0.01 )               //if numerically within 0.01 meter, they're the same
777                                        list += item + ";"
778                                endif
779       
780                        endif
781                endfor
782               
783                newList = list
784        endif
785
786        newList = SortList(newList,";",0)
787        Return(newList)
788End
789
790
791
792
793// -- no longer refreshes the list - this seems redundant, and can be slow if grepping
794//
795//updates the popup list when the menu is "popped" so the list is
796//always fresh, then automatically displays the header of the popped file
797//value of match string is used in the creation of the list - use * to get
798//all valid files
799//
800Function V_PatchPopMenuProc(PatchPopup,popNum,popStr) : PopupMenuControl
801        String PatchPopup
802        Variable popNum
803        String popStr
804
805        //change the contents of gPatchList that is displayed
806        //based on selected Path, match str, and
807        //further trim list to include only RAW SANS files
808       
809//      String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = list
810//      ControlUpdate PatchPopup
811        V_ShowHeaderButtonProc("SHButton")
812End
813
814//when text is entered in the match string, the popup list is refined to
815//include only the selected files, useful for trimming a lengthy list, or selecting
816//a range of files to patch
817//only one wildcard (*) is allowed
818//
819Function V_SetMatchStrProc(ctrlName,varNum,varStr,varName) : SetVariableControl
820        String ctrlName
821        Variable varNum
822        String varStr
823        String varName
824
825        //change the contents of gPatchList that is displayed
826        //based on selected Path, match str, and
827        //further trim list to include only RAW SANS files
828        //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be patched)
829       
830        String list = V_GetValidPatchPopupList()
831       
832        String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = list
833        ControlUpdate PatchPopup
834        PopupMenu PatchPopup,mode=1
835       
836        if(strlen(list) > 0)
837                V_ShowHeaderButtonProc("SHButton")
838        endif
839End
840
841
842//displays the header of the selected file (top in the popup) when the button is clicked
843//sort of a redundant button, since the procedure is automatically called (as if it were
844//clicked) when a new file is chosen from the popup
845//
846// TODO - make sure this is tab-aware
847//
848Function V_ShowHeaderButtonProc(SHButton) : ButtonControl
849        String SHButton
850
851        //displays (editable) header information about current file in popup control
852        //putting the values in the SetVariable displays (resetting the global variables)
853       
854        //get the popup string
855        String partialName, tempName
856        Variable ok
857        ControlInfo/W=V_Patch_Panel PatchPopup
858        If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0)
859                //null selection
860                Abort "no file selected in popup menu"
861        else
862                //selection not null
863                partialName = S_value
864                //Print partialName
865        Endif
866        //get a valid file based on this partialName and catPathName
867        tempName = V_FindValidFilename(partialName)
868       
869        //prepend path to tempName for read routine
870        PathInfo catPathName
871        tempName = S_path + tempName
872       
873        //make sure the file is really a RAW data file
874        ok = V_CheckIfRawData(tempName)                 //--- This loads the whole file to read the instrument string
875        if (!ok)
876                Abort "this file is not recognized as a RAW SANS data file"
877        Endif
878       
879        //Print tempName
880       
881        V_ReadHeaderForPatch(tempName)
882       
883        ControlUpdate/A/W=V_Patch_Panel
884       
885End
886
887
888
889//simple function to get the string value from the popup list of filenames
890//returned string is only the text in the popup, a partial name with no path
891//or VAX version number.
892//
893Function/S V_GetPatchPopupString()
894
895        String str=""
896       
897        ControlInfo patchPopup
898        If(cmpstr(S_value,"")==0)
899                //null selection
900                Abort "no file selected in popup menu"
901        else
902                //selection not null
903                str = S_value
904                //Print str
905        Endif
906       
907        Return str
908End
909
910//Changes (writes to disk!) the specified changes to the (single) file selected in the popup
911//reads the checkboxes to determine which (if any) values need to be written
912//
913// This currently makes sure the name is valid,
914// determines the active tab,
915// and dispatches to the correct (numbered) writer
916//
917Function V_ChangeHeaderButtonProc(CHButton) : ButtonControl
918        String CHButton
919
920        String partialName="", tempName = ""
921        Variable ok
922        //get the popup string
923        partialName = V_GetPatchPopupString()
924       
925        //get a valid file based on this partialName and catPathName
926        tempName = V_FindValidFilename(partialName)
927       
928        //prepend path to tempName for read routine
929        PathInfo catPathName
930        tempName = S_path + tempName
931       
932        //make sure the file is really a RAW data file
933        ok = V_CheckIfRawData(tempName)
934        if (!ok)
935                Abort "this file is not recognized as a RAW SANS data file"
936        Endif
937       
938        // which tab is active?
939        ControlInfo/W=V_Patch_Panel PatchTab
940       
941        switch(V_Value) // numeric switch
942                case 0: // execute if case matches expression
943                        V_WriteHeaderForPatch_0(tempName)
944                        break           // exit from switch
945                case 1:
946                        V_WriteHeaderForPatch_1(tempName)
947                        break
948                case 2:
949                        V_WriteHeaderForPatch_2(tempName)
950                        break
951                case 3:
952                        V_WriteHeaderForPatch_3(tempName)
953                        break
954                case 4:
955                        V_WriteHeaderForPatch_4(tempName)
956                        break
957                case 5:
958                        V_WriteHeaderForPatch_5(tempName)
959                        break
960                default:                        // optional default expression executed
961                        Abort "Tab not found - V_ChangeHeaderButtonProc"
962        endswitch
963
964       
965        //after writing the changes to the file
966        // clean up, to force a reload from disk
967        V_CleanupData_w_Progress(0,1)
968       
969        return(0)
970End
971
972//     
973//*****this function actually writes the data to disk*****
974//
975// TODO - re-write a series of these function to mirror the "fill" functions
976//   specific to each tab
977//
978// TODO x- clear out the old data and force a re-load from disk, or the old data
979//    will be read in from the RawVSANS folder, and it will look like nothing was written
980//                      (done in the calling function)
981//
982// currently, all errors are printed out by the writer, but ignored here
983//
984Function V_WriteHeaderForPatch_0(fname)
985        String fname
986       
987        Variable val,err
988        String textstr
989               
990        Wave/T listWave = root:Packages:NIST:VSANS:Globals:Patch:PP_ListWave
991        Wave selWave = root:Packages:NIST:VSANS:Globals:Patch:PP_selWave
992
993        // test bit 4 to see if the checkbox is selected
994        if ((selWave[0][0] & 2^4) != 0)         // Test if bit 4 is set
995                val = str2num(listWave[0][2])
996                err = V_writeCount_time(fname,val)              // count_time
997        endif
998
999        if ((selWave[1][0] & 2^4) != 0)         // "detector_counts"
1000                val = str2num(listWave[1][2])
1001                err = V_writeDetector_counts(fname,val)
1002        endif   
1003       
1004        if ((selWave[2][0] & 2^4) != 0)         //"monitor_counts"
1005                val = str2num(listWave[2][2])
1006                err = V_writeMonitorCount(fname,val)
1007        endif   
1008       
1009
1010//
1011//      ControlInfo checkPS1            //change the sample label ?
1012//      if(V_Value == 1)
1013//              SVAR gPS1 = root:Packages:NIST:VSANS:Globals:Patch:gPS1
1014//              V_writeSampleDescription(fname,gPS1)
1015//      endif
1016//     
1017//      ControlInfo checkPV1
1018//      if(V_Value == 1)                //sample transmission
1019//              ControlInfo PV1
1020//              V_writeSampleTransmission(fname,V_value)
1021//      Endif
1022//     
1023//      ControlInfo checkPV2
1024//      if(V_Value == 1)                //sample thickness
1025//              ControlInfo PV2
1026//              V_writeSampleThickness(fname,V_Value)
1027//      Endif
1028//     
1029//      ControlInfo checkPV5
1030//      if(V_Value == 1)                //attenuator number
1031//              ControlInfo PV5
1032//              V_writeAttenThickness(fname,V_value)
1033//      Endif
1034//
1035//      ControlInfo checkPV6            // count time
1036//      if(V_Value == 1)
1037//              ControlInfo PV6
1038//              V_writeCount_time(fname,V_Value)
1039//      Endif
1040//
1041//      ControlInfo checkPV7   
1042//      if(V_Value == 1)    //monitor count
1043//              ControlInfo PV7
1044//              V_writeMonitorCount(fname,V_Value)
1045//      Endif
1046//
1047//      ControlInfo checkPV10   
1048//      if(V_Value == 1)      //wavelength
1049//              ControlInfo PV10
1050//              V_writeWavelength(fname,V_Value)
1051//      Endif
1052//
1053//      ControlInfo checkPV11           
1054//      if(V_Value == 1)      //wavelength spread
1055//              ControlInfo PV11
1056//              V_writeWavelength_spread(fname,V_Value)
1057//      Endif   
1058//
1059//      ControlInfo checkPV14           
1060//      if(V_Value == 1)      //source aperture
1061//              ControlInfo PV14
1062//              textStr = num2str(V_Value)
1063//              V_writeSourceAp_size(fname,textStr)             //this is expecting a string
1064//      Endif
1065//     
1066//      ControlInfo checkPV15           
1067//      if(V_Value == 1)      //sample aperture
1068//              ControlInfo PV15
1069//              V_writeSampleAp2_size(fname,V_Value)            //TODO -- not sure if this is correct call
1070//      Endif
1071//
1072//      ControlInfo checkPV16
1073//      if(V_Value == 1)      //source-sam dist
1074//              ControlInfo PV16
1075//// TODO -- replace call
1076////            WriteSrcToSamDistToHeader(fname,num)
1077//      Endif
1078//
1079//      ControlInfo checkPV18
1080//      if(V_Value == 1)      //beamstop diam
1081//              ControlInfo PV18
1082//              V_writeBeamStopC2_size(fname,V_Value)                   //TODO depends on which det carriage I'm working with (2) or (3)
1083//      Endif   
1084//
1085//      ControlInfo checkPS2            //change the DIV file name?
1086//      if(V_Value == 1)
1087//              SVAR gPS2 = root:Packages:NIST:VSANS:Globals:Patch:gPS2
1088//              V_writeSensitivityFileName(fname,gPS2)
1089//      endif   
1090//     
1091//      ControlInfo checkPS3            //change the sample intent?
1092//      if(V_Value == 1)
1093//              SVAR gPS3 = root:Packages:NIST:VSANS:Globals:Patch:gPS3
1094//              V_writeReductionIntent(fname,gPS3)
1095//      endif   
1096//
1097//     
1098//// individual detector values
1099//      ControlInfo checkPV3
1100//      if(V_Value == 1)                //pixel X
1101//              ControlInfo PV3
1102//              V_writeDet_beam_center_x(fname,detStr,V_Value) 
1103//      Endif
1104//     
1105//      ControlInfo checkPV4
1106//      if(V_Value == 1)                // pixel Y
1107//              ControlInfo PV4
1108//              V_writeDet_beam_center_y(fname,detStr,V_Value) 
1109//      Endif
1110//     
1111//      ControlInfo checkPV17
1112//      if(V_Value == 1)      //det offset
1113//              ControlInfo PV17
1114//              V_writeDet_LateralOffset(fname,detStr,V_Value)          // TODO lateral or vertical offset, based on detStr
1115//      Endif
1116//
1117//      ControlInfo checkPV19
1118//      if(V_Value == 1)     //SDD
1119//              ControlInfo PV19
1120//              V_writeDet_distance(fname,detStr,V_Value)       
1121//      Endif
1122//
1123//      ControlInfo checkPV8   
1124//      if(V_Value == 1)     //total detector count
1125//              ControlInfo PV8
1126//              V_writeDet_IntegratedCount(fname,detStr,V_value)               
1127//      Endif
1128
1129
1130        Return(0)
1131End
1132
1133//
1134// tab 1
1135//
1136Function V_WriteHeaderForPatch_1(fname)
1137        String fname
1138
1139        Variable val,err
1140        String str
1141               
1142        Wave/T listWave = root:Packages:NIST:VSANS:Globals:Patch:PP_ListWave
1143        Wave selWave = root:Packages:NIST:VSANS:Globals:Patch:PP_selWave
1144
1145        // test bit 4 to see if the checkbox is selected
1146        if ((selWave[0][0] & 2^4) != 0)         // Test if bit 4 is set
1147                str = listWave[0][2]                    // empty_beam_file_name
1148                err = V_writeEmptyBeamFileName(fname,str)               
1149        endif
1150
1151        if ((selWave[1][0] & 2^4) != 0)         // "background_file_name"
1152                str = listWave[1][2]
1153                err = V_writeBackgroundFileName(fname,str)
1154        endif   
1155       
1156        if ((selWave[2][0] & 2^4) != 0)         //"empty_file_name"
1157                str = listWave[2][2]
1158                err = V_writeEmptyFileName(fname,str)
1159        endif   
1160       
1161        if ((selWave[3][0] & 2^4) != 0)         //"sensitivity_file_name"
1162                str = listWave[3][2]
1163                err = V_writeSensitivityFileName(fname,str)
1164        endif   
1165       
1166        if ((selWave[4][0] & 2^4) != 0)         //"mask_file_name"
1167                str = listWave[4][2]
1168                err = V_writeMaskFileName(fname,str)
1169        endif   
1170       
1171        if ((selWave[5][0] & 2^4) != 0)         //"transmission_file_name"
1172                str = listWave[5][2]
1173                err = V_writeTransmissionFileName(fname,str)
1174        endif   
1175
1176        if ((selWave[6][0] & 2^4) != 0)         //"intent"
1177                str = listWave[6][2]
1178                err = V_writeReductionIntent(fname,str)
1179        endif   
1180       
1181        if ((selWave[7][0] & 2^4) != 0)         //"file_purpose (polSANS)"
1182                str = listWave[7][2]
1183                err = V_writePolReduction_purpose(fname,str)
1184        endif           
1185
1186        if ((selWave[8][0] & 2^4) != 0)         //"group_id (sample)"
1187                val = str2num(listWave[8][2])
1188                err = V_writeReduction_group_ID(fname,val)
1189        endif   
1190       
1191        if ((selWave[9][0] & 2^4) != 0)         //"box_count"
1192                val = str2num(listWave[9][2])
1193                err = V_writeBoxCounts(fname,val)
1194        endif   
1195       
1196        if ((selWave[10][0] & 2^4) != 0)                //"box_count_error"
1197                val = str2num(listWave[10][2])
1198                err = V_writeBoxCountsError(fname,val)
1199        endif   
1200       
1201        if ((selWave[11][0] & 2^4) != 0)                //"whole_trans"
1202                val = str2num(listWave[11][2])
1203                err = V_writeSampleTransWholeDetector(fname,val)
1204        endif   
1205       
1206        if ((selWave[12][0] & 2^4) != 0)                //"whole_trans_error"
1207                val = str2num(listWave[12][2])
1208                err = V_writeSampleTransWholeDetErr(fname,val)
1209        endif   
1210       
1211       
1212               
1213               
1214        return(0)
1215End
1216
1217// SAMPLE
1218Function V_WriteHeaderForPatch_2(fname)
1219        String fname
1220       
1221        Variable val,err
1222        String str
1223               
1224        Wave/T listWave = root:Packages:NIST:VSANS:Globals:Patch:PP_ListWave
1225        Wave selWave = root:Packages:NIST:VSANS:Globals:Patch:PP_selWave
1226
1227        // test bit 4 to see if the checkbox is selected
1228        if ((selWave[0][0] & 2^4) != 0)         // Test if bit 4 is set
1229                str = listWave[0][2]                    // "description"
1230                err = V_writeSampleDescription(fname,str)               
1231        endif
1232
1233        if ((selWave[1][0] & 2^4) != 0)         // "thickness"
1234                val = str2num(listWave[1][2])
1235                err = V_writeSampleThickness(fname,val)
1236        endif   
1237       
1238        if ((selWave[2][0] & 2^4) != 0)         //"transmission"
1239                val = str2num(listWave[2][2])
1240                err = V_writeSampleTransmission(fname,val)
1241        endif   
1242       
1243        if ((selWave[3][0] & 2^4) != 0)         //"transmission_error"
1244                val = str2num(listWave[3][2])
1245                err = V_writeSampleTransError(fname,val)
1246        endif   
1247       
1248        return(0)
1249End
1250
1251// INSTRUMENT
1252Function V_WriteHeaderForPatch_3(fname)
1253        String fname
1254
1255        Variable val,err
1256        String str
1257               
1258        Wave/T listWave = root:Packages:NIST:VSANS:Globals:Patch:PP_ListWave
1259        Wave selWave = root:Packages:NIST:VSANS:Globals:Patch:PP_selWave
1260
1261        // test bit 4 to see if the checkbox is selected
1262        if ((selWave[0][0] & 2^4) != 0)         // Test if bit 4 is set
1263                val = str2num(listWave[0][2])                   // "attenuator_transmission"
1264                err = V_writeAttenuator_transmission(fname,val)         
1265        endif
1266
1267        if ((selWave[1][0] & 2^4) != 0)         // "attenuator_transmission_error"
1268                val = str2num(listWave[1][2])
1269                err = V_writeAttenuator_trans_err(fname,val)
1270        endif   
1271       
1272        if ((selWave[2][0] & 2^4) != 0)         //"monochromator type"
1273                str = listWave[2][2]
1274                err = V_writeMonochromatorType(fname,str)
1275        endif   
1276       
1277        if ((selWave[3][0] & 2^4) != 0)         //"wavelength"
1278                val = str2num(listWave[3][2])
1279                err = V_writeWavelength(fname,val)
1280        endif   
1281
1282        if ((selWave[4][0] & 2^4) != 0)         //"wavelength_spread"
1283                val = str2num(listWave[4][2])
1284                err = V_writeWavelength_spread(fname,val)
1285        endif   
1286       
1287        if ((selWave[5][0] & 2^4) != 0)         //"distance (source aperture)"
1288                val = str2num(listWave[5][2])
1289                err = V_writeSourceAp_distance(fname,val)
1290        endif           
1291       
1292       
1293        return(0)
1294End
1295
1296// TODO -- not yet implemented
1297Function V_WriteHeaderForPatch_4(fname)
1298        String fname
1299       
1300        return(0)
1301End
1302
1303// TODO -- not yet implemented
1304Function V_WriteHeaderForPatch_5(fname)
1305        String fname
1306       
1307        return(0)
1308End
1309
1310
1311// control the display of the radio buttons
1312Function V_MatchCheckProc(name,value)
1313        String name
1314        Variable value
1315       
1316        NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal
1317       
1318        strswitch (name)
1319                case "check0":
1320                        gRadioVal= 1
1321                        break
1322                case "check1":
1323                        gRadioVal= 2
1324                        break
1325                case "check2":
1326                        gRadioVal= 3
1327                        break
1328        endswitch
1329        CheckBox check0,value= gRadioVal==1
1330        CheckBox check1,value= gRadioVal==2
1331        CheckBox check2,value= gRadioVal==3
1332        return(0)
1333End
1334
1335//This function will read only the selected values editable in the patch panel
1336//
1337// -- TODO --
1338// re-write this to be tab-aware. ShowHeaderForPatch() calls this, but does nothing
1339// to update the tab content. Figure out which function is in charge, and update the content.
1340//
1341Function V_ReadHeaderForPatch(fname)
1342        String fname
1343       
1344       
1345        // figure out which is the active tab, then let PatchTabProc fill it in
1346        ControlInfo/W=V_Patch_Panel PatchTab
1347        V_PatchTabProc("",V_Value)     
1348       
1349        Return 0
1350End
1351
1352Function V_ShowPatchHelp(ctrlName) : ButtonControl
1353        String ctrlName
1354//      DisplayHelpTopic/Z/K=1 "VSANS Data Reduction Tutorial[Patch File Headers]"
1355//      if(V_flag !=0)
1356                DoAlert 0,"The VSANS Data Reduction Tutorial Help file could not be found"
1357//      endif
1358End
1359
1360//button action procedure to change the selected information (checked values)
1361//in each file in the popup list. This will change multiple files, and as such,
1362//the user is given a chance to bail out before the whole list of files
1363//is modified
1364//useful for patching a series of runs with the same beamcenters, or transmissions
1365//
1366Function V_ChAllHeadersButtonProc(ctrlName) : ButtonControl
1367        String ctrlName
1368       
1369        String msg
1370        msg = "Do you really want to write all of these values to each data file in the popup list? "
1371        msg += "- clicking NO will leave all files unchanged"
1372        DoAlert 1,msg
1373        If(V_flag == 2)
1374                Abort "no files were changed"
1375        Endif
1376       
1377        //this will change (checked) values in ALL of the headers in the popup list
1378        SVAR list = root:Packages:NIST:VSANS:Globals:Patch:gPatchList
1379        Variable numitems,ii
1380        String partialName="", tempName = ""
1381        Variable ok
1382       
1383        numitems = ItemsInList(list,";")
1384       
1385        if(numitems == 0)
1386                Abort "no items in list for multiple patch"
1387        Endif
1388       
1389        // loop through all of the files
1390        ii=0
1391        do
1392                //get current item in the list
1393                partialName = StringFromList(ii, list, ";")
1394                   
1395                //get a valid file based on this partialName and catPathName
1396                tempName = V_FindValidFilename(partialName)
1397       
1398                //prepend path to tempName for read routine
1399                PathInfo catPathName
1400                tempName = S_path + tempName
1401       
1402                //make sure the file is really a RAW data file
1403                ok = V_CheckIfRawData(tempName)
1404                if (!ok)
1405                   Print "this file is not recognized as a RAW SANS data file = ",tempName
1406                else
1407                   //go write the changes to the file
1408                        // which tab is active?
1409                        ControlInfo/W=V_Patch_Panel PatchTab
1410                       
1411                        switch(V_Value) // numeric switch
1412                                case 0: // execute if case matches expression
1413                                        V_WriteHeaderForPatch_0(tempName)
1414                                        break           // exit from switch
1415                                case 1:
1416                                        V_WriteHeaderForPatch_1(tempName)
1417                                        break
1418                                case 2:
1419                                        V_WriteHeaderForPatch_2(tempName)
1420                                        break
1421                                case 3:
1422                                        V_WriteHeaderForPatch_3(tempName)
1423                                        break
1424                                case 4:
1425                                        V_WriteHeaderForPatch_4(tempName)
1426                                        break
1427                                case 5:
1428                                        V_WriteHeaderForPatch_5(tempName)
1429                                        break
1430                                default:                        // optional default expression executed
1431                                        Abort "Tab not found - V_ChAllHeadersButtonProc"
1432                        endswitch
1433                Endif
1434               
1435                ii+=1
1436        while(ii<numitems)
1437
1438
1439        //after writing the changes to the file
1440        // clean up, to force a reload from disk
1441        V_CleanupData_w_Progress(0,1)
1442
1443        return(0)
1444End
1445
1446
1447//simple action for button to close the panel
1448//
1449// cleans out the RawVSANS folder on closing
1450//
1451Function V_DoneButtonProc(ctrlName) : ButtonControl
1452        String ctrlName
1453
1454        DoWindow/K V_Patch_Panel
1455
1456//      V_CleanOutRawVSANS()
1457// present a progress window
1458        V_CleanupData_w_Progress(0,1)   
1459       
1460        return(0)
1461End
1462
1463
1464
Note: See TracBrowser for help on using the repository browser.