source: sans/Dev/trunk/NCNR_User_Procedures/Common/NCNR_Package_Loader.ipf @ 601

Last change on this file since 601 was 588, checked in by srkline, 13 years ago

Added conditional compile instructions to some reduction procedure files that have only minor facility-specific changes. These changes are not significant enough to merit a separate facility file that must be maintained with essentially duplicate functions.

#define SYMBOL was attempted, but did not work since the symbols weren't actually defined until after the compile... and I couldn't figure out how to define - then compile. in additon, the table is static until Igor is quit - so multiple symbols could be defined, and compiling would fail.

So... the method now that appears to work is to put a dummy function for each facility in its facility specific "Includes" file. Then the conditional compilation checks for exists("function").

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