Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to copy one plot from a waveformGraph to an other waveform Graph?

Hello!
On my GUI page, I have many-many small graphs (one plot on each) on many tab pages. I also have radio button and check boxes that will put different combination of those plots on a BIG graph. So, all I have to do is a copy of the plot from the small graph to the Big graph...

Here what i programmed, but it is not efficient for many graphs (unless i redo the programming to use an array of graphs)...

wfmBIG.ClearData()
Dim Xvalue, Yvalue As Double
'get Tzero
wfmSmallOne.Plots(0).GetDataPoint(0, Xvalue, Yvalue)
Dim myTzero As Double = Xvalue
'get deltaT
wfmSmallOne.Plots(0).GetDataPoint(1, Xvalue, Yvalue)
Dim myDeltatT As Double = Xvalue - myTzero
'plot it on Big graph
wfmBIG.Plots(0).PlotY(wfmSmallOne.Plots(0).GetYData, myTzero, myDeltatT)


so, is there a way to copy (more efficiently )a plot?
0 Kudos
Message 1 of 5
(3,690 Views)
WaveformPlot has a Clone method that will return a copy of the plot with the same data and property settings. For example, your code example would look like this with Clone:


wfmBIG.Plots.Clear()

Dim clonedPlot As WaveformPlot = DirectCast(wfmSmallOne.Plots(0).Clone(), WaveformPlot)
wfmBIG.Plots.Add(clonedPlot)


- Elton
0 Kudos
Message 2 of 5
(3,687 Views)
Seems to be a good idea, but it does not work. I got an "unhandled exception of type 'system.argumentException' occured in mscorlig.dll" message. It seems that "the destination array was not long enough and I need to check destIndex and length, and the array's lower bounds".

I set my option strict and explicit to "on", it might be the reason, but I need those option to "on". So, how do you clone a plot? Or, is there a way to get the deltaT and the Tzero of a plot, so I could just give a command like:
wfmBIG.Plots(0).PlotY(wfmSmallOne.Plots(0).GetYData, wfmSmallOne.Tzero, wfmSmallOne.DeltatT)
?
0 Kudos
Message 3 of 5
(3,675 Views)
Hi.
I made some test on the clone thing. It seems that the "systemArgumentException is related when there is more than 1000 points in the curve. But, even if I don't get the Error Message, it does not work either because the X and Y axis has bad numbers.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myIndexLenght As Integer = 999
Dim myArray(myIndexLenght) As Double
For i As Integer = 0 To myIndexLenght
myArray(i) = i
Next
WaveformGraph1.PlotY(myArray)

Dim clonedPlot As WaveformPlot = DirectCast(WaveformGraph1.Plots(0).Clone(), WaveformPlot)
WaveformGraph2.Plots.Add(clonedPlot)
WaveformGraph2.Plots(0).MapRange(WaveformGraph1.Plots(0).GetBounds(), XAxis2.Range, YAxis2.Range)

End Sub

In that case, the Xaxis and Yaxis are range(-1.7977e+308, 1.7977e+308).
So, how to make a bigger "clonedArrayPlot" and how to get/copy the axes?
0 Kudos
Message 4 of 5
(3,669 Views)
Finally, I created a sub that will do. Just have to call with:
subCopySmallGraph(wfmSmallOne, 0)


Private Sub subCopySmallGraph(ByRef myInputGraph As NationalInstruments.UI.WindowsForms.WaveformGraph, ByVal myPlotIndex As Integer)
Try
Dim Xvalue, Yvalue As Double
'get Tzero
myInputGraph.Plots(0).GetDataPoint(0, Xvalue, Yvalue)
Dim myTzero As Double = Xvalue
'get deltaT
myInputGraph.Plots(0).GetDataPoint(1, Xvalue, Yvalue)
Dim myDeltatT As Double = Xvalue - myTzero

'plot it on Big graph
wfmMain.ClearData()
wfmMain.Plots(myPlotIndex).PlotY(myInputGraph.Plots(0).GetYData, myTzero, myDeltatT)
Catch ex As Exception
'do nothing: just means that the graph has no plot in it
End Try
End Sub

Thank you very much for your help. Even it was not the answer I was looking for, it certainly help me a lot.
0 Kudos
Message 5 of 5
(3,664 Views)