Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Restrict Pan-Mode

I want to restrict the pan-Mode, the user should not be able to pan past the waveform.
I am using a waveformGraph in my project.

Is it easily doable? I have thought about setting back the range of the axis everytime the user exceeds the limit (0-maxDuration), on both sides.
0 Kudos
Message 1 of 3
(3,623 Views)
Hello

YOu could just reset the ranges using the OnPan event for the graph. The OnPan event indicates the end of the panning operation you you will need to store what the pre-panning values were.
Another thing I thought of was if you would draw on the graph to indicate the end of the waveform, like a hatch or something to indicate to the user that anything in this range is invalid. So if the user were to pan in that region, he would would a visual indicator of the invalid section.

I attached an example of this to clarify what I mean by this. Im using Measurement Studio 7.1, but you can do this with 7.0 as well. The main stuff is in the AfterPlotDrawEvent

Hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 3
(3,623 Views)
You can attach an event handler for the XAxisRangeChanged and/or YAxisRangeChanged event on the WaveformGraph. Panning the graph updates the range of the axis causing a range event to be raised. In the event handler, you can check if the maximum of the axis range is greater than the maximum of your data. If so, you can set the maximum of the axis range to the maximum data value. The implementation would be similar for the minimum value. Here is an example that restricts the range of the x-axis by attaching an event handler to the XAxisRangeChanged event:

// e represent the event argument of the
// XAxisRangeChanged event.
XAxis xAxis = e.XAxis;
double delta = xAxis.Range.Maximum - xAxis.Range.Minimu
m;

// These values should be changed to the
// actual minimum and maximum value of
// the data.
double dataMaximum = 20;
double dataMinimum = -10;

if (xAxis.Range.Maximum > dataMaximum)
{
xAxis.Range = new Range(dataMaximum - delta, dataMaximum);
}
else if (xAxis.Range.Minimum < dataMinimum)
{
xAxis.Range = new Range(dataMinimum, dataMinimum + delta);
}

Hope that helps.

Abhishek Ghuwalewala
Measurement Studio
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 3 of 3
(3,623 Views)