source: User Procedures/Irena/IR1_Main.ipf @ 19

Last change on this file since 19 was 19, checked in by ilavsky, 9 years ago

Added check for update to run every 30 days and remind users about proper citations for publications.

File size: 119.2 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=2.52
3
4
5//*************************************************************************\
6//* Copyright (c) 2005 - 2013, Argonne National Laboratory
7//* This file is distributed subject to a Software License Agreement found
8//* in the file LICENSE that is included with this distribution.
9//*************************************************************************/
10
11//2.52 added check for update to run every 30 days and remind users about proper citations.
12//2.51 added Guinier-Porod model (beta version of the tool)
13//2.50 major update, added uncertainity estimation to Sizes and Modeling II. Reflectivity changes.
14//2.49 Minor fixes
15//2.48 Fixed GUI font/size issues on WIndows 7, Plotting tool I 3D upgrades, moved Modeling I to "Other tools"
16//2.47 New mailing list, movie & 3D graphs in Plotting tool I and other many fixes.
17//2.46 lots of small fixes, added easy access to scripting tool and few other changes.
18//2.45 Added features to Data manipulation II and Reflectivity. Updated manual.
19//2.44 minor fix Modeling II, Addition of controls of Modeling II to Scripting tool, other fixes.
20//2.43 add functions to handle modified panels between updates.
21//2.41 and 2.42, minor updates
22//2.40 added Unified level as Form factor and other fixes and improvements
23//2.39 added license for ANL
24
25
26// from version 2.26 I skipped numbers to match the current Irena version number (2.38)
27
28//This macro file is part of Igor macros package called "Irena",
29//the full package should be available from www.uni.aps.anl.gov/~ilavsky
30//this package contains
31// Igor functions for modeling of SAS from various distributions of scatterers...
32
33//Jan Ilavsky, February 2010
34
35//please, read Readme in the distribution zip file with more details on the program
36//report any problems to: ilavsky@aps.anl.gov
37
38
39//main functions.
40//Comment for me: Limit yourself to less than 30 items in the menu, Windows are limited to 30 items. Note: "---" counts as one item!
41
42//define manul date
43constant CurrentManualDateInSecs=  3439748159                   //this is mod date for Manual version 2.50
44constant CurrentVersionNumber = 2.50
45
46
47Menu "SAS"
48        help = {"Irena SAS modeling macros, version 2.50 released 1/4/2013 by Jan Ilavsky"}
49        Submenu "Data import & export"
50                "Import ASCII data", IR1I_ImportDataMain()
51                help={"Import data from ASCII file into Igor for use with macros"}
52                "Import XML data", CS_XMLGUIImportDataMain(defaultType="QRS",defaultQUnits="1/A")
53                help={"Import data from CanSAS 1.0 conforming data sets"}
54                "Export ASCII data", IR2E_UniversalDataExport()
55                help = {"This is tool for export of any 2-3 column data sets as ASCII."}
56        End
57        "---"
58        Submenu "Data Manipulation"
59                "Data manipulation I [one or two data sets]",  IR1D_DataManipulation()
60                help={"Merge data sets, rebin for same Q, etc..."}
61                "Data manipulation II [many data sets]", IR3M_DataManipulationII()
62                help={"Manipulate - for now only average - many data sets"}
63                "Data mining", IR2M_GetDataMiner()
64                help={"Data miner to find various data and plot various waves"}
65        end
66        "---"
67        "Plotting I", IR1P_GeneralPlotTool()
68        help = {"Plotting tool with wide functionality, hopefully"}
69        "Plotting II", IR2D_DWSPlotToolMain()
70        help = {"Plotting tool which controls any top graph"}
71                SubMenu "Support Tools for plots"
72                "Draw Line Of Any Slope", IR2P_DrawLineOfAnySlope()
73                "Draw Line Of -4 Slope",  IR2P_DrawLineOf4Slope()
74                "Draw Line Of -3 Slope",  IR2P_DrawLineOf3Slope()
75                "Draw Line Of -2 Slope",  IR2P_DrawLineOf2Slope()
76                "Make log-log graph decade limits", IR2P_MakeLogLogGraphDecLim()
77                "--"
78                "Fit Line With Cursors", IR2P_FitLineWithCursors()
79                "Fit Power Law with Cursors", IR2P_FitPowerLawWithCursors()
80                End
81        "---"
82        "Unified Fit", IR1A_UnifiedModel()
83        help = {"Modeling of SAS by modeling Guinier and Power law dependecies, based on Unified model by Gregg Beaucage"}
84        "Size Distribution", IR1R_Sizes()
85        help = {"SAS evaluation by regularization and maximum entropy fitting using spheroids"}
86        "Modeling II",IR2L_Main()
87        help = {"Complicated modeling of SAS with Least square fitting or genetic optimization, allows multiple data input and is much more flexible than LSqF. Much more complicated also!)"}
88        "Gunier Porod Fit", IR3GP_Main()
89        help = {"Modeling of SAS as Guinier and Power law dependecies, based on Gunier-Porod model by Bualem Hammouda"}
90        "Fractals model", IR1V_FractalsModel()
91        help = {"Modeling of SAS by combining mass and surface fractal dependecies, based on model by Andrew Allen"}
92        "Analytical models", IR2H_GelsMainFnct()
93        help={"Debye-Bueche, Teubner-Strey model"}
94        "Small-Angle Diffraction", IR2D_MainSmallAngleDiff()
95        help={"Modeling of small angle diffraction - up to 6 peaks and Powerlaw background"}
96        "Pair distance dist. fnct.", IR2Pr_MainPDDF()
97        help={"Calculate pair distribution function using various methods"}
98        "Reflectivity", IR2R_ReflectivitySimpleToolMain()
99        help={"Simple reflectivity model using Parrat's recursive code."}
100        "---"
101        "Scattering contrast calculator", IR1K_ScattCont2()
102        help={"Calculator for scattering contrast. Both X rays and neutrons. Anomalous effects available."}
103        "Configure default fonts and names",IR2C_ConfigMain()
104        help={"Configure default values for GUI Panels and Graph common items, such as font sizes and font types"}
105                SubMenu "Support and Older tools"
106                        "Evaluate Size Distributions", IR1G_EvaluateONESample()
107                        help = {"Not fully finished GUI to evaluate results from methods producing size distributions"}
108                        "Scripting tool",  IR2S_ScriptingTool()
109                        help = {"Scripting tool enabes to run some tools on multiple data sets."}
110                        "Modeling I", IR1S_LSQF_StandardModelsMain()
111                        help = {"Modeling of SAS by modeling distributions (Gauss, LogNormal) of scatterers (spheroids, spheres,cylinders,tubes' core-shell). Uses Least Squuare fitting or Genetic optimization."}
112                        "Modeling I, user models", IR1U_LSQF_UserModelsMain()
113                        help = {"Modeling of SAS with user provided distributions (probability/diameter) for scatterers (spheroids, spheres,cylinders, tubes, core-shell). Uses Least square fitting. "}
114                end
115                SubMenu "Other tools"
116                        "Desmearing", IR1B_DesmearingMain()
117                        help={"Remove slit smearing using Lake method"}
118                        "Show Results notebook", IR1_CreateResultsNbk()
119                        help={"Shows notebook in which tools can create record of the results with graphs"}
120                        "Create QRS folder structure", IR1F_CreateFldrStrctMain()
121                        help={"Create folder structure for users with QRS data in one folder, so Irena can work well"}
122                        "Show SAS logbook", IR1_PullUpLoggbook()
123                        help = {"Some of these macros make ongoing record of what is done, you'll find it here..."}
124                        "Export To XLS File Panel", ExportToXLSFilePanel()
125                        help={"This is tool for Unified fit, made by Gragg Beaucage. For help, contact him..."}
126                End
127                Submenu "Help, About, Manuals, Remove Irena"
128                        "About", IR1_AboutPanel()
129                        help={"Get Panel with info about this release of Irena macros"}
130                        "Check for updates", IR2C_CheckIrenaUpdate(1)
131                        help={"Run Check for update and present citations to use in publications"}     
132                        "Open Irena pdf manual", IR2_OpenIrenaManual()
133                        help={"Opens your pdf reader (Acrobat) with Irena manual in it"}
134                        "Open Form and Structure Factor description", IR2T_LoadFFDescription()
135                        help={"Opens Description of included form factors and structure factors"}
136                        "Open Irena manuscript", IR2_GetIrenaManuscript()
137                        help={"Open or download using ftp and open Irena J. Appl. Cryst manuscript"}
138                        "---"
139                        "Irena Mailing list signup and options", IR2_SignUpForMailingList()
140                        help={"Opens web page in the browser where you can sing up or control options for Irena_users mailing list."}
141                        "Open Web page with help movies", IR2_OpenHelpMoviePage()
142                        help={"Opens web page in the browser where different movies showing use of Irena can be downloaded"}
143                        "Open Irena Web page ", IR2_OpenIrenaPage()
144                        help={"Opens Irena web page in the browser "}
145                        "Submit e-mail with bug or feature request", IR2C_SendEMailBugReport()
146                        help={"This will open your e-mail browser with some info and address. Use to submit info to me. "}
147                        "---"
148                        "Kill all Irena panels and graphs", IR1_KillGraphsAndPanels()
149                        help = {"If you have just too much mess with many open panels and graphs, this will close them all..."}
150                        "Remove Irena Package", IR1_RemoveSASMac()
151                        help={"Removes Irena macros from current Igor experiment"}
152                end
153end
154
155
156
157//****************************************************************************************
158//****************************************************************************************
159//****************************************************************************************
160
161static Function AfterCompiledHook( )                    //check if all windows are up to date to match their code
162
163        //these are tools which have been upgraded to this functionality
164        //Modeling II = LSQF2_MainPanel
165        string WindowProcNames="LSQF2_MainPanel=IR2L_MainCheckVersion;IR2H_ControlPanel=IR2H_MainCheckVersion;DataMiningTool=IR2M_MainCheckVersion;DataManipulationII=IR3M_MainCheckVersion;"
166        WindowProcNames+="IR1I_ImportData=IR1I_MainCheckVersion;IR2S_ScriptingToolPnl=IR2S_MainCheckVersion;IR1R_SizesInputPanel=IR1R_MainCheckVersion;IR1A_ControlPanel=IR1A_MainCheckVersion;"
167        WindowProcNames+="IR1P_ControlPanel=IR1P_MainCheckVersion;IR2R_ReflSimpleToolMainPanel=IR2R_MainCheckVersion;IR3DP_MainPanel=IR3GP_MainCheckVersion;"
168        WindowProcNames+="IR1V_ControlPanel=IR1V_MainCheckVersion;IR2D_ControlPanel=IR2D_MainCheckVersion;IR2Pr_ControlPanel=IR2Pr_MainCheckVersion;UnivDataExportPanel=IR2E_MainCheckVersion;"
169        WindowProcNames+="IR1D_DataManipulationPanel=IR1D_MainCheckVersion;"
170       
171        IR2C_CheckWIndowsProcVersions(WindowProcNames)
172        IR2C_CheckIrenaUpdate(0)
173end
174//****************************************************************************************
175//****************************************************************************************
176
177Function IR2C_CheckWIndowsProcVersions(WindowProcNames)
178        string WindowProcNames
179       
180        variable i 
181        string PanelName
182        String ProcedureName
183        For(i=0;i<ItemsInList(WindowProcNames);i+=1)
184                PanelName = StringFromList(0, StringFromList(i, WindowProcNames, ";")  , "=")
185                ProcedureName = StringFromList(1, StringFromList(i, WindowProcNames, ";")  , "=")
186                DoWIndow $(PanelName)
187                if(V_Flag)
188                        Execute (ProcedureName+"()")
189                endif
190        endfor
191       
192end
193///////////////////////////////////////////
194//****************************************************************************************
195//              Default variables and strings
196//
197//      these are known at this time:
198//              Variables=LegendSize;TagSize;AxisLabelSize;
199//              Strings=FontType;
200//
201//      how to use:
202//      When needed insert font size through lookup function - e.g., IR2C_LkUpDfltVar("LegendSize")
203//      or for font type IR2C_LkUpDfltStr("FontType")
204//      NOTE: Both return string values, because that is what is generally needed!!!!
205// further variables and strings can be added, but need to be added to control panel too...
206//      see example in : IR1_LogLogPlotU()  in this procedure file...
207
208
209Function/S IR2C_LkUpDfltStr(StrName)
210        string StrName
211
212        string result
213        string OldDf=getDataFolder(1)
214        SetDataFolder root:
215        if(!DataFolderExists("root:Packages:IrenaConfigFolder"))
216                IR2C_InitConfigMain()
217        endif
218        SetDataFolder root:Packages
219        setDataFolder root:Packages:IrenaConfigFolder
220        SVAR /Z curString = $(StrName)
221        if(!SVAR_exists(curString))
222                IR2C_InitConfigMain()
223                SVAR curString = $(StrName)
224        endif   
225        result =        "'"+curString+"'"
226        setDataFolder OldDf
227        return result
228end
229
230Function/S IR2C_LkUpDfltVar(VarName)
231        string VarName
232
233        string result
234        string OldDf=getDataFolder(1)
235        SetDataFolder root:
236        if(!DataFolderExists("root:Packages:IrenaConfigFolder"))
237                IR2C_InitConfigMain()
238        endif
239        SetDataFolder root:Packages
240        setDataFolder root:Packages:IrenaConfigFolder
241        NVAR /Z curVariable = $(VarName)
242        if(!NVAR_exists(curVariable))
243                IR2C_InitConfigMain()
244                NVAR curVariable = $(VarName)
245        endif   
246        if(curVariable>=10)
247                result = num2str(       curVariable)
248        else
249                result = "0"+num2str(   curVariable)
250        endif
251        setDataFolder OldDf
252        return result
253end
254//***********************************************************
255//***********************************************************
256//***********************************************************
257//***********************************************************
258//***********************************************************
259Function UpdatePanelVersionNumber(panelName, CurentProcVersion)
260        string panelName
261        variable CurentProcVersion
262        DoWIndow $panelName
263        if(V_Flag)
264                SetWindow $(panelName), note="IrenaProcVersion:"+num2str(CurentProcVersion)+";"
265//              print "Saved To panel note ;    "+"IrenaProcVersion:"+num2str(CurentProcVersion)+";"
266        endif
267end
268
269Function CheckPanelVersionNumber(panelName, CurentProcVersion)
270        string panelName
271        variable CurentProcVersion
272
273        DoWIndow $panelName
274        if(V_Flag)     
275                GetWindow $(panelName), note
276//              print "Found :     "+S_Value
277                if(stringmatch(stringbyKey("IrenaProcVersion",S_value),num2str(CurentProcVersion))) //matches
278                        return 1
279                else
280                        return 0
281                endif
282        else
283                return 1
284        endif
285end
286
287//***********************************************************
288//***********************************************************
289//***********************************************************
290//***********************************************************
291//***********************************************************
292
293Function IR2C_ConfigMain()              //call configuration routine
294
295        //this is main configuration utility...
296        IR2C_InitConfigMain()
297        DoWindow IR2C_MainConfigPanel
298        if(!V_Flag)
299                Execute ("IR2C_MainConfigPanel()")
300        else
301                DoWindow/F IR2C_MainConfigPanel
302        endif
303        IR2C_ReadIrenaGUIPackagePrefs()
304end
305
306//***********************************************************
307//***********************************************************
308//***********************************************************
309//***********************************************************
310//***********************************************************
311structure IrenaPanelDefaults
312        uint32 version                                  // Preferences structure version number. 100 means 1.00.
313        uchar LegendFontType[50]                //50 characters for legend font name
314        uchar PanelFontType[50]         //50 characters for panel font name
315        uint32 defaultFontSize                  //font size as integer
316        uint32 LegendSize                               //font size as integer
317        uint32 TagSize                                  //font size as integer
318        uint32 AxisLabelSize                    //font size as integer
319        int16 LegendUseFolderName               //font size as integer
320        int16 LegendUseWaveName         //font size as integer
321        variable LastUpdateCheck
322        uint32 reserved[100]                    // Reserved for future use
323       
324endstructure
325
326//***********************************************************
327//***********************************************************
328//***********************************************************
329//***********************************************************
330//***********************************************************
331
332Function IR2C_ReadIrenaGUIPackagePrefs()
333
334        struct  IrenaPanelDefaults Defs
335        IR2C_InitConfigMain()
336        SVAR DefaultFontType=root:Packages:IrenaConfigFolder:DefaultFontType
337        NVAR DefaultFontSize=root:Packages:IrenaConfigFolder:DefaultFontSize
338        NVAR LegendSize=root:Packages:IrenaConfigFolder:LegendSize
339        NVAR TagSize=root:Packages:IrenaConfigFolder:TagSize
340        NVAR AxisLabelSize=root:Packages:IrenaConfigFolder:AxisLabelSize
341        NVAR LegendUseFolderName=root:Packages:IrenaConfigFolder:LegendUseFolderName
342        NVAR LegendUseWaveName=root:Packages:IrenaConfigFolder:LegendUseWaveName
343        SVAR FontType=root:Packages:IrenaConfigFolder:FontType
344        LoadPackagePreferences /MIS=1   "Irena" , "IrenaDefaultPanelControls.bin", 0 , Defs
345        if(V_Flag==0)           
346                //print Defs
347                print "Read Irena Penals and graphs preferences from local machine and applied them. "
348                print "Note that this may have changed font size and type selection originally saved with the existing experiment."
349                print "To change them please use \"Configure default fonts and names\""
350                if(Defs.Version==1 || Defs.Version==2)          //Lets declare the one we know as 1
351                        DefaultFontType=Defs.PanelFontType
352                        DefaultFontSize = Defs.defaultFontSize
353                        if (stringMatch(IgorInfo(2),"*Windows*"))               //Windows
354                                DefaultGUIFont /Win   all= {DefaultFontType, DefaultFontSize, 0 }
355                        else
356                                DefaultGUIFont /Mac   all= {DefaultFontType, DefaultFontSize, 0 }
357                        endif
358                        //and now recover the stored other parameters, no action on these...
359                         LegendSize=Defs.LegendSize
360                         TagSize=Defs.TagSize
361                         AxisLabelSize=Defs.AxisLabelSize
362                         LegendUseFolderName=Defs.LegendUseFolderName
363                         LegendUseWaveName=Defs.LegendUseWaveName
364                         FontType=Defs.LegendFontType
365                else
366                        DoAlert 1, "Old version of GUI and Graph Fonts (font size and type preference) found. Do you want to update them now? These are set once on a computer and can be changed in \"Configure default fonts and names\""
367                        if(V_Flag==1)
368                                Execute("IR2C_MainConfigPanel() ")
369                        else
370                        //      SavePackagePreferences /Kill   "Irena" , "IrenaDefaultPanelControls.bin", 0 , Defs      //does not work below 6.10
371                        endif
372                endif
373        else            //problem loading package defaults
374                DoAlert 1, "GUI and Graph defaults (font size and type preferences) are not set. Do you want to set them now? These are set once on a computer and can be changed in \"Configure default fonts and names\" dialog"
375                if(V_Flag==1)
376                        Execute("IR2C_MainConfigPanel() ")
377                endif   
378        endif
379end
380//***********************************************************
381//***********************************************************
382//***********************************************************
383//***********************************************************
384//***********************************************************
385Function IR2C_SaveIrenaGUIPackagePrefs(KillThem)
386        variable KillThem
387       
388        struct  IrenaPanelDefaults Defs
389        IR2C_InitConfigMain()
390        SVAR DefaultFontType=root:Packages:IrenaConfigFolder:DefaultFontType
391        NVAR DefaultFontSize=root:Packages:IrenaConfigFolder:DefaultFontSize
392        NVAR LegendSize=root:Packages:IrenaConfigFolder:LegendSize
393        NVAR TagSize=root:Packages:IrenaConfigFolder:TagSize
394        NVAR AxisLabelSize=root:Packages:IrenaConfigFolder:AxisLabelSize
395        NVAR LegendUseFolderName=root:Packages:IrenaConfigFolder:LegendUseFolderName
396        NVAR LegendUseWaveName=root:Packages:IrenaConfigFolder:LegendUseWaveName
397        SVAR FontType=root:Packages:IrenaConfigFolder:FontType
398
399        Defs.Version                    =               2
400        Defs.PanelFontType              =               DefaultFontType
401        Defs.defaultFontSize    =               DefaultFontSize
402        Defs.LegendSize                         =               LegendSize
403        Defs.TagSize                    =               TagSize
404        Defs.AxisLabelSize              =               AxisLabelSize
405        Defs.LegendUseFolderName =      LegendUseFolderName
406        Defs.LegendUseWaveName =                LegendUseWaveName
407        Defs.LegendFontType     =               FontType
408       
409        if(KillThem)
410        //      SavePackagePreferences /Kill   "Irena" , "IrenaDefaultPanelControls.bin", 0 , Defs              //does nto work below 6.10
411        //      IR2C_ReadIrenaGUIPackagePrefs()
412        else
413                SavePackagePreferences /FLSH=1   "Irena" , "IrenaDefaultPanelControls.bin", 0 , Defs
414        endif
415end
416//***********************************************************
417//***********************************************************
418//***********************************************************
419//***********************************************************
420//***********************************************************
421
422Function IR2C_InitConfigMain()
423
424        //initialize lookup parameters for user selected items.
425        string OldDf=getDataFolder(1)
426        SetDataFolder root:
427        NewDataFolder/O/S root:Packages
428        NewDataFolder/O/S root:Packages:IrenaConfigFolder
429       
430        string ListOfVariables
431        string ListOfStrings
432        //here define the lists of variables and strings needed, separate names by ;...
433        ListOfVariables="LegendSize;TagSize;AxisLabelSize;LegendUseFolderName;LegendUseWaveName;DefaultFontSize;"
434        ListOfStrings="FontType;ListOfKnownFontTypes;DefaultFontType;"
435        variable i
436        //and here we create them
437        for(i=0;i<itemsInList(ListOfVariables);i+=1)   
438                IN2G_CreateItem("variable",StringFromList(i,ListOfVariables))
439        endfor         
440                                                                               
441        for(i=0;i<itemsInList(ListOfStrings);i+=1)     
442                IN2G_CreateItem("string",StringFromList(i,ListOfStrings))
443        endfor 
444        //Now set default values
445        String VariablesDefaultValues
446        String StringsDefaultValues
447        if (stringMatch(IgorInfo(2),"*Windows*"))               //Windows
448                VariablesDefaultValues="LegendSize:8;TagSize:8;AxisLabelSize:8;LegendUseFolderName:0;LegendUseWaveName:0;"
449        else
450                VariablesDefaultValues="LegendSize:10;TagSize:10;AxisLabelSize:10;LegendUseFolderName:0;LegendUseWaveName:0;"
451        endif
452        StringsDefaultValues="FontType:"+StringFromList(0, IR2C_CreateUsefulFontList() ) +";"
453
454        variable CurVarVal
455        string CurVar, CurStr, CurStrVal
456        For(i=0;i<ItemsInList(VariablesDefaultValues);i+=1)
457                CurVar = StringFromList(0,StringFromList(i, VariablesDefaultValues),":")
458                CurVarVal = numberByKey(CurVar, VariablesDefaultValues)
459                NVAR temp=$(CurVar)
460                if(temp==0)
461                        temp = CurVarVal
462                endif
463        endfor
464        For(i=0;i<ItemsInList(StringsDefaultValues);i+=1)
465                CurStr = StringFromList(0,StringFromList(i, StringsDefaultValues),":")
466                CurStrVal = stringByKey(CurStr, StringsDefaultValues)
467                SVAR tempS=$(CurStr)
468                if(strlen(tempS)<1)
469                        tempS = CurStrVal
470                endif
471        endfor
472       
473        SVAR ListOfKnownFontTypes=ListOfKnownFontTypes
474        ListOfKnownFontTypes=IR2C_CreateUsefulFontList()
475        setDataFolder OldDf
476end
477
478//***********************************************************
479//***********************************************************
480//***********************************************************
481//***********************************************************
482//***********************************************************
483Function IR2C_PopMenuProc(ctrlName,popNum,popStr) : PopupMenuControl
484        String ctrlName
485        Variable popNum
486        String popStr
487       
488        if (cmpstr(ctrlName,"LegendSize")==0)
489                NVAR LegendSize=root:Packages:IrenaConfigFolder:LegendSize
490                LegendSize = str2num(popStr)
491        endif
492        if (cmpstr(ctrlName,"TagSize")==0)
493                NVAR TagSize=root:Packages:IrenaConfigFolder:TagSize
494                TagSize = str2num(popStr)
495        endif
496        if (cmpstr(ctrlName,"AxisLabelSize")==0)
497                NVAR AxisLabelSize=root:Packages:IrenaConfigFolder:AxisLabelSize
498                AxisLabelSize = str2num(popStr)
499        endif
500        if (cmpstr(ctrlName,"FontType")==0)
501                SVAR FontType=root:Packages:IrenaConfigFolder:FontType
502                FontType = popStr
503        endif
504        if (cmpstr(ctrlName,"DefaultFontType")==0)
505                SVAR DefaultFontType=root:Packages:IrenaConfigFolder:DefaultFontType
506                DefaultFontType = popStr
507                IR2C_ChangePanelCOntrolsStyle()
508        endif
509        if (cmpstr(ctrlName,"DefaultFontSize")==0)
510                NVAR DefaultFontSize=root:Packages:IrenaConfigFolder:DefaultFontSize
511                DefaultFontSize = str2num(popStr)
512                IR2C_ChangePanelCOntrolsStyle()
513        endif
514        IR2C_SaveIrenaGUIPackagePrefs(0)
515End
516//***********************************************************
517//***********************************************************
518//***********************************************************
519//***********************************************************
520//***********************************************************
521Function IR2C_KillPrefsButtonProc(ba) : ButtonControl
522        STRUCT WMButtonAction &ba
523
524        switch( ba.eventCode )
525                case 2: // mouse up
526                        // click code here
527                        if(stringmatch(ba.ctrlName,"OKBUtton"))
528                                DoWIndow/K IR2C_MainConfigPanel
529                        elseif(stringmatch(ba.ctrlName,"DefaultValues"))
530                                string defFnt
531                                variable defFntSize
532                                if (stringMatch(IgorInfo(2),"*Windows*"))               //Windows
533                                        defFnt=stringFromList(0,IR2C_CreateUsefulFontList())
534                                        defFntSize=12
535                                else
536                                        defFnt="Geneva"
537                                        defFntSize=9
538                                endif
539                                SVAR ListOfKnownFontTypes=root:Packages:IrenaConfigFolder:ListOfKnownFontTypes
540                                SVAR DefaultFontType=root:Packages:IrenaConfigFolder:DefaultFontType
541                                DefaultFontType = defFnt
542                                NVAR DefaultFontSize=root:Packages:IrenaConfigFolder:DefaultFontSize
543                                DefaultFontSize = defFntSize
544                                IR2C_ChangePanelCOntrolsStyle()
545                                IR2C_SaveIrenaGUIPackagePrefs(0)
546                                PopupMenu DefaultFontType,win=IR2C_MainConfigPanel, mode=(1+WhichListItem(defFnt, ListOfKnownFontTypes))
547                                PopupMenu DefaultFontSize,win=IR2C_MainConfigPanel, mode=(1+WhichListItem(num2str(defFntSize), "8;9;10;11;12;14;16;18;20;24;26;30;"))
548                        endif
549                        break
550        endswitch
551        return 0
552End
553
554//***********************************************************
555//***********************************************************
556//***********************************************************
557//***********************************************************
558//***********************************************************
559
560Function IR2C_ChangePanelControlsStyle()
561
562        SVAR DefaultFontType=root:Packages:IrenaConfigFolder:DefaultFontType
563        NVAR DefaultFontSize=root:Packages:IrenaConfigFolder:DefaultFontSize
564
565        if (stringMatch(IgorInfo(2),"*Windows*"))               //Windows
566                DefaultGUIFont /Win   all= {DefaultFontType, DefaultFontSize, 0 }
567        else
568                DefaultGUIFont /Mac   all= {DefaultFontType, DefaultFontSize, 0 }
569        endif
570
571end
572//***********************************************************
573//***********************************************************
574//***********************************************************
575//***********************************************************
576//***********************************************************
577
578Proc IR2C_MainConfigPanel()
579        PauseUpdate; Silent 1           // building window...
580        NewPanel /K=1/W=(282,48,707,356) as "Configure default fonts and names"
581        DoWindow /C IR2C_MainConfigPanel
582        SetDrawLayer UserBack
583        SetDrawEnv fsize= 14,fstyle= 1,textrgb= (0,0,52224)
584        DrawText 10,25,"Irena panels and graphs default fonts and names"
585        SetDrawEnv fsize= 14,fstyle= 3, textrgb= (63500,4369,4369)
586        DrawText 30,53,"Panel and controls font type & size (preference)"
587        SetDrawEnv fsize= 14,fstyle= 3,textrgb= (63500,4369,4369)
588        DrawText 30,150,"Graph text elements"
589//      SVAR ListOfKnownFontTypes=root:Packages:IrenaConfigFolder:ListOfKnownFontTypes
590
591        PopupMenu DefaultFontType,pos={35,65},size={113,21},proc=IR2C_PopMenuProc,title="Panel Controls Font"
592        PopupMenu DefaultFontType,mode=(1+WhichListItem(root:Packages:IrenaConfigFolder:DefaultFontType, root:Packages:IrenaConfigFolder:ListOfKnownFontTypes))
593        PopupMenu DefaultFontType, popvalue=root:Packages:IrenaConfigFolder:DefaultFontType,value= #"IR2C_CreateUsefulFontList()"
594        PopupMenu DefaultFontSize,pos={35,95},size={113,21},proc=IR2C_PopMenuProc,title="Panel Controls Font Size"
595        PopupMenu DefaultFontSize,mode=(1+WhichListItem(num2str(root:Packages:IrenaConfigFolder:DefaultFontSize), "8;9;10;11;12;14;16;18;20;24;26;30;"))
596        PopupMenu DefaultFontSize popvalue=num2str(root:Packages:IrenaConfigFolder:DefaultFontSize),value= #"\"8;9;10;11;12;14;16;18;20;24;26;30;\""
597        Button DefaultValues title="Default",pos={290,70},size={120,20}
598        Button DefaultValues proc=IR2C_KillPrefsButtonProc
599
600        PopupMenu LegendSize,pos={35,165},size={113,21},proc=IR2C_PopMenuProc,title="Legend Size"
601        PopupMenu LegendSize,mode=(1+WhichListItem(num2str(root:Packages:IrenaConfigFolder:LegendSize), "8;9;10;11;12;14;16;18;20;24;26;30;"))
602        PopupMenu LegendSize, popvalue=num2str(root:Packages:IrenaConfigFolder:LegendSize),value= #"\"8;9;10;11;12;14;16;18;20;24;26;30;\""
603//LegendUseFolderName:1;LegendUseWaveName
604        CheckBox LegendUseFolderName,pos={195,165},size={25,16},noproc,title="Legend use Folder Names?"
605        CheckBox LegendUseFolderName,variable= root:Packages:IrenaConfigFolder:LegendUseFolderName, help={"Check to use folder names in legends?"}
606        CheckBox LegendUseWaveName,pos={195,205},size={25,16},noproc,title="Legend use Wave Names?"
607        CheckBox LegendUseWaveName,variable= root:Packages:IrenaConfigFolder:LegendUseWaveName, help={"Check to use wave names in legends?"}
608        PopupMenu TagSize,pos={49,195},size={96,21},proc=IR2C_PopMenuProc,title="Tag Size"
609        PopupMenu TagSize,mode=(1+WhichListItem(num2str(root:Packages:IrenaConfigFolder:TagSize), "8;9;10;11;12;14;16;18;20;24;26;30;"))
610        PopupMenu TagSize,popvalue=num2str(root:Packages:IrenaConfigFolder:TagSize),value= #"\"8;9;10;11;12;14;16;18;20;24;26;30;\""
611        PopupMenu AxisLabelSize,pos={46,225},size={103,21},proc=IR2C_PopMenuProc,title="Label Size"
612        PopupMenu AxisLabelSize,mode=(1+WhichListItem(num2str(root:Packages:IrenaConfigFolder:AxisLabelSize), "8;9;10;11;12;14;16;18;20;24;26;30;"))
613        PopupMenu AxisLabelSize,popvalue=num2str(root:Packages:IrenaConfigFolder:AxisLabelSize),value= #"\"8;9;10;11;12;14;16;18;20;24;26;30;\""
614        PopupMenu FontType,pos={48,255},size={114,21},proc=IR2C_PopMenuProc,title="Font type"
615        PopupMenu FontType,mode=(1+WhichListItem(root:Packages:IrenaConfigFolder:FontType, root:Packages:IrenaConfigFolder:ListOfKnownFontTypes))
616        PopupMenu FontType,popvalue=root:Packages:IrenaConfigFolder:FontType,value= #"root:Packages:IrenaConfigFolder:ListOfKnownFontTypes"
617        Button OKButton title="OK",pos={290,270},size={120,20}
618        Button OKButton proc=IR2C_KillPrefsButtonProc
619
620
621EndMacro
622//***********************************************************
623//***********************************************************
624//***********************************************************
625//***********************************************************
626//***********************************************************
627
628Function/S IR2C_CreateUsefulFontList()
629
630        string SystemFontList=FontList(";")
631        string PreferredFontList="Tahoma;Times;Arial;Geneva;Palatino;Times New Roman;TImes Roman;Book Antiqua;"
632        PreferredFontList+="Courier;Lucida;Vardana;Monaco;Courier CE;System;Verdana;"
633       
634        variable i
635        string UsefulList="", tempList=""
636        For(i=0;i<ItemsInList(PreferredFontList);i+=1)
637                tempList=stringFromList(i,PreferredFontList)
638                if(stringmatch(SystemFOntList, "*"+tempList+";*" ))
639                        UsefulList+=tempList+";"
640                endif
641        endfor
642        return UsefulList
643end
644
645//***********************************************************
646//***********************************************************
647//***********************************************************
648//***********************************************************
649//***********************************************************
650
651Function IR2C_SendEMailBugReport()
652
653        string url, separator
654        if(stringmatch(StringByKey("OS", IgorInfo(3) , ":" , ";"), "*Macintosh*" ))
655                separator="\n"
656        else
657                separator="%0A"
658        endif
659        url="mailto:ilavsky@aps.anl.gov?subject=Irena ver "+num2str(CurrentVersionNumber)+" bug or user comment"
660        url+="&body=The problem or bug occurred on "+separator
661        url+="IgorInfo(0) = "+IgorInfo(0)+separator
662        url+="IgorInfo(3) = "+IgorInfo(3)+separator+separator
663        url+="Please attach notes about the bug or request for new features. If necessary attach your Igor experiment. Thank You J.I."+separator
664        BrowseURL url
665end
666
667//***********************************************************
668//***********************************************************
669//***********************************************************
670//***********************************************************
671//***********************************************************
672///////////////////////////////////////////
673
674Proc IR2P_FitLineWithCursors()
675
676        string destwavename="fit_"+CsrWave(A)
677        CurveFit line CsrWaveRef(A)(xcsr(A),xcsr(B)) /X=CsrXWaveRef(A) /D
678        Tag/C/N=Curvefitres/F=0/A=MC $destwavename, 0.5*numpnts($destwavename), "\Z09Linear fit parameters are: \ry="+num2str(W_coef[0])+"+ x *"+num2str(W_coef[1])
679end
680
681Proc IR2P_FitPowerLawWithCursors()
682
683        string olddf=GetDataFolder(1)
684       
685        if (!DataFolderExists("root:Packages:FittingData:"))
686                NewDataFolder root:Packages:FittingData         //create Desmear folder, if it does not exist
687        endif
688
689        setDataFolder root:Packages:FittingData
690       
691        string name="MyFitWave"
692        string LegendName="Curvefitres"
693       
694        variable freeDestNum=IR2P_FindFreeDestWaveNumber(name)
695        name=name +num2istr(freeDestNum)
696        LegendName=LegendName+num2istr(freeDestNum)
697        Make/D/O/N=(numpnts($(getWavesDataFolder(CsrWaveRef(A),2)))) LogYFitData, $name
698        $name=NaN
699        Make/D/O/N=(numpnts($(getWavesDataFolder(CsrXWaveRef(A),2)))) LogXFitData
700        LogXFitData=log($(getWavesDataFolder(CsrXWaveRef(A),2)))
701        LogYFitData=log($(getWavesDataFolder(CsrWaveRef(A),2)))
702        CurveFit line LogYFitData(xcsr(A),xcsr(B)) /X=LogXFitData /D=$name
703               
704        IR2P_LogPowerWithNaNsRetained($name)
705       
706        //here we will try to figure out, if the data are plotted wrt to leftor right axis...
707        string YwvName=CsrWave(A)
708        string AxType=StringByKey("AXISFLAGS", TraceInfo("",YwvName,0) )//this checks only for first occurence of the wave with this name
709        //this needs to be made more clever, other axis and other occurenc es of the wave with the name...
710        if (cmpstr(AxType,"/R")==0)
711                Append/R $name vs CsrXWaveRef(A)
712        else
713                Append $name vs CsrXWaveRef(A)
714        endif
715        Modify lsize($name)=2
716        String pw=num2str(K1),pr=num2str(10^K0),DIN=num2str((V_siga*10^K0)/2.3026),ca=num2str(pcsr(A)),cb=num2str(pcsr(B)),gf=num2str(V_Pr),DP=num2str(V_sigb)
717        Tag/C/N=$LegendName/F=0/A=MC  $name, (pcsr(A)+pcsr(B))/2, "\Z10Power Law Slope= "+pw+"\Z10 ± "+DP+"\Z08\rPrefactor= "+pr+"\Z08 cm\S-1\M\Z08 ± "+DIN+"\Z08\rx Cursor A::B= "+ca+"\Z08 :: "+cb+"\Z08\rGoodness of fit= "+gf
718
719        KillWaves/Z LogYFitData, LogXFitData
720
721        SetDataFolder $olddf
722end
723
724Function IR2P_FindFreeDestWaveNumber(name)
725        string name
726       
727        variable i=0
728        Do
729                if (exists(name+num2istr(i))==0)
730                        return i
731                endif
732        i+=1
733        while (i<50)
734end
735
736Function IR2P_LogPowerWithNaNsRetained(MyFitWave)
737        wave MyFitWave
738       
739        variable PointsNumber=numpnts(MyFitWave)
740        variable i=0
741        Do
742                if (numtype(MyFitWave[i])==0)
743                        MyFitWave[i]=10^(MyFitWave[i])
744                endif
745        i+=1
746        while (i<PointsNumber)
747end
748//*****************************************
749
750Function IR2P_DrawLineOf3Slope()
751        IR2P_DrawLineOfRequiredSlope(3,3,1,"-3")
752End
753
754//*****************************************
755
756Function IR2P_DrawLineOf2Slope()
757        IR2P_DrawLineOfRequiredSlope(2,2,1,"-2")
758End
759//*****************************************
760
761Function IR2P_DrawLineOf4Slope()
762        IR2P_DrawLineOfRequiredSlope(4,4,1,"-4")
763End
764//*****************************************
765Function IR2P_DrawLineOfAnySlope()
766
767        Variable lineslope,YourNumber,qlabel
768        string label1
769        Prompt lineslope, "Enter slope of line, or select Your number",Popup,"M1;M2;M3;M4;M5;M3.5;M4.5;M2.5;M1.5;Your Number;Vertical;Horizontal;5/3"
770        Prompt YourNumber,"If Your number above selected, enter here a number for the slope:"
771        Prompt qlabel,"Add a Label?",popup,"Power From Above;My own;No"
772        Prompt label1,"If Yes, then here type your label?"
773
774        DoPrompt "Draw line of any slope, select parameters", lineslope, Yournumber, qlabel, label1
775        if (V_Flag)
776                        Abort
777        endif
778        Silent 1
779        do
780                if(lineslope==12)
781                        lineslope=0
782                        break
783                endif
784                if(lineslope==10)
785                        lineslope=YourNumber
786                        break
787                endif
788                if(lineslope==6)
789                        lineslope=3.5
790                        break
791                endif
792                if(lineslope==7)
793                        lineslope=4.5
794                        break
795                endif
796                if(lineslope==8)
797                        lineslope=2.5
798                        break
799                endif
800                if(lineslope==9)
801                        lineslope=1.5
802                        break
803                endif
804                if(lineslope==13)
805                        lineslope=5/3
806                        break
807                endif
808                break
809        while(1)
810
811        IR2P_DrawLineOfRequiredSlope(LineSlope,YourNumber,qLabel,label1)
812end
813
814
815Function IR2P_DrawLineOfRequiredSlope(LineSlope,YourNumber,qLabel,label1)
816        Variable lineslope,YourNumber,qlabel
817        string label1
818       
819        SetDrawEnv xcoord= bottom,ycoord= left,save
820        variable X_start, Y_start
821        getAxis bottom
822        X_start=ceil((floor(log(V_max))+floor(log(V_min)))/2)
823        getAxis left
824        Y_start=ceil((ceil(log(V_max))+ceil(log(V_min)))/2)
825        if(lineslope==11)                                                                                                               //Vertical
826                drawline 10^(X_start),10^(Y_start),10^(X_start+1),10^(Y_start)
827        else
828                drawline 10^(X_start),10^(Y_start),10^(X_start+1),10^(Y_start-lineslope)
829        endif
830        if(qlabel==2)
831                SetDrawEnv fname= "Times",fstyle= 1;DelayUpdate
832                DrawText 10^(X_start),10^(Y_start-1),Label1
833        else
834                if(qlabel==1)//use power from above
835                        SetDrawEnv fname= "Times",fstyle= 1;DelayUpdate
836                        DrawText 10^(X_start),10^(Y_start-1),("-"+num2str(lineslope))
837                endif
838        endif
839EndMacro
840
841
842
843//*****************************************************************************************************************
844//*****************************************************************************************************************
845//*****************************************************************************************************************
846Function IR2_GetIrenaManuscript()
847
848                string WhereIsManuscript
849                string WhereAreProcedures=RemoveEnding(FunctionPath(""),"IR1_Main.ipf")
850                String ManuscriptPath = ParseFilePath(5,"IrenaManuscript.pdf","*",0,0)
851        String cmd
852        print "Irena manuscript reference: "
853        print "Jan Ilavsky and Pete R. Jemian, Irena: tool suite for modeling and analysis of small-angle scattering"
854        print "Journal of Applied Crystallography (2009), 42, 347-353"
855        variable refnum
856        GetFileFolderInfo/Z=1/Q WhereAreProcedures+ManuscriptPath
857        variable foundIt=V_Flag
858        if(foundIt!=0)
859        NewPath/O/Q tempPath, WhereAreProcedures
860                DoAlert 1,  "Local copy of manuscript not found. Should Igor try to download from APS public web site?"
861                if(V_Flag==1)
862                        string url="ftp://ftp.xor.aps.anl.gov/pub/usaxs/IrenaManuscript.pdf"
863                        FTPDownload /O/V=7/P=tempPath/Z url, "IrenaManuscript.pdf"     
864                        if(V_flag!=0)   //ftp failed...
865                                Abort "ftp of manuscript failed, please send e-mail to author to get your copy"
866                        endif
867                else
868                        abort
869                endif
870                killPath tempPath
871        endif
872       
873       
874        if (stringmatch(IgorInfo(2), "*Macintosh*"))
875               sprintf cmd "tell application \"Finder\" to open \"%s\"",WhereAreProcedures+ManuscriptPath
876               ExecuteScriptText cmd
877                if (strlen(S_value)>2)
878//                      DoAlert 0, S_value
879                endif
880
881        else
882                WhereAreProcedures=ParseFilePath(5,WhereAreProcedures,"*",0,0)
883                WhereIsManuscript = "\"" + WhereAreProcedures+ManuscriptPath+"\""
884                NewNotebook/F=0 /N=NewBatchFile
885                Notebook NewBatchFile, text=WhereIsManuscript//+"\r"
886                SaveNotebook/O NewBatchFile as SpecialDirPath("Temporary", 0, 1, 0 )+"StartManual.bat"
887                DoWindow/K NewBatchFile
888                ExecuteScriptText "\""+SpecialDirPath("Temporary", 0, 1, 0 )+"StartManual.bat\""
889        endif
890
891
892end
893
894//*****************************************************************************************************************
895//*****************************************************************************************************************
896Function IR2_OpenIrenaManual()
897        //this function writes batch file and starts the manual.
898        //we need to write following batch file: "C:\Program Files\WaveMetrics\Igor Pro Folder\User Procedures\Irena\Irena manual.pdf"
899        //on Mac we just fire up the Finder with Mac type path...
900       
901        //check where we run...
902                //string WhereIsIgor
903                //pathInfo Igor
904                string WhereIsManual
905                string WhereAreProcedures=RemoveEnding(FunctionPath(""),"IR1_Main.ipf")
906                String manualPath = ParseFilePath(5,"Irena Manual.pdf","*",0,0)
907        String cmd
908       
909        variable refnum
910        GetFileFolderInfo/Z=1/Q WhereAreProcedures+manualPath
911        variable foundIt=V_Flag
912        variable ManualModDate=V_modificationDate
913        //printf "The current manual date is: %+015.4f\r", V_modificationDate
914        if(ManualModDate>0)
915                //print  V_modificationDate
916                print "Found version of Manual is from : " + secs2Date(ManualModDate,1)
917        endif
918        if(foundIt!=0 || ManualModDate<CurrentManualDateInSecs)
919        NewPath/O/Q tempPath, WhereAreProcedures
920                DoAlert 1,  "Local copy of manual not found or is obsolete. Should Igor try to download from APS public web site?"
921                if(V_Flag==1)
922                        string url="ftp://ftp.xor.aps.anl.gov/pub/usaxs/Irena Manual.pdf"
923                        FTPDownload /O/V=7/P=tempPath/Z url, "Irena Manual.pdf"
924                        if(V_flag!=0)   //ftp failed...
925                                Abort "ftp of manual failed, please download the manual from web site and place into ..\Irena folder with the macros."
926                        endif
927                else
928                        abort
929                endif
930                killPath tempPath
931        endif
932       
933        if (stringmatch(IgorInfo(2), "*Macintosh*"))
934             //  manualPath = "User Procedures:Irena:Irena manual.pdf"
935               sprintf cmd "tell application \"Finder\" to open \"%s\"",WhereAreProcedures+manualPath
936               ExecuteScriptText cmd
937                if (strlen(S_value)>2)
938//                      DoAlert 0, S_value
939                endif
940
941        else
942                //manualPath = "User Procedures\Irena\Irena manual.pdf"
943                //WhereIsIgor=WhereIsIgor[0,1]+"\\"+IN2G_ChangePartsOfString(WhereIsIgor[2,inf],":","\\")
944                WhereAreProcedures=ParseFilePath(5,WhereAreProcedures,"*",0,0)
945                whereIsManual = "\"" + WhereAreProcedures+manualPath+"\""
946                NewNotebook/F=0 /N=NewBatchFile
947                Notebook NewBatchFile, text=whereIsManual//+"\r"
948                SaveNotebook/O NewBatchFile as SpecialDirPath("Temporary", 0, 1, 0 )+"StartManual.bat"
949                DoWindow/K NewBatchFile
950                ExecuteScriptText "\""+SpecialDirPath("Temporary", 0, 1, 0 )+"StartManual.bat\""
951        endif
952end
953//*****************************************************************************************************************
954//*****************************************************************************************************************
955Function IR2_OpenHelpMoviePage()
956        DoAlert 1,"Your web browser will open page with help movies. OK? (You must have QuickTime installed)"
957        if(V_flag==1)
958                BrowseURL "http://usaxs.xor.aps.anl.gov/staff/ilavsky/IrenaHelpMovies.html"
959        endif
960End
961
962Function IR2_OpenIrenaPage()
963        DoAlert 1,"Your web browser will Irena home page. OK?"
964        if(V_flag==1)
965                BrowseURL "http://usaxs.xor.aps.anl.gov/staff/ilavsky/irena.html"
966        endif
967End
968
969Function IR2_SignUpForMailingList()
970        DoAlert 1,"Your web browser will open page with the page where you can control your maling list options. OK?"
971        if(V_flag==1)
972                BrowseURL "http://www.aps.anl.gov/mailman/listinfo/irena_users"
973        endif
974End
975
976
977
978//*****************************************************************************************************************
979//*****************************************************************************************************************
980//*****************************************************************************************************************
981
982
983Function IR1_AboutPanel()
984        DoWindow About_Irena_1_Macros
985        if(V_Flag)
986                DoWindow/K About_Irena_1_Macros
987        endif
988
989//      PauseUpdate; Silent 1           // building window...
990        NewPanel/K=1 /W=(173.25,50,580,460) as "About_Irena_1_Macros"
991        DoWindow/C About_Irena_1_Macros
992        SetDrawLayer UserBack
993        SetDrawEnv fsize= 20,fstyle= 1,textrgb= (16384,28160,65280)
994        DrawText 23,30,"Irena macros for Igor Pro >=6.22A"
995        SetDrawEnv fsize= 16,textrgb= (16384,28160,65280)
996        DrawText 100,60,"@ ANL, 2013"
997        DrawText 10,80,"release "+num2str(CurrentVersionNumber)
998        DrawText 11,100,"To get help please contact: ilavsky@aps.anl.gov"
999        SetDrawEnv textrgb= (0,0,65535)
1000        DrawText 11,120,"http://usaxs.xor.aps.anl.gov/staff/ilavsky/irena.htm"
1001        SetDrawEnv fsize= 14, fstyle=1
1002        DrawText 11,148,"Reference: Jan Ilavsky and Pete R. Jemian"
1003        SetDrawEnv fsize= 14, fstyle=1
1004        DrawText 11,168,"J Appl Crystallogr (2009), 42, 347-353"
1005
1006        DrawText 11,195,"Size distribution by Pete Jemian: jemian@anl.gov"
1007        DrawText 11,215,"Unified model by Gregg Beaucage: gbeaucag@uceng.uc.edu"
1008        DrawText 11,230," Beaucage, G. (1995). J Appl Crystallogr 28, 717-728."
1009        DrawText 11,250," Fractals model by Andrew Allen: Andrew.Allen@nist.gov"
1010        DrawText 11,265," Allen, A. J. (2005). J Am Ceram Soc 88, 1367-1381. "
1011        DrawText 11,285," Reflectivity & Genetic Optimization by Andrew Nelson "
1012        DrawText 11,300," (Australian Nuclear Science and Technology Organisation) "
1013        DrawText 11,315,"             Nelson, A. (2006). J Appl Crystallogr 39, 273-276."
1014        DrawText 11,330,"             andyfaff@gmail.com"
1015        DrawText 11,350,"Selected Structure & Form Factors refs: "
1016        DrawText 11,365,"       Kline, S. R. (2006). J Appl Crystallogr 39, 895-900"
1017        DrawText 11,380,"http://www.ncnr.nist.gov/programs/sans/data/data_red.html"
1018// (). 
1019end
1020
1021//*****************************************************************************************************************
1022//*****************************************************************************************************************
1023//*****************************************************************************************************************
1024//*****************************************************************************************************************
1025//*****************************************************************************************************************
1026
1027
1028Function IR1_RemoveSASMac()
1029                Execute/P "IR1_KillGraphsAndPanels()"
1030                Execute/P "DELETEINCLUDE \"IR1_Loader\""
1031                SVAR strChagne=root:Packages:SASItem1Str
1032                strChagne= "Load Irena SAS Modeling Macros"
1033                BuildMenu "SAS"
1034                Execute/P "COMPILEPROCEDURES "
1035end
1036
1037
1038
1039//*****************************************************************************************************************
1040//*****************************************************************************************************************
1041//*****************************************************************************************************************
1042//*****************************************************************************************************************
1043//*****************************************************************************************************************
1044
1045Function IR1S_LSQF_StandardModelsMain()
1046
1047        IN2G_CheckScreenSize("height",670)
1048
1049        DoWindow IR1S_ControlPanel
1050        if (V_Flag)
1051                DoWindow/K IR1S_ControlPanel   
1052        endif
1053        DoWindow IR1_LogLogPlotLSQF
1054        if (V_Flag)
1055                DoWindow/K IR1_LogLogPlotLSQF   
1056        endif
1057        DoWindow IR1_IQ4_Q_PlotLSQF
1058        if (V_Flag)
1059                DoWindow/K IR1_IQ4_Q_PlotLSQF   
1060        endif
1061        DoWindow IR1_Model_Distributions
1062        if (V_Flag)
1063                DoWindow/K IR1_Model_Distributions     
1064        endif
1065        DoWindow IR1S_InterferencePanel
1066        if (V_Flag)
1067                DoWindow/K IR1S_InterferencePanel
1068        endif
1069        IR1T_InitFormFactors()
1070        IR1S_Initialize()
1071        IR1_CreateLoggbook()
1072        //IR1_KillGraphsAndPanels()     
1073        Execute ("IR1S_ControlPanel()")
1074end
1075
1076
1077//*****************************************************************************************************************
1078//*****************************************************************************************************************
1079//*****************************************************************************************************************
1080//*****************************************************************************************************************
1081//*****************************************************************************************************************
1082
1083Function IR1S_Initialize()
1084        //function, which creates the folder for SAS modeling and creates the strings and variables
1085       
1086        string oldDf=GetDataFolder(1)
1087       
1088        NewDataFolder/O/S root:Packages
1089        NewdataFolder/O/S root:Packages:SAS_Modeling
1090       
1091        string ListOfVariables
1092        string ListOfStrings
1093       
1094        //here define the lists of variables and strings needed, separate names by ;...
1095       
1096        ListOfVariables="UseIndra2Data;UseQRSdata;NumberOfDistributions;DisplayVD;DisplayND;CurrentTab;UseInterference;UseLSQF;UseGenOpt;"
1097        ListOfVariables+="Dist1NumberOfPoints;Dist1Contrast;Dist1Location;Dist1Scale;Dist1Shape;Dist1Mean;Dist1Median;Dist1Mode;Dist1LocHighLimit;Dist1LocLowLimit;Dist1ScaleHighLimit;Dist1ScaleLowLimit;"
1098        ListOfVariables+="Dist1ShapeHighLimit;Dist1ShapeLowLimit;Dist1LocStep;Dist1ShapeStep;Dist1ScaleStep;Dist1FitShape;Dist1FitLocation;Dist1FitScale;Dist1VolFraction;"
1099        ListOfVariables+="Dist1VolHighLimit;Dist1VolLowLimit;Dist1FitVol;Dist1NegligibleFraction;Dist1ScatShapeParam1;Dist1ScatShapeParam2;Dist1ScatShapeParam3;Dist1FWHM;"
1100        ListOfVariables+="Dist2NumberOfPoints;Dist2Contrast;Dist2Location;Dist2Scale;Dist2Shape;Dist2Mean;Dist2Median;Dist2Mode;Dist2LocHighLimit;Dist2LocLowLimit;Dist2ScaleHighLimit;Dist2ScaleLowLimit;"
1101        ListOfVariables+="Dist2ShapeHighLimit;Dist2ShapeLowLimit;Dist2LocStep;Dist2ShapeStep;Dist2ScaleStep;Dist2FitShape;Dist2FitLocation;Dist2FitScale;Dist2VolFraction;"
1102        ListOfVariables+="Dist2VolHighLimit;Dist2VolLowLimit;Dist2FitVol;Dist2NegligibleFraction;Dist2ScatShapeParam1;Dist2ScatShapeParam2;Dist2ScatShapeParam3;Dist2FWHM;"
1103        ListOfVariables+="Dist3NumberOfPoints;Dist3Contrast;Dist3Location;Dist3Scale;Dist3Shape;Dist3Mean;Dist3Median;Dist3Mode;Dist3LocHighLimit;Dist3LocLowLimit;Dist3ScaleHighLimit;Dist3ScaleLowLimit;"
1104        ListOfVariables+="Dist3ShapeHighLimit;Dist3ShapeLowLimit;Dist3LocStep;Dist3ShapeStep;Dist3ScaleStep;Dist3FitShape;Dist3FitLocation;Dist3FitScale;Dist3VolFraction;"
1105        ListOfVariables+="Dist3VolHighLimit;Dist3VolLowLimit;Dist3FitVol;Dist3NegligibleFraction;Dist3ScatShapeParam1;Dist3ScatShapeParam2;Dist3ScatShapeParam3;Dist3FWHM;"
1106        ListOfVariables+="Dist4NumberOfPoints;Dist4Contrast;Dist4Location;Dist4Scale;Dist4Shape;Dist4Mean;Dist4Median;Dist4Mode;Dist4LocHighLimit;Dist4LocLowLimit;Dist4ScaleHighLimit;Dist4ScaleLowLimit;"
1107        ListOfVariables+="Dist4ShapeHighLimit;Dist4ShapeLowLimit;Dist4LocStep;Dist4ShapeStep;Dist4ScaleStep;Dist4FitShape;Dist4FitLocation;Dist4FitScale;Dist4VolFraction;"
1108        ListOfVariables+="Dist4VolHighLimit;Dist4VolLowLimit;Dist4FitVol;Dist4NegligibleFraction;Dist4ScatShapeParam1;Dist4ScatShapeParam2;Dist4ScatShapeParam3;Dist4FWHM;"
1109        ListOfVariables+="Dist5NumberOfPoints;Dist5Contrast;Dist5Location;Dist5Scale;Dist5Shape;Dist5Mean;Dist5Median;Dist5Mode;Dist5LocHighLimit;Dist5LocLowLimit;Dist5ScaleHighLimit;Dist5ScaleLowLimit;"
1110        ListOfVariables+="Dist5ShapeHighLimit;Dist5ShapeLowLimit;Dist5LocStep;Dist5ShapeStep;Dist5ScaleStep;Dist5FitShape;Dist5FitLocation;Dist5FitScale;Dist5VolFraction;"
1111        ListOfVariables+="Dist5VolHighLimit;Dist5VolLowLimit;Dist5FitVol;Dist5NegligibleFraction;Dist5ScatShapeParam1;Dist5ScatShapeParam2;Dist5ScatShapeParam3;Dist5FWHM;"
1112        ListOfVariables+="SASBackground;SASBackgroundStep;FitSASBackground;UseNumberDistribution;UseVolumeDistribution;UpdateAutomatically;"
1113        ListOfVariables+="SASBackgroundError;Dist1LocationError;Dist1ScaleError;Dist1ShapeError;Dist1VolFractionError;"
1114        ListOfVariables+="Dist1LocationError;Dist1ScaleError;Dist1ShapeError;Dist1VolFractionError;"
1115        ListOfVariables+="Dist2LocationError;Dist2ScaleError;Dist2ShapeError;Dist2VolFractionError;"
1116        ListOfVariables+="Dist3LocationError;Dist3ScaleError;Dist3ShapeError;Dist3VolFractionError;"
1117        ListOfVariables+="Dist4LocationError;Dist4ScaleError;Dist4ShapeError;Dist4VolFractionError;"
1118        ListOfVariables+="Dist5LocationError;Dist5ScaleError;Dist5ShapeError;Dist5VolFractionError;"
1119        ListOfVariables+="Dist1UseInterference;Dist1InterferencePhi;Dist1InterferenceEta;Dist1InterferencePhiLL;Dist1InterferencePhiHL;Dist1InterferenceEtaLL;Dist1InterferenceEtaHL;"
1120        ListOfVariables+="Dist2UseInterference;Dist2InterferencePhi;Dist2InterferenceEta;Dist2InterferencePhiLL;Dist2InterferencePhiHL;Dist2InterferenceEtaLL;Dist2InterferenceEtaHL;"
1121        ListOfVariables+="Dist3UseInterference;Dist3InterferencePhi;Dist3InterferenceEta;Dist3InterferencePhiLL;Dist3InterferencePhiHL;Dist3InterferenceEtaLL;Dist3InterferenceEtaHL;"
1122        ListOfVariables+="Dist4UseInterference;Dist4InterferencePhi;Dist4InterferenceEta;Dist4InterferencePhiLL;Dist4InterferencePhiHL;Dist4InterferenceEtaLL;Dist4InterferenceEtaHL;"
1123        ListOfVariables+="Dist5UseInterference;Dist5InterferencePhi;Dist5InterferenceEta;Dist5InterferencePhiLL;Dist5InterferencePhiHL;Dist5InterferenceEtaLL;Dist5InterferenceEtaHL;"
1124        ListOfVariables+="Dist1FitInterferencePhi;Dist2FitInterferencePhi;Dist3FitInterferencePhi;Dist4FitInterferencePhi;Dist5FitInterferencePhi;"
1125        ListOfVariables+="Dist1FitInterferenceETA;Dist2FitInterferenceETA;Dist3FitInterferenceETA;Dist4FitInterferenceETA;Dist5FitInterferenceETA;"
1126        ListOfVariables+="Dist1InterferencePhiError;Dist1InterferenceEtaError;Dist2InterferencePhiError;Dist2InterferenceEtaError;"
1127        ListOfVariables+="Dist3InterferencePhiError;Dist3InterferenceEtaError;Dist4InterferencePhiError;Dist4InterferenceEtaError;"
1128        ListOfVariables+="Dist5InterferencePhiError;Dist5InterferenceEtaError;"
1129        ListOfVariables+="UseSlitSmearedData;SlitLength;"       
1130        //Ok add chance to fit the shape parameters
1131        ListOfVariables+="Dist1FitScatShapeParam1;Dist1ScatShapeParam1LowLimit;Dist1ScatShapeParam1HighLimit;Dist1FitScatShapeParam2;Dist1ScatShapeParam2LowLimit;Dist1ScatShapeParam2HighLimit;Dist1FitScatShapeParam3;Dist1ScatShapeParam3LowLimit;Dist1ScatShapeParam3HighLimit;"
1132        ListOfVariables+="Dist2FitScatShapeParam1;Dist2ScatShapeParam1LowLimit;Dist2ScatShapeParam1HighLimit;Dist2FitScatShapeParam2;Dist2ScatShapeParam2LowLimit;Dist2ScatShapeParam2HighLimit;Dist2FitScatShapeParam3;Dist2ScatShapeParam3LowLimit;Dist2ScatShapeParam3HighLimit;"
1133        ListOfVariables+="Dist3FitScatShapeParam1;Dist3ScatShapeParam1LowLimit;Dist3ScatShapeParam1HighLimit;Dist3FitScatShapeParam2;Dist3ScatShapeParam2LowLimit;Dist3ScatShapeParam2HighLimit;Dist3FitScatShapeParam3;Dist3ScatShapeParam3LowLimit;Dist3ScatShapeParam3HighLimit;"
1134        ListOfVariables+="Dist4FitScatShapeParam1;Dist4ScatShapeParam1LowLimit;Dist4ScatShapeParam1HighLimit;Dist4FitScatShapeParam2;Dist4ScatShapeParam2LowLimit;Dist4ScatShapeParam2HighLimit;Dist4FitScatShapeParam3;Dist4ScatShapeParam3LowLimit;Dist4ScatShapeParam3HighLimit;"
1135        ListOfVariables+="Dist5FitScatShapeParam1;Dist5ScatShapeParam1LowLimit;Dist5ScatShapeParam1HighLimit;Dist5FitScatShapeParam2;Dist5ScatShapeParam2LowLimit;Dist5ScatShapeParam2HighLimit;Dist5FitScatShapeParam3;Dist5ScatShapeParam3LowLimit;Dist5ScatShapeParam3HighLimit;"
1136        ListOfVariables+="Dist1ScatShapeParam4;Dist1ScatShapeParam5;"
1137        ListOfVariables+="Dist2ScatShapeParam4;Dist2ScatShapeParam5;"
1138        ListOfVariables+="Dist3ScatShapeParam4;Dist3ScatShapeParam5;"
1139        ListOfVariables+="Dist4ScatShapeParam4;Dist4ScatShapeParam5;"
1140        ListOfVariables+="Dist5ScatShapeParam4;Dist5ScatShapeParam5;"
1141        ListOfVariables+="Dist1ScatShapeParam1Error;Dist1ScatShapeParam2Error;Dist1ScatShapeParam3Error;"
1142        ListOfVariables+="Dist2ScatShapeParam1Error;Dist2ScatShapeParam2Error;Dist2ScatShapeParam3Error;"
1143        ListOfVariables+="Dist3ScatShapeParam1Error;Dist3ScatShapeParam2Error;Dist3ScatShapeParam3Error;"
1144        ListOfVariables+="Dist4ScatShapeParam1Error;Dist4ScatShapeParam2Error;Dist4ScatShapeParam3Error;"
1145        ListOfVariables+="Dist5ScatShapeParam1Error;Dist5ScatShapeParam2Error;Dist5ScatShapeParam3Error;WallThicknessSpreadInFract;"
1146        ListOfVariables+="Dist1UserFFParam1;Dist1UserFFParam2;Dist1UserFFParam3;Dist1UserFFParam4;Dist1UserFFParam5;"
1147        ListOfVariables+="Dist2UserFFParam1;Dist2UserFFParam2;Dist2UserFFParam3;Dist2UserFFParam4;Dist2UserFFParam5;"
1148        ListOfVariables+="Dist3UserFFParam1;Dist3UserFFParam2;Dist3UserFFParam3;Dist3UserFFParam4;Dist3UserFFParam5;"
1149        ListOfVariables+="Dist4UserFFParam1;Dist4UserFFParam2;Dist4UserFFParam3;Dist4UserFFParam4;Dist4UserFFParam5;"
1150        ListOfVariables+="Dist5UserFFParam1;Dist5UserFFParam2;Dist5UserFFParam3;Dist5UserFFParam4;Dist5UserFFParam5;"
1151
1152        ListOfStrings="DataFolderName;IntensityWaveName;QWavename;ErrorWaveName;"
1153        ListOfStrings+="Dist1ShapeModel;Dist1DistributionType;Dist1UserFormFactorFnct;Dist1UserVolumeFnct;"
1154        ListOfStrings+="Dist2ShapeModel;Dist2DistributionType;Dist2UserFormFactorFnct;Dist2UserVolumeFnct;"
1155        ListOfStrings+="Dist3ShapeModel;Dist3DistributionType;Dist3UserFormFactorFnct;Dist3UserVolumeFnct;"
1156        ListOfStrings+="Dist4ShapeModel;Dist4DistributionType;Dist4UserFormFactorFnct;Dist4UserVolumeFnct;"
1157        ListOfStrings+="Dist5ShapeModel;Dist5DistributionType;Dist5UserFormFactorFnct;Dist5UserVolumeFnct;"
1158       
1159        String/g GaussEquation="P(x)=(1/(Width*sqrt(2*pi)) * exp(-(x-Mean)^2/(2*Width^2))"
1160        String/g LogNormalEquation="P(x)=(1/((x-Min)*Mean*sqrt(2*pi)) * exp(-ln((x-Mean)/sdev)^2/(2*sdev^2))"
1161        String/g LSWEquation="P(x)=A*(loc^2*exp(-loc/(1.5-loc)))/((1.5-loc)^(11/3)*(3+loc)^(7/3))"
1162        String/g PowerLawEquation="P(x)= x ^ -(1+(6-slope))"
1163       
1164        variable i
1165        //and here we create them
1166        for(i=0;i<itemsInList(ListOfVariables);i+=1)   
1167                IN2G_CreateItem("variable",StringFromList(i,ListOfVariables))
1168        endfor         
1169                               
1170        for(i=0;i<itemsInList(ListOfStrings);i+=1)     
1171                IN2G_CreateItem("string",StringFromList(i,ListOfStrings))
1172        endfor 
1173        //cleanup after possible previous fitting stages...
1174        Wave/Z CoefNames=root:Packages:SAS_Modeling:CoefNames
1175        Wave/Z CoefficientInput=root:Packages:SAS_Modeling:CoefficientInput
1176        KillWaves/Z CoefNames, CoefficientInput
1177       
1178        IR1S_SetInitialValues()
1179end
1180
1181
1182//*****************************************************************************************************************
1183//*****************************************************************************************************************
1184//*****************************************************************************************************************
1185//*****************************************************************************************************************
1186//*****************************************************************************************************************
1187
1188Function IR1S_SetInitialValues()
1189        //and here set default values...
1190
1191        string OldDf=getDataFolder(1)
1192        setDataFolder root:Packages:SAS_Modeling
1193        NVAR UseQRSData=root:Packages:SAS_Modeling:UseQRSData
1194        NVAR UseIndra2data=root:Packages:SAS_Modeling:UseIndra2data
1195        NVAR NumberOfDistributions=root:Packages:SAS_Modeling:NumberOfDistributions
1196        NVAR DisplayND=root:Packages:SAS_Modeling:DisplayND
1197        NVAR DisplayVD=root:Packages:SAS_Modeling:DisplayVD
1198        NVAR FitSASBackground=root:Packages:SAS_Modeling:FitSASBackground
1199        NVAR UseNumberDistribution=root:Packages:SAS_Modeling:UseNumberDistribution
1200        NVAR UseVolumeDistribution=root:Packages:SAS_Modeling:UseVolumeDistribution                                             
1201        NVAR UpdateAutomatically=root:Packages:SAS_Modeling:UpdateAutomatically
1202       
1203        if (UseQRSData)
1204                UseIndra2data=0
1205        endif
1206        NumberOfDistributions=0
1207        DisplayND=0
1208        DisplayVD=1
1209       
1210        if (FitSASBackground==0)
1211                FitSASBackground=1
1212        endif
1213       
1214        if (UseNumberDistribution==0 && UseVolumeDistribution==0)
1215                 UseVolumeDistribution=1
1216                 UseNumberDistribution=0
1217        endif
1218               
1219        NVAR UseLSQF
1220        NVAR UseGenOpt
1221        if(UseLSQF+UseGenOpt!=1)
1222                UseLSQF=1
1223                UseGenOpt=0
1224        endif
1225       
1226        UpdateAutomatically=0
1227
1228        //and here we set distribution specific parameters....
1229       
1230        IR1S_SetInitialValuesForAdist(1)        //dist 1
1231        IR1S_SetInitialValuesForAdist(2)        //dist 2
1232        IR1S_SetInitialValuesForAdist(3)        //dist 3
1233        IR1S_SetInitialValuesForAdist(4)        //dist 4
1234        IR1S_SetInitialValuesForAdist(5)        //dist 5
1235
1236        setDataFolder oldDF
1237       
1238end     
1239
1240
1241//*****************************************************************************************************************
1242//*****************************************************************************************************************
1243//*****************************************************************************************************************
1244//*****************************************************************************************************************
1245//*****************************************************************************************************************
1246
1247Function IR1S_SetInitialValuesForAdist(distNum)
1248        variable distNum
1249        //default values for distribution 1
1250        string OldDf=GetDataFolder(1)
1251       
1252        setDataFOlder root:Packages:SAS_Modeling
1253       
1254        SVAR testStr =$("Dist"+num2str(distNum)+"UserFormFactorFnct")
1255        if(strlen(testStr)<1)
1256                testStr = "IR1T_ExampleSphereFFPoints"
1257        endif
1258        SVAR testStr =$("Dist"+num2str(distNum)+"UserVolumeFnct")
1259        if(strlen(testStr)<1)
1260                testStr = "IR1T_ExampleSphereVolume"
1261        endif
1262       
1263        NVAR testVar=$("Dist"+num2str(distNum)+"NumberOfPoints")
1264        if (testVar==0)
1265                 testVar=50
1266        endif
1267        NVAR testVar=$("Dist"+num2str(distNum)+"ScatShapeParam1")
1268        if(testVar==0)
1269                 testVar=1
1270        endif
1271        NVAR testVar=$("Dist"+num2str(distNum)+"ScatShapeParam2")
1272        if (testVar==0)
1273                 testVar=1
1274        endif
1275        NVAR testVar=$("Dist"+num2str(distNum)+"ScatShapeParam3")
1276        if (testVar==0)
1277                 testVar=1
1278        endif
1279       
1280        NVAR testVar=$("Dist"+num2str(distNum)+"NegligibleFraction")
1281        if (testVar==0)
1282                 testVar=0.01
1283        endif
1284        NVAR testVar=$("Dist"+num2str(distNum)+"VolHighLimit")
1285        if (testVar==0)
1286                 testVar=0.99
1287        endif
1288        NVAR testVar=$("Dist"+num2str(distNum)+"VolLowLimit")
1289        if (testVar==0)
1290                 testVar=0.00001
1291        endif
1292        NVAR testVar=$("Dist"+num2str(distNum)+"VolFraction")
1293        if (testVar==0)
1294                 testVar=0.05
1295        endif
1296        NVAR testVar=$("Dist"+num2str(distNum)+"FitVol")
1297        if (testVar==0)
1298                 testVar=1
1299        endif
1300        NVAR testVar=$("Dist"+num2str(distNum)+"FitShape")
1301        if (testVar==0)
1302                 testVar=1
1303        endif
1304        NVAR testVar=$("Dist"+num2str(distNum)+"FitLocation")
1305        if (testVar==0)
1306                 testVar=0
1307        endif
1308        NVAR testVar=$("Dist"+num2str(distNum)+"FitScale")
1309        if (testVar==0)
1310                 testVar=1
1311        endif
1312        NVAR testVar=$("Dist"+num2str(distNum)+"Contrast")
1313        if (testVar==0)
1314                 testVar=100
1315        endif
1316        NVAR testVar=$("Dist"+num2str(distNum)+"Scale")
1317        if (testVar==0)
1318                if (distNum==1)
1319                                 testVar=100
1320                endif
1321                if (distNum==2)
1322                                 testVar=400
1323                endif
1324                if (distNum==3)
1325                                 testVar=800
1326                endif
1327                if (distNum==4)
1328                                 testVar=1600
1329                endif
1330                if (distNum==5)
1331                                 testVar=3200
1332                endif
1333        endif
1334        NVAR testVar=$("Dist"+num2str(distNum)+"Location")
1335        if (testVar==0)
1336                 testVar=0
1337        endif
1338        NVAR testVar=$("Dist"+num2str(distNum)+"Shape")
1339        if (testVar==0)
1340                 testVar=0.5
1341        endif
1342        NVAR testVar=$("Dist"+num2str(distNum)+"LocHighLimit")
1343        if (testVar==0)
1344                 testVar=1000000
1345        endif
1346        NVAR testVar=$("Dist"+num2str(distNum)+"LocLowLimit")
1347        if (testVar==0)
1348                 testVar=10
1349        endif
1350        NVAR testVar=$("Dist"+num2str(distNum)+"ScaleHighLimit")
1351        if (testVar==0)
1352                 testVar=100000
1353        endif
1354        NVAR testVar=$("Dist"+num2str(distNum)+"ScaleLowLimit")
1355        if (testVar==0)
1356                 testVar=5
1357        endif
1358        NVAR testVar=$("Dist"+num2str(distNum)+"ShapeHighLimit")
1359        if (testVar==0)
1360                 testVar=0.9
1361        endif
1362        NVAR testVar=$("Dist"+num2str(distNum)+"ShapeLowLimit")
1363        if (testVar==0)
1364                 testVar=0.1
1365        endif
1366        NVAR testVar=$("Dist"+num2str(distNum)+"LocStep")
1367        if (testVar==0)
1368                 testVar=50
1369        endif
1370        NVAR testVar=$("Dist"+num2str(distNum)+"ShapeStep")
1371        if (testVar==0)
1372                 testVar=0.1
1373        endif
1374        NVAR testVar=$("Dist"+num2str(distNum)+"ScaleStep")
1375        if (testVar==0)
1376                 testVar=10
1377        endif
1378        SVAR testStr=$("Dist"+num2str(distNum)+"ShapeModel")
1379        if(strlen(testStr)==0)
1380                testStr="spheroid"
1381        endif
1382        SVAR testStr=$("Dist"+num2str(distNum)+"DistributionType")
1383        if(strlen(testStr)==0)
1384                testStr="LogNormal"
1385        endif
1386       
1387        NVAR testVar=$("Dist"+num2str(distNum)+"FitScatShapeParam1")
1388        if (testVar==0)
1389                 testVar=0
1390        endif
1391        NVAR testVar=$("Dist"+num2str(distNum)+"FitScatShapeParam2")
1392        if (testVar==0)
1393                 testVar=0
1394        endif
1395        NVAR testVar=$("Dist"+num2str(distNum)+"FitScatShapeParam3")
1396        if (testVar==0)
1397                 testVar=0
1398        endif
1399        NVAR testVar=$("Dist"+num2str(distNum)+"UseInterference")
1400        if (testVar==0)
1401                 testVar=0
1402        endif
1403        NVAR testVar=$("Dist"+num2str(distNum)+"InterferencePhi")
1404        if (testVar==0)
1405                 testVar=1
1406        endif
1407        NVAR testVar=$("Dist"+num2str(distNum)+"InterferencePhiHL")
1408        if (testVar==0)
1409                 testVar=8
1410        endif
1411        NVAR testVar=$("Dist"+num2str(distNum)+"InterferenceEta")
1412        if (testVar==0)
1413                 testVar=200
1414        endif
1415        NVAR testVar=$("Dist"+num2str(distNum)+"InterferenceEtaLL")
1416        if (testVar==0)
1417                 testVar=0
1418        endif
1419        NVAR testVar=$("Dist"+num2str(distNum)+"InterferenceEtaHL")
1420        if (testVar==0)
1421                 testVar=10000
1422        endif
1423
1424        setDataFolder oldDf
1425end
1426
1427
1428//*****************************************************************************************************************
1429//*****************************************************************************************************************
1430//*****************************************************************************************************************
1431//*****************************************************************************************************************
1432//*****************************************************************************************************************
1433
1434Function IR1_GraphMeasuredData(Package)
1435        string Package  //tells me, if this is called from Unified or LSQF
1436        //this function graphs data into the various graphs as needed
1437       
1438        string oldDf=GetDataFolder(1)
1439        setDataFolder root:Packages:SAS_Modeling
1440        SVAR DataFolderName
1441        SVAR IntensityWaveName
1442        SVAR QWavename
1443        SVAR ErrorWaveName
1444        variable cursorAposition, cursorBposition
1445       
1446        //fix for liberal names
1447        IntensityWaveName = PossiblyQuoteName(IntensityWaveName)
1448        QWavename = PossiblyQuoteName(QWavename)
1449        ErrorWaveName = PossiblyQuoteName(ErrorWaveName)
1450       
1451        WAVE/Z test=$(DataFolderName+IntensityWaveName)
1452        if (!WaveExists(test))
1453                abort "Error in IntensityWaveName wave selection"
1454        endif
1455        cursorAposition=0
1456        cursorBposition=numpnts(test)-1
1457        WAVE/Z test=$(DataFolderName+QWavename)
1458        if (!WaveExists(test))
1459                abort "Error in QWavename wave selection"
1460        endif
1461        WAVE/Z test=$(DataFolderName+ErrorWaveName)
1462        if (!WaveExists(test))
1463                abort "Error in ErrorWaveName wave selection"
1464        endif
1465        Duplicate/O $(DataFolderName+IntensityWaveName), OriginalIntensity
1466        Duplicate/O $(DataFolderName+QWavename), OriginalQvector
1467        Duplicate/O $(DataFolderName+ErrorWaveName), OriginalError
1468        Redimension/D OriginalIntensity, OriginalQvector, OriginalError
1469        wavestats /Q OriginalQvector
1470        if(V_min<0)
1471                OriginalQvector = OriginalQvector[p]<=0 ? NaN : OriginalQvector[p]
1472        endif
1473        IN2G_RemoveNaNsFrom3Waves(OriginalQvector,OriginalIntensity, OriginalError)
1474        NVAR/Z SubtractBackground=root:Packages:SAS_Modeling:SubtractBackground
1475        if(NVAR_Exists(SubtractBackground) && (cmpstr(Package,"Unified")==0))
1476                OriginalIntensity =OriginalIntensity - SubtractBackground
1477        endif
1478        NVAR/Z UseSlitSmearedData=root:Packages:SAS_Modeling:UseSlitSmearedData
1479        if(NVAR_Exists(UseSlitSmearedData) && (cmpstr(Package,"LSQF")==0))
1480                if(UseSlitSmearedData)
1481                        NVAR SlitLength=root:Packages:SAS_Modeling:SlitLength
1482                        variable tempSL=NumberByKey("SlitLength", note(OriginalIntensity) , "=" , ";")
1483                        if(numtype(tempSL)==0)
1484                                SlitLength=tempSL
1485                        endif
1486                endif
1487        endif
1488        NVAR/Z UseSMRData=root:Packages:SAS_Modeling:UseSMRData
1489        if(NVAR_Exists(UseSMRData) && (cmpstr(Package,"Unified")==0))
1490                if(UseSMRData)
1491                        NVAR SlitLengthUnif=root:Packages:SAS_Modeling:SlitLengthUnif
1492                        variable tempSL1=NumberByKey("SlitLength", note(OriginalIntensity) , "=" , ";")
1493                        if(numtype(tempSL1)==0)
1494                                SlitLengthUnif=tempSL1
1495                        endif
1496                endif
1497        endif
1498       
1499       
1500        if (cmpstr(Package,"Unified")==0)               //called from unified
1501                DoWindow IR1_LogLogPlotU
1502                if (V_flag)
1503                        Dowindow/K IR1_LogLogPlotU
1504                endif
1505                Execute ("IR1_LogLogPlotU()")
1506        elseif (cmpstr(Package,"LSQF")==0)
1507                DoWindow IR1_LogLogPlotLSQF
1508                if (V_flag)
1509                        cursorAposition=pcsr(A,"IR1_LogLogPlotLSQF")
1510                        cursorBposition=pcsr(B,"IR1_LogLogPlotLSQF")
1511                        Dowindow/K IR1_LogLogPlotLSQF
1512                endif
1513                Execute ("IR1_LogLogPlotLSQF()")
1514                cursor/P/W=IR1_LogLogPlotLSQF A, OriginalIntensity,cursorAposition
1515                cursor/P/W=IR1_LogLogPlotLSQF B, OriginalIntensity,cursorBposition
1516        endif
1517       
1518        Duplicate/O $(DataFolderName+IntensityWaveName), OriginalIntQ4
1519        Duplicate/O $(DataFolderName+QWavename), OriginalQ4
1520        Duplicate/O $(DataFolderName+ErrorWaveName), OriginalErrQ4
1521        Redimension/D OriginalIntQ4, OriginalQ4, OriginalErrQ4
1522        wavestats /Q OriginalQ4
1523        if(V_min<0)
1524                OriginalQ4 = OriginalQ4[p]<=0 ? NaN : OriginalQ4[p]
1525        endif
1526        IN2G_RemoveNaNsFrom3Waves(OriginalQ4,OriginalIntQ4, OriginalErrQ4)
1527
1528        if(NVAR_Exists(SubtractBackground) && (cmpstr(Package,"Unified")==0))
1529                OriginalIntQ4 =OriginalIntQ4 - SubtractBackground
1530        endif
1531       
1532        OriginalQ4=OriginalQ4^4
1533        OriginalIntQ4=OriginalIntQ4*OriginalQ4
1534        OriginalErrQ4=OriginalErrQ4*OriginalQ4
1535
1536        if (cmpstr(Package,"Unified")==0)               //called from unified
1537                DoWindow IR1_IQ4_Q_PlotU
1538                if (V_flag)
1539                        Dowindow/K IR1_IQ4_Q_PlotU
1540                endif
1541                Execute ("IR1_IQ4_Q_PlotU()")
1542        elseif (cmpstr(Package,"LSQF")==0)
1543                DoWindow IR1_IQ4_Q_PlotLSQF
1544                if (V_flag)
1545                        Dowindow/K IR1_IQ4_Q_PlotLSQF
1546                endif
1547                Execute ("IR1_IQ4_Q_PlotLSQF()")
1548        endif
1549        setDataFolder oldDf
1550end
1551
1552
1553//*****************************************************************************************************************
1554//*****************************************************************************************************************
1555//*****************************************************************************************************************
1556//*****************************************************************************************************************
1557//*****************************************************************************************************************
1558
1559Proc  IR1_IQ4_Q_PlotLSQF()
1560        PauseUpdate; Silent 1           // building window...
1561        String fldrSav= GetDataFolder(1)
1562        SetDataFolder root:Packages:SAS_Modeling:
1563        Display /W=(283.5,228.5,761.25,383)/K=1  OriginalIntQ4 vs OriginalQvector as "IQ4_Q_Plot"
1564        DoWindow/C IR1_IQ4_Q_PlotLSQF
1565        ModifyGraph mode(OriginalIntQ4)=3
1566        ModifyGraph msize(OriginalIntQ4)=1
1567        ModifyGraph log=1
1568        ModifyGraph mirror=1
1569        Label left "Intensity * Q^4"
1570        Label bottom "Q [A\\S-1\\M]"
1571        ErrorBars/Y=1 OriginalIntQ4 Y,wave=(OriginalErrQ4,OriginalErrQ4)
1572        TextBox/C/N=DateTimeTag/F=0/A=RB/E=2/X=2.00/Y=1.00 "\\Z07"+date()+", "+time()   
1573        TextBox/C/N=SampleNameTag/F=0/A=LB/E=2/X=2.00/Y=1.00 "\\Z07"+DataFolderName+IntensityWaveName   
1574        //and now some controls
1575//      ControlBar 30
1576//      Button SaveStyle size={80,20}, pos={50,5},proc=IR1U_StyleButtonCotrol,title="Save Style"
1577//      Button ApplyStyle size={80,20}, pos={150,5},proc=IR1U_StyleButtonCotrol,title="Apply Style"
1578        SetDataFolder fldrSav
1579        Execute/P("AutoPositionWindow/M=1 /R=IR1_LogLogPlotLSQF IR1_IQ4_Q_PlotLSQF")
1580        Execute/P("Dowindow/F IR1_LogLogPlotLSQF")
1581EndMacro
1582
1583
1584//*****************************************************************************************************************
1585//*****************************************************************************************************************
1586//*****************************************************************************************************************
1587//*****************************************************************************************************************
1588//*****************************************************************************************************************
1589
1590//Window IR1_IQ4_Q_PlotLSQF() : Graph
1591//      PauseUpdate; Silent 1           // building window...
1592//      String fldrSav= GetDataFolder(1)
1593//      SetDataFolder root:Packages:SAS_Modeling:
1594//      Display /W=(295.5,237.5,753.75,421.25)/K=1  OriginalIntQ4 vs OriginalQvector as "IQ4_Q_Plot"
1595//      SetDataFolder fldrSav
1596//      ModifyGraph mode=3
1597//      ModifyGraph msize=1
1598//      ModifyGraph log=1
1599//      ModifyGraph mirror=1
1600//      Label left "Intensity * Q^4"
1601//      Label bottom "Q [A\\S-1\\M]"
1602//      Legend/W=IR1_IQ4_Q_Plot/N=text0/J/F=0/A=MC/X=-29.74/Y=37.76 "\\s(OriginalIntQ4) Experimental intensity * Q^4"
1603//      ErrorBars/Y=1 OriginalIntQ4 Y,wave=(:Packages:SAS_Modeling:OriginalErrQ4,:Packages:SAS_Modeling:OriginalErrQ4)
1604//      //and now some controls
1605//      ControlBar 30
1606//      Button SaveStyle size={80,20}, pos={50,5},proc=IR1U_StyleButtonCotrol,title="Save Style"
1607//      Button ApplyStyle size={80,20}, pos={150,5},proc=IR1U_StyleButtonCotrol,title="Apply Style"
1608//EndMacro
1609
1610
1611//*****************************************************************************************************************
1612//*****************************************************************************************************************
1613//*****************************************************************************************************************
1614//*****************************************************************************************************************
1615//*****************************************************************************************************************
1616
1617Proc  IR1_LogLogPlotLSQF()
1618        PauseUpdate; Silent 1           // building window...
1619        String fldrSav= GetDataFolder(1)
1620        SetDataFolder root:Packages:SAS_Modeling:
1621        Display /W=(282.75,37.25,759.75,208.25)/K=1  OriginalIntensity vs OriginalQvector as "LogLogPlot"
1622        DoWindow/C IR1_LogLogPlotLSQF
1623        ModifyGraph mode(OriginalIntensity)=3
1624        ModifyGraph msize(OriginalIntensity)=1
1625        ModifyGraph log=1
1626        ModifyGraph mirror=1
1627        ShowInfo
1628        Label left "Intensity [cm\\S-1\\M]"
1629        Label bottom "Q [A\\S-1\\M]"
1630        Legend/W=IR1_LogLogPlotLSQF/N=text0/J/F=0/A=MC/X=32.03/Y=38.79 "\\s(OriginalIntensity) Experimental intensity"
1631        ErrorBars/Y=1 OriginalIntensity Y,wave=(OriginalError,OriginalError)
1632        //and now some controls
1633        TextBox/C/N=DateTimeTag/F=0/A=RB/E=2/X=2.00/Y=1.00 "\\Z07"+date()+", "+time()   
1634        TextBox/C/N=SampleNameTag/F=0/A=LB/E=2/X=2.00/Y=1.00 "\\Z07"+DataFolderName+IntensityWaveName   
1635//      ControlBar 30
1636//      Button SaveStyle size={80,20}, pos={50,5},proc=IR1U_StyleButtonCotrol,title="Save Style"
1637//      Button ApplyStyle size={80,20}, pos={150,5},proc=IR1U_StyleButtonCotrol,title="Apply Style"
1638        SetDataFolder fldrSav
1639        Execute /P("AutoPositionWindow/M=0 /R=IR1S_ControlPanel IR1_LogLogPlotLSQF")
1640EndMacro
1641
1642
1643//*****************************************************************************************************************
1644//*****************************************************************************************************************
1645//*****************************************************************************************************************
1646//*****************************************************************************************************************
1647//*****************************************************************************************************************
1648
1649Function IR1_CopyDataBackToFolder(StandardOrUser)
1650        string StandardOrUser
1651        //here we need to copy the final data back to folder
1652        //before that we need to also attach note to teh waves with the results
1653       
1654        string OldDf=getDataFOlder(1)
1655        setDataFolder root:Packages:SAS_Modeling
1656       
1657        Wave Distdiameters=root:Packages:SAS_Modeling:Distdiameters
1658        Wave TotalNumberDist=root:Packages:SAS_Modeling:TotalNumberDist
1659        Wave TotalVolumeDist=root:Packages:SAS_Modeling:TotalVolumeDist
1660        Wave DistModelIntensity=root:Packages:SAS_Modeling:DistModelIntensity
1661        Wave ModelQvector=root:Packages:SAS_Modeling:ModelQvector
1662       
1663        NVAR NumberOfDistributions=root:Packages:SAS_Modeling:NumberOfDistributions
1664        SVAR DataFolderName=root:Packages:SAS_Modeling:DataFolderName
1665       
1666        string UsersComment, ExportSeparateDistributions
1667        UsersComment="Result from Modeling "+date()+"  "+time()
1668        ExportSeparateDistributions="No"
1669        Prompt UsersComment, "Modify comment to be saved with these results"
1670        Prompt ExportSeparateDistributions, "Export separately populations data", popup, "No;Yes"
1671        DoPrompt "Need input for saving data", UsersComment, ExportSeparateDistributions
1672        if (V_Flag)
1673                abort
1674        endif
1675
1676        Duplicate/O Distdiameters, tempDistdiameters
1677        Duplicate/O TotalNumberDist, tempTotalNumberDist
1678        Duplicate/O TotalVolumeDist, tempTotalVolumeDist
1679        Duplicate/O DistModelIntensity, tempDistModelIntensity
1680        Duplicate/O ModelQvector, tempModelQvector
1681        string ListOfWavesForNotes="tempDistdiameters;tempTotalNumberDist;tempTotalVolumeDist;tempDistModelIntensity;tempModelQvector;"
1682
1683        IR1_AppendWaveNote(ListOfWavesForNotes,StandardOrUser)          //append wave notes
1684       
1685        variable j,i
1686        If(cmpstr(ExportSeparateDistributions,"Yes")==0)
1687                for(j=1;j<=NumberOfDistributions;j+=1)          //copy local populations
1688                        Wave tempDia=$("Dist"+num2str(j)+"diameters")           
1689                        Wave tempNumDis=$("Dist"+num2str(j)+"NumberDist")               
1690                        Wave tempVolDist=$("Dist"+num2str(j)+"VolumeDist")     
1691                        Duplicate/O tempDia, $("tempDist"+num2str(j)+"diameters")               
1692                        Duplicate/O tempNumDis, $("tempDist"+num2str(j)+"NumberDist")           
1693                        Duplicate/O tempVolDist, $("tempDist"+num2str(j)+"VolumeDist") 
1694                        ListOfWavesForNotes="tempDist"+num2str(j)+"diameters;tempDist"+num2str(j)+"NumberDist;tempDist"+num2str(j)+"VolumeDist;"
1695                        IR1_AppendWNOfDist(j,ListOfWavesForNotes, StandardOrUser)
1696                endfor
1697        endif
1698
1699        //need to change direction if user uses modeling here...
1700        if(stringmatch(DataFolderName,"root:Packages*"))
1701                string NewDataFolderStr="root:SASModels:"
1702                string tempNewDatFldrName=""
1703                Prompt NewDataFolderStr, "Trying to save model to Packages folder, suggest change the folder"
1704                DoPrompt "Override the data saving target",  NewDataFolderStr
1705                if(V_Flag)
1706                        abort
1707                endif
1708                SetDataFolder root:
1709                if(!Stringmatch(NewDataFolderStr[Strlen(NewDataFolderStr)-1],":"))
1710                        NewDataFolderStr+=":"
1711                endif   
1712                for(i=0;i<ItemsInList(NewDataFolderStr,":");i+=1)
1713                        if(!StringMatch(StringFromList(i,NewDataFolderStr,":"),"root"))
1714                                NewDataFolder/O/S $(StringFromList(i,NewDataFolderStr,":"))
1715                        endif
1716                        tempNewDatFldrName+=possiblyQuoteName(StringFromList(i,NewDataFolderStr,":"))+":"
1717                endfor
1718                setDataFolder $tempNewDatFldrName
1719        else
1720                setDataFolder $DataFolderName   
1721        endif
1722        string tempname
1723        variable ii=0
1724        For(ii=0;ii<1000;ii+=1)
1725                tempname="ModelingDiameters_"+num2str(ii)
1726                if (checkname(tempname,1)==0)
1727                        break
1728                endif
1729        endfor
1730        Duplicate /O tempDistdiameters, $tempname
1731        Wave MytempWave=$tempname
1732        IN2G_AppendorReplaceWaveNote(tempname,"UsersComment",UsersComment)
1733        IN2G_AppendorReplaceWaveNote(tempname,"Wname",tempname)
1734        IN2G_AppendorReplaceWaveNote(tempname,"Units","A")
1735        Redimension/D MytempWave
1736       
1737        tempname="ModelingNumberDistribution_"+num2str(ii)
1738        Duplicate /O tempTotalNumberDist, $tempname
1739        Wave MytempWave=$tempname
1740        IN2G_AppendorReplaceWaveNote(tempname,"UsersComment",UsersComment)
1741        IN2G_AppendorReplaceWaveNote(tempname,"Wname",tempname)
1742        IN2G_AppendorReplaceWaveNote(tempname,"Units","1/cm3")
1743        Redimension/D MytempWave
1744       
1745        tempname="ModelingVolumeDistribution_"+num2str(ii)
1746        Duplicate /O tempTotalVolumeDist, $tempname
1747        Wave MytempWave=$tempname
1748        IN2G_AppendorReplaceWaveNote(tempname,"UsersComment",UsersComment)
1749        IN2G_AppendorReplaceWaveNote(tempname,"Wname",tempname)
1750        IN2G_AppendorReplaceWaveNote(tempname,"Units","fraction")
1751        Redimension/D MytempWave
1752       
1753        tempname="ModelingIntensity_"+num2str(ii)
1754        Duplicate /O tempDistModelIntensity, $tempname
1755        Wave MytempWave=$tempname
1756        IN2G_AppendorReplaceWaveNote(tempname,"UsersComment",UsersComment)
1757        IN2G_AppendorReplaceWaveNote(tempname,"Wname",tempname)
1758        IN2G_AppendorReplaceWaveNote(tempname,"Units","cm-1")
1759        Redimension/D MytempWave
1760       
1761        tempname="ModelingQvector_"+num2str(ii)
1762        Duplicate /O tempModelQvector, $tempname
1763        Wave MytempWave=$tempname
1764        IN2G_AppendorReplaceWaveNote(tempname,"UsersComment",UsersComment)
1765        IN2G_AppendorReplaceWaveNote(tempname,"Wname",tempname)
1766        IN2G_AppendorReplaceWaveNote(tempname,"Units","A-1")
1767        Redimension/D MytempWave
1768
1769        If(cmpstr(ExportSeparateDistributions,"Yes")==0)
1770                for(j=1;j<=NumberOfDistributions;j+=1)          //copy local populations
1771                        Wave tempDia=$("root:Packages:SAS_Modeling:tempDist"+num2str(j)+"diameters")           
1772                        Wave tempNumDis=$("root:Packages:SAS_Modeling:tempDist"+num2str(j)+"NumberDist")               
1773                        Wave tempVolDist=$("root:Packages:SAS_Modeling:tempDist"+num2str(j)+"VolumeDist")       
1774       
1775                        tempname="ModelingDia_Pop"+num2str(j)+"_"+num2str(ii)
1776                        Duplicate/O tempDia, $tempname
1777                        Wave MytempWave=$tempname
1778                        IN2G_AppendorReplaceWaveNote(tempname,"DataFolderInIgor",DataFolderName)
1779                        IN2G_AppendorReplaceWaveNote(tempname,"UsersComment",UsersComment)
1780                        IN2G_AppendorReplaceWaveNote(tempname,"Wname",tempname)
1781                        IN2G_AppendorReplaceWaveNote(tempname,"Units","A-1")
1782                        Redimension/D MytempWave
1783                               
1784                        tempname="ModelingNumDist_Pop"+num2str(j)+"_"+num2str(ii)
1785                        Duplicate/O tempNumDis, $tempname
1786                        Wave MytempWave=$tempname
1787                        IN2G_AppendorReplaceWaveNote(tempname,"DataFolderInIgor",DataFolderName)
1788                        IN2G_AppendorReplaceWaveNote(tempname,"UsersComment",UsersComment)
1789                        IN2G_AppendorReplaceWaveNote(tempname,"Wname",tempname)
1790                        IN2G_AppendorReplaceWaveNote(tempname,"Units","1/cm3")
1791                        Redimension/D MytempWave
1792       
1793                        tempname="ModelingVolDist_Pop"+num2str(j)+"_"+num2str(ii)
1794                        Duplicate/O tempVolDist, $tempname
1795                        Wave MytempWave=$tempname
1796                        IN2G_AppendorReplaceWaveNote(tempname,"DataFolderInIgor",DataFolderName)
1797                        IN2G_AppendorReplaceWaveNote(tempname,"UsersComment",UsersComment)
1798                        IN2G_AppendorReplaceWaveNote(tempname,"Wname",tempname)
1799                        IN2G_AppendorReplaceWaveNote(tempname,"Units","fraction")
1800                        Redimension/D MytempWave
1801                       
1802                        KillWaves/Z tempVolDist, tempNumDis, tempDia
1803                endfor
1804        endif
1805        setDataFolder root:Packages:SAS_Modeling
1806
1807        Killwaves/Z tempDistdiameters,tempTotalNumberDist,tempTotalVolumeDist, tempDistModelIntensity, tempModelQvector
1808        setDataFolder OldDf
1809end
1810
1811
1812//*****************************************************************************************************************
1813//*****************************************************************************************************************
1814//*****************************************************************************************************************
1815//*****************************************************************************************************************
1816//*****************************************************************************************************************
1817
1818Function IR1_AppendWaveNote(ListOfWavesForNotes, StandardOrUser)
1819        string ListOfWavesForNotes, StandardOrUser
1820       
1821        string oldDf=GetDataFolder(1)
1822        setDataFolder root:Packages:SAS_Modeling
1823
1824        NVAR NumberOfDistributions=root:Packages:SAS_Modeling:NumberOfDistributions
1825
1826        NVAR SASBackground=root:Packages:SAS_Modeling:SASBackground
1827        NVAR FitSASBackground=root:Packages:SAS_Modeling:FitSASBackground
1828        NVAR UseNumberDistribution=root:Packages:SAS_Modeling:UseNumberDistribution
1829        NVAR UseInterference=root:Packages:SAS_Modeling:UseInterference
1830        NVAR UseSlitSmearedData=root:Packages:SAS_Modeling:UseSlitSmearedData
1831        NVAR SlitLength=root:Packages:SAS_Modeling:SlitLength
1832        SVAR DataFolderName=root:Packages:SAS_Modeling:DataFolderName
1833        string ExperimentName=IgorInfo(1)
1834        variable i, cursorAposition, cursorBposition
1835        For(i=0;i<ItemsInList(ListOfWavesForNotes);i+=1)
1836
1837                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"IgorExperimentName",ExperimentName)
1838                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"DataFolderinIgor",DataFolderName)
1839               
1840                if (cmpstr(StandardOrUser,"standard")==0)
1841                        if (UseNumberDistribution)
1842                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"DistributionTypeModelled", "Number distribution")   
1843                        else
1844                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes), "DistributionTypeModelled", "Volume distribution") 
1845                        endif   
1846                else
1847                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes), "DistributionTypeModelled","User defined distributions used, modified volume and diameters")                       
1848                endif
1849                //handle the cursors
1850                CursorAPosition=pcsr(A, "IR1_LogLogPlotLSQF")
1851                CursorBPosition=pcsr(B, "IR1_LogLogPlotLSQF")
1852                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"CursorAPosition",num2str(CursorAPosition))
1853                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"CursorBPosition",num2str(CursorBPosition))
1854               
1855                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"NumberOfModelledDistributions",num2str(NumberOfDistributions))
1856                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"UseInterference",num2str(UseInterference))
1857                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"UseSlitSmearedData",num2str(UseSlitSmearedData))
1858                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"SlitLength",num2str(SlitLength))
1859
1860                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"SASBackground",num2str(SASBackground))
1861                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"FitSASBackground",num2str(FitSASBackground))
1862        endfor
1863
1864        For(i=1;i<=NumberOfDistributions;i+=1)
1865                IR1_AppendWNOfDist(i,ListOfWavesForNotes, StandardOrUser)
1866        endfor
1867
1868        setDataFolder oldDF
1869
1870end
1871
1872
1873//*****************************************************************************************************************
1874//*****************************************************************************************************************
1875//*****************************************************************************************************************
1876//*****************************************************************************************************************
1877//*****************************************************************************************************************
1878
1879Function IR1_AppendWNOfDist(DistNum,ListOfWavesForNotes, StandardOrUser)
1880        variable DistNum
1881        string ListOfWavesForNotes, StandardOrUser
1882       
1883        string oldDf=GetDataFolder(1)
1884        setDataFolder root:Packages:SAS_Modeling
1885
1886        NVAR DistVolFraction=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"VolFraction")
1887        NVAR DistVolFractionError=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"VolFractionError")
1888        NVAR DistScatShapeParam1=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"ScatShapeParam1")
1889        NVAR DistScatShapeParam2=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"ScatShapeParam2")
1890        NVAR DistScatShapeParam3=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"ScatShapeParam3")
1891        NVAR DistScatShapeParam4=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"ScatShapeParam4")
1892        NVAR DistScatShapeParam5=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"ScatShapeParam5")
1893        SVAR DistShapeModel=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"ShapeModel")
1894
1895        if (cmpstr(StandardOrUser,"standard")==0)
1896                NVAR DistNumberOfPoints=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"NumberOfPoints")
1897                NVAR DistContrast=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"Contrast")
1898                NVAR DistLocation=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"Location")
1899                NVAR DistScale=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"Scale")
1900                NVAR DistShape=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"Shape")
1901                NVAR DistLocationError=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"LocationError")
1902                NVAR DistScaleError=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"ScaleError")
1903                NVAR DistShapeError=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"ShapeError")
1904                SVAR DistDistributionType=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"DistributionType")
1905                NVAR DistNegligibleFraction= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"NegligibleFraction")
1906                NVAR DistUseInterference= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"UseInterference")
1907                NVAR DistInterferencePhi= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"InterferencePhi")
1908                NVAR DistInterferenceEta= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"InterferenceEta")
1909                NVAR DistInterferencePhiError= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"InterferencePhiError")
1910                NVAR DistInterferenceEtaError= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"InterferenceEtaError")
1911                NVAR DistFitInterferencePhi= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"FitInterferencePhi")
1912                NVAR DistFitInterferenceEta= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"FitInterferenceEta")
1913                NVAR DistFitShape= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"FitShape")
1914                NVAR DistFitLocation= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"FitLocation")
1915                NVAR DistFitScale= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"FitScale")
1916                NVAR DistFitVol= $("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"FitVol")
1917        else
1918                NVAR DistDiamAddition=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"DiamAddition")
1919                NVAR DistDiamMulitplier=$("root:Packages:SAS_Modeling:Dist"+num2str(DistNum)+"DiamMulitplier")
1920        endif           
1921       
1922        SVAR GaussEquation=root:Packages:SAS_Modeling:GaussEquation
1923        SVAR LogNormalEquation=root:Packages:SAS_Modeling:LogNormalEquation
1924        SVAR LSWEquation=root:Packages:SAS_Modeling:LSWEquation
1925        SVAR PowerLawEquation=root:Packages:SAS_Modeling:PowerLawEquation
1926       
1927        variable i
1928        For(i=0;i<ItemsInList(ListOfWavesForNotes);i+=1)
1929                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"ShapeModel",DistShapeModel)
1930                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"ScatShapeParam1",num2str(DistScatShapeParam1))
1931                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"ScatShapeParam2",num2str(DistScatShapeParam2))
1932                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"ScatShapeParam3",num2str(DistScatShapeParam3))
1933                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"ScatShapeParam4",num2str(DistScatShapeParam4))
1934                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"ScatShapeParam5",num2str(DistScatShapeParam5))
1935
1936                if (cmpstr(StandardOrUser,"standard")==0)
1937                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"DistributionType",DistDistributionType)
1938                        if (cmpstr(DistDistributionType,"Gauss")==0)
1939                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"Formula",GaussEquation)             
1940                        endif
1941                        if (cmpstr(DistDistributionType,"LSW")==0)
1942                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"Formula",LSWEquation)               
1943                        endif
1944                        if (cmpstr(DistDistributionType,"LogNormal")==0)
1945                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"Formula",LogNormalEquation)         
1946                        endif
1947                        if (cmpstr(DistDistributionType,"PowerLaw")==0)
1948                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"Formula",PowerLawEquation)         
1949                        endif
1950                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"NegligibleFraction",num2str(DistNegligibleFraction))
1951
1952                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"FitShape",num2str(DistFitShape))
1953                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"FitLocation",num2str(DistFitLocation))
1954                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"FitScale",num2str(DistFitScale))
1955                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"FitVol",num2str(DistFitVol))
1956                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"VolFraction",num2str(DistVolFraction))
1957                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"Location",num2str(DistLocation))
1958                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"Scale",num2str(DistScale))
1959                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"Shape",num2str(DistShape))
1960                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"VolFractionError",num2str(DistVolFractionError))
1961                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"LocationError",num2str(DistLocationError))
1962                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"ScaleError",num2str(DistScaleError))
1963                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"ShapeError",num2str(DistShapeError))
1964                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"NumberOfPoints",num2str(DistNumberOfPoints))
1965                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"Contrast",num2str(DistContrast))
1966                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"DistributionType",DistDistributionType)
1967                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"UseInterference",num2str(DistUseInterference))
1968                        if (DistUseInterference)
1969                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"InterferencePhi",num2str(DistInterferencePhi))
1970                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"InterferenceEta",num2str(DistInterferenceEta))
1971                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"InterferencePhiError",num2str(DistInterferencePhiError))
1972                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"InterferenceEtaError",num2str(DistInterferenceEtaError))
1973                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"FitInterferencePhi",num2str(DistFitInterferencePhi))
1974                                IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"FitInterferenceEta",num2str(DistFitInterferenceEta))
1975                        endif
1976                else
1977                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"VolFraction",num2str(DistVolFraction))
1978                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"DiamAddition",num2str(DistDiamAddition))
1979                        IN2G_AppendorReplaceWaveNote(stringFromList(i,ListOfWavesForNotes),"Dist"+num2str(DistNum)+"DiamMultiplier",num2str(DistDiamMulitplier))
1980                endif
1981        endfor
1982
1983        setDataFolder OldDf
1984end
1985
1986
1987//*****************************************************************************************************************
1988//*****************************************************************************************************************
1989//*****************************************************************************************************************
1990//*****************************************************************************************************************
1991//*****************************************************************************************************************
1992
1993Function IR1_ExportASCIIResults(standardOrUser)
1994        string standardOrUser                   //"standard" or "User", depending where called from...
1995
1996        //here we need to copy the export results out of Igor
1997        //before that we need to also attach note to teh waves with the results
1998       
1999        string OldDf=getDataFOlder(1)
2000        setDataFolder root:Packages:SAS_Modeling
2001       
2002        Wave Distdiameters=root:Packages:SAS_Modeling:Distdiameters
2003        Wave TotalNumberDist=root:Packages:SAS_Modeling:TotalNumberDist
2004        Wave TotalVolumeDist=root:Packages:SAS_Modeling:TotalVolumeDist
2005       
2006        NVAR NumberOfDistributions=root:Packages:SAS_Modeling:NumberOfDistributions
2007        SVAR DataFolderName=root:Packages:SAS_Modeling:DataFolderName
2008       
2009        Duplicate/O Distdiameters, tempDistdiameters
2010        Duplicate/O TotalNumberDist, tempTotalNumberDist
2011        Duplicate/O TotalVolumeDist, tempTotalVolumeDist
2012        string ListOfWavesForNotes="tempDistdiameters;tempTotalNumberDist;tempTotalVolumeDist;"
2013       
2014        IR1_AppendWaveNote(ListOfWavesForNotes, standardOrUser)
2015       
2016        string Comments="Record of Data evaluation with Irena SAS modeling macros;" +note(tempDistdiameters)+"diameters[A]\t\tNumberDist[1/cm3]\t\tVolumeDist[cm3/cm3]\r"
2017        variable pos=0
2018        variable ComLength=strlen(Comments)
2019        Do
2020                pos=strsearch(Comments, ";", pos+5)
2021                Comments=Comments[0,pos-1]+"\r#\t"+Comments[pos+1,inf]
2022        while (pos>0)
2023
2024        string filename1
2025        filename1=StringFromList(ItemsInList(DataFolderName,":")-1, DataFolderName,":")+"_SAS_model.txt"
2026        variable refnum
2027
2028        Open/D/T=".txt"/M="Select file to save data to" refnum as filename1
2029        filename1=S_filename
2030        if (strlen(filename1)==0)
2031                abort
2032        endif
2033
2034       
2035        String nb = "Notebook0"
2036        NewNotebook/N=$nb/F=0/V=0/K=0/W=(5.25,40.25,558,408.5) as "ExportData"
2037        Notebook $nb defaultTab=20, statusWidth=238, pageMargins={72,72,72,72}
2038        Notebook $nb font="Arial", fSize=10, fStyle=0, textRGB=(0,0,0)
2039        Notebook $nb text=Comments[1,strlen(Comments)-2]       
2040       
2041       
2042        SaveNotebook $nb as filename1
2043        DoWindow /K $nb
2044        Save/A/G/M="\r\n" tempDistdiameters,tempTotalNumberDist,tempTotalVolumeDist as filename1         
2045       
2046
2047
2048        Killwaves/Z tempDistdiameters,tempTotalNumberDist,tempTotalVolumeDist
2049        setDataFolder OldDf
2050end
2051       
2052
2053//****************************************************************
2054//****************************************************************
2055//***********************************
2056//***********************************
2057
2058Function IR2C_CheckIrenaUpdate(CalledFromMenu)
2059        variable CalledFromMenu
2060        //CalledFromMenu=1 run always...
2061        struct  IrenaPanelDefaults Defs
2062        LoadPackagePreferences /MIS=1   "Irena" , "IrenaDefaultPanelControls.bin", 0 , Defs
2063        if(V_Flag==0 && CalledFromMenu==0)             
2064                //print Defs
2065                if(Defs.Version==2)             //Lets declare the one we know as 1
2066                        if(datetime - Defs.LastUpdateCheck >30 * 24 * 60 * 60 || CalledFromMenu)
2067                                //call check version procedure and advise user on citations
2068                                IR2C_CheckVersions()
2069                                Defs.LastUpdateCheck = datetime
2070                                SavePackagePreferences /FLSH=1   "Irena" , "IrenaDefaultPanelControls.bin", 0 , Defs
2071                        endif
2072                else
2073                        Defs.Version                    =               2
2074                        Defs.LastUpdateCheck = datetime
2075                        IR2C_CheckVersions()
2076                        SavePackagePreferences /FLSH=1   "Irena" , "IrenaDefaultPanelControls.bin", 0 , Defs
2077                endif
2078        else            //either preferences do not exist or user asked for the check
2079                Defs.Version                    =               2
2080                Defs.LastUpdateCheck = datetime
2081                IR2C_CheckVersions()
2082                SavePackagePreferences /FLSH=1   "Irena" , "IrenaDefaultPanelControls.bin", 0 , Defs
2083        endif
2084       
2085end
2086
2087//****************************************************************
2088//****************************************************************
2089static Function IR2C_CheckVersions()
2090        string PackageString   
2091        //create list of Igor procedure files on this machine
2092        IR2C_ListIgorProcFiles()
2093        DoWIndow CheckForUpdatePanel
2094        if(V_Flag)
2095                DoWIndow/F CheckForUpdatePanel                                                         
2096        else
2097                Execute("CheckForUpdatePanel()")                       
2098        endif
2099        //Irena code
2100        string OldDf=GetDataFolder(1)
2101        //create location for the results waves...
2102        NewDataFolder/O/S root:Packages
2103        NewDataFolder/O/S root:Packages:UseProcedureFiles
2104        variable/g InstalledIrenaVersion
2105        variable/g WebIrenaVersion             
2106        InstalledIrenaVersion = IR2C_FindFileVersion("Boot Irena1 modeling.ipf")       
2107        //now get the web based version.
2108        NewPath  /O/Q TempPath  (SpecialDirPath("temporary", 0, 0, 0 ))
2109        //download the file
2110        variable InstallHadFatalError
2111        InstallHadFatalError = IR2C_DownloadFile("IgorCode/Igor Procedures/Boot Irena1 modeling.ipf","TempPath", "Boot Irena1 modeling.ipf")
2112        sleep/s 1
2113        WebIrenaVersion = IR2C_FindVersionOfSingleFile("Boot Irena1 modeling.ipf","TempPath")
2114        if(InstallHadFatalError || numtype(WebIrenaVersion)!=0)
2115                DoAlert 0, "Check for latest Irena version failed. Check you Internet connection. Try later again..."
2116        endif
2117        DeleteFile /Z /P=tempPath "Boot Irena1 modeling.ipf"   
2118        SetDataFOlder OldDf
2119end     
2120//****************************************************************
2121//****************************************************************
2122static Function IR2C_FindFileVersion(FilenameStr)
2123        string FilenameStr
2124       
2125        Wave/T PathToFIles= root:Packages:UseProcedureFiles:PathToFIles
2126        Wave/T FileNames=root:Packages:UseProcedureFiles:FileNames
2127        Wave FileVersions =root:Packages:UseProcedureFiles:FileVersions
2128        variable i, imax=Numpnts(FileNames), versionFound
2129        string tempname
2130        versionFound=-1
2131        For(i=0;i<imax;i+=1)
2132                tempname = FileNames[i]
2133                if(stringmatch(tempname,FileNameStr))
2134                        versionFound = FileVersions[i]
2135                        return versionFound
2136                endif
2137        endfor
2138        return -1
2139end
2140//****************************************************************
2141//****************************************************************
2142//****************************************************************
2143//****************************************************************
2144
2145static Function IR2C_FindVersionOfSingleFile(tempFileName,PathStr)
2146        string tempFileName, PathStr
2147               
2148                string tempScraptext
2149                Grep/P=$(PathStr)/Z/E="(?i)^#pragma[ ]*version[ ]*=[ ]*" tempFileName as "Clipboard"
2150                sleep/s (0.02)
2151                tempScraptext = GetScrapText()
2152                if(strlen(tempScraptext)>10)            //found line with #pragma version"
2153                        tempScraptext = replaceString("#pragma",tempScraptext,"")       //remove #pragma
2154                        tempScraptext = replaceString("version",tempScraptext,"")               //remove version
2155                        tempScraptext = replaceString("=",tempScraptext,"")                     //remove =
2156                        tempScraptext = replaceString("\t",tempScraptext,"  ")                  //remove optional tabulators, some actually use them.
2157                        tempScraptext = RemoveEnding(tempScraptext,"\r")                        //remove optional tabulators, some actually use them.
2158                        //forget about the comments behind the text.
2159                    //str2num is actually quite clever in this and converts start of the string which makes sense.
2160                        return str2num(tempScraptext)
2161                else             //no version found, set to NaN
2162                        return NaN
2163                endif
2164
2165end
2166
2167
2168//****************************************************************
2169//****************************************************************
2170//****************************************************************
2171//****************************************************************
2172static Function IR2C_ListIgorProcFiles()
2173        GetFileFolderInfo/Q/Z/P=Igor "Igor Procedures" 
2174        if(V_Flag==0)
2175                IR2C_ListProcFiles(S_Path,1 )
2176        endif
2177        GetFileFolderInfo/Q/Z IR2C_GetIgorUserFilesPath()+"Igor Procedures:"
2178        if(V_Flag==0)
2179                IR2C_ListProcFiles(IR2C_GetIgorUserFilesPath()+"Igor Procedures:",0)
2180        endif
2181        KillPath/Z tempPath
2182end
2183 //****************************************************************
2184//****************************************************************
2185//****************************************************************
2186//****************************************************************
2187static Function IR2C_ListProcFiles(PathStr, resetWaves)
2188        string PathStr
2189        variable resetWaves
2190       
2191        String abortMessage     //HR Used if we have to abort because of an unexpected error
2192       
2193        string OldDf=GetDataFolder(1)
2194        //create location for the results waves...
2195        NewDataFolder/O/S root:Packages
2196        NewDataFolder/O/S root:Packages:UseProcedureFiles
2197        //if this is top call to the routine we need to wipe out the waves so we remove old junk
2198        string CurFncName=GetRTStackInfo(1)
2199        string CallingFncName=GetRTStackInfo(2)
2200        variable runningTopLevel=0
2201        if(!stringmatch(CurFncName,CallingFncName))
2202                runningTopLevel=1
2203        endif
2204        if(resetWaves)
2205                        Make/O/N=0/T FileNames         
2206                        Make/O/N=0/T PathToFiles
2207                        Make/O/N=0 FileVersions
2208        endif
2209       
2210       
2211        //if this was first call, now the waves are gone.
2212        //and now we need to create the output waves
2213        Wave/Z/T FileNames
2214        Wave/Z/T PathToFiles
2215        Wave/Z FIleVersions
2216        If(!WaveExists(FileNames) || !WaveExists(PathToFiles) || !WaveExists(FIleVersions))
2217                Make/O/T/N=0 FileNames, PathToFIles
2218                Make/O/N=0 FileVersions
2219                Wave/T FileNames
2220                Wave/T PathToFiles
2221                Wave FileVersions
2222                //I am not sure if we really need all of those declarations, but, well, it should not hurt...
2223        endif
2224       
2225        //this is temporary path to the place we are looking into now... 
2226        NewPath/Q/O tempPath, PathStr
2227        if (V_flag != 0)                //HR Add error checking to prevent infinite loop
2228                sprintf abortMessage, "Unexpected error creating a symbolic path pointing to \"%s\"", PathStr
2229                Print abortMessage      // To make debugging easier
2230                Abort abortMessage
2231        endif
2232
2233        //list al items in this path
2234        string ItemsInTheFolder= IndexedFile(tempPath,-1,"????")+IndexedDir(tempPath, -1, 0 )
2235       
2236        //HR If there is a shortcut in "Igor Procedures", ItemsInTheFolder will include something like "HDF5 Browser.ipf.lnk". Windows shortcuts are .lnk files.       
2237       
2238        //remove all . files.
2239        ItemsInTheFolder = GrepList(ItemsInTheFolder, "^\." ,1)
2240        //Now we removed all junk files on Macs (starting with .)
2241        //now lets check what each of these files are and add to the right lists or follow...
2242        variable i, imax=ItemsInList(ItemsInTheFolder)
2243        string tempFileName, tempScraptext, tempPathStr
2244        variable IamOnMac, isItXOP
2245        if(stringmatch(IgorInfo(2),"Windows"))
2246                IamOnMac=0
2247        else
2248                IamOnMac=1
2249        endif
2250        For(i=0;i<imax;i+=1)
2251                tempFileName = stringfromlist(i,ItemsInTheFolder)
2252                GetFileFolderInfo/Z/Q/P=tempPath tempFileName
2253                isItXOP = IamOnMac * stringmatch(tempFileName, "*xop*" )
2254               
2255                if(V_isAliasShortcut)
2256                        //HR If tempFileName is "HDF5 Browser.ipf.lnk", or any other shortcut to a file, S_aliasPath is a path to a file, not a folder.
2257                        //HR Thus the "NewPath tempPath" command will fail.
2258                        //HR Thus tempPath will retain its old value, causing you to recurse the same folder as before, resulting in an infinite loop.
2259                       
2260                        //is alias, need to follow and look further. Use recursion...
2261                        if(strlen(S_aliasPath)>3)               //in case user has stale alias, S_aliasPath has 0 length. Need to skip this pathological case.
2262                                //HR Recurse only if S_aliasPath points to a folder. I don't really know what I'm doing here but this seems like it will prevent the infinite loop.
2263                                GetFileFolderInfo/Z/Q/P=tempPath S_aliasPath   
2264                                isItXOP = IamOnMac * stringmatch(S_aliasPath, "*xop*" )
2265                                if (V_flag==0 && V_isFolder&&!isItXOP)          //this is folder, so all items in the folder are included... Except XOP is folder too...
2266                                        IR2C_ListProcFiles(S_aliasPath, 0)
2267                                elseif(V_flag==0 && (!V_isFolder || isItXOP))   //this is link to file. Need to include the info on the file...
2268                                        //*************
2269                                        Redimension/N=(numpnts(FileNames)+1) FileNames, PathToFiles,FileVersions
2270                                        tempFileName =stringFromList(ItemsInList(S_aliasPath,":")-1, S_aliasPath,":")
2271                                        tempPathStr = RemoveFromList(tempFileName, S_aliasPath,":")
2272                                        FileNames[numpnts(FileNames)] = tempFileName
2273                                        PathToFiles[numpnts(FileNames)] = tempPathStr
2274                                        //try to get version from #pragma version = ... This seems to be the most robust way I found...
2275                                        if(stringmatch(tempFileName, "*.ipf"))
2276                                                Grep/P=tempPath/E="(?i)^#pragma[ ]*version[ ]*=[ ]*" tempFileName as "Clipboard"
2277                                                sleep/s (0.02)
2278                                                tempScraptext = GetScrapText()
2279                                                if(strlen(tempScraptext)>10)            //found line with #pragma version"
2280                                                        tempScraptext = replaceString("#pragma",tempScraptext,"")       //remove #pragma
2281                                                        tempScraptext = replaceString("version",tempScraptext,"")               //remove version
2282                                                        tempScraptext = replaceString("=",tempScraptext,"")                     //remove =
2283                                                        tempScraptext = replaceString("\t",tempScraptext,"  ")                  //remove optional tabulators, some actually use them.
2284                                                        tempScraptext = removeending(tempScraptext," \r")                       //remove optional tabulators, some actually use them.
2285                                                        //forget about the comments behind the text.
2286                                                       //str2num is actually quite clever in this and converts start of the string which makes sense.
2287                                                        FileVersions[numpnts(FileNames)]=str2num(tempScraptext)
2288                                                else             //no version found, set to NaN
2289                                                        FileVersions[numpnts(FileNames)]=NaN
2290                                                endif
2291                                        else                    //no version for non-ipf files
2292                                                FileVersions[numpnts(FileNames)]=NaN
2293                                        endif
2294                                //************
2295
2296
2297                                endif
2298                        endif
2299                        //and now when we got back, fix the path definition to previous or all will crash...
2300                        NewPath/Q/O tempPath, PathStr
2301                        if (V_flag != 0)                //HR Add error checking to prevent infinite loop
2302                                sprintf abortMessage, "Unexpected error creating a symbolic path pointing to \"%s\"", PathStr
2303                                Print abortMessage      // To make debugging easier
2304                                Abort abortMessage
2305                        endif
2306                elseif(V_isFolder&&!isItXOP)   
2307                        //is folder, need to follow into it. Use recursion.
2308                        IR2C_ListProcFiles(PathStr+tempFileName+":", 0)
2309                        //and fix the path back or all will fail...
2310                        NewPath/Q/O tempPath, PathStr
2311                        if (V_flag != 0)                //HR Add error checking to prevent infinite loop
2312                                sprintf abortMessage, "Unexpected error creating a symbolic path pointing to \"%s\"", PathStr
2313                                Print abortMessage      // To make debugging easier
2314                                Abort abortMessage
2315                        endif
2316                elseif(V_isFile||isItXOP)
2317                        //this is real file. Store information as needed.
2318                        Redimension/N=(numpnts(FileNames)+1) FileNames, PathToFiles,FileVersions
2319                        FileNames[numpnts(FileNames)-1] = tempFileName
2320                        PathToFiles[numpnts(FileNames)-1] = PathStr
2321                        //try to get version from #pragma version = ... This seems to be the most robust way I found...
2322                        if(stringmatch(tempFileName, "*.ipf"))
2323                                Grep/P=tempPath/E="(?i)^#pragma[ ]*version[ ]*=[ ]*" tempFileName as "Clipboard"
2324                                sleep/s(0.02)
2325                                tempScraptext = GetScrapText()
2326                                if(strlen(tempScraptext)>10)            //found line with #pragma version"
2327                                        tempScraptext = replaceString("#pragma",tempScraptext,"")       //remove #pragma
2328                                        tempScraptext = replaceString("version",tempScraptext,"")               //remove version
2329                                        tempScraptext = replaceString("=",tempScraptext,"")                     //remove =
2330                                        tempScraptext = replaceString("\t",tempScraptext,"  ")                  //remove optional tabulators, some actually use them.
2331                                        //forget about the comments behind the text.
2332                                       //str2num is actually quite clever in this and converts start of the string which makes sense.
2333                                        FileVersions[numpnts(FileNames)-1]=str2num(tempScraptext)
2334                                else             //no version found, set to NaN
2335                                        FileVersions[numpnts(FileNames)-1]=NaN
2336                                endif
2337                        else                    //no version for non-ipf files
2338                                FileVersions[numpnts(FileNames)-1]=NaN
2339                        endif
2340                endif
2341        endfor
2342//      if(runningTopLevel)
2343//              //some output here...
2344//              print "Found   "+num2str(numpnts(FileNames))+"  files in   "+PathStr+" folder, its subfolders and linked folders and subfolders"
2345//              KillPath/Z tempPath
2346//      endif
2347 
2348        setDataFolder OldDf
2349end
2350
2351
2352//***********************************
2353//***********************************
2354//***********************************
2355//***********************************
2356static Function /S IR2C_Windows2IgorPath(pathIn)
2357        String pathIn
2358        String pathOut = ParseFilePath(5, pathIn, ":", 0, 0)
2359        return pathOut
2360End
2361//***********************************
2362//***********************************
2363//***********************************
2364//***********************************
2365
2366static Function/S IR2C_GetIgorUserFilesPath()
2367        // This should be a Macintosh path but, because of a bug prior to Igor Pro 6.20B03
2368        // it may be a Windows path.
2369        String path = SpecialDirPath("Igor Pro User Files", 0, 0, 0)
2370        path = IR2C_Windows2IgorPath(path)
2371        return path
2372End
2373
2374//***********************************
2375//***********************************
2376//****************************************************************
2377//****************************************************************
2378
2379static Function IR2C_DownloadFile(StringWithPathAndname,LocalPath, LocalName)
2380        string StringWithPathAndname, LocalPath, LocalName
2381
2382        variable InstallUsingLocalCopy = 0
2383        variable InstallUsinghttp = 1
2384        variable i
2385        variable APSError=0
2386        variable OtherError=0
2387        if(InstallUsingLocalCopy)               
2388                string tempFldrNm
2389                tempFldrNm = removeFromList("IgorCode",StringWithPathAndname,"/")
2390                PathInfo LocalCopyForInstallation
2391                if(V_Flag==0)           //local copy path was not found.
2392                        //let's try to find in where Igor experiment started from, that path is known as "home"
2393                        string ItemsInTheFolder= IndexedDir(home, -1, 0 )
2394                        if(stringmatch(ItemsInTheFolder, "*IgorCode;*" ))
2395                                PathInfo/S home
2396                                NewPath /C/O/Q  LocalCopyForInstallation, S_Path+"IgorCode:"
2397                                Print "Found IgorCode folder in location where this experiment started, using that folder as file source"
2398                        else           
2399                                NewPath /C/M="Find Folder called \"IgorCode\""/O/Q  LocalCopyForInstallation
2400                                if(V_Flag!=0)
2401                                        abort "Local copy of Installation files not found and user cancelled. Visit: http://usaxs.xray.aps.anl.gov/staff/ilavsky/irena.html if you want to download it"
2402                                endif
2403                        endif
2404                endif
2405                PathInfo LocalCopyForInstallation
2406                GetFileFolderInfo  /P=$(LocalPath) /Q /Z S_Path+ReplaceString("/", tempFldrNm, ":")
2407                if(V_Flag!=0)
2408                        NewPath /C/M="Find Folder called \"IgorCode\""/O/Q  LocalCopyForInstallation
2409                endif
2410                PathInfo LocalCopyForInstallation
2411                CopyFile /O/P=$(LocalPath)/Z S_Path+ReplaceString("/", tempFldrNm, ":")  as LocalName
2412                // Remove ReadOnly property from the file. This is important on WIndows when copying from CD or DVD
2413                SetFileFolderInfo/P=$(LocalPath)/RO=0 LocalName
2414        elseif(!InstallUsinghttp)
2415                string httpurl="http://ftp.xray.aps.anl.gov/usaxs/"
2416                //string url="http://ftp.xray.aps.anl.gov/usaxs/"               //this is http address for future use with URLencode, URLdecode, and FetchURL
2417                String httpPath = httpurl+StringWithPathAndname //HR Use local variable for easier debugging.
2418                //HR Print ftpPath      //HR For debugging
2419                        //// Get a binary image file from a web server and then
2420                        //// save the image to a file on the desktop.
2421                httpPath =  ReplaceString(" ", httpPath, "%20")         //handle just spaces here...
2422                String fileBytes, tempPathStr
2423                Variable error = GetRTError(1)
2424                i=0
2425                Do
2426                         fileBytes = FetchURL(httpPath)
2427                         error = GetRTError(1)
2428                         sleep/S 0.2
2429                         if(error!=0)
2430                                 print "file: "+httpPath+" download FAILED, this was http download attempt No: "+num2str(i)
2431                                // print "file: "+httpPath+" downloaded "+num2str(i+1)+" times"
2432                                 print "Trying to download same file using ftp"
2433                                 tempPathStr = ReplaceString("http://ftp.xray.aps.anl.gov/usaxs/", httpPath, "ftp://ftp.xray.aps.anl.gov/pub/usaxs/")
2434                                 fileBytes = FetchURL(tempPathStr)
2435                                 error = GetRTError(1)
2436                                 sleep/S 0.2
2437                                 if(error!=0)
2438                                         print "file: "+tempPathStr+" download FAILED, this was ftp download attempt No: "+num2str(i+1)
2439                                 else
2440                                         print "file: "+tempPathStr+" downloaded succesfully by ftp, this was ftp download attempt No: "+num2str(i+1)
2441                                 endif
2442                        endif
2443                        i+=1
2444                while((error!=0 || GrepString(fileBytes, "ERROR: Proxy Error" ))&& i<5)
2445                if ( error != 0 || GrepString(fileBytes, "ERROR: Proxy Error" ) || i>=5)
2446                        if(GrepString(fileBytes, "ERROR: Proxy Error" ) )
2447                                Print "********************     APS Proxy error           *******************"
2448                                Print "**** Please, try installing later again or try using ftp protocol or local copy method."
2449                                Print "**** Also, report problem to ilavsky@aps.anl.gov  the following, so we can get this fixed:"
2450                                Print "APS proxy error has consistently produced error while trying to download following file:"+StringWithPathAndname
2451                                Print Date() +"   "+time()
2452                                print "Igor version :"+IgorInfo(3)
2453                                APSError+=1
2454                        elseif(error != 0 || i>=5)
2455                                Print "*************         S E R V E R      E R R O R                 ****************"
2456                                Print "**** Please, report problem to ilavsky@aps.anl.gov  the following:"
2457                                Print "Failed to get from http/ftp server following file.....   " + StringWithPathAndname
2458                                Print Date() +"   "+time()
2459                                print "Igor version :"+IgorInfo(3)
2460                        endif
2461                        print "********************  end of error message  ********************"
2462                        OtherError=1
2463                else
2464                        Variable refNum
2465                        Open/P=$(LocalPath)  refNum as LocalName
2466                        FBinWrite refNum, fileBytes
2467                        Close refNum
2468                        SetFileFolderInfo/P=$(LocalPath)/RO=0 LocalName         
2469                endif
2470                //FTPDownload /O/V=0/P=$(LocalPath)/Z ftpPath, LocalName       
2471        else
2472                string url="ftp://ftp.xray.aps.anl.gov/pub/usaxs/"
2473                //string url="http://ftp.xray.aps.anl.gov/usaxs/"               //this is http address for future use with URLencode, URLdecode, and FetchURL
2474                String ftpPath = url+StringWithPathAndname      //HR Use local variable for easier debugging.
2475                //HR Print ftpPath      //HR For debugging
2476                //ftpPath = ReplaceString("GenCurvefit", ftpPath, "GenCurveFit", 1)     //HR Quick and Dirty fix - change spelling so we find the file on the FTP server.
2477                FTPDownload /O/V=0/P=$(LocalPath)/Z ftpPath, LocalName 
2478       
2479                if(V_flag!=0)   //ftp failed...
2480                        Print "*************                  E R R O R                       ****************"
2481                        Print "**** Please, report problem to ilavsky@aps.anl.gov  the following:"
2482                        Print "Failed to load from ftp server following file.....   " + StringWithPathAndname
2483                        Print Date() +"   "+time()
2484                        print "Igor version :"+IgorInfo(3)
2485                        print "********************  end of error message  ********************"
2486                else //ftyp success, change the read only flag here...
2487                // Remove ReadOnly property from the file:
2488                SetFileFolderInfo/P=$(LocalPath)/RO=0 LocalName         
2489                endif
2490        endif
2491        variable nosuccess
2492        if(V_Flag!=0)
2493                nosuccess=1
2494        endif
2495        return OtherError+APSError
2496       
2497end
2498
2499//****************************************************************
2500//****************************************************************
2501//***********************************
2502//***********************************
2503
2504
2505//Motofit paper [J. Appl. Cryst. 39, 273-276]
2506//http://scripts.iucr.org/cgi-bin/paper?S0021889806005073
2507//J. Appl. Cryst. (2006). 39, 273-276    [ doi:10.1107/S0021889806005073 ]
2508//A. Nelson, Co-refinement of multiple-contrast neutron/X-ray reflectivity data using MOTOFIT
2509//
2510
2511
2512
2513Function IR2C_CheckVersionButtonProc(ba) : ButtonControl
2514        STRUCT WMButtonAction &ba
2515
2516        switch( ba.eventCode )
2517                case 2: // mouse up
2518                        // click code here
2519                        if(stringmatch(ba.ctrlName,"OpenIrenaWebPage"))
2520                                //open web page with Irena
2521                                BrowseURL "http://usaxs.xray.aps.anl.gov/staff/ilavsky/irena.html"
2522                        endif
2523                        if(stringmatch(ba.ctrlName,"OpenIrenaManuscriptWebPage"))
2524                                //open web page with Irena
2525                                BrowseURL "http://dx.doi.org/10.1107/S0021889809002222"
2526                        endif
2527                        if(stringmatch(ba.ctrlName,"OpenGCManuscriptWebPage"))
2528                                //doi:10.1007/s11661-009-9950-x
2529                                BrowseURL "http://www.jomgateway.net/ArticlePage.aspx?DOI=10.1007/s11661-009-9950-x"
2530                        endif
2531                        if(stringmatch(ba.ctrlName,"OpenMotofitManuscriptWebPage"))
2532                                //doi:10.1007/s11661-009-9950-x
2533                                BrowseURL "http://scripts.iucr.org/cgi-bin/paper?S0021889806005073"
2534                        endif
2535                        if(stringmatch(ba.ctrlName,"OpenUFManuscriptWebPage"))
2536                                BrowseURL "http://scripts.iucr.org/cgi-bin/paper?S0021889895005292"
2537                        endif           
2538                       
2539                        break
2540                case -1: // control being killed
2541                        break
2542        endswitch
2543
2544        return 0
2545End
2546//****************************************************************
2547//****************************************************************
2548//***********************************
2549//***********************************
2550
2551Window CheckForUpdatePanel() : Panel
2552        PauseUpdate; Silent 1           // building window...
2553        NewPanel /W=(116,68,880,550)/K=1 as "Irena check for updates"
2554        SetDrawLayer UserBack
2555        SetDrawEnv fsize= 20,fstyle= 3,textrgb= (0,0,65535)
2556        DrawText 114,37,"Once-per-month reminder to check for Irena update"
2557        SetDrawEnv fsize= 14,fstyle= 3,textrgb= (65535,0,0)
2558        DrawText 27,110,"Reminder: When publishing data analyzed using Irena package, please cite following manuscripts:"
2559        SetDrawEnv textrgb= (0,0,65535)
2560        DrawText 27,133,"J. Ilavsky and P. Jemian, Irena: tool suite for modeling and analysis of small- angle scattering "
2561        SetDrawEnv textrgb= (0,0,65535)
2562        DrawText 27,158,"J. Appl. Cryst. (2009). 42, 347Ð353"
2563        SetDrawEnv textrgb= (0,0,65535)
2564        DrawText 27,205,"Glassy Carbon Absolute Int. Calibration: F. Zhang, J. Ilavsky, G. G. Long, J. P.G. Quintana, "
2565        SetDrawEnv textrgb= (0,0,65535)
2566        DrawText 27,230,"A. J. Allen, and P. Jemian, Glassy Carbon as an Absolute Intensity Calibration Standard"
2567        SetDrawEnv textrgb= (0,0,65535)
2568        DrawText 27,255,"for Small-Angle Scattering, MMTA, DOI: 10.1007/s11661-009-9950-x"
2569        SetDrawEnv textrgb= (0,0,65535)
2570        DrawText 27,320,"Reflectivity: A. Nelson, Co-refinement of multiple-contrast neutron/X-ray reflectivity"
2571        SetDrawEnv textrgb= (0,0,65535)
2572        DrawText 27,345,"data using MOTOFIT, Appl. Cryst. (2006). 39, 273-276"
2573        SetDrawEnv textrgb= (0,0,65535)
2574        DrawText 27,390,"Unified Fit: G. Beaucage, Approximations Leading to a Unified Exponential/Power-Law "
2575        SetDrawEnv textrgb= (0,0,65535)
2576        DrawText 27,415,"Approach to Small-Angle Scattering, J. Appl. Cryst. (1995). 28, 717-728"
2577
2578        SetDrawEnv fstyle= 2,fsize= 10,textrgb= (0,0,0)
2579        DrawText 10,470,"This tool runs automatically every 30 days on each computer. It can be also called from the SAS sub-menu as \"Check for updates\""
2580
2581        SetVariable InstalledIrenaVersion,pos={48,56},size={199,15},bodyWidth=100,title="Installed Irena Version"
2582        SetVariable InstalledIrenaVersion,help={"This is the current Irena version installed"}
2583        SetVariable InstalledIrenaVersion,fStyle=1
2584        SetVariable InstalledIrenaVersion,limits={0,0,0},value= root:Packages:UseProcedureFiles:InstalledIrenaVersion,noedit= 1
2585        SetVariable WebIrenaVersion,pos={297,56},size={183,15},bodyWidth=100,title="Web Irena Version"
2586        SetVariable WebIrenaVersion,help={"This is the current Irena version installed"}
2587        SetVariable WebIrenaVersion,fStyle=1
2588        SetVariable WebIrenaVersion,limits={0,0,0},value= root:Packages:UseProcedureFiles:WebIrenaVersion,noedit= 1
2589        Button OpenIrenaWebPage,pos={551,53},size={150,20},proc=IR2C_CheckVersionButtonProc,title="Open Irena web page"
2590        Button OpenIrenaManuscriptWebPage,pos={551,143},size={150,20},proc=IR2C_CheckVersionButtonProc,title="Manuscript web page"
2591        Button OpenGCManuscriptWebPage,pos={551,240},size={150,20},proc=IR2C_CheckVersionButtonProc,title="Manuscript web page"
2592        Button OpenMotofitManuscriptWebPage,pos={551,325},size={150,20},proc=IR2C_CheckVersionButtonProc,title="Manuscript web page"
2593        Button OpenUFManuscriptWebPage,pos={551,402},size={150,20},proc=IR2C_CheckVersionButtonProc,title="Manuscript web page"
2594EndMacro
2595//****************************************************************
2596//****************************************************************
2597//***********************************
2598//***********************************
Note: See TracBrowser for help on using the repository browser.