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