Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ILNumerics:手动创建的记号_C#_Ilnumerics - Fatal编程技术网

C# ILNumerics:手动创建的记号

C# ILNumerics:手动创建的记号,c#,ilnumerics,C#,Ilnumerics,我创建了手动记号,如ilnumerics页面所示: . 让我们以x轴上的日期为例。 我的问题如下: 在我的程序中,我想使用交互式鼠标缩放和拖动。但如果我这样做,则记号标签和网格线将从plotcube的左右边界中绘制出来。同样在上述示例中 我发现我可以通过使用plotCube的剪裁属性来解决网格线问题。对于我的面板大小,它如下所示: plotCub.Clipping = new ILClipParams{ Plane0 = new Vector4(1, 0,

我创建了手动记号,如ilnumerics页面所示: . 让我们以x轴上的日期为例。 我的问题如下:

在我的程序中,我想使用交互式鼠标缩放和拖动。但如果我这样做,则记号标签和网格线将从plotcube的左右边界中绘制出来。同样在上述示例中

我发现我可以通过使用plotCube的剪裁属性来解决网格线问题。对于我的面板大小,它如下所示:

        plotCub.Clipping = new ILClipParams{
            Plane0 = new Vector4(1, 0, 0, 0.63f),
            Plane1 = new Vector4(-1, 0, 0, 0.63f)
        };
但勾号标签仍在边界外绘制。我现在的解决方法是在plotcube的左侧和右侧放置面板。我想会有更好的办法来解决这个问题

另一个问题是剪裁只适合当前面板大小。但是我想在运行时更改面板大小,然后剪辑就不再适合了。 我没有找到如何获得剪辑的正确因子。还是有其他/更好的解决方案

提前感谢您的帮助

编辑:对不起,好像我是瞎子!!现在,我在dynamic ticks示例中使用了TickCreationFunc。 那很好!但现在我面临着新的问题: 当我使用TickCreationFunc(如示例中所示)时,每当我缩放或拖动场景时,刻度都会完全更新。 但该函数只返回刻度的位置。通过LabelTransferMFunc,我可以操纵标签的文本,通过DefaultLabel,我可以设置所有记号的字体和定位。 现在我正在寻找一种方法来定义单个记号的定位点,因为我需要将记号交替放置在两个高度上,因为它们不可读,否则它们太近。 有没有办法做到这一点??下面是我的代码的一个最小化示例:

private void ilPanel1_Load(object sender, EventArgs e)
{
    // create some base data:
    ILArray<double> A = new Double[,] { { 1, 4, 0 }, { 10, 12, 0 }, { 100, 10, 0 }, { 1000, 18, 0 }, { 10000, 15, 0 } };
    // create a line plot and keep a reference to it
    var linePlot = new ILLinePlot(ILMath.tosingle(A));

    ilPanel1.Scene.Add(new ILPlotCube{
        Children = { linePlot },
        Axes = {
            XAxis = {
                Ticks = {
                    TickCreationFunc = (min, max, count) => {
                        List<float> ret = new List<float>();
                        using (ILScope.Enter())
                        {
                            // some example ticks
                            for (double i = 0; i <= 10000; i += 100)
                            {
                                // only ticks within the plotcube limits
                                if ((float)ILMath.log10(i) >= min && (float)ILMath.log10(i) <= max)
                                {
                                    float mval = (float)ILMath.log10(i);
                                    // add if not allready in the collection
                                    if (!ret.Contains(mval))
                                        ret.Add(mval);
                                }
                            }
                        }
                        return ret;
                    },
                    LabelTransformFunc = (ind, val) => {
                        String s = "" + (float)(ILMath.round(ILMath.pow(10.0, Convert.ToSingle(val.ToString("f3"))) * 10) / 10.0);
                        return s;
                    },
                    DefaultLabel = {Font = new Font("ProFont", 5), Anchor = new PointF(0.5f, -1.0f)},
               },
           },
       },
       ScaleModes = { XAxisScale = AxisScale.Logarithmic },
   });
我无法读取或操作这些函数中的刻度,我不知道在哪里可以这样做

因此,我尝试使用TickCreationFuncEx作为我的VisualStudio警告我TickCreationFunc不再是最新的?!使用该函数,我可以返回一个完整的ILTickCollection,并根据需要设置所有锚点。 但plotcube似乎没有调用该函数。我忘了什么吗? 这是我写的。我将TickCreationFunc、LabelTransferormFunc和DefaultLabel替换为:

当我调试我的第一个程序版本时,我看到TickCreationFunc被反复调用,但在第二个版本中,TickCreationFuncEx从未被调用。我做错了什么

提前非常感谢您的帮助

TickCreationFuncEx = (min, max, count, axis, scale) => {
    IList<ILTick> ret = new List<ILTick>();
    // some example ticks
    for (double i = 0; i <= 10000; i += 100)
    {
        // only ticks within the plotcube limits
        if ((float)ILMath.log10(i) >= min && (float)ILMath.log10(i) <= max)
        {
            String s = "" + i;
            float mval = (float)ILMath.log10(i);
            ret.Add(new ILTick(mval, s));

        }
    }
    Font f = new Font("ProFont", 5);
    for (int i = 0; i < ret.Count; i++)
    {
        ret[i].Label.Font = f;
        if (i % 2 == 1)
            ret[i].Label.Anchor = new PointF(0.5f, -1.0f);
        else
            ret[i].Label.Anchor = new PointF(0.5f, 0.25f);
    }
    return ret;
}