source: sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/PlotManager.ipf @ 211

Last change on this file since 211 was 211, checked in by srkline, 15 years ago

Several disjoint changes:

1) Threaded the 1D Cylinder_PolyRadius function
2) in Wrapper, popping the data set list now will auto-pop the function, then the coef to properly update the table of coefficients.
3) tick units in the plots are suppressed (y-axis)
4) Killing data (PlotManager?) now kills the dependent variable so that the rest can be killed
5) Ellipsoid_2D function now has the correct notation of the rotation axis in the parameter names.

File size: 8.4 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=3.00
3#pragma IgorVersion=6.0
4
5
6//////////////////////////////////////////
7//
8// Plot manager that is largely based on the plot manager in the Reduction package
9//
10// "A_" is crudely prepended to function names to avoid conflicts
11//
12// -- data folders will sitll overlap, but should not be an issue
13//
14// 28SEP07 SRK
15//
16//////////////////////////////////////////
17Proc Show_Plot_Manager()
18        A_Init_OneDLoader()
19        DoWindow/F Plot_Manager
20        if(V_flag==0)
21                A_Plot_Manager()
22        endif
23        A_OneDLoader_GetListButton("")
24End
25
26Window A_Plot_Manager() : Panel
27        PauseUpdate; Silent 1           // building window...
28        NewPanel /W=(658,347,1018,737)/N=Plot_Manager/K=1 as "Plot Manager"
29        ModifyPanel cbRGB=(37265,65535,32896)
30        ModifyPanel fixedSize=1
31       
32        Button button0,pos={165,353},size={50,20},proc=A_PlotManager_Done,title="Done"
33        PopupMenu popup0,pos={15,225},size={233,20},title="Data in Memory"
34        PopupMenu popup0,mode=1,value= #"A_OneDDataInMemory()"
35        Button button2,pos={122,259},size={100,20},proc=A_PlotManager_Append,title="Append Data"
36        Button button3,pos={15,259},size={80,20},proc=A_PlotManager_newGraph,title="New Graph"
37        Button button4,pos={15,293},size={220,20},proc=A_PlotManager_Kill,title="Remove Selection From Memory"
38        Button button5,pos={15,323},size={220,20},proc=A_PlotManager_KillAll,title="Remove All Data From Memory"
39        ListBox fileList,pos={13,11},size={206,179}
40        ListBox fileList,listWave=root:myGlobals:OneDLoader:fileWave
41        ListBox fileList,selWave=root:myGlobals:OneDLoader:selWave,mode= 4
42        Button button6,pos={238,153},size={100,20},proc=A_OneDLoader_LoadButton,title="Load File(s)"
43        Button button6,help={"Loads the selected files into memory and will graph them if that option is checked"}
44        Button button7,pos={238,20},size={100,20},proc=A_OneDLoader_NewFolderButton,title="New Folder"
45        Button button7,help={"Select a new data folder"}
46        GroupBox group0,pos={222,108},size={50,4},title="Shift-click to load"
47        GroupBox group0_1,pos={222,123},size={50,4},title="multiple files"
48        GroupBox group1,pos={7,207},size={350,4}
49EndMacro
50
51//uses the same data folder listing as the wrapper
52// if it's right there, it's right here
53Function/S A_OneDDataInMemory()
54        String list = W_DataSetPopupList()
55        return(list)
56end
57
58
59Function A_PlotManager_Done(ctrlName) : ButtonControl
60        String ctrlName
61        DoWindow/K Plot_Manager
62End
63
64Function A_PlotManager_Append(ctrlName) : ButtonControl
65        String ctrlName
66        //appends data set from memory
67       
68        //get the current selection
69        ControlInfo popup0
70        if(strlen(S_Value)==0 || cmpstr(S_Value,"No data loaded")==0)
71                Abort "You must load data from a file into memory before appending the data"
72        Endif
73       
74        A_PM_doAppend(S_Value)
75       
76        DoWindow/F Plot_Manager
77End
78
79//actually does the appending
80//pass it the name of the wave, find the q-i-s waves
81Function A_PM_doAppend(DF)
82        String DF
83        //appends data set from memory
84        String qStr,eStr,istr
85        Variable rr,gg,bb
86       
87        if(cmpstr(WinList("*", ";","WIN:1"),"") == 0 )
88                DoAlert 0,"There are no open graphs. Please use the New Graph button"
89                return(0)
90        endif
91       
92        SetDataFolder $("root:"+DF)
93        //iStr will end in "i"
94        qStr = DF+"_q"
95        eStr = DF+"_s"
96        iStr = DF+"_i"
97       
98        rr = abs(trunc(enoise(65535)))
99        gg = abs(trunc(enoise(65535)))
100        bb = abs(trunc(enoise(65535)))
101       
102        // append to whatever is top-most graph
103        AppendToGraph $iStr vs $qStr
104        ModifyGraph log=1,mode($istr)=3,marker($iStr)=19,msize($iStr)=2,rgb($iStr)=(rr,gg,bb)
105        ErrorBars $iStr Y,wave=($eStr,$eStr)
106
107        SetDataFolder root:
108End
109
110Proc A_PlotManager_newGraph(ctrlName) : ButtonControl
111        String ctrlName
112       
113        //get the current selection
114        ControlInfo popup0
115        if(strlen(S_Value)==0 || cmpstr(S_Value,"No data loaded")==0)
116                Abort "You must load data from a file into memory before plotting the data"
117        Endif
118       
119        A_PM_doNewGraph(S_Value)
120        DoWindow/F Plot_Manager
121End
122
123Function A_PM_doNewGraph(DF)
124        String DF
125
126        String qStr,eStr,iStr
127        Variable rr,gg,bb
128       
129        SetDataFolder $("root:"+DF)
130        //iStr will end in "i"
131        qStr = DF+"_q"
132        eStr = DF+"_s"
133        iStr = DF+"_i"
134       
135        rr = abs(trunc(enoise(65535)))
136        gg = abs(trunc(enoise(65535)))
137        bb = abs(trunc(enoise(65535)))
138       
139        // always make a new graph
140        Display $iStr vs $qStr
141        ModifyGraph log=1,mode($istr)=3,marker($iStr)=19,msize($iStr)=2,rgb=(rr,gg,bb)
142        ModifyGraph grid=1,mirror=2,standoff=0
143        ErrorBars $iStr Y,wave=($eStr,$eStr)
144        ModifyGraph tickUnit(left)=1
145                               
146        Label left "I(q)"
147        Label bottom "q (A\\S-1\\M)"
148       
149        Legend
150       
151        SetDataFolder root:
152End
153
154//kill the specified wave (if possible)
155Proc A_PlotManager_Kill(ctrlName) : ButtonControl
156        String ctrlName
157       
158        String savDF=GetDataFolder(1)
159        String DF
160
161        ControlInfo popup0
162        DF=S_Value              //this will end in "i"
163
164        SetDataFolder DF
165        KillVariables/A                 //removes the dependent variables
166        SetDataFolder savDF
167       
168        //now kill the data folder
169        KillDataFolder $DF
170        ControlUpdate popup0            //refresh the popup, very important if last item removed
171End
172
173//kill the specified wave (if possible)
174Proc A_PlotManager_KillAll(ctrlName) : ButtonControl
175        String ctrlName
176       
177        String savDF=GetDataFolder(1)
178        String DF
179
180        String list =  A_OneDDataInMemory()
181        Variable num=ItemsInList(list),ii
182       
183        ii=0
184        do     
185                DF=StringFromList(ii, list  ,";")
186               
187                SetDataFolder DF
188                KillVariables/A                 //removes the dependent variables first
189                SetDataFolder savDF
190       
191                //now kill the data folder
192                KillDataFolder/Z $DF
193                ii+=1
194        while(ii<num)
195        ControlUpdate popup0            //refresh the popup, very important if all items are removed
196End
197
198Proc A_Init_OneDLoader()
199        //create the data folder
200        NewDataFolder/O/S root:myGlobals:OneDLoader
201        //create the waves
202        Make/O/T/N=1 fileWave=""
203        Make/O/N=1 selWave=0
204        Variable/G ind=0
205        SetDataFolder root:
206End
207
208
209//prompt for a new path, and get a new listing
210Function A_OneDLoader_NewFolderButton(ctrlName) : ButtonControl
211        String ctrlName
212
213        A_PickPath()
214        A_OneDLoader_GetListButton("")
215        return(0)
216End
217
218//filters to remove only the files that are named like a raw data file, i.e. "*.SAn"
219//does not check to see if they really are RAW files though...(too tedious)
220Function A_OneDLoader_GetListButton(ctrlName) : ButtonControl
221        String ctrlName
222       
223        //make sure that path exists
224        PathInfo catPathName
225        if (V_flag == 0)
226                Abort "Folder path does not exist - use \"New Folder\" button on Main Panel"
227        Endif
228       
229        String newList = A_ReducedDataFileList("")
230        Variable num
231       
232        num=ItemsInList(newlist,";")
233        WAVE/T fileWave=$"root:myGlobals:OneDLoader:fileWave"
234        WAVE selWave=$"root:myGlobals:OneDLoader:selWave"
235        Redimension/N=(num) fileWave
236        Redimension/N=(num) selWave
237        fileWave = StringFromList(p,newlist,";")
238        Sort filewave,filewave
239End
240
241Function A_OneDLoader_LoadButton(ctrlName) : ButtonControl
242        String ctrlName
243       
244        //loop through the selected files in the list...
245        Wave/T fileWave=$"root:myGlobals:OneDLoader:fileWave"
246        Wave sel=$"root:myGlobals:OneDLoader:selWave"
247        Variable num=numpnts(sel),ii=0
248        String fname="",pathStr="",fullPath="",newFileName=""
249       
250        PathInfo catPathName                    //this is where the files are
251        pathStr=S_path
252       
253        Variable doGraph,cnt
254
255        ControlInfo check0
256        doGraph=V_Value
257        cnt=0
258        // get the current state
259        do
260                if(sel[ii] == 1)
261                        fname=pathStr + fileWave[ii]
262                        Execute "A_LoadOneDDataWithName(\""+fname+"\",1)"
263                        cnt += 1        //a file was loaded
264                endif
265                ii+=1
266        while(ii<num)
267
268        return(0)
269End
270
271
272//function called by the popups to get a file list of data that can be sorted
273// this procedure simply removes the raw data files from the string - there
274//can be lots of other junk present, but this is very fast...
275//
276// could also use the alternate procedure of keeping only file with the proper extension
277//
278// another possibility is to get a listing of the text files, but is unreliable on
279// Windows, where the data file must be .txt (and possibly OSX)
280//
281Function/S A_ReducedDataFileList(ctrlName)
282        String ctrlName
283
284        String list="",newList="",item=""
285        Variable num,ii
286       
287        //check for the path
288        PathInfo catPathName
289        if(V_Flag==0)
290                DoAlert 0, "Data path does not exist - pick the data path from the button on the main panel"
291                Return("")
292        Endif
293       
294        list = IndexedFile(catpathName,-1,"????")
295        num=ItemsInList(list,";")
296        //print "num = ",num
297        for(ii=(num-1);ii>=0;ii-=1)
298                item = StringFromList(ii, list  ,";")
299                //simply remove all that are not raw data files (SA1 SA2 SA3)
300                if( !stringmatch(item,"*.SA1*") && !stringmatch(item,"*.SA2*") && !stringmatch(item,"*.SA3*") )
301                        if( !stringmatch(item,".*") && !stringmatch(item,"*.pxp") && !stringmatch(item,"*.DIV"))                //eliminate mac "hidden" files, pxp, and div files
302                                newlist += item + ";"
303                        endif
304                endif
305        endfor
306        //sort
307        newList = SortList(newList,";",0)
308
309        return newlist
310End
Note: See TracBrowser for help on using the repository browser.