source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Tile_2D.ipf @ 779

Last change on this file since 779 was 763, checked in by srkline, 12 years ago

fix for ticket #310, added a checkbox to "Select All Files" for the ASCII export panel.

fix for ticket #311, made the tiled images of the PNG layouts square by properly sizing them after tiling. The tiling operation does not preserve the aspect ratio, but rather stretches to fill.

File size: 20.8 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=5.0
3#pragma IgorVersion=6.1
4
5//***************************
6// Vers 1.2 100901
7//
8//***************************
9
10//Procedures to create a layout of 2D raw data files selected from a list.
11//2D data files are log or linear scale, selected on the panel. The min/max range of the Z-scale (counts)
12// can be fixed so that all images are on a directly comparable scale.
13//New or existing layouts can be used.
14//Graphics are repeatedly read in to the "RAW" folder, then saved to the Clipboard
15//as PNG files (note that the Demo version of IGOR can't do this operation) to be
16//appended to the seelcted layout. Graphics are sequentially named with the suffix "L_PNG"
17//created layouts are killed along with the graphics files in memory when the panel is killed
18//********************
19// Also contains procedures for a simple panel for 2d export of data files (especially raw data)
20//
21//
22
23// initializes data folder and waves needed for the panel (contains a listbox)
24Proc Init_Tile()
25        //create the data folder
26        NewDataFolder/O/S root:myGlobals:Tile_2D
27        //create the waves
28        Make/O/T/N=1 fileWave=""
29        Make/O/N=1 selWave=0
30        Variable/G ind=0
31        Variable/G minScale=0
32        Variable/G maxScale=100
33        SetDataFolder root:
34End
35
36// main procedure to call to bring up the panel
37// re-initializes necessary folders and waves
38Proc Show_Tile_2D_Panel()
39        DoWindow/F Tile_2D
40        if(V_Flag==0)
41                Init_Tile()
42                Tile_2D()
43        endif
44End
45
46//procedure to draw the "tile" panel
47Proc Tile_2D()
48        PauseUpdate; Silent 1           // building window...
49        NewPanel /W=(849,337,1248,553) /K=2
50        DoWindow/C Tile_2D
51       
52        ListBox fileList,pos={5,4},size={206,206}
53        ListBox fileList,listWave=root:myGlobals:Tile_2D:fileWave
54        ListBox fileList,selWave=root:myGlobals:Tile_2D:selWave,mode= 4
55        Button button0,pos={217,131},size={170,20},proc=AddToLayoutButtonProc,title="Add Selected To Layout"
56        Button button0,help={"Adds images of the selected files to the layout selected in the popup menu"}
57        Button button1,pos={316,182},size={50,20},proc=TileDoneButtonProc,title="Done"
58        Button button1,help={"Closes the panel, kills the layouts, and kills images from your memory"}
59        Button button3,pos={227,6},size={60,20},proc=GetListButtonProc,title="Get List"
60        Button button3,help={"Refreshes the list of data files"}
61        Button button4,pos={340,6},size={25,20},proc=ShowTileHelp,title="?"
62        Button button4,help={"Show help file for tiling raw data files in a layout"}
63        Button button5,pos={217,155},size={170,20},proc=AddAllToLayout,title="Add All To Layout"
64        Button button5,help={"Adds images of all raw files, 40 per layout"}
65        CheckBox check0,pos={216,64},size={71,14},title="Log scaling"
66        CheckBox check0,help={"If checked, the image color will be log scale"},value= 1
67        PopupMenu popup0,pos={226,38},size={141,20},title="Layout ?"
68        PopupMenu popup0,help={"Sets a new or existing layout as the destination when adding images"}
69        PopupMenu popup0,mode=1,popvalue="New Layout",value= #"\"New Layout;\"+WinList(\"*\", \";\",\"WIN:4\")"
70        CheckBox check1,pos={216,86},size={72,14},proc=FixScale_CheckProc,title="Fixed Scale"
71        CheckBox check1,value= 0,help={"Sets a fixed z-scale (counts) for all images in the layout. Enter the min and max values"}
72        SetVariable scale_0,pos={216,105},size={80,15},title="min"
73        SetVariable scale_0,limits={-Inf,Inf,0},value= root:myGlobals:Tile_2D:minScale
74        SetVariable scale_0,help={"Minimum mapped count value"},disable=1               //initially not visible
75        SetVariable scale_1,pos={300,105},size={80,15},title="max"
76        SetVariable scale_1,limits={-Inf,Inf,0},value=root:myGlobals:Tile_2D:maxScale
77        SetVariable scale_1,help={"Maximum mapped count value"},disable=1               //initially not visible
78EndMacro
79
80Function ShowTileHelp(ctrlName) : ButtonControl
81        String ctrlName
82        DisplayHelpTopic/Z/K=1 "SANS Data Reduction Tutorial[Tile 2-D Images]"
83        if(V_flag !=0)
84                DoAlert 0,"The SANS Data Reduction Tutorial Help file could not be found"
85        endif
86end
87
88Function FixScale_CheckProc(ctrlName,checked) : CheckBoxControl
89        String ctrlName
90        Variable checked
91
92//      Print "fix scale =",checked
93        //Tile_2D panel must be on top, since it's being checked
94        SetVariable scale_0,disable=(!checked)
95        SetVariable scale_1,disable=(!checked)
96End
97
98
99// upon hitting the "add to layout" button...
100// polls the selected file(s) in the listbox and sequentially loads each
101// file into RAW folder, and makes a PNG of the file, and appends each to the selected layout
102// ...see SetGraphic() in Schematic.ipf
103Function AddToLayoutButtonProc(ctrlName) : ButtonControl
104        String ctrlName
105
106        ControlInfo popup0
107        String layoutStr=S_Value        //create new layout or append to old one
108       
109        ControlInfo check0
110        Variable makeLog=V_Value        //make the images logscale?
111       
112        ControlInfo check1
113        Variable fixScale=V_Value       //use fixed, user-defined scale
114       
115        Variable minScale,maxScale
116        NVAR mns=root:myGlobals:Tile_2D:minScale
117        NVAR mxs=root:myGlobals:Tile_2D:maxScale
118        if(fixScale==1)
119                if(makeLog==1)
120                //check for zero
121                        if((mns<=0) || (mxs<=0) )
122                                Abort "min and max scale must be greater than zero for log-scaling"
123                        endif
124                        minScale=log(mns)
125                        maxScale=log(mxs)
126                else
127                        minScale=mns
128                        maxScale=mxs
129                endif
130        else
131                minScale = -1
132                maxScale = -1           //if both are equal, autoscale data
133        endif
134       
135        //loop through the selected files in the list...
136        Wave/T fileWave=$"root:myGlobals:Tile_2D:fileWave"
137        Wave sel=$"root:myGlobals:Tile_2D:selWave"
138        NVAR ind=root:myGlobals:Tile_2D:ind
139        Variable num=numpnts(sel),ii=0,err=0,startInd=ind,shift
140        Variable ht=1.5,wd=1.5          //height and width of the graphic (in inches)
141        String fname="",pathStr=""
142       
143        PathInfo catPathName                    //this is where the files are
144        pathStr=S_path
145       
146        // get the current state
147        NVAR defaultScaling = root:Packages:NIST:gLogScalingAsDefault
148        Variable oldState = defaultScaling
149        defaultScaling = 0              //set the scaling to linear
150       
151        do
152                if(sel[ii] == 1)
153                        fname=pathStr + FindValidFilename(fileWave[ii]) //in case of VAX version numbers
154                        ReadHeaderAndData(fname)                //fname is the full path
155                        String/G root:myGlobals:gDataDisplayType="RAW" 
156                        fRawWindowHook()
157                        if(makeLog)
158                                err = ConvertFolderToLogScale("RAW")
159                        endif
160                        MakePNGforLayout(minScale,maxScale,"RAW",ind)
161                        ind+=1                  //a running count of all of the PNG's
162                endif
163                ii+=1
164        while(ii<num)
165        //close the SANS_Data window
166        DoWindow/K SANS_Data
167       
168        //now add to the appropriate layout
169        if(cmpstr(layoutStr,"New Layout")==0)
170                NewLayout
171                DoWindow/C $("PNGLayout"+num2str(ind))
172        else   
173                DoWindow/F $layoutStr
174        endif
175        for(ii=startInd;ii<ind;ii+=1)
176                AppendLayoutObject/F=1/R=(72,40,144,112) picture $("RAW"+num2str(ii)+"L_PNG")
177//              ModifyLayout top($("RAW"+num2str(ii)+"L_PNG"))=(40+mod(30*ii,560))      //separate the graphics (in points)
178//              ModifyLayout/I width($("RAW"+num2str(ii)+"L_PNG"))=(wd),height($("RAW"+num2str(ii)+"L_PNG"))=(wd) //(in inches)
179        endfor
180        //careful tiling the objects in the layout - it alters the aspect ratio
181        Variable totalNumPNGs = itemsinlist(PICTList("*L_PNG", ";", "WIN:"))
182        String rcStr="/A=(4,3)"
183        wd = 2.5
184//      Print totalNumPNGs
185        if(totalNumPNGs>12)
186                rcStr="/A=(5,4)"
187                wd = 1.9
188        endif
189        if(totalNumPNGs>20)
190                rcStr="/A=(7,5)"
191                wd = 1.4
192        endif
193        if(totalNumPNGs>35)
194                rcStr="/A=(8,5)"
195                wd = 1.2
196        endif
197        if(totalNumPNGs>40)
198                rcStr=""
199                wd = 1
200        endif
201        Execute "Tile"+rcStr+"/O=8"
202       
203        // pick an appropriate width and height (the same) for the permutations of rows and columns to get the
204        // largest possible images
205        // -- then propogate this change to the Add All to Layout function
206        //
207        for(ii=startInd;ii<ind;ii+=1)
208                ModifyLayout/I width($("RAW"+num2str(ii)+"L_PNG"))=(wd),height($("RAW"+num2str(ii)+"L_PNG"))=(wd) //(in inches)
209        endfor
210       
211        defaultScaling = oldState               //set the scaling back to the previous state
212        return(0)
213End
214
215// upon hitting the "add to layout" button...
216// loads all of the data files in the list
217// file into RAW folder, and makes a PNG of the file, and appends each to the selected layout
218// ...see SetGraphic() in Schematic.ipf
219// This test version will add 40 images to each layout, and tile them
220//
221Function AddALLToLayout(ctrlName) : ButtonControl
222        String ctrlName
223
224        DoWindow/F Tile_2D
225        if(V_flag==0)
226                DoAlert 0,"You must have the Tile_2D panel open to use this operation"
227                Return(0)
228        endif
229       
230        //pop the file list to get a current list
231        GetListButtonProc("")
232       
233        //tile_2d will now be the top window, but check anyways, since this is not called from a button control
234        ControlInfo/W=Tile_2D popup0
235        String layoutStr=S_Value        //create new layout or append to old one
236       
237        ControlInfo/W=Tile_2D check0
238        Variable makeLog=V_Value        //make the images logscale?
239       
240        ControlInfo/W=Tile_2D check1
241        Variable fixScale=V_Value       //use fixed, user-defined scale
242       
243        Variable minScale,maxScale
244        NVAR mns=root:myGlobals:Tile_2D:minScale
245        NVAR mxs=root:myGlobals:Tile_2D:maxScale
246        if(fixScale==1)
247                if(makeLog==1)
248                //check for zero
249                        if((mns<=0) || (mxs<=0) )
250                                Abort "min and max scale must be greater than zero for log-scaling"
251                        endif
252                        minScale=log(mns)
253                        maxScale=log(mxs)
254                else
255                        minScale=mns
256                        maxScale=mxs
257                endif
258        else
259                minScale = -1
260                maxScale = -1           //if both are equal, autoscale data
261        endif
262       
263        //loop through the selected files in the list...
264        Wave/T fileWave=$"root:myGlobals:Tile_2D:fileWave"
265        Wave sel=$"root:myGlobals:Tile_2D:selWave"
266        NVAR ind=root:myGlobals:Tile_2D:ind             //largest index of the PNG files currently in memory
267        Variable num,ii=0,err=0,startInd,shift
268        Variable ht=1.5,wd=1.5          //height and width of the graphic (in inches)
269        String fname="",pathStr=""
270        Variable numPerLayout=40                        //number of images per layout
271       
272        num=numpnts(fileWave)           //total number of files
273        startind = ind                                  //this layout(s) PNG files start with this index
274       
275        PathInfo catPathName                    //this is where the files are
276        pathStr=S_path
277       
278        // get the current state
279        NVAR defaultScaling = root:Packages:NIST:gLogScalingAsDefault
280        Variable oldState = defaultScaling
281        defaultScaling = 0              //set the scaling to linear
282       
283        //make all of the PNG files
284        do
285                fname=pathStr + FindValidFilename(fileWave[ii]) //in case of VAX version numbers
286                ReadHeaderAndData(fname)                //fname is the full path
287                String/G root:myGlobals:gDataDisplayType="RAW" 
288                fRawWindowHook()
289                if(makeLog)
290                        err = ConvertFolderToLogScale("RAW")
291                endif
292                MakePNGforLayout(minScale,maxScale,"RAW",ind)
293                ind+=1                  //a running count of all of the PNG's
294
295                ii+=1
296        while(ii<num)
297        //close the SANS_Data window
298        DoWindow/K SANS_Data
299       
300        //now add to the appropriate layout(s)
301       
302//      if(cmpstr(layoutStr,"New Layout")==0)
303//              NewLayout
304//              DoWindow/C $("PNGLayout"+num2str(ind))
305//      else   
306//              DoWindow/F $layoutStr
307//      endif
308        Variable jj,kk
309        String rcStr=""
310       
311        // determine the appropriate scaling for the number of files.
312        // if < 40 files, pick the scaling. if > 40, use wd =1, and the last
313        // layout may be sparse, but will be scaled like the others.
314
315        if(num>12)
316                rcStr="/A=(5,4)"
317                wd = 1.9
318        endif
319        if(num>20)
320                rcStr="/A=(7,5)"
321                wd = 1.4
322        endif
323        if(num>35)
324                rcStr="/A=(8,5)"
325                wd = 1.2
326        endif
327        if(num>40)
328                rcStr=""
329                wd = 1
330        endif
331
332
333       
334        NewLayout
335        DoWindow/C $("PNGLayout"+num2str(startInd))
336        for(ii=startInd;ii<ind;ii+=numPerLayout)
337                jj=ii
338                do
339                        AppendLayoutObject/F=1/R=(72,40,144,112) picture $("RAW"+num2str(jj)+"L_PNG")
340                        ModifyLayout/I width($("RAW"+num2str(jj)+"L_PNG"))=(wd),height($("RAW"+num2str(ii)+"L_PNG"))=(wd) //(in inches)
341                        jj+=1
342                while( (jj<ii+numPerLayout) && (jj<ind) )       //index in batch, keep from running over total number of PNGs
343                Execute "Tile"+rcStr+"/O=8"
344                //now make them square
345                for(kk=ii;kk<jj;kk+=1)
346                        ModifyLayout/I width($("RAW"+num2str(kk)+"L_PNG"))=(wd),height($("RAW"+num2str(kk)+"L_PNG"))=(wd) //(in inches)
347                endfor
348               
349                if(jj<ind)              //need another layout
350                        NewLayout
351                        DoWindow/C $("PNGLayout"+num2str(jj))
352                endif
353        endfor
354
355        defaultScaling = oldState               //set the scaling back to the previous state
356        return(0)
357End
358
359
360//filters to keep onle the files that are named like a raw data file, i.e. "*.SAn"
361//does not check to see if they really are RAW files though...(too slow)
362// ... if the filename does NOt have "SA1","SA2", or "SA3" in the name (anywhere)
363// the files will NOT show up in the list box
364//
365Function GetListButtonProc(ctrlName) : ButtonControl
366        String ctrlName
367       
368        //make sure that path exists
369        PathInfo catPathName
370        if (V_flag == 0)
371                Abort "Folder path does not exist - use Pick Path button on Main Panel"
372        Endif
373       
374        String newList=""
375        Variable num
376
377        newList = GetRawDataFileList()
378       
379        num=ItemsInList(newlist,";")
380        WAVE/T fileWave=$"root:myGlobals:Tile_2D:fileWave"
381        WAVE selWave=$"root:myGlobals:Tile_2D:selWave"
382        Redimension/N=(num) fileWave
383        Redimension/N=(num) selWave
384        fileWave = StringFromList(p,newlist,";")
385        Sort filewave,filewave
386End
387
388// procedure called when user is done
389// deletes all of the graphs, layouts, etc associated with the files that were read in...
390//to free up memory and cluttered space
391//
392//since panel and graphics are killed, gives the user a chance to reconsider
393Function TileDoneButtonProc(ctrlName) : ButtonControl
394        String ctrlName
395
396        DoAlert 1,"Closing the panel will kill the created Layouts. Do you want to continue?"
397        if(V_Flag==2)
398                return(0)
399        endif
400       
401        String pngList=PICTList("*L_PNG",";",""),item=""
402        String ltList=WinList("PNGLayout*", ";","WIN:4")                //default named layout windows
403        Variable ii,num
404       
405        //close the layouts, then kill the PNG's
406        num=ItemsinList(ltList,";")
407        for(ii=0;ii<num;ii+=1)
408                item=StringFromList(ii,ltList,";")
409                DoWindow/K $item
410        endfor
411       
412        num=ItemsinList(pngList,";")
413        for(ii=0;ii<num;ii+=1)
414                item=StringFromList(ii,pngList,";")
415                KillPICTs/Z $item
416        endfor
417        //kill the panel, and reset the globals
418        DoWindow/K Tile_2D
419        Execute "Init_Tile()"
420        return(0)
421End
422
423// data has laready been loaded into RAW folder
424// make a PNG file by first creating a small graph, then save the graph to the  clipboard,
425// and then load it back in from the clipboard in to memory
426// (from memory it can be easily appended to a layout)
427//
428// if minScale and maxScale are equal, data will be (individually) autoscaled
429// if minScale and maxScale are unequal, all sets will be scaled to those values
430//
431Function MakePNGforLayout(minScale,maxScale,type,ii)
432        Variable minScale,maxScale
433        String type
434        Variable ii
435       
436        if(!WaveExists($"root:myGlobals:NIHColors"))
437                NIHColorIndex()
438        Endif
439       
440        WAVE NIHColors = $"root:myGlobals:NIHColors"
441        WAVE data = $("root:Packages:NIST:"+type+":data")
442        String nameStr = type +num2str(ii)+ "L_PNG"
443
444        PauseUpdate; Silent 1           // building window...
445        Display /W=(40,40,196,196)
446        //plot and name the picture, then kill it
447        AppendImage data
448        DoWindow/C temp_png
449        if(minScale==maxScale)
450                WaveStats/Q data
451                minScale=V_min
452                maxScale=V_max
453        Endif
454        ScaleColorsToData(minScale, maxScale, NIHColors)
455        ModifyImage data cindex=NIHColors
456        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14
457        ModifyGraph nticks=4
458        ModifyGraph minor=1
459        ModifyGraph fSize=9
460        ModifyGraph standoff=0
461        ModifyGraph tkLblRot(left)=90
462        ModifyGraph btLen=3
463        ModifyGraph tlOffset=-2
464        SVAR fileStr = $("root:Packages:NIST:"+type+":fileList")
465        Textbox/N=text0/F=0/A=MT/X=0.00/Y=0.00/E fileStr
466       
467// comment out the line below for DEMO_MODIFIED version
468        SavePICT/Z/E=-5 as "Clipboard"          //saves as PNG format
469       
470        LoadPICT/O/Q "Clipboard",$nameStr
471        DoWindow/K temp_png
472        return(0)
473End
474
475
476//******************
477//procedures to display a simple panel to export a list of files as ASCII
478//******************
479
480// initialization procedure to create the necessary data floder and the waves for
481// the list box in the panel
482Proc Init_RawExport()
483        //create the data folder
484        NewDataFolder/O/S root:myGlobals:RAW2ASCII
485        //create the waves
486        Make/O/T/N=1 fileWave=""
487        Make/O/N=1 selWave=0
488        Variable/G ind=0
489        SetDataFolder root:
490End
491
492// main procedure for invoking the raw to ascii panel
493// initializes each time to make sure
494Proc Export_RAW_Ascii_Panel()
495        Init_RawExport()
496        DoWindow/F RAW_to_ASCII
497        if(V_Flag==0)
498                RAW_to_ASCII()
499        endif
500End
501
502//procedure for drawing the simple panel to export raw->ascii
503//root:myGlobals:RAW2ASCII:selWave = 1
504Proc RAW_to_ASCII()
505        PauseUpdate; Silent 1           // building window...
506        NewPanel /W=(501,97,885,282) /K=2
507        DoWindow/C RAW_to_ASCII
508        ListBox fileList,pos={4,3},size={206,179}
509        ListBox fileList,listWave=root:myGlobals:RAW2ASCII:fileWave
510        ListBox fileList,selWave=root:myGlobals:RAW2ASCII:selWave,mode= 4
511        Button button0,pos={239,132},size={110,20},proc=RA_ExportButtonProc,title="Export File(s)"
512        Button button0,help={"Exports (saves to disk) the selected files as ASCII format"}
513        Button button1,pos={270,156},size={50,20},proc=RawExportDoneButtonProc,title="Done"
514        Button button1,help={"Closes the panel"}
515        Button button3,pos={230,16},size={60,20},proc=RA_GetListButtonProc,title="Get List"
516        Button button3,help={"Refreshes the file listing"}
517        Button button4,pos={330,16},size={25,20},proc=ShowRawExportHelp,title="?"
518        Button button4,help={"Show the help file for 2-D export of raw data files"}
519        CheckBox check0,pos={220,50},size={115,14},title="detector coordinates",value= 1,mode=1
520        CheckBox check0,proc=RA_ExportCheckProc
521        CheckBox check1,pos={220,66},size={104,14},title="Qx,Qy coordinates",value= 0,mode=1
522        CheckBox check1,proc=RA_ExportCheckProc
523        CheckBox check2,pos={220,82},size={104,14},title="Det. Coord, Grasp compatible",value= 0,mode=1
524        CheckBox check2,proc=RA_ExportCheckProc
525        CheckBox check3,pos={220,110},size={104,14},title="Select All Files",value= 0
526        CheckBox check3,proc=RA_SelectAllCheckProc
527EndMacro
528
529Function RA_SelectAllCheckProc(ctrlName,checked) : CheckBoxControl
530        String ctrlName
531        Variable checked
532
533        WAVE w = root:myGlobals:RAW2ASCII:selWave
534        if(checked)
535                w = 1           // select everything
536                CheckBox check3,value=1
537        else
538                w = 0           // deselect all
539                CheckBox check3,value=0
540        endif
541       
542
543        return(0)
544End
545
546Function RA_ExportCheckProc(ctrlName,checked) : CheckBoxControl
547        String ctrlName
548        Variable checked
549
550        strswitch (ctrlName)
551                case "check0":
552                        CheckBox check0,value=1
553                        CheckBox check1,value=0
554                        CheckBox check2,value=0
555                        break
556                case "check1":
557                        CheckBox check0,value=0
558                        CheckBox check1,value=1
559                        CheckBox check2,value=0
560                        break
561                case "check2":
562                        CheckBox check0,value=0
563                        CheckBox check1,value=0
564                        CheckBox check2,value=1
565        endswitch
566        return(0)
567End
568
569
570//closes the panel when done
571Function RawExportDoneButtonProc(ctrlName) : ButtonControl
572        String ctrlName
573
574        //kill the panel
575        DoWindow/K RAW_to_ASCII
576        return(0)
577End
578
579//filters to keep onle the files that are named like a raw data file, i.e. "*.SAn"
580//does not check to see if they really are RAW files though...(too slow)
581Function RA_GetListButtonProc(ctrlName) : ButtonControl
582        String ctrlName
583       
584        //make sure that path exists
585        PathInfo catPathName
586        if (V_flag == 0)
587                Abort "Folder path does not exist - use Pick Path button on Main Panel"
588        Endif
589       
590        Variable num
591        String newList = GetRawDataFileList()
592       
593        num=ItemsInList(newlist,";")
594        WAVE/T fileWave=$"root:myGlobals:RAW2ASCII:fileWave"
595        WAVE selWave=$"root:myGlobals:RAW2ASCII:selWave"
596        Redimension/N=(num) fileWave
597        Redimension/N=(num) selWave
598        fileWave = StringFromList(p,newlist,";")
599        Sort filewave,filewave
600End
601
602// does a Fast2DExport of the files selected from the listbox
603//polls the listbox for selected files and loops through each selection
604//exported file is filename + ".ASC" if an ascii detector image
605// or ".DAT" if it is in Qx, Qy, I(Qx,Qy) triple format
606//
607// temporarily change the default logScale display to linear during export
608//
609Function RA_ExportButtonProc(ctrlName) : ButtonControl
610        String ctrlName
611       
612        //loop through the selected files in the list...
613        Wave/T fileWave=$"root:myGlobals:RAW2ASCII:fileWave"
614        Wave sel=$"root:myGlobals:RAW2ASCII:selWave"
615        Variable num=numpnts(sel),ii=0,qxqy=0,detCoord=0,GraspASCII=0
616        String fname="",pathStr="",fullPath="",newFileName=""
617       
618        PathInfo catPathName                    //this is where the files are
619        pathStr=S_path
620       
621        //what type of export?
622        // check0 is det coord, check1 is QxQy, check2 is old-style VAX ASCII for Grasp
623        ControlInfo check0
624        detCoord=V_Value                //==1 if detCoord desired
625        ControlInfo check1
626        qxqy=V_Value            //==1 if qxqy desired
627        ControlInfo check2
628        GraspASCII=V_Value              //==1 if GraspASCII desired
629       
630        // get the current state
631        NVAR defaultScaling = root:Packages:NIST:gLogScalingAsDefault
632        Variable oldState = defaultScaling
633        defaultScaling = 0              //set the scaling to linear
634        do
635                if(sel[ii] == 1)
636                        fname=pathStr + FindValidFilename(fileWave[ii])         //in case of VAX version numbers
637                        ReadHeaderAndData(fname)                //fname is the full path
638                        String/G root:myGlobals:gDataDisplayType="RAW" 
639                        fRawWindowHook()
640                        WAVE/T/Z tw = $"root:Packages:NIST:RAW:textRead"        //to be sure that wave exists if no data was ever displayed
641                        newFileName= GetNameFromHeader(tw[0])
642                       
643                        if(qxqy)
644                                fullPath=pathStr+newFileName+".DAT"
645                                QxQy_Export("RAW",fullpath,0)
646                        endif
647                        if(detCoord)
648                                fullPath=pathStr+newFileName+".ASC"
649                                Fast2dExport("RAW",fullpath,0)
650                        endif
651                        if(GraspASCII)
652                                fullPath=pathStr+newFileName+".GSP"
653                                Fast2dExport_OldStyle("RAW",fullpath,0)
654                        endif
655                endif
656                ii+=1
657        while(ii<num)
658       
659        defaultScaling = oldState               //set the scaling back to what it was
660        return(0)
661End
662
663Function ShowRawExportHelp(ctrlName) : ButtonControl
664        String ctrlName
665        DisplayHelpTopic/Z/K=1 "SANS Data Reduction Tutorial[2-D ASCII Export]"
666        if(V_flag !=0)
667                DoAlert 0,"The SANS Data Reduction Tutorial Help file could not be found"
668        endif
669end
Note: See TracBrowser for help on using the repository browser.