LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetGraphCoordsFromPoint Bug?

Solved!
Go to solution
GetGraphCoordsFromPoint does not seem to work right. It seems to have an offset and scaling issue in both directions. Has anyone else had this issue?
0 Kudos
Message 1 of 5
(3,614 Views)

Hi rmich,

Could you please explain what kind of offset and scaling you're experiencing?  The Help for the GetGraphCoordsFromPoint function state that "The pixel coordinates should be relative to the top, left corner of the panel. The return value indicates whether the point is within the graph plot area." 

How does what you're experiencing differ from this?  


Mark E.
National Instruments

0 Kudos
Message 2 of 5
(3,566 Views)

I created a simple app with a 100x100 graph and a callback to print the coordinates.

 

...

  case EVENT_LEFT_CLICK:
   GetRelativeMouseState (panel, control, &mx, &my, NULL, NULL, NULL);
   status = GetGraphCoordsFromPoint (panel, control, MakePoint(mx, my), &x, &y);
   
   if(status>0)
    printf("%d,%d = %lf, %lf\n", mx, my, x, y);
   
   break;

... 

 

This is an example of what I get when I click on the graph:

Where I Click    Reported coodinates

0, 20                   4.3,28.9

30,70                 4.3, 97.3

100,0                 84.0, 26.8

100,75               84.0, 97.8

 

status is <0 for any Xless tha ~20 or Y greater than ~75. It will report valid coordinates by clicking below or to the right of the plot area down to the lower right of the graph control. It is as if the reported area is shifted to the right and down.

 

0 Kudos
Message 3 of 5
(3,541 Views)

Try calling GetRelativeMouseState() with 0 instead of a control value.

 

JR

0 Kudos
Message 4 of 5
(3,534 Views)
Solution
Accepted by topic author rmich
Yes, that was it. I missed the subtlety that GetGraphCoordsFromPoint() works from panel coordinates, not control coordinates. 
0 Kudos
Message 5 of 5
(3,527 Views)