我用来创建 3D 等高线图的表面等高线。我现在一直在我的 3D 图形中绘制轮廓线,这也很有效,但是没有显示图例,为什么?
代码:
private void button1_Click(object sender, EventArgs e)
{
ILArray<float> data = ILSpecialData.sincf(50, 50);
BackgroundWorker bgw = new BackgroundWorker();
bgw.DoWork += bgwCreateProcess_DoWork;
bgw.RunWorkerAsync(data);
}
private void bgwCreateProcess_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
ILArray<float> data = e.Argument as ILArray<float>;
using (ILScope.Enter())
{
ILScene scene = new ILScene();
ILPlotCube plotCube = new ILPlotCube(twoDMode: false);
plotCube.Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), Math.PI / 2);
ILSurface surface = new ILSurface(data);
List<ContourLevel> conturLevels = new List<ContourLevel>();
conturLevels.Add(new ContourLevel() { Text = "Limit Max", Value = 0.9f, LineWidth = 2 });
conturLevels.Add(new ContourLevel() { Text = "Limit Min", Value = -0.1f, LineWidth = 2 });
conturLevels.Add(new ContourLevel() { Text = "Average", Value = 0.5f, LineWidth = 3 });
ILContourPlot contourPlot = new ILContourPlot(data, conturLevels, create3D: true);
plotCube.Children.Add(contourPlot);
ILLegend legend = new ILLegend();
legend.Location = new PointF(.99f, 0f);
surface.Children.Add(legend);
ILColorbar colorbar = new ILColorbar();
colorbar.Location = new PointF(.99f, 0.4f);
surface.Children.Add(colorbar);
surface.Markable = false;
surface.Fill.Markable = false;
surface.Wireframe.Markable = false;
surface.Wireframe.Visible = true;
surface.UseLighting = false;
plotCube.Add(surface);
scene.Add(plotCube);
ilPanel.Scene = scene;
}
}
这段代码应该扩展到一个winform、一个ILPanel和一个按钮。最后但必须订阅按钮的 Click 事件。更少的代码是不可能的,否则情况就会改变。