Example #1
0
        public ILLinePlotWrapper(ILLinePlot source, ILPanelEditor editor, string path, string name = null, string label = null)
            : base(source, editor, path, BuildName(name, editor.Panel, source, ILLinePlot.LinePlotTag),
                   String.IsNullOrEmpty(label) ? GetLinePlotLabelFromLegend(source, editor.Panel) : label)
        {
            this.source = source;

            line = new ILLinesWrapper(source.Line, editor, Path, ILLinePlot.LineTag, "Line");
            marker = new ILMarkerWrapper(source.Marker, editor, Path, ILLinePlot.MarkerTag, "Marker");
            positions = new ReadOnlyCollection<float>(source.Positions.ToList());
        }
Example #2
0
        private static string GetLinePlotLabelFromLegend(ILLinePlot source, ILPanel panel)
        {
            int index = GetNodeIndex(panel, source);
            var legend = panel.Scene.First<ILLegend>();
            if (legend != null)
            {
                // Get text from ILLegendItem at the index
                if (legend.Items.Children.Count() > index)
                    return String.Format("{0} ('{1}')", ILLinePlot.LinePlotTag, legend.Items.Find<ILLegendItem>().ElementAt(index).Text);
            }

            return null;
        }
        /// <summary>
        /// Draws the adjusted function into a two-dimensional grid.
        /// </summary>
        private void draw2DShape()
        {
            var scene = new ILScene();

            // Copying all adjusted expression for further adjustments
            string[] polishAdjusted = new string[adjustedExpressionTree.Length];

            for (int i = 0; i < polishAdjusted.Length; i++)
                polishAdjusted[i] = String.Copy(adjustedExpressionTree[i]);

            NumericOption option = currentModel
                    .getNumericOption(firstAxisCombobox.SelectedItem.ToString());

            // Replace remaining options with variables and actual values
            for (int i = 0; i < polishAdjusted.Length; i++)
            {
                if (currentModel.getNumericOption(polishAdjusted[i]) != null)
                {
                    if (polishAdjusted[i].Equals(option.Name))
                        polishAdjusted[i] = "XY";
                    else
                    {
                        // All other options will be set on the value they have been set in the
                        // settings option.
                        float value = 0;
                        numericSettings.TryGetValue(currentModel.getNumericOption(polishAdjusted[i]), out value);

                        string[] parts = value.ToString().Split(new char[] {'.', ',' });

                        if (parts.Length == 1)
                            polishAdjusted[i] = parts[0];
                        else if (parts.Length == 2)
                            polishAdjusted[i] = parts[0] + "." + parts[1];
                        else
                            throw new Exception("An illegal number was found!");
                    }
                }
                else if (currentModel.getBinaryOption(polishAdjusted[i]) != null)
                    polishAdjusted[i] = "1.0";
            }

            // Define plot cube
            ILPlotCube cube = new ILPlotCube(twoDMode: true);
            cube.Axes.XAxis.Label.Text = option.Name;
            cube.Axes.YAxis.Label.Text = PERFORMANCE_AXIS_LABEL;

            // Calculate values for the measurements
            ILArray<float> XY = Array.ConvertAll(option.getAllValues().ToArray(), x => (float) x);
            XY = XY.T;

            XY["0;:"] = XY;
            XY["1;:"] = calculateFunction(polishAdjusted, new string[] { "XY" }, new ILArray<float>[] { XY });

            // Adding interactive points to the cube
            for (int i = 0; i < XY.Size[1]; i++)
            {
                ILPoints point = createPoint(XY[0, i], XY[1, i], 0, pointPositionLabel);

                // Adding events to the point to display its coordinates on the screen
                point.MouseMove += (s, a) =>
                {
                    Vector3 coor = point.GetPosition();

                    pointPositionLabel.Text = option.Name + ": " + coor.X.ToString() + ", " + PERFORMANCE_AXIS_LABEL + ": " + coor.Y.ToString();
                    pointPositionLabel.Visible = true;
                };

                cube.Add(point);
            }

            calculatedPerformances = ILMath.zeros<float>(0, 0);

            for (int i = 0; i < XY.Size[0]; i++)
                for (int j = 0; j < XY.Size[1]; j++)
                    calculatedPerformances[i, j] = XY[i, j];

            // Calculated values for the plot
            XY = ILMath.linspace<float>(option.Min_value, option.Max_value, 50);

            XY["0;:"] = XY;
            XY["1;:"] = calculateFunction(polishAdjusted, new string[] { "XY" }, new ILArray<float>[] { XY });

            // Adding a lineplot to the cube
            ILLinePlot linePlot = new ILLinePlot(XY)
            {
                Line =
                {
                    Color = calculatedColor
                }
            };

            cube.Add(linePlot);

            ilFunctionPanel.Scene = new ILScene()
                {
                    cube
                };

            // Saving the coordinates/values of the points for the measurements
            drawnPerformances = XY;
        }
Example #4
0
 public LineGroup(string nameOfLine = "nameless")
 {
     Graph = new ILLinePlot(ILMath.empty <float>(), nameOfLine, lineWidth: 1);
 }