Beispiel #1
0
        private void drawOnlyPoints(Random random)
        {
            for (int i = 0; i < carDealers.Count; i++)
            {
                Color color = roundColor(random);

                try
                {
                    float[,] pointsForCar = new float[carDealers[i].carList.Count, 3];
                    for (int j = 0; j < carDealers[i].carList.Count; j++)
                    {
                        pointsForCar[j, 0] = carDealers[i].carList[j].age;
                        pointsForCar[j, 1] = carDealers[i].carList[j].beuty;
                        pointsForCar[j, 2] = 0;
                    }

                    ILPoints points = new ILPoints();
                    points.Positions = pointsForCar;
                    points.Color     = color;

                    plotCube.Add(points);
                }
                catch (NullReferenceException e)
                {
                    Debug.WriteLine("Poleciał wyjątek brak listy samchoddów.");
                }
            }
        }
Beispiel #2
0
        public void PlotSurface(ILArray <float> array)
        {
            //float max=array.Max();
            float scale = 1;

            float.TryParse(cmbZScale.Text, out scale);

            if (btnRemoveExisted.Checked)
            {
                _PlotCube.Children.Clear();
            }

            //   _PlotCube.Axes.ZAxis.Scale(1, 1, scale);
            var sf = new ILSurface(array)
            {
                Colormap = EnumHelper.FromString <Colormaps>(cmbColorMap.ComboBox.SelectedItem.ToString())
            };

            sf.Fill.Markable      = false;
            sf.Wireframe.Markable = false;
            if (scale != 1)
            {
                var newsf = sf.Scale(1, 1, scale);
                _PlotCube.Add(newsf);
            }
            else
            {
                _PlotCube.Add(sf);
            }
            // _PlotCube.Axes.ZAxis.Max = max;
            PopulateLegend();
            ilPanel1.Refresh();
        }
Beispiel #3
0
        void RenderFunction()
        {
            var function = _population.OptimizationFunction;
            var surface  = new ILSurface((x, y) => (float)function.Calculate(x, y),
                                         xmin: (float)function.MinX, xmax: (float)function.MaxX,
                                         ymin: (float)function.MinX, ymax: (float)function.MaxX,
                                         xlen: 100, ylen: 100);

            if (_currentSurface != null)
            {
                _plotCube.Remove(_currentSurface);
                _currentSurface.Dispose();
            }
            _currentSurface = surface;
            _plotCube.Add(surface);

            renderContainer.Refresh();
        }
Beispiel #4
0
        // Initial plot setup, modify this as needed
        private void ilPanel1_Load(object sender, EventArgs e)
        {
            ILPlotCube plotCube = new ILPlotCube();

            ILPoints points = new ILPoints();

            points.Positions = list0;
            points.Color     = Color.Red;

            ILPoints points2 = new ILPoints();

            points2.Positions = list1;
            points2.Color     = Color.Blue;

            plotCube.Add(points);
            plotCube.Add(points2);

            ilPanel1.Scene.Add(plotCube);
        }
 protected override Image DoCreateChartImage()
 {
     var scene = new ILScene();
     var tmpArray = new float[2, Parameters.SeriaData.Count()];
     var i = 0;
     foreach (var item in Parameters.SeriaData)
     {
         tmpArray[0, i] = item.Key;
         tmpArray[1, i] = item.Value;
         i++;
     }
     ILArray<float> data = tmpArray;
     var cube = new ILPlotCube { AutoScaleOnAdd = true };
     cube.Add(new ILLinePlot(data.T));
     scene.Add(cube);
     var driver = new ILGDIDriver(Parameters.ChartWidth, Parameters.ChartHeight, scene, Color.White);
     driver.Render();
     return driver.BackBuffer.Bitmap;
 }
