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

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

fix bugs in operation of patch panel (wrong button function) and bugs in mask draw panel where the maximum row/column allowed was not being updated.

  • Property svn:executable set to *
File size: 41.3 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// Updated for use with VSANS (in process)
8// -- currently very crude, and needs to be changed to accomodate the
9//   large number of parameters in the file that may/will need to be patched.
10// -- if this turns out to be too crude or too difficult to work with for what
11//   VSANS needs, I may ditch the entire procedure and start fresh
12//
13// June 2016 SRK
14//
15
16// TODOs have been inserted to comment out all of the calls that don't compile and need to be replaced
17
18// TODO
19// -- not all of the functions here have been prefixed with "V_", especially the action procedures from the panel
20//   so this cannot be opened with the SANS Reduction, or there will be clashes
21// -- same file load/reload issue as with other operations that read a field from the file. ANY read requires
22//   that the entire file is read in, even just to check and see if it's raw data... then there is a local
23//   copy present to confuse matters of what was actually written
24//
25// -- for the batch entering of fields, when all of the proper beam center values are determined, then
26//    all (2 x 9 = 18) of these values will need to be entered in all of the data files that "match" this
27//    "configuration" - however a configuration is to be defined and differentiated from other configurations.
28//
29// -- there may be other situations where batch entering needs are
30//               different, and this may lead to different interface choices
31//
32//
33
34
35//**************************
36// Vers. 1.2 092101
37//
38//procedures required to allow patching of raw SANS data headers
39//only a limited number of fields are allowable for changes, although the list could
40//be enhanced quite easily, at the expense of a larger, more complex panel
41//information for the Patch Panel is stored in the root:Packages:NIST:VSANS:Globals:Patch subfolder
42//
43// writes changes directly to the raw data headers as requested
44// * note that if a data file is currently in a work folder, the (real) header on disk
45// will be updated, but the data in the (WORK) folder will not reflect these changes, unless
46// the data folder is first cleared and the data is re-loaded
47//
48//**************************
49
50//main entry procedure for displaying the Patch Panel
51//
52Proc V_PatchFiles()
53       
54        DoWindow/F V_Patch_Panel
55        If(V_flag == 0)
56                V_InitializePatchPanel()
57                //draw panel
58                V_Patch_Panel()
59        Endif
60End
61
62//initialization of the panel, creating the necessary data folder and global
63//variables if necessary - simultaneously initialize the globals for the Trans
64//panel at this time, to make sure they all exist
65//
66// root:Packages:NIST:VSANS:Globals:
67Proc V_InitializePatchPanel()
68        //create the global variables needed to run the Patch Panel
69        //all are kept in root:Packages:NIST:VSANS:Globals:Patch
70        If( ! (DataFolderExists("root:Packages:NIST:VSANS:Globals:Patch"))  )
71                //create the data folder and the globals for BOTH the Patch and Trans panels
72                NewDataFolder/O root:Packages:NIST:VSANS:Globals:Patch
73        Endif
74        V_CreatePatchGlobals()          //re-create them every time (so text and radio buttons are correct)
75End
76
77//the data folder root:Packages:NIST:VSANS:Globals:Patch must exist
78//
79Proc V_CreatePatchGlobals()
80        //ok, create the globals
81        String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr = "*"
82        PathInfo catPathName
83        If(V_flag==1)
84                String dum = S_path
85                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = dum
86        else
87                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = "no path selected"
88        endif
89        String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = "none"
90        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS1 = "no file selected"
91        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS2 = "no file selected"
92        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS3 = "no box selected"
93        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS4 = "no file selected"
94        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS5 = "no file selected"
95        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS6 = "no file selected"
96        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV1 =0
97        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV2 = 0
98        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV3 = 0
99        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV4 = 0
100        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV5 = 0
101        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV6 = 0
102        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV7 = 0
103        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV8 = 0
104        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV9 = 0
105        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV10 = 0
106        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV11 = 0
107        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV12 = 0
108        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV13 = 0
109        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV14 = 0
110        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV15 = 0
111        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV16 = 0
112        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV17 = 0
113        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV18 = 0
114        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV19 = 0
115        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gTransCts = 0
116        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gRadioVal = 1
117End
118
119//button action procedure to select the local path to the folder that
120//contains the SANS data
121//sets catPathName, updates the path display and the popup of files (in that folder)
122//
123Function V_PickPathButton(PathButton) : ButtonControl
124        String PathButton
125       
126        //set the global string to the selected pathname
127        V_PickPath()
128        //set a local copy of the path for Patch
129        PathInfo/S catPathName
130        String dum = S_path
131        if (V_flag == 0)
132                //path does not exist - no folder selected
133                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = "no folder selected"
134        else
135                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = dum
136        endif
137       
138        //Update the pathStr variable box
139        ControlUpdate/W=V_Patch_Panel $"PathDisplay"
140       
141        //then update the popup list
142        // (don't update the list - not until someone enters a search critera) -- Jul09
143        //
144        SetMatchStrProc("",0,"*","")            //this is equivalent to finding everything, typical startup case
145
146End
147
148
149//returns a list of valid files (raw data, no version numbers, no averaged files)
150//that is semicolon delimited, and is suitable for display in a popup menu
151//
152Function/S xGetValidPatchPopupList()
153
154        //make sure that path exists
155        PathInfo catPathName
156        String path = S_path
157        if (V_flag == 0)
158                Abort "folder path does not exist - use Pick Path button"
159        Endif
160       
161        String newList = ""
162
163        newList = V_GetRawDataFileList()
164
165        //trim list to include only selected files
166        SVAR match = root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr
167        if(strlen(match) == 0)          //if nothing is entered for a match string, return everything, rather than nothing
168                match = "*"
169        endif
170
171        newlist = V_MyMatchList(match,newlist,";")
172       
173        newList = SortList(newList,";",0)
174        Return(newList)
175End
176
177//returns a list of valid files (raw data, no version numbers, no averaged files)
178//that is semicolon delimited, and is suitable for display in a popup menu
179//
180// Uses Grep to look through the any text in the file, which includes the sample label
181// can be very slow across the network, as it re-pops the menu on a selection (since some folks don't hit
182// enter when inputing a filter string)
183//
184// - or -
185// a list or range of run numbers
186// - or -
187// a SDD (to within 0.001m)
188// - or -
189// * to get everything
190//
191//      NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal
192 // 1== Run # (comma range OK)
193 // 2== Grep the text (SLOW)
194 // 3== filter by SDD (within 0.001 m)
195Function/S GetValidPatchPopupList()
196
197        //make sure that path exists
198        PathInfo catPathName
199        String path = S_path
200        if (V_flag == 0)
201                Abort "folder path does not exist - use Pick Path button"
202        Endif
203       
204        String newList = ""
205
206        newList = V_GetRawDataFileList()
207
208        //trim list to include only selected files
209        SVAR match = root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr
210        if(strlen(match) == 0 || cmpstr(match,"*")==0)          //if nothing or "*" entered for a match string, return everything, rather than nothing
211                match = "*"
212        // old way, with simply a wildcard
213                newlist = V_MyMatchList(match,newlist,";")
214                newList = SortList(newList,";",0)
215                return(newList)
216        endif
217       
218        //loop through all of the files as needed
219
220       
221        String list="",item="",fname,runList="",numStr=""
222        Variable ii,num=ItemsInList(newList),val,sdd
223        NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal
224       
225        // run number list
226        if(gRadioVal == 1)
227                       
228                list = V_ExpandNumRanges(match)         //now simply comma delimited
229                num=ItemsInList(list,",")
230                for(ii=0;ii<num;ii+=1)
231                        item = StringFromList(ii,list,",")
232                        val=str2num(item)
233
234                        runList += V_GetFileNameFromPathNoSemi(V_FindFileFromRunNumber(val)) + ";"             
235                endfor
236                newlist = runList
237               
238        endif
239       
240        //grep through what text I can find in the VAX binary
241        // Grep Note: the \\b sequences limit matches to a word boundary before and after
242        // "boondoggle", so "boondoggles" and "aboondoggle" won't match.
243        if(gRadioVal == 2)
244                for(ii=0;ii<num;ii+=1)
245                        item=StringFromList(ii, newList , ";")
246//                      Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item
247                        Grep/P=catPathName/Q/E=("(?i)"+match) item
248                        if( V_value )   // at least one instance was found
249//                              Print "found ", item,ii
250                                list += item + ";"
251                        endif
252                endfor
253
254                newList = list
255        endif
256       
257        // SDD
258        Variable pos
259        String SDDStr=""
260        if(gRadioVal == 3)
261                pos = strsearch(match, "*", 0)
262                if(pos == -1)           //no wildcard
263                        val = str2num(match)
264                else
265                        val = str2num(match[0,pos-1])
266                endif
267               
268//              print val
269                for(ii=0;ii<num;ii+=1)
270                        item=StringFromList(ii, newList , ";")
271                        fname = path + item
272// TODO -- replace call -- this is hard-wired for "FL"
273                        sdd = V_getDet_ActualDistance(fname,"FL")
274                        if(pos == -1)
275                                //no wildcard
276                                if(abs(val - sdd) < 0.01        )               //if numerically within 0.01 meter, they're the same
277                                        list += item + ";"
278                                endif
279                        else
280                                //yes, wildcard, try a string match?
281                                // string match doesn't work -- 1* returns 1m and 13m data
282                                // round the value (or truncate?)
283                               
284                                //SDDStr = num2str(sdd)
285                                //if(strsearch(SDDStr,match[0,pos-1],0) != -1)
286                                //      list += item + ";"
287                                //endif
288                               
289                                if(abs(val - round(sdd)) < 0.01 )               //if numerically within 0.01 meter, they're the same
290                                        list += item + ";"
291                                endif
292       
293                        endif
294                endfor
295               
296                newList = list
297        endif
298
299        newList = SortList(newList,";",0)
300        Return(newList)
301End
302
303
304
305
306// -- no longer refreshes the list - this seems redundant, and can be slow if grepping
307//
308//updates the popup list when the menu is "popped" so the list is
309//always fresh, then automatically displays the header of the popped file
310//value of match string is used in the creation of the list - use * to get
311//all valid files
312//
313Function PatchPopMenuProc(PatchPopup,popNum,popStr) : PopupMenuControl
314        String PatchPopup
315        Variable popNum
316        String popStr
317
318        //change the contents of gPatchList that is displayed
319        //based on selected Path, match str, and
320        //further trim list to include only RAW SANS files
321        //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be patched)
322
323//      String list = GetValidPatchPopupList()
324       
325//      String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = list
326//      ControlUpdate PatchPopup
327        ShowHeaderButtonProc("SHButton")
328End
329
330//when text is entered in the match string, the popup list is refined to
331//include only the selected files, useful for trimming a lengthy list, or selecting
332//a range of files to patch
333//only one wildcard (*) is allowed
334//
335Function SetMatchStrProc(ctrlName,varNum,varStr,varName) : SetVariableControl
336        String ctrlName
337        Variable varNum
338        String varStr
339        String varName
340
341        //change the contents of gPatchList that is displayed
342        //based on selected Path, match str, and
343        //further trim list to include only RAW SANS files
344        //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be patched)
345       
346        String list = GetValidPatchPopupList()
347       
348        String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = list
349        ControlUpdate PatchPopup
350        PopupMenu PatchPopup,mode=1
351       
352        if(strlen(list) > 0)
353                ShowHeaderButtonProc("SHButton")
354        endif
355End
356
357
358//displays the header of the selected file (top in the popup) when the button is clicked
359//sort of a redundant button, since the procedure is automatically called (as if it were
360//clicked) when a new file is chosen from the popup
361//
362Function ShowHeaderButtonProc(SHButton) : ButtonControl
363        String SHButton
364
365        //displays (editable) header information about current file in popup control
366        //putting the values in the SetVariable displays (resetting the global variables)
367       
368        //get the popup string
369        String partialName, tempName
370        Variable ok
371        ControlInfo/W=V_Patch_Panel PatchPopup
372        If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0)
373                //null selection
374                Abort "no file selected in popup menu"
375        else
376                //selection not null
377                partialName = S_value
378                //Print partialName
379        Endif
380        //get a valid file based on this partialName and catPathName
381        tempName = V_FindValidFilename(partialName)
382       
383        //prepend path to tempName for read routine
384        PathInfo catPathName
385        tempName = S_path + tempName
386       
387        //make sure the file is really a RAW data file
388        ok = V_CheckIfRawData(tempName)
389        if (!ok)
390                Abort "this file is not recognized as a RAW SANS data file"
391        Endif
392       
393        //Print tempName
394       
395        ReadHeaderForPatch(tempName)
396       
397        ControlUpdate/A/W=V_Patch_Panel
398       
399End
400
401//utility function that polls the checkboxes of the editable parameters
402//returns a wave with the yes/no checked state of the boxes
403// 0 = not checked (user does NOT want this header value updated)
404// 1 = checked (YES, change this value in the header)
405//num (input) is a simple check to make sure that the wave is set up properly
406//from the calling routine
407//
408//Function GetCheckBoxesState(w,num)
409//      Wave w     //on return, this wave contains the current state of the checkboxes
410//      Variable num
411//     
412//      if(num != 20)
413//              Abort "wrong number of checkboxes GetCheckBoxesState()"
414//      Endif
415//      ControlInfo checkPS1
416//      w[0] = V_value
417//     
418//      Variable ii
419//      String baseStr="checkPV"
420//     
421//      ii=1
422//      do
423//              ControlInfo $(baseStr + num2str(ii))
424//              w[ii] = V_Value
425//              ii+=1
426//      while(ii<num)
427//      return(0)
428//End
429
430//on return, wt is a TEXT wave with the values in the SetVar boxes
431//will poll the SetVariable controls to get the new values - will get all the values,
432//and let the writing routine decide which ones it will actually use
433//num (input) is a simple check to make sure that the wave is set up properly
434//from the calling routine
435//
436//Function GetEditedSetVarBoxes(wt,num)
437//      Wave/T wt         
438//      Variable num
439//     
440//      if(num != 20)
441//              Abort "wrong number of checkboxes GetEditedSetVarBoxes()"
442//      Endif
443//     
444//      //pass all as a text wave - so only one wave has to be passed (conversion 2x, though)
445//      //global is set to the changed value when entered. read others directly from the control
446//     
447//      //make sure the text label is exactly 60 characters long, to match VAX field length
448//      SVAR dum=root:Packages:NIST:VSANS:Globals:Patch:gPS1
449//
450////    wt[0] = str60
451//      wt[0] = dum                     //with Nexus, no need to enforce 60 character field
452////   
453//      Variable ii
454//      String baseStr="PV"
455//      ii=1
456//      do
457//              ControlInfo $(baseStr + num2str(ii))
458//              wt[ii] = num2str(V_Value)
459//              ii+=1
460//      while(ii<num)
461//     
462//      return(0)       //no error
463//End
464
465
466//simple function to get the string value from the popup list of filenames
467//returned string is only the text in the popup, a partial name with no path
468//or VAX version number.
469//
470Function/S GetPatchPopupString()
471
472        String str=""
473       
474        ControlInfo patchPopup
475        If(cmpstr(S_value,"")==0)
476                //null selection
477                Abort "no file selected in popup menu"
478        else
479                //selection not null
480                str = S_value
481                //Print str
482        Endif
483       
484        Return str
485End
486
487//Changes (writes to disk!) the specified changes to the (single) file selected in the popup
488//reads the checkboxes to determine which (if any) values need to be written
489//
490Function ChangeHeaderButtonProc(CHButton) : ButtonControl
491        String CHButton
492
493        //read the (20) checkboxes to determine what changes to make
494        //The order/length of these waves are crucial!, set by nvars     
495        String partialName="", tempName = ""
496        Variable ok,nvars = 20,ii
497       
498//      Make/O/N=(nvars) tempChange
499//      Wave w=tempchange
500//      GetCheckBoxesState(w,nvars)
501        //Print "w[0] = ",w[0]
502       
503       
504//      //Get the current values in each of the fields - to pass to Write() as a textwave
505//      Make/O/T/N=(nvars) tempValues
506//      Wave/T wt=tempValues
507//      //initialize textwave
508//      ii=0
509//      do
510//              wt[ii] = ""
511//              ii+=1
512//      while(ii<nvars)
513//      GetEditedSetVarBoxes(wt,nvars)
514       
515        //get the popup string
516        partialName = GetPatchPopupString()
517       
518        //get a valid file based on this partialName and catPathName
519        tempName = V_FindValidFilename(partialName)
520       
521        //prepend path to tempName for read routine
522        PathInfo catPathName
523        tempName = S_path + tempName
524       
525        //make sure the file is really a RAW data file
526        ok = V_CheckIfRawData(tempName)
527        if (!ok)
528                Abort "this file is not recognized as a RAW SANS data file"
529        Endif
530       
531        //go write the changes to the file
532//      WriteHeaderForPatch(tempName,w,wt)
533        WriteHeaderForPatch(tempName)
534       
535        //clean up wave before leaving
536        KillWaves/Z w,wt
537       
538End
539
540
541//      ControlInfo checkPS1
542//      w[0] = V_value
543//     
544//      Variable ii
545//      String baseStr="checkPV"
546//     
547//      ii=1
548//      do
549//              ControlInfo $(baseStr + num2str(ii))
550//              w[ii] = V_Value
551//              ii+=1
552//      while(ii<num)
553       
554//*****this function actually writes the data to disk*****
555//overwrites the specific bytes the the header that are to be changed
556//real values are written out mimicking VAX format, so that can be properly
557//re-read as raw binary VAX files.
558//if any additional fields are to be edited, the exact byte location must be known
559//
560Function WriteHeaderForPatch(fname)
561        String fname
562//      Wave change
563//      Wave/T textVal
564       
565        Variable refnum,num
566        String textstr
567
568// TODO:
569// -- currently I hard-wired a detector choice. This needs to be changed (somehow), with a better interface
570//
571        ControlInfo popup_0
572        String detStr = S_value
573
574// handle strings differently
575
576        ControlInfo checkPS1            //change the sample label ?
577        if(V_Value == 1)
578                SVAR gPS1 = root:Packages:NIST:VSANS:Globals:Patch:gPS1
579                V_writeSampleDescription(fname,gPS1)
580        endif
581       
582        ControlInfo checkPV1
583        if(V_Value == 1)                //sample transmission
584                ControlInfo PV1
585                V_writeSampleTransmission(fname,V_value)
586        Endif
587       
588        ControlInfo checkPV2
589        if(V_Value == 1)                //sample thickness
590                ControlInfo PV2
591                V_writeSampleThickness(fname,V_Value)
592        Endif
593       
594        ControlInfo checkPV5
595        if(V_Value == 1)                //attenuator number
596                ControlInfo PV5
597                V_writeAttenThickness(fname,V_value)
598        Endif
599
600        ControlInfo checkPV6            // count time
601        if(V_Value == 1)
602                ControlInfo PV6
603                V_writeCount_time(fname,V_Value)
604        Endif
605
606        ControlInfo checkPV7   
607        if(V_Value == 1)    //monitor count
608                ControlInfo PV7
609                V_writeMonitorCount(fname,V_Value)
610        Endif
611
612        ControlInfo checkPV10   
613        if(V_Value == 1)      //wavelength
614                ControlInfo PV10
615                V_writeWavelength(fname,V_Value)
616        Endif
617
618        ControlInfo checkPV11           
619        if(V_Value == 1)      //wavelength spread
620                ControlInfo PV11
621                V_writeWavelength_spread(fname,V_Value)
622        Endif   
623
624        ControlInfo checkPV14           
625        if(V_Value == 1)      //source aperture
626                ControlInfo PV14
627                textStr = num2str(V_Value)
628                V_writeSourceAp_size(fname,textStr)             //this is expecting a string
629        Endif
630       
631        ControlInfo checkPV15           
632        if(V_Value == 1)      //sample aperture
633                ControlInfo PV15
634                V_writeSampleAp2_size(fname,V_Value)            //TODO -- not sure if this is correct call
635        Endif
636
637        ControlInfo checkPV16
638        if(V_Value == 1)      //source-sam dist
639                ControlInfo PV16
640// TODO -- replace call
641//              WriteSrcToSamDistToHeader(fname,num)
642        Endif
643
644        ControlInfo checkPV18
645        if(V_Value == 1)      //beamstop diam
646                ControlInfo PV18
647                V_writeBeamStopC2_size(fname,V_Value)                   //TODO depends on which det carriage I'm working with (2) or (3)
648        Endif   
649
650        ControlInfo checkPS2            //change the DIV file name?
651        if(V_Value == 1)
652                SVAR gPS2 = root:Packages:NIST:VSANS:Globals:Patch:gPS2
653                V_writeSensitivityFileName(fname,gPS2)
654        endif   
655       
656        ControlInfo checkPS3            //change the sample intent?
657        if(V_Value == 1)
658                SVAR gPS3 = root:Packages:NIST:VSANS:Globals:Patch:gPS3
659                V_writeReductionIntent(fname,gPS3)
660        endif   
661
662       
663// individual detector values   
664        ControlInfo checkPV3
665        if(V_Value == 1)                //pixel X
666                ControlInfo PV3
667                V_writeDet_beam_center_x(fname,detStr,V_Value) 
668        Endif
669       
670        ControlInfo checkPV4
671        if(V_Value == 1)                // pixel Y
672                ControlInfo PV4
673                V_writeDet_beam_center_y(fname,detStr,V_Value) 
674        Endif
675       
676        ControlInfo checkPV17
677        if(V_Value == 1)      //det offset
678                ControlInfo PV17
679                V_writeDet_LateralOffset(fname,detStr,V_Value)          // TODO lateral or vertical offset, based on detStr
680        Endif
681
682        ControlInfo checkPV19
683        if(V_Value == 1)     //SDD
684                ControlInfo PV19
685                V_writeDet_distance(fname,detStr,V_Value)       
686        Endif
687
688        ControlInfo checkPV8   
689        if(V_Value == 1)     //total detector count
690                ControlInfo PV8
691                V_writeDet_IntegratedCount(fname,detStr,V_value)               
692        Endif
693
694
695        Return(0)
696End
697
698//panel recreation macro for the PatchPanel...
699//
700Proc V_Patch_Panel()
701        PauseUpdate; Silent 1      // building window...
702        NewPanel /W=(519,85,950,688)/K=2 as "Patch Raw VSANS Data Files"
703        DoWindow/C V_Patch_Panel
704        ModifyPanel cbRGB=(11291,48000,3012)
705        ModifyPanel fixedSize=1
706        SetDrawLayer UserBack
707        SetDrawEnv fname= "Courier",fstyle= 1
708        DrawText 3,107,"Change?"
709        DrawLine 7,30,422,30
710        DrawLine 7,288,422,288
711        DrawLine 7,199,422,199
712        DrawLine 7,378+18,422,378+18
713        DrawLine 7,469+18,422,469+18
714       
715        SetVariable PathDisplay,pos={77,7},size={310,13},title="Path"
716        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"}
717        SetVariable PathDisplay,font="Courier",fSize=10
718        SetVariable PathDisplay,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr
719        Button PathButton,pos={2,3},size={70,20},proc=PickPathButton,title="Pick Path"
720        Button PathButton,help={"Select the folder containing the raw SANS data files"}
721        Button helpButton,pos={400,3},size={25,20},proc=ShowPatchHelp,title="?"
722        Button helpButton,help={"Show the help file for patching raw data headers"}
723        PopupMenu PatchPopup,pos={4,37},size={156,19},proc=PatchPopMenuProc,title="File(s) to Patch"
724        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"}
725        PopupMenu PatchPopup,mode=1,popvalue="none",value= #"root:Packages:NIST:VSANS:Globals:Patch:gPatchList"
726//      Button SHButton,pos={324,37},size={100,20},proc=ShowHeaderButtonProc,title="Show Header"
727//      Button SHButton,help={"This will display the header of the file indicated in the popup menu."}
728        Button CHButton,pos={314,37},size={110,20},proc=ChangeHeaderButtonProc,title="Change Header"
729        Button CHButton,help={"This will change the checked values (ONLY) in the single file selected in the popup."}
730        SetVariable PMStr,pos={6,63},size={174,13},proc=SetMatchStrProc,title="Match String"
731        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."}
732        SetVariable PMStr,font="Courier",fSize=10
733        SetVariable PMStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr
734        Button ChAllButton,pos={245,60},size={180,20},proc=ChAllHeadersButtonProc,title="Change All Headers in List"
735        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."}
736        Button DoneButton,pos={314,85},size={110,20},proc=DoneButtonProc,title="Done Patching"
737        Button DoneButton,help={"When done Patching files, this will close this control panel."}
738//      Button cat_short,pos={9,485},size={100,20},proc=DoCatShort,title="File Catalog"
739//      Button cat_short,help={"Use this button to generate a notebook with file header information. Very useful for identifying files."}
740        CheckBox check0,pos={18,80},size={40,15},title="Run #",value= 1,mode=1,proc=MatchCheckProc
741        CheckBox check1,pos={78,80},size={40,15},title="Text",value= 0,mode=1,proc=MatchCheckProc
742        CheckBox check2,pos={138,80},size={40,15},title="SDD",value= 0,mode=1,proc=MatchCheckProc
743
744        Variable base=111,step=18
745        SetVariable PS1,pos={42,base},size={340,13},proc=SetLabelVarProc,title="label"
746        SetVariable PS1,help={"Current sample label"},font="Courier",fSize=10
747        SetVariable PS1,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPS1
748        SetVariable PV1,pos={42,base+step},size={340,13},title="Transmission"
749        SetVariable PV1,help={"Current transmission\rvalue"},font="Courier",fSize=10
750        SetVariable PV1,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV1
751        SetVariable PV2,pos={42,base+2*step},size={340,13},title="Thickness (cm)"
752        SetVariable PV2,help={"Current sample thickness, in units of centimeters"}
753        SetVariable PV2,font="Courier",fSize=10
754        SetVariable PV2,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV2
755
756        SetVariable PV5,pos={42,base+3*step},size={340,13},title="Attenuator number"
757        SetVariable PV5,help={"attenuator number present during data collection"}
758        SetVariable PV5,font="Courier",fSize=10
759        SetVariable PV5,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV5
760        SetVariable PV6,pos={42,base+4*step},size={340,13},title="Counting time (s)",font="Courier",fSize=10
761        SetVariable PV6,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV6
762        SetVariable PV6,help={"total counting time in seconds"}
763        SetVariable PV7,pos={42,base+5*step},size={340,13},title="Monitor count",font="Courier",fSize=10
764        SetVariable PV7,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV7
765        SetVariable PV7,help={"total monitor counts"}
766
767        SetVariable PV10,pos={42,base+6*step},size={340,13},title="Wavelength (A)",font="Courier",fSize=10
768        SetVariable PV10,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV10
769        SetVariable PV10,help={"neutron wavelength in angstroms"}
770        SetVariable PV11,pos={42,base+7*step},size={340,13},title="Wavelength spread (dL/L)",font="Courier",fSize=10
771        SetVariable PV11,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV11
772        SetVariable PV11,help={"wavelength spread (delta lambda)/lambda"}
773
774        SetVariable PV14,pos={42,base+8*step},size={340,13},title="Source aperture diameter (mm)",font="Courier",fSize=10
775        SetVariable PV14,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV14
776        SetVariable PV14,help={"source aperture diameter, in millimeters"}
777        SetVariable PV15,pos={42,base+9*step},size={340,13},title="Sample aperture diameter (mm)",font="Courier",fSize=10
778        SetVariable PV15,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV15
779        SetVariable PV15,help={"sample aperture diameter, in millimeters"}
780        SetVariable PV16,pos={42,base+10*step},size={340,13},title="Source to sample distance (cm)",font="Courier",fSize=10
781        SetVariable PV16,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV16
782        SetVariable PV16,help={"Source to sample distance in centimeters"}
783       
784        SetVariable PV18,pos={42,base+11*step},size={340,13},title="Beamstop diameter (mm)",font="Courier",fSize=10
785        SetVariable PV18,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV18
786        SetVariable PV18,help={"beamstop diamter, in millimeters (1 inch = 25.4mm)"}
787// TODO: add functions for these, make the intent a popup (since it's an enumerated type)
788        SetVariable PS2,pos={42,base+12*step},size={340,13},title="DIV file name"//,proc=SetLabelVarProc
789        SetVariable PS2,help={"DIV file name"},font="Courier",fSize=10
790        SetVariable PS2,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPS2
791        SetVariable PS3,pos={42,base+13*step},size={340,13},title="Intent"//,proc=SetLabelVarProc
792        SetVariable PS3,help={"File Intent"},font="Courier",fSize=10
793        SetVariable PS3,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPS3
794        PopupMenu popup_1,pos={42,base+14*step},size={109,20},title="File intent"
795        PopupMenu popup_1,mode=1,popvalue="SCATTER",value= #"\"SCATTER;EMPTY;BLOCKED BEAM;TRANS;EMPTY BEAM;\""
796       
797        CheckBox checkPS1,pos={18,base},size={20,20},title=""
798        CheckBox checkPS1,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
799        CheckBox checkPV1,pos={18,base+step},size={20,20},title=""
800        CheckBox checkPV1,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
801        CheckBox checkPV2,pos={18,base+2*step},size={20,20},title=""
802        CheckBox checkPV2,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
803
804        CheckBox checkPV5,pos={18,base+3*step},size={20,20},title=""
805        CheckBox checkPV5,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
806        CheckBox checkPV6,pos={18,base+4*step},size={20,20},title=""
807        CheckBox checkPV6,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
808        CheckBox checkPV7,pos={18,base+5*step},size={20,20},title="",value=0
809        CheckBox checkPV7,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
810
811        CheckBox checkPV10,pos={18,base+6*step},size={20,20},title="",value=0
812        CheckBox checkPV10,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
813        CheckBox checkPV11,pos={18,base+7*step},size={20,20},title="",value=0
814        CheckBox checkPV11,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
815
816        CheckBox checkPV14,pos={18,base+8*step},size={20,20},title="",value=0
817        CheckBox checkPV14,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
818        CheckBox checkPV15,pos={18,base+9*step},size={20,20},title="",value=0
819        CheckBox checkPV15,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
820        CheckBox checkPV16,pos={18,base+10*step},size={20,20},title="",value=0
821        CheckBox checkPV16,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
822
823        CheckBox checkPV18,pos={18,base+11*step},size={20,20},title="",value=0
824        CheckBox checkPV18,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
825        CheckBox checkPS2,pos={18,base+12*step},size={20,20},title="",value=0
826        CheckBox checkPS2,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
827        CheckBox checkPS3,pos={18,base+13*step},size={20,20},title="",value=0
828        CheckBox checkPS3,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
829
830
831
832
833// put these in a tabbed? section for the 9 different panels
834// will it be able to patch all "FL" with the proper values, then all "FR", etc. to batchwise correct files?
835
836        base = base+19*step
837        PopupMenu popup_0,pos={30,base-step-10},size={109,20},title="Detector Panel",proc=PatchPopMenuProc
838        PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;MR;ML;MT;MB;B;\""
839
840        SetVariable PV3,pos={42,base},size={340,13},title="Beamcenter X"
841        SetVariable PV3,help={"Current X-position of the beamcenter, in pixels"}
842        SetVariable PV3,font="Courier",fSize=10
843        SetVariable PV3,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV3
844        SetVariable PV4,pos={42,base+step},size={340,13},title="Beamcenter Y"
845        SetVariable PV4,help={"Current Y-position of the beamcenter, in pixels"}
846        SetVariable PV4,font="Courier",fSize=10
847        SetVariable PV4,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV4
848
849
850        SetVariable PV17,pos={42,base+2*step},size={340,13},title="Detector offset (mm)",font="Courier",fSize=10
851        SetVariable PV17,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV17
852        SetVariable PV17,help={"Detector offset, in millimeters"}
853        SetVariable PV19,pos={42,base+3*step},size={340,13},title="Sample to detector distance (cm)",font="Courier",fSize=10
854        SetVariable PV19,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV19
855        SetVariable PV19,help={"sample to detector distance, in centimeters"}
856       
857        SetVariable PV8,pos={42,base+4*step},size={340,13},title="Detector count",font="Courier",fSize=10
858        SetVariable PV8,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV8
859        SetVariable PV8,help={"total detector counts"}
860
861               
862        CheckBox checkPV3,pos={18,base},size={20,20},title=""
863        CheckBox checkPV3,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
864        CheckBox checkPV4,pos={18,base+step},size={20,20},title=""
865        CheckBox checkPV4,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
866
867        CheckBox checkPV8,pos={18,base+2*step},size={20,20},title="",value=0
868        CheckBox checkPV8,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
869
870        CheckBox checkPV17,pos={18,base+3*step},size={20,20},title="",value=0
871        CheckBox checkPV17,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
872
873        CheckBox checkPV19,pos={18,base+4*step},size={20,20},title="",value=0
874        CheckBox checkPV19,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
875
876//      SetVariable PV9,pos={42,273},size={340,13},title="Trans. det. count",font="Courier",fSize=10
877//      SetVariable PV9,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV9
878//      SetVariable PV9,help={"Transmission\r detector counts"}
879//      SetVariable PV12,pos={42,327},size={340,13},title="Temperature (C)",font="Courier",fSize=10
880//      SetVariable PV12,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV12
881//      SetVariable PV12,help={"Set point temperature in centigrade"}
882//      SetVariable PV13,pos={42,345},size={340,13},title="Magnetic field (G)",font="Courier",fSize=10
883//      SetVariable PV13,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV13
884//      SetVariable PV13,help={"magnetic field strength units?"}
885//      CheckBox checkPV9,pos={18,270},size={20,20},title="",value=0
886//      CheckBox checkPV9,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
887//      CheckBox checkPV12,pos={18,324},size={20,20},title="",value=0
888//      CheckBox checkPV12,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
889//      CheckBox checkPV13,pos={18,342},size={20,20},title="",value=0
890//      CheckBox checkPV13,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
891
892End
893
894
895Function MatchCheckProc(name,value)
896        String name
897        Variable value
898       
899        NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal
900       
901        strswitch (name)
902                case "check0":
903                        gRadioVal= 1
904                        break
905                case "check1":
906                        gRadioVal= 2
907                        break
908                case "check2":
909                        gRadioVal= 3
910                        break
911        endswitch
912        CheckBox check0,value= gRadioVal==1
913        CheckBox check1,value= gRadioVal==2
914        CheckBox check2,value= gRadioVal==3
915End
916
917//This function will read only the selected values editable in the patch panel
918//The values read are passed to the panel through the global variables
919//the function WriteHeaderForPatch() MUST mirror this set of reads, or nothing can be updated
920//
921//fname is the full path:name;vers to open the file
922//
923Function ReadHeaderForPatch(fname)
924        String fname
925       
926        //assign to the globals for display in the panel
927
928        // TODO -- replace ALL (get) calls below
929        // TODO -- verify that these calls are really returning what is expected by the checkbox label
930        // -- some are clearly wrong for VSANS
931       
932        // TODO -- remove the hard-wired detStr. This will require some serious interface thought.
933        ControlInfo popup_0
934        String detStr = S_value
935       
936        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS1= V_getSampleDescription(fname)
937
938        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV1 = V_getSampleTransmission(fname)
939        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV2 = V_getSampleThickness(fname)
940
941        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV5 = V_getAttenThickness(fname)
942        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV6 = V_getCount_Time(fname)
943        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV7 = V_getMonitorCount(fname)
944
945//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV9 = -999           // TODO no equivalent for VSANS to --getTransDetectorCounts(fname)
946        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV10 = V_getWavelength(fname)
947        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV11 = V_getWavelength_Spread(fname)
948//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV12 = -999 // TODO no equivalent yet for -- getTemperature(fname)
949//      Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV13 = -999 // TODO no equivalent yet for -- getFieldStrength(fname)
950        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV14 = str2num(V_getSourceAp_size(fname))
951        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV15 = V_getSampleAp2_size(fname)
952        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV16 = -999 // TODO no equivalent yet for -- getSourceToSampleDist(fname)
953        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV18 = V_getBeamStopC3_size(fname)
954
955// per detector information
956        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV3 = V_getDet_beam_center_x(fname,detStr)
957        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV4 = V_getDet_beam_center_y(fname,detStr)
958        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV17 = V_getDet_LateralOffset(fname,detStr)  //TODO lateral vs vertical offset
959        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV19 = V_getDet_ActualDistance(fname,detStr)
960        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV8 = V_getDet_IntegratedCount(fname,detStr)
961               
962        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS2= V_getSensitivityFileName(fname)   //DIV file name
963        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS3= V_getReduction_intent(fname)              //intent
964       
965        Return 0
966End
967
968Function ShowPatchHelp(ctrlName) : ButtonControl
969        String ctrlName
970//      DisplayHelpTopic/Z/K=1 "VSANS Data Reduction Tutorial[Patch File Headers]"
971//      if(V_flag !=0)
972                DoAlert 0,"The VSANS Data Reduction Tutorial Help file could not be found"
973//      endif
974End
975
976//button action procedure to change the selected information (checked values)
977//in each file in the popup list. This will change multiple files, and as such,
978//the user is given a chance to bail out before the whole list of files
979//is modified
980//useful for patching a series of runs with the same beamcenters, or transmissions
981//
982Function ChAllHeadersButtonProc(ctrlName) : ButtonControl
983        String ctrlName
984       
985        String msg
986        msg = "Do you really want to write all of these values to each data file in the popup list? "
987        msg += "- clicking NO will leave all files unchanged"
988        DoAlert 1,msg
989        If(V_flag == 2)
990                Abort "no files were changed"
991        Endif
992       
993        //this will change (checked) values in ALL of the headers in the popup list
994        SVAR list = root:Packages:NIST:VSANS:Globals:Patch:gPatchList
995        Variable numitems,ii
996        numitems = ItemsInList(list,";")
997       
998        if(numitems == 0)
999                Abort "no items in list for multiple patch"
1000        Endif
1001       
1002        //read the (6) checkboxes to determine what changes to make
1003        //The order/length of these waves are crucial!, set by nvars     
1004        String partialName="", tempName = ""
1005        Variable ok,nvars = 20
1006       
1007//      Make/O/N=(nvars) tempChange
1008//      Wave w=tempchange
1009//      GetCheckBoxesState(w,nvars)
1010        //Print "w[0] = ",w[0]
1011       
1012//      //Get the current values in each of the fields - to pass to Write() as a textwave
1013//      Make/O/T/N=(nvars) tempValues
1014//      Wave/T wt=tempValues
1015//      //initialize textwave
1016//      ii=0
1017//      do
1018//              wt[ii] = ""
1019//              ii+=1
1020//      while(ii<nvars)
1021//      GetEditedSetVarBoxes(wt,nvars)
1022       
1023        //loop through all of the files in the list, applying changes as dictated by w and wt waves
1024        ii=0
1025        do
1026                //get current item in the list
1027                partialName = StringFromList(ii, list, ";")
1028                   
1029                //get a valid file based on this partialName and catPathName
1030                tempName = V_FindValidFilename(partialName)
1031       
1032                //prepend path to tempName for read routine
1033                PathInfo catPathName
1034                tempName = S_path + tempName
1035       
1036                //make sure the file is really a RAW data file
1037                ok = V_CheckIfRawData(tempName)
1038                if (!ok)
1039                   Print "this file is not recognized as a RAW SANS data file = ",tempName
1040                else
1041                   //go write the changes to the file
1042//                 WriteHeaderForPatch(tempName,w,wt)
1043                   WriteHeaderForPatch(tempName)
1044                Endif
1045               
1046                ii+=1
1047        while(ii<numitems)
1048       
1049        //clean up wave before leaving
1050        KillWaves/Z w,wt
1051               
1052End
1053
1054
1055//simple action for button to close the panel
1056//
1057// cleans out the RawVSANS folder on closing
1058//
1059Function DoneButtonProc(ctrlName) : ButtonControl
1060        String ctrlName
1061
1062        DoWindow/K V_Patch_Panel
1063
1064//      V_CleanOutRawVSANS()
1065// present a progress window
1066        V_CleanupData_w_Progress(0,1)   
1067       
1068        return(0)
1069End
1070
1071//resets the global string corresponding to the sample label
1072//updates when new text is entered
1073//
1074Function SetLabelVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl
1075        String ctrlName
1076        Variable varNum
1077        String varStr
1078        String varName
1079       
1080        //reset the global variable to the entered text so that it can be relayed to the
1081        //write() routine. Only the TEXT SetVariable control needs to be handled this way
1082       
1083        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS1 = varStr
1084
1085End
1086
Note: See TracBrowser for help on using the repository browser.