我使用 3D 等高线图来创建表面等高线。我想使用鼠标移动事件来确定网格坐标,但它在 3D 视图中不起作用。当我用鼠标双击 3D 角色时,它显示为平面。我现在正在寻找一种方法来确定图形是否显示为平面以便确定正确的网格坐标即可。我想显示一个带有网格坐标的工具提示。
另外,我正在寻找一个函数来通过代码本身将图形描绘成平面。
代码:
private void CreateContourPlot(ILArray<float> valueArray)
{ #region CreateContourPlot
try
{
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(valueArray);
List<ContourLevel> conturLevels = null;
if (LimitsDrawing)
{
conturLevels.Add(new ContourLevel() {Text = string.Empty, Value = LimitMin, LineWidth = 2, LineColor = ConvertColorToFloat(LimitsMinColor)});
conturLevels.Add(new ContourLevel() {Text = string.Empty, Value = LimitMax, LineWidth = 2, LineColor = ConvertColorToFloat(LimitsMaxColor)});
}
if (AverageLineDrawing)
{
if (conturLevels == null)
{
conturLevels = new List<ContourLevel>();
}
conturLevels.Add(new ContourLevel() {Text = string.Empty, Value = AverageLineValue, LineWidth = 3, LineColor = ConvertColorToFloat(AverageLineColor)});
}
if (conturLevels != null)
{
ILContourPlot contourPlot = new ILContourPlot(valueArray, conturLevels, create3D: true);
ILLegend legend = new ILLegend();
contourPlot.Add(legend);
plotCube.Add(contourPlot);
}
surface.Markable = false;
surface.Fill.Markable = false;
surface.Wireframe.Markable = false;
surface.Wireframe.Visible = GridDrawing;
surface.UseLighting = UsedLight;
surface.MouseEnter += ILSurface_MouseEnter;
surface.MouseMove += ILSurface_MouseMove;
surface.MouseLeave += ILSurface_MouseLeave;
plotCube.Add(surface);
scene.Add(plotCube);
SetSceneToChart(scene);
}
}
catch (Exception ex)
{
MessageBox.Show("There was an error in the creating process.\n" + ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
}
#endregion CreateContourPlot
}
私人无效ILSurface_MouseMove(对象发送者,ILMouseEventArgs e){#region MouseMove
ILGroup group = e.Target.Parent;
if (group != null)
{
Matrix4 trans = group.Transform;
while (!(group is ILCamera) && group != null)
{
group = group.Parent;
trans = group.Transform * trans;
}
if (group is ILCamera)
{
var pos = new Vector3(e.LocationF.X * 2 - 1, e.LocationF.Y * -2 + 1, 0);
trans = Matrix4.Invert(trans);
pos = trans * pos;
toolTipChart.SetToolTip(ilpnlChart, pos);
}
}
#endregion MouseMove
}
图像视图 3D 图 1 3D 视图
图像查看鼠标双击 图2 鼠标双击查看(平面图)