Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WritableGraph problem. How to preload data into InputData?

Solved!
Go to solution

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

0 Kudos
Message 1 of 5
(5,656 Views)

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&colon;


    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;
    }

~ Paul H
0 Kudos
Message 2 of 5
(5,644 Views)

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

0 Kudos
Message 3 of 5
(5,632 Views)
Solution
Accepted by topic author DevAutoit

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( ...

~ Paul H
Message 4 of 5
(5,627 Views)

Thanks

 

Now I got it going.

 

/Mats

0 Kudos
Message 5 of 5
(5,624 Views)