LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with single plot xy graph cursor snapping

Solved!
Go to solution

Hey All,

 

I am new to cursors and having difficulties having the proper behavior occur after searching hours through help documents and other forum threads. The program consists of 2 vector coordinate inputs and the number of points along those vectors with a third vector for an offset correction. This builds an XY graph of evenly distributed points.

 

The next step of the program is to use a Boolean array that maps to the xy array indices and allow the user to "select" which points to use through mouse events. I am attempting to use a bunch of cursors to choose which points are active by setting a cursor that snaps to the indices of the xy data array.

 

Since it is only a single graph, I was using the single-plot mode forced to Plot 0 to allow the cursor to snap to these indices, however my cursor is stuck at [0,0] even though I have debugged that the x/y position data is being fed properly though the invoke node. I also have found that every time a mouse down event occurs, the previous cursor list loses the x/y position data from the cursor and has it set back to [0,0].

 

I am hoping for some assistance in finding the right direction with the cursors to both build a cursor list and have them snapped to the correct data indices for use later to update the Boolean array.

 

Trying to work my way up the learning curve.


Thank you

0 Kudos
Message 1 of 9
(1,523 Views)

Why would you need cursors at all? Just create a second plot that has e.g. red circles and add/remove a point according to the closest valid grid point.

 

How about making the boolean array a control and let the user choose there which points to select?

 

(I don't understand your data creation for the xy graph. Seems exceedingly complicated for what it does.)

Message 2 of 9
(1,499 Views)

altenbach's answer is probably the most useful... there are better ways to store this information than a cursor list.

 

That having been said, at first glance your code should work. I briefly dug through help files and nothing struck me as wrong with it.  So I spent a little bit of time playing around to see if I could figure out what is going on.

 

There are two different fields in the cursor list cluster that control the position of your cursor. These fields are:

  • Index - Array index of the point to which the cursor is snapped. This property can have a value between 0 and the number of data points minus 1.
  • Cursor Position - Position of cursor in terms of X-Y coordinates.

 

You are writing both of these properties at the same time.  In the case of snapped plots, the index property supersedes Cursor Position. You will notice that if you change the Cursor Mode to 0 (free floating) your code behaves as expected.

 

The solution here then is to first add the additional curser to the CrsrList, then set the XY position. I couldn't find any documentation on this, but almost certainly there is code in the backend when setting the XY position property that will translate this into an index. That's what you're actually setting.

 

BowenM_1-1618521518375.png

 

Message 3 of 9
(1,460 Views)
Solution
Accepted by topic author dougbtg

As I said, cursors are probably not the right tool for this. Here's what I had in mind earlier...

 

Maybe it can give you some ideas. I am sure certain changes are needed.

 

 

 

altenbach_0-1618524330631.png

 

 

Message 4 of 9
(1,450 Views)

In the case of snapped plots, the index property supersedes Cursor Position. You will notice that if you change the Cursor Mode to 0 (free floating) your code behaves as expected.


I had tested this mode as well along with using the single-plot, snapped mode that instead of the setting set to Plot 0, to the -1 setting where it could snap to any plot near the cursor position. It would create a cursor near the point I was at, but the cursor would not "fill" the data point until I created a second cursor at the same data point.

 

I had been approaching it the opposite way thinking that the Index would be set after the coordinates "snapping" to the position that was located closest to the data point. I will give this idea a run, though I do agree that cursors are probably not the most optimal solution; I am still working on the learning curve of LabVIEW. I really appreciate your assistance and time.

0 Kudos
Message 5 of 9
(1,412 Views)

Why would you need cursors at all? Just create a second plot that has e.g. red circles and add/remove a point according to the closest valid grid point.


Hm, I think this would be a good solution as I could better coerce the mouse event to the data point as the arrays would be identical.

 

How about making the boolean array a control and let the user choose there which points to select?


The reason the boolean array is showing at all was for testing purposes. The data array is not meant to be rectangular always which might be difficult for the user to associate the boolean array points to the xy data points, it is more to be a background process for determining which data points will be used.

 


(I don't understand your data creation for the xy graph. Seems exceedingly complicated for what it does.)

Me too.. was tasked with approaching a problem from a different way and wanted to move forward to the next step. Tried to use a vector setup that could handle skew and rotations. I am constantly learning as I work with LabVIEW in my position.

 

The experience and extra eyes help a ton. Thank you

0 Kudos
Message 6 of 9
(1,406 Views)

Yes. getting rid of the boolean array will simplify the code significantly. Note that my method works for any arrangements of points (skewed, spiral, etc.) and all you need is change the code for generating the data. You can also put some filter in so the click is only functional if the distance to the closest point is below a threshold. Good luck!

Message 7 of 9
(1,401 Views)

@altenbach wrote:

Note that my method works for any arrangements of points (skewed, spiral, etc.) and all you need is change the code for generating the data.


Here's a quick example:

 

altenbach_0-1618601441782.png

 

Message 8 of 9
(1,396 Views)

Just finalizing the thread by attaching a solution I built from what @altenbach had provided earlier.

 

I really appreciate your approach and the simplicity of how you built the structure. I had not ever used a complex representation for simplifying the data arrays, so I have learned quite a lot and want to say thank you for your help and your time you gave.

0 Kudos
Message 9 of 9
(1,359 Views)