LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Editing an existing graph

Solved!
Go to solution
This is what I am trying to achieve;

1.    As the user makes a left click close to a vertex (of a graph) (within a radius of 50 pixels) the vertex is selected and a small red cross is show on vertex position.

2.    If there are multiple vertices, close to the point clicked by user, the vertex closest to the point of click is selected.

3.    As the user updates a selected vertex, the graph display is changed accordingly.

Thanks for your help and time!

Have a very pleasant day!
 

 
0 Kudos
Message 1 of 23
(4,501 Views)

Hi,

 

What sort of updates would the user be making to the "vertex"?

Regards,
Claire Reid
National Instruments
0 Kudos
Message 2 of 23
(4,470 Views)

I'm not sure about a small red cross,

but I would try something with cursors.

 

Let me see if I can come up with something, I'll get back to you. 

Cory K
0 Kudos
Message 3 of 23
(4,466 Views)

Heres the idea I had in mind (attached):

 

When the mouse is clicked on the graph, capture position, and (using invoke node) change that to (x,y).

 

Seperately, use peak finder to output an array of maxiums.
Find the difference in (x,y) values between each peak and the mouse click. This should output an array.

Find the minimum distance, using array max/min finder.

 

Use this outputted index to go back to the original array outputted by the peaks, and find out which peak that was.

Automatically move the peak there.


I know I've been rambling, so you can look at the example I attached if you dont understand.


*Note - you will need to do a little math to find the ACTUAL distance (pythagorean's theorem)

at the moment, I just found distance to nearest X, then to nearest Y 

This is not the proper way to do it. Just add a little more code to what I gave you to implement pythagoreans theorem. 

Cory K
Message 4 of 23
(4,450 Views)
Solution
Accepted by Rashid-Malik

@cory K wrote:
Note - you will need to do a little math to find the ACTUAL distance (pythagorean's theorem)

at the moment, I just found distance to nearest X, then to nearest Y 

This is not the proper way to do it. Just add a little more code to what I gave you to implement pythagoreans theorem. 


Here you go. I fixed what I was talking about above.

Cory K
Message 5 of 23
(4,446 Views)

An example using an event structure must have a loop. Otherwise it will not work properly. The "Run Continuously" toolbar button is not an acceptable substitute.

 

For (1) and (2) the simplest solution is, as already suggested, a cursor. I also would like a better explanation of what is meant with (3). 

0 Kudos
Message 6 of 23
(4,441 Views)

smercurio_fc wrote:

An example using an event structure must have a loop. Otherwise it will not work properly.



I know. I was showing him how to implement the idea I had. That wasnt supposed to be copy&paste code.
Cory K
Message 7 of 23
(4,430 Views)
The user would click on a graph (which he had previously created). Our program should check if the click has been done near an existing vertex (within 50 pixel radius of the point clicked). Then he on click another point on the graph and the previous vertex would be replaced with the new one.
0 Kudos
Message 8 of 23
(4,396 Views)

Thanks a lot Cory K! I am impatiently waiting for your solution to my predicament.

Have a very pleasant day!

0 Kudos
Message 9 of 23
(4,394 Views)
Thanks a lot Cory K, that was great help. It solved our problem partially (the displaying of an x mark at the nearest vertex).
0 Kudos
Message 10 of 23
(4,392 Views)