1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma IgorVersion=6.0 |
---|
3 | #pragma version=3.00 |
---|
4 | |
---|
5 | //************************ |
---|
6 | // |
---|
7 | // Utility procedure to allow the user to select exactly which fitting |
---|
8 | // functions they wish to include in their experiment. Smearing and plotting |
---|
9 | // procedures are automatically included |
---|
10 | // |
---|
11 | // Functions are now in "SANS Models" Menu, with submenus for |
---|
12 | // smeared/unsmeared functions |
---|
13 | // |
---|
14 | // this change was prompted due to the 31 item limitation of Windows submenus |
---|
15 | // resulting in functions being unavailable in the curve fitting dialog |
---|
16 | // |
---|
17 | // A built-in list of procedure files is included, and should match the current |
---|
18 | // distribution package -- see the procedure asdf() for instructions on how |
---|
19 | // to update the built-in list of procedures |
---|
20 | // |
---|
21 | // SRK 091801 |
---|
22 | // |
---|
23 | // Updated for easier use 02 JUL 04 SRK |
---|
24 | // |
---|
25 | // SRK 16DEC05 added utility function to get the list of all functions |
---|
26 | // first - select and include all of the models |
---|
27 | // -- Proc GetAllModelFunctions() |
---|
28 | // |
---|
29 | // SEE TypeNewModelList() for instructions on how to permanently add new model |
---|
30 | // functions to the list... (APR 06 SRK) |
---|
31 | // |
---|
32 | // added Freeze Model - to duplicate a model function/strip the dependency |
---|
33 | // and plot it on the top graph - so that parameters can be changed... |
---|
34 | // SRK 09 JUN 2006 |
---|
35 | // |
---|
36 | //*************************** |
---|
37 | |
---|
38 | // main procedure for invoking the Procedure list panel |
---|
39 | // initializes each time to make sure |
---|
40 | Proc ModelPicker_Panel() |
---|
41 | |
---|
42 | Variable/G root:SANS_ANA_VERSION=3.00 |
---|
43 | |
---|
44 | DoWindow/F Procedure_List |
---|
45 | if(V_Flag==0) |
---|
46 | Init_FileList() |
---|
47 | Procedure_List() |
---|
48 | endif |
---|
49 | End |
---|
50 | |
---|
51 | // initialization procedure to create the necessary data folder and the waves for |
---|
52 | // the list box in the panel |
---|
53 | Proc Init_FileList() |
---|
54 | //create the data folders and globals |
---|
55 | NewDataFolder/O root:myGlobals //others will need this...make it just in case |
---|
56 | |
---|
57 | if(!DataFolderExists("root:myGlobals:FileList")) |
---|
58 | NewDataFolder/O/S root:myGlobals:FileList |
---|
59 | //create the waves |
---|
60 | Make/O/T/N=0 fileWave,includedFileWave |
---|
61 | Make/O/N=0 selWave,selToDelWave |
---|
62 | // String/G allFiles="" |
---|
63 | String/G MenuItemStr1="" |
---|
64 | String/G MenuItemStr2="" |
---|
65 | //DON'T create MenuItemStr_def |
---|
66 | |
---|
67 | // a switch for me to turn off file checking |
---|
68 | Variable/G checkForFiles=1 //set to true initially |
---|
69 | checkForFiles = !(stringmatch(ParseFilePath(0,SpecialDirPath("Desktop",0,0,0),":",1,1),"s*ine")) //zero for me |
---|
70 | |
---|
71 | //fill the list of procedures |
---|
72 | // |
---|
73 | // first time, create wave from built-in list |
---|
74 | FileList_BuiltInList() //makes sure that the wave exists |
---|
75 | FileList_GetListButtonProc("") //converts it into a list for the panel |
---|
76 | |
---|
77 | // "include" nothing to force a load of the utility procedures |
---|
78 | FileList_InsertButtonProc("") |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | SetDataFolder root: |
---|
83 | Endif |
---|
84 | End |
---|
85 | |
---|
86 | |
---|
87 | // for my own testing to read in a new list of procedures |
---|
88 | // FileList_GetListButtonProc("") will only read in a new list |
---|
89 | // if the wave SANS_Model_List does not exist |
---|
90 | Proc ReadNewProcList() |
---|
91 | KillWaves/Z root:myGlobals:FileList:SANS_Model_List //kill the old list |
---|
92 | FileList_GetListButtonProc("") |
---|
93 | End |
---|
94 | |
---|
95 | // To create a new "Built-in" list of procedures, edit the |
---|
96 | // wave SANS_Model_List (a text wave), adding your new procedure names |
---|
97 | // (sort alphabetically if desired) |
---|
98 | // then use TypeNewModelList() to spit out the text format. |
---|
99 | // then paste this list into FileList_BuiltInList |
---|
100 | // |
---|
101 | // note that you won't have help for these new procedures until |
---|
102 | // you update the function documentation, making the name of the procedure |
---|
103 | // file a Subtopic |
---|
104 | // |
---|
105 | Proc TypeNewModelList() |
---|
106 | variable ii=0,num=numpnts(root:myGlobals:FileList:SANS_Model_List) |
---|
107 | printf "Make/O/T/N/=%d SANS_Model_List\r\r",num |
---|
108 | do |
---|
109 | printf "SANS_Model_List[%d] = \"%s\"\r",ii,root:myGlobals:FileList:SANS_Model_List[ii] |
---|
110 | ii+=1 |
---|
111 | while(ii<num) |
---|
112 | End |
---|
113 | |
---|
114 | Proc FileList_BuiltInList() |
---|
115 | SetDataFolder root:myGlobals:FileList |
---|
116 | |
---|
117 | ////paste here... after deleting the old make statement and list |
---|
118 | |
---|
119 | Make/O/T/N=62 SANS_Model_List |
---|
120 | |
---|
121 | SANS_Model_List[0] = "Beaucage.ipf" |
---|
122 | SANS_Model_List[1] = "BE_Polyelectrolyte.ipf" |
---|
123 | SANS_Model_List[2] = "BimodalSchulzSpheres.ipf" |
---|
124 | SANS_Model_List[3] = "BinaryHardSpheres.ipf" |
---|
125 | SANS_Model_List[4] = "CoreShell.ipf" |
---|
126 | SANS_Model_List[5] = "CoreShellCylinder.ipf" |
---|
127 | SANS_Model_List[6] = "CoreShell_and_Struct.ipf" |
---|
128 | SANS_Model_List[7] = "CylinderForm.ipf" |
---|
129 | SANS_Model_List[8] = "Cylinder_and_Struct.ipf" |
---|
130 | SANS_Model_List[9] = "Cylinder_PolyLength.ipf" |
---|
131 | SANS_Model_List[10] = "Cylinder_PolyRadius.ipf" |
---|
132 | SANS_Model_List[11] = "DAB_model.ipf" |
---|
133 | SANS_Model_List[12] = "Debye.ipf" |
---|
134 | SANS_Model_List[13] = "EllipticalCylinder.ipf" |
---|
135 | SANS_Model_List[14] = "FlexCyl_EllipCross.ipf" |
---|
136 | SANS_Model_List[15] = "FlexCyl_PolyLen.ipf" |
---|
137 | SANS_Model_List[16] = "FlexCyl_PolyRadius.ipf" |
---|
138 | SANS_Model_List[17] = "FlexibleCylinder.ipf" |
---|
139 | SANS_Model_List[18] = "Fractal.ipf" |
---|
140 | SANS_Model_List[19] = "GaussSpheres.ipf" |
---|
141 | SANS_Model_List[20] = "GaussSpheres_and_Struct.ipf" |
---|
142 | SANS_Model_List[21] = "HardSphereStruct.ipf" |
---|
143 | SANS_Model_List[22] = "HollowCylinders.ipf" |
---|
144 | SANS_Model_List[23] = "HPMSA.ipf" |
---|
145 | SANS_Model_List[24] = "LamellarFF.ipf" |
---|
146 | SANS_Model_List[25] = "LamellarFF_HG.ipf" |
---|
147 | SANS_Model_List[26] = "LamellarPS.ipf" |
---|
148 | SANS_Model_List[27] = "LamellarPS_HG.ipf" |
---|
149 | SANS_Model_List[28] = "LogNormalSphere.ipf" |
---|
150 | SANS_Model_List[29] = "LogNormSpheres_and_Struct.ipf" |
---|
151 | SANS_Model_List[30] = "Lorentz_model.ipf" |
---|
152 | SANS_Model_List[31] = "MultiShell.ipf" |
---|
153 | SANS_Model_List[32] = "OblateCS_and_Struct.ipf" |
---|
154 | SANS_Model_List[33] = "OblateForm.ipf" |
---|
155 | SANS_Model_List[34] = "Parallelepiped.ipf" |
---|
156 | SANS_Model_List[35] = "Peak_Gauss_model.ipf" |
---|
157 | SANS_Model_List[36] = "Peak_Lorentz_model.ipf" |
---|
158 | SANS_Model_List[37] = "PolyCore.ipf" |
---|
159 | SANS_Model_List[38] = "PolyCoreShellCylinder.ipf" |
---|
160 | SANS_Model_List[39] = "PolyCoreShellRatio.ipf" |
---|
161 | SANS_Model_List[40] = "PolyCore_and_Struct.ipf" |
---|
162 | SANS_Model_List[41] = "PolyCSRatio_and_Struct.ipf" |
---|
163 | SANS_Model_List[42] = "PolyHardSphereInten.ipf" |
---|
164 | SANS_Model_List[43] = "PolyRectSphere_and_Struct.ipf" |
---|
165 | SANS_Model_List[44] = "Power_Law_model.ipf" |
---|
166 | SANS_Model_List[45] = "ProlateCS_and_Struct.ipf" |
---|
167 | SANS_Model_List[46] = "ProlateForm.ipf" |
---|
168 | SANS_Model_List[47] = "RectPolySpheres.ipf" |
---|
169 | SANS_Model_List[48] = "SchulzSpheres.ipf" |
---|
170 | SANS_Model_List[49] = "SchulzSpheres_and_Struct.ipf" |
---|
171 | SANS_Model_List[50] = "SmearedRPA.ipf" |
---|
172 | SANS_Model_List[51] = "Sphere.ipf" |
---|
173 | SANS_Model_List[52] = "Sphere_and_Struct.ipf" |
---|
174 | SANS_Model_List[53] = "SquareWellStruct.ipf" |
---|
175 | SANS_Model_List[54] = "StackedDiscs.ipf" |
---|
176 | SANS_Model_List[55] = "StickyHardSphereStruct.ipf" |
---|
177 | SANS_Model_List[56] = "Teubner.ipf" |
---|
178 | SANS_Model_List[57] = "TriaxialEllipsoid.ipf" |
---|
179 | SANS_Model_List[58] = "UnifEllipsoid_and_Struct.ipf" |
---|
180 | SANS_Model_List[59] = "UniformEllipsoid.ipf" |
---|
181 | SANS_Model_List[60] = "Vesicle_UL.ipf" |
---|
182 | SANS_Model_List[61] = "Vesicle_UL_and_Struct.ipf" |
---|
183 | |
---|
184 | ///end paste here |
---|
185 | End |
---|
186 | |
---|
187 | //another way to add a single procedure name to the list |
---|
188 | // (only in the current experiment!) |
---|
189 | // not a permanent add to the template, unless you re-save the |
---|
190 | // template |
---|
191 | Proc AddProcedureToList(ProcedureName) |
---|
192 | String ProcedureName |
---|
193 | |
---|
194 | SetDataFolder root:myGlobals:FileList |
---|
195 | Variable num |
---|
196 | num=numpnts(fileWave) |
---|
197 | Redimension/N=(num+1) fileWave |
---|
198 | fileWave[num] = ProcedureName |
---|
199 | num=numpnts(selWave) |
---|
200 | Redimension/N=(num+1) selWave |
---|
201 | selWave[num] = 0 |
---|
202 | |
---|
203 | SetDataFolder root: |
---|
204 | End |
---|
205 | ///////////////////////////////////////////////////////////// |
---|
206 | |
---|
207 | |
---|
208 | Proc doCheck(val) |
---|
209 | Variable val |
---|
210 | // a switch for me to turn off file checking |
---|
211 | root:myGlobals:FileList:checkForFiles=val //0==no check, 1=check |
---|
212 | End |
---|
213 | |
---|
214 | |
---|
215 | //Function MakeMenu_ButtonProc(ctrlName) : ButtonControl |
---|
216 | // String ctrlName |
---|
217 | |
---|
218 | // RefreshMenu() |
---|
219 | //End |
---|
220 | |
---|
221 | //procedure for drawing the simple panel to pick and compile selected models |
---|
222 | // |
---|
223 | Proc Procedure_List() |
---|
224 | PauseUpdate; Silent 1 // building window... |
---|
225 | NewPanel /W=(1115,44,1453,363) /K=2 |
---|
226 | DoWindow/C Procedure_List |
---|
227 | ModifyPanel fixedSize=1 |
---|
228 | |
---|
229 | ListBox fileList,pos={4,3},size={200,203},listWave=root:myGlobals:FileList:fileWave |
---|
230 | ListBox fileList,selWave=root:myGlobals:FileList:selWave,mode= 4 |
---|
231 | ListBox inclList,pos={4,212},size={200,100} |
---|
232 | ListBox inclList,listWave=root:myGlobals:FileList:includedFileWave |
---|
233 | ListBox inclList,selWave=root:myGlobals:FileList:selToDelWave,mode= 4 |
---|
234 | Button button0,pos={212,173},size={110,20},proc=FileList_InsertButtonProc,title="Include File(s)" |
---|
235 | Button button0,help={"Includes the selected procedures, functions appear under the SANS Models menu"} |
---|
236 | Button button5,pos={212,283},size={110,20},proc=FileList_RemoveButtonProc,title="Remove File(s)" |
---|
237 | Button button5,help={"Removes selected procedures from the experiment"} |
---|
238 | Button PickerButton,pos={212,14},size={90,20},proc=FileList_HelpButtonProc,title="Help" |
---|
239 | Button PickerButton,help={"If you need help understanding what a help button does, you really need help"} |
---|
240 | Button button1,pos={212,37},size={100,20},proc=FileList_HelpButtonProc,title="Function Help" |
---|
241 | Button button1,help={"If you need help understanding what a help button does, you really need help"} |
---|
242 | GroupBox group0,pos={203,128},size={46,11},title="Select model functions" |
---|
243 | GroupBox group0_1,pos={203,145},size={46,11},title="to include" |
---|
244 | EndMacro |
---|
245 | |
---|
246 | |
---|
247 | //button function to prompt user to select path where procedures are located |
---|
248 | Function FL_PickButtonProc(ctrlName) : ButtonControl |
---|
249 | String ctrlName |
---|
250 | |
---|
251 | PickProcPath() |
---|
252 | End |
---|
253 | |
---|
254 | //bring the help notebook to the front |
---|
255 | Function FileList_HelpButtonProc(ctrlName) : ButtonControl |
---|
256 | String ctrlName |
---|
257 | |
---|
258 | if(cmpstr(ctrlName,"PickerButton")==0) //PickerButton is the picker help |
---|
259 | DisplayHelpTopic "SANS Model Picker" |
---|
260 | return(0) |
---|
261 | endif |
---|
262 | |
---|
263 | //otherwise, show the help for the selected function |
---|
264 | //loop through the selected files in the list... |
---|
265 | // |
---|
266 | Wave/T fileWave=$"root:myGlobals:FileList:fileWave" |
---|
267 | Wave sel=$"root:myGlobals:FileList:selWave" |
---|
268 | |
---|
269 | Variable num=numpnts(sel),ii |
---|
270 | String fname="" |
---|
271 | |
---|
272 | // NVAR doCheck=root:myGlobals:FileList:checkForFiles |
---|
273 | ii=num-1 //work bottom-up to not lose the index |
---|
274 | do |
---|
275 | if(sel[ii] == 1) |
---|
276 | fname = fileWave[ii] //RemoveExten(fileWave[ii]) |
---|
277 | endif |
---|
278 | ii-=1 |
---|
279 | while(ii>=0) |
---|
280 | |
---|
281 | // nothing selected in the list to include, |
---|
282 | //try the list of already-included files |
---|
283 | if(cmpstr(fname,"")==0) |
---|
284 | Wave/T inclFileWave=$"root:myGlobals:FileList:includedFileWave" |
---|
285 | Wave seltoDel=$"root:myGlobals:FileList:selToDelWave" |
---|
286 | num=numpnts(seltoDel) |
---|
287 | ii=num-1 //work bottom-up to not lose the index |
---|
288 | do |
---|
289 | if(seltoDel[ii] == 1) |
---|
290 | fname = inclFileWave[ii] //RemoveExten(fileWave[ii]) |
---|
291 | endif |
---|
292 | ii-=1 |
---|
293 | while(ii>=0) |
---|
294 | endif |
---|
295 | |
---|
296 | if(cmpstr(fname,"")!=0) |
---|
297 | // Print "show help for ",RemoveExten(fname) |
---|
298 | // Print fname[strlen(fname)-11,strlen(fname)-1] |
---|
299 | if(cmpstr(fname[strlen(fname)-11,strlen(fname)-1],"_Struct.ipf") ==0 ) |
---|
300 | DisplayHelpTopic "How Form Factors and Structure Factors are Combined" |
---|
301 | else |
---|
302 | DisplayHelpTopic fname |
---|
303 | endif |
---|
304 | else |
---|
305 | DoAlert 0,"Please select a function from the list to display its help file" |
---|
306 | endif |
---|
307 | |
---|
308 | return(0) |
---|
309 | End |
---|
310 | |
---|
311 | //closes the panel when done |
---|
312 | Function FileListDoneButtonProc(ctrlName) : ButtonControl |
---|
313 | String ctrlName |
---|
314 | |
---|
315 | //kill the panel |
---|
316 | DoWindow/K Procedure_List |
---|
317 | return(0) |
---|
318 | End |
---|
319 | |
---|
320 | //reads in the list of procedures |
---|
321 | // (in practice, the list will be part of the experiment) |
---|
322 | // but this can be used to easily update the list if |
---|
323 | // new models are added, or if a custom list is desired |
---|
324 | // - these lists could also be stored in the template |
---|
325 | // |
---|
326 | Function FileList_GetListButtonProc(ctrlName) : ButtonControl |
---|
327 | String ctrlName |
---|
328 | |
---|
329 | String list="" |
---|
330 | |
---|
331 | if(Exists("root:myGlobals:FileList:SANS_Model_List") != 1) |
---|
332 | SetDataFolder root:myGlobals:FileList |
---|
333 | LoadWave/A/T |
---|
334 | WAVE/T w=$(StringFromList(0,S_WaveNames,";")) |
---|
335 | SetDataFolder root: |
---|
336 | else |
---|
337 | WAVE/T w=$("root:myGlobals:FileList:SANS_Model_List") |
---|
338 | endif |
---|
339 | |
---|
340 | // // convert the input wave to a semi-list |
---|
341 | // SVAR allFiles=root:myGlobals:FileList:allFiles |
---|
342 | // allFiles=MP_TextWave2SemiList(w) |
---|
343 | list=MP_TextWave2SemiList(w) |
---|
344 | |
---|
345 | //get the list of available files from the specified path |
---|
346 | String newList="",item="" |
---|
347 | Variable num=ItemsInList(list,";"),ii |
---|
348 | |
---|
349 | // remove the items that have already been included |
---|
350 | Wave/T includedFileWave=$"root:myGlobals:FileList:includedFileWave" |
---|
351 | Variable numInc=numpnts(includedFileWave) |
---|
352 | for(ii=0;ii<numInc;ii+=1) |
---|
353 | list = RemoveFromList(includedFileWave[ii],list,";") |
---|
354 | endfor |
---|
355 | list = SortList(list,";",0) |
---|
356 | num=ItemsInList(list,";") |
---|
357 | WAVE/T fileWave=$"root:myGlobals:FileList:fileWave" |
---|
358 | WAVE selWave=$"root:myGlobals:FileList:selWave" |
---|
359 | Redimension/N=(num) fileWave //make the waves the proper length |
---|
360 | Redimension/N=(num) selWave |
---|
361 | fileWave = StringFromList(p,list,";") //converts the list to a wave |
---|
362 | Sort filewave,filewave |
---|
363 | |
---|
364 | return(0) |
---|
365 | End |
---|
366 | |
---|
367 | //*******OLD WAY******* |
---|
368 | //*******NOT USED******* |
---|
369 | //gets the list of files in the folder specified by procPathName |
---|
370 | //filters the list to remove some of the procedures that the user does not need to see |
---|
371 | // list is assigned to textbox wave |
---|
372 | Function OLD_FileList_GetListButtonProc(ctrlName) : ButtonControl |
---|
373 | String ctrlName |
---|
374 | |
---|
375 | //make sure that path exists |
---|
376 | PathInfo procPathName |
---|
377 | if (V_flag == 0) |
---|
378 | //Abort "Folder path does not exist - use Pick Path button to set path" |
---|
379 | //build the path to the User Procedures folder |
---|
380 | PathInfo Igor |
---|
381 | // Print S_Path |
---|
382 | String UserProcStr=S_path+"User Procedures:" |
---|
383 | NewPath/O/Q procPathName UserProcStr |
---|
384 | Endif |
---|
385 | |
---|
386 | String list="" |
---|
387 | // list=IndexedFile(procPathName,-1,"????") |
---|
388 | |
---|
389 | // new way, to catch all files in all subfolders |
---|
390 | SVAR allFiles=root:myGlobals:FileList:allFiles |
---|
391 | allFiles="" //clear the list |
---|
392 | |
---|
393 | ListAllFilesAndFolders("procPathName",1,1,0) //this sets allFiles |
---|
394 | list = allFiles |
---|
395 | |
---|
396 | //get the list of available files from the specified path |
---|
397 | |
---|
398 | String newList="",item="" |
---|
399 | Variable num=ItemsInList(list,";"),ii |
---|
400 | //remove procedures from the list the are unrelated, or may be loaded by default (Utils) |
---|
401 | list = RemoveFromList(".DS_Store",list,";") //occurs on OSX, not "hidden" to Igor |
---|
402 | list = RemoveFromList("GaussUtils.ipf",list,";" ) |
---|
403 | list = RemoveFromList("PlotUtils.ipf",list,";" ) |
---|
404 | list = RemoveFromList("PlotUtilsMacro.ipf",list,";" ) |
---|
405 | list = RemoveFromList("WriteModelData.ipf",list,";" ) |
---|
406 | list = RemoveFromList("WMMenus.ipf",list,";" ) |
---|
407 | list = RemoveFromList("DemoLoader.ipf",list,";" ) |
---|
408 | // remove the items that have already been included |
---|
409 | Wave/T includedFileWave=$"root:myGlobals:FileList:includedFileWave" |
---|
410 | Variable numInc=numpnts(includedFileWave) |
---|
411 | for(ii=0;ii<numInc;ii+=1) |
---|
412 | list = RemoveFromList(includedFileWave[ii],list,";") |
---|
413 | endfor |
---|
414 | list = SortList(list,";",0) |
---|
415 | num=ItemsInList(list,";") |
---|
416 | WAVE/T fileWave=$"root:myGlobals:FileList:fileWave" |
---|
417 | WAVE selWave=$"root:myGlobals:FileList:selWave" |
---|
418 | Redimension/N=(num) fileWave //make the waves the proper length |
---|
419 | Redimension/N=(num) selWave |
---|
420 | fileWave = StringFromList(p,list,";") //converts the list to a wave |
---|
421 | Sort filewave,filewave |
---|
422 | End |
---|
423 | |
---|
424 | // returns 1 if the file exists, 0 if the file is not there |
---|
425 | // fails miserably if there are aliases in the UP folder, although |
---|
426 | // the #include doesn't mind |
---|
427 | Function CheckFileInUPFolder(fileStr) |
---|
428 | String fileStr |
---|
429 | |
---|
430 | Variable err=0 |
---|
431 | String/G root:myGlobals:FileList:allFiles="" |
---|
432 | SVAR allFiles = root:myGlobals:FileList:allFiles |
---|
433 | |
---|
434 | PathInfo Igor |
---|
435 | String UPStr=S_path+"User Procedures:" |
---|
436 | NewPath /O/Q/Z UPPath ,UPStr |
---|
437 | ListAllFilesAndFolders("UPPath",1,1,0) //this sets allFiles |
---|
438 | String list = allFiles |
---|
439 | // err = FindListItem(fileStr, list ,";" ,0) |
---|
440 | err = strsearch(list, fileStr, 0,2) //this is not case-sensitive, but Igor 5! |
---|
441 | // err = strsearch(list, fileStr, 0) //this is Igor 4+ compatible |
---|
442 | // Print err |
---|
443 | if(err == -1) |
---|
444 | return(0) |
---|
445 | else |
---|
446 | return(1) //name was found somewhere |
---|
447 | endif |
---|
448 | End |
---|
449 | |
---|
450 | |
---|
451 | Function FileList_InsertButtonProc(ctrlName) : ButtonControl |
---|
452 | String ctrlName |
---|
453 | |
---|
454 | //loop through the selected files in the list... |
---|
455 | Wave/T fileWave=$"root:myGlobals:FileList:fileWave" |
---|
456 | Wave sel=$"root:myGlobals:FileList:selWave" |
---|
457 | //and adjust the included file lists |
---|
458 | Wave/T includedFileWave=$"root:myGlobals:FileList:includedFileWave" |
---|
459 | Wave selToDel=$"root:myGlobals:FileList:selToDelWave" |
---|
460 | |
---|
461 | Variable numIncl=numpnts(includedFileWave) |
---|
462 | Variable num=numpnts(sel),ii,ok |
---|
463 | String fname="" |
---|
464 | |
---|
465 | //Necessary for every analysis experiment |
---|
466 | Execute/P "INSERTINCLUDE \"PlotUtilsMacro\"" |
---|
467 | Execute/P "INSERTINCLUDE \"GaussUtils\"" |
---|
468 | Execute/P "INSERTINCLUDE \"WriteModelData\"" |
---|
469 | |
---|
470 | NVAR doCheck=root:myGlobals:FileList:checkForFiles |
---|
471 | |
---|
472 | ii=num-1 //work bottom-up to not lose the index |
---|
473 | do |
---|
474 | if(sel[ii] == 1) |
---|
475 | //can I make sure the file exists before trying to include it? |
---|
476 | if(doCheck) |
---|
477 | ok = CheckFileInUPFolder(fileWave[ii]) |
---|
478 | endif |
---|
479 | if(ok || !doCheck) |
---|
480 | fname = RemoveExten(fileWave[ii]) |
---|
481 | Execute/P "INSERTINCLUDE \""+fname+"\"" |
---|
482 | // add to the already included list, and remove from the to-include list (and selWaves also) |
---|
483 | InsertPoints numpnts(includedFileWave), 1, includedFileWave,selToDel |
---|
484 | includedFileWave[numpnts(includedFileWave)-1]=fileWave[ii] |
---|
485 | |
---|
486 | DeletePoints ii, 1, fileWave,sel |
---|
487 | else |
---|
488 | DoAlert 0,"File "+fileWave[ii]+" was not found in the User Procedures folder, so it was not included" |
---|
489 | endif |
---|
490 | endif |
---|
491 | ii-=1 |
---|
492 | while(ii>=0) |
---|
493 | // Execute/P "COMPILEPROCEDURES ";Execute/P/Q/Z "RefreshMenu()" |
---|
494 | Execute/P "COMPILEPROCEDURES " |
---|
495 | |
---|
496 | sel=0 //clear the selections |
---|
497 | selToDel=0 |
---|
498 | |
---|
499 | return(0) |
---|
500 | End |
---|
501 | |
---|
502 | Function FileList_RemoveButtonProc(ctrlName) : ButtonControl |
---|
503 | String ctrlName |
---|
504 | |
---|
505 | //loop through the selected files in the list... |
---|
506 | Wave/T includedFileWave=$"root:myGlobals:FileList:includedFileWave" |
---|
507 | Wave selToDel=$"root:myGlobals:FileList:selToDelWave" |
---|
508 | // and put the unwanted procedures back in the to-add list |
---|
509 | Wave/T fileWave=$"root:myGlobals:FileList:fileWave" |
---|
510 | Wave sel=$"root:myGlobals:FileList:selWave" |
---|
511 | |
---|
512 | |
---|
513 | Variable num=numpnts(selToDel),ii |
---|
514 | String fname="" |
---|
515 | |
---|
516 | ii=num-1 //work backwards |
---|
517 | do |
---|
518 | if(selToDel[ii] == 1) |
---|
519 | fname = RemoveExten(includedFileWave[ii]) |
---|
520 | Execute/P "DELETEINCLUDE \""+fname+"\"" |
---|
521 | //add to the to-include list |
---|
522 | InsertPoints numpnts(fileWave), 1, fileWave,sel |
---|
523 | fileWave[numpnts(fileWave)-1]=includedFileWave[ii] |
---|
524 | //delete the point |
---|
525 | DeletePoints ii, 1, includedFileWave,selToDel |
---|
526 | endif |
---|
527 | ii-=1 |
---|
528 | while(ii>=0) |
---|
529 | // Execute/P "COMPILEPROCEDURES ";Execute/P/Q/Z "RefreshMenu()" |
---|
530 | Execute/P "COMPILEPROCEDURES " |
---|
531 | |
---|
532 | sel=0 |
---|
533 | selToDel=0 |
---|
534 | |
---|
535 | Sort filewave,filewave |
---|
536 | return(0) |
---|
537 | End |
---|
538 | |
---|
539 | |
---|
540 | //removes ANY ".ext" extension from the name |
---|
541 | // - wipes out all after the "dot" |
---|
542 | // - procedure files to be included (using quotes) must be in User Procedures folder |
---|
543 | // and end in .ipf? |
---|
544 | Function/S RemoveExten(str) |
---|
545 | String str |
---|
546 | |
---|
547 | Variable loc=0 |
---|
548 | String tempStr="" |
---|
549 | |
---|
550 | loc=strsearch(str,".",0) |
---|
551 | tempStr=str[0,loc-1] |
---|
552 | return(tempStr) |
---|
553 | End |
---|
554 | |
---|
555 | // function to have user select the path where the procedure files are |
---|
556 | // - the selected path is set as procPathName |
---|
557 | // |
---|
558 | // setting the path to "igor" does not seem to have the desired effect of |
---|
559 | // bringing up the Igor Pro folder in the NewPath Dialog |
---|
560 | // |
---|
561 | //may also be able to use folder lists on HD - for more sophisticated listings |
---|
562 | Function PickProcPath() |
---|
563 | |
---|
564 | //set the global string to the selected pathname |
---|
565 | PathInfo/S Igor |
---|
566 | |
---|
567 | NewPath/O/M="pick the SANS Procedure folder" procPathName |
---|
568 | return(0) //no error |
---|
569 | End |
---|
570 | |
---|
571 | |
---|
572 | //my menu, seemingly one item, but really a long string for each submenu |
---|
573 | // if root:MenuItemStr exists |
---|
574 | //Menu "SANS Models" |
---|
575 | // StrVarOrDefault("root:myGlobals:FileList:MenuItemStr_def","ModelPicker_Panel")//, RefreshMenu() |
---|
576 | // SubMenu "Unsmeared Models" |
---|
577 | // StrVarOrDefault("root:myGlobals:FileList:MenuItemStr1","ModelPicker_Panel") |
---|
578 | // End |
---|
579 | // SubMenu "Smeared Models" |
---|
580 | // StrVarOrDefault("root:myGlobals:FileList:MenuItemStr2","ModelPicker_Panel") |
---|
581 | // End |
---|
582 | // SubMenu "Models 3" |
---|
583 | // StrVarOrDefault("root:MenuItemStr3","ModelPicker_Panel") |
---|
584 | // End |
---|
585 | //End |
---|
586 | |
---|
587 | //wrapper to use the A_ prepended file loader from the dynamically defined menu |
---|
588 | //Proc LoadSANSorUSANSData() |
---|
589 | // A_LoadOneDData() |
---|
590 | //End |
---|
591 | |
---|
592 | //// tweaked to find RPA model which has an extra parameter in the declaration |
---|
593 | //Function RefreshMenu() |
---|
594 | // |
---|
595 | // String list="",sep=";" |
---|
596 | // |
---|
597 | // //list = "Refresh Menu"+sep+"ModelPicker_Panel"+sep+"-"+sep |
---|
598 | // list = "ModelPicker_Panel"+sep+"-"+sep |
---|
599 | //// list += MacroList("LoadO*",sep,"KIND:1,NPARAMS:0") //data loader |
---|
600 | // list += "Load SANS or USANS Data;" //use the wrapper above to get the right loader |
---|
601 | //// list += "Reset Resolution Waves;" // resets the resolution waves used for the calculations |
---|
602 | //// list += "Freeze Model;" // freeze a model to compare plots on the same graph |
---|
603 | // list += MacroList("WriteM*",sep,"KIND:1,NPARAMS:4") //data writer |
---|
604 | // list += "-"+sep |
---|
605 | // String/G root:myGlobals:FileList:MenuItemStr_def = TrimListTo255(list) |
---|
606 | // |
---|
607 | // list = "" |
---|
608 | // list += MacroList("*",sep,"KIND:1,NPARAMS:3") //unsmeared plot procedures |
---|
609 | // list += MacroList("Plot*",sep,"KIND:1,NPARAMS:4") //RPA has 4 parameters |
---|
610 | // list = RemoveFromList("FreezeModel", list ,";") // remove FreezeModel, it's not a model |
---|
611 | // // list += "-"+sep |
---|
612 | // String/G root:myGlobals:FileList:MenuItemStr1 = TrimListTo255(list) |
---|
613 | // |
---|
614 | // list="" |
---|
615 | // list += MacroList("PlotSmea*",sep,"KIND:1,NPARAMS:1") //smeared plot procedures |
---|
616 | // list += MacroList("PlotSmea*",sep,"KIND:1,NPARAMS:2") //smeared RPA has 2 parameters |
---|
617 | // String/G root:myGlobals:FileList:MenuItemStr2 = TrimListTo255(list) |
---|
618 | // |
---|
619 | // BuildMenu "SANS Models" |
---|
620 | // |
---|
621 | // return(0) |
---|
622 | //End |
---|
623 | |
---|
624 | //if the length of any of the strings is more than 255, the menu will disappear |
---|
625 | Function/S TrimListTo255(list) |
---|
626 | String list |
---|
627 | |
---|
628 | Variable len,num |
---|
629 | num = itemsinlist(list,";") |
---|
630 | len = strlen(list) |
---|
631 | if(len>255) |
---|
632 | DoAlert 0, "Not all menu items are shown - remove some of the models" |
---|
633 | do |
---|
634 | list = RemoveListItem(num-1, list ,";" ) |
---|
635 | len=strlen(list) |
---|
636 | num=itemsinlist(list,";") |
---|
637 | while(len>255) |
---|
638 | endif |
---|
639 | return(list) |
---|
640 | End |
---|
641 | |
---|
642 | Function/S MP_TextWave2SemiList(textW) |
---|
643 | Wave/T textW |
---|
644 | |
---|
645 | String list="" |
---|
646 | Variable num=numpnts(textW),ii=0 |
---|
647 | do |
---|
648 | list += textw[ii] + ";" |
---|
649 | ii+=1 |
---|
650 | while(ii<num) |
---|
651 | return(list) |
---|
652 | End |
---|
653 | |
---|
654 | Function MP_SemiList2TextWave(list,outWStr) |
---|
655 | String list,outWStr |
---|
656 | |
---|
657 | Variable num=itemsinList(list) |
---|
658 | Make/T/O/N=(num) $outWStr |
---|
659 | WAVE/T w=$outWStr |
---|
660 | w = StringFromList(p,list,";") |
---|
661 | return(0) |
---|
662 | End |
---|
663 | |
---|
664 | //modified to get a list of all files in folder and subfolders |
---|
665 | // passed back through a global variable |
---|
666 | Function ListAllFilesAndFolders(pathName, full, recurse, level) |
---|
667 | String pathName // Name of symbolic path in which to look for folders. |
---|
668 | Variable full // True to print full paths instead of just folder name. |
---|
669 | Variable recurse // True to recurse (do it for subfolders too). |
---|
670 | Variable level // Recursion level. Pass 0 for the top level. |
---|
671 | |
---|
672 | Variable ii |
---|
673 | String prefix |
---|
674 | |
---|
675 | SVAR allFiles=root:myGlobals:FileList:allFiles |
---|
676 | // Build a prefix (a number of tabs to indicate the folder level by indentation) |
---|
677 | prefix = "" |
---|
678 | ii = 0 |
---|
679 | do |
---|
680 | if (ii >= level) |
---|
681 | break |
---|
682 | endif |
---|
683 | prefix += "\t" // Indent one more tab |
---|
684 | ii += 1 |
---|
685 | while(1) |
---|
686 | |
---|
687 | // Printf "%s%s\r", prefix, pathName |
---|
688 | // Print IndexedFile($pathName,-1,"????") |
---|
689 | allFiles += IndexedFile($pathName,-1,"????") |
---|
690 | |
---|
691 | String path |
---|
692 | ii = 0 |
---|
693 | do |
---|
694 | path = IndexedDir($pathName, ii, full) |
---|
695 | if (strlen(path) == 0) |
---|
696 | break // No more folders |
---|
697 | endif |
---|
698 | // Printf "%s%s\r", prefix, path |
---|
699 | |
---|
700 | if (recurse) // Do we want to go into subfolder? |
---|
701 | String subFolderPathName = "tempPrintFoldersPath_" + num2istr(level+1) |
---|
702 | |
---|
703 | // Now we get the path to the new parent folder |
---|
704 | String subFolderPath |
---|
705 | if (full) |
---|
706 | subFolderPath = path // We already have the full path. |
---|
707 | else |
---|
708 | PathInfo $pathName // We have only the folder name. Need to get full path. |
---|
709 | subFolderPath = S_path + path |
---|
710 | endif |
---|
711 | |
---|
712 | NewPath/Q/O $subFolderPathName, subFolderPath |
---|
713 | ListAllFilesAndFolders(subFolderPathName, full, recurse, level+1) |
---|
714 | KillPath/Z $subFolderPathName |
---|
715 | endif |
---|
716 | |
---|
717 | ii += 1 |
---|
718 | while(1) |
---|
719 | End |
---|
720 | |
---|
721 | |
---|
722 | // utility function to get the list of all functions |
---|
723 | // first - select and include all of the models |
---|
724 | // |
---|
725 | Proc GetAllModelFunctions() |
---|
726 | String str = FunctionList("*",";","KIND:10,NINDVARS:1") |
---|
727 | Print itemsinList(str) |
---|
728 | |
---|
729 | MP_SemiList2TextWave(str,"UserFunctionList") |
---|
730 | edit UserFunctionList |
---|
731 | end |
---|
732 | |
---|
733 | // allows an easy way to "freeze" a model calculation |
---|
734 | // - duplicates X and Y waves (tags them _q and _i) |
---|
735 | // - kill the dependecy |
---|
736 | // - append it to the top graph |
---|
737 | // - it can later be exported with WriteModelData |
---|
738 | // |
---|
739 | // in Igor 5, you can restrict the WaveList to be just the top graph... |
---|
740 | // SRK 09 JUN 2006 |
---|
741 | // |
---|
742 | Proc FreezeModel(xWave,yWave,newNameStr) |
---|
743 | String xWave,yWave,newNameStr |
---|
744 | Prompt xwave,"X data",popup,WaveList("*",";","") |
---|
745 | Prompt ywave,"y data",popup,WaveList("*",";","") |
---|
746 | Prompt newNameStr,"new name for the waves, _q and _i will be appended" |
---|
747 | |
---|
748 | Duplicate/O $xwave,$(newNameStr+"_q") |
---|
749 | Duplicate/O $ywave,$(newNameStr+"_i") |
---|
750 | SetFormula $(newNameStr+"_i"), "" |
---|
751 | |
---|
752 | AppendToGraph $(newNameStr+"_i") vs $(newNameStr+"_q") |
---|
753 | |
---|
754 | End |
---|