Beispiel #6
0
        public MainWindow()
        {
            InitializeComponent();

            CBMat.ItemsSource = net.matList.Where(mat => mat.Name != "");
            Designer.MatList.ItemsSource = net.matList.Where(mat => mat.Name != "");

            Designer.TrackNode += Designer_TrackNode;

            CBMode.Items.Add("Paralelo");
            CBMode.Items.Add("Série");

            DGMatList.ItemsSource = net.matList;
            DGMatList.RowEditEnding += DGMatList_RowEditEnding;

            var scene = new ILScene();
            plot = new ILPlotCube(twoDMode: false);
            scene.Add(plot);
            var signal = ILMath.ones<float>(10, 10);
            ILSurface surf = new ILSurface(signal)
            {
                Wireframe = { Color = System.Drawing.Color.FromArgb(50, 60, 60, 60) },
                Colormap = Colormaps.Jet,

            };
            plot.AllowPan = false;
            plot.AllowZoom = false;
            plot.Projection = Projection.Orthographic;
            plot.Position = new Vector3(1, 3, .5);
            plot.AllowRotation = false;
            plot.Add(surf);
            scene.First<ILPlotCube>().AspectRatioMode = AspectRatioMode.MaintainRatios;
            scene.First<ILPlotCube>().Rotation = Matrix4.Rotation(new Vector3(0.1, 0, 0), ILMath.pi / 2);
            ilPanel.Scene.Add(scene);

            ResultSeeker.ValueChanged += ResultSeeker_ValueChanged;

            var sceneHx = new ILScene();
            plotHx = new ILPlotCube(twoDMode: false);
            sceneHx.Add(plotHx);
            var signalHx = ILMath.ones<float>(10, 10);
            ILSurface surfHx = new ILSurface(signalHx)
            {
                Wireframe = { Color = System.Drawing.Color.FromArgb(50, 60, 60, 60) },
                Colormap = Colormaps.Jet,
            };
            plotHx.Projection = Projection.Orthographic;
            plotHx.Position = new Vector3(1, 3, .5);
            plotHx.AllowRotation = false;
            plotHx.Add(surfHx);
            sceneHx.First<ILPlotCube>().AspectRatioMode = AspectRatioMode.MaintainRatios;
            sceneHx.First<ILPlotCube>().Rotation = Matrix4.Rotation(new Vector3(0.1, 0, 0), ILMath.pi / 2);
            ilPanelHx.Scene.Add(sceneHx);

            ResultSeekerHx.ValueChanged += ResultSeekerHx_ValueChanged;

            var sceneHy = new ILScene();
            plotHy = new ILPlotCube(twoDMode: false);
            sceneHy.Add(plotHy);
            var signalHy = ILMath.ones<float>(10, 10);
            ILSurface surfHy = new ILSurface(signalHy)
            {
                Wireframe = { Color = System.Drawing.Color.FromArgb(50, 60, 60, 60) },
                Colormap = Colormaps.Jet,
            };
            plotHy.Projection = Projection.Orthographic;
            plotHy.Position = new Vector3(1, 3, .5);
            plotHy.AllowRotation = false;
            plotHy.Add(surfHy);
            sceneHy.First<ILPlotCube>().AspectRatioMode = AspectRatioMode.MaintainRatios;
            sceneHy.First<ILPlotCube>().Rotation = Matrix4.Rotation(new Vector3(0.1, 0, 0), ILMath.pi / 2);
            ilPanelHy.Scene.Add(sceneHy);

            ResultSeekerHy.ValueChanged += ResultSeekerHy_ValueChanged;

            var sceneHz = new ILScene();
            plotHz = new ILPlotCube(twoDMode: false);
            sceneHz.Add(plotHz);
            var signalHz = ILMath.ones<float>(10, 10);
            ILSurface surfHz = new ILSurface(signalHz)
            {
                Wireframe = { Color = System.Drawing.Color.FromArgb(50, 60, 60, 60) },
                Colormap = Colormaps.Jet,

            };
            plotHz.Projection = Projection.Orthographic;
            plotHz.Position = new Vector3(1, 3, .5);
            //plotHz.AllowRotation = false;
            plotHz.Add(surfHz);
            sceneHz.First<ILPlotCube>().AspectRatioMode = AspectRatioMode.MaintainRatios;
            sceneHz.First<ILPlotCube>().Rotation = Matrix4.Rotation(new Vector3(0.1, 0, 0), ILMath.pi / 2);
            ilPanelHz.Scene.Add(sceneHz);

            ResultSeekerHz.ValueChanged += ResultSeekerHz_ValueChanged;

            var sceneEx = new ILScene();
            plotEx = new ILPlotCube(twoDMode: false);
            sceneEx.Add(plotEx);
            var signalEx = ILMath.ones<float>(10, 10);
            ILSurface surfEx = new ILSurface(signalEx)
            {
                Wireframe = { Color = System.Drawing.Color.FromArgb(50, 60, 60, 60) },
                Colormap = Colormaps.Jet,
            };
            plotEx.Projection = Projection.Orthographic;
            plotEx.Position = new Vector3(1, 3, .5);
            //plotEx.AllowRotation = false;
            plotEx.Add(surfEx);
            sceneEx.First<ILPlotCube>().AspectRatioMode = AspectRatioMode.MaintainRatios;
            sceneEx.First<ILPlotCube>().Rotation = Matrix4.Rotation(new Vector3(0.1, 0, 0), ILMath.pi / 2);
            ilPanelEx.Scene.Add(sceneEx);

            ResultSeekerEx.ValueChanged += ResultSeekerEx_ValueChanged;

            var sceneEy = new ILScene();
            plotEy = new ILPlotCube(twoDMode: false);
            sceneEy.Add(plotEy);
            var signalEy = ILMath.ones<float>(10, 10);
            ILSurface surfEy = new ILSurface(signalEy)
            {
                Wireframe = { Color = System.Drawing.Color.FromArgb(50, 60, 60, 60) },
                Colormap = Colormaps.Jet,
            };
            plotEy.Projection = Projection.Orthographic;
            plotEy.Position = new Vector3(1, 3, .5);
            //plotEy.AllowRotation = false;
            plotEy.Add(surfEy);
            sceneHy.First<ILPlotCube>().AspectRatioMode = AspectRatioMode.MaintainRatios;
            sceneHy.First<ILPlotCube>().Rotation = Matrix4.Rotation(new Vector3(0.1, 0, 0), ILMath.pi / 2);
            ilPanelEy.Scene.Add(sceneEy);

            ResultSeekerEy.ValueChanged += ResultSeekerEy_ValueChanged;
        }
        private void Display(LabelledSeries<Tuple<double, double>>[] dataSeries)
        {
            var scene = new ILScene();

            if (dataSeries == null)
                return;
            var PlotColors = new[] { Color.Blue, Color.Red, Color.Violet, Color.Brown, Color.Green, Color.Gold, Color.Olive };

            for (var i = 0; i < dataSeries.Length; i++)
            {
                var timeSeriesItem = dataSeries[i];
                var colorIndex = i % (PlotColors.Length - 1);
                var plotColor = PlotColors[colorIndex];
                var count = timeSeriesItem.Series.Length;
                if (count > 0)
                {
                    var plotCube = new ILPlotCube();
                    ILArray<float> array = GetMatrix(new[] { timeSeriesItem.Series.Select(s => (float)s.Item1).ToArray(), timeSeriesItem.Series.Select(s => (float)s.Item2).ToArray(), timeSeriesItem.Series.Select(s => (float)0).ToArray() });
                    plotCube.Add(new ILPoints
                    {
                        Positions = array,
                        Color = plotColor
                    });

                    scene.Add(plotCube);
                }
            }

            plotter.Scene = scene;
            plotter.Refresh();
        }
        /// <summary>
        /// Draws the adjusted function into a three-dimencional grid.
        /// </summary>
        private void draw3DShape()
        {
            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]);

            // Getting selected options for axes
            NumericOption firstOption = currentModel.getNumericOption(firstAxisCombobox.SelectedItem.ToString());
            NumericOption secondOption = currentModel.getNumericOption(secondAxisCombobox.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(firstOption.Name))
                        polishAdjusted[i] = "XMat";
                    else if (polishAdjusted[i].Equals(secondOption.Name))
                        polishAdjusted[i] = "YMat";
                    else
                    {
                        // All other options will be set on the value they have been set in the
                        // settings option.
                        NumericOption option = currentModel.getNumericOption(polishAdjusted[i]);

                        float value = 0;
                        numericSettings.TryGetValue(option, 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 the ranges of the axes
            ILArray<float> X, Y, A;
            ILPlotCube cube = new ILPlotCube(twoDMode: false);
            cube.Axes.XAxis.Label.Text = firstOption.Name;
            cube.Axes.YAxis.Label.Text = secondOption.Name;
            cube.Axes.ZAxis.Label.Text = PERFORMANCE_AXIS_LABEL;

            // Calculating the surface
            X = Array.ConvertAll(firstOption.getAllValues().ToArray(), x => (float)x);
            Y = Array.ConvertAll(secondOption.getAllValues().ToArray(), y => (float)y);

            ILArray<float> XMat = 1;
            ILArray<float> YMat = ILMath.meshgrid(Y, X, XMat);

            A = ILMath.zeros<float>(X.Length, Y.Length, 3);

            // Fill array with values
            A[":;:;0"] = calculateFunction(polishAdjusted,
                new string[] { "XMat", "YMat" }, new ILArray<float>[] { XMat, YMat });
            A[":;:;1"] = XMat;
            A[":;:;2"] = YMat;

            cube.Add(new ILSurface(A));

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

            // Saving the coordinates/values of the points for the measurements
            for (int i = 0; i < A.Size[0]; i++)
                for (int j = 0; j < A.Size[1]; j++)
                    for (int k = 0; k < A.Size[2]; k++)
                        calculatedPerformances[i, j, k] = A[i, j, k];

            // Calculating the points on the surface
            X = X.T;
            Y = Y.T;

            XMat = 1;
            YMat = ILMath.meshgrid(Y, X, XMat);

            ILArray<float> resultArray = calculateFunction(polishAdjusted,
                new string[] { "XMat", "YMat" }, new ILArray<float>[] { XMat, YMat }).GetArrayForRead();
            ILArray<float> xArray = XMat.GetArrayForRead();
            ILArray<float> yArray = YMat.GetArrayForRead();

            // Fill array with values
            A = ILMath.zeros<float>(3, resultArray.Length);
            A["0;:"] = xArray.T;
            A["1;:"] = yArray.T;
            A["2;:"] = resultArray.T;

            for (int i = 0; i < A.Size[1]; i++)
            {
                ILPoints point = createPoint(A[0, i], A[1, i], A[2, i], pointPositionLabel);

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

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

                cube.Add(point);
            }

            ilFunctionPanel.Scene = new ILScene()
                {
                    cube
                };
        }
        /// <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;
        }
        /// <summary>
        /// Updates the measurement tab of the application.
        /// 
        /// The method will check, if the preconditions are fulfilled (for example: Are there any
        /// loaded measurements?). Is not, an error message will be displayed. Is all preconditions
        /// are fulfilled, each IlPanel in the measurment tab will be recalculated and redrawn.
        /// </summary>
        private void updateMeasurementTab()
        {
            // Check if measurements are loaded
            if (!measurementsLoaded)
            {
                overviewPanel.Visible = false;
                bothGraphsPanel.Visible = false;
                measurementsOnlyPanel.Visible = false;
                absoluteDifferencePanel.Visible = false;
                relativeDifferencePanel.Visible = false;

                nfpValueCombobox.Enabled = false;
                measurementViewCombobox.Enabled = false;
                measurementErrorLabel.Visible = true;
                measurementErrorLabel.Text = ERROR_NO_MEASUREMENTS_LOADED;
                return;
            }

            // Check if a graph has been calculated before
            if (configurationForCalculation == null)
            {
                overviewPanel.Visible = false;
                bothGraphsPanel.Visible = false;
                measurementsOnlyPanel.Visible = false;
                absoluteDifferencePanel.Visible = false;
                relativeDifferencePanel.Visible = false;

                nfpValueCombobox.Enabled = false;
                measurementViewCombobox.Enabled = false;
                measurementErrorLabel.Visible = true;
                measurementErrorLabel.Text = ERROR_NO_PERFORMANCES;
                return;
            }

            // Check if the current configuration is possible
            if (!sat.checkConfigurationSAT(configurationForCalculation.BinaryOptions.Keys.ToList(), currentModel, true))
            {
                overviewPanel.Visible = false;
                bothGraphsPanel.Visible = false;
                measurementsOnlyPanel.Visible = false;
                absoluteDifferencePanel.Visible = false;
                relativeDifferencePanel.Visible = false;

                nfpValueCombobox.Enabled = false;
                measurementViewCombobox.Enabled = false;
                measurementErrorLabel.Visible = true;
                measurementErrorLabel.Text = ERROR_ILLEGAL_CONFIGURATION;
                return;
            }

            // Calculating all measured configurations that can be used
            List<Configuration> neededConfigurations = new List<Configuration>();

            foreach (Configuration conf in GlobalState.allMeasurements.Configurations)
            {
                bool insert = true;

                foreach (KeyValuePair<BinaryOption, BinaryOption.BinaryValue> entry in conf.BinaryOptions.ToList())
                    insert = insert && configurationForCalculation.BinaryOptions.ContainsKey(entry.Key);

                if (insert)
                {
                    foreach (KeyValuePair<NumericOption, double> pair in configurationForCalculation.NumericOptions.ToList())
                    {
                        double val;

                        if (conf.NumericOptions.TryGetValue(pair.Key, out val))
                            insert = insert && val == pair.Value;
                    }
                }

                if (insert)
                    neededConfigurations.Add(conf);
            }

            // Check if there are no measurements for the current settings
            if (neededConfigurations.Count == 0)
            {
                overviewPerformanceIlPanel.Scene = new ILScene();
                overviewMeasurementIlPanel.Scene = new ILScene();
                overviewAbsoluteDifferenceIlPanel.Scene = new ILScene();
                overviewRelativeDifferenceIlPanel.Scene = new ILScene();
                bothGraphsIlPanel.Scene = new ILScene();
                measurementsOnlyIlPanel.Scene = new ILScene();
                absoluteDifferenceIlPanel.Scene = new ILScene();
                relativeDifferenceIlPanel.Scene = new ILScene();
                overviewPerformanceIlPanel.Refresh();
                overviewMeasurementIlPanel.Refresh();
                overviewAbsoluteDifferenceIlPanel.Refresh();
                overviewRelativeDifferenceIlPanel.Refresh();
                bothGraphsIlPanel.Refresh();
                measurementsOnlyIlPanel.Refresh();
                absoluteDifferenceIlPanel.Refresh();
                relativeDifferenceIlPanel.Refresh();

                overviewPanel.Visible = false;
                bothGraphsPanel.Visible = false;
                measurementsOnlyPanel.Visible = false;
                absoluteDifferencePanel.Visible = false;
                relativeDifferencePanel.Visible = false;

                nfpValueCombobox.Enabled = false;
                measurementViewCombobox.Enabled = false;
                measurementErrorLabel.Visible = true;
                measurementErrorLabel.Text = ERROR_NO_MEASUREMENTS_AVAILABLE;
                return;
            }

            if (nfpValueCombobox.Items.Count == 0)
            {
                foreach (KeyValuePair<string, NFProperty> entry in GlobalState.nfProperties.ToList())
                    nfpValueCombobox.Items.Add(entry.Key);

                nfpValueCombobox.SelectedIndex = 0;
            }

            NFProperty prop = new NFProperty(nfpValueCombobox.SelectedItem.ToString());

            // Check if at least one configuration contains the current nfp value
            if(neededConfigurations.All(x => !x.nfpValues.Keys.Contains(prop)))
            {
                overviewPerformanceIlPanel.Scene = new ILScene();
                overviewMeasurementIlPanel.Scene = new ILScene();
                overviewAbsoluteDifferenceIlPanel.Scene = new ILScene();
                overviewRelativeDifferenceIlPanel.Scene = new ILScene();
                bothGraphsIlPanel.Scene = new ILScene();
                measurementsOnlyIlPanel.Scene = new ILScene();
                absoluteDifferenceIlPanel.Scene = new ILScene();
                relativeDifferenceIlPanel.Scene = new ILScene();
                overviewPerformanceIlPanel.Refresh();
                overviewMeasurementIlPanel.Refresh();
                overviewAbsoluteDifferenceIlPanel.Refresh();
                overviewRelativeDifferenceIlPanel.Refresh();
                bothGraphsIlPanel.Refresh();
                measurementsOnlyIlPanel.Refresh();
                absoluteDifferenceIlPanel.Refresh();
                relativeDifferenceIlPanel.Refresh();

                overviewPanel.Visible = false;
                bothGraphsPanel.Visible = false;
                measurementsOnlyPanel.Visible = false;
                absoluteDifferencePanel.Visible = false;
                relativeDifferencePanel.Visible = false;

                nfpValueCombobox.Enabled = true;
                measurementViewCombobox.Enabled = false;
                measurementErrorLabel.Visible = true;
                measurementErrorLabel.Text = ERROR_NO_MEASUREMENTS_NFP;
                return;
            }

            measurementErrorLabel.Visible = false;
            measurementViewCombobox.Enabled = true;
            nfpValueCombobox.Enabled = true;

            ILPlotCube bothGraphsCube, measurementsOnlyCube, absoluteDifferenceCube,
                relativeDifferenceCube, overviewPerformanceCube, overviewMeasurementsCube,
                overviewAbsoluteDifferenceCube, overviewRelativeDifferenceCube;

            // Decide if there has to be a 2D or 3D shape
            if (chosenOptions.Item2 == null)
            {
                // Define plot cubes
                bothGraphsCube = new ILPlotCube(twoDMode: true);
                measurementsOnlyCube = new ILPlotCube(twoDMode: true);
                absoluteDifferenceCube = new ILPlotCube(twoDMode: true);
                relativeDifferenceCube = new ILPlotCube(twoDMode: true);
                overviewPerformanceCube = new ILPlotCube(twoDMode: true);
                overviewMeasurementsCube = new ILPlotCube(twoDMode: true);
                overviewAbsoluteDifferenceCube = new ILPlotCube(twoDMode: true);
                overviewRelativeDifferenceCube = new ILPlotCube(twoDMode: true);

                bothGraphsCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                bothGraphsCube.Axes.YAxis.Label.Text = CORRESPONDING_VALUES_LABEL;
                measurementsOnlyCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                measurementsOnlyCube.Axes.YAxis.Label.Text = MEASURED_VALUE_LABEL;
                absoluteDifferenceCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                absoluteDifferenceCube.Axes.YAxis.Label.Text = ABSOLUTE_DIFFERENCE_LABEL;
                relativeDifferenceCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                relativeDifferenceCube.Axes.YAxis.Label.Text = RELATIVE_DIFFERENCE_LABEL;
                overviewPerformanceCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                overviewPerformanceCube.Axes.YAxis.Label.Text = PERFORMANCE_AXIS_LABEL;
                overviewMeasurementsCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                overviewMeasurementsCube.Axes.YAxis.Label.Text = MEASURED_VALUE_LABEL;
                overviewAbsoluteDifferenceCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                overviewAbsoluteDifferenceCube.Axes.YAxis.Label.Text = ABSOLUTE_DIFFERENCE_LABEL;
                overviewRelativeDifferenceCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                overviewRelativeDifferenceCube.Axes.YAxis.Label.Text = RELATIVE_DIFFERENCE_LABEL;

                // Add all values into the array
                ILArray<float> XY = ILMath.zeros<float>(0, 0);
                ILArray<float> absoluteDifferences = ILMath.zeros<float>(0, 0);
                ILArray<float> relativeDifferences = ILMath.zeros<float>(0, 0);
                List<double> values = chosenOptions.Item1.getAllValues();
                values.Sort();

                int pos = 0;

                foreach (double value in values)
                {
                    Configuration c = null;
                    double d;

                    // Get the measurement for the current settings
                    for (int j = 0; j < neededConfigurations.Count && c == null; j++)
                    {
                        neededConfigurations[j].NumericOptions.TryGetValue(chosenOptions.Item1, out d);

                        if (d == value)
                            c = neededConfigurations[j];
                    }

                    if (c == null || !c.nfpValues.TryGetValue(prop, out d))
                    {
                        // If there are no measurements for this specific setting, the line plots
                        // have to be drawn up to this point.
                        if (XY.Size[0] > 0)
                        {
                            bothGraphsCube.Add(new ILLinePlot(XY)
                            {
                                ColorOverride = measurementColor
                            });
                            measurementsOnlyCube.Add(new ILLinePlot(XY)
                            {
                                ColorOverride = measurementColor
                            });
                            absoluteDifferenceCube.Add(new ILLinePlot(absoluteDifferences));
                            relativeDifferenceCube.Add(new ILLinePlot(relativeDifferences));
                            overviewMeasurementsCube.Add(new ILLinePlot(XY)
                            {
                                ColorOverride = measurementColor
                            });
                            overviewAbsoluteDifferenceCube.Add(new ILLinePlot(absoluteDifferences));
                            overviewRelativeDifferenceCube.Add(new ILLinePlot(relativeDifferences));

                            XY = ILMath.zeros<float>(0, 0);
                            absoluteDifferences = ILMath.zeros<float>(0, 0);
                            relativeDifferences = ILMath.zeros<float>(0, 0);
                            pos = 0;
                        }
                    }
                    else
                    {
                        // Calculate all values for the corresponding line plots.
                        XY[0, pos] = (float)value;
                        XY[1, pos] = (float)d;
                        absoluteDifferences[0, pos] = (float)value;
                        absoluteDifferences[1, pos] = ILMath.abs((float)d - calculatedPerformances[1, values.IndexOf(value)]);
                        relativeDifferences[0, pos] = (float)value;

                        if (ILMath.abs(XY[1, pos]) < 1)
                            relativeDifferences[1, pos] = absoluteDifferences[1, pos] == XY[1, pos] ? 0 : 100;
                        else
                            relativeDifferences[1, pos] = absoluteDifferences[1, pos] >= 1 ? absoluteDifferences[1, pos]/XY[1, pos] * 100 : 0;

                        ILPoints point = createPoint(XY[0, pos], XY[1, pos], 0, measurementPointLabel);

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

                            measurementPointLabel.Text = chosenOptions.Item1.Name + ": " + coor.X.ToString() + ", " + PERFORMANCE_AXIS_LABEL + ": " + coor.Y.ToString();
                            measurementPointLabel.Visible = true;
                        };

                        pos++;

                        bothGraphsCube.Add(point);
                        measurementsOnlyCube.Add(point);
                    }
                }

                // Insert all remaining line plot parts into the corresponding cubes.
                bothGraphsCube.Add(new ILLinePlot(XY)
                {
                    ColorOverride = measurementColor
                });
                bothGraphsCube.Add(new ILLinePlot(drawnPerformances)
                {
                    Line =
                    {
                        Color = calculatedColor,
                        DashStyle = DashStyle.Dashed
                    }
                });
                measurementsOnlyCube.Add(new ILLinePlot(XY)
                {
                    ColorOverride = measurementColor
                });
                absoluteDifferenceCube.Add(new ILLinePlot(absoluteDifferences));
                absoluteDifferenceCube.Add(new ILLinePlot(ILMath.zeros<float>(1, 1)));
                relativeDifferenceCube.Add(new ILLinePlot(relativeDifferences));
                relativeDifferenceCube.Add(new ILLinePlot(ILMath.zeros<float>(1, 1)));

                overviewPerformanceCube.Add(new ILLinePlot(drawnPerformances)
                {
                    ColorOverride = calculatedColor
                });
                overviewMeasurementsCube.Add(new ILLinePlot(XY)
                {
                    ColorOverride = measurementColor
                });
                overviewAbsoluteDifferenceCube.Add(new ILLinePlot(absoluteDifferences));
                overviewAbsoluteDifferenceCube.Add(new ILLinePlot(ILMath.zeros<float>(1, 1)));
                overviewRelativeDifferenceCube.Add(new ILLinePlot(relativeDifferences));
                overviewRelativeDifferenceCube.Add(new ILLinePlot(ILMath.zeros<float>(1, 1)));
            }
            else
            {
                ILArray<float> measurements, X, Y, absoluteDifferences, relativeDifferences;

                // Define all plot cubes
                bothGraphsCube = new ILPlotCube(twoDMode: false);
                measurementsOnlyCube = new ILPlotCube(twoDMode: false);
                absoluteDifferenceCube = new ILPlotCube(twoDMode: false);
                relativeDifferenceCube = new ILPlotCube(twoDMode: false);
                overviewPerformanceCube = new ILPlotCube(twoDMode: false);
                overviewMeasurementsCube = new ILPlotCube(twoDMode: false);
                overviewAbsoluteDifferenceCube = new ILPlotCube(twoDMode: false);
                overviewRelativeDifferenceCube = new ILPlotCube(twoDMode: false);

                bothGraphsCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                bothGraphsCube.Axes.YAxis.Label.Text = chosenOptions.Item2.Name;
                bothGraphsCube.Axes.ZAxis.Label.Text = CORRESPONDING_VALUES_LABEL;
                measurementsOnlyCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                measurementsOnlyCube.Axes.YAxis.Label.Text = chosenOptions.Item2.Name;
                measurementsOnlyCube.Axes.ZAxis.Label.Text = MEASURED_VALUE_LABEL;
                absoluteDifferenceCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                absoluteDifferenceCube.Axes.YAxis.Label.Text = chosenOptions.Item2.Name;
                absoluteDifferenceCube.Axes.ZAxis.Label.Text = ABSOLUTE_DIFFERENCE_LABEL;
                relativeDifferenceCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                relativeDifferenceCube.Axes.YAxis.Label.Text = chosenOptions.Item2.Name;
                relativeDifferenceCube.Axes.ZAxis.Label.Text = RELATIVE_DIFFERENCE_LABEL;
                overviewPerformanceCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                overviewPerformanceCube.Axes.YAxis.Label.Text = chosenOptions.Item2.Name;
                overviewPerformanceCube.Axes.ZAxis.Label.Text = PERFORMANCE_AXIS_LABEL;
                overviewMeasurementsCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                overviewMeasurementsCube.Axes.YAxis.Label.Text = chosenOptions.Item2.Name;
                overviewMeasurementsCube.Axes.ZAxis.Label.Text = MEASURED_VALUE_LABEL;
                overviewAbsoluteDifferenceCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                overviewAbsoluteDifferenceCube.Axes.YAxis.Label.Text = chosenOptions.Item2.Name;
                overviewAbsoluteDifferenceCube.Axes.ZAxis.Label.Text = ABSOLUTE_DIFFERENCE_LABEL;
                overviewRelativeDifferenceCube.Axes.XAxis.Label.Text = chosenOptions.Item1.Name;
                overviewRelativeDifferenceCube.Axes.YAxis.Label.Text = chosenOptions.Item2.Name;
                overviewRelativeDifferenceCube.Axes.ZAxis.Label.Text = RELATIVE_DIFFERENCE_LABEL;

                // Initialize and fill all arrays
                X = Array.ConvertAll(chosenOptions.Item1.getAllValues().ToArray(), x => (float)x);
                Y = Array.ConvertAll(chosenOptions.Item2.getAllValues().ToArray(), y => (float)y);

                ILArray<float> XMat = 1;
                ILArray<float> YMat = ILMath.meshgrid(Y, X, XMat);

                measurements = ILMath.zeros<float>(X.Length, Y.Length, 3);
                absoluteDifferences = ILMath.zeros<float>(X.Length, Y.Length, 3);
                relativeDifferences = ILMath.zeros<float>(X.Length, Y.Length, 3);

                measurements[":;:;1"] = XMat;
                measurements[":;:;2"] = YMat;

                List<double> valuesX = chosenOptions.Item1.getAllValues();
                List<double> valuesY = chosenOptions.Item2.getAllValues();
                valuesX.Sort();
                valuesY.Sort();

                // Read every possible measurement value. If there is none, the corresponding value will
                /// be set to negative infinity.
                for (int i = 0; i < valuesX.Count; i++)
                {
                    for(int j = 0; j < valuesY.Count; j++)
                    {
                        Configuration c = null;
                        double d1, d2;

                        for (int k = 0; k < neededConfigurations.Count && c == null; k++)
                        {
                            neededConfigurations[k].NumericOptions.TryGetValue(chosenOptions.Item1, out d1);
                            neededConfigurations[k].NumericOptions.TryGetValue(chosenOptions.Item2, out d2);

                            if (d1 == valuesX[i] && d2 == valuesY[j])
                                c = neededConfigurations[k];
                        }

                        if (c == null || !c.nfpValues.TryGetValue(prop, out d1))
                            measurements[i, j, 0] = float.NegativeInfinity;
                        else
                        {
                            measurements[i, j, 0] = (float)d1;

                            ILPoints point = createPoint(measurements[i, j, 1], measurements[i, j, 2], measurements[i, j, 0], measurementPointLabel);

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

                                measurementPointLabel.Text = chosenOptions.Item1.Name + ": " + coor.X.ToString() + ", " + chosenOptions.Item2.Name + ": " + coor.Y.ToString() + ", " + PERFORMANCE_AXIS_LABEL + ": " + coor.Z.ToString();
                                measurementPointLabel.Visible = true;
                            };

                            bothGraphsCube.Add(point);
                            measurementsOnlyCube.Add(point);
                        }
                    }
                }

                // Calculate all absolute and relative differences.
                for (int i = 0; i < measurements.Size[0]; i++)
                {
                    for (int j = 0; j < measurements.Size[1]; j++)
                    {
                        absoluteDifferences[i, j, 0] = measurements[i, j, 0] == float.NegativeInfinity
                            ? float.NegativeInfinity : Math.Abs(measurements[i, j, 0].GetArrayForRead()[0] - calculatedPerformances[i, j, 0].GetArrayForRead()[0]);
                        absoluteDifferences[i, j, 1] = measurements[i, j, 1].GetArrayForRead()[0];
                        absoluteDifferences[i, j, 2] = measurements[i, j, 2].GetArrayForRead()[0];

                        if (measurements[i, j, 0] == float.NegativeInfinity)
                            relativeDifferences[i, j, 0] = float.NegativeInfinity;
                        else if (measurements[i, j, 0] == 0)
                            relativeDifferences[i, j, 0] = absoluteDifferences[i, j, 0] == 0 ? 0 : 100;
                        else
                            relativeDifferences[i, j, 0] = absoluteDifferences[i, j, 0] >= 1 ? absoluteDifferences[i, j, 0] / measurements[i, j, 0] * 100 : 0;

                        relativeDifferences[i, j, 1] = measurements[i, j, 1].GetArrayForRead()[0];
                        relativeDifferences[i, j, 2] = measurements[i, j, 2].GetArrayForRead()[0];
                    }
                }

                // Insert all information into the cubes
                bothGraphsCube.Add(new ILSurface(measurements)
                    {
                        ColorMode = ILSurface.ColorModes.Solid
                    }
                );
                bothGraphsCube.Add(new ILSurface(calculatedPerformances));
                measurementsOnlyCube.Add(new ILSurface(measurements)
                    {
                        ColorMode = ILSurface.ColorModes.Solid
                    }
                );
                absoluteDifferenceCube.Add(new ILSurface(absoluteDifferences)
                {
                    Children = { new ILColorbar() }
                });
                absoluteDifferenceCube.Add(new ILSurface(ILMath.zeros<float>(3, 3, 3)));
                relativeDifferenceCube.Add(new ILSurface(relativeDifferences)
                {
                    Children = { new ILColorbar() }
                });
                relativeDifferenceCube.Add(new ILSurface(ILMath.zeros<float>(3, 3, 3)));
                overviewPerformanceCube.Add(new ILSurface(calculatedPerformances));
                overviewMeasurementsCube.Add(new ILSurface(measurements)
                {
                    ColorMode = ILSurface.ColorModes.Solid
                });
                overviewMeasurementsCube.Add(new ILSurface(ILMath.zeros<float>(3, 3, 3)));
                overviewAbsoluteDifferenceCube.Add(new ILSurface(absoluteDifferences));
                overviewAbsoluteDifferenceCube.Add(new ILSurface(ILMath.zeros<float>(3, 3, 3)));
                overviewRelativeDifferenceCube.Add(new ILSurface(relativeDifferences));
                overviewRelativeDifferenceCube.Add(new ILSurface(ILMath.zeros<float>(3, 3, 3)));

                // Adding events for a synchronized rotation of the overview cubes
                overviewPerformanceCube.MouseMove += (s, e) =>
                {
                    ILPlotCube cube = overviewPerformanceIlPanel.GetCurrentScene().First<ILPlotCube>();
                    Matrix4 matrix = cube.Rotation;

                    overviewMeasurementsCube.Rotation = matrix;
                    overviewAbsoluteDifferenceCube.Rotation = matrix;
                    overviewRelativeDifferenceCube.Rotation = matrix;

                    overviewMeasurementIlPanel.Refresh();
                    overviewAbsoluteDifferenceIlPanel.Refresh();
                    overviewRelativeDifferenceIlPanel.Refresh();
                };

                overviewMeasurementsCube.MouseMove += (s, e) =>
                {
                    ILPlotCube cube = overviewMeasurementIlPanel.GetCurrentScene().First<ILPlotCube>();
                    Matrix4 matrix = cube.Rotation;

                    overviewPerformanceCube.Rotation = matrix;
                    overviewAbsoluteDifferenceCube.Rotation = matrix;
                    overviewRelativeDifferenceCube.Rotation = matrix;

                    overviewPerformanceIlPanel.Refresh();
                    overviewAbsoluteDifferenceIlPanel.Refresh();
                    overviewRelativeDifferenceIlPanel.Refresh();
                };

                overviewAbsoluteDifferenceCube.MouseMove += (s, e) =>
                {
                    ILPlotCube cube = overviewAbsoluteDifferenceIlPanel.GetCurrentScene().First<ILPlotCube>();
                    Matrix4 matrix = cube.Rotation;

                    overviewPerformanceCube.Rotation = matrix;
                    overviewMeasurementsCube.Rotation = matrix;
                    overviewRelativeDifferenceCube.Rotation = matrix;

                    overviewPerformanceIlPanel.Refresh();
                    overviewMeasurementIlPanel.Refresh();
                    overviewRelativeDifferenceIlPanel.Refresh();
                };

                overviewRelativeDifferenceCube.MouseMove += (s, e) =>
                {
                    ILPlotCube cube = overviewRelativeDifferenceIlPanel.GetCurrentScene().First<ILPlotCube>();
                    Matrix4 matrix = cube.Rotation;

                    overviewPerformanceCube.Rotation = matrix;
                    overviewMeasurementsCube.Rotation = matrix;
                    overviewAbsoluteDifferenceCube.Rotation = matrix;

                    overviewPerformanceIlPanel.Refresh();
                    overviewMeasurementIlPanel.Refresh();
                    overviewAbsoluteDifferenceIlPanel.Refresh();
                };
            }

            overviewPerformanceIlPanel.Scene = new ILScene { overviewPerformanceCube };
            overviewMeasurementIlPanel.Scene = new ILScene { overviewMeasurementsCube };
            overviewAbsoluteDifferenceIlPanel.Scene = new ILScene { overviewAbsoluteDifferenceCube };
            overviewRelativeDifferenceIlPanel.Scene = new ILScene { overviewRelativeDifferenceCube };
            bothGraphsIlPanel.Scene = new ILScene { bothGraphsCube };
            measurementsOnlyIlPanel.Scene = new ILScene { measurementsOnlyCube };
            absoluteDifferenceIlPanel.Scene = new ILScene { absoluteDifferenceCube };
            relativeDifferenceIlPanel.Scene = new ILScene { relativeDifferenceCube };

            overviewPerformanceIlPanel.Refresh();
            overviewMeasurementIlPanel.Refresh();
            overviewAbsoluteDifferenceIlPanel.Refresh();
            overviewRelativeDifferenceIlPanel.Refresh();
            bothGraphsIlPanel.Refresh();
            measurementsOnlyIlPanel.Refresh();
            absoluteDifferenceIlPanel.Refresh();
            relativeDifferenceIlPanel.Refresh();

            updateMeasurementPanel();
        }
