Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

copy waveForm plot to an other waveform

I want to copy small wavefromGraph plot on a bigger waveform plot.

I have created an event handler (that work fine)
AddHandler wfmFFTphase.MouseHover, AddressOf subPlotInBigGraph

so when you click on the small graph, the plot should be copied into the bigger graph

Private Sub subPlotInBigGraph(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim hisWfrm As WaveformGraph
Dim hisPlot As WaveformPlot
Dim plotNumber As Integer
'suspend layout
Me.Cursor = Cursors.WaitCursor
Me.Refresh()
Me.SuspendLayout()
'get sender
hisWfrm = CType(sender, WaveformGraph)
hisPlot = hisWfrm.Plots(0)
'copy hisplot to the plot on bigger graph (Plotfiltered)
PlotFiltered.ClearData()
PlotFiltered = hisPlot
PlotFiltered.Visible = True
'resume layout
Me.ResumeLayout()
Me.Refresh()
Me.Cursor = Cursors.Default
End Sub

Should be easy, but I think I don't know how this "plot" thing works..Any good example?
0 Kudos
Message 1 of 5
(3,948 Views)
Please could you provide a little more detail on what exactly you are trying to "copy". From the post it seems that what you want to copy is the plot's data from the small waveform graph to a larger waveform graph. If this is infact what you are trying to do, I would suggest configuring the appearance (such as the line color, line style, etc.) of the plot on the large waveform graph up front at design-time. To do this launch the collection editor for the Plots property of the large graph from the property grid in Visual Studio.

In your post, you also mentioned that you were trying to "copy" the plot "when you click on the small graph". But in the event handler code, you were attaching an event handler to the MouseHover event of the graph. The MouseHover event is raised when the mouse hovers over the control, whereas the MouseDown event is raised "when you click on the small graph". I am not sure which of these you were actually trying to handle, but for the solution below I have used the MouseDown event. Also notice that I am handling the PlotAreaMouseDown event rather than the MouseDown event.


AddHandler wfmFFTphase.PlotAreaMouseDown, AddressOf subPlotInBigGraph

Private Sub subPlotInBigGraph(ByVal sender As Object, ByVal e As MouseEventArgs)
'GetPlotAt returns the plot at which the mouse
'was clicked or null if the mouse was not clicked
'on a plot.
Dim hisPlot As WaveformPlot = CType(wfmFFTphase.GetPlotAt(e.X, e.Y), WaveformPlot)

If Not (hisPlot Is Nothing) Then
Me.Cursor = Cursors.WaitCursor
Me.SuspendLayout()

PlotFiltered.ClearData()

'Copy the small graph's data
Dim hisYData As Double() = hisPlot.GetYData()
'Plot the data on the bigger graph
PlotFiltered.Plots(0).PlotY(hisYData)
PlotFiltered.Visible = True

Me.ResumeLayout()
Me.Cursor = Cursors.Default
End If
End Sub
Abhishek Ghuwalewala | Measurement Studio | National Instruments
Message 2 of 5
(3,937 Views)
Clone() is a fast way to copy plots, annotation, cursors, etc especially when they are heavily customized.
You just have to clone them and then add the copy to an other graph.

(I dont know if that helps :))
0 Kudos
Message 3 of 5
(3,927 Views)
Thanks a lot.

Because I did not know how to make a "cone" and because I have many small graph to copy from, I choosed the handler version.
I also used both handler, mouseHower and mouseDown. First one to show information and the second one to copy in the big graphs (addHandler and remove then if a checkBox is checked)

I copy the program example and, because I have 7 small graph to make bigger copy, I made some changes (kept the sender). It works fine and is very rapid (less than a second for more than 250,000 points of data). The only problem I did not solve yet is to change the axis so the curve is as big as it could. I have the filling it must have something to do with copying the Yaxis...

Private Sub subPlotInBigGraph(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim hisWfrm As WaveformGraph
Dim hisPlot As WaveformPlot
Dim plotNumber As Integer
'get sender
hisWfrm = CType(sender, WaveformGraph)
hisPlot = CType(hisWfrm.GetPlotAt(e.X, e.Y), WaveformPlot)
If Not (hisPlot Is Nothing) Then
'suspend layout
Me.Cursor = Cursors.WaitCursor
Me.SuspendLayout()
PlotFiltered.ClearData()
'Copy the small graph's data
Dim hisYData As Double() = hisPlot.GetYData()
'Plot the data on the bigger graph
PlotFiltered.PlotY(hisYData)
PlotFiltered.Visible = True
Me.ResumeLayout()
Me.Cursor = Cursors.Default
End If
0 Kudos
Message 4 of 5
(3,920 Views)
Lew,

If you are still sorting out how to change the YAxis programmatically, you could try something like:

Dim newRange As New Range(0, 150)
hisWfrm.YAxes(0).Range = newRange

Hope this helps!

Eric
0 Kudos
Message 5 of 5
(3,885 Views)