LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Snap to point cursor: how to catch the "snap" event

Solved!
Go to solution

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

0 Kudos
Message 1 of 4
(4,043 Views)
Solution
Accepted by Laser

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?

Message 2 of 4
(4,040 Views)

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

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

You are welcome!

 

The only difference between normal mode and hot mode of controls is the generation of commit events...Smiley Wink

 

VAL_HOT User action can generate commit or value changed events.
VAL_NORMAL User action can generate value changed events but not commit events.
0 Kudos
Message 4 of 4
(4,029 Views)