Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WaveformGraph and maintaining zoom factors between waveform plots?

I'm using Measurement Studio for VS 2005. I note that the NI examples that use the waveformgraph component maintain zoom factors between plots. I have added plots to the plots collection in my project, and I am plotting using the NationalInstruments.UI.WaveformPlot.PlotY function that is accessed through a member variable for the plot and the only parameter I am passing to the function is an 1-D double array that contains the data to be plotted. PlotY is called at a rate of 50 times a second.

If I stop plotting, I can zoom using the built-in zoom functionality, however, when I resume plotting, the zoom factor is not maintained, and the plot autoscales back to the original setting with each successive plot.

Here's a line of code that I use to plot:

                        this.m_wfpRawSignal.PlotY(djagarrCurrentData[(int)enumJagArrayData.mRawInputData]);

djagarrCurrentData[(int)enumJagArrayData.mRawInputData] is a double array.

From the way that the NI examples behave, I have to assume that it is possible to maintain the zoom level between successive plots. What do I have to do to make this happen, and is there sample code available that shows how to do it? If the sample is available, would you please post it?

Thanks.

Best Regards,
Matthew

0 Kudos
Message 1 of 17
(6,443 Views)

Hi Matthew,

I'm interested to know what specific examples you were looking at. I have pulled up a few examples but am unable to find an example that holds the zoom factor.

While we do not have any specific examples that show how to set the zoom factor, I can give you some pointers.

First, you can use the zoom events on the waveform graph to check when a graph's zoom has changed. For instance, you could use the Zoom event to check whenever the graph has been zoomed. Then you could save the zoomed range from the X-axis to a variable and assign this range later when you plot.

You could use this method to get the zoom factor as well. You could then use the function ZoomAroundPoint if you know where you want to zoom around and at what factor you want to zoom.

This should get you started. Let me know what example you were looking at, I'll check it out and then I might be able to give you a more specific answer.

Matt
NI

0 Kudos
Message 2 of 17
(6,430 Views)
Hi Matt,

Thanks for the reply.

Here's the directory for the example.

\Program Files\National Instruments\MeasurementStudioVS2005\DotNET\Examples\UI\WindowsForms\Graph\PlotWaveforms\cs


Best Regards,
Matthew

0 Kudos
Message 3 of 17
(6,427 Views)
Thanks for the example.
 
After looking at the example, you'll see that on the yAxis the Mode property is set to Fixed (to see this graphically, go to the waveformGraph properties, look at the YAxes group). This will fix the zoom on the y-axis, even after data plotted on the graph again. Normally, this property is set to AutoScaleLoose which re-scales the graph each time a plot is added.
 
To test this out, you can try changing the Mode property to AutoScaleLoose and you will notice the graph resets everytime you press the button.
 
You simply need to change the mode property for the yAxis to Fixed and the zooming should stay the same on the y-axis. You can do the same for the x-axis as well.
 
Matt
National Instruments
0 Kudos
Message 4 of 17
(6,422 Views)
Hi Matt,

I tried what you suggested, i.e., setting the y axis scaling to fixed, and I can now zoom in without the graph resetting itself every time I plot.

However, zooming out does not seem to work at all. That is, I am able to press "shift" and "left-click" to zoom in as many times as I want to,  however, when I press "shift" and "right-click", the control does not zoom out. Is there something that I am missing? Do I, perhaps, have to save the initial zoom factor and then reset it with each successive "shift right-click" event? I note also that if I code a zoom event handler for the control, it fires for every "shift left-click" instance. However, it does not fire for "shift right-click".

Any further ideas you might have on this would be greatly appreciated.

Best Regards,
Matthew

0 Kudos
Message 5 of 17
(6,403 Views)
Hi Matthew,
 
I'm not sure why your graph wouldn't be zooming out.
 
The zoom in and zoom out functions should be caught by the Zoom event (as specified in the Measurement Studio help) and should be activated by selecting the Zoom properties under the interaction mode on the graph. Make sure all of the zoom properties are selected (for instance, ZoomX and ZoomY) under the InteractionMode property for you graph.
 
What exactly is happening when you shift + right-click? Is the animation showing up (like the outline of where it is zooming out)? Is the graph changing at all?
 
Also, what version of Measurement Studio are you using?
 
Matt
NI
0 Kudos
Message 6 of 17
(6,396 Views)
Hi Matt,

Thanks for youre reply.  I am using Measurement Studio 8.0.1 and Visual Studio 2005.

