source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_RAW_Data_Panel.ipf @ 1108

Last change on this file since 1108 was 1108, checked in by srkline, 5 years ago

changes mostly to VCALC to add in what bits of information I have about the instrument dimensions. Added in stubs (based on NG3 SANS) for the beam intensity. Added in a preset condition for Front+Middle. Still need a more uniform way to do this.

File size: 40.3 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2#pragma version=1.0
3#pragma IgorVersion=6.1
4
5//
6// this will become the equivalent of "RawWindowHook"
7//
8// Procedures to:
9// display the detector data
10// visualization tools
11// mouse interaction
12// status information necessary to understand the data
13// buttons to more functionality to process data
14
15
16// TODO
17//
18// -- have the status automatically fill in when a new file is loaded, rather than needing a click of the "status" button
19// x- need a place somewhere to show the currently displayed folder
20// x- checkboxes for "active" corrections?
21// x- display of Q, counts, QxQy, X and Y
22// x- do I need a color bar? or is this not used at all? I like it to be there, or the colors are a waste of information
23//              (then... where do I put the color bar?)
24// x- define the "hook" function, and attach it to the panel (or the main detector subwindow?)
25//
26
27
28//
29// call this after loading data to either draw the data display panel or to update the contents
30//
31// TODO
32// -- make sure that the "type" input is correctly used for the updating of the data, values, etc.
33// -- add a procedure to define the global variables for pos, counts, QxQy, etc.
34//
35Function V_UpdateDisplayInformation(type)
36        String type
37       
38        DoWindow/F VSANS_Data
39//      Print V_flag
40        if(V_flag==0)
41       
42                VSANSDataPanelGlobals()
43               
44                Execute "VSANS_DataPanel()"             //draws the panel
45
46        endif
47       
48        // TODO: update the information here  - in either case
49        // what isn't automatically picked up? What is "stale" on the display?
50        String/G root:Packages:NIST:VSANS:Globals:gCurDispType = type
51       
52        // fake a click on all three tabs - to populate the data
53        V_FakeTabClick(2)
54        V_FakeTabClick(1)
55        V_FakeTabClick(0)
56
57        V_LogLinDisplayPref()           // resets the display depending on the preference state
58       
59        // either clear the status, or fake a click
60//      root:Packages:NIST:VSANS:Globals:gStatusText = "status info box"
61
62        V_FakeStatusButtonClick()
63
64// NOTE: This is where the beam center is picked up so that the panel array scaling is reset
65// so that the images will automatically display in relation to the beam center
66        V_FakeRestorePanelsButtonClick()                //so the panels display correctly
67
68       
69//      DoWindow/T VSANS_Data,type + " VSANS_Data"
70
71        // get the string with the file name that is in the "type" folder
72        // this string is what goes in the status of the display
73        SVAR gFileForDisplay = root:Packages:NIST:VSANS:Globals:gLastLoadedFile         //for the status of the display
74        SVAR gFileList = $("root:Packages:NIST:VSANS:"+type+":gFileList")
75       
76        gFileForDisplay=gFileList
77       
78
79        String newTitle = "WORK_"+type
80        DoWindow/F VSANS_Data
81        DoWindow/T VSANS_Data, newTitle
82        KillStrings/Z newTitle
83       
84end
85
86Function V_LogLinDisplayPref()
87
88        // get the state of the log/lin button, and make sure preferences are obeyed
89        // log/lin current state is in the S_UserData string (0=linear, 1=log)
90        ControlInfo/W=VSANS_Data button_log
91        Variable curState
92        curState = str2num(S_UserData)
93
94        NVAR gLogScalingAsDefault = root:Packages:NIST:VSANS:Globals:gLogScalingAsDefault
95        if(curState != gLogScalingAsDefault)
96                STRUCT WMButtonAction ba
97                ba.eventCode = 2                //fake mouse click
98                V_LogLinButtonProc(ba)
99        endif
100       
101        return(0)
102end
103
104
105//
106// creates/initializes the globals for display of the data panel
107//
108Function VSANSDataPanelGlobals()
109
110        SetDataFolder root:Packages:NIST:VSANS:Globals
111       
112        Variable/G gXPos=0
113        Variable/G gYPos=0
114        Variable/G gQX=0
115        Variable/G gQY=0
116        Variable/G gQQ=0
117        Variable/G gNCounts=0
118        String/G gCurDispFile = "default string"
119        String/G gCurTitle = ""
120        String/G gCurDispType = ""
121        String/G gStatusText = "status"
122        String/G gLastLoadedFile=""
123       
124        SetDataFolder root:
125End
126
127
128// TODO
129//
130// -- now that the sliders work, label them and move them to a better location
131// -- logical location for all of the buttons
132// -- add raw data load button, load/draw mask button
133// x- fill in the proper window title in the DoWindow/T command
134// -- add help text for all of the controls
135// -- tab order? can I set this?
136//
137Window VSANS_DataPanel() : Panel
138        PauseUpdate; Silent 1           // building window...
139        NewPanel /W=(37,45,1038,719) /K=1 /N=VSANS_Data
140//      ShowTools/A
141        ModifyPanel cbRGB=(65535,60076,49151)
142
143        String curFolder = root:Packages:NIST:VSANS:Globals:gCurDispType
144        DoWindow/T VSANS_Data,curFolder + " VSANS_Data"
145        SetWindow VSANS_Data,hook(dataHook)=VSANSDataHook,hookevents=2
146       
147        SetDrawLayer UserBack
148        SetDrawEnv linethick= 2,dash= 1,fillpat= 0
149        DrawRect 200,70,310,160
150        SetDrawEnv linethick= 2,dash= 1,fillpat= 0
151        DrawRect 320,70,430,160
152        SetDrawEnv linethick= 2,dash= 1,fillpat= 0
153        DrawRect 440,70,535,160
154       
155        SetDrawEnv fsize= 18
156        DrawText 230,115,"Front"
157        SetDrawEnv fsize= 18
158        DrawText 348,115,"Middle"
159        SetDrawEnv fsize= 18
160        DrawText 476,115,"Back"
161       
162        ToolsGrid visible=1
163
164
165        TabControl tab0,pos={13,41},size={572,617},proc=V_DataTabProc,tabLabel(0)="Front"
166        TabControl tab0,tabLabel(1)="Middle",tabLabel(2)="Back",value= 2,focusRing=0
167        TabControl tab0 labelBack=(63535,56076,45151)
168
169// on the side 
170        Button button_status,pos={607,146},size={70,20},proc=V_StatusButtonProc,title="Status",disable=2
171        Button button_IvsQ,pos={689,113},size={70,20},proc=V_IvsQPanelButtonProc,title="I vs. Q"
172        Button button_file_m,pos={619,55},size={50,20},proc=V_File_minus_ButtonProc,title="File <"
173        Button button_file_p,pos={679,55},size={50,20},proc=V_File_plus_ButtonProc,title="File >"
174        Button button_log,pos={689,146},size={70,20},proc=V_LogLinButtonProc,title="isLin",userData="0"
175        Button button_tab_p,pos={648,81},size={50,20},proc=V_Tab_p_ButtonProc,title="Tab >"
176        Button button_isolate,pos={606,114},size={70,20},proc=V_IsolateButtonProc,title="Isolate"
177        Button button_toWork,pos={770,146},size={90,20},proc=V_ToWorkFileButtonProc,title="to WORK"
178        Button button_annular,pos={770,114},size={90,20},proc=V_annularAvgButtonProc,title="Annular Avg"
179        Button button_SpreadPanels,pos={880,114},size={100,20},proc=V_SpreadPanelButtonProc,title="Spread Panels"
180        Button button_RestorePanels,pos={880,146},size={100,20},proc=V_RestorePanelButtonProc,title="Restore Panels"
181
182
183        TitleBox title_file,pos={606,178},fsize=12,size={76,20},variable= root:Packages:NIST:VSANS:Globals:gLastLoadedFile
184        TitleBox title_dataPresent,pos={606,210},fsize=12,size={76,20},variable= root:Packages:NIST:VSANS:Globals:gCurDispFile
185        TitleBox title_status,pos={606,240},size={200,200},fsize=12,variable= root:Packages:NIST:VSANS:Globals:gStatusText
186       
187//      Button button_tagFile,pos={720,412},size={70,20},proc=V_TagFileButtonProc,title="Tag File"
188//      Button button_tagFile,disable=2
189//      Button button_saveIQ,pos={603,412},size={120,20},proc=V_SaveIQ_ButtonProc,title="Save I(Q) as ITX"
190//      Button button_BeamCtr,pos={603,566},size={110,20},proc=V_BeamCtrButtonProc,title="Beam Center",disable=2
191//      Button pick_trim,pos={603,450},size={120,20},proc=V_TrimDataProtoButton,title="Trim I(Q) Data"
192//      Button pick_trim,help={"This button will prompt the user for trimming parameters"}     
193       
194
195// on the tabs, always visible
196        TitleBox title_xy,pos={20,65},fsize=12,size={76,20},variable= root:Packages:NIST:VSANS:Globals:gLastLoadedFile
197        Slider slider_hi,pos={558,224},size={16,80},proc=V_HiMapSliderProc
198        Slider slider_hi,limits={0,1,0},value= 1,ticks= 0
199        Slider slider_lo,pos={558,315},size={16,80},proc=V_LowMapSliderProc
200        Slider slider_lo,limits={0,1,0},value= 0,ticks= 0
201
202        SetVariable xpos,pos={22,97},size={50,17},title="X "
203        SetVariable xpos,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:gXPos
204        SetVariable xpos,help={"x-position on the detector"},frame=0,noedit=1
205        SetVariable ypos,pos={22,121},size={50,17},title="Y "
206        SetVariable ypos,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:gYPos
207        SetVariable ypos,help={"y-position on the detector"},frame=0,noedit=1
208        SetVariable counts,pos={22,151},size={150,17},title="Counts "
209        SetVariable counts,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:gNCounts
210        SetVariable counts,help={"Neutron counts"},frame=0,noedit=1
211        SetVariable qxval,pos={83,94},size={85,17},title="qX"
212        SetVariable qxval,help={"q value in the x-direction on the detector"},frame=0,noedit=1
213        SetVariable qxval,format="%+7.5f",limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:gQX
214        SetVariable qyval,pos={83,113},size={85,17},title="qY"
215        SetVariable qyval,help={"q value in the y-direction on the detector"},frame=0,noedit=1
216        SetVariable qyval,format="%+7.5f",limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:gQY
217        SetVariable q_pos,pos={83,132},size={85,17},title="q "
218        SetVariable q_pos,help={"q-value on the detector at (x,y)"},format="%+7.5f"
219        SetVariable q_pos,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:gQQ,frame=0,noedit=1
220       
221        Make/O/D tmp_asdf
222        // for back panels (in pixels) 
223//      Display/W=(50,185,545,620)/HOST=# tmp_asdf
224        Display/W=(50,185,517,620)/HOST=# tmp_asdf
225        RenameWindow #,det_panelsB
226        ModifyGraph mode=2              // mode = 2 = dots
227        ModifyGraph marker=19
228        ModifyGraph rgb=(0,0,0)
229        ModifyGraph tick=2,mirror=1
230//      Label left "pixels"                     //don't bother labeling pixels here - it will get redrawn, do it
231//      Label bottom "pixels"                   // when the selected tab is resized to be the focus
232        SetActiveSubwindow ##
233       
234        // for middle panels (in pixels?)       
235        Display/W=(50,185,517,620)/HOST=# tmp_asdf
236        RenameWindow #,det_panelsM
237        ModifyGraph mode=2              // mode = 2 = dots
238        ModifyGraph marker=19
239        ModifyGraph rgb=(0,0,0)
240        ModifyGraph tick=2,mirror=1
241//      Label left "pixels"
242//      Label bottom "pixels"   
243        SetActiveSubwindow ##
244       
245        // for front panels (in pixels?)       
246        Display/W=(50,185,517,620)/HOST=# tmp_asdf
247        RenameWindow #,det_panelsF
248        ModifyGraph mode=2              // mode = 2 = dots
249        ModifyGraph marker=19
250        ModifyGraph rgb=(0,0,0)
251        ModifyGraph tick=2,mirror=1
252//      Label left "pixels"
253//      Label bottom "pixels"   
254        SetActiveSubwindow ##
255       
256EndMacro
257
258//
259// event code 4: mouse moved
260// event code 11: keyboard events
261//
262// mouse moved is the only event that I really care about for the data display.
263//
264// TODO:
265// -- figure out how to respond only to events in the main window
266// -- figure out which is the correct image to respond "from"
267// -- More complete documentation of how the hook is identifying what graph is "under" the mouse
268//    AND what assumptions are behind this identification
269//
270//
271Function VSANSDataHook(s)
272        STRUCT WMWinHookStruct &s
273
274        Variable hookResult = 0
275
276        switch(s.eventCode)
277                case 0:                         // Activate
278                        // Handle activate
279//                      Print "Activate"
280                        break
281
282                case 1:                         // Deactivate
283                        // Handle deactivate
284                        break
285                       
286                case 3:         //mouse down
287//                      Print "mouse down"
288//
289// TODO (Way in the future -- I could make the small graphs into "buttons" by responding to a "mouse up" (not down)
290//    that hits in one of the small graph areas, and treat that as a click on that tab
291// -- instead of this, I can try to get the focus rectangle to work more easily to move with the TAB,
292//    if I can intercept the keystroke (event 11), see below.
293//
294                        break
295                       
296                case 4:         // mouse moved
297                        NVAR xloc = root:Packages:NIST:VSANS:Globals:gXPos
298                        NVAR yloc = root:Packages:NIST:VSANS:Globals:gYPos
299                        NVAR gQX = root:Packages:NIST:VSANS:Globals:gQX
300                        NVAR gQY = root:Packages:NIST:VSANS:Globals:gQY
301                        NVAR gQQ = root:Packages:NIST:VSANS:Globals:gQQ
302                        NVAR gNCounts = root:Packages:NIST:VSANS:Globals:gNCounts
303                        SVAR gCurDispFile = root:Packages:NIST:VSANS:Globals:gCurDispFile
304                        SVAR gCurDispType = root:Packages:NIST:VSANS:Globals:gCurDispType               //the current folder
305                        Variable xaxval,yaxval,tab
306                       
307                        // is the mouse location within the "main" display window?
308                        // if so, do something, if not, do nothing?
309                        // right now, the "main" display is at (50,185,545,620). its name depends on the active tab
310                       
311//                              xloc = s.mouseLoc.h
312//                              yloc = s.mouseLoc.v
313
314//                      if out of bounds, exit now
315//              TODO - currently the values are hard-wired. eliminate this later if the size of the graph changes
316                        if(s.mouseLoc.h < 50 || s.mouseLoc.h > 545 || s.mouseLoc.v < 185 || s.mouseLoc.v > 620)
317                                break
318                        endif   
319                       
320//                      if(in bounds)
321//                              get the point location
322//                              update the globals --
323//                              but which data instance am I pointing to?
324//                              deduce the carriage and panel, and calculate Q
325//                      endif
326
327                        GetWindow $s.winName activeSW
328                        String activeSubwindow = S_value                // returns something like: "VSANS_Data#det_panelsF"
329                               
330                        xaxval= AxisValFromPixel("","bottom",s.mouseLoc.h)
331                        yaxval= AxisValFromPixel("","left",s.mouseLoc.v)
332//                      xloc = round(xaxval)
333//                      yloc = round(yaxval)
334                        xloc = xaxval
335                        yloc = yaxval
336                       
337                        // which tab is selected? -this is the main graph panel (subwindow may not be the active one!)
338                        ControlInfo/W=VSANS_Data tab0
339                        tab = V_Value
340                        if(tab == 0)
341                                activeSubwindow = "VSANS_Data#det_panelsF"
342                        elseif (tab == 1)
343                                activeSubwindow = "VSANS_Data#det_panelsM"
344                        else
345                                activeSubwindow = "VSANS_Data#det_panelsB"
346                        endif
347                       
348                       
349                        // which images are here?
350                        String detStr="",imStr,carriageStr
351                        String currentImageRef
352                        String imageList = ImageNameList(activeSubwindow,";")
353                        Variable ii,nIm,testX,testY,xctr,yctr,sdd,lam,pixSizeX,pixSizeY
354                        nIm = ItemsInList(imageList,";")
355                        gCurDispFile = imageList
356                        if(nIm==0)
357                                break           //problem, get out
358                        endif
359
360                        // images were added in the order TBLR, so look back through in the order RLBT, checking each to see if
361                        // the xy value is found on that (scaled) array
362                                               
363                        // loop backwards through the list of panels (may only be one if on the back)
364                        for(ii=nIm-1;ii>=0;ii-=1)
365                                Wave w = ImageNameToWaveRef(activeSubwindow,StringFromList(ii, imageList,";"))
366                               
367                                // which, if any image is the mouse xy location on?
368                                // use a multidemensional equivalent to x2pnt: (ScaledDimPos - DimOffset(waveName, dim))/DimDelta(waveName,dim)
369
370                               
371                                testX = ScaleToIndex(w,xloc,0)
372                                testY = ScaleToIndex(w,yloc,1)
373                               
374                                if( (testX >= 0 && testX < DimSize(w,0)) && (testY >= 0 && testY < DimSize(w,1)) )
375                                        // we're in-bounds on this wave
376                                       
377                                        // count value to the global
378                                        gNCounts = w[testX][testY]              //wrong for T/B panels
379
380                                       
381                                        // deduce the detector panel
382                                        currentImageRef = StringFromList(ii, imageList,";")     //the image instance ##
383                                        // string is "data", or "data#2" etc. - so this returns "", "1", "2", or "3"
384                                        imStr = StringFromList(1, currentImageRef,"#")         
385                                        carriageStr = activeSubWindow[strlen(activeSubWindow)-1]
386                                       
387                                        if(cmpstr(carriageStr,"B")==0)
388                                                detStr = carriageStr
389                                        else
390                                                if(strlen(imStr)==0)
391                                                        imStr = "9"                     // a dummy value so I can replace it later
392                                                endif
393                                                detStr = carriageStr+imStr              // "F2" or something similar
394                                                detStr = ReplaceString("9", detStr, "T")        // ASSUMPTION :::: instances 0123 correspond to TBLR
395                                                detStr = ReplaceString("1", detStr, "B")        // ASSUMPTION :::: this is the order that the panels
396                                                detStr = ReplaceString("2", detStr, "L")        // ASSUMPTION :::: are ALWAYS added to the graph
397                                                detStr = ReplaceString("3", detStr, "R")        // ASSUMPTION ::::
398                                        endif
399                                        gCurDispFile = detStr
400
401                                        // now figure out q
402                                        // calculate the q-values, will be different depending on which panel is up (pixel size, geometry, etc.)
403                                        // DONE: !!!! get rid of the hard-wired values
404                                        // DONE: be sure that the units from HDF are what I expect
405                                        // DONE: beam center XY are pixels in the file, expected in the function, but are better suited for mm or cm
406                                        // DONE: units of xy pixel size are likely wrong
407//                                      xctr = V_getDet_beam_center_x(gCurDispType,detStr)              //written in pixels
408//                                      yctr = V_getDet_beam_center_y(gCurDispType,detStr)
409                                        xctr = V_getDet_beam_center_x_mm(gCurDispType,detStr)           //written in mm
410                                        yctr = V_getDet_beam_center_y_mm(gCurDispType,detStr)   
411                                       
412                                        sdd = V_getDet_ActualDistance(gCurDispType,detStr)              //written in cm, pass in [cm]
413                                        lam = V_getWavelength(gCurDispType)             //A
414//                                      pixSizeX = V_getDet_x_pixel_size(gCurDispType,detStr)           // written mm? need mm
415//                                      pixSizeY = V_getDet_y_pixel_size(gCurDispType,detStr)           // written mm? need mm
416//
417
418                                        String destPath = "root:Packages:NIST:VSANS:"+gCurDispType
419                                        Wave data_realDistX = $(destPath + ":entry:instrument:detector_"+detStr+":data_realDistX")
420                                        Wave data_realDistY = $(destPath + ":entry:instrument:detector_"+detStr+":data_realDistY")     
421                                       
422// DONE: figure out what coordinates I need to pass -- xloc, yloc, textX, testY, (+1 on any?)                           
423                                        //gQQ = VC_CalcQval(testX,testY,xctr,yctr,sdd,lam,pixSizeX,pixSizeY)
424                                        //gQX = VC_CalcQX(testX,testY,xctr,yctr,sdd,lam,pixSizeX,pixSizeY)
425                                        //gQY = VC_CalcQY(testX,testY,xctr,yctr,sdd,lam,pixSizeX,pixSizeY)
426                                        gQQ = V_CalcQval(testX,testY,xctr,yctr,sdd,lam,data_realDistX,data_realDistY)
427                                        gQX = V_CalcQX(testX,testY,xctr,yctr,sdd,lam,data_realDistX,data_realDistY)
428                                        gQY = V_CalcQY(testX,testY,xctr,yctr,sdd,lam,data_realDistX,data_realDistY)
429
430                                        ii = -1         //look no further, set ii to bad value to exit the for loop
431                                       
432                                        // TODO
433                                        //  this - it sets the globals to display to the pixel values, unscaled
434                                        xloc = testX
435                                        yloc = testY
436                                       
437                                endif   //end if(mouse is over a detector panel)
438                               
439
440                        endfor          // end loop over list of displayed images
441               
442                        break
443                       
444                        case 11: // keyboard event
445                                // TODO -- figure out why I'm not getting the TAB keystroke
446                                //  -- I want to be able to use the tab to change the focus only between File <.> and Tab > buttons, not everything
447                                // see the help file section "Keyboard Events" for an example and "WMWinHookStruct"
448                               
449                                //Print "key code = ",s.specialKeyCode
450                                //hookresult = 1                //if non-zero, we handled it and Igor will ignore it
451                                break
452                // And so on . . .
453        endswitch
454
455        return hookResult               // 0 if nothing done, else 1
456End
457
458
459// ********
460//
461// this procedure does most of the work for drawing the panels, setting the proper log/lin
462// scaling, the color scale, and the location based on the active tab
463//
464//lots to to here:
465//
466// - 1 - display the appropriate controls for each tab, and hide the others
467// - 2 - display the correct detector data for each tab, and remove the others from the graph
468// -----?? can I draw 3 graphs, and just put the right one on top?? move the other two to the side?
469//
470//
471// TODO
472//  -- add all of the controls of the VCALC panel (log scaling, adjusting the axes, etc.)
473//  x- get the panel to be correctly populated first, rather than needing to click everywhere to fill in
474//  x- remove the dependency on VCALC being initialized first, and using dummy waves from there...
475//
476//
477Function V_DataTabProc(tca) : TabControl
478        STRUCT WMTabControlAction &tca
479
480        switch( tca.eventCode )
481                case 2: // mouse up
482                        Variable tab = tca.tab
483               
484//                      SetDataFolder root:Packages:NIST:VSANS:VCALC
485                        SetDataFolder root:
486                        RemoveFromGraph/Z /W=VSANS_Data#det_panelsB tmp_asdf
487                        RemoveFromGraph/Z /W=VSANS_Data#det_panelsM tmp_asdf
488                        RemoveFromGraph/Z /W=VSANS_Data#det_panelsF tmp_asdf
489                        SetDataFolder root:
490                       
491                        SVAR dataType = root:Packages:NIST:VSANS:Globals:gCurDispType
492                       
493// make sure log scaling is correct
494                        NVAR state = root:Packages:NIST:VSANS:Globals:gIsLogScale
495                        if(State == 0)
496                                // lookup wave
497                                Wave LookupWave = root:Packages:NIST:VSANS:Globals:linearLookupWave
498                        else
499                                // lookup wave - the linear version
500                                Wave LookupWave = root:Packages:NIST:VSANS:Globals:logLookupWave
501                        endif
502                                               
503                       
504                        //************
505                        // -- can I use "ReplaceWave/W=VSANS_Data#det_panelsB allinCDF" to do this?
506                        // -- only works for "B", since for M and F panels, all 4 data sets are named "data"
507                        // in their respective folders...
508                       
509                       
510                        // get the slider values for the color mapping
511                        Variable lo,hi,lo_B,hi_B
512                        Variable lo_MT,lo_MB,lo_MR,lo_ML
513                        Variable lo_FT,lo_FB,lo_FR,lo_FL
514                        Variable hi_MT,hi_MB,hi_MR,hi_ML
515                        Variable hi_FT,hi_FB,hi_FR,hi_FL
516                        ControlInfo slider_lo
517                        lo = V_Value
518                        ControlInfo slider_hi
519                        hi = V_Value
520                       
521                       
522                        String tmpStr
523                        Variable ii
524                        if(tab==2)
525                                tmpStr = ImageNameList("VSANS_Data#det_panelsB",";")
526                                // for some odd reason, it appears that I need to work from the back of the list
527                                // since the traces get "renumbered" as I take them off !! A do loop may be a better choice
528                                if(ItemsInList(tmpStr) > 0)
529                                        do
530                                                RemoveImage /W=VSANS_Data#det_panelsB $(StringFromList(0,tmpStr,";"))           //get 1st item
531                                                tmpStr = ImageNameList("VSANS_Data#det_panelsB",";")                                                            //refresh list
532                                        while(ItemsInList(tmpStr) > 0)
533                                endif
534                               
535                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:instrument:detector_B")
536                                Wave det_B=data
537                               
538                                CheckDisplayed /W=VSANS_Data#det_panelsB det_B 
539                                if(V_flag == 0)         // 0 == data is not displayed, so append it
540                                        AppendImage/W=VSANS_Data#det_panelsB det_B
541                                        lo_B = lo*(WaveMax(det_B) - WaveMin(det_B)) + WaveMin(det_B)
542                                        hi_B = hi*(WaveMax(det_B) - WaveMin(det_B)) + WaveMin(det_B)
543                                        ModifyImage/W=VSANS_Data#det_panelsB ''#0 ctab= {lo_B,hi_B,ColdWarm,0}          // don't autoscale {*,*,ColdWarm,0}
544                                endif
545                                MoveSubWindow/W=VSANS_Data#det_panelsB fnum=(50,185,517,620)
546                                MoveSubWindow/W=VSANS_Data#det_panelsM fnum=(320,70,430,160)
547                                MoveSubWindow/W=VSANS_Data#det_panelsF fnum=(200,70,310,160)
548
549                                ModifyImage/W=VSANS_Data#det_panelsB ''#0 ctabAutoscale=0,lookup= LookupWave
550                               
551//                              // make the plot square
552//                              ModifyGraph/W=VSANS_Data#det_panelsB width={Aspect,1}
553                                // match the aspect ratio of the data
554                                ModifyGraph/W=VSANS_Data#det_panelsB width={Aspect,0.41}                        //680/1656 = 0.41
555                               
556                                SetActiveSubWindow VSANS_Data#det_panelsB
557                                Label left "pixels"
558                                Label bottom "pixels"
559                                SetDataFolder root:
560                        endif
561       
562                        if(tab==1)
563                                tmpStr = ImageNameList("VSANS_Data#det_panelsM",";")
564                                // for some odd reason, it appears that I need to work from the back of the list
565                                // since the traces get "renumbered" as I take them off !! A do loop may be a better choice
566                                if(ItemsInList(tmpStr) > 0)
567                                        do
568                                                RemoveImage /W=VSANS_Data#det_panelsM $(StringFromList(0,tmpStr,";"))           //get 1st item
569                                                tmpStr = ImageNameList("VSANS_Data#det_panelsM",";")                                                            //refresh list
570                                        while(ItemsInList(tmpStr) > 0)
571                                endif
572
573                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:instrument:detector_ML")
574                                Wave det_ML=data                               
575                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:instrument:detector_MR")
576                                Wave det_MR=data
577                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:instrument:detector_MT")
578                                Wave det_MT=data
579                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:instrument:detector_MB")
580                                Wave det_MB=data
581
582                                CheckDisplayed /W=VSANS_Data#det_panelsM det_MR
583                                if(V_flag == 0)
584                                        AppendImage/W=VSANS_Data#det_panelsM det_MT             //order is important here to get LR on "top" of display
585                                        AppendImage/W=VSANS_Data#det_panelsM det_MB
586                                        AppendImage/W=VSANS_Data#det_panelsM det_ML
587                                        AppendImage/W=VSANS_Data#det_panelsM det_MR
588                                        lo_MT = lo*(WaveMax(det_MT) - WaveMin(det_MT)) + WaveMin(det_MT)
589                                        hi_MT = hi*(WaveMax(det_MT) - WaveMin(det_MT)) + WaveMin(det_MT)
590                                        lo_MB = lo*(WaveMax(det_MB) - WaveMin(det_MB)) + WaveMin(det_MB)
591                                        hi_MB = hi*(WaveMax(det_MB) - WaveMin(det_MB)) + WaveMin(det_MB)
592                                        lo_ML = lo*(WaveMax(det_ML) - WaveMin(det_ML)) + WaveMin(det_ML)
593                                        hi_ML = hi*(WaveMax(det_ML) - WaveMin(det_ML)) + WaveMin(det_ML)
594                                        lo_MR = lo*(WaveMax(det_MR) - WaveMin(det_MR)) + WaveMin(det_MR)
595                                        hi_MR = hi*(WaveMax(det_MR) - WaveMin(det_MR)) + WaveMin(det_MR)
596                                       
597                                        ModifyImage/W=VSANS_Data#det_panelsM ''#0 ctab= {lo_MT,hi_MT,ColdWarm,0}                // ''#n means act on the nth image (there are 4)
598                                        ModifyImage/W=VSANS_Data#det_panelsM ''#1 ctab= {lo_MB,hi_MB,ColdWarm,0}
599                                        ModifyImage/W=VSANS_Data#det_panelsM ''#2 ctab= {lo_ML,hi_ML,ColdWarm,0}
600                                        ModifyImage/W=VSANS_Data#det_panelsM ''#3 ctab= {lo_MR,hi_MR,ColdWarm,0}
601                                endif
602                                MoveSubWindow/W=VSANS_Data#det_panelsM fnum=(50,185,517,620)
603                                MoveSubWindow/W=VSANS_Data#det_panelsB fnum=(440,70,550,160)
604                                MoveSubWindow/W=VSANS_Data#det_panelsF fnum=(200,70,310,160)
605
606                                ModifyImage/W=VSANS_Data#det_panelsM ''#0 ctabAutoscale=0,lookup= LookupWave
607                                ModifyImage/W=VSANS_Data#det_panelsM ''#1 ctabAutoscale=0,lookup= LookupWave
608                                ModifyImage/W=VSANS_Data#det_panelsM ''#2 ctabAutoscale=0,lookup= LookupWave
609                                ModifyImage/W=VSANS_Data#det_panelsM ''#3 ctabAutoscale=0,lookup= LookupWave
610                               
611                                // make the plot square
612                                ModifyGraph/W=VSANS_Data#det_panelsM width={Aspect,1}
613                                                       
614                                SetActiveSubWindow VSANS_Data#det_panelsM
615                                Label left "pixels"
616                                Label bottom "pixels"
617                                SetDataFolder root:
618                        endif
619
620                        if(tab==0)
621                                tmpStr = ImageNameList("VSANS_Data#det_panelsF",";")
622                                // for some odd reason, it appears that I need to work from the back of the list
623                                // since the traces get "renumbered" as I take them off !! A do loop may be a better choice
624                                if(ItemsInList(tmpStr) > 0)
625                                        do
626                                                RemoveImage /W=VSANS_Data#det_panelsF $(StringFromList(0,tmpStr,";"))           //get 1st item
627                                                tmpStr = ImageNameList("VSANS_Data#det_panelsF",";")                                                            //refresh list
628                                        while(ItemsInList(tmpStr) > 0)
629                                endif
630
631                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:instrument:detector_FL")
632                                Wave det_FL=data
633                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:instrument:detector_FR")
634                                Wave det_FR=data
635                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:instrument:detector_FT")
636                                Wave det_FT=data                               
637                                SetDataFolder $("root:Packages:NIST:VSANS:"+dataType+":entry:instrument:detector_FB")
638                                Wave det_FB=data
639                                                               
640                                CheckDisplayed /W=VSANS_Data#det_panelsF det_FL
641                                if(V_flag == 0)
642                                        AppendImage/W=VSANS_Data#det_panelsF det_FT
643                                        AppendImage/W=VSANS_Data#det_panelsF det_FB
644                                        AppendImage/W=VSANS_Data#det_panelsF det_FL
645                                        AppendImage/W=VSANS_Data#det_panelsF det_FR
646                                        lo_FT = lo*(WaveMax(det_FT) - WaveMin(det_FT)) + WaveMin(det_FT)
647                                        hi_FT = hi*(WaveMax(det_FT) - WaveMin(det_FT)) + WaveMin(det_FT)
648                                        lo_FB = lo*(WaveMax(det_FB) - WaveMin(det_FB)) + WaveMin(det_FB)
649                                        hi_FB = hi*(WaveMax(det_FB) - WaveMin(det_FB)) + WaveMin(det_FB)
650                                        lo_FL = lo*(WaveMax(det_FL) - WaveMin(det_FL)) + WaveMin(det_FL)
651                                        hi_FL = hi*(WaveMax(det_FL) - WaveMin(det_FL)) + WaveMin(det_FL)
652                                        lo_FR = lo*(WaveMax(det_FR) - WaveMin(det_FR)) + WaveMin(det_FR)
653                                        hi_FR = hi*(WaveMax(det_FR) - WaveMin(det_FR)) + WaveMin(det_FR)
654                                       
655                                        ModifyImage/W=VSANS_Data#det_panelsF ''#0 ctab= {lo_FT,hi_FT,ColdWarm,0}
656                                        ModifyImage/W=VSANS_Data#det_panelsF ''#1 ctab= {lo_FB,hi_FB,ColdWarm,0}
657                                        ModifyImage/W=VSANS_Data#det_panelsF ''#2 ctab= {lo_FL,hi_FL,ColdWarm,0}
658                                        ModifyImage/W=VSANS_Data#det_panelsF ''#3 ctab= {lo_FR,hi_FR,ColdWarm,0}
659                                endif
660                                MoveSubWindow/W=VSANS_Data#det_panelsF fnum=(50,185,517,620)
661                                MoveSubWindow/W=VSANS_Data#det_panelsB fnum=(440,70,550,160)
662                                MoveSubWindow/W=VSANS_Data#det_panelsM fnum=(320,70,430,160)
663                               
664                                ModifyImage/W=VSANS_Data#det_panelsF ''#0 ctabAutoscale=0,lookup= LookupWave
665                                ModifyImage/W=VSANS_Data#det_panelsF ''#1 ctabAutoscale=0,lookup= LookupWave
666                                ModifyImage/W=VSANS_Data#det_panelsF ''#2 ctabAutoscale=0,lookup= LookupWave
667                                ModifyImage/W=VSANS_Data#det_panelsF ''#3 ctabAutoscale=0,lookup= LookupWave
668
669                                // make the plot square
670                                ModifyGraph/W=VSANS_Data#det_panelsF width={Aspect,1}                           
671       
672                                SetActiveSubWindow VSANS_Data#det_panelsF
673                                Label left "pixels"
674                                Label bottom "pixels"
675                                SetDataFolder root:
676                        endif
677
678                                               
679                        break
680                case -1: // control being killed
681                        break
682        endswitch
683
684
685// update the status when the tab is clicked                   
686        STRUCT WMButtonAction sa
687        sa.eventCode = 2
688        V_StatusButtonProc(sa)
689                       
690                       
691        return 0
692End
693
694// fake restore panels button click
695Function V_FakeRestorePanelsButtonClick()
696
697        STRUCT WMButtonAction ba
698        ba.eventCode = 2
699        V_RestorePanelButtonProc(ba)
700       
701        return(0)
702End
703
704
705// fake status button click
706Function V_FakeStatusButtonClick()
707
708        STRUCT WMButtonAction ba
709        ba.eventCode = 2
710        V_StatusButtonProc(ba)
711       
712        return(0)
713End
714
715// fake click on each tab to populate the data
716Function V_FakeTabClick(tab)
717        Variable tab
718       
719        STRUCT WMTabControlAction tca
720
721        tca.eventCode = 2               //fake mouse up
722        tca.tab = tab
723        V_DataTabProc(tca)
724       
725        TabControl tab0,win=VSANS_Data,value= tab               //select the proper tab
726        return(0)
727End
728
729//
730//
731// move one file number back
732//
733Function V_File_minus_ButtonProc(ba) : ButtonControl
734        STRUCT WMButtonAction &ba
735
736        switch( ba.eventCode )
737                case 2: // mouse up
738                        // click code here
739                        V_LoadPlotAndDisplayRAW(-1)
740                       
741                        break
742                case -1: // control being killed
743                        break
744        endswitch
745
746        return 0
747End
748
749//
750//
751// move one file number forward
752//
753Function V_File_plus_ButtonProc(ba) : ButtonControl
754        STRUCT WMButtonAction &ba
755
756        switch( ba.eventCode )
757                case 2: // mouse up
758                        // click code here
759                        V_LoadPlotAndDisplayRAW(1)
760
761                        break
762                case -1: // control being killed
763                        break
764        endswitch
765
766        return 0
767End
768
769//
770// button that mimics a click on the tab, cycling through the tabs 0->1->2->0 etc.
771// only goes one direction
772//
773Function V_Tab_p_ButtonProc(ba) : ButtonControl
774        STRUCT WMButtonAction &ba
775
776        switch( ba.eventCode )
777                case 2: // mouse up
778                        // click code here
779                        ControlInfo/W=VSANS_Data tab0
780                       
781                        V_Value += 1
782                        if(V_Value == 3)
783                                V_Value = 0             //reset to 0
784                        endif
785                        V_FakeTabClick(V_Value)
786
787// now part of every tab click
788//// update the status when the tab is clicked                 
789                        STRUCT WMButtonAction sa
790                        sa.eventCode = 2
791                        V_StatusButtonProc(sa)
792
793                        break
794                case -1: // control being killed
795                        break
796        endswitch
797
798        return 0
799End
800
801
802// See V_Detector_Isolate.ipf
803// isolates a single panel to allow a better view of the details
804// useful for T/B panels which are partially blocked from view
805//
806// will open a separate panel to display the selected detector
807// (more to do here, depending what is necessary for instrument troubleshooting)
808// - like being able to turn corrections on/off and view with different axes (pix, mm, Q)
809//
810Function V_IsolateButtonProc(ba) : ButtonControl
811        STRUCT WMButtonAction &ba
812
813        switch( ba.eventCode )
814                case 2: // mouse up
815                        // click code here
816                        V_DetectorIsolate()
817                        break
818                case -1: // control being killed
819                        break
820        endswitch
821
822        return 0
823End
824
825//
826// if the data display is RAW, convert to the specified WORK data type
827//
828// DONE
829// x- better error checking
830// x- if the data type is not RAW, can I Copy Folder instead?
831//
832Function V_ToWorkFileButtonProc(ba) : ButtonControl
833        STRUCT WMButtonAction &ba
834
835        switch( ba.eventCode )
836                case 2: // mouse up
837                        // click code here
838                       
839                        Execute "V_Convert_to_Workfile()"
840
841                        break
842                case -1: // control being killed
843                        break
844        endswitch
845
846        return 0
847End
848
849
850//
851//
852// opens a separate panel with the I(q) representation of the data
853//  controls on the panel select how the data is processed/grouped, etc.
854//
855//
856Function V_IvsQPanelButtonProc(ba) : ButtonControl
857        STRUCT WMButtonAction &ba
858
859        switch( ba.eventCode )
860                case 2: // mouse up
861                        // click code here
862                       
863                        V_PlotData_Panel()              //-9999 requests a read from the popup on the panel
864                        Variable binType = V_GetBinningPopMode()
865                        ControlInfo/W=V_1D_Data popup0
866                        V_BinningModePopup("",binType,S_Value)          // does binning of current popString and updates the graph
867                       
868                        break
869                case -1: // control being killed
870                        break
871        endswitch
872
873        return 0
874End
875
876
877//
878// TODO:
879// -- simply calls the missing parameter dialog to do the average.
880//  see the file V_IQ_Annular.ipf for all of the features yet to be added.
881//
882// x- currently just the graph, no controls
883//
884Function V_annularAvgButtonProc(ba) : ButtonControl
885        STRUCT WMButtonAction &ba
886
887        switch( ba.eventCode )
888                case 2: // mouse up
889                        // click code here
890                       
891                        Execute "Annular_Binning()"                     
892
893                        break
894                case -1: // control being killed
895                        break
896        endswitch
897
898        return 0
899End
900
901//
902//
903// gets the status of the currently displayed file and dumps it to the panel (not the cmd window)
904// - lots to decide here about what is the important stuff to display. There's a lot more information for VSANS
905//
906Function V_StatusButtonProc(ba) : ButtonControl
907        STRUCT WMButtonAction &ba
908
909        switch( ba.eventCode )
910                case 2: // mouse up
911                        // click code here
912                       
913                        // figure out wether to display per carraige, or the whole file
914                        SVAR str = root:Packages:NIST:VSANS:Globals:gStatusText
915                        SVAR type = root:Packages:NIST:VSANS:Globals:gCurDispType               //what folder
916                        // which tab active
917                        ControlInfo/W=VSANS_Data tab0
918                        Variable curTab = V_value
919                       
920//                      // fake this, since if the tab was clicked, it hasn't been updated yet and we're off by one
921//                      if(ba.eventCode == 3)
922//                              curTab += 1
923//                              if(curTab == 3)
924//                                      curTab = 0
925//                              endif
926//                      endif
927                       
928                        //
929                        str = "Current data is from "+ type + "\r"
930                        str += "Description = "+V_getSampleDescription(type) + "\r"
931                        str += "Wavelength is "+num2str(V_getWavelength(type)) + " A \r"
932                        if(curTab == 2)
933                                str += "SDD B = "+num2str(V_getDet_ActualDistance(type,"B")) + " cm \r"         //V_getDet_distance(fname,detStr)
934                        endif
935                        if(curTab == 1)
936                                str += "SDD ML = "+num2str(V_getDet_ActualDistance(type,"ML")) + " cm   "
937                                str += "offset = "+num2str(V_getDet_LateralOffset(type,"ML")) + " cm \r"
938                                str += "SDD MR = "+num2str(V_getDet_ActualDistance(type,"MR")) + " cm   "
939                                str += "offset = "+num2str(V_getDet_LateralOffset(type,"MR")) + " cm \r"
940                                str += "SDD MT = "+num2str(V_getDet_ActualDistance(type,"MT")) + " cm   "
941                                str += "offset = "+num2str(V_getDet_VerticalOffset(type,"MT")) + " cm \r"
942                                str += "SDD MB = "+num2str(V_getDet_ActualDistance(type,"MB")) + " cm   "
943                                str += "offset = "+num2str(V_getDet_VerticalOffset(type,"MB")) + " cm \r"
944                        endif
945                        if(curTab == 0)
946                                str += "SDD FL = "+num2str(V_getDet_ActualDistance(type,"FL")) + " cm   "
947                                str += "offset = "+num2str(V_getDet_LateralOffset(type,"FL")) + " cm \r"
948                                str += "SDD FR = "+num2str(V_getDet_ActualDistance(type,"FR")) + " cm   "
949                                str += "offset = "+num2str(V_getDet_LateralOffset(type,"FR")) + " cm \r"
950                                str += "SDD FT = "+num2str(V_getDet_ActualDistance(type,"FT")) + " cm   "
951                                str += "offset = "+num2str(V_getDet_VerticalOffset(type,"FT")) + " cm \r"
952                                str += "SDD FB = "+num2str(V_getDet_ActualDistance(type,"FB")) + " cm   "
953                                str += "offset = "+num2str(V_getDet_VerticalOffset(type,"FB")) + " cm \r"
954                        endif
955                       
956                       
957                       
958                       
959                       
960                        break
961                case -1: // control being killed
962                        break
963        endswitch
964
965        return 0
966End
967
968
969// TODO:
970// x- link this to the preferences for the display. this is done in UpdateDisplayInformation (the main call) so that
971//     the panels are rescaled only once, rather than toggled three times (F, M, B) if I call from the tabProc
972// -- come up with a better definition of the log lookup wave (> 1000 pts, what is the first point)
973// -- make an equivalent linear wave
974// -- hard wire it in so it is created at initialization and stored someplace safe
975// -- catch the error if it doesn't exist (re-make the wave as needed)
976//
977// Using the ModifyImage log=1 keyword fails for values of zero in the data, which is a common
978// occurrence with count data. the display just goes all gray, so that's not an option. Use the lookup wave instead
979//
980// toggle the (z) value of the display log/lin
981//
982Function V_LogLinButtonProc(ba) : ButtonControl
983        STRUCT WMButtonAction &ba
984
985        switch( ba.eventCode )
986                case 2: // mouse up
987                        // click code here
988                       
989                        // which tab is active? does it matter - or do I log-scale everything?
990                        // log/lin current state is in the S_UserData string (0=linear, 1=log)
991                        ControlInfo/W=VSANS_Data button_log
992                        Variable curState,newState
993                        String newStateStr,newTitleStr
994                       
995                       
996                        curState = str2num(S_UserData)
997                       
998                        if(curState == 0)
999                                newState = 1
1000                                newStateStr="1"
1001                                newTitleStr = "isLog"
1002                                // lookup wave
1003                                Wave LookupWave = root:Packages:NIST:VSANS:Globals:logLookupWave
1004                        else
1005                                newState = 0
1006                                newStateStr="0"
1007                                newTitleStr = "isLin"
1008                                // lookup wave - the linear version
1009                                Wave LookupWave = root:Packages:NIST:VSANS:Globals:linearLookupWave
1010                        endif
1011                       
1012                        // update the button and the global value
1013                        Button button_log,userData=newStateStr,title=newTitleStr
1014                        NVAR state = root:Packages:NIST:VSANS:Globals:gIsLogScale
1015                        state = newState
1016                       
1017                        // on the front:                       
1018                        ModifyImage/W=VSANS_Data#det_panelsF ''#0 ctabAutoscale=0,lookup= LookupWave
1019                        ModifyImage/W=VSANS_Data#det_panelsF ''#1 ctabAutoscale=0,lookup= LookupWave
1020                        ModifyImage/W=VSANS_Data#det_panelsF ''#2 ctabAutoscale=0,lookup= LookupWave
1021                        ModifyImage/W=VSANS_Data#det_panelsF ''#3 ctabAutoscale=0,lookup= LookupWave
1022                        //on the middle:
1023//                      ModifyImage/W=VSANS_Data#det_panelsM ''#0 log=newState
1024//                      ModifyImage/W=VSANS_Data#det_panelsM ''#1 log=newState
1025//                      ModifyImage/W=VSANS_Data#det_panelsM ''#2 log=newState
1026//                      ModifyImage/W=VSANS_Data#det_panelsM ''#3 log=newState
1027                               
1028                        ModifyImage/W=VSANS_Data#det_panelsM ''#0 ctabAutoscale=0,lookup= LookupWave
1029                        ModifyImage/W=VSANS_Data#det_panelsM ''#1 ctabAutoscale=0,lookup= LookupWave
1030                        ModifyImage/W=VSANS_Data#det_panelsM ''#2 ctabAutoscale=0,lookup= LookupWave
1031                        ModifyImage/W=VSANS_Data#det_panelsM ''#3 ctabAutoscale=0,lookup= LookupWave
1032
1033
1034                        // on the back:
1035                        ModifyImage/W=VSANS_Data#det_panelsB ''#0 ctabAutoscale=0,lookup= LookupWave
1036
1037                        break
1038                case -1: // control being killed
1039                        break
1040        endswitch
1041
1042        return 0
1043End
1044
1045// TODO
1046// possibly function to "tag" files right here in the disaply with things
1047// like their intent, or other values that reduction will need, kind of like a "quick patch"
1048// with limited functionality (since full function would be a nightmare!)
1049Function V_TagFileButtonProc(ba) : ButtonControl
1050        STRUCT WMButtonAction &ba
1051
1052        switch( ba.eventCode )
1053                case 2: // mouse up
1054                        // click code here
1055                        DoAlert 0, "TagFileButtonProc(ba) unfinished - this may be used to 'tag' a file as scatter, trans, emp, bkg, etc."
1056                       
1057                               
1058                        break
1059                case -1: // control being killed
1060                        break
1061        endswitch
1062
1063        return 0
1064End
1065
1066// TODO
1067// -- fill in more functionality
1068// -- currently a straight concatentation of all data, no options
1069// -- maybe allow save of single panels?
1070// -- any other options?
1071Function V_SaveIQ_ButtonProc(ba) : ButtonControl
1072        STRUCT WMButtonAction &ba
1073
1074        switch( ba.eventCode )
1075                case 2: // mouse up
1076                        // click code here
1077
1078//                      V_SimpleSave1DData("root:Packages:NIST:VSANS:","","","")       
1079
1080// this is the same as clicking the I(q) button. Ensures that the current file has been averaged,
1081// and the data being saved is not "stale"
1082
1083                        V_PlotData_Panel()              //
1084                        Variable binType = V_GetBinningPopMode()
1085                        ControlInfo/W=V_1D_Data popup0
1086                        V_BinningModePopup("",binType,S_Value)          // does default circular binning and updates the graph
1087       
1088                        SVAR type = root:Packages:NIST:VSANS:Globals:gCurDispType               //what folder
1089
1090                        // look for the binning type
1091//                      Variable binType
1092//                      ControlInfo/W=V_1D_Data popup0
1093//                      binType = (V_flag == 0) ? 1 : V_flag            // if binType not defined, set binType == 1
1094
1095                        String saveName=""
1096                // write out the data set to a file
1097                        if(strlen(saveName)==0)
1098                                Execute "V_GetNameForSave()"
1099                                SVAR newName = root:saveName
1100                                saveName = newName
1101                        endif
1102                       
1103                        V_Write1DData_ITX("root:Packages:NIST:VSANS:",type,saveName,binType)
1104       
1105                        Print "Saved file: "    +       saveName + ".itx"       
1106                        break
1107                case -1: // control being killed
1108                        break
1109        endswitch
1110
1111        return 0
1112End
1113
1114//TODO
1115//
1116//link this to the beam center finding panel
1117//
1118Function V_BeamCtrButtonProc(ba) : ButtonControl
1119        STRUCT WMButtonAction &ba
1120
1121        switch( ba.eventCode )
1122                case 2: // mouse up
1123                        // click code here
1124                        DoAlert 0,"Beam Center panel is under construction..."
1125//                      V_FindBeamCenter()
1126                        break
1127                case -1: // control being killed
1128                        break
1129        endswitch
1130
1131        return 0
1132End
1133
1134//
1135//
1136// this "spreads" the display of panels to a nominal separation for easier viewing
1137//
1138Function V_SpreadPanelButtonProc(ba) : ButtonControl
1139        STRUCT WMButtonAction &ba
1140
1141        switch( ba.eventCode )
1142                case 2: // mouse up
1143                        // click code here
1144                        V_SpreadOutPanels()
1145                       
1146                        break
1147                case -1: // control being killed
1148                        break
1149        endswitch
1150
1151        return 0
1152End
1153
1154//
1155//
1156// this "restores" the display of panels to their actual position based on the apparent beam center
1157//
1158Function V_RestorePanelButtonProc(ba) : ButtonControl
1159        STRUCT WMButtonAction &ba
1160
1161        switch( ba.eventCode )
1162                case 2: // mouse up
1163                        // click code here
1164                        V_RestorePanels()
1165                               
1166                        break
1167                case -1: // control being killed
1168                        break
1169        endswitch
1170
1171        return 0
1172End
1173
1174// TODO
1175//
1176// link this slider to the "high" end of the color mapping for whatever is currently displayed
1177//
1178// -- see Buttons.ipf for the old SANS implementation
1179//
1180Function V_HiMapSliderProc(sa) : SliderControl
1181        STRUCT WMSliderAction &sa
1182
1183        switch( sa.eventCode )
1184                case -1: // control being killed
1185                        break
1186                default:
1187                        if( sa.eventCode & 1 ) // value set
1188                                Variable curval = sa.curval
1189                                ControlInfo tab0
1190                                V_FakeTabClick(V_Value)
1191                               
1192//                              ControlInfo slider_lo
1193//                              V_MakeImageLookupTables(10000,V_Value,curval)
1194                        endif
1195                        break
1196        endswitch
1197
1198        return 0
1199End
1200
1201// TODO
1202//
1203// link this slider to the "low" end of the color mapping for whatever is currently displayed
1204//
1205// -- see Buttons.ipf for the old SANS implementation
1206//
1207Function V_LowMapSliderProc(sa) : SliderControl
1208        STRUCT WMSliderAction &sa
1209
1210        switch( sa.eventCode )
1211                case -1: // control being killed
1212                        break
1213                default:
1214                        if( sa.eventCode & 1 ) // value set
1215                                Variable curval = sa.curval
1216                                ControlInfo tab0
1217                                V_FakeTabClick(V_Value)
1218
1219//                              ControlInfo slider_hi
1220//                              V_MakeImageLookupTables(10000,curval,V_Value)
1221                        endif
1222                        break
1223        endswitch
1224
1225        return 0
1226End
1227
1228
Note: See TracBrowser for help on using the repository browser.