LabWindows/CVI

取消
显示结果 
搜索替代 
您的意思是: 

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 项奖励
1 条消息(共 4 条)
3,838 次查看
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.
2 条消息(共 4 条)
3,838 次查看
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 项奖励
3 条消息(共 4 条)
3,838 次查看
> 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 项奖励
4 条消息(共 4 条)
3,838 次查看