LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Draw by hand onto x/y-graph

Solved!
Go to solution

Hey all,

 

I create a control program for a piezo mirror that moves the focus of a laser beam on a sample. I included several possibilities to create figures that the beam will then carf into the material.

 

Now I would like to include additionally the possibility to draw a figure by hand /mouse onto a x/y-graph that can then be read out by the program as an x/y-Array.

Is this easily possible or would this require a lot of effort? Does someone know how to implement this?

 

Thank you in advance.

0 Kudos
Message 1 of 28
(4,805 Views)

Hi Labphew,

 

ou can use mouse move events to track your mouse movement.

Use them to draw your XY graph background image…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 28
(4,777 Views)

Hey GerdW,

 

would you mind to give me a minimal working example (only if it is quickly done)? 

 

Thank you for your answer,

Labphew

0 Kudos
Message 3 of 28
(4,769 Views)
Solution
Accepted by Labphew

I would use a free cursor and then use the Cursor Release event.  This way the array won't get huge with every tiny movement.  You just take the position when the user lets go of the cursor.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 28
(4,765 Views)
Solution
Accepted by Labphew

See this small VI for tracking mouse movement…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 28
(4,760 Views)

Hey again,

 

thank you very much. It helped me to figure out my problem. However "coordinates" are not the coordinates in the xy-graph, but the vertical and horizontal coordinates of the pane. I cannot use these position-coordinates to plot the graph etc.

The better property for my problem is "CursLoc" where I have to drag and drop the Cursor to draw something but at least "CursLoc" then gives the correct coordinates.

 

Nethertheless thank you very much.

 

0 Kudos
Message 6 of 28
(4,743 Views)

Labphew,

 

you just need to subtract a fixed offset: coordinates in graph := mouse position - position of the graph

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 28
(4,737 Views)

@crossrulz

 

thank you for your answer. Together with the minimal working example of GerdW I solved my problem.

 

I used curser movement as event but included a "wait" in the event case, so that the number of points can be reduced.

 

I don't know who of you two I should mark as solution...

 

0 Kudos
Message 8 of 28
(4,732 Views)

Labphew wrote:

I don't know who of you two I should mark as solution...


You can mark both as solutions.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 28
(4,727 Views)

Shame that Draw Graph with Events.vi is no longer in the Example Finder.  It does exactly what the OP wants.  I've used (stolen?) it to jumpstart many mouse-drawing programs.  Found many mentions of it on-line but no code.  Smiley Sad

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 10 of 28
(4,711 Views)