【发布时间】:2013-10-18 23:27:08
【问题描述】:
我用来创建 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 事件。更少的代码是不可能的,否则情况就会改变。
【问题讨论】:
-
能否提供一个可运行的迷你示例?
-
图例的绘制问题,在没有BackgroundWorker的ILPanel Load事件上创建图表时不会出现。只要我把它变成一个有或没有后台工人的方法,她就不再显示了。
-
Felix,您的示例包含很多不必要的信息/代码。如果没有机会运行代码,我们将无法为您提供帮助。请提供一个较小的示例,仅显示相关部分!
-
我希望现在更清楚了。
标签: ilnumerics