Control Table Entry with Graph Cursor

I've done a lot of spectral simulations in my career, and one issue that seems to crop up frequently is selecting a line of interest on a graph consisting of 1000s of lines and figuring out what it is by viewing waves of frequency, intensity, quantum number, other label, etc. For occasional use, putting a cursor on the line and reading the point number is sufficient to go find the entries in the respective waves, but for rapid perusal, I came up with this trick. It "links" the top graph to the top table (one can imagine other simple ways to select the relevent graph and table...the underlying function uses window names) so that moving cursor A on the graph will bring the same point to the top line of the to the table. The assumption being whatever waves are displayed in the table match the spectral lines (or other type of data) on a point-by-point basis (labels, quantum numbers, radiative lifetimes, linewidths, etc)

You can also imagine changing how the line is selected: use a mouse click event with a hit test, for example. I went with the cursor instead because I figured I'd want a visual cue on the graph that I selected the point I thought I had, so even with a mouse click based selection I figured I'd end up programmatically moving a cursor to the selected point. Your mileage may vary.

Just guessing the supported Igor version. The limiting feature is probably the named window hook; I'm not sure when these were introduced.

Menu "Graph Linker"
    "Link Top Graph and Table", LinkGraphToTable(WinName(0,1), WinName(0,2))

Function LinkGraphToTable(graphname, tablename)
    string graphname, tablename
    SetWindow $graphname, hook(csr) = HookGraphToTable, userdata(TableLink)=tablename

Function HookGraphToTable(s)
    STRUCT WMWinHookStruct &s
    Variable hookResult = 0
    string graphname, tablename
        case 7:             // CursorMoved
            tablename = GetUserData(s.winName, "", "TableLink")
            if (WinType(tablename) == 2)
                Modifytable /W=$tablename topLeftCell=(pcsr(A),-1),selection=(pcsr(A),0,pcsr(A),-1,pcsr(A),-1)
                print tablename, "is missing, Delinking Graph"
                SetWindow $s.winName, hook(csr) = $""

    return hookResult       // 0 if nothing done, else 1

To see how it works, copy and paste following code on the command line:

make /d /n = 10000 testX, testY
testX = enoise(100)
testY = exp(gnoise(1))
display testY vs testX
ModifyGraph mode=1
make /t /n = 10000 labels
labels = num2char(mod(p,26) + 65)
edit testX, testY, labels

Select Graph Linker -> Link Top Graph and Table

and move the cursor around.




Igor Pro 8

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More