| 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) |
|---|
| 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 /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 |
|---|
| 78 | EndMacro |
|---|
| 79 | |
|---|
| 80 | Function 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 |
|---|
| 86 | end |
|---|
| 87 | |
|---|
| 88 | Function 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) |
|---|
| 96 | End |
|---|
| 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 |
|---|
| 103 | Function 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:myGlobals: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 | //maybe don't tile or stack 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 | // Print totalNumPNGs |
|---|
| 184 | if(totalNumPNGs>12) |
|---|
| 185 | rcStr="/A=(5,4)" |
|---|
| 186 | endif |
|---|
| 187 | if(totalNumPNGs>20) |
|---|
| 188 | rcStr="/A=(7,5)" |
|---|
| 189 | endif |
|---|
| 190 | if(totalNumPNGs>35) |
|---|
| 191 | rcStr="/A=(8,5)" |
|---|
| 192 | endif |
|---|
| 193 | if(totalNumPNGs>40) |
|---|
| 194 | rcStr="" |
|---|
| 195 | endif |
|---|
| 196 | Execute "Tile"+rcStr+"/O=8" |
|---|
| 197 | |
|---|
| 198 | defaultScaling = oldState //set the scaling back to the previous state |
|---|
| 199 | return(0) |
|---|
| 200 | End |
|---|
| 201 | |
|---|
| 202 | // upon hitting the "add to layout" button... |
|---|
| 203 | // loads all of the data files in the list |
|---|
| 204 | // file into RAW folder, and makes a PNG of the file, and appends each to the selected layout |
|---|
| 205 | // ...see SetGraphic() in Schematic.ipf |
|---|
| 206 | // This test version will add 40 images to each layout, and tile them |
|---|
| 207 | // |
|---|
| 208 | Function AddALLToLayout(ctrlName) : 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:Packages:NIST:"+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:Packages:NIST:"+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:Packages:NIST: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 |
|---|