Changeset 1104


Ignore:
Timestamp:
May 31, 2018 10:12:09 AM (4 years ago)
Author:
srkline
Message:

updated mask drawing procedures to allow draw/erase of different shapes, rather than limited to single tubes.

added USANS_SlitSmearing.ipf back to the includes, removing the VSANS version which was duplicated.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf

    r1100 r1104  
    1717#include "GaussUtils_v40" 
    1818#include "NIST_XML_v40" 
     19#include "USANS_SlitSmearing_v40" 
     20 
    1921// 
    2022//#include "NCNR_Utils"         //needed to load linear fits, mostly VAX file name junk 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Attenuation.ipf

    r1073 r1104  
    261261End 
    262262 
    263 // TODO -- this may not correctly mimic the enumerated type of the file 
    264 //  but I need to fudge this somehow 
    265 // 
    266 // returns null string if the type cannot be deduced, calling procedure is responsible 
    267 //  for properly handling this error condition 
    268 // 
    269 Function/S V_DeduceMonochromatorType(fname) 
    270         String fname 
    271          
    272         String typeStr="" 
    273  
    274         if(cmpstr(V_getVelSelStatus(fname),"IN") == 0) 
    275                 typeStr = "velocity_selector" 
    276         endif 
    277          
    278         if(cmpstr(V_getWhiteBeamStatus(fname),"IN") == 0) 
    279                 typeStr = "white_beam" 
    280         endif 
    281          
    282         if(cmpstr(V_getCrystalStatus(fname),"IN") == 0) 
    283                 typeStr = "crystal" 
    284         endif    
    285          
    286         return(typeStr) 
    287 End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Initialize.ipf

    r1101 r1104  
    422422        Printf "Hook cleaned out RawVSANS, experiment saved\r" 
    423423 
    424         KillDataFolder/Z root:Packages:NIST:VSANS:RAW 
    425         KillDataFolder/Z root:Packages:NIST:VSANS:SAM 
    426         KillDataFolder/Z root:Packages:NIST:VSANS:EMP 
    427         KillDataFolder/Z root:Packages:NIST:VSANS:BGD 
    428         KillDataFolder/Z root:Packages:NIST:VSANS:COR 
    429         KillDataFolder/Z root:Packages:NIST:VSANS:DIV 
    430         KillDataFolder/Z root:Packages:NIST:VSANS:MSK 
    431         KillDataFolder/Z root:Packages:NIST:VSANS:ABS 
    432         KillDataFolder/Z root:Packages:NIST:VSANS:CAL 
    433         KillDataFolder/Z root:Packages:NIST:VSANS:STO 
    434         KillDataFolder/Z root:Packages:NIST:VSANS:SUB 
    435         KillDataFolder/Z root:Packages:NIST:VSANS:DRK 
    436         KillDataFolder/Z root:Packages:NIST:VSANS:ADJ 
     424 
     425// these KillDF are a bad idea - it wipes out all of the current work 
     426// whenever a save is done - which is the opposite of what you want 
     427// to happen when you save! 
     428 
     429//      KillDataFolder/Z root:Packages:NIST:VSANS:RAW 
     430//      KillDataFolder/Z root:Packages:NIST:VSANS:SAM 
     431//      KillDataFolder/Z root:Packages:NIST:VSANS:EMP 
     432//      KillDataFolder/Z root:Packages:NIST:VSANS:BGD 
     433//      KillDataFolder/Z root:Packages:NIST:VSANS:COR 
     434//      KillDataFolder/Z root:Packages:NIST:VSANS:DIV 
     435//      KillDataFolder/Z root:Packages:NIST:VSANS:MSK 
     436//      KillDataFolder/Z root:Packages:NIST:VSANS:ABS 
     437//      KillDataFolder/Z root:Packages:NIST:VSANS:CAL 
     438//      KillDataFolder/Z root:Packages:NIST:VSANS:STO 
     439//      KillDataFolder/Z root:Packages:NIST:VSANS:SUB 
     440//      KillDataFolder/Z root:Packages:NIST:VSANS:DRK 
     441//      KillDataFolder/Z root:Packages:NIST:VSANS:ADJ 
    437442 
    438443// re-create anthing that was killed 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MaskUtils.ipf

    r1093 r1104  
    1010// 
    1111// 
    12 //  this is (at first) to be a very simple editor to generate masks row/column wise, not drawing 
    13 //  masks with arbitrary shape.  
    14 // 
    15 // 
    1612// 
    1713// 
     
    2218 
    2319// TODO  
    24 // -- when mask is loaded, need to be sure to clean up the "extra" waves that may be present 
    25 // 
    26 // -- the overlay and the currentTube waves since these are not overwritten or killed when new mask  
     20// x- when mask is loaded, need to be sure to clean up the "extra" waves that may be present 
     21// 
     22// x- the overlay and the currentTube waves since these are not overwritten or killed when new mask  
    2723//  data is read in from HDF. need to manually? check for these and delete then, or the data and 
    2824//  mask overlay will be out of sync. 
     
    6864// x- draw a mask 
    6965// x- save a mask (all panels) 
    70 // -- move everything into it's own folder, rather than root: 
     66// x- move everything into it's own folder, rather than root: 
    7167// -- be able to save the mask name to the RAW data file 
    7268// -- be able to read a mask based on what name is in the data file 
     
    117113// TODO 
    118114//  need buttons for: 
    119 //              -- quit (to exit gracefully) 
    120 //    -- help (button is there, fill in the content) 
    121 // 
    122 Proc V_MaskEditorPanel() : Panel 
     115//              x- quit (to exit gracefully) (no, just close the window is fine) 
     116//    x- help (button is there, fill in the content) 
     117// 
     118Proc V_MaskEditorPanel() 
    123119        PauseUpdate; Silent 1           // building window... 
    124120 
    125         NewPanel /W=(662,418,1300,960)/N=MaskEditPanel   /K=1 
    126 //      ShowTools/A 
    127          
    128         PopupMenu popup_0,pos={20,50},size={109,20},proc=V_SetMaskPanelPopMenuProc,title="Detector Panel" 
     121        Display /W=(662,418,1300,960)/N=MaskEditPanel    /K=1 
     122 
     123        ShowTools rect 
     124        ControlBar 100 
     125                 
     126        PopupMenu popup_0,pos={18,40},size={109,20},proc=V_SetMaskPanelPopMenuProc,title="Detector Panel" 
    129127        PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;MR;ML;MT;MB;B;\"" 
    130         PopupMenu popup_2,pos={20,20},size={109,20},title="Data Source"//,proc=SetFldrPopMenuProc 
     128        PopupMenu popup_2,pos={18,10},size={109,20},title="Data Source"//,proc=SetFldrPopMenuProc 
    131129        PopupMenu popup_2,mode=1,popvalue="RAW",value= #"\"RAW;SAM;VCALC;\"" 
    132130 
    133         SetVariable setvar0,pos={257.00,20.00},size={150.00,14.00},title="tube number" 
     131        SetVariable setvar0,pos={226,32},size={112,23},title="tube number" 
    134132        SetVariable setvar0,limits={0,127,1},value=root:Packages:NIST:VSANS:Globals:Mask:gMaskTube 
    135         Button button_0,pos={257,46.00},size={50.00,20.00},proc=V_AddToMaskButtonProc,title="Add" 
    136         Button button_1,pos={319.00,46.00},size={50.00,20.00},proc=V_RemoveFromMaskButtonProc,title="Del" 
    137         Button button_2,pos={409.00,46.00},size={90.00,20.00},proc=V_ToggleMaskButtonProc,title="Toggle" 
    138         Button button_3,pos={509.00,46.00},size={80.00,20.00},proc=V_SaveMaskButtonProc,title="Save" 
    139         Button button_4,pos={603.00,10.00},size={20.00,20.00},proc=V_DrawMaskHelpButtonProc,title="?" 
    140         CheckBox check_0,pos={190.00,23.00},size={37.00,15.00},proc=V_DrawMaskRadioCheckProc,title="Row" 
     133        Button button_0,pos={226,58},size={50.00,20.00},proc=V_AddToMaskButtonProc,title="Add" 
     134        Button button_1,pos={288,58},size={50.00,20.00},proc=V_RemoveFromMaskButtonProc,title="Del" 
     135        Button button_2,pos={496,41},size={90.00,20.00},proc=V_ToggleMaskButtonProc,title="Toggle" 
     136        Button button_3,pos={506,66},size={80.00,20.00},proc=V_SaveMaskButtonProc,title="Save" 
     137        CheckBox check_0,pos={174,35},size={37.00,15.00},proc=V_DrawMaskRadioCheckProc,title="Row" 
    141138        CheckBox check_0,value= 0,mode=1 
    142         CheckBox check_1,pos={190.00,46.00},size={32.00,15.00},proc=V_DrawMaskRadioCheckProc,title="Col" 
     139        CheckBox check_1,pos={174,58},size={32.00,15.00},proc=V_DrawMaskRadioCheckProc,title="Col" 
    143140        CheckBox check_1,value= 1,mode=1 
     141 
     142        Button button_5,pos={18,70.00},size={70.00,20.00},proc=V_MaskToolsButton,title="Tools" 
     143        Button button_6,pos={380,33},size={90.00,20.00},proc=V_AddShapeToMaskButtonProc,title="Add Shape" 
     144        Button button_7,pos={380,58},size={90.00,20.00},proc=V_AddShapeToMaskButtonProc,title="Del Shape" 
     145        Button button_8,pos={556.00,14.00},size={30.00,20.00},proc=V_DrawMaskHelpButtonProc,title="?" 
     146 
     147        GroupBox group0,pos={163.00,5.00},size={188.00,90.00},title="Mask Tubes" 
     148        GroupBox group1,pos={365.00,5.00},size={122.00,90.00},title="Mask Shapes" 
    144149 
    145150        SetWindow MaskEditPanel, hook(MyHook)=V_MaskWindowHook 
     
    152157        V_OverlayMask("FL",1) 
    153158 
     159        SetDrawLayer/W=MaskEditPanel ProgFront 
     160        SetDrawEnv/W=MaskEditPanel xcoord= bottom,ycoord= left,save     //be sure to use axis coordinate mode 
    154161EndMacro 
    155162 
     
    304311End 
    305312 
    306  
     313// toggles the view of the mask, either show the mask, or hide it 
     314// 
    307315Function V_ToggleMaskButtonProc(ba) : ButtonControl 
    308316        STRUCT WMButtonAction &ba 
     
    317325                        wave/Z overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":overlay") 
    318326                         
    319                         CheckDisplayed/W=MaskEditPanel#DetData overlay 
     327                        CheckDisplayed/W=MaskEditPanel overlay 
    320328                        Variable state = !(V_flag)              //if V_flag == 0, then set to 1 (and vice versa) 
    321329                        V_OverlayMask(str,state) 
     
    329337End 
    330338 
    331  
     339// adds a row (or column) to the mask 
     340// 
    332341Function V_AddToMaskButtonProc(ba) : ButtonControl 
    333342        STRUCT WMButtonAction &ba 
     
    363372End 
    364373 
     374// 
     375//adds or erases the mask, based on which button was clicked 
     376// (only checks for "add shape", otherwise erases mask) 
     377// 
     378Function V_AddShapeToMaskButtonProc(ba) : ButtonControl 
     379        STRUCT WMButtonAction &ba 
     380 
     381        switch( ba.eventCode ) 
     382                case 2: // mouse up 
     383                        // click code here 
     384                        ControlInfo popup_0 
     385                        String str=S_Value 
     386                         
     387                        wave/Z data = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":data") 
     388 
     389                        SetDrawLayer/W=MaskEditPanel ProgFront 
     390                        SetDrawEnv/W=MaskEditPanel xcoord= bottom,ycoord= left,save     //be sure to use axis coordinate mode 
     391 
     392                        ImageGenerateROIMask/W=MaskEditPanel curDispPanel               //M_ROIMask is in the root: folder 
     393                         
     394                        WAVE M_ROIMask=M_ROIMask 
     395                        if(cmpstr("button_6",ba.ctrlName)==0) 
     396                                data = (data || M_ROIMask)              // 0=0, 1=1             == "drawing" more mask points                    
     397                        else 
     398                                data = (M_ROIMask[p][q] == 1 && data[p][q] == 1) ? 0 : data[p][q]               // if the drawn shape = 1, set the mask to 0 (erase) 
     399                        endif 
     400                         
     401                        V_OverlayMask(str,1) 
     402                         
     403                        SetDrawLayer/K ProgFront 
     404                        SetDrawLayer/W=MaskEditPanel ProgFront 
     405                        SetDrawEnv/W=MaskEditPanel xcoord= bottom,ycoord= left,save     //be sure to use axis coordinate mode 
     406                        break 
     407                case -1: // control being killed 
     408                        break 
     409        endswitch 
     410 
     411        return 0 
     412End 
     413 
     414// show the tools (they are there by default) 
     415// 
     416Function V_MaskToolsButton(ba) : ButtonControl 
     417        STRUCT WMButtonAction &ba 
     418 
     419        switch( ba.eventCode ) 
     420                case 2: // mouse up 
     421                        // click code here 
     422                         
     423                        ShowTools rect 
     424                         
     425                        SetDrawLayer/W=MaskEditPanel ProgFront 
     426                        SetDrawEnv/W=MaskEditPanel xcoord= bottom,ycoord= left,save     //be sure to use axis coordinate mode 
     427                        SetDrawEnv/W=MaskEditPanel fillPat=1     
     428                         
     429                        break 
     430                case -1: // control being killed 
     431                        break 
     432        endswitch 
     433 
     434        return 0 
     435End 
     436 
     437// un-mask a row or column 
     438// 
    365439Function V_RemoveFromMaskButtonProc(ba) : ButtonControl 
    366440        STRUCT WMButtonAction &ba 
     
    409483                        // remove the old image (it may not be the right shape) 
    410484                        // -- but make sure it exists first... 
    411                         String childList = ChildWindowList("MaskEditPanel") 
    412                         Variable flag 
    413                          
    414                         flag = WhichListItem("DetData", ChildList)              //returns -1 if not in list, 0+ otherwise 
    415                         if(flag != -1) 
    416                                 KillWindow MaskEditPanel#DetData 
    417                         endif 
    418                          
    419                         flag = WhichListItem("ModelData", ChildList) 
    420                         if(flag != -1) 
    421                                 KillWindow MaskEditPanel#ModelData 
    422                         endif 
     485 
     486                        String list = ImageNameList("", ";" ) 
     487                        Variable num=ItemsInList(list) 
     488                        Variable ii 
     489                        for(ii=0;ii<num;ii+=1) 
     490//                              Wave w = ImageNameToWaveRef("", StringFromList(ii, list,";")) 
     491//                              CheckDisplayed/W=MaskEditPanel w 
     492                                 
     493                                RemoveImage/W=MaskEditPanel $(StringFromList(ii, list,";")) 
     494                        endfor 
     495 
     496 
    423497         
    424498                        // draw the correct images 
     
    438512                        V_DrawMaskRadioCheckProc(cba)           //call the radio button action proc      
    439513                         
    440                         //overlay the mask 
     514                        //overlay the mask (removes the old mask first) 
    441515                        V_OverlayMask(popStr,1) 
     516 
     517                        SetDrawLayer/K ProgFront 
     518                        SetDrawLayer/W=MaskEditPanel ProgFront 
     519                        SetDrawEnv/W=MaskEditPanel xcoord= bottom,ycoord= left,save     //be sure to use axis coordinate mode 
    442520 
    443521                        break 
     
    457535// -- need to adjust the size of the image subwindows  
    458536// 
    459 // -- need to do something for panel "B". currently ignored 
     537// x- need to do something for panel "B". currently ignored 
    460538// 
    461539// 
     
    588666 
    589667        //draw the detector panel 
    590         Display/W=(left,top,right,bottom)/HOST=#  
     668//      Display/W=(left,top,right,bottom) 
    591669        AppendImage curDispPanel 
    592670        ModifyImage curDispPanel ctab= {*,*,ColdWarm,0} 
     
    595673        Label left "Y pixels" 
    596674        Label bottom "X pixels"  
    597         RenameWindow #,DetData 
    598         SetActiveSubwindow ##    
     675 
    599676         
    600677        DoUpdate 
     
    659736                        endif                    
    660737                                 
    661                         CheckDisplayed/W=MaskEditPanel#DetData overlay 
     738                        CheckDisplayed/W=MaskEditPanel overlay 
    662739                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
    663                                 AppendImage/W=MaskEditPanel#DetData overlay 
    664                                 AppendImage/W=MaskEditPanel#DetData currentTube 
     740                                AppendImage/W=MaskEditPanel overlay 
     741                                AppendImage/W=MaskEditPanel currentTube 
    665742//                              ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0.9,1,BlueRedGreen,0}        ,minRGB=NaN,maxRGB=0 
    666                                 ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,40000) 
    667                                 ModifyImage/W=MaskEditPanel#DetData currentTube ctab= {0.9,1,CyanMagenta,0}     ,minRGB=NaN,maxRGB=0 
     743                                ModifyImage/W=MaskEditPanel overlay ctab= {0.9,0.95,BlueRedGreen,0}     ,minRGB=NaN,maxRGB=(0,65000,0,40000) 
     744                                ModifyImage/W=MaskEditPanel currentTube ctab= {0.9,1,CyanMagenta,0}     ,minRGB=NaN,maxRGB=0 
    668745                //              ModifyImage/W=MaskEditPanel#DetData overlay ctab= {0,*,BlueRedGreen,0}   
    669746                        endif 
     
    674751                        wave currentTube = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+str+":currentTube") 
    675752 
    676                         CheckDisplayed/W=MaskEditPanel#DetData overlay 
     753                        CheckDisplayed/W=MaskEditPanel overlay 
    677754//                      Print "V_flag = ",V_flag 
    678755         
    679756                        If(V_Flag == 1)         //overlay is present 
    680                                 RemoveImage/W=MaskEditPanel#DetData overlay 
    681                                 RemoveImage/W=MaskEditPanel#DetData currentTube 
     757                                RemoveImage/W=MaskEditPanel overlay 
     758                                RemoveImage/W=MaskEditPanel currentTube 
    682759                        endif 
    683760                endif 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Utilities_Comparisons.ipf

    r1102 r1104  
    397397 
    398398 
    399  
     399// TODO -- this may not correctly mimic the enumerated type of the file 
     400//  but I need to fudge this somehow 
     401// 
     402// returns null string if the type cannot be deduced, calling procedure is responsible 
     403//  for properly handling this error condition 
     404// 
     405Function/S V_DeduceMonochromatorType(fname) 
     406        String fname 
     407         
     408        String typeStr="" 
     409 
     410        if(cmpstr(V_getVelSelStatus(fname),"IN") == 0) 
     411                typeStr = "velocity_selector" 
     412        endif 
     413         
     414        if(cmpstr(V_getWhiteBeamStatus(fname),"IN") == 0) 
     415                typeStr = "white_beam" 
     416        endif 
     417         
     418        if(cmpstr(V_getCrystalStatus(fname),"IN") == 0) 
     419                typeStr = "crystal" 
     420        endif    
     421         
     422        return(typeStr) 
     423End 
     424 
     425 
Note: See TracChangeset for help on using the changeset viewer.