#pragma rtGlobals=1 // Use modern global access method. Menu "Analysis" "LogCursorInfo" End Function LogCursorInfo() //Panel which sets up waves to which it may log various cursor measurements //Puts a button on top graph to do a logging event //Delta means cursor B value - cursor A value unless Absolute value is checked //The X, Y, and Point logs, the wave name and wave used for stats are the cursor A value unless the "Record B Cursor" value is checked //Need to test for existing waves and windows Variable Temp1, Temp2, Left, Bottom Variable /G Absolut, Right, CursA, CursB String TempStr String/G LogXName="", LogXDName="", LogYName="", LogYDName="", LogPName="", LogPDName="", LogWaveName="", LogAvgName="", LogSDName="", LogSEMName="", LogGraph LogGraph=WinName(0,1) ShowInfo /W=$LogGraph if (cmpstr("",CsrInfo(A))==0) Cursor /P A $WaveName("", 0,1) 0 endif if (cmpstr("",CsrInfo(B))==0) Cursor /P B $WaveName("", 0,1) 0 endif TempStr=StringByKey("SCREEN1", IgorInfo(0)) Temp1=StrSearch(TempStr,"RECT",0) Temp2=StrSearch(TempStr,",",Temp1) //find first comma (after left) Left=Str2Num(TempStr[Temp1+5,Temp2-1]) Temp1=StrSearch(TempStr,",",Temp2+1) //second comma Temp1=StrSearch(TempStr,",",Temp1+1) //third comma (before bottom) Bottom=Str2Num(TempStr[Temp1+1,strlen(TempStr)-1]) NewPanel /W=(Left+10, Bottom-245, Left+450, Bottom-100) as "Log Cursor Values" Dowindow/C WriteIt //Top Row: Cursors SetVariable CurA size={95,20}, pos={20,5}, disable=0, proc=MoveCursor, value=CursA, title="Cursor A", win=WriteIt SetVariable CurB size={95,20}, pos={120,5}, disable=0, proc=MoveCursor, value=CursB, title="Cursor B", win=WriteIt Button SWAP size={50,18}, pos={230, 4}, proc=SwapCursor, title="Swap", Win=WriteIt //Erase Button OOPS size={75,18}, pos={350, 4}, proc=LogIt, disable=1, title="Erase Last", Win=WriteIt //1st col: Left/Right CheckBox RIGH size={100,20}, pos={35,25}, disable=0, noproc, variable=Right, title="Use Cursor B", win=WriteIt //X PopupMenu XWave size={130,20}, pos={5,45}, bodywidth=100, disable=0, proc=WaveHandler, value=("None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:0")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:0")), mode=1, title="X", win=WriteIt //Y PopupMenu YWave size={130,20}, pos={5,70}, bodywidth=100, disable=0, proc=WaveHandler, value=("None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:0")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:0")), mode=1, title="Y", win=WriteIt //Point PopupMenu PWave size={130,20}, pos={5,95}, bodywidth=100, disable=0, proc=WaveHandler, value=("None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:0")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:0")), mode=1, title="Point", win=WriteIt //WaveName PopupMenu WaveWave size={150,20}, pos={15,120}, bodywidth=100, disable=0, proc=WaveHandler, value=("None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:1")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:1")), mode=1, title="Wave Name", win=WriteIt //2nd col: Delta CheckBox ABSL size={100,20}, pos={200,25}, disable=0, noproc, variable=Absolut, title="Absolute Value", win=WriteIt //DeltaX PopupMenu DXWave size={160,20}, pos={140,45}, bodywidth=100, disable=0, proc=WaveHandler, value=("None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:0")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:0")), mode=1, title="DeltaX", win=WriteIt //DeltaY PopupMenu DYWave size={160,20}, pos={140,70}, bodywidth=100, disable=0, proc=WaveHandler, value=("None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:0")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:0")), mode=1, title="DeltaY", win=WriteIt //DeltaPoint PopupMenu DPWave size={160,20}, pos={140,95}, bodywidth=100, disable=0, proc=WaveHandler, value=("None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:0")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:0")), mode=1, title="Delta Point", win=WriteIt //3rd col: Stats //Avg PopupMenu AvgWave size={130,20}, pos={305,45}, bodywidth=100, disable=0, proc=WaveHandler, value=("None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:0")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:0")), mode=1, title="Avg.", win=WriteIt //SD PopupMenu SDWave size={130,20}, pos={305,70}, bodywidth=100, disable=0, proc=WaveHandler, value=("None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:0")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:0")), mode=1, title="SD", win=WriteIt //SEM PopupMenu SEMWave size={130,20}, pos={305,95}, bodywidth=100, disable=0, proc=WaveHandler, value=("None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:0")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:0")), mode=1, title="SEM", win=WriteIt //Other windows: Button LogItNow size={33,20}, pos={5,5}, proc=LogIt, title="Log", Win=$LogGraph Edit as "Logged Values" DoWindow /C LogTable END Function CursorMovedHook(info) String info // info looks like this: GRAPH:graphName;CURSOR:;TNAME:traceName;MODIFIERS:modifierNum; ISFREE:freeNum;POINT:xPointNumber;[YPOINT:yPointNumber;] //Update cursor info on log panel if appropriate SVAR LogGraph if (SVAR_Exists(LogGraph)) NVAR CursA, CursB if (cmpstr(LogGraph, stringbykey("GRAPH",info))==0) if (cmpstr(stringbykey("ISFREE",info),"0")==0) if (cmpstr(stringbykey("CURSOR",info),"A")==0) CursA=pcsr(A) else CursB=pcsr(B) endif endif endif endif END Function SwapCursor(ctrlname) string ctrlname //Which button called it //Neither trace instance nor data folder aware SVAR LogGraph DoWindow /F $LogGraph //Might be annoying but easy way to move cursor on desired graph NVAR CursA, CursB Variable Temp=CursA Cursor /P A $CsrWave(A) CursB Cursor /P B $CsrWave(B) Temp End Function MoveCursor(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum // value of variable as number String varStr // value of variable as string String varName // name of variable //Neither trace instance nor data folder aware SVAR LogGraph DoWindow /F $LogGraph //Might be annoying but easy way to move cursor on desired graph if (cmpstr(ctrlName,"CurA")==0) Cursor /P A $CsrWave(A) varNum else Cursor /P B $CsrWave(B) varNum endif END Function WaveHandler (ctrlName,popNum,popStr) : PopupMenuControl String ctrlName //which popup called function Variable popNum // which item is currently selected (1-based) String popStr // contents of current popup item as string //Handles requests from popup to log to a particular wave, including making the wave if needed, adding and removing from LogTable SVAR LogXName, LogXDName, LogYName, LogYDName, LogPName, LogPDName, LogWaveName, LogAvgName, LogSDName, LogSEMName Variable ItemToPop String TempStr if (popNum==2) //New Wave popStr="Log" Prompt popStr, "New Wave Name" DoPrompt "Name of logging wave", popStr if (cmpstr(ctrlName, "WaveWave")==0) Make /T/N=0 $popStr TempStr="None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:1")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:1") else Make /N=0 $popStr TempStr="None;New;"+WAVEList ("Log*",";", "MAXCOLS:1,TEXT:0")+WAVEList ("!Log*",";", "MAXCOLS:1,TEXT:0") endif AppendtoTable /W=LogTable $popStr ModifyTable /W=LogTable width($popStr)=45, sigDigits($popStr)=3 ItemToPop=WhichListItem(popStr,TempStr)+1 elseif (popNum==1) //No Wave popStr="" ItemToPop=1 else //Existing Wave //First check that wave isn't already being used to log another parameter TempStr=LogXName+";"+ LogXDName+";"+ LogYName+";"+ LogYDName+";"+ LogPName+";"+ LogPDName+";"+ LogWaveName+";"+LogAvgName+";"+LogSDName+";"+LogSEMName if (FindListItem(popStr,TempStr)>-1) ctrlName="" //Prevents any updating DoAlert 0, "That wave is already being used" //Ideally one would restore the previous pop value, but not easily had here else AppendtoTable /W=LogTable $popStr ModifyTable /W=LogTable width($popStr)=45, sigDigits($popStr)=3 endif ItemToPop=popNum endif //Update popups and table strswitch (ctrlName) case "XWave": if (cmpstr(LogXName,"")!=0) //if there was an old logging wave, remove it from table RemoveFromTable/W=LogTable $LogXName endif LogXName=popStr PopupMenu XWave mode=ItemToPop break case "DXWave": if (cmpstr(LogXDName,"")!=0) RemoveFromTable/W=LogTable $LogXDName endif LogXDName=popStr PopupMenu DXWave mode=ItemToPop break case "YWave": if (cmpstr(LogYName,"")!=0) RemoveFromTable/W=LogTable $LogYName endif LogYName=popStr PopupMenu YWave mode=ItemToPop break case "DYWave": if (cmpstr(LogYDName,"")!=0) RemoveFromTable/W=LogTable $LogYDName endif LogYDName=popStr PopupMenu DYWave mode=ItemToPop break case "PWave": if (cmpstr(LogPName,"")!=0) RemoveFromTable/W=LogTable $LogPName endif LogPName=popStr PopupMenu PWave mode=ItemToPop break case "DPWave": if (cmpstr(LogPDName,"")!=0) RemoveFromTable/W=LogTable $LogPDName endif LogPDName=popStr PopupMenu DPWave mode=ItemToPop break case "WaveWave": if (cmpstr(LogWaveName,"")!=0) RemoveFromTable/W=LogTable $LogWaveName endif LogWaveName=popStr PopupMenu WaveWave mode=ItemToPop break case "AvgWave": if (cmpstr(LogAvgName,"")!=0) RemoveFromTable/W=LogTable $LogAvgName endif LogAvgName=popStr PopupMenu AvgWave mode=ItemToPop break case "SDWave": if (cmpstr(LogSDName,"")!=0) RemoveFromTable/W=LogTable $LogSDName endif LogSDName=popStr PopupMenu SDWave mode=ItemToPop break case "SEMWave": if (cmpstr(LogSEMName,"")!=0) RemoveFromTable/W=LogTable $LogSEMName endif LogSEMName=popStr PopupMenu SEMWave mode=ItemToPop break endswitch Button OOPS disable=1, Win=WriteIt End Function LogIt(ctrlname) string ctrlname //Which button called it //Log the data from the current cursor positions to the appropriate waves Variable WritingPoint NVAR Absolut, Right SVAR LogXName, LogXDName, LogYName, LogYDName, LogPName, LogPDName, LogWaveName, LogAvgName, LogSDName, LogSEMName //First we must make all the waves as long as the longest so that all logged data goes in the same row //Also handles the Erase Last button if (cmpstr(LogXName,"")!=0) WAVE LogX=$LogXName WritingPoint=numpnts(LogX) endif if (cmpstr(LogXDName,"")!=0) WAVE LogXD=$LogXDName WritingPoint=max(WritingPoint,numpnts(LogXD)) endif if (cmpstr(LogYName,"")!=0) WAVE LogY=$LogYName WritingPoint=max(WritingPoint,numpnts(LogY)) endif if (cmpstr(LogYDName,"")!=0) WAVE LogYD=$LogYDName WritingPoint=max(WritingPoint,numpnts(LogYD)) endif if (cmpstr(LogPName,"")!=0) WAVE LogP=$LogPName WritingPoint=max(WritingPoint,numpnts(LogP)) endif if (cmpstr(LogPDName,"")!=0) WAVE LogPD=$LogPDName WritingPoint=max(WritingPoint,numpnts(LogPD)) endif if (cmpstr(LogWaveName,"")!=0) WAVE/T LogWave=$LogWaveName WritingPoint=max(WritingPoint,numpnts(LogWave)) endif if (cmpstr(LogAvgName,"")!=0) WAVE LogAvg=$LogAvgName WritingPoint=max(WritingPoint,numpnts(LogAvg)) endif if (cmpstr(LogSDName,"")!=0) WAVE LogSD=$LogSDName WritingPoint=max(WritingPoint,numpnts(LogSD)) endif if (cmpstr(LogSEMName,"")!=0) WAVE LogSEM=$LogSEMName WritingPoint=max(WritingPoint,numpnts(LogSEM)) endif if (cmpstr(ctrlname,"LogItNow")==0) //Called from Log (vs. Erase) if ((cmpstr("",CsrInfo(A))!=0)&&(cmpstr("",CsrInfo(A))!=0)) //Make sure both cursors are on graph if (cmpstr(LogXName,"")!=0) ReDimAndFill(LogX, WritingPoint+1) if (Right) LogX[WritingPoint]=hcsr(B) else LogX[WritingPoint]=hcsr(A) endif endif if (cmpstr(LogXDName,"")!=0) ReDimAndFill(LogXD, WritingPoint+1) LogXD[WritingPoint]=(hcsr(B)-hcsr(A)) if (absolut) LogXD[WritingPoint]=abs(LogXD[WritingPoint]) endif endif if (cmpstr(LogYName,"")!=0) ReDimAndFill(LogY, WritingPoint+1) if (Right) LogY[WritingPoint]=vcsr(B) else LogY[WritingPoint]=vcsr(A) endif endif if (cmpstr(LogYDName,"")!=0) ReDimAndFill(LogYD, WritingPoint+1) LogYD[WritingPoint]=(vcsr(B)-vcsr(A)) if (absolut) LogYD[WritingPoint]=abs(LogYD[WritingPoint]) endif endif if (cmpstr(LogPName,"")!=0) ReDimAndFill(LogP, WritingPoint+1) if (Right) LogP[WritingPoint]=pcsr(B) else LogP[WritingPoint]=pcsr(A) endif endif if (cmpstr(LogPDName,"")!=0) ReDimAndFill(LogPD, WritingPoint+1) LogPD[WritingPoint]=(pcsr(B)-pcsr(A)) if (absolut) LogPD[WritingPoint]=abs(LogPD[WritingPoint]) endif endif if (cmpstr(LogWaveName,"")!=0) Variable OldPnts=numpnts(LogWave) redimension /N=(WritingPoint+1) LogWave if ((WritingPoint+1)>OldPnts) LogWave[OldPnts,WritingPoint]="" endif if (Right) LogWave[WritingPoint]=CsrWave(B) else LogWave[WritingPoint]=CsrWave(A) endif endif if (Right) WaveStats /Q/R=[pcsr(A),pcsr(B)] $CsrWave(B) else WaveStats /Q/R=[pcsr(A),pcsr(B)] $CsrWave(A) endif if (cmpstr(LogAvgName,"")!=0) ReDimAndFill(LogAvg, WritingPoint+1) LogAvg[WritingPoint]=V_avg endif if (cmpstr(LogSDName,"")!=0) ReDimAndFill(LogSD, WritingPoint+1) LogSD[WritingPoint]=V_sdev endif if (cmpstr(LogSEMName,"")!=0) ReDimAndFill(LogSEM, WritingPoint+1) LogSEM[WritingPoint]=V_sdev/sqrt(V_npnts) endif Button OOPS disable=0, Win=WriteIt endif else //Erase one point if (cmpstr(LogXName,"")!=0) redimension /N=(WritingPoint-1) LogX endif if (cmpstr(LogXDName,"")!=0) redimension /N=(WritingPoint-1) LogXD endif if (cmpstr(LogYName,"")!=0) redimension /N=(WritingPoint-1) LogY endif if (cmpstr(LogYDName,"")!=0) redimension /N=(WritingPoint-1) LogYD endif if (cmpstr(LogPName,"")!=0) redimension /N=(WritingPoint-1) LogP endif if (cmpstr(LogPDName,"")!=0) redimension /N=(WritingPoint-1) LogPD endif if (cmpstr(LogWaveName,"")!=0) redimension /N=(WritingPoint-1) LogWave endif if (cmpstr(LogAvgName,"")!=0) redimension /N=(WritingPoint-1) LogAvg endif if (cmpstr(LogSDName,"")!=0) redimension /N=(WritingPoint-1) LogSD endif if (cmpstr(LogSEMName,"")!=0) redimension /N=(WritingPoint-1) LogSEM endif Button OOPS disable=1, Win=WriteIt endif END Function ReDimAndFill(WaveToDo, NewDim) Wave WaveToDo Variable NewDim Variable OldPnts=numpnts(WaveToDo) redimension /N=(NewDim) WaveToDo if (NewDim>OldPnts) WaveToDo[OldPnts,NewDim-1]=NaN endif End