Paul が指摘したように、これを行うためのより効率的な試みがあります。
private void ilPanel1_Load(object sender, EventArgs e) {
using (ILScope.Enter()) {
// create some test data
ILArray<float> A = ILMath.tosingle(ILMath.rand(1, 50));
// add a plot cube and a line plot (with markers)
ilPanel1.Scene.Add(new ILPlotCube(){
new ILLinePlot(A, markerStyle: MarkerStyle.Rectangle)
});
// register update event
ilPanel1.BeginRenderFrame += (o, args) =>
{
// use a scope for automatic memory cleanup
using (ILScope.Enter()) {
// fetch the existint line plot object
var linePlot = ilPanel1.Scene.First<ILLinePlot>();
// fetch the current positions
var posBuffer = linePlot.Line.Positions;
ILArray<float> data = posBuffer.Storage;
// add a random offset
data = data + ILMath.tosingle(ILMath.randn(1, posBuffer.DataCount) * 0.005f);
// update the positions of the line plot
linePlot.Line.Positions.Update(data);
// fit the line plot inside the plot cube limits
ilPanel1.Scene.First<ILPlotCube>().Reset();
// inform the scene to take the update
linePlot.Configure();
}
};
// start the infinite rendering loop
ilPanel1.Clock.Running = true;
}
}
ここでは、 に登録された無名関数内で完全な更新が実行されBeginRenderFrame
ます。
シーン オブジェクトは、レンダリング フレームごとに再作成されるのではなく、再利用されます。更新の最後に、シーンが知る必要があります。これはConfigure
、影響を受けるノードまたはその親ノードの中のいくつかのノードを呼び出すことによって完了します。これにより、シーンが部分的な更新をレンダリングするのを防ぎます。
更新のたびにクリーンアップするために、ILNumerics アーティフィシャル スコープを使用します。これは、より大きな配列が含まれる場合に特に有益です。ilPanel1.Scene.First<ILPlotCube>().Reset()
プロット キューブの範囲を新しいデータ コンテンツに再スケーリングするために、への呼び出しを追加しました。
最後に、Clock
ILPanel の を開始して、レンダリング ループを開始します。
結果は動的なライン プロットであり、レンダリング フレームごとに更新されます。