As somewhat of an aside, when I zoom in, the first time that I press the shift key and hover over the graph component, the magnifying glass does not appear. It only appears when I first click the graph, then press the shift key.

As to what is happening when I attempt to zoom out, it appears that nothing happens. I'll qualify that further. If I press the shift key (given that I have already first clicked on the graph component), the magnifying glass appears. If I then right-click, nothing appears to happen. If I attempt to right-click and drag to generate a region to zoom out around, no region is drawn (assuming one is supposed to be drawn as documentation on exactly what is supposed to happen in a zoom in/out operation does not seem to be present in the help for the component).

Note, too, that zoom out does not happen if the X axis is set for either "autoscaleloose" or "fixed".

So, the best that I can say is that nothing at all seems to happen when pressing the shift key and right-clicking to zoom out. Is zoom out the expected behavior for shift-right-click?

Thanks again.

Best Regards,
Matthew

0 Kudos
Message 7 of 17
(6,379 Views)

Hi Matthew,

To answer your first aside, the reason that the magnifying glass does not appear until you have clicked on the graph control is because the graph control does not have focus. The application may have focus (and probably another control on the application has focus), but you must select the graph before your cursor will recognize the shift-press event.

In order to accurately describe zooming out, I'll first reference zooming in. When you zoom in, when you shift+click, a colored box should appear around the area you are zooming in on. Then, if you have ZoomAnimation turned on for your graph, there will be an animation that "shows" zooming in. For zooming out, the colored box will not appear; however, the outline animation should happen if ZoomAnimation is set to true.

The zoom in and zoom out function should be built in to the graph control as described above.

Are you able to zoom in and then zoom out? From what it sounds like, you are trying to zoom out before you have ever zoomed in. I do not believe this is possible because I do not think the graph will let you zoom outside of its range if the range is set to Fixed (which is necessary for you if you do not want the range to change on each plot). Even if you move around the graph (using Control+drag) and then try to zoom out, your range does not change, it simply continues moving you towards your initial range.

If you are unable to zoom out after zooming in, try your exact click sequence on one of our examples and see how it reacts differently. I created a simple example and was able to replicate everything I told you above with Measurement Studio 8.0.1 and Visual Studio 2005.

Matt
NI

0 Kudos
Message 8 of 17
(6,375 Views)
Matt,

I zoom in, and then zooming out does not work.

With the NI sample that I cited above, try this:
  1. Run the program, leave all the buttons at their default setting when the program starts.
  2. Press the "Plot Waveform" button once or more.
  3. Zoom in once or more.
  4. Without zooming out, press the "Plot Waveform" button again.
  5. Now try zooming out.
Assuming that you note the same behavior that I do, zooming out does not work when you follow those steps; in fact, zooming out does not work at all at that point. If no plot has occurred between zooming in and zooming out, one can zoom in, and then zoom out to the original scale factor as many times as one wants to. However, follow the steps I outlined, and you can continue to zoom in, but if you plot again, you can no longer zoom out. For a real-world application that plots real-time data, IMHO, it would seem that the control working this way is not particularly useful.

As I stated above, this is what the application I am working on does. It plots successive plots at a rate of 50 plots/sec. Apparently, after zooming in, then plotting without zooming out, the zoom out function does not work. The NI sample code does not approach the same level of complexity as does the application I am working.

So, is this a bug? If so, what's the work around? If this is not a bug, then what is the suggested means for zooming out in these circumstances, or if you don't see this behavior, then maybe you would be kind enough to talk to R&D to ask them what they think could be the problem?

Thanks.

Best Regards,
Matthew

0 Kudos
Message 9 of 17
(6,362 Views)
Hi Matthew,
 
I believe I understand your problem now (before I thought you were simply unable to zoom).
 
The cause of the zoom being disabled is your use of the function PlotY. Every time you use PlotY, it is resetting the history for zooming. This means you cannot zoom out any further and is expected behavior (and like you pointed out, you are still able to zoom out after zooming in). Using PlotYAppend, I was able to zoom in, plot and then zoom out to the original zoom factor after zooming in once. This is because, as I said, PlotY resets the history of zooming; however, because PlotYAppend is simply appending to the graph, it does not reset the zoom history and you can unzoom.
 
One other possible workaround is that you can use the event handler for the zoom event, capture the axes when a zoom event occurs, and then also create an event handler for the unzoom event. In the unzoom event you could manually resize the axis to unzoom. This could get a little difficult depending on how many times they zoomed in, but unfortunately I think this is going to be the only way you can do it with your current setup.
 
Matt
NI
0 Kudos
Message 10 of 17
(6,351 Views)