12-06-2011 11:51 AM
Hello,
I have an application where I am sampling some data from an FPGA. I want to be able to select an area of the graph with the cursors and have the position of those cursors then be used in a calculation. Is this possible?
12-06-2011 01:18 PM
From your Graph, you can create a Property Node of Cursor. From there you can use Cursor List Property to get an array of information about the cursors on the plot area, including positions. From the X and Y position of two Cursors, you can determine a rectangle, and thus what the cursor is measuring.
12-06-2011 01:34 PM - edited 12-06-2011 01:44 PM
I would recommend a "cursor move event". Keep the two positions as an array of two positions (cluster of xy) in a shift register, and replace the respective values based on the cursor index and new xy positions from the event terminals (CursIdx & CurseLoc).
After replacement, use the values from the shift register to recalculate whatever needs to be done. 😉
Here's a very quick draft:
(Note that the FOR loop on the left shows also how to get both positions without all the extra baggage of the cursor list property.)
12-06-2011 01:47 PM
This was very helpful, thanks to you both.
Michael
12-06-2011 02:48 PM - edited 12-06-2011 02:50 PM
@altenbach wrote:
[..]
(Note that the FOR loop on the left shows also how to get both positions without all the extra baggage of the cursor list property.)
What baggage? It ain't much brother. I'm not much for creating events to get data that already exists out in space. Good thing Michael marked his own reply as the Solution, or I'd be sore and all.
12-06-2011 02:58 PM
Its my first post, I thought it was a generic 'accept thread as having a solution' button. Not 'mark this reply as solution'. 🙂 Sorry! I'm trying both!
12-06-2011 03:04 PM
@WyndyPickle wrote:
Its my first post, I thought it was a generic 'accept thread as having a solution' button. Not 'mark this reply as solution'. 🙂 Sorry! I'm trying both!
It's all good! Welcome to the Froums. Good first question.
12-06-2011 03:05 PM - edited 12-06-2011 03:09 PM
@broken Arrow wrote:
What baggage?
Form the problem description it sounded like he want to interactively change the cursors at any time, so an event structure seems appropriate. How else would you trigger reading the updated positions?
The cursor list is a huge data structure. I prefer to surgically get only what I need, but that's just me. 😄
Why get all these items if we only want the position? 😮 That's like ordering a sandwich "with everything" if all you want is a slice of cheese. ;))
I am glad that there are many different ways to do things...
12-06-2011 03:49 PM - edited 12-06-2011 03:52 PM
Well one other thing .. my graph has two cursors... i want to set the position of the X-axis of one as the minimum and the other X-axis value as the maximum. When I try and create a property node, and select Cursor ... all I get is cursor 1 ... how do I get to the additional cursors on the graph?
Nevermind.. I found the Cursor List attribute.
12-07-2011 07:56 AM
@WyndyPickle wrote:
[...]
When I try and create a property node, and select Cursor ... all I get is cursor 1 ... how do I get to the additional cursors on the graph?
[..]
Just so you know, look at Altenbach's example above - look at the Property Node inside the For Loop on the left. You have to set the Active Cursor before asking for Position. 0 = first, 1 = second, etc.