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