09-19-2013 01:45 AM
Hi All,
I'm using a graph control with 1 cursor set as snap to point and I'm plotting just one waveform: snap to points works very well!
My problem is that I need to display the snapped point value and it looks like the snapping code runs after the Graph events.
So using the code below, when I left click on the graph, I get the mouse position value and not the closest point of my plot to mouse position.
I tried with all graph events but was not able to discover any event that triggers the cursor has been taken to closest point.
int CVICALLBACK GraphGetCursor (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_LEFT_CLICK_UP:
GetGraphCursor (hPanel, hControl, 1, &dX, &dY);
break;
}
return 0;
}
My actual solution was to create a timer (50ms) and enable it on the event above.
Then calling GetGraphCursor (hPanel, hControl, 1, &dX, &dY) in EVENT_TIMER_TICK event, that occours after the cursor has been snapped to the closest point, I get the correct values I was looking for.
Any suggestion for a more elegant solution?
Thanks a lot
Sergio
Solved! Go to Solution.
09-19-2013 01:58 AM
Hi Sergio,
did you have a look at the example graphcursors? It seems to do what you want using the EVENT_COMMIT. Does this example not work for you?
09-19-2013 02:33 AM
Yes, it works!
I was using the Graph in Normal Mode and EVENT_COMMIT didn't work in that mode, so I was trying with other events.
Setting the Graph in HOT mode, EVENT_COMMIT works fine for my purpose.
Thank you very much Wolfgang!
Sergio
09-19-2013 02:49 AM
You are welcome!
The only difference between normal mode and hot mode of controls is the generation of commit events...
VAL_HOT | User action can generate commit or value changed events. |
VAL_NORMAL | User action can generate value changed events but not commit events. |