LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Drawing line with mouse clicks in picture indicator

Solved!
Go to solution

Hello,

I need to import a JPG in a picture control, draw a line with 2 clicks, read bothe XY positions and perform some basic trigonometry. Any easy or striaghtforward way to draw to line with the mouse and read thos epositions on the bitmap (relative pixel positions)?

Thanks in advance,

0 Kudos
Message 1 of 21
(5,756 Views)

Use mouse-down events and mouse move events and get the image coordinates similar to this example.

 

Store the start coordinates in a shift regsiter on "mouse down" and draw the line to the current position on "mouse move". Finalize the line on "mouse up". See how far you get.

0 Kudos
Message 2 of 21
(5,738 Views)

What have you tried?  Do you want the drawing of the line to be interactive where you would see a preview of the line?  Or do you want to pick two points and draw a line between, with no preview?

 

You'll want to use an event structure with some events for mouse down (and/or mouse move....depending on the preview requirement), some feedback nodes shift registers for storing previous clicks, and the picture functions. 

aputman
0 Kudos
Message 3 of 21
(5,734 Views)

Thank you both for the prompt responses!

Yes, I'd prefer the "interactive" line. And it has been a "while" since I last opened LV. Never worked with the mouse.

I will give my best followig days. If you have a more concrete example with the mouse events... I'd appreciate a lot!

Thanks again 🙂

0 Kudos
Message 4 of 21
(5,721 Views)

Have you search the examples that ship with Labview?

aputman
0 Kudos
Message 5 of 21
(5,668 Views)

Here's a very simple example based on my suggestions. The line is temporary, and only shows while the mouse is down. At the same time, it shows the lenght of the line in an indicator.

0 Kudos
Message 6 of 21
(5,639 Views)
Altenbach, Yes, that is about what I am trying to do - measure distance between 2 coordinates, whether MouseDown-MouseDown or MouseDown-MouseUp. Prior the measurement I would calibrate a pixel-measured distance with known distance in [mm], providing the [mm/pixel] ratio. The mouse property is related to the 2D picture control? Is it possible to read and prepare picture control size from the JPG in advance?
0 Kudos
Message 7 of 21
(5,614 Views)

@golubovski wrote:
 Is it possible to read and prepare picture control size from the JPG in advance?

Yes.

0 Kudos
Message 8 of 21
(5,609 Views)

This may sound ridiculus, but LabVIEW 2015 won't let me "change to write" the "bounds" proerty node(s) of the 2D picture control - this right-click option is greyed!!! I have searched and fount numerous examples where exactly this parameter (formerly DrawAreaSize) is set to be written to.

Am I missing something here?

0 Kudos
Message 9 of 21
(5,580 Views)

OK, found it. Options are not listed in alphabetical order after all. Please disregard the previous post...

0 Kudos
Message 10 of 21
(5,561 Views)