11-02-2012 11:28 AM
Hi all,
i need to programmatically bring to center the only cursor of a XY graph (a multi-point cursor made of 4 plots).
I realized an algorithm to calculate the x value to send to the "Cursor.Cursor position:Cursor X" property of the graph.
The cursor seems to be correctly set, but i resets instantly. Seems like i need to set the property for every 4 plots, but i don't know how.
Any clue?
Thanks
Marco
11-02-2012 12:06 PM
What do you mean by "resets instantly"? Does it change when the graph updates? Please post your code.
11-02-2012 03:58 PM
@aRCo wrote:
(a multi-point cursor made of 4 plots).
A cursor is not made of plots. Is the cursor locked to a plot (single, multi) or is it free?
We need to see some code.
11-05-2012 03:04 AM - edited 11-05-2012 03:05 AM
Here's the code.
The strange behaviour described in the first post is replicated: after clicking the "Center cursor" button, the multi-point cursor is centered, but it soon resets its position (i.e. it place itself in correspondance of the first sample).
Note that deleting the multi-point cursor and creating a new single-point one, the behaviour is not replicated and the cursor is correctly centered, without resetting its position.
11-05-2012 03:58 AM - edited 11-05-2012 04:04 AM
Se the "cursor index" property and set it to half the number of X points. (or use more complicated math if the graph is zoomed, not shown)
(All your booleans should be latch action, eliminating all local variables. You also don't need the reference. There probably also should be a small wait.)
(All that said, I never use multiplot cursors, but maybe there is a bug somewhere if they are used. Your code works fine if the cursor is locked to a single plot)
11-05-2012 04:33 AM
Thanks, setting "Cursor.Index" property solved the problem.
A question about the modifications you did on my code. Why you replaced the "Bundle Cluster" function with the composition of "Re/Im to Complex" and "Build Cluster Array" functions? Is there an efficiency reason or is it the result of your presonal preference?
11-05-2012 11:16 AM
No, I just like it better. Less clutter. 😉
Overall, your x-points are spaced equally, so a plain waveform graph (after setting x0 and dx) or even a chart would probably be sufficient. An XY graph seems overkill! You could just set the wait time to 1s or even use a timed loop. There are also probably better way to implement the buffer. Try to operate in-place.
11-06-2012 02:07 AM - edited 11-06-2012 02:29 AM
In this simplified version they are, but the definitive one gives the user the possibility to modify the wait time, meaning that dx can vary. It also contain in-place structures (one for each plot), where the operations of adding and deleting are realized.
Thanks