我使用三维等高线图来创建表面轮廓。 我想使用鼠标移动事件确定网格坐标,但它在3D视图中不起作用。当我用鼠标双击3D角色时,显示为平面。我现在正在寻找一种方法来确定图形是否显示为平面以确定正确的网格坐标。 我想显示一个带有网格坐标的工具提示。
此外,我正在通过代码本身寻找图中的函数Portray flat。
代码:
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
}
private void ILSurface_MouseMove(object sender,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
}
Image view 3D 图1 3D视图
Image view mouse double click 图2通过鼠标双击(平面视图)
查看