1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | |
---|
3 | // load/unload courtesy of Jan Ilavsky |
---|
4 | // June 2008 |
---|
5 | |
---|
6 | // - SRK Oct 2008 |
---|
7 | // rather than deleting the macros, it is preferable to simply hide the appropriate panels. |
---|
8 | // deleting the ipf files will break dependencies, leave panels hanging open without |
---|
9 | // their associated procedures, etc. |
---|
10 | |
---|
11 | // names of everything have been changed so I won't clash with Jan's code |
---|
12 | // |
---|
13 | // |
---|
14 | // - make this an independent module in case of bad compilation... |
---|
15 | |
---|
16 | |
---|
17 | Menu "Macros" |
---|
18 | StrVarOrDefault("root:Packages:NCNRItemStr1a","Load NCNR Analysis Macros"), NCNR_AnalysisLoader(StrVarOrDefault("root:Packages:NCNRItemStr1a","Load NCNR Analysis Macros")) |
---|
19 | StrVarOrDefault("root:Packages:NCNRItemStr1b","-"), NCNR_AnalysisLoader(StrVarOrDefault("root:Packages:NCNRItemStr1b","-")) |
---|
20 | |
---|
21 | StrVarOrDefault("root:Packages:NCNRItemStr2a","Load NCNR SANS Reduction Macros"), NCNR_SANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr2a","Load NCNR SANS Reduction Macros")) |
---|
22 | StrVarOrDefault("root:Packages:NCNRItemStr2b","-"), NCNR_SANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr2b","-")) |
---|
23 | |
---|
24 | StrVarOrDefault("root:Packages:NCNRItemStr3a","Load NCNR USANS Reduction Macros"), NCNR_USANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr3a","Load NCNR USANS Reduction Macros")) |
---|
25 | StrVarOrDefault("root:Packages:NCNRItemStr3b","-"), NCNR_USANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr3b","-")) |
---|
26 | end |
---|
27 | |
---|
28 | Function NCNR_AnalysisLoader(itemStr) |
---|
29 | String itemStr |
---|
30 | |
---|
31 | if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.02) |
---|
32 | Abort "Your version of Igor is lower than 6.02, these macros need version 6.02 or higher.... " |
---|
33 | endif |
---|
34 | |
---|
35 | NewDataFolder/O root:Packages //create the folder for string variable |
---|
36 | String/G root:Packages:NCNRItemStr1a = itemStr |
---|
37 | String/G root:Packages:NCNRItemStr1b = itemStr |
---|
38 | SVAR gMenuStr1a = root:Packages:NCNRItemStr1a |
---|
39 | SVAR gMenuStr1b = root:Packages:NCNRItemStr1b |
---|
40 | |
---|
41 | String SANSAna_WinList = "wrapperPanel;Procedure_List;" |
---|
42 | strswitch(itemStr) // string switch |
---|
43 | case "Load NCNR Analysis Macros": |
---|
44 | Execute/P "INSERTINCLUDE \"SA_Includes_v400\"" |
---|
45 | Execute/P "INSERTINCLUDE \"PlotUtilsMacro_v40\"" |
---|
46 | Execute/P "INSERTINCLUDE \"GaussUtils_v40\"" |
---|
47 | Execute/P "INSERTINCLUDE \"WriteModelData_v40\"" |
---|
48 | Execute/P "INSERTINCLUDE \"USANS_SlitSmearing_v40\"" |
---|
49 | Execute/P "INSERTINCLUDE \"SANSModelPicker_v40\"" |
---|
50 | Execute/P "COMPILEPROCEDURES " |
---|
51 | Execute/P ("Init_WrapperPanel()") |
---|
52 | Execute/P ("ModelPicker_Panel()") |
---|
53 | |
---|
54 | gMenuStr1a = "Hide NCNR Analysis Macros" |
---|
55 | // gMenuStr1b = "Unload NCNR Analysis Macros" |
---|
56 | gMenuStr1b = "-" |
---|
57 | BuildMenu "Macros" |
---|
58 | |
---|
59 | break |
---|
60 | case "Unload NCNR Analysis Macros": |
---|
61 | // very dangerous - don't really want to implement this because it will surely crash |
---|
62 | Execute/P "DELETEINCLUDE \"SA_Includes_v400\"" |
---|
63 | Execute/P "DELETEINCLUDE \"PlotUtilsMacro_v40\"" |
---|
64 | Execute/P "DELETEINCLUDE \"GaussUtils_v40\"" |
---|
65 | Execute/P "DELETEINCLUDE \"WriteModelData_v40\"" |
---|
66 | Execute/P "DELETEINCLUDE \"USANS_SlitSmearing_v40\"" |
---|
67 | Execute/P "DELETEINCLUDE \"SANSModelPicker_v40\"" |
---|
68 | Execute/P "COMPILEPROCEDURES " |
---|
69 | DoWindow wrapperPanel |
---|
70 | if(V_Flag) |
---|
71 | DoWindow/K wrapperPanel |
---|
72 | endif |
---|
73 | DoWindow Procedure_List |
---|
74 | If(V_Flag) |
---|
75 | DoWindow/K Procedure_List |
---|
76 | endif |
---|
77 | |
---|
78 | gMenuStr1a = "Load NCNR Analysis Macros" |
---|
79 | gMenuStr1b = "-" |
---|
80 | |
---|
81 | BuildMenu "Macros" |
---|
82 | |
---|
83 | break |
---|
84 | case "Hide NCNR Analysis Macros": |
---|
85 | HideShowWindowsInList(SANSAna_WinList,1) |
---|
86 | |
---|
87 | gMenuStr1a = "Show NCNR Analysis Macros" |
---|
88 | // gMenuStr1b = "Unload NCNR Analysis Macros" |
---|
89 | gMenuStr1b = "-" |
---|
90 | BuildMenu "Macros" |
---|
91 | |
---|
92 | break |
---|
93 | case "Show NCNR Analysis Macros": |
---|
94 | HideShowWindowsInList(SANSAna_WinList,0) |
---|
95 | |
---|
96 | gMenuStr1a = "Hide NCNR Analysis Macros" |
---|
97 | // gMenuStr1b = "Unload NCNR Analysis Macros" |
---|
98 | gMenuStr1b = "-" |
---|
99 | BuildMenu "Macros" |
---|
100 | |
---|
101 | break |
---|
102 | default: |
---|
103 | Abort "Invalid Menu Selection" |
---|
104 | endswitch |
---|
105 | |
---|
106 | end |
---|
107 | |
---|
108 | |
---|
109 | // now add for the SANS Reduction |
---|
110 | Function NCNR_SANSReductionLoader(itemStr) |
---|
111 | String itemStr |
---|
112 | |
---|
113 | if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.02) |
---|
114 | Abort "Your version of Igor is lower than 6.02, these macros need version 6.02 or higher.... " |
---|
115 | endif |
---|
116 | |
---|
117 | NewDataFolder/O root:Packages //create the folder for string variable |
---|
118 | String/G root:Packages:NCNRItemStr2a = itemStr |
---|
119 | String/G root:Packages:NCNRItemStr2b = itemStr |
---|
120 | SVAR gMenuStr2a = root:Packages:NCNRItemStr2a |
---|
121 | SVAR gMenuStr2b = root:Packages:NCNRItemStr2b |
---|
122 | |
---|
123 | String SANSRed_WinList = "Main_Panel;" |
---|
124 | strswitch(itemStr) // string switch |
---|
125 | case "Load NCNR SANS Reduction Macros": |
---|
126 | Execute/P "INSERTINCLUDE \"Includes_v510\"" |
---|
127 | Execute/P "COMPILEPROCEDURES " |
---|
128 | Execute/P ("Initialize()") |
---|
129 | |
---|
130 | gMenuStr2a = "Hide NCNR SANS Reduction Macros" |
---|
131 | // gMenuStr2b = "Unload NCNR SANS Reduction Macros" |
---|
132 | gMenuStr2b = "-" |
---|
133 | BuildMenu "Macros" |
---|
134 | |
---|
135 | break |
---|
136 | case "Unload NCNR SANS Reduction Macros": |
---|
137 | // very dangerous - don't really want to implement this because it will surely crash |
---|
138 | Execute/P "DELETEINCLUDE \"Includes_v510\"" |
---|
139 | Execute/P "COMPILEPROCEDURES " |
---|
140 | DoWindow Main_Panel |
---|
141 | if(V_Flag) |
---|
142 | DoWindow/K Main_Panel |
---|
143 | endif |
---|
144 | |
---|
145 | gMenuStr2a = "Load NCNR SANS Reduction Macros" |
---|
146 | gMenuStr2b = "-" |
---|
147 | |
---|
148 | BuildMenu "Macros" |
---|
149 | |
---|
150 | break |
---|
151 | case "Hide NCNR SANS Reduction Macros": |
---|
152 | HideShowWindowsInList(SANSRed_WinList,1) |
---|
153 | |
---|
154 | gMenuStr2a = "Show NCNR SANS Reduction Macros" |
---|
155 | // gMenuStr2b = "Unload NCNR SANS Reduction Macros" |
---|
156 | gMenuStr2b = "-" |
---|
157 | BuildMenu "Macros" |
---|
158 | |
---|
159 | break |
---|
160 | case "Show NCNR SANS Reduction Macros": |
---|
161 | HideShowWindowsInList(SANSRed_WinList,0) |
---|
162 | |
---|
163 | gMenuStr2a = "Hide NCNR SANS Reduction Macros" |
---|
164 | // gMenuStr2b = "Unload NCNR SANS Reduction Macros" |
---|
165 | gMenuStr2b = "-" |
---|
166 | BuildMenu "Macros" |
---|
167 | |
---|
168 | break |
---|
169 | default: |
---|
170 | Abort "Invalid Menu Selection" |
---|
171 | endswitch |
---|
172 | |
---|
173 | end |
---|
174 | |
---|
175 | // now add for the SANS Reduction |
---|
176 | Function NCNR_USANSReductionLoader(itemStr) |
---|
177 | String itemStr |
---|
178 | |
---|
179 | if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.02) |
---|
180 | Abort "Your version of Igor is lower than 6.02, these macros need version 6.02 or higher.... " |
---|
181 | endif |
---|
182 | |
---|
183 | NewDataFolder/O root:Packages //create the folder for string variable |
---|
184 | String/G root:Packages:NCNRItemStr3a = itemStr |
---|
185 | String/G root:Packages:NCNRItemStr3b = itemStr |
---|
186 | SVAR gMenuStr3a = root:Packages:NCNRItemStr3a |
---|
187 | SVAR gMenuStr3b = root:Packages:NCNRItemStr3b |
---|
188 | |
---|
189 | String USANS_WinList = "USANS_Panel;COR_Graph;RawDataWin;Desmear_Graph;" |
---|
190 | |
---|
191 | strswitch(itemStr) // string switch |
---|
192 | case "Load NCNR USANS Reduction Macros": |
---|
193 | Execute/P "INSERTINCLUDE \"USANS_Includes\"" |
---|
194 | Execute/P "COMPILEPROCEDURES " |
---|
195 | Execute/P ("ShowUSANSPanel()") |
---|
196 | |
---|
197 | gMenuStr3a = "Hide NCNR USANS Reduction Macros" |
---|
198 | // gMenuStr3b = "Unload NCNR USANS Reduction Macros" |
---|
199 | gMenuStr3b = "-" |
---|
200 | BuildMenu "Macros" |
---|
201 | |
---|
202 | break |
---|
203 | case "Unload NCNR USANS Reduction Macros": |
---|
204 | // very dangerous - don't really want to implement this because it will surely crash |
---|
205 | Execute/P "DELETEINCLUDE \"USANS_Includes\"" |
---|
206 | Execute/P "COMPILEPROCEDURES " |
---|
207 | DoWindow USANS_Panel |
---|
208 | if(V_Flag) |
---|
209 | DoWindow/K USANS_Panel |
---|
210 | endif |
---|
211 | |
---|
212 | gMenuStr3a = "Load NCNR USANS Reduction Macros" |
---|
213 | gMenuStr3b = "-" |
---|
214 | |
---|
215 | BuildMenu "Macros" |
---|
216 | |
---|
217 | break |
---|
218 | case "Hide NCNR USANS Reduction Macros": |
---|
219 | HideShowWindowsInList(USANS_WinList,1) |
---|
220 | |
---|
221 | gMenuStr3a = "Show NCNR USANS Reduction Macros" |
---|
222 | // gMenuStr3b = "Unload NCNR USANS Reduction Macros" |
---|
223 | gMenuStr3b = "-" |
---|
224 | BuildMenu "Macros" |
---|
225 | |
---|
226 | break |
---|
227 | case "Show NCNR USANS Reduction Macros": |
---|
228 | HideShowWindowsInList(USANS_WinList,0) |
---|
229 | |
---|
230 | gMenuStr3a = "Hide NCNR USANS Reduction Macros" |
---|
231 | // gMenuStr3b = "Unload NCNR USANS Reduction Macros" |
---|
232 | gMenuStr3b = "-" |
---|
233 | BuildMenu "Macros" |
---|
234 | |
---|
235 | break |
---|
236 | default: |
---|
237 | Abort "Invalid Menu Selection" |
---|
238 | endswitch |
---|
239 | |
---|
240 | end |
---|
241 | |
---|
242 | // 1 = hide, 0 = show |
---|
243 | Function HideShowWindowsInList(list,hide) |
---|
244 | String list |
---|
245 | Variable hide |
---|
246 | |
---|
247 | String item |
---|
248 | Variable ii,num=ItemsinList(list) |
---|
249 | for(ii=0;ii<num;ii+=1) |
---|
250 | item = StringFromList(ii, list , ";") |
---|
251 | DoWindow $item |
---|
252 | if(V_Flag) |
---|
253 | DoWindow/HIDE=(hide) $item |
---|
254 | endif |
---|
255 | endfor |
---|
256 | return(0) |
---|
257 | End |
---|