source: sans/Dev/trunk/NCNR_Igor_Procedures/NCNR_Package_Loader.ipf @ 828

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

adding some loaders to the macros menu - strictly for testing so that some of the newest procedures can be easily tested.

File size: 12.8 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion=6.1
3
4// load/unload courtesy of Jan Ilavsky
5// June 2008
6
7// - SRK Oct 2008
8// rather than deleting the macros, it is preferable to simply hide the appropriate panels.
9// deleting the ipf files will break dependencies, leave panels hanging open without
10// their associated procedures, etc.
11
12// names of everything have been changed so I won't clash with Jan's code
13//
14//
15// - make this an independent module in case of bad compilation...
16
17
18Menu "Macros"
19        StrVarOrDefault("root:Packages:NCNRItemStr1a","Load NCNR Analysis Macros"), NCNR_AnalysisLoader(StrVarOrDefault("root:Packages:NCNRItemStr1a","Load NCNR Analysis Macros"))
20        StrVarOrDefault("root:Packages:NCNRItemStr1b","-"), NCNR_AnalysisLoader(StrVarOrDefault("root:Packages:NCNRItemStr1b","-"))
21
22        StrVarOrDefault("root:Packages:NCNRItemStr2a","Load NCNR SANS Reduction Macros"), NCNR_SANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr2a","Load NCNR SANS Reduction Macros"))
23        StrVarOrDefault("root:Packages:NCNRItemStr2b","-"), NCNR_SANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr2b","-"))
24
25        StrVarOrDefault("root:Packages:NCNRItemStr3a","Load NCNR USANS Reduction Macros"), NCNR_USANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr3a","Load NCNR USANS Reduction Macros"))
26        StrVarOrDefault("root:Packages:NCNRItemStr3b","-"), NCNR_USANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr3b","-"))
27       
28        StrVarOrDefault("root:Packages:NCNRItemStr4a","Load NCNR SANS Live Data"), NCNR_SANSLiveLoader(StrVarOrDefault("root:Packages:NCNRItemStr4a","Load NCNR SANS Live Data"))
29        StrVarOrDefault("root:Packages:NCNRItemStr4b","-"), NCNR_SANSLiveLoader(StrVarOrDefault("root:Packages:NCNRItemStr4b","-"))
30
31        // for testing ONLY
32        "-"
33        "Load Polarization Reduction",Execute/P "INSERTINCLUDE \"Include_Polarization\"";Execute/P "COMPILEPROCEDURES "
34
35        "Load Batch Fitting",Execute/P "INSERTINCLUDE \"Auto_Fit\"";Execute/P "COMPILEPROCEDURES ";Execute/P "InitializeAutoFitPanel()"
36
37        "Load Real Space Modeling",Execute/P "INSERTINCLUDE \"FFT_Cubes_Includes\"";Execute/P "INSERTINCLUDE \"FFT_Fit_Includes\"";Execute/P "COMPILEPROCEDURES ";Execute/P "Init_FFT()"
38        "-"
39
40end
41
42Function NCNR_AnalysisLoader(itemStr)
43        String itemStr
44               
45        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.1)
46                Abort "Your version of Igor is lower than 6.1, these macros need version 6.1 or higher.... "
47        endif
48       
49        NewDataFolder/O root:Packages           //create the folder for string variable
50        String/G root:Packages:NCNRItemStr1a = itemStr
51        String/G root:Packages:NCNRItemStr1b = itemStr
52        SVAR gMenuStr1a = root:Packages:NCNRItemStr1a
53        SVAR gMenuStr1b = root:Packages:NCNRItemStr1b
54       
55        String SANSAna_WinList = "wrapperPanel;Procedure_List;Report;Plot_Manager;A_FitPanel;A_FitWindow;Sum_Model_Panel;"
56        SANSAna_WinList += "NewGlobalFitPanel;SimpGFPanel;Invariant_Panel;invariant_graph;"
57        strswitch(itemStr)      // string switch
58                case "Load NCNR Analysis Macros":       
59                        Execute/P "INSERTINCLUDE \"SA_Includes_v410\""
60                        Execute/P "INSERTINCLUDE \"PlotUtilsMacro_v40\""
61                        Execute/P "INSERTINCLUDE \"GaussUtils_v40\""
62                        Execute/P "INSERTINCLUDE \"WriteModelData_v40\""
63                        Execute/P "INSERTINCLUDE \"USANS_SlitSmearing_v40\""
64                        Execute/P "INSERTINCLUDE \"SANSModelPicker_v40\""
65                        Execute/P "COMPILEPROCEDURES "
66                        Execute/P ("Init_WrapperPanel()")
67                        Execute/P ("ModelPicker_Panel()")
68                        Execute/P ("DoIgorMenu \"Control\" \"Retrieve All Windows\"")
69               
70                        gMenuStr1a = "Hide NCNR Analysis Macros"
71//                      gMenuStr1b = "Unload NCNR Analysis Macros"
72                        gMenuStr1b = "-"
73                        BuildMenu "Macros"
74                       
75                        break                                           
76                case "Unload NCNR Analysis Macros":     
77                // very dangerous - don't really want to implement this because it will surely crash
78                        Execute/P "DELETEINCLUDE \"SA_Includes_v410\""
79                        Execute/P "DELETEINCLUDE \"PlotUtilsMacro_v40\""
80                        Execute/P "DELETEINCLUDE \"GaussUtils_v40\""
81                        Execute/P "DELETEINCLUDE \"WriteModelData_v40\""
82                        Execute/P "DELETEINCLUDE \"USANS_SlitSmearing_v40\""
83                        Execute/P "DELETEINCLUDE \"SANSModelPicker_v40\""
84                        Execute/P "COMPILEPROCEDURES "
85                        DoWindow wrapperPanel
86                        if(V_Flag)
87                                DoWindow/K wrapperPanel
88                        endif
89                        DoWindow Procedure_List
90                        If(V_Flag)
91                                DoWindow/K Procedure_List
92                        endif
93
94                        gMenuStr1a = "Load NCNR Analysis Macros"
95                        gMenuStr1b = "-"
96                       
97                        BuildMenu "Macros"
98                       
99                        break
100                case "Hide NCNR Analysis Macros":       
101                        HideShowWindowsInList(SANSAna_WinList,1)       
102               
103                        gMenuStr1a = "Show NCNR Analysis Macros"
104//                      gMenuStr1b = "Unload NCNR Analysis Macros"
105                        gMenuStr1b = "-"
106                        BuildMenu "Macros"
107                       
108                        break
109                case "Show NCNR Analysis Macros":
110                        HideShowWindowsInList(SANSAna_WinList,0)       
111               
112                        gMenuStr1a = "Hide NCNR Analysis Macros"
113//                      gMenuStr1b = "Unload NCNR Analysis Macros"
114                        gMenuStr1b = "-"
115                        BuildMenu "Macros"
116                       
117                        break
118                default:
119                        Abort "Invalid Menu Selection"
120        endswitch
121
122end
123
124
125// now add for the SANS Reduction
126Function NCNR_SANSReductionLoader(itemStr)
127        String itemStr
128       
129        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.1)
130                Abort "Your version of Igor is lower than 6.1, these macros need version 6.1 or higher.... "
131        endif
132       
133        NewDataFolder/O root:Packages           //create the folder for string variable
134        String/G root:Packages:NCNRItemStr2a = itemStr
135        String/G root:Packages:NCNRItemStr2b = itemStr
136        SVAR gMenuStr2a = root:Packages:NCNRItemStr2a
137        SVAR gMenuStr2b = root:Packages:NCNRItemStr2b
138       
139        String SANSRed_WinList = "Main_Panel;CatVSTable;SANS_Data;Plot_Manager;Average_Panel;Plot_1d;CatWin;Surface_3D;FitPanel;FitWindow;"
140        SANSRed_WinList += "FitRPAPanel;SANS_Histo;drawMaskWin;Multiple_Reduce_Panel;NSORT_Panel;NSORT_Graph;CombineTable;ToCombine;Patch_Panel;"
141        SANSRed_WinList += "ProtocolPanel;Schematic_Layout;Tile_2D;RAW_to_ASCII;Trans_Panel;TransFileTable;ScatterFileTable;Convert_to_Trans;"
142        SANSRed_WinList += "WorkFileMath;Pref_Panel;Subtract_1D_Panel;Plot_Sub1D;SASCALC;MC_SASCALC;Saved_Configurations;TISANE;Sim_1D_Panel;"
143        SANSRed_WinList += "Trial_Configuration;Saved_Configurations;DataArithmeticPanel;DAPlotPanel;"
144        strswitch(itemStr)      // string switch
145                case "Load NCNR SANS Reduction Macros":
146                        Execute/P "INSERTINCLUDE \"Includes_v520\""
147                        Execute/P "COMPILEPROCEDURES "
148                        Execute/P ("Initialize()")
149                        Execute/P ("DoIgorMenu \"Control\" \"Retrieve All Windows\"")
150
151                        gMenuStr2a = "Hide NCNR SANS Reduction Macros"
152//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
153                        gMenuStr2b = "-"
154                        BuildMenu "Macros"
155                       
156                        break                                           
157                case "Unload NCNR SANS Reduction Macros":       
158                // very dangerous - don't really want to implement this because it will surely crash
159                        Execute/P "DELETEINCLUDE \"Includes_v520\""
160                        Execute/P "COMPILEPROCEDURES "
161                        DoWindow Main_Panel
162                        if(V_Flag)
163                                DoWindow/K Main_Panel
164                        endif
165
166                        gMenuStr2a = "Load NCNR SANS Reduction Macros"
167                        gMenuStr2b = "-"
168                       
169                        BuildMenu "Macros"
170                       
171                        break
172                case "Hide NCNR SANS Reduction Macros":
173                        HideShowWindowsInList(SANSRed_WinList,1)
174               
175                        gMenuStr2a = "Show NCNR SANS Reduction Macros"
176//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
177                        gMenuStr2b = "-"
178                        BuildMenu "Macros"
179                       
180                        break
181                case "Show NCNR SANS Reduction Macros":
182                        HideShowWindowsInList(SANSRed_WinList,0)
183               
184                        gMenuStr2a = "Hide NCNR SANS Reduction Macros"
185//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
186                        gMenuStr2b = "-"
187                        BuildMenu "Macros"
188                       
189                        break
190                default:
191                        Abort "Invalid Menu Selection"
192        endswitch
193
194end
195
196// now add for the SANS Reduction
197Function NCNR_USANSReductionLoader(itemStr)
198        String itemStr
199       
200        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.1)
201                Abort "Your version of Igor is lower than 6.1, these macros need version 6.1 or higher.... "
202        endif
203       
204        NewDataFolder/O root:Packages           //create the folder for string variable
205        String/G root:Packages:NCNRItemStr3a = itemStr
206        String/G root:Packages:NCNRItemStr3b = itemStr
207        SVAR gMenuStr3a = root:Packages:NCNRItemStr3a
208        SVAR gMenuStr3b = root:Packages:NCNRItemStr3b
209       
210        String USANS_WinList = "USANS_Panel;COR_Graph;RawDataWin;Desmear_Graph;USANS_Slope;UCALC;"
211       
212        strswitch(itemStr)      // string switch
213                case "Load NCNR USANS Reduction Macros":       
214                        Execute/P "INSERTINCLUDE \"USANS_Includes_v230\""
215                        Execute/P "COMPILEPROCEDURES "
216                        Execute/P ("ShowUSANSPanel()")
217                        Execute/P ("DoIgorMenu \"Control\" \"Retrieve All Windows\"")
218
219                        gMenuStr3a = "Hide NCNR USANS Reduction Macros"
220//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
221                        gMenuStr3b = "-"
222                        BuildMenu "Macros"
223                       
224                        break                                           
225                case "Unload NCNR USANS Reduction Macros":     
226                // very dangerous - don't really want to implement this because it will surely crash
227                        Execute/P "DELETEINCLUDE \"USANS_Includes_v230\""
228                        Execute/P "COMPILEPROCEDURES "
229                        DoWindow USANS_Panel
230                        if(V_Flag)
231                                DoWindow/K USANS_Panel
232                        endif
233
234                        gMenuStr3a = "Load NCNR USANS Reduction Macros"
235                        gMenuStr3b = "-"
236                       
237                        BuildMenu "Macros"
238                       
239                        break
240                case "Hide NCNR USANS Reduction Macros":       
241                        HideShowWindowsInList(USANS_WinList,1) 
242               
243                        gMenuStr3a = "Show NCNR USANS Reduction Macros"
244//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
245                        gMenuStr3b = "-"
246                        BuildMenu "Macros"
247                       
248                        break
249                case "Show NCNR USANS Reduction Macros":
250                        HideShowWindowsInList(USANS_WinList,0) 
251                       
252                        gMenuStr3a = "Hide NCNR USANS Reduction Macros"
253//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
254                        gMenuStr3b = "-"
255                        BuildMenu "Macros"
256                       
257                        break
258                default:
259                        Abort "Invalid Menu Selection"
260        endswitch
261       
262end
263
264// 1 = hide, 0 = show
265Function HideShowWindowsInList(list,hide)
266        String list
267        Variable hide
268       
269        String item
270        Variable ii,num=ItemsinList(list)
271        for(ii=0;ii<num;ii+=1)
272                item = StringFromList(ii, list , ";")
273                DoWindow $item
274                if(V_Flag)
275                        DoWindow/HIDE=(hide) $item
276                endif
277        endfor
278        return(0)
279End
280
281// now add for the SANS Live
282Function NCNR_SANSLiveLoader(itemStr)
283        String itemStr
284       
285        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.1)
286                Abort "Your version of Igor is lower than 6.1, these macros need version 6.1 or higher.... "
287        endif
288       
289        NewDataFolder/O root:Packages           //create the folder for string variable
290        String/G root:Packages:NCNRItemStr4a = itemStr
291        String/G root:Packages:NCNRItemStr4b = itemStr
292        SVAR gMenuStr4a = root:Packages:NCNRItemStr4a
293        SVAR gMenuStr4b = root:Packages:NCNRItemStr4b
294       
295        String SANSLive_WinList = "RT_Panel;SANS_Data;"
296        //SANSLive_WinList += "FitRPAPanel;SANS_Histo;drawMaskWin;Multiple_Reduce_Panel;NSORT_Panel;NSORT_Graph;CombineTable;ToCombine;Patch_Panel;"
297        //SANSLive_WinList += "ProtocolPanel;Schematic_Layout;Tile_2D;RAW_to_ASCII;Trans_Panel;TransFileTable;ScatterFileTable;Convert_to_Trans;"
298        //SANSLive_WinList += "WorkFileMath;Pref_Panel;Subtract_1D_Panel;Plot_Sub1D;SASCALC;MC_SASCALC;Saved_Configurations;TISANE;"
299        strswitch(itemStr)      // string switch
300                case "Load NCNR SANS Live Data":       
301                        Execute/P "INSERTINCLUDE \"Includes_v520\""
302                        Execute/P "COMPILEPROCEDURES "
303                        Execute/P ("Init_for_RealTime()")
304               
305                        gMenuStr4a = "Hide NCNR SANS Live Data"
306//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
307                        gMenuStr4b = "-"
308                        BuildMenu "Macros"
309                       
310                        break                                           
311                case "Unload NCNR SANS Live Data":     
312                // very dangerous - don't really want to implement this because it will surely crash
313                        Execute/P "DELETEINCLUDE \"Includes_v520\""
314                        Execute/P "COMPILEPROCEDURES "
315                        DoWindow Main_Panel
316                        if(V_Flag)
317                                DoWindow/K Main_Panel
318                        endif
319
320                        gMenuStr4a = "Load NCNR SANS Live Data"
321                        gMenuStr4b = "-"
322                       
323                        BuildMenu "Macros"
324                       
325                        break
326                case "Hide NCNR SANS Live Data":
327                        HideShowWindowsInList(SANSLive_WinList,1)
328               
329                        gMenuStr4a = "Show NCNR SANS Reduction Macros"
330//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
331                        gMenuStr4b = "-"
332                        BuildMenu "Macros"
333                       
334                        break
335                case "Show NCNR SANS Reduction Macros":
336                        HideShowWindowsInList(SANSLive_WinList,0)
337               
338                        gMenuStr4a = "Hide NCNR SANS Reduction Macros"
339//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
340                        gMenuStr4b = "-"
341                        BuildMenu "Macros"
342                       
343                        break
344                default:
345                        Abort "Invalid Menu Selection"
346        endswitch
347
348end
349
350Function WhatSymbolsAreDefined()
351
352#if (exists("QUOKKA")==6)
353                print "function QUOKKA defined"
354#else
355                print "function QUOKKA NOT defined"
356#endif
357       
358#if(exists("HFIR")==6)
359                print "function HFIR defined"
360#else
361                print "function HFIR NOT defined"
362#endif
363       
364#if(exists("ILL_D22")==6)
365                print "function ILL_D22 defined"
366#else
367                print "function ILL_D22 NOT defined"
368#endif
369
370
371
372// for a lot of reasons, defined symbols do not work
373// mostly, the procedures are compiled before the symbols are
374// defined (or re-defined)
375// another issues is that they are persistent, and  don't disappear
376// until Igor is quit.
377       
378//      SetIgorOption poundDefine=QUOKKA?
379//      if(V_flag)
380//              print "QUOKKA defined"
381//      else
382//              print "QUOKKA NOT defined"
383//      endif
384//     
385//      SetIgorOption poundDefine=HFIR?
386//      if(V_flag)
387//              print "HFIR defined"
388//      else
389//              print "HFIR NOT defined"
390//      endif
391//     
392//      SetIgorOption poundDefine=ILL_D22?
393//      if(V_flag)
394//              print "ILL_D22 defined"
395//      else
396//              print "ILL_D22 NOT defined"
397//      endif
398
399        return(0)
400End
401
402Proc ClearDefinedSymbols()
403        SetIgorOption poundUnDefine=QUOKKA
404        SetIgorOption poundUnDefine=HFIR
405        SetIgorOption poundUnDefine=ILL_D22
406End
Note: See TracBrowser for help on using the repository browser.