Trouble with mouse location on pictures

I’m trying to use the mouse to draw rectangles on a Picture indicator.
However, the mouse coordinates are not corresponding consistently to the Rectangle coordinates, and I can’t seem to make sense of it.

Here’s a video demonstrating the problem.
http://screencast.com/t/Yzg1YTViYWUt
While you can’t see whether I’m clicking or not, every short diagonal movement is a click-and-drag action.
(In one of them, I believe the rectangle it made was actually outside the picture).

Is there anything wrong with my code?

(Note:
I am using the Picture control, not at IMAQ image. This code is not intended to run on the cRIO, and probably won’t be usable within the FRC Framework)

Picture properties.vi (34.1 KB)


Picture properties.vi (34.1 KB)

Hey, that’s a neat trick. Are the XY coordinates you’re getting from the mouse within the frame, within the window, or within the entire screen? Also, what’s the scope of the rectangle creation (same scopes as above)? I’m guessing you’ve already set that up correctly, but if it’s not doing what it’s supposed to be doing…

Okay, I found several problems:
The X and Y axis were switched when creating the rectangle.
The picture origin was not correct (thus creating a consistant offset)
The correct picture origin is dependent on the picture position plus a fixed offset.

Anyways, I got it working correctly, and uploaded it in case you wanted to see too.

Thanks!

Picture properties.vi (38.4 KB)


Picture properties.vi (38.4 KB)

Oooh, these are always great fun!

NI has tons of examples for these picture controls. They’re of course on NI Developer Zone, but if you look up picture controls and the like in the LabVIEW Help, they will have examples there too to look at. Lots of cool ideas.

Glad it worked!