LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Cursor coordinates ?

Say you have one plot (a waveform) on a graph.
There's also a cursor, set to "Snap to point".

When a user clicks on the graph, the cursor is placed on the X coordinate of the click and on the
Y coordinate of the plot (not the click). So far so good; the problem is that the coordinates
returned by GetGraphCursor are the coordinates of the click.
How can I get the coordinates where the circle of the cursor actually is (snaped on the plot) ?
--
Guillaume Dargaud
http://www.gdargaud.net/
"Beware of bugs in the above code; I have only proved it correct, not tried it." - Donald E.
Knuth
0 Kudos
Message 1 of 4
(3,109 Views)
It looks like it depends on when you call GetGraphCursor. If you call it on EVENT_LEFTCLICK, you get the clicked-on coordinate. If you call it on EVENT_COMMIT, you get the snapped-to coordinate.
I just tried the graphcursors.prj sample project that shipped with CVI using CVI 6.0 and 7.0 (evaluation). In both cases, GetGraphCursor returned the X and Y coordinates to which the cursor snapped, not where I clicked.
In the sample, the Marker Position is for cursor 2, the short cross marker (set to snap to grid). I ran the project, clicked on Plot Data, moved cursor 3 (one of the long-cross markers) to a marked point on the Y axis, then moved cursor 2 along the horizontal line of cursor 3 and clicked at various points. That way I could easily tell that the Y coordina
te was the snapped-to coordinate, not the clicked coordinate.
If you change the callback for the graph to use EVENT_LEFTCLICK, you get the clicked-on coordinate.
Message 2 of 4
(3,109 Views)
The reason for this is most likely the CALLBACK order. The very first callback to execute is your control callback, so when you check the EVENT_LEFTCLICK the graph has not processed the callback and returns the wrong coordinates. You can wait for the COMMIT event or install a callback after your callback in the left click. Here is a document that explains this a bit furhter.

Just my 2 cents.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 3 of 4
(3,109 Views)
> The reason for this is most likely the CALLBACK order. The very first
> callback to execute is your control callback, so when you check the
> EVENT_LEFTCLICK the graph has not processed the callback and returns
> the wrong coordinates. You can wait for the COMMIT event or install a
> callback after your callback in the left click.
Thanks. I had the plot to NORMAL and the callback to EVENT_VAL_CHANGED.
It all works fine with HOT an...




0 Kudos
Message 4 of 4
(3,109 Views)