Beispiel #11
0
        private void PlotByNodesPoints(
            DenseMatrix dmListOfData,
            Dictionary <string, object> properties,
            string description = "")
        {
            strDataDescription = description;
            ThreadSafeOperations.SetText(lblDescription, strDataDescription, false);

            defaultProperties  = properties;
            strOutputDirectory = (string)defaultProperties["DefaultDataFilesLocation"];
            if (!ServiceTools.CheckIfDirectoryExists(strOutputDirectory))
            {
                strOutputDirectory = "";
            }

            dmDataList = dmListOfData.Copy();
            double dataMaxVal = dmDataList.Column(3).Max();
            double dataMinVal = dmDataList.Column(3).Min();

            ILScene scene = new ILScene();

            currSurfPlotCube          = new ILPlotCube();
            currSurfPlotCube.TwoDMode = false;

            ILArray <float> A =
                ILMath.tosingle((ILArray <double>)(dmDataList.SubMatrix(0, dmDataList.RowCount, 0, 3).ToArray()));

            ILArray <float> colors = ILMath.zeros <float>(4, dmDataList.RowCount);

            ColorScheme newCS = new ColorScheme("");


            double[] dvRvalues = DenseVector.Create(dmDataList.RowCount, (r) =>
            {
                Bgr currColor = newCS.GetColorByValueAndRange(dmDataList[r, 3], dataMinVal, dataMaxVal);
                return(currColor.Red / 255.0d);
            }).ToArray();
            double[] dvGvalues = DenseVector.Create(dmDataList.RowCount, (r) =>
            {
                Bgr currColor = newCS.GetColorByValueAndRange(dmDataList[r, 3], dataMinVal, dataMaxVal);
                return(currColor.Green / 255.0d);
            }).ToArray();
            double[] dvBvalues = DenseVector.Create(dmDataList.RowCount, (r) =>
            {
                Bgr currColor = newCS.GetColorByValueAndRange(dmDataList[r, 3], dataMinVal, dataMaxVal);
                return(currColor.Blue / 255.0d);
            }).ToArray();
            colors["0;:"] = ILMath.tosingle((ILArray <double>)dvRvalues);
            colors["1;:"] = ILMath.tosingle((ILArray <double>)dvGvalues);
            colors["2;:"] = ILMath.tosingle((ILArray <double>)dvBvalues);
            colors["3;:"] = 0.5f;

            ILPoints pts = new ILPoints
            {
                Positions = A,
                Colors    = colors,
            };

            pts.Color = null;
            currSurfPlotCube.Add(pts);

            currSurfPlotCube.Projection = Projection.Orthographic;
            currSurfPlotCube.Rotation   = Matrix4.Rotation(new Vector3(1, 1, 1), 0.5f);
            currSurfPlotCube.Plots.Reset();
            scene.Add(currSurfPlotCube);

            ilPanel1.Scene = scene;
        }
Beispiel #12
0
        public void SetSurface()
        {
            points = new ILPoints();
            points.Size = 10;
            points.Color = null;

            scene = new ILScene();
            plotCube = new ILPlotCube(twoDMode: false);

            surface = new ILSurface(
                            (x, y) =>
                            {
                                return Calculate(new double[] { x, y });
                            },
                            xmin: Min, xmax: Max, xlen: 100,
                            ymin: YMin, ymax: YMax, ylen: 100,
                            colormap: Colormaps.ILNumerics
                        );

            plotCube.Add(surface);
        }