source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Combine_1D.ipf @ 1247

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

more changes to panel scaling so that they are viewed properly on a small-screen laptop

File size: 19.9 KB
Line 
1#pragma TextEncoding = "MacRoman"
2#pragma rtGlobals=3             // Use modern global access method and strict wave access.
3#pragma IgorVersion = 7.00
4
5
6
7
8//
9// TODO:
10// x- make  the data folder list for the popup
11// x- make the data folder popup do the work of plotting
12//
13// x- (done by invoking the panel)
14//   x-make a button to show the default table, and set up dependencies to link to the graph display
15//
16// -- have an "active" data set to trim, or make duplicates for all of the data sets
17//
18// -- button to convert the points to strings that can be used and written to data files?
19// -- is this really necessary? if the save button is clicked, the strings are automatically generated
20//  -- but what if it's not? What if I do something else to send the strings to a protocol? or to a file?
21//
22// -- find a better way to be sure that the dependency does not generate errors if it is not
23//   properly killed
24//
25// -- help file
26//
27// x- larger panel
28//
29// x- error checking if the binType and the data present don't match. (test for failure)
30// -- do I really need the binType popup? How else would I know what data sets to plot/remove?
31//
32// x- table is continually duplicated
33// -- AutoPosition the windows next to each other
34// x- (different)(not ugly) color for the control bar so it's distinguishable from the regular data plot
35// x- "Done" button that kills the root:ToTrim folder (may need to kill the dependency first)
36//
37Proc V_CombineDataGraph()
38
39        Variable sc = 1
40                       
41        if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)
42                sc = 0.7
43        endif
44
45// this is the "initialization" step
46        NewDataFolder/O root:ToTrim
47       
48        DoWindow/F V_1D_Combine
49
50        Variable num,ii
51        String detStr
52               
53        if(V_flag==0)
54                       
55                if(root:Packages:NIST:VSANS:Globals:gLaptopMode == 1)
56                        Display/W=(100*sc,40*sc,700*sc,590*sc)/N=V_1D_Combine /K=2
57                else
58                        Display /W=(277,526,879,1069)/N=V_1D_Combine /K=2
59                endif
60
61                ControlBar 70*sc
62                ModifyGraph cbRGB=(44000,44000,44000)
63               
64//              Button button2,pos={sc*15,5*sc},size={sc*70,20*sc},proc=V_Load_ITX_button,title="Load Data"
65//              Button button2,help={"Load an ITX file"}
66               
67//              PopupMenu popup1,pos={sc*125,5*sc},size={sc*90,20*sc},title="Data Folder"
68//              PopupMenu popup1,help={"data folder"}
69//              PopupMenu popup1,value= GetAList(4),proc=V_DataFolderPlotPop
70               
71                PopupMenu popup0,pos={sc*15,5*sc},size={sc*70,20*sc},title="Bin Type"
72                PopupMenu popup0,help={"binning type"}
73                PopupMenu popup0,value= ksBinTypeStr,proc=V_DataBinTypePlotPop
74
75                Button button3,pos={sc*544.00,5*sc},size={sc*30.00,20.00*sc},title="?"
76                Button button3,proc=V_ShowCombine1DHelp,help={"help file for combining 1D data"}
77
78                CheckBox check0,pos={sc*18.00,36.00*sc},size={sc*57.00,16.00*sc},proc=V_Plot1D_LogCheckProc,title="Log Axes"
79                CheckBox check0,value= 1
80
81                Button AllQ,pos={sc*100,36*sc},size={sc*70,20*sc},proc=V_AllQ_Plot_1D_ButtonProc,title="All Q"
82                Button AllQ,help={"Show the full q-range of the dataset"}
83
84                Button button1,pos={sc*225,36*sc},size={sc*140,20*sc},proc=V_TrimWaves2StringButton,title="Save Trim Points"
85                Button button1,help={"Convert the waves to global strings"}
86               
87//              Button button4,pos={sc*388,36*sc},size={sc*90.00,20.00*sc},title="Trim & Save"
88//              Button button4,help={"combine and save 1D data"},proc=V_SaveTrimmed_Button
89               
90                Button button0,pos={sc*524,36*sc},size={sc*70,20*sc},proc=V_DoneCombine1D_ButtonProc,title="Done"
91                Button button0,help={"Close the panel and kill the temporary folder"}
92                               
93                Legend/C/N=text0/J/X=72.00/Y=60.00
94
95        endif   
96       
97
98        //trust that the table is present? No, but don't overwrite the data in the waves
99        // unless any one of the three doesn't exist
100       
101        SetDataFolder root:Packages:NIST:VSANS:Globals:Protocols
102
103        if(exists("PanelNameW") == 0 || exists("Beg_pts") == 0 || exists("End_pts") == 0)
104                Make/O/T/N=(ItemsInList(ksPanelBinTypeList)) PanelNameW
105                Make/O/D/N=(ItemsInList(ksPanelBinTypeList)) Beg_pts
106                Make/O/D/N=(ItemsInList(ksPanelBinTypeList)) End_pts
107       
108                num = ItemsInList(ksPanelBinTypeList)
109                ii=0
110                do
111                        detStr = StringFromList(ii, ksPanelBinTypeList)
112                        Beg_pts[ii]  = NumberByKey(detStr, ksBinTrimBegDefault,"=",";")
113                        End_pts[ii] = NumberByKey(detStr, ksBinTrimEndDefault,"=",";")
114                        PanelNameW[ii] = detStr
115                        ii += 1
116                while(ii<num)
117               
118        endif
119        // now make sure that the table is present
120        DoWindow/F V_TrimPointsTable
121
122        if(V_flag==0)
123                Edit/K=0/N=V_TrimPointsTable PanelNameW,Beg_pts,End_pts         
124        endif
125       
126        // last, set up the dependency (but don't set it up twice!)
127        if(exists("root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate") == 0)
128                Make/O/D/N=1 root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate
129                root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate := V_TrimTestUpdate(Beg_pts, End_pts)
130        else
131                string dependencyStr = GetFormula(root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate)
132                if(strlen(dependencyStr)==0)
133                        root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate := V_TrimTestUpdate(Beg_pts, End_pts)
134                endif
135        endif
136       
137        SetDataFolder root:
138               
139End
140
141
142Function V_ShowCombine1DHelp(ctrlName) : ButtonControl
143        String ctrlName
144        DisplayHelpTopic/Z/K=1 "VSANS Data Reduction Documentation[Combine 1D Files]"
145        if(V_flag !=0)
146                DoAlert 0,"The VSANS Data Reduction Tutorial Help file could not be found"
147        endif
148        return(0)
149End
150
151// function that is a simple dependency, and updates the trimmed waves
152// that are displayed
153//
154// does not actually modify the real data, makes a copy, and is only a visual
155//
156//
157Function V_TrimTestUpdate(Beg_pts, End_pts)
158        Wave Beg_pts,End_pts
159       
160        // trim the data displayed
161        // do this by setting the iBin values to NaN, so it won't display
162        // won't hurt to set twice...
163       
164        Wave/T panelStr = root:Packages:NIST:VSANS:Globals:Protocols:PanelNameW
165        Wave begW = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts
166        Wave endW = root:Packages:NIST:VSANS:Globals:Protocols:End_pts
167
168        // in case the dependency is still active, and the folder was killed
169        if(DataFolderExists("root:ToTrim") == 0)
170                return(0)
171        endif
172       
173//      SetDataFolder root:ToTrim
174//      ControlInfo/W=V_1D_Combine popup1
175//      String dataFldrStr = S_Value
176        NVAR gIgnoreBackDet = root:Packages:NIST:VSANS:Globals:gIgnoreDetB
177        SVAR curDispType = root:Packages:NIST:VSANS:Globals:gCurDispType
178        String dataFldrStr = "root:Packages:NIST:VSANS:"+curDispType
179       
180        Variable num,ii,p1,p2
181        String str,detStr
182        num=numpnts(panelStr)
183       
184        for(ii=0;ii<num;ii+=1)
185                detStr = panelStr[ii]
186                if(gIgnoreBackDet && cmpstr(detStr,"B") == 0)
187                        // do nothing
188                else
189                        Wave/Z iw = $("root:ToTrim:iBin_qxqy_"+detStr+"_trim")
190                        Wave/Z iw_orig = $(dataFldrStr+":iBin_qxqy_"+detStr)
191        //              Wave/Z iw = $("iBin_qxqy_"+detStr)
192        //              Wave/Z ew = $("eBin_qxqy_"+detStr)
193                        if(WaveExists(iw) && WaveExists(iw_orig))
194                               
195        //                      DeletePoints 0,nBeg, qw,iw,ew
196                                // start fresh
197                                iw = iw_orig
198                                Variable npt
199                                npt = numpnts(iw)
200                                                       
201                                p1 = begW[ii]
202                                if(p1 > 0 && p1 < npt-1)
203                                        iw[0,p1-1] = NaN
204                                endif
205                               
206        //                      DeletePoints npt-nEnd,nEnd, qw,iw,ew
207                                p2 = EndW[ii]
208                               
209                                if(p2 > 0 && p2 < npt-1)
210                                        iw[npt-p2,npt-1] = NaN
211                                endif                   
212                        endif
213                endif
214        endfor
215       
216        SetDataFolder root:
217
218        return(0)
219End
220
221//
222// x- verify that the proper waves exist for the binning type
223//
224// x- the logic here is wrong. if the ToTrim folder is empty (As on startup)
225//  then the waves are always missing - and the function returns an error - every time
226//
227// now works with the "current" data that is displayed, rather than relying on
228// a lot of user input regarding the details of the saved data
229//
230Function V_DataBinTypePlotPop(ctrlName,popNum,popStr) : PopupMenuControl
231        String ctrlName
232        Variable popNum // which item is currently selected (1-based)
233        String popStr           // contents of current popup item as string
234
235
236        String str,winStr="V_1D_Combine"
237        Variable binType,num,ii,err
238
239        binType = V_BinTypeStr2Num(popStr)
240       
241       
242        //  x- need to update this to make sure that the data waves are present before plotting. This
243        //    currently looks in the ToTrim folder, but the binning could be wrong in the data folder
244        //    and will be an error...
245       
246        //dataType now needs to be the full path to the folder
247        // Plot the "real" data. data copy to trim will be plotted later
248        //
249        SVAR dispType = root:Packages:NIST:VSANS:Globals:gCurDispType
250        String collimationStr="pinhole"         //TODO: where do I get this information from ? does it matter here?
251
252// dispatch based on the string, not on the number of selection in the pop string
253        V_QBinAllPanels_Circular(dispType,binType,collimationStr)
254
255        String workTypeStr
256        workTypeStr = "root:Packages:NIST:VSANS:"+dispType
257       
258
259//      dataType = "root:"+popStr
260//     
261//      //remove EVERYTHING from the graph, no matter what
262        String type,list,item
263//      list = TraceNameList(winStr,";",1)
264//      for(ii=0;ii<ItemsInList(list);ii+=1)
265//              item = StringFromList(ii, list, ";")
266////            CheckDisplayed/W=$winStr $(item)
267////            if(V_flag==1)
268//                      RemoveFromGraph/Z/W=$winStr $(item)
269////            endif
270//      endfor 
271//     
272       
273        sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,binType,winStr
274
275        Execute ("V_Back_IQ_Graph"+str)
276        Execute ("V_Middle_IQ_Graph"+str)
277        Execute ("V_Front_IQ_Graph"+str)
278
279        ModifyGraph marker=8,opaque=1,msize=3           //make the traces open white circles
280
281
282        NewDataFolder/O root:ToTrim
283       
284        //remove all of the "toTrim" data from the graph, if it's there
285        SetDataFolder root:ToTrim
286        for(ii=0;ii<ItemsInList(ksPanelBinTypeList);ii+=1)
287                type = StringFromList(ii, ksPanelBinTypeList, ";")
288                CheckDisplayed/W=$winStr $("iBin_qxqy_"+type+"_trim")
289                if(V_flag==1)
290                        RemoveFromGraph/W=$winStr $("iBin_qxqy_"+type+"_trim")
291                endif
292        endfor 
293        SetDataFolder root:
294
295
296        //then kill the data folder, so it can be duplicated
297       
298//
299//      // duplicate all of the data into the new folder
300        SetDataFolder $workTypeStr
301        list = WaveList("*",";","")             //must be in the correct data folder
302        SetDataFolder root:
303//      Print list     
304        num = ItemsInList(list)
305        for(ii=0;ii<num;ii+=1)
306                str = StringFromList(ii,list)
307                Duplicate/O $(workTypeStr+":"+str), $("root:ToTrim:"+str+"_trim")
308        endfor
309       
310//      // be sure that the data is present in the ToTrim folder before trying to plot
311//      err = V_TrimWavesExist(binType)
312//      if(err)
313//              DoAlert 0,"wrong bin type selected"
314//              return(0)
315//      endif
316       
317       
318        // plot the linked data
319        sprintf str,"(\"%s\",%d,\"%s\")","root:ToTrim",binType,winStr
320
321        Execute ("V_Back_IQ_Graph_trim"+str)
322        Execute ("V_Middle_IQ_Graph_trim"+str)
323        Execute ("V_Front_IQ_Graph_trim"+str)
324        // and link the data to the table with a dependency?
325//      done in the panel macro?
326       
327        // last, force the dependency to update so that the trimmed points are shown
328        Wave w = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts
329        w[0] += 1
330        w[0] -= 1
331       
332       
333        return(0)       
334End
335
336
337
338//
339// x- verify that the proper waves exist for the binning type
340//
341// x- the logic here is wrong. if the ToTrim folder is empty (As on startup)
342//  then the waves are always missing - and the function returns an error - every time
343//
344// currently unused, in favor of using the current data rather than saved itx data
345//
346Function V_DataFolderPlotPop(ctrlName,popNum,popStr) : PopupMenuControl
347        String ctrlName
348        Variable popNum // which item is currently selected (1-based)
349        String popStr           // contents of current popup item as string
350
351
352        String str,winStr="V_1D_Combine",dataType
353        Variable binType,num,ii
354        ControlInfo popup0
355        binType = V_BinTypeStr2Num(S_Value)
356       
357       
358        //  x- need to update this to make sure that the data waves are present before plotting. This
359        //    currently looks in the ToTrim folder, but the binning could be wrong in the data folder
360        //    and will be an error...
361       
362        // be sure that the data is present in the ToTrim folder before trying to plot
363        Variable err = V_itxWavesExist(popStr,binType)
364        if(err)
365                DoAlert 0,"wrong bin type selected"
366                return(0)
367        endif
368       
369       
370        //dataType now needs to be the full path to the folder
371        // Plot the "real" data. data copy to trim will be plotted later
372        //
373        dataType = "root:"+popStr
374       
375        //remove EVERYTHING from the graph, no matter what
376        String type,list,item
377        list = TraceNameList(winStr,";",1)
378        for(ii=0;ii<ItemsInList(list);ii+=1)
379                item = StringFromList(ii, list, ";")
380//              CheckDisplayed/W=$winStr $(item)
381//              if(V_flag==1)
382                        RemoveFromGraph/Z/W=$winStr $(item)
383//              endif
384        endfor 
385       
386       
387        sprintf str,"(\"%s\",%d,\"%s\")",dataType,binType,winStr
388
389        Execute ("V_Back_IQ_Graph"+str)
390        Execute ("V_Middle_IQ_Graph"+str)
391        Execute ("V_Front_IQ_Graph"+str)
392
393        ModifyGraph marker=8,opaque=1,msize=3           //make the traces open white circles
394
395
396        NewDataFolder/O root:ToTrim
397       
398        //remove all of the "toTrim" data from the graph, if it's there
399        SetDataFolder root:ToTrim
400        for(ii=0;ii<ItemsInList(ksPanelBinTypeList);ii+=1)
401                type = StringFromList(ii, ksPanelBinTypeList, ";")
402                CheckDisplayed/W=$winStr $("iBin_qxqy_"+type+"_trim")
403                if(V_flag==1)
404                        RemoveFromGraph/W=$winStr $("iBin_qxqy_"+type+"_trim")
405                endif
406        endfor 
407        SetDataFolder root:
408
409
410        //then kill the data folder, so it can be duplicated
411       
412//
413//      // duplicate all of the data into the new folder
414        SetDataFolder $dataType
415        list = WaveList("*",";","")             //must be in the correct data folder
416        SetDataFolder root:
417//      Print list     
418        num = ItemsInList(list)
419        for(ii=0;ii<num;ii+=1)
420                str = StringFromList(ii,list)
421                Duplicate/O $(dataType+":"+str), $("root:ToTrim:"+str+"_trim")
422        endfor
423       
424        // be sure that the data is present in the ToTrim folder before trying to plot
425        err = V_TrimWavesExist(binType)
426        if(err)
427                DoAlert 0,"wrong bin type selected"
428                return(0)
429        endif
430       
431       
432        // plot the linked data
433        sprintf str,"(\"%s\",%d,\"%s\")","root:ToTrim",binType,winStr
434
435        Execute ("V_Back_IQ_Graph_trim"+str)
436        Execute ("V_Middle_IQ_Graph_trim"+str)
437        Execute ("V_Front_IQ_Graph_trim"+str)
438        // and link the data to the table with a dependency?
439//      done in the panel macro?
440       
441        // last, force the dependency to update so that the trimmed points are shown
442        Wave w = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts
443        w[0] += 1
444        w[0] -= 1
445       
446       
447        return(0)       
448End
449
450
451
452// kill the dependency,
453// kill the panel, then the associated ToTrim folder
454// do not kill the beg/end waves
455//
456Function V_DoneCombine1D_ButtonProc(ctrlName) : ButtonControl
457        String ctrlName
458       
459        Wave trimUpdate = root:Packages:NIST:VSANS:Globals:Protocols:trimUpdate
460        trimUpdate = 1          //kills the dependency
461        DoWindow/K V_1D_Combine
462       
463        KillDataFolder/Z root:ToTrim
464       
465        return(0)
466End
467
468// TODO
469// -- verify that this works for all binning cases
470// -- see V_Trim1DDataStr to see if they can be combined
471//
472Function V_SaveTrimmed_Button(ctrlName) : ButtonControl
473        String ctrlName
474       
475        String detListStr,dataType,str
476        Variable bintype,num,ii
477
478        ControlInfo popup0
479        binType = V_BinTypeStr2Num(S_Value)
480       
481       
482        if(binType == 1)
483                detListStr = ksBinType1
484        endif
485        if(binType == 2)
486                detListStr = ksBinType2
487        endif
488        if(binType == 3)
489                detListStr = ksBinType3
490        endif
491        if(binType == 4)
492                detListStr = ksBinType4
493        endif
494        if(strlen(detListStr)==0)
495                DoAlert 0,"error in V_SaveTrimmed_Button"
496                return(0)
497        endif
498
499// set the global strings
500        V_TrimWaves2String()            //in case the button wasn't clicked
501        SVAR gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr
502        SVAR gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr
503
504// get a fresh copy of the data
505// duplicate all of the data into the new folder
506        ControlInfo popup1
507        dataType = "root:"+S_Value
508
509        SetDataFolder $dataType
510        String list = WaveList("*",";","")              //must be in the correct data folder
511        SetDataFolder root:
512//      Print list     
513        num = ItemsInList(list)
514        for(ii=0;ii<num;ii+=1)
515                str = StringFromList(ii,list)
516                Duplicate/O $(dataType+":"+str), $("root:ToTrim:"+str+"_trim")
517        endfor
518
519       
520// trim each data set
521        Variable nBeg,nEnd,npt
522        String detstr
523       
524        SetDataFolder root:ToTrim
525        num = ItemsInList(detListStr)
526        for(ii=0;ii<num;ii+=1)
527                detStr = StringFromList(ii, detListStr)
528                nBeg = NumberByKey(detStr, gBegPtsStr,"=",";")
529                nEnd = NumberByKey(detStr, gEndPtsStr,"=",";")
530               
531//              V_TrimOneSet(folderStr,detStr,nBeg,nEnd)
532                Wave/Z qw = $("qBin_qxqy_"+detStr+"_trim")
533                Wave/Z iw = $("iBin_qxqy_"+detStr+"_trim")
534                Wave/Z ew = $("eBin_qxqy_"+detStr+"_trim")
535
536                DeletePoints 0,nBeg, qw,iw,ew
537
538                npt = numpnts(qw)
539                DeletePoints npt-nEnd,nEnd, qw,iw,ew
540//             
541        endfor
542
543
544// remove Q=0 from "B" if it's present
545        SetDataFolder root:ToTrim
546        WAVE/Z qBin = qBin_qxqy_B_trim
547        WAVE/Z iBin = iBin_qxqy_B_trim
548        WAVE/Z eBin = eBin_qxqy_B_trim
549//      WAVE/Z nBin = nBin_qxqy_B_trim
550//      WAVE/Z iBin2 = iBin2_qxqy_B_trim
551
552        if(qBin[0] == 0)
553                DeletePoints 0, 1, qBin,iBin,eBin//,nBin,iBin2
554        endif
555
556       
557// concatenate
558        V_1DConcatenate("root:","ToTrim","_trim",binType)
559
560// sort the waves - concatenation creates tmp_q, tmp_i, tmp_s
561// so this call will work (doesn't need the "_trim" tag)
562        V_TmpSort1D("root:","ToTrim")
563
564// write out the data to disk
565
566        Execute "V_GetNameForSave()"
567        SVAR newName = root:saveName
568        String saveName = newName
569
570        //will write out the tmp_q, tmp_i, tmp_s waves
571        V_Write1DData("root:","ToTrim",saveName)                //don't pass the full path, just the name
572
573       
574// put a fresh copy of the data back into the folder since the data was actually trimmed
575// duplicate all of the data into the new folder
576        ControlInfo popup1
577        dataType = "root:"+S_Value
578
579        SetDataFolder $dataType
580        list = WaveList("*",";","")             //must be in the correct data folder
581        SetDataFolder root:
582//      Print list     
583        num = ItemsInList(list)
584        for(ii=0;ii<num;ii+=1)
585                str = StringFromList(ii,list)
586                Duplicate/O $(dataType+":"+str), $("root:ToTrim:"+str+"_trim")
587        endfor
588
589
590        SetDataFolder root:
591       
592        return(0)
593End
594
595
596
597//
598// dialog to select and load an itx format data file
599//
600Function V_Load_ITX_Button(ctrlName) : ButtonControl
601        String ctrlName
602       
603        Execute "V_Load_Data_ITX()"
604       
605        return(0)
606End
607
608
609// TODO
610// -- document
611Function V_TrimWaves2StringButton(ctrlName) : ButtonControl
612        String ctrlName
613       
614        V_TrimWaves2String()
615
616        return(0)
617End
618
619// for each of the binning types, be sure that the corresponding waves in the
620// root:ToTrim folder actually do exist.
621// return 0 for OK, 1 if error
622Function V_TrimWavesExist(binType)
623        Variable binType
624       
625        String binStr="",str
626        Variable num,ii
627       
628        if(binType == 1)
629                binStr = ksBinType1
630        endif
631        if(binType == 2)
632                binStr = ksBinType2
633        endif
634        if(binType == 3)
635                binStr = ksBinType3
636        endif
637        if(binType == 4)
638                binStr = ksBinType4
639        endif
640       
641        num = ItemsInList(binStr)
642        for(ii=0;ii<num;ii+=1)
643                str = StringFromList(ii,binStr)
644                if(exists("root:ToTrim:iBin_qxqy_"+Str+"_trim") == 0)           // not in use = error
645                        return(1)
646                endif
647        endfor
648       
649        return(0)               //everything checked out OK, no error
650
651end
652
653// for each of the binning types, be sure that the corresponding waves in the
654// root:ToTrim folder actually do exist.
655// return 0 for OK, 1 if error
656Function V_itxWavesExist(folderStr,binType)
657        String folderStr
658        Variable binType
659       
660        String binStr="",str
661        Variable num,ii
662       
663        if(binType == 1)
664                binStr = ksBinType1
665        endif
666        if(binType == 2)
667                binStr = ksBinType2
668        endif
669        if(binType == 3)
670                binStr = ksBinType3
671        endif
672        if(binType == 4)
673                binStr = ksBinType4
674        endif
675       
676        num = ItemsInList(binStr)
677        for(ii=0;ii<num;ii+=1)
678                str = StringFromList(ii,binStr)
679                if(exists("root:"+folderStr+":iBin_qxqy_"+Str) == 0)            // not in use = error
680                        return(1)
681                endif
682        endfor
683       
684        return(0)               //everything checked out OK, no error
685
686end
687
688
689
690//
691// take the waves, and convert to strings that can be added to the protocol
692//
693//
694// x- get the variables out of root:, and move it to Protocols
695// x- get the waves out of root:, and move it to Protocols
696// x- be sure that the variables are initialized (done in main initialization
697// x- link this to the panel?
698//
699Function V_TrimWaves2String()
700
701
702        SVAR gBegPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gBegPtsStr
703        SVAR gEndPtsStr=root:Packages:NIST:VSANS:Globals:Protocols:gEndPtsStr
704
705        Wave/T PanelNameW = root:Packages:NIST:VSANS:Globals:Protocols:PanelNameW
706        Wave Beg_pts = root:Packages:NIST:VSANS:Globals:Protocols:Beg_pts
707        Wave End_pts = root:Packages:NIST:VSANS:Globals:Protocols:End_pts
708       
709// ksPanelBinTypeList = "B;FT;FB;FL;FR;MT;MB;ML;MR;FTB;FLR;MTB;MLR;FLRTB;MLRTB;"
710// ksBinTrimBegDefault = "B=5;FT=6;FB=6;FL=6;FR=6;MT=6;MB=6;ML=6;MR=6;FTB=7;FLR=7;MTB=7;MLR=7;FLRTB=8;MLRTB=8;"
711// ksBinTrimEndDefault
712
713        // wipe out the "old" global strings
714        gBegPtsStr = ksBinTrimBegDefault
715        gEndPtsStr = ksBinTrimEndDefault
716
717        Variable num, ii,nBeg,nEnd
718        String item,panelStr
719       
720        num = numpnts(PanelNameW)
721        for(ii=0;ii<num;ii+=1)
722                panelStr = PanelNameW[ii]
723                gBegPtsStr = ReplaceNumberByKey(panelStr, gBegPtsStr, Beg_pts[ii],"=",";")
724                gEndPtsStr = ReplaceNumberByKey(panelStr, gEndPtsStr, End_pts[ii],"=",";")
725        endfor
726
727        return(0)
728End
729
730
Note: See TracBrowser for help on using the repository browser.