#pragma rtGlobals=1 // Use modern global access method. #pragma version=5.0 #pragma IgorVersion=6.1 //************************** // Vers. 1.2 092101 // //proceures required to allow patching of raw SANS data headers //only a limited number of fields are allowble for changes, although the list could //be enhanced quite easily, at the expense of a larger, more complex panel //information for the Patch Panel is stored in the root:myGlobals:Patch subfolder // // writes changes directly to the raw data headers as requested // * note that if a data file is currently in a work folder, the (real) header on disk // will be updated, but the data in the folder will not reflect these changes, unless // the data folder is first cleared // //************************** //main entry procedure for displaying the Patch Panel // Proc PatchFiles() DoWindow/F Patch_Panel If(V_flag == 0) InitializePatchPanel() //draw panel Patch_Panel() Endif End //initialization of the panel, creating the necessary data folder and global //variables if necessary - simultaneously initialize the globals for the Trans //panel at theis time, to make sure they all exist // Proc InitializePatchPanel() //create the global variables needed to run the Patch Panel //all are kept in root:myGlobals:Patch If( ! (DataFolderExists("root:myGlobals:Patch")) ) //create the data folder and the globals for BOTH the Patch and Trans panels NewDataFolder/O root:myGlobals:Patch Endif CreatePatchGlobals() //re-create them every time (so text and radio buttons are correct) End //the data folder root:myGlobals:Patch must exist // Proc CreatePatchGlobals() //ok, create the globals String/G root:myGlobals:Patch:gPatchMatchStr = "*" PathInfo catPathName If(V_flag==1) String dum = S_path String/G root:myGlobals:Patch:gCatPathStr = dum else String/G root:myGlobals:Patch:gCatPathStr = "no path selected" endif String/G root:myGlobals:Patch:gPatchList = "none" String/G root:myGlobals:Patch:gPS1 = "no file selected" String/G root:myGlobals:Patch:gPS2 = "no file selected" String/G root:myGlobals:Patch:gPS3 = "no box selected" Variable/G root:myGlobals:Patch:gPV1 =0 Variable/G root:myGlobals:Patch:gPV2 = 0 Variable/G root:myGlobals:Patch:gPV3 = 0 Variable/G root:myGlobals:Patch:gPV4 = 0 Variable/G root:myGlobals:Patch:gPV5 = 0 Variable/G root:myGlobals:Patch:gPV6 = 0 Variable/G root:myGlobals:Patch:gPV7 = 0 Variable/G root:myGlobals:Patch:gPV8 = 0 Variable/G root:myGlobals:Patch:gPV9 = 0 Variable/G root:myGlobals:Patch:gPV10 = 0 Variable/G root:myGlobals:Patch:gPV11 = 0 Variable/G root:myGlobals:Patch:gPV12 = 0 Variable/G root:myGlobals:Patch:gPV13 = 0 Variable/G root:myGlobals:Patch:gPV14 = 0 Variable/G root:myGlobals:Patch:gPV15 = 0 Variable/G root:myGlobals:Patch:gPV16 = 0 Variable/G root:myGlobals:Patch:gPV17 = 0 Variable/G root:myGlobals:Patch:gPV18 = 0 Variable/G root:myGlobals:Patch:gPV19 = 0 Variable/G root:myGlobals:Patch:gTransCts = 0 Variable/G root:myGlobals:Patch:gRadioVal = 1 End //button action procedure to select the local path to the folder that //contains the SANS data //sets catPathName, updates the path display and the popup of files (in that folder) // Function PickPathButton(PathButton) : ButtonControl String PathButton //set the global string to the selected pathname PickPath() //set a local copy of the path for Patch PathInfo/S catPathName String dum = S_path if (V_flag == 0) //path does not exist - no folder selected String/G root:myGlobals:Patch:gCatPathStr = "no folder selected" else String/G root:myGlobals:Patch:gCatPathStr = dum endif //Update the pathStr variable box ControlUpdate/W=Patch_Panel $"PathDisplay" //then update the popup list // (don't update the list - not until someone enters a search critera) -- Jul09 // SetMatchStrProc("",0,"*","") //this is equivalent to finding everything, typical startup case End //returns a list of valid files (raw data, no version numbers, no averaged files) //that is semicolon delimited, and is suitable for display in a popup menu // Function/S xGetValidPatchPopupList() //make sure that path exists PathInfo catPathName String path = S_path if (V_flag == 0) Abort "folder path does not exist - use Pick Path button" Endif String newList = "" newList = GetRawDataFileList() //trim list to include only selected files SVAR match = root:myGlobals:Patch:gPatchMatchStr if(strlen(match) == 0) //if nothing is entered for a match string, return everything, rather than nothing match = "*" endif newlist = MyMatchList(match,newlist,";") newList = SortList(newList,";",0) Return(newList) End //returns a list of valid files (raw data, no version numbers, no averaged files) //that is semicolon delimited, and is suitable for display in a popup menu // // Uses Grep to look through the any text in the file, which includes the sample label // can be very slow across the network, as it re-pops the menu on a selection (since some folks don't hit // enter when inputing a filter string) // // - or - // a list or range of run numbers // - or - // a SDD (to within 0.001m) // - or - // * to get everything // // NVAR gRadioVal= root:myGlobals:Patch:gRadioVal // 1== Run # (comma range OK) // 2== Grep the text (SLOW) // 3== filter by SDD (within 0.001 m) Function/S GetValidPatchPopupList() //make sure that path exists PathInfo catPathName String path = S_path if (V_flag == 0) Abort "folder path does not exist - use Pick Path button" Endif String newList = "" newList = GetRawDataFileList() //trim list to include only selected files SVAR match = root:myGlobals:Patch:gPatchMatchStr if(strlen(match) == 0 || cmpstr(match,"*")==0) //if nothing or "*" entered for a match string, return everything, rather than nothing match = "*" // old way, with simply a wildcard newlist = MyMatchList(match,newlist,";") newList = SortList(newList,";",0) return(newList) endif //loop through all of the files as needed String list="",item="",fname,runList="",numStr="" Variable ii,num=ItemsInList(newList),val,sdd NVAR gRadioVal= root:myGlobals:Patch:gRadioVal // run number list if(gRadioVal == 1) // list = ParseRunNumberList(match) //slow, file access every time // list = ReplaceString(",", list, ";") // newList = list list = ExpandNumRanges(match) //now simply comma delimited num=ItemsInList(list,",") for(ii=0;ii 0) ShowHeaderButtonProc("SHButton") endif End //displays the header of the selected file (top in the popup) when the button is clicked //sort of a redundant button, since the procedure is automatically called (as if it were //clicked) when a new file is chosen from the popup // Function ShowHeaderButtonProc(SHButton) : ButtonControl String SHButton //displays (editable) header information about current file in popup control //putting the values in the SetVariable displays (resetting the global variables) //get the popup string String partialName, tempName Variable ok ControlInfo/W=Patch_Panel PatchPopup If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0) //null selection Abort "no file selected in popup menu" else //selection not null partialName = S_value //Print partialName Endif //get a valid file based on this partialName and catPathName tempName = FindValidFilename(partialName) //prepend path to tempName for read routine PathInfo catPathName tempName = S_path + tempName //make sure the file is really a RAW data file ok = CheckIfRawData(tempName) if (!ok) Abort "this file is not recognized as a RAW SANS data file" Endif //Print tempName ReadHeaderForPatch(tempName) ControlUpdate/A/W=Patch_Panel End //utility function that polls the checkboxes of the editable parameters //returns a wave with the yes/no checked state of the boxes // 0 = not checked (user does NOT want this header value updated) // 1 = checked (YES, change this value in the header) //num (input) is a simple check to make sure that the wave is set up properly //from the calling routine // Function GetCheckBoxesState(w,num) Wave w //on return, this wave contains the current state of the checkboxes Variable num if(num != 20) Abort "wrong number of checkboxes GetCheckBoxesState()" Endif ControlInfo checkPS1 w[0] = V_value Variable ii String baseStr="checkPV" ii=1 do ControlInfo $(baseStr + num2str(ii)) w[ii] = V_Value ii+=1 while(ii