03-01-2013 02:43 AM
Hi
I was planning to do an simple editor to edit limits by drawing a curve in the WritableGraph control.
To be able to set the limit I first load data into a Point[] array and set the graph.DataSource to that array (which plots the loaded data).
Then I draw an upper limit into the WritableGraph (using the loaded data as a reference, in my case it's sampled data from a test-bench)
The imit-curve is saved to a file. Fetching InputData from the graph by using the code below.
WaveformInputData theData = (WaveformInputData)graph.InputData[0];
Buffer<double> bufferTime = (Buffer<double>)theData.GetData()[0];
Buffer<double> bufferLimit = (Buffer<double>)theData.GetData()[1];
My problem is when I go back to the screen for editing limits.
Is there any way to preload the InputData in the writablegraph so you could continue editing the limit file?
I've tried some tricks that doesn't work 🙂
/Mats
Solved! Go to Solution.
03-01-2013 12:44 PM
There is no direct way to load data back into the InputData
collection of a writable graph. I have created a task to improve this scenario.
As a workaround you can add the data back in the same way it was produced in the first place, by "replaying" the equivalent mouse interactions used to draw the data:
int size = bufferTime.Size;
inputData.AddData( DataToRelative( 0 ), PlotAreaMouseAction.Click );
for( int i = 1; i < size; ++i )
inputData.AddData( DataToRelative( i ), PlotAreaMouseAction.Move );
inputData.AddData( DataToRelative( size - 1 ), PlotAreaMouseAction.None );
private Point DataToRelative( int index ) {
var value = new[] { bufferTime[index], bufferLimit[index] };
Point relativePoint = graph.DataToRelative( graph.AllPlots[0], value );
return relativePoint;
}
03-04-2013 04:36 AM
Hi.
That might work. But I'm not really sure where to find the .AddData function. How should I use your example?
I cannot find a function AddData which take a Point and a PlotAreaMouseAction as parameters.
/Mats
03-04-2013 09:31 AM
Sorry, I see that you named the WaveformInputData
value in your example as "theData", not "inputData". The method is on the input data instance you add to the writable graph's InputData
collection when you re-initialize it.
Extending my example:
// Create input data and add to graph.
var inputData = new WaveformInputData( );
graph.InputData.Add( inputData );
// Initialize, input data (as before).
int size = bufferTime.Size;
inputData.AddData( ...
03-04-2013 09:48 AM
Thanks
Now I got it going.
/Mats