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

Last change on this file since 476 was 476, checked in by srkline, 14 years ago

Tried to stop the unloading clash of GlobalFit? and SimpleGlobalFit?. The Simple fit depends on GlobalFit?, so it can't be unloaded.

SumSANSModels now automatically finds the number of coefficients, since the coefficients are always in the root: folder. Saves the users a step.

Added more windows to the analysis list in the package loader

File size: 8.6 KB
RevLine 
[428]1#pragma rtGlobals=1             // Use modern global access method.
[476]2#pragma IgorVersion=6.0
3//#pragma IndependentModule=NCNRLoader          //can't seem to get this to work properly...
[428]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","-"))
28end
29
30Function NCNR_AnalysisLoader(itemStr)
31        String itemStr
32               
33        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.02)
34                Abort "Your version of Igor is lower than 6.02, these macros need version 6.02 or higher.... "
35        endif
36       
37        NewDataFolder/O root:Packages           //create the folder for string variable
38        String/G root:Packages:NCNRItemStr1a = itemStr
39        String/G root:Packages:NCNRItemStr1b = itemStr
40        SVAR gMenuStr1a = root:Packages:NCNRItemStr1a
41        SVAR gMenuStr1b = root:Packages:NCNRItemStr1b
42       
[476]43        String SANSAna_WinList = "wrapperPanel;Procedure_List;Report;Plot_Manager;A_FitPanel;A_FitWindow;Sum_Model_Panel;"
44        SANSAna_WinList += "NewGlobalFitPanel;SimpGFPanel;Invariant_Panel;invariant_graph;"
[428]45        strswitch(itemStr)      // string switch
46                case "Load NCNR Analysis Macros":       
47                        Execute/P "INSERTINCLUDE \"SA_Includes_v400\""
48                        Execute/P "INSERTINCLUDE \"PlotUtilsMacro_v40\""
49                        Execute/P "INSERTINCLUDE \"GaussUtils_v40\""
50                        Execute/P "INSERTINCLUDE \"WriteModelData_v40\""
51                        Execute/P "INSERTINCLUDE \"USANS_SlitSmearing_v40\""
52                        Execute/P "INSERTINCLUDE \"SANSModelPicker_v40\""
53                        Execute/P "COMPILEPROCEDURES "
54                        Execute/P ("Init_WrapperPanel()")
55                        Execute/P ("ModelPicker_Panel()")
56               
57                        gMenuStr1a = "Hide NCNR Analysis Macros"
58//                      gMenuStr1b = "Unload NCNR Analysis Macros"
59                        gMenuStr1b = "-"
60                        BuildMenu "Macros"
61                       
62                        break                                           
63                case "Unload NCNR Analysis Macros":     
64                // very dangerous - don't really want to implement this because it will surely crash
65                        Execute/P "DELETEINCLUDE \"SA_Includes_v400\""
66                        Execute/P "DELETEINCLUDE \"PlotUtilsMacro_v40\""
67                        Execute/P "DELETEINCLUDE \"GaussUtils_v40\""
68                        Execute/P "DELETEINCLUDE \"WriteModelData_v40\""
69                        Execute/P "DELETEINCLUDE \"USANS_SlitSmearing_v40\""
70                        Execute/P "DELETEINCLUDE \"SANSModelPicker_v40\""
71                        Execute/P "COMPILEPROCEDURES "
72                        DoWindow wrapperPanel
73                        if(V_Flag)
74                                DoWindow/K wrapperPanel
75                        endif
76                        DoWindow Procedure_List
77                        If(V_Flag)
78                                DoWindow/K Procedure_List
79                        endif
80
81                        gMenuStr1a = "Load NCNR Analysis Macros"
82                        gMenuStr1b = "-"
83                       
84                        BuildMenu "Macros"
85                       
86                        break
87                case "Hide NCNR Analysis Macros":       
[433]88                        HideShowWindowsInList(SANSAna_WinList,1)       
[428]89               
90                        gMenuStr1a = "Show NCNR Analysis Macros"
91//                      gMenuStr1b = "Unload NCNR Analysis Macros"
92                        gMenuStr1b = "-"
93                        BuildMenu "Macros"
94                       
95                        break
[433]96                case "Show NCNR Analysis Macros":
97                        HideShowWindowsInList(SANSAna_WinList,0)       
[428]98               
99                        gMenuStr1a = "Hide NCNR Analysis Macros"
100//                      gMenuStr1b = "Unload NCNR Analysis Macros"
101                        gMenuStr1b = "-"
102                        BuildMenu "Macros"
103                       
104                        break
105                default:
106                        Abort "Invalid Menu Selection"
107        endswitch
108
109end
110
111
112// now add for the SANS Reduction
113Function NCNR_SANSReductionLoader(itemStr)
114        String itemStr
115       
116        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.02)
117                Abort "Your version of Igor is lower than 6.02, these macros need version 6.02 or higher.... "
118        endif
119       
120        NewDataFolder/O root:Packages           //create the folder for string variable
121        String/G root:Packages:NCNRItemStr2a = itemStr
122        String/G root:Packages:NCNRItemStr2b = itemStr
123        SVAR gMenuStr2a = root:Packages:NCNRItemStr2a
124        SVAR gMenuStr2b = root:Packages:NCNRItemStr2b
125       
[455]126        String SANSRed_WinList = "Main_Panel;CatVSTable;SANS_Data;Plot_Manager;Average_Panel;Plot_1d;CatWin;Surface_3D;FitPanel;FitWindow;"
127        SANSRed_WinList += "FitRPAPanel;SANS_Histo;drawMaskWin;Multiple_Reduce_Panel;NSORT_Panel;NSORT_Graph;CombineTable;ToCombine;Patch_Panel;"
128        SANSRed_WinList += "ProtocolPanel;Schematic_Layout;Tile_2D;RAW_to_ASCII;Trans_Panel;TransFileTable;ScatterFileTable;Convert_to_Trans;"
129        SANSRed_WinList += "WorkFileMath;Pref_Panel;Subtract_1D_Panel;Plot_Sub1D;SASCALC;MC_SASCALC;Saved_Configurations;TISANE;"
[428]130        strswitch(itemStr)      // string switch
131                case "Load NCNR SANS Reduction Macros":
[448]132                        Execute/P "INSERTINCLUDE \"Includes_v520\""
[428]133                        Execute/P "COMPILEPROCEDURES "
134                        Execute/P ("Initialize()")
135               
136                        gMenuStr2a = "Hide NCNR SANS Reduction Macros"
137//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
138                        gMenuStr2b = "-"
139                        BuildMenu "Macros"
140                       
141                        break                                           
142                case "Unload NCNR SANS Reduction Macros":       
143                // very dangerous - don't really want to implement this because it will surely crash
[448]144                        Execute/P "DELETEINCLUDE \"Includes_v520\""
[428]145                        Execute/P "COMPILEPROCEDURES "
146                        DoWindow Main_Panel
147                        if(V_Flag)
148                                DoWindow/K Main_Panel
149                        endif
150
151                        gMenuStr2a = "Load NCNR SANS Reduction Macros"
152                        gMenuStr2b = "-"
153                       
154                        BuildMenu "Macros"
155                       
156                        break
[433]157                case "Hide NCNR SANS Reduction Macros":
158                        HideShowWindowsInList(SANSRed_WinList,1)
[428]159               
160                        gMenuStr2a = "Show NCNR SANS Reduction Macros"
161//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
162                        gMenuStr2b = "-"
163                        BuildMenu "Macros"
164                       
165                        break
166                case "Show NCNR SANS Reduction Macros":
[433]167                        HideShowWindowsInList(SANSRed_WinList,0)
[428]168               
169                        gMenuStr2a = "Hide NCNR SANS Reduction Macros"
170//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
171                        gMenuStr2b = "-"
172                        BuildMenu "Macros"
173                       
174                        break
175                default:
176                        Abort "Invalid Menu Selection"
177        endswitch
178
179end
180
181// now add for the SANS Reduction
182Function NCNR_USANSReductionLoader(itemStr)
183        String itemStr
184       
185        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.02)
186                Abort "Your version of Igor is lower than 6.02, these macros need version 6.02 or higher.... "
187        endif
188       
189        NewDataFolder/O root:Packages           //create the folder for string variable
190        String/G root:Packages:NCNRItemStr3a = itemStr
191        String/G root:Packages:NCNRItemStr3b = itemStr
192        SVAR gMenuStr3a = root:Packages:NCNRItemStr3a
193        SVAR gMenuStr3b = root:Packages:NCNRItemStr3b
194       
[455]195        String USANS_WinList = "USANS_Panel;COR_Graph;RawDataWin;Desmear_Graph;USANS_Slope;"
[433]196       
[428]197        strswitch(itemStr)      // string switch
198                case "Load NCNR USANS Reduction Macros":       
199                        Execute/P "INSERTINCLUDE \"USANS_Includes\""
200                        Execute/P "COMPILEPROCEDURES "
201                        Execute/P ("ShowUSANSPanel()")
202               
203                        gMenuStr3a = "Hide NCNR USANS Reduction Macros"
204//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
205                        gMenuStr3b = "-"
206                        BuildMenu "Macros"
207                       
208                        break                                           
209                case "Unload NCNR USANS Reduction Macros":     
210                // very dangerous - don't really want to implement this because it will surely crash
211                        Execute/P "DELETEINCLUDE \"USANS_Includes\""
212                        Execute/P "COMPILEPROCEDURES "
213                        DoWindow USANS_Panel
214                        if(V_Flag)
215                                DoWindow/K USANS_Panel
216                        endif
217
218                        gMenuStr3a = "Load NCNR USANS Reduction Macros"
219                        gMenuStr3b = "-"
220                       
221                        BuildMenu "Macros"
222                       
223                        break
224                case "Hide NCNR USANS Reduction Macros":       
[433]225                        HideShowWindowsInList(USANS_WinList,1) 
[428]226               
227                        gMenuStr3a = "Show NCNR USANS Reduction Macros"
228//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
229                        gMenuStr3b = "-"
230                        BuildMenu "Macros"
231                       
232                        break
[433]233                case "Show NCNR USANS Reduction Macros":
234                        HideShowWindowsInList(USANS_WinList,0) 
235                       
[428]236                        gMenuStr3a = "Hide NCNR USANS Reduction Macros"
237//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
238                        gMenuStr3b = "-"
239                        BuildMenu "Macros"
240                       
241                        break
242                default:
243                        Abort "Invalid Menu Selection"
244        endswitch
245       
246end
247
[433]248// 1 = hide, 0 = show
249Function HideShowWindowsInList(list,hide)
250        String list
251        Variable hide
252       
253        String item
254        Variable ii,num=ItemsinList(list)
255        for(ii=0;ii<num;ii+=1)
256                item = StringFromList(ii, list , ";")
257                DoWindow $item
258                if(V_Flag)
259                        DoWindow/HIDE=(hide) $item
260                endif
261        endfor
262        return(0)
263End
Note: See TracBrowser for help on using the repository browser.