바울이 지적한 바와 같이,이 작업을 수행 할 수있는보다 효율적인 시도가 알려 : 여기
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()
에 대한 호출을 추가했습니다.
마지막으로 ILPanel의 Clock
을 시작하여 렌더링 루프를 시작하십시오.
결과는 동적 인 플롯이며, 모든 렌더링 프레임에서 자동으로 업데이트됩니다.