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

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

More fixes for the installer to properly copy the files in, and date stamp them when they are moved out so that there are no overwrite issues when the installer is run multiple times. NCNR_Package_Loader is explicitly closed to be sure that it is not opened multiple times (even though it was moved).

Package loader now runs Retrieve Windows from the Igor menu after initialization, to bring all windows on-screen.

File size: 12.5 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                        Execute/P ("DoIgorMenu \"Control\" \"Retrieve All Windows\"")
60               
61                        gMenuStr1a = "Hide NCNR Analysis Macros"
62//                      gMenuStr1b = "Unload NCNR Analysis Macros"
63                        gMenuStr1b = "-"
64                        BuildMenu "Macros"
65                       
66                        break                                           
67                case "Unload NCNR Analysis Macros":     
68                // very dangerous - don't really want to implement this because it will surely crash
69                        Execute/P "DELETEINCLUDE \"SA_Includes_v400\""
70                        Execute/P "DELETEINCLUDE \"PlotUtilsMacro_v40\""
71                        Execute/P "DELETEINCLUDE \"GaussUtils_v40\""
72                        Execute/P "DELETEINCLUDE \"WriteModelData_v40\""
73                        Execute/P "DELETEINCLUDE \"USANS_SlitSmearing_v40\""
74                        Execute/P "DELETEINCLUDE \"SANSModelPicker_v40\""
75                        Execute/P "COMPILEPROCEDURES "
76                        DoWindow wrapperPanel
77                        if(V_Flag)
78                                DoWindow/K wrapperPanel
79                        endif
80                        DoWindow Procedure_List
81                        If(V_Flag)
82                                DoWindow/K Procedure_List
83                        endif
84
85                        gMenuStr1a = "Load NCNR Analysis Macros"
86                        gMenuStr1b = "-"
87                       
88                        BuildMenu "Macros"
89                       
90                        break
91                case "Hide NCNR Analysis Macros":       
92                        HideShowWindowsInList(SANSAna_WinList,1)       
93               
94                        gMenuStr1a = "Show NCNR Analysis Macros"
95//                      gMenuStr1b = "Unload NCNR Analysis Macros"
96                        gMenuStr1b = "-"
97                        BuildMenu "Macros"
98                       
99                        break
100                case "Show NCNR Analysis Macros":
101                        HideShowWindowsInList(SANSAna_WinList,0)       
102               
103                        gMenuStr1a = "Hide NCNR Analysis Macros"
104//                      gMenuStr1b = "Unload NCNR Analysis Macros"
105                        gMenuStr1b = "-"
106                        BuildMenu "Macros"
107                       
108                        break
109                default:
110                        Abort "Invalid Menu Selection"
111        endswitch
112
113end
114
115
116// now add for the SANS Reduction
117Function NCNR_SANSReductionLoader(itemStr)
118        String itemStr
119       
120        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.02)
121                Abort "Your version of Igor is lower than 6.02, these macros need version 6.02 or higher.... "
122        endif
123       
124        NewDataFolder/O root:Packages           //create the folder for string variable
125        String/G root:Packages:NCNRItemStr2a = itemStr
126        String/G root:Packages:NCNRItemStr2b = itemStr
127        SVAR gMenuStr2a = root:Packages:NCNRItemStr2a
128        SVAR gMenuStr2b = root:Packages:NCNRItemStr2b
129       
130        String SANSRed_WinList = "Main_Panel;CatVSTable;SANS_Data;Plot_Manager;Average_Panel;Plot_1d;CatWin;Surface_3D;FitPanel;FitWindow;"
131        SANSRed_WinList += "FitRPAPanel;SANS_Histo;drawMaskWin;Multiple_Reduce_Panel;NSORT_Panel;NSORT_Graph;CombineTable;ToCombine;Patch_Panel;"
132        SANSRed_WinList += "ProtocolPanel;Schematic_Layout;Tile_2D;RAW_to_ASCII;Trans_Panel;TransFileTable;ScatterFileTable;Convert_to_Trans;"
133        SANSRed_WinList += "WorkFileMath;Pref_Panel;Subtract_1D_Panel;Plot_Sub1D;SASCALC;MC_SASCALC;Saved_Configurations;TISANE;Sim_1D_Panel;"
134        SANSRed_WinList += "Trial_Configuration;Saved_Configurations;DataArithmeticPanel;DAPlotPanel;"
135        strswitch(itemStr)      // string switch
136                case "Load NCNR SANS Reduction Macros":
137                        Execute/P "INSERTINCLUDE \"Includes_v520\""
138                        Execute/P "COMPILEPROCEDURES "
139                        Execute/P ("Initialize()")
140                        Execute/P ("DoIgorMenu \"Control\" \"Retrieve All Windows\"")
141
142                        gMenuStr2a = "Hide NCNR SANS Reduction Macros"
143//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
144                        gMenuStr2b = "-"
145                        BuildMenu "Macros"
146                       
147                        break                                           
148                case "Unload NCNR SANS Reduction Macros":       
149                // very dangerous - don't really want to implement this because it will surely crash
150                        Execute/P "DELETEINCLUDE \"Includes_v520\""
151                        Execute/P "COMPILEPROCEDURES "
152                        DoWindow Main_Panel
153                        if(V_Flag)
154                                DoWindow/K Main_Panel
155                        endif
156
157                        gMenuStr2a = "Load NCNR SANS Reduction Macros"
158                        gMenuStr2b = "-"
159                       
160                        BuildMenu "Macros"
161                       
162                        break
163                case "Hide NCNR SANS Reduction Macros":
164                        HideShowWindowsInList(SANSRed_WinList,1)
165               
166                        gMenuStr2a = "Show NCNR SANS Reduction Macros"
167//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
168                        gMenuStr2b = "-"
169                        BuildMenu "Macros"
170                       
171                        break
172                case "Show NCNR SANS Reduction Macros":
173                        HideShowWindowsInList(SANSRed_WinList,0)
174               
175                        gMenuStr2a = "Hide NCNR SANS Reduction Macros"
176//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
177                        gMenuStr2b = "-"
178                        BuildMenu "Macros"
179                       
180                        break
181                default:
182                        Abort "Invalid Menu Selection"
183        endswitch
184
185end
186
187// now add for the SANS Reduction
188Function NCNR_USANSReductionLoader(itemStr)
189        String itemStr
190       
191        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.02)
192                Abort "Your version of Igor is lower than 6.02, these macros need version 6.02 or higher.... "
193        endif
194       
195        NewDataFolder/O root:Packages           //create the folder for string variable
196        String/G root:Packages:NCNRItemStr3a = itemStr
197        String/G root:Packages:NCNRItemStr3b = itemStr
198        SVAR gMenuStr3a = root:Packages:NCNRItemStr3a
199        SVAR gMenuStr3b = root:Packages:NCNRItemStr3b
200       
201        String USANS_WinList = "USANS_Panel;COR_Graph;RawDataWin;Desmear_Graph;USANS_Slope;UCALC;"
202       
203        strswitch(itemStr)      // string switch
204                case "Load NCNR USANS Reduction Macros":       
205                        Execute/P "INSERTINCLUDE \"USANS_Includes\""
206                        Execute/P "COMPILEPROCEDURES "
207                        Execute/P ("ShowUSANSPanel()")
208                        Execute/P ("DoIgorMenu \"Control\" \"Retrieve All Windows\"")
209
210                        gMenuStr3a = "Hide NCNR USANS Reduction Macros"
211//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
212                        gMenuStr3b = "-"
213                        BuildMenu "Macros"
214                       
215                        break                                           
216                case "Unload NCNR USANS Reduction Macros":     
217                // very dangerous - don't really want to implement this because it will surely crash
218                        Execute/P "DELETEINCLUDE \"USANS_Includes\""
219                        Execute/P "COMPILEPROCEDURES "
220                        DoWindow USANS_Panel
221                        if(V_Flag)
222                                DoWindow/K USANS_Panel
223                        endif
224
225                        gMenuStr3a = "Load NCNR USANS Reduction Macros"
226                        gMenuStr3b = "-"
227                       
228                        BuildMenu "Macros"
229                       
230                        break
231                case "Hide NCNR USANS Reduction Macros":       
232                        HideShowWindowsInList(USANS_WinList,1) 
233               
234                        gMenuStr3a = "Show NCNR USANS Reduction Macros"
235//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
236                        gMenuStr3b = "-"
237                        BuildMenu "Macros"
238                       
239                        break
240                case "Show NCNR USANS Reduction Macros":
241                        HideShowWindowsInList(USANS_WinList,0) 
242                       
243                        gMenuStr3a = "Hide NCNR USANS Reduction Macros"
244//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
245                        gMenuStr3b = "-"
246                        BuildMenu "Macros"
247                       
248                        break
249                default:
250                        Abort "Invalid Menu Selection"
251        endswitch
252       
253end
254
255// 1 = hide, 0 = show
256Function HideShowWindowsInList(list,hide)
257        String list
258        Variable hide
259       
260        String item
261        Variable ii,num=ItemsinList(list)
262        for(ii=0;ii<num;ii+=1)
263                item = StringFromList(ii, list , ";")
264                DoWindow $item
265                if(V_Flag)
266                        DoWindow/HIDE=(hide) $item
267                endif
268        endfor
269        return(0)
270End
271
272// now add for the SANS Live
273Function NCNR_SANSLiveLoader(itemStr)
274        String itemStr
275       
276        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.02)
277                Abort "Your version of Igor is lower than 6.02, these macros need version 6.02 or higher.... "
278        endif
279       
280        NewDataFolder/O root:Packages           //create the folder for string variable
281        String/G root:Packages:NCNRItemStr4a = itemStr
282        String/G root:Packages:NCNRItemStr4b = itemStr
283        SVAR gMenuStr4a = root:Packages:NCNRItemStr4a
284        SVAR gMenuStr4b = root:Packages:NCNRItemStr4b
285       
286        String SANSLive_WinList = "RT_Panel;SANS_Data;"
287        //SANSLive_WinList += "FitRPAPanel;SANS_Histo;drawMaskWin;Multiple_Reduce_Panel;NSORT_Panel;NSORT_Graph;CombineTable;ToCombine;Patch_Panel;"
288        //SANSLive_WinList += "ProtocolPanel;Schematic_Layout;Tile_2D;RAW_to_ASCII;Trans_Panel;TransFileTable;ScatterFileTable;Convert_to_Trans;"
289        //SANSLive_WinList += "WorkFileMath;Pref_Panel;Subtract_1D_Panel;Plot_Sub1D;SASCALC;MC_SASCALC;Saved_Configurations;TISANE;"
290        strswitch(itemStr)      // string switch
291                case "Load NCNR SANS Live Data":       
292                        Execute/P "INSERTINCLUDE \"Includes_v520\""
293                        Execute/P "COMPILEPROCEDURES "
294                        Execute/P ("Init_for_RealTime()")
295               
296                        gMenuStr4a = "Hide NCNR SANS Live Data"
297//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
298                        gMenuStr4b = "-"
299                        BuildMenu "Macros"
300                       
301                        break                                           
302                case "Unload NCNR SANS Live Data":     
303                // very dangerous - don't really want to implement this because it will surely crash
304                        Execute/P "DELETEINCLUDE \"Includes_v520\""
305                        Execute/P "COMPILEPROCEDURES "
306                        DoWindow Main_Panel
307                        if(V_Flag)
308                                DoWindow/K Main_Panel
309                        endif
310
311                        gMenuStr4a = "Load NCNR SANS Live Data"
312                        gMenuStr4b = "-"
313                       
314                        BuildMenu "Macros"
315                       
316                        break
317                case "Hide NCNR SANS Live Data":
318                        HideShowWindowsInList(SANSLive_WinList,1)
319               
320                        gMenuStr4a = "Show NCNR SANS Reduction Macros"
321//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
322                        gMenuStr4b = "-"
323                        BuildMenu "Macros"
324                       
325                        break
326                case "Show NCNR SANS Reduction Macros":
327                        HideShowWindowsInList(SANSLive_WinList,0)
328               
329                        gMenuStr4a = "Hide NCNR SANS Reduction Macros"
330//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
331                        gMenuStr4b = "-"
332                        BuildMenu "Macros"
333                       
334                        break
335                default:
336                        Abort "Invalid Menu Selection"
337        endswitch
338
339end
340
341Function WhatSymbolsAreDefined()
342
343#if (exists("QUOKKA")==6)
344                print "function QUOKKA defined"
345#else
346                print "function QUOKKA NOT defined"
347#endif
348       
349#if(exists("HFIR")==6)
350                print "function HFIR defined"
351#else
352                print "function HFIR NOT defined"
353#endif
354       
355#if(exists("ILL_D22")==6)
356                print "function ILL_D22 defined"
357#else
358                print "function ILL_D22 NOT defined"
359#endif
360
361
362
363// for a lot of reasons, defined symbols do not work
364// mostly, the procedures are compiled before the symbols are
365// defined (or re-defined)
366// another issues is that they are persistent, and  don't disappear
367// until Igor is quit.
368       
369//      SetIgorOption poundDefine=QUOKKA?
370//      if(V_flag)
371//              print "QUOKKA defined"
372//      else
373//              print "QUOKKA NOT defined"
374//      endif
375//     
376//      SetIgorOption poundDefine=HFIR?
377//      if(V_flag)
378//              print "HFIR defined"
379//      else
380//              print "HFIR NOT defined"
381//      endif
382//     
383//      SetIgorOption poundDefine=ILL_D22?
384//      if(V_flag)
385//              print "ILL_D22 defined"
386//      else
387//              print "ILL_D22 NOT defined"
388//      endif
389
390        return(0)
391End
392
393Proc ClearDefinedSymbols()
394        SetIgorOption poundUnDefine=QUOKKA
395        SetIgorOption poundUnDefine=HFIR
396        SetIgorOption poundUnDefine=ILL_D22
397End
Note: See TracBrowser for help on using the repository browser.