Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How Do You Move Cursor To Another Plot?

I have a couple of plots I am working with. How do I move the Cursor (programmatically) from one plot to the next?

I have tried assigning the "Plot" to the cursor and using SnapToPointOnPlot, but it does no good.

You can set the snapmode to SnapToNearestPoint and drag the cursor there (that works), but I need to do it programmatically.
0 Kudos
Message 1 of 9
(4,900 Views)
Hello,

This is a very good question and I have been trying to solve it since you posted it. At this point, it doesn't seem possible. The documentation for the CWCursor under the Plot property states the following "You cannot associate the cursor with a plot."; However, in the properties for the Control, you can set the cursor to one of you plots.

One possible workaround for this may include setting up more than one cursor and assigning them one to a plot. Then with code, enable and disable the cursors ( or make visible/unvisible) as appropriate.

I will be looking into this matter further and I will update this Discussion if new information becomes available.

Good Luck!

Mike Rakolta
Applications Engineer
National Instruments
http://www.ni.c
om/ask
0 Kudos
Message 2 of 9
(4,900 Views)
The Remarks for the Plot property on the CWCursor object in online help could definitely be better. The sentence you are quoting was within the specific context of the SnapMode property being set to CWSnapFree and wasn't meant to be a general statement.

We will rework these words for our next release.

David
0 Kudos
Message 4 of 9
(4,900 Views)
Unfortunately, I want to have upto 10 plots. Having a different cursor for each plot is not very practical.
0 Kudos
Message 5 of 9
(4,900 Views)
I want to make sure that you saw my detailed answer to your original question. My answer demonstrates how to meet your request, I'm pretty sure. You should be able to have a single cursor and programmatically manage it to work with as many plots as you have. Let me know if the code I posted doesn't perform as you expect.

David
0 Kudos
Message 6 of 9
(4,900 Views)
David, I appreciate the comments. Was there some code you posted to resolve this problem? (It sounds like you did in your last response.)

I cannot see any attachements and I am interested in any possible solutions you might have.
0 Kudos
Message 7 of 9
(4,900 Views)
Yes, there was some code. Your original question now has two answers posted to it. The comments we are currently exchanging are within the second answer (not my answer.) To view all answers to your question, click on the button View All Answers To This Question. You should see this button at the bottom of your question next to the button Answer This Question.

I'm not sure why you didn't get notified of my direct answer, but did get notified of my comment to another answer. Odd.

David
0 Kudos
Message 8 of 9
(4,900 Views)
The following code demonstrates what you want to do. The form should have a 2D Graph (CWGraph1), a DSP control (CWDSP1), and a command button. Your difficulty may have been in (not) using the Set statement to assign a plot to the cursor. The VB lines of particular interest are in bold.

Private Sub Command1_Click()
Dim phase
Dim x
Dim y

'Create one sine wave
phase = 0
x = CWDSP1.SineWave(128, 1, 0.01, phase)
'Create a second sine wave
phase = 30
y = CWDSP1.SineWave(128, 1, 0.01, phase)
'Remove any plots from graph
CWGraph1.Plots.RemoveAll
'Plot one
CWGraph1.PlotY x
'This line prevents the next call to PlotY from overwriting the first plot.
CWGraph1.Plots(1).MultiPlot = False

CWGraph1.PlotY y

'I added a cursor interactively, so it already exists on the graph.
'Tell the cursor to snap to points on a specific plot
CWGraph1.Cursors(1).SnapMode = cwCSnapPointsOnPlot
'Tell the cursor which plot to snap to. You MUST use a Set statement because
' CWGraph1.Plots(1) references an object (in this case a plot object.)
Set CWGraph1.Cursors(1).Plot = CWGraph1.Plots(1)
'Put the cursor at index 64 of the plot data.
CWGraph1.Cursors(1).PointIndex = 64
MsgBox "asdf"
'Attach the cursor to the second plot.
Set CWGraph1.Cursors(1).Plot = CWGraph1.Plots(2)
'Put the cursor at index 32 of the plot data.
CWGraph1.Cursors(1).PointIndex = 32
End Sub

I hope this helps,
David
0 Kudos
Message 3 of 9
(4,899 Views)
It works.

The "Set" was my problem. Thanks!!!!!!
0 Kudos
Message 9 of 9
(4,899 Views)